diff --git a/src/video_engine/vie_image_process_impl.cc b/src/video_engine/vie_image_process_impl.cc index 1ab4a85d03..05e7e8893f 100644 --- a/src/video_engine/vie_image_process_impl.cc +++ b/src/video_engine/vie_image_process_impl.cc @@ -8,389 +8,271 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * vie_image_process_impl.cpp - */ -#include "vie_image_process_impl.h" +#include "video_engine/vie_image_process_impl.h" -// Defines -#include "vie_defines.h" +#include "system_wrappers/interface/trace.h" +#include "video_engine/main/interface/vie_errors.h" +#include "video_engine/vie_capturer.h" +#include "video_engine/vie_channel.h" +#include "video_engine/vie_channel_manager.h" +#include "video_engine/vie_defines.h" +#include "video_engine/vie_encoder.h" +#include "video_engine/vie_impl.h" +#include "video_engine/vie_input_manager.h" -#include "trace.h" -#include "vie_errors.h" -#include "vie_impl.h" -#include "vie_channel.h" -#include "vie_channel_manager.h" -#include "vie_encoder.h" -#include "vie_input_manager.h" -#include "vie_capturer.h" +namespace webrtc { -namespace webrtc -{ - -// ---------------------------------------------------------------------------- -// GetInterface -// ---------------------------------------------------------------------------- - -ViEImageProcess* ViEImageProcess::GetInterface(VideoEngine* videoEngine) -{ +ViEImageProcess* ViEImageProcess::GetInterface(VideoEngine* video_engine) { #ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API - if (videoEngine == NULL) - { - return NULL; - } - VideoEngineImpl* vieImpl = reinterpret_cast (videoEngine); - ViEImageProcessImpl* vieImageProcessImpl = vieImpl; - (*vieImageProcessImpl)++; // Increase ref count - - return vieImageProcessImpl; -#else + if (!video_engine) { return NULL; + } + VideoEngineImpl* vie_impl = reinterpret_cast(video_engine); + ViEImageProcessImpl* vie_image_process_impl = vie_impl; + // Increase ref count. + (*vie_image_process_impl)++; + return vie_image_process_impl; +#else + return NULL; #endif } -// ---------------------------------------------------------------------------- -// Release -// -// Releases the interface, i.e. reduces the reference counter. The number of -// remaining references is returned, -1 if released too many times. -// ---------------------------------------------------------------------------- - -int ViEImageProcessImpl::Release() -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, instance_id_, +int ViEImageProcessImpl::Release() { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_, "ViEImageProcess::Release()"); - (*this)--; // Decrease ref count + // Decrease ref count. + (*this)--; - WebRtc_Word32 refCount = GetCount(); - if (refCount < 0) - { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, instance_id_, - "ViEImageProcess release too many times"); - SetLastError(kViEAPIDoesNotExist); - return -1; - } - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, instance_id_, - "ViEImageProcess reference count: %d", refCount); - return refCount; + WebRtc_Word32 ref_count = GetCount(); + if (ref_count < 0) { + WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_, + "ViEImageProcess release too many times"); + SetLastError(kViEAPIDoesNotExist); + return -1; + } + WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_, + "ViEImageProcess reference count: %d", ref_count); + return ref_count; } -// ---------------------------------------------------------------------------- -// Constructor -// ---------------------------------------------------------------------------- - -ViEImageProcessImpl::ViEImageProcessImpl() -{ - WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_, +ViEImageProcessImpl::ViEImageProcessImpl() { + WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_, "ViEImageProcessImpl::ViEImageProcessImpl() Ctor"); } -// ---------------------------------------------------------------------------- -// Destructor -// ---------------------------------------------------------------------------- - -ViEImageProcessImpl::~ViEImageProcessImpl() -{ - WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_, +ViEImageProcessImpl::~ViEImageProcessImpl() { + WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_, "ViEImageProcessImpl::~ViEImageProcessImpl() Dtor"); } -// ============================================================================ -// Effect filter -// ============================================================================ - -// ---------------------------------------------------------------------------- -// RegisterCaptureEffectFilter -// -// Registers an effect filter for a capture device -// ---------------------------------------------------------------------------- - int ViEImageProcessImpl::RegisterCaptureEffectFilter( - const int captureId, ViEEffectFilter& captureFilter) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(captureId: %d)", __FUNCTION__, captureId); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } + const int capture_id, + ViEEffectFilter& capture_filter) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(capture_id: %d)", __FUNCTION__, capture_id); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } - ViEInputManagerScoped is(input_manager_); - ViECapturer* vieCapture = is.Capture(captureId); - if (vieCapture == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Capture device %d doesn't exist", __FUNCTION__, - captureId); - SetLastError(kViEImageProcessInvalidCaptureId); - return -1; - } - - if (vieCapture->RegisterEffectFilter(&captureFilter) != 0) - { - SetLastError(kViEImageProcessFilterExists); - return -1; - } - return 0; + ViEInputManagerScoped is(input_manager_); + ViECapturer* vie_capture = is.Capture(capture_id); + if (!vie_capture) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Capture device %d doesn't exist", __FUNCTION__, + capture_id); + SetLastError(kViEImageProcessInvalidCaptureId); + return -1; + } + if (vie_capture->RegisterEffectFilter(&capture_filter) != 0) { + SetLastError(kViEImageProcessFilterExists); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// DeregisterCaptureEffectFilter -// -// Deregisters a previously set fffect filter -// ---------------------------------------------------------------------------- +int ViEImageProcessImpl::DeregisterCaptureEffectFilter(const int capture_id) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(capture_id: %d)", __FUNCTION__, capture_id); -int ViEImageProcessImpl::DeregisterCaptureEffectFilter(const int captureId) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(captureId: %d)", __FUNCTION__, captureId); - - ViEInputManagerScoped is(input_manager_); - ViECapturer* vieCapture = is.Capture(captureId); - if (vieCapture == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Capture device %d doesn't exist", __FUNCTION__, - captureId); - SetLastError(kViEImageProcessInvalidCaptureId); - return -1; - } - if (vieCapture->RegisterEffectFilter(NULL) != 0) - { - SetLastError(kViEImageProcessFilterDoesNotExist); - return -1; - } - return 0; + ViEInputManagerScoped is(input_manager_); + ViECapturer* vie_capture = is.Capture(capture_id); + if (!vie_capture) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Capture device %d doesn't exist", __FUNCTION__, + capture_id); + SetLastError(kViEImageProcessInvalidCaptureId); + return -1; + } + if (vie_capture->RegisterEffectFilter(NULL) != 0) { + SetLastError(kViEImageProcessFilterDoesNotExist); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// RegisterSendEffectFilter -// -// Registers an effect filter for a channel -// ---------------------------------------------------------------------------- +int ViEImageProcessImpl::RegisterSendEffectFilter( + const int video_channel, + ViEEffectFilter& send_filter) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(video_channel: %d)", __FUNCTION__, video_channel); -int ViEImageProcessImpl::RegisterSendEffectFilter(const int videoChannel, - ViEEffectFilter& sendFilter) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(videoChannel: %d)", __FUNCTION__, videoChannel); + ViEChannelManagerScoped cs(channel_manager_); + ViEEncoder* vie_encoder = cs.Encoder(video_channel); + if (vie_encoder == NULL) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); + SetLastError(kViEImageProcessInvalidChannelId); + return -1; + } - ViEChannelManagerScoped cs(channel_manager_); - ViEEncoder* vieEncoder = cs.Encoder(videoChannel); - if (vieEncoder == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Channel %d doesn't exist", __FUNCTION__, videoChannel); - SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - - if (vieEncoder->RegisterEffectFilter(&sendFilter) != 0) - { - SetLastError(kViEImageProcessFilterExists); - return -1; - } - return 0; + if (vie_encoder->RegisterEffectFilter(&send_filter) != 0) { + SetLastError(kViEImageProcessFilterExists); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// DeregisterSendEffectFilter -// -// Deregisters a previously set effect filter -// ---------------------------------------------------------------------------- +int ViEImageProcessImpl::DeregisterSendEffectFilter(const int video_channel) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(video_channel: %d)", __FUNCTION__, video_channel); -int ViEImageProcessImpl::DeregisterSendEffectFilter(const int videoChannel) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(videoChannel: %d)", __FUNCTION__, videoChannel); - - ViEChannelManagerScoped cs(channel_manager_); - ViEEncoder* vieEncoder = cs.Encoder(videoChannel); - if (vieEncoder == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Channel %d doesn't exist", __FUNCTION__, videoChannel); - SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - if (vieEncoder->RegisterEffectFilter(NULL) != 0) - { - SetLastError(kViEImageProcessFilterDoesNotExist); - return -1; - } - return 0; + ViEChannelManagerScoped cs(channel_manager_); + ViEEncoder* vie_encoder = cs.Encoder(video_channel); + if (vie_encoder == NULL) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); + SetLastError(kViEImageProcessInvalidChannelId); + return -1; + } + if (vie_encoder->RegisterEffectFilter(NULL) != 0) { + SetLastError(kViEImageProcessFilterDoesNotExist); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// RegisterRenderEffectFilter -// -// Registers an effect filter for an incoming decoded stream -// ---------------------------------------------------------------------------- - int ViEImageProcessImpl::RegisterRenderEffectFilter( - const int videoChannel, ViEEffectFilter& renderFilter) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(videoChannel: %d)", __FUNCTION__, videoChannel); + const int video_channel, + ViEEffectFilter& render_filter) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(video_channel: %d)", __FUNCTION__, video_channel); - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* vieChannel = cs.Channel(videoChannel); - if (vieChannel == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Channel %d doesn't exist", __FUNCTION__, videoChannel); - SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - - if (vieChannel->RegisterEffectFilter(&renderFilter) != 0) - { - SetLastError(kViEImageProcessFilterExists); - return -1; - } - return 0; + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); + SetLastError(kViEImageProcessInvalidChannelId); + return -1; + } + if (vie_channel->RegisterEffectFilter(&render_filter) != 0) { + SetLastError(kViEImageProcessFilterExists); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// DeregisterRenderEffectFilter -// -// ---------------------------------------------------------------------------- +int ViEImageProcessImpl::DeregisterRenderEffectFilter(const int video_channel) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(video_channel: %d)", __FUNCTION__, video_channel); -int ViEImageProcessImpl::DeregisterRenderEffectFilter(const int videoChannel) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(videoChannel: %d)", __FUNCTION__, videoChannel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); + SetLastError(kViEImageProcessInvalidChannelId); + return -1; + } - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* vieChannel = cs.Channel(videoChannel); - if (vieChannel == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Channel %d doesn't exist", __FUNCTION__, videoChannel); - SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - - if (vieChannel->RegisterEffectFilter(NULL) != 0) - { - SetLastError(kViEImageProcessFilterDoesNotExist); - return -1; - } - return 0; + if (vie_channel->RegisterEffectFilter(NULL) != 0) { + SetLastError(kViEImageProcessFilterDoesNotExist); + return -1; + } + return 0; } -// ============================================================================ -// Image enhancement -// ============================================================================ - -// ---------------------------------------------------------------------------- -// EnableDeflickering -// -// Enables/disables deflickering of the captured image. -// ---------------------------------------------------------------------------- - -int ViEImageProcessImpl::EnableDeflickering(const int captureId, - const bool enable) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(captureId: %d, enable: %d)", __FUNCTION__, captureId, enable); - - ViEInputManagerScoped is(input_manager_); - ViECapturer* vieCapture = is.Capture(captureId); - if (vieCapture == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Capture device %d doesn't exist", __FUNCTION__, - captureId); - SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - - if (vieCapture->EnableDeflickering(enable) != 0) - { - if (enable) - SetLastError(kViEImageProcessAlreadyEnabled); - else - { - SetLastError(kViEImageProcessAlreadyDisabled); - } - return -1; - } - return 0; -} - -// ---------------------------------------------------------------------------- -// EnableDenoising -// -// Enables/disables denoising of the captured image. -// ---------------------------------------------------------------------------- - -int ViEImageProcessImpl::EnableDenoising(const int captureId, const bool enable) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(captureId: %d, enable: %d)", __FUNCTION__, captureId, enable); - - ViEInputManagerScoped is(input_manager_); - ViECapturer* vieCapture = is.Capture(captureId); - if (vieCapture == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Capture device %d doesn't exist", __FUNCTION__, - captureId); - SetLastError(kViEImageProcessInvalidCaptureId); - return -1; - } - - if (vieCapture->EnableDenoising(enable) != 0) - { - if (enable) - SetLastError(kViEImageProcessAlreadyEnabled); - else - { - SetLastError(kViEImageProcessAlreadyDisabled); - } - return -1; - } - return 0; - -} - -// ---------------------------------------------------------------------------- -// EnableColorEnhancement -// -// Enables coloe enhancement for decoded images -// ---------------------------------------------------------------------------- - -int ViEImageProcessImpl::EnableColorEnhancement(const int videoChannel, - const bool enable) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s(videoChannel: %d, enable: %d)", __FUNCTION__, videoChannel, +int ViEImageProcessImpl::EnableDeflickering(const int capture_id, + const bool enable) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(capture_id: %d, enable: %d)", __FUNCTION__, capture_id, enable); - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* vieChannel = cs.Channel(videoChannel); - if (vieChannel == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Channel %d doesn't exist", __FUNCTION__, videoChannel); - SetLastError(kViEImageProcessInvalidChannelId); - return -1; + ViEInputManagerScoped is(input_manager_); + ViECapturer* vie_capture = is.Capture(capture_id); + if (!vie_capture) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Capture device %d doesn't exist", __FUNCTION__, + capture_id); + SetLastError(kViEImageProcessInvalidChannelId); + return -1; + } + + if (vie_capture->EnableDeflickering(enable) != 0) { + if (enable) { + SetLastError(kViEImageProcessAlreadyEnabled); + } else { + SetLastError(kViEImageProcessAlreadyDisabled); } - if (vieChannel->EnableColorEnhancement(enable) != 0) - { - if (enable) - SetLastError(kViEImageProcessAlreadyEnabled); - else - { - SetLastError(kViEImageProcessAlreadyDisabled); - } - return -1; - } - return 0; + return -1; + } + return 0; } -} // namespace webrtc + +int ViEImageProcessImpl::EnableDenoising(const int capture_id, + const bool enable) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(capture_id: %d, enable: %d)", __FUNCTION__, capture_id, + enable); + + ViEInputManagerScoped is(input_manager_); + ViECapturer* vie_capture = is.Capture(capture_id); + if (!vie_capture) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Capture device %d doesn't exist", __FUNCTION__, + capture_id); + SetLastError(kViEImageProcessInvalidCaptureId); + return -1; + } + + if (vie_capture->EnableDenoising(enable) != 0) { + if (enable) { + SetLastError(kViEImageProcessAlreadyEnabled); + } else { + SetLastError(kViEImageProcessAlreadyDisabled); + } + return -1; + } + return 0; +} + +int ViEImageProcessImpl::EnableColorEnhancement(const int video_channel, + const bool enable) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s(video_channel: %d, enable: %d)", __FUNCTION__, video_channel, + enable); + + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Channel %d doesn't exist", __FUNCTION__, video_channel); + SetLastError(kViEImageProcessInvalidChannelId); + return -1; + } + if (vie_channel->EnableColorEnhancement(enable) != 0) { + if (enable) { + SetLastError(kViEImageProcessAlreadyEnabled); + } else { + SetLastError(kViEImageProcessAlreadyDisabled); + } + return -1; + } + return 0; +} + +} // namespace webrtc diff --git a/src/video_engine/vie_image_process_impl.h b/src/video_engine/vie_image_process_impl.h index d7494da4ad..6666625b79 100644 --- a/src/video_engine/vie_image_process_impl.h +++ b/src/video_engine/vie_image_process_impl.h @@ -8,59 +8,42 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * vie_image_process_impl.h - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_IMAGE_PROCESS_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_IMAGE_PROCESS_IMPL_H_ +#ifndef WEBRTC_VIDEO_ENGINE_VIE_IMAGE_PROCESS_IMPL_H_ +#define WEBRTC_VIDEO_ENGINE_VIE_IMAGE_PROCESS_IMPL_H_ #include "typedefs.h" -#include "vie_ref_count.h" -#include "vie_image_process.h" -#include "vie_shared_data.h" +#include "video_engine/main/interface/vie_image_process.h" +#include "video_engine/vie_ref_count.h" +#include "video_engine/vie_shared_data.h" -namespace webrtc -{ +namespace webrtc { -// ---------------------------------------------------------------------------- -// ViEImageProcessImpl -// ---------------------------------------------------------------------------- +class ViEImageProcessImpl + : public virtual ViESharedData, + public ViEImageProcess, + public ViERefCount { + public: + // Implements ViEImageProcess. + virtual int Release(); + virtual int RegisterCaptureEffectFilter(const int capture_id, + ViEEffectFilter& capture_filter); + virtual int DeregisterCaptureEffectFilter(const int capture_id); + virtual int RegisterSendEffectFilter(const int video_channel, + ViEEffectFilter& send_filter); + virtual int DeregisterSendEffectFilter(const int video_channel); + virtual int RegisterRenderEffectFilter(const int video_channel, + ViEEffectFilter& render_filter); + virtual int DeregisterRenderEffectFilter(const int video_channel); + virtual int EnableDeflickering(const int capture_id, const bool enable); + virtual int EnableDenoising(const int capture_id, const bool enable); + virtual int EnableColorEnhancement(const int video_channel, + const bool enable); -class ViEImageProcessImpl: public virtual ViESharedData, - public ViEImageProcess, - public ViERefCount -{ -public: - virtual int Release(); - - // Effect filter - virtual int RegisterCaptureEffectFilter(const int captureId, - ViEEffectFilter& captureFilter); - - virtual int DeregisterCaptureEffectFilter(const int captureId); - - virtual int RegisterSendEffectFilter(const int videoChannel, - ViEEffectFilter& sendFilter); - - virtual int DeregisterSendEffectFilter(const int videoChannel); - - virtual int RegisterRenderEffectFilter(const int videoChannel, - ViEEffectFilter& renderFilter); - - virtual int DeregisterRenderEffectFilter(const int videoChannel); - - // Image enhancement - virtual int EnableDeflickering(const int captureId, const bool enable); - - virtual int EnableDenoising(const int captureId, const bool enable); - - virtual int EnableColorEnhancement(const int videoChannel, - const bool enable); - -protected: - ViEImageProcessImpl(); - virtual ~ViEImageProcessImpl(); + protected: + ViEImageProcessImpl(); + virtual ~ViEImageProcessImpl(); }; -} // namespace webrtc -#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_IMAGE_PROCESS_IMPL_H_ + +} // namespace webrtc + +#endif // WEBRTC_VIDEO_ENGINE_VIE_IMAGE_PROCESS_IMPL_H_ diff --git a/src/video_engine/vie_impl.cc b/src/video_engine/vie_impl.cc index bfc6c7d471..d697e00711 100644 --- a/src/video_engine/vie_impl.cc +++ b/src/video_engine/vie_impl.cc @@ -8,296 +8,225 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * vie_impl.cc - */ +#include "video_engine/vie_impl.h" -#include "vie_impl.h" -#include "trace.h" - -#if (defined(_WIN32) || defined(_WIN64)) -#include // For LoadLibrary -#include // For _T +#if (defined(WIN32_) || defined(WIN64_)) +#include // For LoadLibrary. +#include // For T_. #endif +#include "system_wrappers/interface/trace.h" + #ifdef WEBRTC_ANDROID -#include "video_capture_factory.h" -#include "video_render.h" +#include "modules/video_capture/main/interface/video_capture_factory.h" +#include "modules/video_render/main/interface/video_render.h" #endif -// Global counter to get an id for each new ViE instance -static WebRtc_Word32 gViEActiveInstanceCounter = 0; +// Global counter to get an id for each new ViE instance. +static WebRtc_Word32 g_vie_active_instance_counter = 0; -namespace webrtc -{ +namespace webrtc { -// ------------------------------------------------------------------------- -// GetVideoEngine (C-function) -// -// extern "C" ensures that GetProcAddress() can find the function address -// ------------------------------------------------------------------------- - -extern "C" -{ -VideoEngine* GetVideoEngine(); - -VideoEngine* GetVideoEngine() -{ +// extern "C" ensures that GetProcAddress() can find the function address. +extern "C" { + VideoEngine* GetVideoEngine() { VideoEngineImpl* self = new VideoEngineImpl(); - if (self == NULL) - { - return NULL; + if (!self) { + return NULL; } - gViEActiveInstanceCounter++; - VideoEngine* vie = reinterpret_cast (self); + g_vie_active_instance_counter++; + VideoEngine* vie = reinterpret_cast(self); return vie; -} + } } -// ------------------------------------------------------------------------- -// Create -// ------------------------------------------------------------------------- - -VideoEngine* VideoEngine::Create() -{ -#if (defined(_WIN32) || defined(_WIN64)) - // Load a debug dll, if there is one... - HMODULE hmod_ = LoadLibrary(TEXT("VideoEngineTestingDLL.dll")); - if (hmod_) - { - typedef VideoEngine* (*PFNGetVideoEngineLib)(void); - PFNGetVideoEngineLib pfn = - (PFNGetVideoEngineLib)GetProcAddress(hmod_,"GetVideoEngine"); - if (pfn) - { - VideoEngine* self = pfn(); - return self; - } - else - { - assert(!"Failed to open test dll VideoEngineTestingDLL.dll"); - return NULL; - } +VideoEngine* VideoEngine::Create() { +#if (defined(WIN32_) || defined(WIN64_)) + // Load a debug dll, if there is one. + HMODULE hmod_ = LoadLibrary(TEXT("VideoEngineTestingDLL.dll")); + if (hmod_) { + typedef VideoEngine* (*PFNGetVideoEngineLib)(void); + PFNGetVideoEngineLib pfn = + (PFNGetVideoEngineLib)GetProcAddress(hmod_, "GetVideoEngine"); + if (pfn) { + VideoEngine* self = pfn(); + return self; + } else { + assert(!"Failed to open test dll VideoEngineTestingDLL.dll"); + return NULL; } + } #endif - return GetVideoEngine(); + return GetVideoEngine(); } -// ------------------------------------------------------------------------- -// Delete -// -// Deletes the VideoEngineImpl instance if all reference counters are -// down to zero. -// ------------------------------------------------------------------------- +bool VideoEngine::Delete(VideoEngine*& video_engine) { + if (!video_engine) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "VideoEngine::Delete - No argument"); + return false; + } + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, g_vie_active_instance_counter, + "VideoEngine::Delete(vie = 0x%p)", video_engine); + VideoEngineImpl* vie_impl = reinterpret_cast(video_engine); -bool VideoEngine::Delete(VideoEngine*& videoEngine) -{ - if (videoEngine == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "VideoEngine::Delete - No argument"); - return false; - } - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "VideoEngine::Delete( vie = 0x%p)", videoEngine); - - VideoEngineImpl* vieImpl = reinterpret_cast (videoEngine); - - // Check all reference counters - ViEBaseImpl* vieBase = vieImpl; - if (vieBase->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViEBase ref count: %d", vieBase->GetCount()); - return false; - } + // Check all reference counters. + ViEBaseImpl* vie_base = vie_impl; + if (vie_base->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViEBase ref count: %d", vie_base->GetCount()); + return false; + } #ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API - ViECaptureImpl* vieCapture = vieImpl; - if (vieCapture->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViECapture ref count: %d", vieCapture->GetCount()); - return false; - } + ViECaptureImpl* vie_capture = vie_impl; + if (vie_capture->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViECapture ref count: %d", vie_capture->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_CODEC_API - ViECodecImpl* vieCodec = vieImpl; - if (vieCodec->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViECodec ref count: %d", vieCodec->GetCount()); - return false; - } + ViECodecImpl* vie_codec = vie_impl; + if (vie_codec->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViECodec ref count: %d", vie_codec->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API - ViEEncryptionImpl* vieEncryption = vieImpl; - if (vieEncryption->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViEEncryption ref count: %d", vieEncryption->GetCount()); - return false; - } + ViEEncryptionImpl* vie_encryption = vie_impl; + if (vie_encryption->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViEEncryption ref count: %d", vie_encryption->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - ViEExternalCodecImpl* vieExternalCodec = vieImpl; - if (vieExternalCodec->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViEEncryption ref count: %d", vieEncryption->GetCount()); - return false; - } + ViEExternalCodecImpl* vie_external_codec = vie_impl; + if (vie_external_codec->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViEEncryption ref count: %d", vie_encryption->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_FILE_API - ViEFileImpl* vieFile = vieImpl; - if (vieFile->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViEFile ref count: %d", vieFile->GetCount()); - return false; - } + ViEFileImpl* vie_file = vie_impl; + if (vie_file->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViEFile ref count: %d", vie_file->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API - ViEImageProcessImpl* vieImageProcess = vieImpl; - if (vieImageProcess->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViEImageProcess ref count: %d", vieImageProcess->GetCount()); - return false; - } + ViEImageProcessImpl* vie_image_process = vie_impl; + if (vie_image_process->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViEImageProcess ref count: %d", + vie_image_process->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_NETWORK_API - ViENetworkImpl* vieNetwork = vieImpl; - if (vieNetwork->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViENetwork ref count: %d", vieNetwork->GetCount()); - return false; - } + ViENetworkImpl* vie_network = vie_impl; + if (vie_network->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViENetwork ref count: %d", vie_network->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_RENDER_API - ViERenderImpl* vieRender = vieImpl; - if (vieRender->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViERender ref count: %d", vieRender->GetCount()); - return false; - } + ViERenderImpl* vie_render = vie_impl; + if (vie_render->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViERender ref count: %d", vie_render->GetCount()); + return false; + } #endif #ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API - ViERTP_RTCPImpl* vieRtpRtcp = vieImpl; - if (vieRtpRtcp->GetCount() > 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "ViERTP_RTCP ref count: %d", vieRtpRtcp->GetCount()); - return false; - } + ViERTP_RTCPImpl* vie_rtp_rtcp = vie_impl; + if (vie_rtp_rtcp->GetCount() > 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "ViERTP_RTCP ref count: %d", vie_rtp_rtcp->GetCount()); + return false; + } #endif - // Delete VieImpl - delete vieImpl; - vieImpl = NULL; - videoEngine = NULL; + delete vie_impl; + vie_impl = NULL; + video_engine = NULL; - // Decrease the number of instances - gViEActiveInstanceCounter--; + // Decrease the number of instances. + g_vie_active_instance_counter--; - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, gViEActiveInstanceCounter, + WEBRTC_TRACE(kTraceInfo, kTraceVideo, g_vie_active_instance_counter, "%s: instance deleted. Remaining instances: %d", __FUNCTION__, - gViEActiveInstanceCounter); - - return true; + g_vie_active_instance_counter); + return true; } -// ------------------------------------------------------------------------- -// [static] SetTraceFile -// ------------------------------------------------------------------------- - -int VideoEngine::SetTraceFile(const char* fileNameUTF8, - const bool addFileCounter) -{ - if (fileNameUTF8 == NULL) - { - return -1; - } - if (Trace::SetTraceFile(fileNameUTF8, addFileCounter) == -1) - { - return -1; - } - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "SetTraceFileName(fileNameUTF8 = %s, addFileCounter = %d", - fileNameUTF8, addFileCounter); - return 0; +int VideoEngine::SetTraceFile(const char* file_nameUTF8, + const bool add_file_counter) { + if (!file_nameUTF8) { + return -1; + } + if (Trace::SetTraceFile(file_nameUTF8, add_file_counter) == -1) { + return -1; + } + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, g_vie_active_instance_counter, + "SetTraceFileName(file_nameUTF8 = %s, add_file_counter = %d", + file_nameUTF8, add_file_counter); + return 0; } -// ------------------------------------------------------------------------- -// [static] SetTraceFilter -// ------------------------------------------------------------------------- +int VideoEngine::SetTraceFilter(const unsigned int filter) { + WebRtc_UWord32 old_filter = 0; + Trace::LevelFilter(old_filter); -int VideoEngine::SetTraceFilter(const unsigned int filter) -{ - WebRtc_UWord32 oldFilter = 0; - Trace::LevelFilter(oldFilter); + if (filter == kTraceNone && old_filter != kTraceNone) { + // Do the logging before turning it off. + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, g_vie_active_instance_counter, + "SetTraceFilter(filter = 0x%x)", filter); + } - if (filter == webrtc::kTraceNone && oldFilter != webrtc::kTraceNone) - { - // Do the logging before turning it off - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "SetTraceFilter(filter = 0x%x)", filter); - } - - WebRtc_Word32 error = Trace::SetLevelFilter(filter); - - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, gViEActiveInstanceCounter, + WebRtc_Word32 error = Trace::SetLevelFilter(filter); + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, g_vie_active_instance_counter, "SetTraceFilter(filter = 0x%x)", filter); - if (error != 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "SetTraceFilter error: %d", error); - return -1; - } - - return 0; + if (error != 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "SetTraceFilter error: %d", error); + return -1; + } + return 0; } -// ------------------------------------------------------------------------- -// [static] SetTraceFilter -// ------------------------------------------------------------------------- - -int VideoEngine::SetTraceCallback(webrtc::TraceCallback* callback) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "SetTraceCallback(webrtc::TraceCallback = 0x%p)", callback); - return Trace::SetTraceCallback(callback); +int VideoEngine::SetTraceCallback(TraceCallback* callback) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, g_vie_active_instance_counter, + "SetTraceCallback(TraceCallback = 0x%p)", callback); + return Trace::SetTraceCallback(callback); } -// ------------------------------------------------------------------------- -// [static] SetAndroidObjects -// ------------------------------------------------------------------------- - -int VideoEngine::SetAndroidObjects(void* javaVM, void* javaContext) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, gViEActiveInstanceCounter, +int VideoEngine::SetAndroidObjects(void* javaVM, void* java_context) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, g_vie_active_instance_counter, "SetAndroidObjects()"); #ifdef WEBRTC_ANDROID - if (VideoCaptureFactory::SetAndroidObjects(javaVM,javaContext) != 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "Could not set capture module Android objects"); - return -1; - } - if (VideoRender::SetAndroidObjects(javaVM) != 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "Could not set render module Android objects"); - return -1; - } - return 0; -#else - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, gViEActiveInstanceCounter, - "WEBRTC_ANDROID not defined for VideoEngine::SetAndroidObjects"); + if (VideoCaptureFactory::SetAndroidObjects(javaVM, javaContext) != 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "Could not set capture module Android objects"); return -1; + } + if (VideoRender::SetAndroidObjects(javaVM) != 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "Could not set render module Android objects"); + return -1; + } + return 0; +#else + WEBRTC_TRACE(kTraceError, kTraceVideo, g_vie_active_instance_counter, + "WEBRTC_ANDROID not defined for VideoEngine::SetAndroidObjects"); + return -1; #endif } -} // namespace webrtc + +} // namespace webrtc diff --git a/src/video_engine/vie_impl.h b/src/video_engine/vie_impl.h index bea2065c67..3f50ab175f 100644 --- a/src/video_engine/vie_impl.h +++ b/src/video_engine/vie_impl.h @@ -8,83 +8,79 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * vie_impl.h - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_IMPL_H_ +#ifndef WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_ +#define WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_ #include "engine_configurations.h" -#include "vie_defines.h" +#include "video_engine/vie_defines.h" -// Include all sub API:s - -#include "vie_base_impl.h" +#include "video_engine/vie_base_impl.h" #ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API -#include "vie_capture_impl.h" +#include "video_engine/vie_capture_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_CODEC_API -#include "vie_codec_impl.h" +#include "video_engine/vie_codec_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API -#include "vie_encryption_impl.h" +#include "video_engine/vie_encryption_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_FILE_API -#include "vie_file_impl.h" +#include "video_engine/vie_file_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API -#include "vie_image_process_impl.h" +#include "video_engine/vie_image_process_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_NETWORK_API -#include "vie_network_impl.h" +#include "video_engine/vie_network_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_RENDER_API -#include "vie_render_impl.h" +#include "video_engine/vie_render_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API -#include "vie_rtp_rtcp_impl.h" +#include "video_engine/vie_rtp_rtcp_impl.h" #endif #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API -#include "vie_external_codec_impl.h" +#include "video_engine/vie_external_codec_impl.h" #endif -namespace webrtc -{ +namespace webrtc { -class VideoEngineImpl: public ViEBaseImpl +class VideoEngineImpl + : public ViEBaseImpl #ifdef WEBRTC_VIDEO_ENGINE_CODEC_API - , public ViECodecImpl + , public ViECodecImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API - , public ViECaptureImpl + , public ViECaptureImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_ENCRYPTION_API - , public ViEEncryptionImpl + , public ViEEncryptionImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_FILE_API - , public ViEFileImpl + , public ViEFileImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API - , public ViEImageProcessImpl + , public ViEImageProcessImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_NETWORK_API - , public ViENetworkImpl + , public ViENetworkImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_RENDER_API - , public ViERenderImpl + , public ViERenderImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API - , public ViERTP_RTCPImpl + , public ViERTP_RTCPImpl #endif #ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API -,public ViEExternalCodecImpl + , public ViEExternalCodecImpl #endif -{ -public: - VideoEngineImpl() {}; - virtual ~VideoEngineImpl() {}; +{ // NOLINT + public: + VideoEngineImpl() {} + virtual ~VideoEngineImpl() {} }; + } // namespace webrtc -#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_IMPL_H_ + +#endif // WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_ diff --git a/src/video_engine/vie_network_impl.cc b/src/video_engine/vie_network_impl.cc index fedf9e4d0d..b3d0a489bd 100644 --- a/src/video_engine/vie_network_impl.cc +++ b/src/video_engine/vie_network_impl.cc @@ -8,1119 +8,733 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * vie_network_impl.cpp - */ +#include "video_engine/vie_network_impl.h" -#include "vie_network_impl.h" - -// Defines -#include "engine_configurations.h" -#include "vie_defines.h" - -// WebRTC include -#include "vie_errors.h" -#include "trace.h" -#include "vie_impl.h" -#include "vie_channel.h" -#include "vie_channel_manager.h" -#include "vie_encoder.h" - -// System include #include - -// Conditional system include -#if (defined(_WIN32) || defined(_WIN64)) +#if (defined(WIN32_) || defined(WIN64_)) #include #endif -namespace webrtc -{ +#include "engine_configurations.h" +#include "system_wrappers/interface/trace.h" +#include "video_engine/main/interface/vie_errors.h" +#include "video_engine/vie_channel.h" +#include "video_engine/vie_channel_manager.h" +#include "video_engine/vie_defines.h" +#include "video_engine/vie_encoder.h" +#include "video_engine/vie_impl.h" -// ---------------------------------------------------------------------------- -// GetInterface -// ---------------------------------------------------------------------------- +namespace webrtc { -ViENetwork* ViENetwork::GetInterface(VideoEngine* videoEngine) -{ +ViENetwork* ViENetwork::GetInterface(VideoEngine* video_engine) { #ifdef WEBRTC_VIDEO_ENGINE_NETWORK_API - if (videoEngine == NULL) - { - return NULL; - } - VideoEngineImpl* vieImpl = reinterpret_cast (videoEngine); - ViENetworkImpl* vieNetworkImpl = vieImpl; - (*vieNetworkImpl)++; // Increase ref count - - return vieNetworkImpl; -#else + if (!video_engine) { return NULL; + } + VideoEngineImpl* vie_impl = reinterpret_cast(video_engine); + ViENetworkImpl* vie_networkImpl = vie_impl; + // Increase ref count. + (*vie_networkImpl)++; + return vie_networkImpl; +#else + return NULL; #endif } -// ---------------------------------------------------------------------------- -// Release -// -// Releases the interface, i.e. reduces the reference counter. The number of -// remaining references is returned, -1 if released too many times. -// ---------------------------------------------------------------------------- +int ViENetworkImpl::Release() { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, instance_id_, + "ViENetwork::Release()"); + // Decrease ref count. + (*this)--; -int ViENetworkImpl::Release() -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, instance_id_, - "ViENetwork::Release()"); - (*this)--; // Decrease ref count - - WebRtc_Word32 refCount = GetCount(); - if (refCount < 0) - { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceVideo, instance_id_, - "ViENetwork release too many times"); - SetLastError(kViEAPIDoesNotExist); - return -1; - } - WEBRTC_TRACE(webrtc::kTraceInfo, webrtc::kTraceVideo, instance_id_, - "ViENetwork reference count: %d", refCount); - return refCount; + WebRtc_Word32 ref_count = GetCount(); + if (ref_count < 0) { + WEBRTC_TRACE(kTraceWarning, kTraceVideo, instance_id_, + "ViENetwork release too many times"); + SetLastError(kViEAPIDoesNotExist); + return -1; + } + WEBRTC_TRACE(kTraceInfo, kTraceVideo, instance_id_, + "ViENetwork reference count: %d", ref_count); + return ref_count; } -// ---------------------------------------------------------------------------- -// Constructor -// ---------------------------------------------------------------------------- - -ViENetworkImpl::ViENetworkImpl() -{ - WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_, - "ViENetworkImpl::ViENetworkImpl() Ctor"); +ViENetworkImpl::ViENetworkImpl() { + WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_, + "ViENetworkImpl::ViENetworkImpl() Ctor"); } -// ---------------------------------------------------------------------------- -// Destructor -// ---------------------------------------------------------------------------- - -ViENetworkImpl::~ViENetworkImpl() -{ - WEBRTC_TRACE(webrtc::kTraceMemory, webrtc::kTraceVideo, instance_id_, - "ViENetworkImpl::~ViENetworkImpl() Dtor"); +ViENetworkImpl::~ViENetworkImpl() { + WEBRTC_TRACE(kTraceMemory, kTraceVideo, instance_id_, + "ViENetworkImpl::~ViENetworkImpl() Dtor"); } -// ============================================================================ -// Receive functions -// ============================================================================ +int ViENetworkImpl::SetLocalReceiver(const int video_channel, + const unsigned short rtp_port, + const unsigned short rtcp_port, + const char* ip_address) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, rtp_port: %u, rtcp_port: %u, ip_address: %s)", + __FUNCTION__, video_channel, rtp_port, rtcp_port, ip_address); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } -// ---------------------------------------------------------------------------- -// SetLocalReceiver -// -// Initializes the receive socket -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetLocalReceiver(const int videoChannel, - const unsigned short rtpPort, - const unsigned short rtcpPort, - const char* ipAddress) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, rtpPort: %u, rtcpPort: %u, ipAddress: %s)", - __FUNCTION__, videoChannel, rtpPort, rtcpPort, ipAddress); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + // The channel doesn't exists. + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_,videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - - if (ptrViEChannel->Receiving()) - { - SetLastError(kViENetworkAlreadyReceiving); - return -1; - } - if (ptrViEChannel->SetLocalReceiver(rtpPort, rtcpPort, ipAddress) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; + if (vie_channel->Receiving()) { + SetLastError(kViENetworkAlreadyReceiving); + return -1; + } + if (vie_channel->SetLocalReceiver(rtp_port, rtcp_port, ip_address) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// GetLocalReceiver -// -// Gets settings for an initialized receive socket -// ---------------------------------------------------------------------------- -int ViENetworkImpl::GetLocalReceiver(const int videoChannel, - unsigned short& rtpPort, - unsigned short& rtcpPort, char* ipAddress) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); +int ViENetworkImpl::GetLocalReceiver(const int video_channel, + unsigned short& rtp_port, + unsigned short& rtcp_port, + char* ip_address) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->GetLocalReceiver(rtpPort, rtcpPort, ipAddress) != 0) - { - SetLastError(kViENetworkLocalReceiverNotSet); - return -1; - } - return 0; + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->GetLocalReceiver(rtp_port, rtcp_port, ip_address) != 0) { + SetLastError(kViENetworkLocalReceiverNotSet); + return -1; + } + return 0; } -// ============================================================================ -// Send functions -// ============================================================================ +int ViENetworkImpl::SetSendDestination(const int video_channel, + const char* ip_address, + const unsigned short rtp_port, + const unsigned short rtcp_port, + const unsigned short source_rtp_port, + const unsigned short source_rtcp_port) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, ip_address: %s, rtp_port: %u, rtcp_port: %u, " + "sourceRtpPort: %u, source_rtcp_port: %u)", + __FUNCTION__, video_channel, ip_address, rtp_port, rtcp_port, + source_rtp_port, source_rtcp_port); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } -// ---------------------------------------------------------------------------- -// SetSendDestination -// -// Initializes the send socket -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetSendDestination(const int videoChannel, - const char* ipAddress, - const unsigned short rtpPort, - const unsigned short rtcpPort, - const unsigned short sourceRtpPort, - const unsigned short sourceRtcpPort) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, ipAddress: %s, rtpPort: %u, rtcpPort: %u, " - "sourceRtpPort: %u, sourceRtcpPort: %u)", - __FUNCTION__, videoChannel, ipAddress, rtpPort, rtcpPort, - sourceRtpPort, sourceRtcpPort); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s Channel doesn't exist", __FUNCTION__); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->Sending()) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s Channel already sending.", __FUNCTION__); - SetLastError(kViENetworkAlreadySending); - return -1; - } - if (ptrViEChannel->SetSendDestination(ipAddress, rtpPort, rtcpPort, - sourceRtpPort, sourceRtcpPort) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - - return 0; + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "%s Channel doesn't exist", __FUNCTION__); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->Sending()) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "%s Channel already sending.", __FUNCTION__); + SetLastError(kViENetworkAlreadySending); + return -1; + } + if (vie_channel->SetSendDestination(ip_address, rtp_port, rtcp_port, + source_rtp_port, + source_rtcp_port) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// GetSendDestination -// -// Gets settings for an initialized send socket -// ---------------------------------------------------------------------------- -int ViENetworkImpl::GetSendDestination(const int videoChannel, char* ipAddress, - unsigned short& rtpPort, - unsigned short& rtcpPort, - unsigned short& sourceRtpPort, - unsigned short& sourceRtcpPort) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->GetSendDestination(ipAddress, rtpPort, rtcpPort, - sourceRtpPort, sourceRtcpPort) != 0) - { - SetLastError(kViENetworkDestinationNotSet); - return -1; - } - return 0; +int ViENetworkImpl::GetSendDestination(const int video_channel, + char* ip_address, + unsigned short& rtp_port, + unsigned short& rtcp_port, + unsigned short& source_rtp_port, + unsigned short& source_rtcp_port) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, + ViEId(instance_id_, video_channel), "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->GetSendDestination(ip_address, rtp_port, rtcp_port, + source_rtp_port, + source_rtcp_port) != 0) { + SetLastError(kViENetworkDestinationNotSet); + return -1; + } + return 0; } -// ============================================================================ -// External transport -// ============================================================================ - -// ---------------------------------------------------------------------------- -// RegisterSendTransport -// -// Registers the customer implemented send transport -// ---------------------------------------------------------------------------- -int ViENetworkImpl::RegisterSendTransport(const int videoChannel, - Transport& transport) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s Channel doesn't exist", __FUNCTION__); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->Sending()) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s Channel already sending.", __FUNCTION__); - SetLastError(kViENetworkAlreadySending); - return -1; - } - if (ptrViEChannel->RegisterSendTransport(transport) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; +int ViENetworkImpl::RegisterSendTransport(const int video_channel, + Transport& transport) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "%s Channel doesn't exist", __FUNCTION__); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->Sending()) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "%s Channel already sending.", __FUNCTION__); + SetLastError(kViENetworkAlreadySending); + return -1; + } + if (vie_channel->RegisterSendTransport(transport) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// DeregisterSendTransport -// -// Deregisters the send transport implementation from -// RegisterSendTransport -// ---------------------------------------------------------------------------- -int ViENetworkImpl::DeregisterSendTransport(const int videoChannel) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s Channel doesn't exist", __FUNCTION__); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->Sending()) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s Channel already sending", __FUNCTION__); - SetLastError(kViENetworkAlreadySending); - return -1; - } - if (ptrViEChannel->DeregisterSendTransport() != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; +int ViENetworkImpl::DeregisterSendTransport(const int video_channel) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "%s Channel doesn't exist", __FUNCTION__); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->Sending()) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "%s Channel already sending", __FUNCTION__); + SetLastError(kViENetworkAlreadySending); + return -1; + } + if (vie_channel->DeregisterSendTransport() != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// ReceivedRTPPacket -// -// Function for inserting a RTP packet received by a customer transport -// ---------------------------------------------------------------------------- -int ViENetworkImpl::ReceivedRTPPacket(const int videoChannel, const void* data, - const int length) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, data: -, length: %d)", __FUNCTION__, - videoChannel, length); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - return ptrViEChannel->ReceivedRTPPacket(data, length); +int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data, + const int length) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, data: -, length: %d)", __FUNCTION__, + video_channel, length); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + // The channel doesn't exists + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + return vie_channel->ReceivedRTPPacket(data, length); } -// ---------------------------------------------------------------------------- -// ReceivedRTCPPacket -// -// Function for inserting a RTCP packet received by a customer transport -// ---------------------------------------------------------------------------- -int ViENetworkImpl::ReceivedRTCPPacket(const int videoChannel, - const void* data, const int length) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, data: -, length: %d)", __FUNCTION__, - videoChannel, length); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - return ptrViEChannel->ReceivedRTCPPacket(data, length); +int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel, + const void* data, const int length) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, data: -, length: %d)", __FUNCTION__, + video_channel, length); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + return vie_channel->ReceivedRTCPPacket(data, length); } -// ============================================================================ -// Get info -// ============================================================================ - -// ---------------------------------------------------------------------------- -// GetSourceInfo -// -// Retreives informatino about the remote side sockets -// ---------------------------------------------------------------------------- -int ViENetworkImpl::GetSourceInfo(const int videoChannel, - unsigned short& rtpPort, - unsigned short& rtcpPort, char* ipAddress, - unsigned int ipAddressLength) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->GetSourceInfo(rtpPort, rtcpPort, ipAddress, - ipAddressLength) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; +int ViENetworkImpl::GetSourceInfo(const int video_channel, + unsigned short& rtp_port, + unsigned short& rtcp_port, char* ip_address, + unsigned int ip_address_length) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->GetSourceInfo(rtp_port, rtcp_port, ip_address, + ip_address_length) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// GetLocalIP -// -// Gets the local ip address -// ---------------------------------------------------------------------------- -int ViENetworkImpl::GetLocalIP(char ipAddress[64], bool ipv6) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, ViEId(instance_id_), - "%s( ipAddress, ipV6: %d)", __FUNCTION__, ipv6); +int ViENetworkImpl::GetLocalIP(char ip_address[64], bool ipv6) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_), + "%s( ip_address, ipV6: %d)", __FUNCTION__, ipv6); #ifndef WEBRTC_EXTERNAL_TRANSPORT - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } - - if (ipAddress == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: No argument", __FUNCTION__); - SetLastError(kViENetworkInvalidArgument); - return -1; - } - - WebRtc_UWord8 numSocketThreads = 1; - UdpTransport* ptrSocketTransport = - UdpTransport::Create( - ViEModuleId(instance_id_,-1),numSocketThreads); - - if (ptrSocketTransport == NULL) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Could not create socket module", __FUNCTION__); - SetLastError(kViENetworkUnknownError); - return -1; - } - - WebRtc_Word8 localIpAddress[64]; - if (ipv6) - { - WebRtc_UWord8 localIP[16]; - if (ptrSocketTransport->LocalHostAddressIPV6(localIP) != 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Could not get local IP", __FUNCTION__); - SetLastError(kViENetworkUnknownError); - return -1; - } - // Convert 128-bit address to character string (a:b:c:d:e:f:g:h) - sprintf(localIpAddress, - "%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", - localIP[0], localIP[1], localIP[2], localIP[3], localIP[4], - localIP[5], localIP[6], localIP[7], localIP[8], localIP[9], - localIP[10], localIP[11], localIP[12], localIP[13], - localIP[14], localIP[15]); - } - else - { - WebRtc_UWord32 localIP = 0; - if (ptrSocketTransport->LocalHostAddress(localIP) != 0) - { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: Could not get local IP", __FUNCTION__); - SetLastError(kViENetworkUnknownError); - return -1; - } - // Convert 32-bit address to character string (x.y.z.w) - sprintf(localIpAddress, "%d.%d.%d.%d", (int) ((localIP >> 24) & 0x0ff), - (int) ((localIP >> 16) & 0x0ff), - (int) ((localIP >> 8) & 0x0ff), (int) (localIP & 0x0ff)); - } - strcpy(ipAddress, localIpAddress); - UdpTransport::Destroy( - ptrSocketTransport); - WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: local ip = %s", __FUNCTION__, localIpAddress); - - return 0; -#else - WEBRTC_TRACE(webrtc::kTraceStateInfo, webrtc::kTraceVideo, ViEId(instance_id_), - "%s: not available for external transport", __FUNCTION__); - + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); return -1; + } + + if (!ip_address) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: No argument", __FUNCTION__); + SetLastError(kViENetworkInvalidArgument); + return -1; + } + + WebRtc_UWord8 num_socket_threads = 1; + UdpTransport* socket_transport = UdpTransport::Create( + ViEModuleId(instance_id_, -1), num_socket_threads); + + if (!socket_transport) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Could not create socket module", __FUNCTION__); + SetLastError(kViENetworkUnknownError); + return -1; + } + + WebRtc_Word8 local_ip_address[64]; + if (ipv6) { + WebRtc_UWord8 local_ip[16]; + if (socket_transport->LocalHostAddressIPV6(local_ip) != 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Could not get local IP", __FUNCTION__); + SetLastError(kViENetworkUnknownError); + return -1; + } + // Convert 128-bit address to character string (a:b:c:d:e:f:g:h). + sprintf(local_ip_address, + "%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:" + "%.2x%.2x", + local_ip[0], local_ip[1], local_ip[2], local_ip[3], local_ip[4], + local_ip[5], local_ip[6], local_ip[7], local_ip[8], local_ip[9], + local_ip[10], local_ip[11], local_ip[12], local_ip[13], + local_ip[14], local_ip[15]); + } else { + WebRtc_UWord32 local_ip = 0; + if (socket_transport->LocalHostAddress(local_ip) != 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s: Could not get local IP", __FUNCTION__); + SetLastError(kViENetworkUnknownError); + return -1; + } + // Convert 32-bit address to character string (x.y.z.w). + sprintf(local_ip_address, "%d.%d.%d.%d", + static_cast((local_ip >> 24) & 0x0ff), + static_cast((local_ip >> 16) & 0x0ff), + static_cast((local_ip >> 8) & 0x0ff), + static_cast(local_ip & 0x0ff)); + } + strcpy(ip_address, local_ip_address); + UdpTransport::Destroy(socket_transport); + WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(instance_id_), + "%s: local ip = %s", __FUNCTION__, local_ip_address); + return 0; +#else + WEBRTC_TRACE(kTraceStateInfo, kTraceVideo, ViEId(instance_id_), + "%s: not available for external transport", __FUNCTION__); + + return -1; #endif } -// ============================================================================ -// IPv6 -// ============================================================================ - -// ---------------------------------------------------------------------------- -// EnableIPv6 -// -// Enables IPv6 -// ---------------------------------------------------------------------------- -int ViENetworkImpl::EnableIPv6(int videoChannel) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->EnableIPv6() != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; +int ViENetworkImpl::EnableIPv6(int video_channel) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->EnableIPv6() != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// IsIPv6Enabled -// -// Returns true if IPv6 is enabled, false otherwise. -// ---------------------------------------------------------------------------- -bool ViENetworkImpl::IsIPv6Enabled(int videoChannel) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return false; - } - return ptrViEChannel->IsIPv6Enabled(); +bool ViENetworkImpl::IsIPv6Enabled(int video_channel) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return false; + } + return vie_channel->IsIPv6Enabled(); } -// ============================================================================ -// Source IP address and port filter -// ============================================================================ - -// ---------------------------------------------------------------------------- -// SetSourceFilter -// -// Sets filter source port and IP address. Packets from all other sources -// will be discarded. -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetSourceFilter(const int videoChannel, - const unsigned short rtpPort, - const unsigned short rtcpPort, - const char* ipAddress) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, rtpPort: %u, rtcpPort: %u, ipAddress: %s)", - __FUNCTION__, videoChannel, rtpPort, rtcpPort, ipAddress); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->SetSourceFilter(rtpPort, rtcpPort, ipAddress) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; +int ViENetworkImpl::SetSourceFilter(const int video_channel, + const unsigned short rtp_port, + const unsigned short rtcp_port, + const char* ip_address) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, rtp_port: %u, rtcp_port: %u, ip_address: %s)", + __FUNCTION__, video_channel, rtp_port, rtcp_port, ip_address); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->SetSourceFilter(rtp_port, rtcp_port, ip_address) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// GetSourceFilter -// -// Gets vaules set by SetSourceFilter -// ---------------------------------------------------------------------------- -int ViENetworkImpl::GetSourceFilter(const int videoChannel, - unsigned short& rtpPort, - unsigned short& rtcpPort, char* ipAddress) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->GetSourceFilter(rtpPort, rtcpPort, ipAddress) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; +int ViENetworkImpl::GetSourceFilter(const int video_channel, + unsigned short& rtp_port, + unsigned short& rtcp_port, + char* ip_address) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->GetSourceFilter(rtp_port, rtcp_port, ip_address) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ============================================================================ -// ToS -// ============================================================================ - -// ---------------------------------------------------------------------------- -// SetToS -// -// Sets values for ToS -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetSendToS(const int videoChannel, const int DSCP, - const bool useSetSockOpt = false) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, DSCP: %d, useSetSockOpt: %d)", __FUNCTION__, - videoChannel, DSCP, useSetSockOpt); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } +int ViENetworkImpl::SetSendToS(const int video_channel, const int DSCP, + const bool use_set_sockOpt = false) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, DSCP: %d, use_set_sockOpt: %d)", __FUNCTION__, + video_channel, DSCP, use_set_sockOpt); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } #if defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) - WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, videoChannel), - " force useSetSockopt=true since there is no alternative" - " implementation"); - if (ptrViEChannel->SetToS(DSCP, true) != 0) + WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(instance_id_, video_channel), + " force use_set_sockopt=true since there is no alternative" + " implementation"); + if (vie_channel->SetToS(DSCP, true) != 0) { #else - if (ptrViEChannel->SetToS(DSCP, useSetSockOpt) != 0) + if (vie_channel->SetToS(DSCP, use_set_sockOpt) != 0) { #endif - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; -} - -// ---------------------------------------------------------------------------- -// GetToS -// -// Gets values set by SetToS -// ---------------------------------------------------------------------------- -int ViENetworkImpl::GetSendToS(const int videoChannel, int& DSCP, - bool& useSetSockOpt) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->GetToS((WebRtc_Word32&) DSCP, useSetSockOpt) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; -} - -// ============================================================================ -// GQoS -// ============================================================================ - -// ---------------------------------------------------------------------------- -// SetSendGQoS -// -// Sets settings for GQoS. Must be called after SetSendCodec to get correct -// bitrate setting. -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetSendGQoS(const int videoChannel, const bool enable, - const int serviceType, const int overrideDSCP) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, enable: %d, serviceType: %d, " - "overrideDSCP: %d)", - __FUNCTION__, videoChannel, enable, serviceType, overrideDSCP); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } - -#if (defined(_WIN32) || defined(_WIN64)) - // Sanity check. We might crash if testing and relying on an OS socket error - if (enable - && (serviceType != SERVICETYPE_BESTEFFORT) - && (serviceType != SERVICETYPE_CONTROLLEDLOAD) - && (serviceType != SERVICETYPE_GUARANTEED) && - (serviceType != SERVICETYPE_QUALITATIVE)) - { - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s: service type %d not supported", __FUNCTION__, - videoChannel, serviceType); - SetLastError(kViENetworkServiceTypeNotSupported); - return -1; - } - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - ViEEncoder* ptrVieEncoder = cs.Encoder(videoChannel); - if (ptrVieEncoder == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - VideoCodec videoCodec; - if (ptrVieEncoder->GetEncoder(videoCodec) != 0) - { - // Could not get - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s: Could not get max bitrate for the channel", - __FUNCTION__); - SetLastError(kViENetworkSendCodecNotSet); - return -1; - } - if(ptrViEChannel->SetSendGQoS(enable, serviceType, videoCodec.maxBitrate, - overrideDSCP)!=0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; - -#else - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s: Not supported", - __FUNCTION__); - SetLastError(kViENetworkNotSupported); + SetLastError(kViENetworkUnknownError); return -1; + } + return 0; +} + +int ViENetworkImpl::GetSendToS(const int video_channel, int& DSCP, + bool& use_set_sockOpt) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->GetToS((WebRtc_Word32&) DSCP, use_set_sockOpt) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; +} + +int ViENetworkImpl::SetSendGQoS(const int video_channel, const bool enable, + const int service_type, + const int overrideDSCP) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, enable: %d, service_type: %d, " + "overrideDSCP: %d)", __FUNCTION__, video_channel, enable, + service_type, overrideDSCP); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } + +#if (defined(WIN32_) || defined(WIN64_)) + // Sanity check. We might crash if testing and relying on an OS socket error. + if (enable && + (service_type != SERVICETYPE_BESTEFFORT) && + (service_type != SERVICETYPE_CONTROLLEDLOAD) && + (service_type != SERVICETYPE_GUARANTEED) && + (service_type != SERVICETYPE_QUALITATIVE)) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s: service type %d not supported", __FUNCTION__, + video_channel, service_type); + SetLastError(kViENetworkServiceTypeNotSupported); + return -1; + } + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + ViEEncoder* vie_encoder = cs.Encoder(video_channel); + if (!vie_encoder) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + VideoCodec video_codec; + if (vie_encoder->GetEncoder(video_codec) != 0) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "%s: Could not get max bitrate for the channel", + __FUNCTION__); + SetLastError(kViENetworkSendCodecNotSet); + return -1; + } + if (vie_channel->SetSendGQoS(enable, service_type, video_codec.maxBitrate, + overrideDSCP) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; +#else + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s: Not supported", __FUNCTION__); + SetLastError(kViENetworkNotSupported); + return -1; #endif } -// ---------------------------------------------------------------------------- -// GetSendGQoS -// -// Gets the settigns set by SetSendGQoS -// ---------------------------------------------------------------------------- -int ViENetworkImpl::GetSendGQoS(const int videoChannel, bool& enabled, - int& serviceType, int& overrideDSCP) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->GetSendGQoS(enabled, (WebRtc_Word32&) serviceType, - (WebRtc_Word32&) overrideDSCP) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; - +int ViENetworkImpl::GetSendGQoS(const int video_channel, bool& enabled, + int& service_type, int& overrideDSCP) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->GetSendGQoS(enabled, service_type, overrideDSCP) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ============================================================================ -// Network settings -// ============================================================================ - -// ---------------------------------------------------------------------------- -// SetMTU -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetMTU(int videoChannel, unsigned int mtu) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d, mtu: %u)", - __FUNCTION__, videoChannel, mtu); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->SetMTU(mtu) != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; - +int ViENetworkImpl::SetMTU(int video_channel, unsigned int mtu) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, mtu: %u)", __FUNCTION__, video_channel, mtu); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->SetMTU(mtu) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ============================================================================ -// Packet timout notification -// ============================================================================ - -// ---------------------------------------------------------------------------- -// SetPacketTimeoutNotification -// -// Sets the time for packet timout notifications -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetPacketTimeoutNotification(const int videoChannel, +int ViENetworkImpl::SetPacketTimeoutNotification(const int video_channel, bool enable, - int timeoutSeconds) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, enable: %d, timeoutSeconds: %u)", - __FUNCTION__, videoChannel, enable, timeoutSeconds); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->SetPacketTimeoutNotification(enable, timeoutSeconds) - != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; + int timeout_seconds) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, enable: %d, timeout_seconds: %u)", + __FUNCTION__, video_channel, enable, timeout_seconds); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->SetPacketTimeoutNotification(enable, + timeout_seconds) != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ============================================================================ -// Periodic dead-or-alive reports -// ============================================================================ - -// ---------------------------------------------------------------------------- -// RegisterObserver -// ---------------------------------------------------------------------------- -int ViENetworkImpl::RegisterObserver(const int videoChannel, - ViENetworkObserver& observer) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->RegisterNetworkObserver(&observer) != 0) - { - SetLastError(kViENetworkObserverAlreadyRegistered); - return -1; - } - return 0; +int ViENetworkImpl::RegisterObserver(const int video_channel, + ViENetworkObserver& observer) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->RegisterNetworkObserver(&observer) != 0) { + SetLastError(kViENetworkObserverAlreadyRegistered); + return -1; + } + return 0; } -// ---------------------------------------------------------------------------- -// DeregisterObserver -// ---------------------------------------------------------------------------- -int ViENetworkImpl::DeregisterObserver(const int videoChannel) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "%s(channel: %d)", - __FUNCTION__, videoChannel); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (!ptrViEChannel->NetworkObserverRegistered()) - { - SetLastError(kViENetworkObserverNotRegistered); - return -1; - } - return ptrViEChannel->RegisterNetworkObserver(NULL); +int ViENetworkImpl::DeregisterObserver(const int video_channel) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (!vie_channel->NetworkObserverRegistered()) { + SetLastError(kViENetworkObserverNotRegistered); + return -1; + } + return vie_channel->RegisterNetworkObserver(NULL); } -// ---------------------------------------------------------------------------- -// SetPeriodicDeadOrAliveStatus -// -// Enables/disables the dead-or-alive callback -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SetPeriodicDeadOrAliveStatus(const int videoChannel, - bool enable, - unsigned int sampleTimeSeconds) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, enable: %d, sampleTimeSeconds: %ul)", - __FUNCTION__, videoChannel, enable, sampleTimeSeconds); - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (!ptrViEChannel->NetworkObserverRegistered()) - { - SetLastError(kViENetworkObserverNotRegistered); - return -1; - } - - if (ptrViEChannel->SetPeriodicDeadOrAliveStatus(enable, sampleTimeSeconds) - != 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; +int ViENetworkImpl::SetPeriodicDeadOrAliveStatus( + const int video_channel, + bool enable, + unsigned int sample_time_seconds) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, enable: %d, sample_time_seconds: %ul)", + __FUNCTION__, video_channel, enable, sample_time_seconds); + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (!vie_channel->NetworkObserverRegistered()) { + SetLastError(kViENetworkObserverNotRegistered); + return -1; + } + if (vie_channel->SetPeriodicDeadOrAliveStatus(enable, sample_time_seconds) + != 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -// ============================================================================ -// Send packet using the User Datagram Protocol (UDP) -// ============================================================================ - -// ---------------------------------------------------------------------------- -// SendUDPPacket -// -// Send an extra UDP packet -// ---------------------------------------------------------------------------- -int ViENetworkImpl::SendUDPPacket(const int videoChannel, const void* data, +int ViENetworkImpl::SendUDPPacket(const int video_channel, const void* data, const unsigned int length, - int& transmittedBytes, - bool useRtcpSocket = false) -{ - WEBRTC_TRACE(webrtc::kTraceApiCall, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), - "%s(channel: %d, data: -, length: %d, transmitterBytes: -, " - "useRtcpSocket: %d)", __FUNCTION__, videoChannel, length, - useRtcpSocket); - if (!Initialized()) - { - SetLastError(kViENotInitialized); - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, ViEId(instance_id_), - "%s - ViE instance %d not initialized", __FUNCTION__, - instance_id_); - return -1; - } - - // Get the channel - ViEChannelManagerScoped cs(channel_manager_); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) - { - // The channel doesn't exists - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceVideo, - ViEId(instance_id_, videoChannel), "Channel doesn't exist"); - SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (ptrViEChannel->SendUDPPacket((const WebRtc_Word8*) data, length, - (WebRtc_Word32&) transmittedBytes, - useRtcpSocket) < 0) - { - SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; + int& transmitted_bytes, + bool use_rtcp_socket = false) { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, ViEId(instance_id_, video_channel), + "%s(channel: %d, data: -, length: %d, transmitter_bytes: -, " + "useRtcpSocket: %d)", __FUNCTION__, video_channel, length, + use_rtcp_socket); + if (!Initialized()) { + SetLastError(kViENotInitialized); + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_), + "%s - ViE instance %d not initialized", __FUNCTION__, + instance_id_); + return -1; + } + ViEChannelManagerScoped cs(channel_manager_); + ViEChannel* vie_channel = cs.Channel(video_channel); + if (!vie_channel) { + WEBRTC_TRACE(kTraceError, kTraceVideo, ViEId(instance_id_, video_channel), + "Channel doesn't exist"); + SetLastError(kViENetworkInvalidChannelId); + return -1; + } + if (vie_channel->SendUDPPacket((const WebRtc_Word8*) data, length, + (WebRtc_Word32&) transmitted_bytes, + use_rtcp_socket) < 0) { + SetLastError(kViENetworkUnknownError); + return -1; + } + return 0; } -} // namespace webrtc + +} // namespace webrtc diff --git a/src/video_engine/vie_network_impl.h b/src/video_engine/vie_network_impl.h index 41c1634ad8..396e29df4d 100644 --- a/src/video_engine/vie_network_impl.h +++ b/src/video_engine/vie_network_impl.h @@ -8,130 +8,104 @@ * be found in the AUTHORS file in the root of the source tree. */ -/* - * vie_network_impl.h - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_NETWORK_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_NETWORK_IMPL_H_ +#ifndef WEBRTC_VIDEO_ENGINE_VIE_NETWORK_IMPL_H_ +#define WEBRTC_VIDEO_ENGINE_VIE_NETWORK_IMPL_H_ #include "typedefs.h" -#include "vie_defines.h" -#include "vie_network.h" -#include "vie_ref_count.h" -#include "vie_shared_data.h" +#include "video_engine/main/interface/vie_network.h" +#include "video_engine/vie_ref_count.h" +#include "video_engine/vie_shared_data.h" -namespace webrtc -{ +namespace webrtc { -// ---------------------------------------------------------------------------- -// ViENetworkImpl -// ---------------------------------------------------------------------------- +class ViENetworkImpl + : public virtual ViESharedData, + public ViENetwork, + public ViERefCount { + public: + // Implements ViENetwork. + virtual int Release(); + virtual int SetLocalReceiver(const int video_channel, + const unsigned short rtp_port, + const unsigned short rtcp_port, + const char* ip_address); + virtual int GetLocalReceiver(const int video_channel, + unsigned short& rtp_port, + unsigned short& rtcp_port, + char* ip_address); + virtual int SetSendDestination(const int video_channel, + const char* ip_address, + const unsigned short rtp_port, + const unsigned short rtcp_port, + const unsigned short source_rtp_port, + const unsigned short source_rtcp_port); + virtual int GetSendDestination(const int video_channel, + char* ip_address, + unsigned short& rtp_port, + unsigned short& rtcp_port, + unsigned short& source_rtp_port, + unsigned short& source_rtcp_port); + virtual int RegisterSendTransport(const int video_channel, + Transport& transport); + virtual int DeregisterSendTransport(const int video_channel); + virtual int ReceivedRTPPacket(const int video_channel, + const void* data, + const int length); + virtual int ReceivedRTCPPacket(const int video_channel, + const void* data, + const int length); + virtual int GetSourceInfo(const int video_channel, + unsigned short& rtp_port, + unsigned short& rtcp_port, + char* ip_address, + unsigned int ip_address_length); + virtual int GetLocalIP(char ip_address[64], bool ipv6); + virtual int EnableIPv6(int video_channel); + virtual bool IsIPv6Enabled(int video_channel); + virtual int SetSourceFilter(const int video_channel, + const unsigned short rtp_port, + const unsigned short rtcp_port, + const char* ip_address); + virtual int GetSourceFilter(const int video_channel, + unsigned short& rtp_port, + unsigned short& rtcp_port, + char* ip_address); + virtual int SetSendToS(const int video_channel, + const int DSCP, + const bool use_set_sockOpt); + virtual int GetSendToS(const int video_channel, + int& DSCP, + bool& use_set_sockOpt); + virtual int SetSendGQoS(const int video_channel, + const bool enable, + const int service_type, + const int overrideDSCP); + virtual int GetSendGQoS(const int video_channel, + bool& enabled, + int& service_type, + int& overrideDSCP); + virtual int SetMTU(int video_channel, unsigned int mtu); + virtual int SetPacketTimeoutNotification(const int video_channel, + bool enable, + int timeout_seconds); + virtual int RegisterObserver(const int video_channel, + ViENetworkObserver& observer); + virtual int DeregisterObserver(const int video_channel); + virtual int SetPeriodicDeadOrAliveStatus( + const int video_channel, + const bool enable, + const unsigned int sample_time_seconds); + virtual int SendUDPPacket(const int video_channel, + const void* data, + const unsigned int length, + int& transmitted_bytes, + bool use_rtcp_socket); -class ViENetworkImpl : public virtual ViESharedData, - public ViENetwork, - public ViERefCount -{ -public: - virtual int Release(); - - // Receive functions - virtual int SetLocalReceiver(const int videoChannel, - const unsigned short rtpPort, - const unsigned short rtcpPort, - const char* ipAddress); - - virtual int GetLocalReceiver(const int videoChannel, - unsigned short& rtpPort, - unsigned short& rtcpPort, char* ipAddress); - - // Send functions - virtual int SetSendDestination(const int videoChannel, - const char* ipAddress, - const unsigned short rtpPort, - const unsigned short rtcpPort, - const unsigned short sourceRtpPort, - const unsigned short sourceRtcpPort); - - virtual int GetSendDestination(const int videoChannel, char* ipAddress, - unsigned short& rtpPort, - unsigned short& rtcpPort, - unsigned short& sourceRtpPort, - unsigned short& sourceRtcpPort); - - // External transport - virtual int RegisterSendTransport(const int videoChannel, - Transport& transport); - - virtual int DeregisterSendTransport(const int videoChannel); - - virtual int ReceivedRTPPacket(const int videoChannel, const void* data, - const int length); - - virtual int ReceivedRTCPPacket(const int videoChannel, const void* data, - const int length); - - // Get info - virtual int GetSourceInfo(const int videoChannel, unsigned short& rtpPort, - unsigned short& rtcpPort, char* ipAddress, - unsigned int ipAddressLength); - - virtual int GetLocalIP(char ipAddress[64], bool ipv6); - - // IPv6 - virtual int EnableIPv6(int videoChannel); - - virtual bool IsIPv6Enabled(int videoChannel); - - // Source IP address and port filter - virtual int SetSourceFilter(const int videoChannel, - const unsigned short rtpPort, - const unsigned short rtcpPort, - const char* ipAddress); - - virtual int GetSourceFilter(const int videoChannel, - unsigned short& rtpPort, - unsigned short& rtcpPort, char* ipAddress); - - // ToS - virtual int SetSendToS(const int videoChannel, const int DSCP, - const bool useSetSockOpt); - - virtual int GetSendToS(const int videoChannel, int& DSCP, - bool& useSetSockOpt); - - // GQoS - virtual int SetSendGQoS(const int videoChannel, const bool enable, - const int serviceType, const int overrideDSCP); - - virtual int GetSendGQoS(const int videoChannel, bool& enabled, - int& serviceType, int& overrideDSCP); - - // Network settings - virtual int SetMTU(int videoChannel, unsigned int mtu); - - // Packet timout notification - virtual int SetPacketTimeoutNotification(const int videoChannel, - bool enable, int timeoutSeconds); - - // Periodic dead-or-alive reports - virtual int RegisterObserver(const int videoChannel, - ViENetworkObserver& observer); - - virtual int DeregisterObserver(const int videoChannel); - - virtual int - SetPeriodicDeadOrAliveStatus(const int videoChannel, const bool enable, - const unsigned int sampleTimeSeconds); - - // Send extra packet using the User Datagram Protocol (UDP) - virtual int SendUDPPacket(const int videoChannel, const void* data, - const unsigned int length, int& transmittedBytes, - bool useRtcpSocket); - -protected: - ViENetworkImpl(); - virtual ~ViENetworkImpl(); + protected: + ViENetworkImpl(); + virtual ~ViENetworkImpl(); }; -} // namespace webrtc -#endif // WEBRTC_VIDEO_ENGINE_MAIN_SOURCE_VIE_NETWORK_IMPL_H_ + +} // namespace webrtc + +#endif // WEBRTC_VIDEO_ENGINE_VIE_NETWORK_IMPL_H_