diff --git a/WATCHLISTS b/WATCHLISTS index fa7f382ac6..79e282315f 100644 --- a/WATCHLISTS +++ b/WATCHLISTS @@ -24,7 +24,6 @@ }, 'documented_interfaces': { 'filepath': 'webrtc/[^/]*\.h$|'\ - 'webrtc/video_engine/include/.*|'\ 'webrtc/voice_engine/include/.*', }, 'build_files': { diff --git a/talk/app/webrtc/java/jni/peerconnection_jni.cc b/talk/app/webrtc/java/jni/peerconnection_jni.cc index f8f363ae38..a6cba440ce 100644 --- a/talk/app/webrtc/java/jni/peerconnection_jni.cc +++ b/talk/app/webrtc/java/jni/peerconnection_jni.cc @@ -78,7 +78,6 @@ #include "webrtc/base/stringutils.h" #include "webrtc/system_wrappers/interface/field_trial_default.h" #include "webrtc/system_wrappers/interface/trace.h" -#include "webrtc/video_engine/include/vie_base.h" #include "webrtc/voice_engine/include/voe_base.h" #if defined(ANDROID) && !defined(WEBRTC_CHROMIUM_BUILD) diff --git a/talk/libjingle.gyp b/talk/libjingle.gyp index fdef9062b0..1c97f0f0a4 100755 --- a/talk/libjingle.gyp +++ b/talk/libjingle.gyp @@ -494,7 +494,6 @@ 'media/webrtc/webrtcvideoframe.h', 'media/webrtc/webrtcvideoframefactory.cc', 'media/webrtc/webrtcvideoframefactory.h', - 'media/webrtc/webrtcvie.h', 'media/webrtc/webrtcvoe.h', 'media/webrtc/webrtcvoiceengine.cc', 'media/webrtc/webrtcvoiceengine.h', diff --git a/talk/media/webrtc/fakewebrtcvideoengine.h b/talk/media/webrtc/fakewebrtcvideoengine.h index f8ede9a987..fed19c9707 100644 --- a/talk/media/webrtc/fakewebrtcvideoengine.h +++ b/talk/media/webrtc/fakewebrtcvideoengine.h @@ -36,12 +36,14 @@ #include "talk/media/webrtc/fakewebrtccommon.h" #include "talk/media/webrtc/webrtcvideodecoderfactory.h" #include "talk/media/webrtc/webrtcvideoencoderfactory.h" -#include "talk/media/webrtc/webrtcvie.h" #include "webrtc/base/basictypes.h" #include "webrtc/base/criticalsection.h" #include "webrtc/base/gunit.h" #include "webrtc/base/stringutils.h" #include "webrtc/base/thread_annotations.h" +#include "webrtc/modules/video_coding/codecs/interface/video_error_codes.h" +#include "webrtc/video_decoder.h" +#include "webrtc/video_encoder.h" namespace cricket { diff --git a/talk/media/webrtc/fakewebrtcvoiceengine.h b/talk/media/webrtc/fakewebrtcvoiceengine.h index 5b86b538be..18999ba3d0 100644 --- a/talk/media/webrtc/fakewebrtcvoiceengine.h +++ b/talk/media/webrtc/fakewebrtcvoiceengine.h @@ -1027,9 +1027,6 @@ class FakeWebRtcVoiceEngine unsigned short payloadSize)); WEBRTC_STUB(GetLastRemoteTimeStamp, (int channel, uint32_t* lastRemoteTimeStamp)); - WEBRTC_STUB(SetVideoEngineBWETarget, (int channel, - webrtc::ViENetwork* vie_network, - int video_channel)); // webrtc::VoEVideoSync WEBRTC_STUB(GetPlayoutBufferSize, (int& bufferMs)); diff --git a/talk/media/webrtc/webrtcvie.h b/talk/media/webrtc/webrtcvie.h deleted file mode 100644 index 81874d995b..0000000000 --- a/talk/media/webrtc/webrtcvie.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - * libjingle - * Copyright 2004 Google Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TALK_MEDIA_WEBRTCVIE_H_ -#define TALK_MEDIA_WEBRTCVIE_H_ - -#include "talk/media/webrtc/webrtccommon.h" -#include "webrtc/base/common.h" -#include "webrtc/common_types.h" -#include "webrtc/modules/interface/module_common_types.h" -#include "webrtc/modules/video_capture/include/video_capture.h" -#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" -#include "webrtc/modules/video_render/include/video_render.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/include/vie_external_codec.h" -#include "webrtc/video_engine/include/vie_image_process.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" - -namespace cricket { - -// all tracing macros should go to a common file - -// automatically handles lifetime of VideoEngine -class scoped_vie_engine { - public: - explicit scoped_vie_engine(webrtc::VideoEngine* e) : ptr(e) {} - // VERIFY, to ensure that there are no leaks at shutdown - ~scoped_vie_engine() { - if (ptr) { - webrtc::VideoEngine::Delete(ptr); - } - } - webrtc::VideoEngine* get() const { return ptr; } - private: - webrtc::VideoEngine* ptr; -}; - -// scoped_ptr class to handle obtaining and releasing VideoEngine -// interface pointers -template class scoped_vie_ptr { - public: - explicit scoped_vie_ptr(const scoped_vie_engine& e) - : ptr(T::GetInterface(e.get())) {} - explicit scoped_vie_ptr(T* p) : ptr(p) {} - ~scoped_vie_ptr() { if (ptr) ptr->Release(); } - T* operator->() const { return ptr; } - T* get() const { return ptr; } - private: - T* ptr; -}; - -// Utility class for aggregating the various WebRTC interface. -// Fake implementations can also be injected for testing. -class ViEWrapper { - public: - ViEWrapper() - : engine_(webrtc::VideoEngine::Create()), - base_(engine_), codec_(engine_), capture_(engine_), - network_(engine_), render_(engine_), rtp_(engine_), - image_(engine_), ext_codec_(engine_) { - } - - ViEWrapper(webrtc::ViEBase* base, webrtc::ViECodec* codec, - webrtc::ViECapture* capture, webrtc::ViENetwork* network, - webrtc::ViERender* render, webrtc::ViERTP_RTCP* rtp, - webrtc::ViEImageProcess* image, - webrtc::ViEExternalCodec* ext_codec) - : engine_(NULL), - base_(base), - codec_(codec), - capture_(capture), - network_(network), - render_(render), - rtp_(rtp), - image_(image), - ext_codec_(ext_codec) { - } - - virtual ~ViEWrapper() {} - webrtc::VideoEngine* engine() { return engine_.get(); } - webrtc::ViEBase* base() { return base_.get(); } - webrtc::ViECodec* codec() { return codec_.get(); } - webrtc::ViECapture* capture() { return capture_.get(); } - webrtc::ViENetwork* network() { return network_.get(); } - webrtc::ViERender* render() { return render_.get(); } - webrtc::ViERTP_RTCP* rtp() { return rtp_.get(); } - webrtc::ViEImageProcess* image() { return image_.get(); } - webrtc::ViEExternalCodec* ext_codec() { return ext_codec_.get(); } - int error() { return base_->LastError(); } - - private: - scoped_vie_engine engine_; - scoped_vie_ptr base_; - scoped_vie_ptr codec_; - scoped_vie_ptr capture_; - scoped_vie_ptr network_; - scoped_vie_ptr render_; - scoped_vie_ptr rtp_; - scoped_vie_ptr image_; - scoped_vie_ptr ext_codec_; -}; - -// Adds indirection to static WebRtc functions, allowing them to be mocked. -class ViETraceWrapper { - public: - virtual ~ViETraceWrapper() {} - - virtual int SetTraceFilter(const unsigned int filter) { - return webrtc::VideoEngine::SetTraceFilter(filter); - } - virtual int SetTraceFile(const char* fileNameUTF8) { - return webrtc::VideoEngine::SetTraceFile(fileNameUTF8); - } - virtual int SetTraceCallback(webrtc::TraceCallback* callback) { - return webrtc::VideoEngine::SetTraceCallback(callback); - } -}; - -} // namespace cricket - -#endif // TALK_MEDIA_WEBRTCVIE_H_ diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc index fcf8ef754f..4f2c38a1cc 100644 --- a/talk/media/webrtc/webrtcvoiceengine.cc +++ b/talk/media/webrtc/webrtcvoiceengine.cc @@ -53,7 +53,6 @@ #include "webrtc/base/stringutils.h" #include "webrtc/common.h" #include "webrtc/modules/audio_processing/include/audio_processing.h" -#include "webrtc/video_engine/include/vie_network.h" #ifdef WIN32 #include // NOLINT diff --git a/talk/media/webrtc/webrtcvoiceengine_unittest.cc b/talk/media/webrtc/webrtcvoiceengine_unittest.cc index f995093648..4d43cd29d8 100644 --- a/talk/media/webrtc/webrtcvoiceengine_unittest.cc +++ b/talk/media/webrtc/webrtcvoiceengine_unittest.cc @@ -39,7 +39,6 @@ #include "talk/media/base/fakertp.h" #include "talk/media/webrtc/fakewebrtccall.h" #include "talk/media/webrtc/fakewebrtcvoiceengine.h" -#include "talk/media/webrtc/webrtcvie.h" #include "talk/media/webrtc/webrtcvoiceengine.h" #include "webrtc/p2p/base/fakesession.h" #include "talk/session/media/channel.h" diff --git a/webrtc/engine_configurations.h b/webrtc/engine_configurations.h index ba18147bf6..4f6159cac9 100644 --- a/webrtc/engine_configurations.h +++ b/webrtc/engine_configurations.h @@ -85,27 +85,6 @@ #define WEBRTC_VOICE_ENGINE_VIDEO_SYNC_API #define WEBRTC_VOICE_ENGINE_VOLUME_CONTROL_API -// ============================================================================ -// VideoEngine -// ============================================================================ - -// ---------------------------------------------------------------------------- -// Settings for special VideoEngine configurations -// ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -// VideoEngine sub-API:s -// ---------------------------------------------------------------------------- - -#define WEBRTC_VIDEO_ENGINE_CAPTURE_API -#define WEBRTC_VIDEO_ENGINE_CODEC_API -#define WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API -#define WEBRTC_VIDEO_ENGINE_RENDER_API -#define WEBRTC_VIDEO_ENGINE_RTP_RTCP_API -#define WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - -// Now handled by gyp: -// WEBRTC_VIDEO_ENGINE_FILE_API - // ============================================================================ // Platform specific configurations // ============================================================================ diff --git a/webrtc/test/channel_transport/channel_transport.cc b/webrtc/test/channel_transport/channel_transport.cc index 725a090641..25eb59d887 100644 --- a/webrtc/test/channel_transport/channel_transport.cc +++ b/webrtc/test/channel_transport/channel_transport.cc @@ -16,7 +16,6 @@ #include "testing/gtest/include/gtest/gtest.h" #endif #include "webrtc/test/channel_transport/udp_transport.h" -#include "webrtc/video_engine/include/vie_network.h" #include "webrtc/video_engine/vie_defines.h" #include "webrtc/voice_engine/include/voe_network.h" @@ -80,58 +79,5 @@ int VoiceChannelTransport::SetSendDestination(const char* ip_address, return socket_transport_->InitializeSendSockets(ip_address, rtp_port); } - -VideoChannelTransport::VideoChannelTransport(ViENetwork* vie_network, - int channel) - : channel_(channel), - vie_network_(vie_network) { - uint8_t socket_threads = 1; - socket_transport_ = UdpTransport::Create(channel, socket_threads); - int registered = vie_network_->RegisterSendTransport(channel, - *socket_transport_); -#if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS) - EXPECT_EQ(0, registered); -#else - assert(registered == 0); -#endif -} - -VideoChannelTransport::~VideoChannelTransport() { - vie_network_->DeregisterSendTransport(channel_); - UdpTransport::Destroy(socket_transport_); -} - -void VideoChannelTransport::IncomingRTPPacket( - const int8_t* incoming_rtp_packet, - const size_t packet_length, - const char* /*from_ip*/, - const uint16_t /*from_port*/) { - vie_network_->ReceivedRTPPacket( - channel_, incoming_rtp_packet, packet_length, PacketTime()); -} - -void VideoChannelTransport::IncomingRTCPPacket( - const int8_t* incoming_rtcp_packet, - const size_t packet_length, - const char* /*from_ip*/, - const uint16_t /*from_port*/) { - vie_network_->ReceivedRTCPPacket(channel_, incoming_rtcp_packet, - packet_length); -} - -int VideoChannelTransport::SetLocalReceiver(uint16_t rtp_port) { - int return_value = socket_transport_->InitializeReceiveSockets(this, - rtp_port); - if (return_value == 0) { - return socket_transport_->StartReceiving(kViENumReceiveSocketBuffers); - } - return return_value; -} - -int VideoChannelTransport::SetSendDestination(const char* ip_address, - uint16_t rtp_port) { - return socket_transport_->InitializeSendSockets(ip_address, rtp_port); -} - } // namespace test } // namespace webrtc diff --git a/webrtc/test/channel_transport/include/channel_transport.h b/webrtc/test/channel_transport/include/channel_transport.h index 77107d94d5..8b84517de0 100644 --- a/webrtc/test/channel_transport/include/channel_transport.h +++ b/webrtc/test/channel_transport/include/channel_transport.h @@ -15,7 +15,6 @@ namespace webrtc { -class ViENetwork; class VoENetwork; namespace test { @@ -51,37 +50,6 @@ class VoiceChannelTransport : public UdpTransportData { UdpTransport* socket_transport_; }; -// Helper class for VideoEngine tests. -class VideoChannelTransport : public UdpTransportData { - public: - VideoChannelTransport(ViENetwork* vie_network, int channel); - - virtual ~VideoChannelTransport(); - - // Start implementation of UdpTransportData. - void IncomingRTPPacket(const int8_t* incoming_rtp_packet, - const size_t packet_length, - const char* /*from_ip*/, - const uint16_t /*from_port*/) override; - - void IncomingRTCPPacket(const int8_t* incoming_rtcp_packet, - const size_t packet_length, - const char* /*from_ip*/, - const uint16_t /*from_port*/) override; - // End implementation of UdpTransportData. - - // Specifies the ports to receive RTP packets on. - int SetLocalReceiver(uint16_t rtp_port); - - // Specifies the destination port and IP address for a specified channel. - int SetSendDestination(const char* ip_address, uint16_t rtp_port); - - private: - int channel_; - ViENetwork* vie_network_; - UdpTransport* socket_transport_; -}; - } // namespace test } // namespace webrtc diff --git a/webrtc/video/receive_statistics_proxy.h b/webrtc/video/receive_statistics_proxy.h index 204ceb74ee..3e515658ed 100644 --- a/webrtc/video/receive_statistics_proxy.h +++ b/webrtc/video/receive_statistics_proxy.h @@ -19,8 +19,8 @@ #include "webrtc/frame_callback.h" #include "webrtc/modules/remote_bitrate_estimator/rate_statistics.h" #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h" -#include "webrtc/video_engine/include/vie_codec.h" #include "webrtc/video_engine/report_block_stats.h" +#include "webrtc/video_engine/vie_channel.h" #include "webrtc/video_receive_stream.h" #include "webrtc/video_renderer.h" diff --git a/webrtc/video/send_statistics_proxy.h b/webrtc/video/send_statistics_proxy.h index 5bc6a0bd78..6dc4a8adc4 100644 --- a/webrtc/video/send_statistics_proxy.h +++ b/webrtc/video/send_statistics_proxy.h @@ -21,8 +21,8 @@ #include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" #include "webrtc/modules/video_coding/main/interface/video_coding_defines.h" #include "webrtc/system_wrappers/interface/clock.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_codec.h" +#include "webrtc/video_engine/overuse_frame_detector.h" +#include "webrtc/video_engine/vie_encoder.h" #include "webrtc/video_send_stream.h" namespace webrtc { diff --git a/webrtc/video/video_send_stream.cc b/webrtc/video/video_send_stream.cc index d9868ab6bb..7b1bfaebcb 100644 --- a/webrtc/video/video_send_stream.cc +++ b/webrtc/video/video_send_stream.cc @@ -171,16 +171,14 @@ VideoSendStream::VideoSendStream( ConfigureSsrcs(); - char rtcp_cname[ViERTP_RTCP::KMaxRTCPCNameLength]; - DCHECK_LT(config_.rtp.c_name.length(), - static_cast(ViERTP_RTCP::KMaxRTCPCNameLength)); + char rtcp_cname[RTCP_CNAME_SIZE]; + DCHECK_LT(config_.rtp.c_name.length(), sizeof(rtcp_cname)); strncpy(rtcp_cname, config_.rtp.c_name.c_str(), sizeof(rtcp_cname) - 1); rtcp_cname[sizeof(rtcp_cname) - 1] = '\0'; vie_channel_->SetRTCPCName(rtcp_cname); - vie_capturer_ = ViECapturer::CreateViECapturer(module_process_thread_); - CHECK_EQ(0, vie_capturer_->RegisterFrameCallback(channel_id_, vie_encoder_)); + vie_capturer_ = new ViECapturer(module_process_thread_, vie_encoder_); vie_channel_->RegisterSendTransport(&transport_adapter_); // 28 to match packet overhead in ModuleRtpRtcpImpl. @@ -243,7 +241,6 @@ VideoSendStream::~VideoSendStream() { vie_channel_->DeregisterSendTransport(); vie_capturer_->RegisterCpuOveruseObserver(nullptr); - vie_capturer_->DeregisterFrameCallback(vie_encoder_); delete vie_capturer_; vie_encoder_->DeRegisterExternalEncoder( diff --git a/webrtc/video/video_send_stream.h b/webrtc/video/video_send_stream.h index 7e31b6dc9b..87bfc524e9 100644 --- a/webrtc/video/video_send_stream.h +++ b/webrtc/video/video_send_stream.h @@ -26,6 +26,7 @@ namespace webrtc { +class ChannelGroup; class CpuOveruseObserver; class ProcessThread; class ViECapturer; diff --git a/webrtc/video_engine/BUILD.gn b/webrtc/video_engine/BUILD.gn index 2e496417a5..a4947ceeea 100644 --- a/webrtc/video_engine/BUILD.gn +++ b/webrtc/video_engine/BUILD.gn @@ -35,57 +35,23 @@ source_set("video_engine_core") { "report_block_stats.h", "stream_synchronization.cc", "stream_synchronization.h", - "vie_base_impl.cc", - "vie_base_impl.h", - "vie_capture_impl.cc", - "vie_capture_impl.h", "vie_capturer.cc", "vie_capturer.h", "vie_channel.cc", "vie_channel_group.cc", "vie_channel_group.h", "vie_channel.h", - "vie_channel_manager.cc", - "vie_channel_manager.h", - "vie_codec_impl.cc", - "vie_codec_impl.h", "vie_defines.h", "vie_encoder.cc", "vie_encoder.h", - "vie_external_codec_impl.cc", - "vie_external_codec_impl.h", - "vie_file_image.cc", - "vie_file_image.h", "vie_frame_provider_base.cc", "vie_frame_provider_base.h", - "vie_image_process_impl.cc", - "vie_image_process_impl.h", - "vie_impl.cc", - "vie_impl.h", - "vie_input_manager.cc", - "vie_input_manager.h", - "vie_manager_base.cc", - "vie_manager_base.h", - "vie_network_impl.cc", - "vie_network_impl.h", "vie_receiver.cc", "vie_receiver.h", - "vie_ref_count.cc", - "vie_ref_count.h", "vie_remb.cc", "vie_remb.h", - "vie_renderer.cc", - "vie_renderer.h", - "vie_render_impl.cc", - "vie_render_impl.h", - "vie_render_manager.cc", - "vie_render_manager.h", - "vie_rtp_rtcp_impl.cc", - "vie_rtp_rtcp_impl.h", "vie_sender.cc", "vie_sender.h", - "vie_shared_data.cc", - "vie_shared_data.h", "vie_sync_module.cc", "vie_sync_module.h", ] diff --git a/webrtc/video_engine/include/vie_base.h b/webrtc/video_engine/include/vie_base.h deleted file mode 100644 index f5bec893a2..0000000000 --- a/webrtc/video_engine/include/vie_base.h +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This sub-API supports the following functionalities: -// -// - Creating and deleting VideoEngine instances. -// - Creating and deleting channels. -// - Connect a video channel with a corresponding voice channel for audio/video -// synchronization. -// - Start and stop sending and receiving. - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_BASE_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_BASE_H_ - -#include "webrtc/common_types.h" - -namespace webrtc { - -class Config; -class VoiceEngine; -class ReceiveStatisticsProxy; -class SendStatisticsProxy; - -// Internal-class forward declarations, used to break out implementations for -// the new video API to remove interface dependencies to the VideoEngine API -// See webrtc:1695. -class ChannelGroup; -class ViEChannel; -class ViEEncoder; -class ViESharedData; - -// CpuOveruseObserver is called when a system overuse is detected and -// VideoEngine cannot keep up the encoding frequency. -class CpuOveruseObserver { - public: - // Called as soon as an overuse is detected. - virtual void OveruseDetected() = 0; - // Called periodically when the system is not overused any longer. - virtual void NormalUsage() = 0; - - protected: - virtual ~CpuOveruseObserver() {} -}; - -struct CpuOveruseOptions { - CpuOveruseOptions() - : enable_capture_jitter_method(false), - low_capture_jitter_threshold_ms(20.0f), - high_capture_jitter_threshold_ms(30.0f), - enable_encode_usage_method(true), - low_encode_usage_threshold_percent(55), - high_encode_usage_threshold_percent(85), - low_encode_time_rsd_threshold(-1), - high_encode_time_rsd_threshold(-1), - enable_extended_processing_usage(true), - frame_timeout_interval_ms(1500), - min_frame_samples(120), - min_process_count(3), - high_threshold_consecutive_count(2) {} - - // Method based on inter-arrival jitter of captured frames. - bool enable_capture_jitter_method; - float low_capture_jitter_threshold_ms; // Threshold for triggering underuse. - float high_capture_jitter_threshold_ms; // Threshold for triggering overuse. - // Method based on encode time of frames. - bool enable_encode_usage_method; - int low_encode_usage_threshold_percent; // Threshold for triggering underuse. - int high_encode_usage_threshold_percent; // Threshold for triggering overuse. - // TODO(asapersson): Remove options, not used. - int low_encode_time_rsd_threshold; // Additional threshold for triggering - // underuse (used in addition to - // threshold above if configured). - int high_encode_time_rsd_threshold; // Additional threshold for triggering - // overuse (used in addition to - // threshold above if configured). - bool enable_extended_processing_usage; // Include a larger time span (in - // addition to encode time) for - // measuring the processing time of a - // frame. - // General settings. - int frame_timeout_interval_ms; // The maximum allowed interval between two - // frames before resetting estimations. - int min_frame_samples; // The minimum number of frames required. - int min_process_count; // The number of initial process times required before - // triggering an overuse/underuse. - int high_threshold_consecutive_count; // The number of consecutive checks - // above the high threshold before - // triggering an overuse. - - bool Equals(const CpuOveruseOptions& o) const { - return enable_capture_jitter_method == o.enable_capture_jitter_method && - low_capture_jitter_threshold_ms == o.low_capture_jitter_threshold_ms && - high_capture_jitter_threshold_ms == - o.high_capture_jitter_threshold_ms && - enable_encode_usage_method == o.enable_encode_usage_method && - low_encode_usage_threshold_percent == - o.low_encode_usage_threshold_percent && - high_encode_usage_threshold_percent == - o.high_encode_usage_threshold_percent && - low_encode_time_rsd_threshold == o.low_encode_time_rsd_threshold && - high_encode_time_rsd_threshold == o.high_encode_time_rsd_threshold && - enable_extended_processing_usage == - o.enable_extended_processing_usage && - frame_timeout_interval_ms == o.frame_timeout_interval_ms && - min_frame_samples == o.min_frame_samples && - min_process_count == o.min_process_count && - high_threshold_consecutive_count == o.high_threshold_consecutive_count; - } -}; - -struct CpuOveruseMetrics { - CpuOveruseMetrics() - : capture_jitter_ms(-1), - avg_encode_time_ms(-1), - encode_usage_percent(-1), - capture_queue_delay_ms_per_s(-1) {} - - int capture_jitter_ms; // The current estimated jitter in ms based on - // incoming captured frames. - int avg_encode_time_ms; // The average encode time in ms. - int encode_usage_percent; // The average encode time divided by the average - // time difference between incoming captured frames. - int capture_queue_delay_ms_per_s; // The current time delay between an - // incoming captured frame until the frame - // is being processed. The delay is - // expressed in ms delay per second. -}; - -class CpuOveruseMetricsObserver { - public: - virtual ~CpuOveruseMetricsObserver() {} - virtual void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) = 0; -}; - -class WEBRTC_DLLEXPORT VideoEngine { - public: - // Creates a VideoEngine object, which can then be used to acquire sub‐APIs. - static VideoEngine* Create(); - static VideoEngine* Create(const Config& config); - - // Deletes a VideoEngine instance. - static bool Delete(VideoEngine*& video_engine); - - // Specifies the amount and type of trace information, which will be created - // by the VideoEngine. - static int SetTraceFilter(const unsigned int filter); - - // Sets the name of the trace file and enables non‐encrypted trace messages. - static int SetTraceFile(const char* file_nameUTF8, - const bool add_file_counter = false); - - // Installs the TraceCallback implementation to ensure that the VideoEngine - // user receives callbacks for generated trace messages. - static int SetTraceCallback(TraceCallback* callback); - - protected: - VideoEngine() {} - virtual ~VideoEngine() {} -}; - -class WEBRTC_DLLEXPORT ViEBase { - public: - // Factory for the ViEBase sub‐API and increases an internal reference - // counter if successful. Returns NULL if the API is not supported or if - // construction fails. - static ViEBase* GetInterface(VideoEngine* video_engine); - - // Releases the ViEBase sub-API and decreases an internal reference counter. - // Returns the new reference count. This value should be zero - // for all sub-API:s before the VideoEngine object can be safely deleted. - virtual int Release() = 0; - - // Initiates all common parts of the VideoEngine. - virtual int Init() = 0; - - // Connects a VideoEngine instance to a VoiceEngine instance for audio video - // synchronization. - virtual int SetVoiceEngine(VoiceEngine* voice_engine) = 0; - - // Creates a new channel. - virtual int CreateChannel(int& video_channel) = 0; - - // Creates a new channel grouped together with |original_channel|. The channel - // can both send and receive video. It is assumed the channel is sending - // and/or receiving video to the same end-point. - // Note: |CreateReceiveChannel| will give better performance and network - // properties for receive only channels. - virtual int CreateChannel(int& video_channel, - int original_channel) = 0; - - virtual int CreateChannelWithoutDefaultEncoder(int& video_channel, - int original_channel) = 0; - - virtual ChannelGroup* GetChannelGroup(int channel_id) = 0; - virtual ViEChannel* GetChannel(int channel_id) = 0; - virtual ViEEncoder* GetEncoder(int channel_id) = 0; - - // Creates a new channel grouped together with |original_channel|. The channel - // can only receive video and it is assumed the remote end-point is the same - // as for |original_channel|. - virtual int CreateReceiveChannel(int& video_channel, - int original_channel) = 0; - - // Deletes an existing channel and releases the utilized resources. - virtual int DeleteChannel(const int video_channel) = 0; - - // Registers an observer to be called when an overuse is detected, see - // 'CpuOveruseObserver' for details. - // NOTE: This is still very experimental functionality. - virtual int RegisterCpuOveruseObserver(int channel, - CpuOveruseObserver* observer) = 0; - - // Sets options for cpu overuse detector. - virtual int SetCpuOveruseOptions(int channel, - const CpuOveruseOptions& options) = 0; - - // Gets cpu overuse measures. - virtual int GetCpuOveruseMetrics(int channel, CpuOveruseMetrics* metrics) = 0; - virtual void RegisterCpuOveruseMetricsObserver( - int channel, - CpuOveruseMetricsObserver* observer) = 0; - - // Registers a callback which is called when send-side delay statistics has - // been updated. - // TODO(holmer): Remove the default implementation when fakevideoengine.h has - // been updated. - virtual void RegisterSendSideDelayObserver( - int channel, SendSideDelayObserver* observer) {} - - // Specifies the VoiceEngine and VideoEngine channel pair to use for - // audio/video synchronization. - virtual int ConnectAudioChannel(const int video_channel, - const int audio_channel) = 0; - - // Disconnects a previously paired VideoEngine and VoiceEngine channel pair. - virtual int DisconnectAudioChannel(const int video_channel) = 0; - - // Starts sending packets to an already specified IP address and port number - // for a specified channel. - virtual int StartSend(const int video_channel) = 0; - - // Stops packets from being sent for a specified channel. - virtual int StopSend(const int video_channel) = 0; - - // Prepares VideoEngine for receiving packets on the specified channel. - virtual int StartReceive(const int video_channel) = 0; - - // Stops receiving incoming RTP and RTCP packets on the specified channel. - virtual int StopReceive(const int video_channel) = 0; - - // Retrieves the version information for VideoEngine and its components. - virtual int GetVersion(char version[1024]) = 0; - - // Returns the last VideoEngine error code. - virtual int LastError() = 0; - - virtual void RegisterSendStatisticsProxy( - int channel, - SendStatisticsProxy* send_statistics_proxy) = 0; - - virtual void RegisterReceiveStatisticsProxy( - int channel, - ReceiveStatisticsProxy* receive_statistics_proxy) = 0; - - virtual ViESharedData* shared_data() = 0; - - protected: - ViEBase() {} - virtual ~ViEBase() {} -}; - -} // namespace webrtc - -#endif // #define WEBRTC_VIDEO_ENGINE_MAIN_INTERFACE_VIE_BASE_H_ diff --git a/webrtc/video_engine/include/vie_capture.h b/webrtc/video_engine/include/vie_capture.h deleted file mode 100644 index 53072c2b8b..0000000000 --- a/webrtc/video_engine/include/vie_capture.h +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This sub-API supports the following functionalities: -// -// - Allocating capture devices. -// - Connect a capture device with one or more channels. -// - Start and stop capture devices. -// - Getting capture device capabilities. - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CAPTURE_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CAPTURE_H_ - -#include "webrtc/common_types.h" -#include "webrtc/common_video/rotation.h" -#include "webrtc/video_frame.h" - -namespace webrtc { - -class VideoEngine; -class VideoCaptureModule; - -// This structure describes one set of the supported capabilities for a capture -// device. -struct CaptureCapability { - unsigned int width; - unsigned int height; - unsigned int maxFPS; - RawVideoType rawType; - VideoCodecType codecType; - unsigned int expectedCaptureDelay; - bool interlaced; - CaptureCapability() { - width = 0; - height = 0; - maxFPS = 0; - rawType = kVideoI420; - codecType = kVideoCodecUnknown; - expectedCaptureDelay = 0; - interlaced = false; - } -}; - -// This enumerator tells the current brightness alarm mode. -enum Brightness { - Normal = 0, - Bright = 1, - Dark = 2 -}; - -// This enumerator describes the capture alarm mode. -enum CaptureAlarm { - AlarmRaised = 0, - AlarmCleared = 1 -}; - -// This class declares an abstract interface to be used when implementing -// a user-defined capture device. This interface is not meant to be -// implemented by the user. Instead, the user should call AllocateCaptureDevice -// in the ViECapture interface, which will create a suitable implementation. -// The user should then call IncomingFrame in this interface to deliver -// captured frames to the system. -class WEBRTC_DLLEXPORT ViEExternalCapture { - public: - ViEExternalCapture() {} - virtual ~ViEExternalCapture() {} - - // This method is called by the user to deliver a new captured frame to - // VideoEngine. - virtual void IncomingFrame(const I420VideoFrame& frame) = 0; -}; - -// This class declares an abstract interface for a user defined observer. It is -// up to the VideoEngine user to implement a derived class which implements the -// observer class. The observer is registered using RegisterObserver() and -// deregistered using DeregisterObserver(). -class WEBRTC_DLLEXPORT ViECaptureObserver { - public: - // This method is called if a bright or dark captured image is detected. - virtual void BrightnessAlarm(const int capture_id, - const Brightness brightness) = 0; - - // This method is called periodically telling the capture device frame rate. - virtual void CapturedFrameRate(const int capture_id, - const unsigned char frame_rate) = 0; - - // This method is called if the capture device stops delivering images to - // VideoEngine. - virtual void NoPictureAlarm(const int capture_id, - const CaptureAlarm alarm) = 0; - - protected: - virtual ~ViECaptureObserver() {} -}; - -class WEBRTC_DLLEXPORT ViECapture { - public: - // Factory for the ViECapture sub‐API and increases an internal reference - // counter if successful. Returns NULL if the API is not supported or if - // construction fails. - static ViECapture* GetInterface(VideoEngine* video_engine); - - // Releases the ViECapture sub-API and decreases an internal reference - // counter. - // Returns the new reference count. This value should be zero - // for all sub-API:s before the VideoEngine object can be safely deleted. - virtual int Release() = 0; - - // Gets the number of available capture devices. - virtual int NumberOfCaptureDevices() = 0; - - // Gets the name and unique id of a capture device. - virtual int GetCaptureDevice(unsigned int list_number, - char* device_nameUTF8, - const unsigned int device_nameUTF8Length, - char* unique_idUTF8, - const unsigned int unique_idUTF8Length) = 0; - - // Allocates a capture device to be used in VideoEngine. - virtual int AllocateCaptureDevice(const char* unique_idUTF8, - const unsigned int unique_idUTF8Length, - int& capture_id) = 0; - - // Registers an external capture device to be used in VideoEngine - virtual int AllocateExternalCaptureDevice( - int& capture_id, - ViEExternalCapture *&external_capture) = 0; - - // Use capture device using external capture module. - virtual int AllocateCaptureDevice(VideoCaptureModule& capture_module, - int& capture_id) = 0; - - // Releases a capture device and makes it available for other applications. - virtual int ReleaseCaptureDevice(const int capture_id) = 0; - - // This function connects a capture device with a channel. Multiple channels - // can be connected to the same capture device. - virtual int ConnectCaptureDevice(const int capture_id, - const int video_channel) = 0; - - // Disconnects a capture device as input for a specified channel. - virtual int DisconnectCaptureDevice(const int video_channel) = 0; - - // Makes a capture device start capturing video frames. - virtual int StartCapture( - const int capture_id, - const CaptureCapability& capture_capability = CaptureCapability()) = 0; - - // Stops a started capture device from capturing video frames. - virtual int StopCapture(const int capture_id) = 0; - - // Rotates captured frames before encoding and sending. - // Used on mobile devices with rotates cameras. - virtual int SetVideoRotation(const int capture_id, - const VideoRotation rotation) = 0; - - // This function sets the expected delay from when a video frame is captured - // to when that frame is delivered to VideoEngine. - virtual int SetCaptureDelay(const int capture_id, - const unsigned int capture_delay_ms) = 0; - - // Returns the number of sets of capture capabilities the capture device - // supports. - virtual int NumberOfCapabilities( - const char* unique_id_utf8, - const unsigned int unique_id_utf8_length) = 0; - - // Gets a set of capture capabilities for a specified capture device. - virtual int GetCaptureCapability(const char* unique_id_utf8, - const unsigned int unique_id_utf8_length, - const unsigned int capability_number, - CaptureCapability& capability) = 0; - - // Displays the capture device property dialog box for the specified capture - // device. Windows only. - virtual int ShowCaptureSettingsDialogBox( - const char* unique_idUTF8, - const unsigned int unique_id_utf8_length, - const char* dialog_title, - void* parent_window = NULL, - const unsigned int x = 200, - const unsigned int y = 200) = 0; - - // Gets the clockwise angle the frames from the camera must be rotated in - // order to display the frames correctly if the display is rotated in its - // natural orientation. - virtual int GetOrientation(const char* unique_id_utf8, - VideoRotation& orientation) = 0; - - // Enables brightness alarm detection and the brightness alarm callback. - virtual int EnableBrightnessAlarm(const int capture_id, - const bool enable) = 0; - - // Registers an instance of a user implementation of the ViECaptureObserver. - virtual int RegisterObserver(const int capture_id, - ViECaptureObserver& observer) = 0; - - // Removes an already registered instance of ViECaptureObserver. - virtual int DeregisterObserver(const int capture_id) = 0; - - protected: - ViECapture() {} - virtual ~ViECapture() {} -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CAPTURE_H_ diff --git a/webrtc/video_engine/include/vie_codec.h b/webrtc/video_engine/include/vie_codec.h deleted file mode 100644 index 4190d6bddb..0000000000 --- a/webrtc/video_engine/include/vie_codec.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This sub-API supports the following functionalities: -// - Setting send and receive codecs. -// - Codec specific settings. -// - Key frame signaling. -// - Stream management settings. - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CODEC_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CODEC_H_ - -#include "webrtc/common_types.h" - -namespace webrtc { - -class VideoEngine; -struct VideoCodec; - -// This class declares an abstract interface for a user defined observer. It is -// up to the VideoEngine user to implement a derived class which implements the -// observer class. The observer is registered using RegisterEncoderObserver() -// and deregistered using DeregisterEncoderObserver(). -class WEBRTC_DLLEXPORT ViEEncoderObserver { - public: - // This method is called once per second with the current encoded frame rate - // and bit rate. - virtual void OutgoingRate(const int video_channel, - const unsigned int framerate, - const unsigned int bitrate) = 0; - - // This method is called whenever the state of the SuspendBelowMinBitrate - // changes, i.e., when |is_suspended| toggles. - virtual void SuspendChange(int video_channel, bool is_suspended) = 0; - - protected: - virtual ~ViEEncoderObserver() {} -}; - -// This class declares an abstract interface for a user defined observer. It is -// up to the VideoEngine user to implement a derived class which implements the -// observer class. The observer is registered using RegisterDecoderObserver() -// and deregistered using DeregisterDecoderObserver(). -class WEBRTC_DLLEXPORT ViEDecoderObserver { - public: - // This method is called when a new incoming stream is detected, normally - // triggered by a new incoming SSRC or payload type. - virtual void IncomingCodecChanged(const int video_channel, - const VideoCodec& video_codec) = 0; - - // This method is called once per second containing the frame rate and bit - // rate for the incoming stream - virtual void IncomingRate(const int video_channel, - const unsigned int framerate, - const unsigned int bitrate) = 0; - - // Called periodically with decoder timing information. All values are - // "current" snapshots unless decorated with a min_/max_ prefix. - virtual void DecoderTiming(int decode_ms, - int max_decode_ms, - int current_delay_ms, - int target_delay_ms, - int jitter_buffer_ms, - int min_playout_delay_ms, - int render_delay_ms) = 0; - - // This method is called when the decoder needs a new key frame from encoder - // on the sender. - virtual void RequestNewKeyFrame(const int video_channel) = 0; - - protected: - virtual ~ViEDecoderObserver() {} -}; - -class WEBRTC_DLLEXPORT ViECodec { - public: - // Factory for the ViECodec sub‐API and increases an internal reference - // counter if successful. Returns NULL if the API is not supported or if - // construction fails. - static ViECodec* GetInterface(VideoEngine* video_engine); - - // Releases the ViECodec sub-API and decreases an internal reference - // counter. - // Returns the new reference count. This value should be zero - // for all sub-API:s before the VideoEngine object can be safely deleted. - virtual int Release() = 0; - - // Gets the number of available codecs for the VideoEngine build. - virtual int NumberOfCodecs() const = 0; - - // Gets a VideoCodec struct for a codec containing the default configuration - // for that codec type. - virtual int GetCodec(const unsigned char list_number, - VideoCodec& video_codec) const = 0; - - // Sets the send codec to use for a specified channel. - virtual int SetSendCodec(const int video_channel, - const VideoCodec& video_codec) = 0; - - // Gets the current send codec settings. - virtual int GetSendCodec(const int video_channel, - VideoCodec& video_codec) const = 0; - - // Prepares VideoEngine to receive a certain codec type and setting for a - // specified payload type. - virtual int SetReceiveCodec(const int video_channel, - const VideoCodec& video_codec) = 0; - - // Gets the current receive codec. - virtual int GetReceiveCodec(const int video_channel, - VideoCodec& video_codec) const = 0; - - // This function is used to get codec configuration parameters to be - // signaled from the encoder to the decoder in the call setup. - virtual int GetCodecConfigParameters( - const int video_channel, - unsigned char config_parameters[kConfigParameterSize], - unsigned char& config_parameters_size) const = 0; - - // Enables advanced scaling of the captured video stream if the stream - // differs from the send codec settings. - virtual int SetImageScaleStatus(const int video_channel, - const bool enable) = 0; - - // Gets the number of sent key frames and number of sent delta frames. - virtual int GetSendCodecStastistics(const int video_channel, - unsigned int& key_frames, - unsigned int& delta_frames) const = 0; - - // Gets the number of decoded key frames and number of decoded delta frames. - virtual int GetReceiveCodecStastistics(const int video_channel, - unsigned int& key_frames, - unsigned int& delta_frames) const = 0; - - // Estimate of the min required buffer time from the expected arrival time - // until rendering to get smooth playback. - virtual int GetReceiveSideDelay(const int video_channel, - int* delay_ms) const = 0; - - // Current target bitrate for this channel. - virtual uint32_t GetLastObservedBitrateBps(int video_channel) const = 0; - // Gets the bitrate targeted by the video codec rate control in kbit/s. - virtual int GetCodecTargetBitrate(const int video_channel, - unsigned int* bitrate) const = 0; - - // Gets the number of packets discarded by the jitter buffer because they - // arrived too late. - // TODO(asapersson): Remove default implementation. - virtual int GetNumDiscardedPackets(int video_channel) const { return -1; } - - // TODO(asapersson): Remove once the api has been removed from - // fakewebrtcvideoengine.h. - virtual unsigned int GetDiscardedPackets( - const int video_channel) const { return 0; } - - // Enables key frame request callback in ViEDecoderObserver. - virtual int SetKeyFrameRequestCallbackStatus(const int video_channel, - const bool enable) = 0; - - // Enables key frame requests for detected lost packets. - virtual int SetSignalKeyPacketLossStatus( - const int video_channel, - const bool enable, - const bool only_key_frames = false) = 0; - - // Registers an instance of a user implementation of the ViEEncoderObserver. - virtual int RegisterEncoderObserver(const int video_channel, - ViEEncoderObserver& observer) = 0; - - // Removes an already registered instance of ViEEncoderObserver. - virtual int DeregisterEncoderObserver(const int video_channel) = 0; - - // Registers an instance of a user implementation of the ViEDecoderObserver. - virtual int RegisterDecoderObserver(const int video_channel, - ViEDecoderObserver& observer) = 0; - - // Removes an already registered instance of ViEDecoderObserver. - virtual int DeregisterDecoderObserver(const int video_channel) = 0; - - // This function forces the next encoded frame to be a key frame. This is - // normally used when the remote endpoint only supports out‐band key frame - // request. - virtual int SendKeyFrame(const int video_channel) = 0; - - // This function makes the decoder wait for a key frame before starting to - // decode the incoming video stream. - virtual int WaitForFirstKeyFrame(const int video_channel, - const bool wait) = 0; - - // Enables recording of debugging information. - virtual int StartDebugRecording(int video_channel, - const char* file_name_utf8) = 0; - // Disables recording of debugging information. - virtual int StopDebugRecording(int video_channel) = 0; - - // Lets the sender suspend video when the rate drops below - // |threshold_bps|, and turns back on when the rate goes back up above - // |threshold_bps| + |window_bps|. - // This is under development; not tested. - virtual void SuspendBelowMinBitrate(int video_channel) = 0; - - // TODO(holmer): Remove this default implementation when possible. - virtual bool GetSendSideDelay(int video_channel, int* avg_delay_ms, - int* max_delay_ms) const { return false; } - - protected: - ViECodec() {} - virtual ~ViECodec() {} -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_CODEC_H_ diff --git a/webrtc/video_engine/include/vie_errors.h b/webrtc/video_engine/include/vie_errors.h deleted file mode 100644 index 24aa0980bb..0000000000 --- a/webrtc/video_engine/include/vie_errors.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_ERRORS_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_ERRORS_H_ - -enum ViEErrors { - // ViEBase. - kViENotInitialized = 12000, // Init has not been called successfully. - kViEBaseVoEFailure, // SetVoiceEngine. ViE failed to use VE instance. Check VE instance pointer.ConnectAudioChannel failed to set voice channel. Have SetVoiceEngine been called? Is the voice channel correct. - kViEBaseChannelCreationFailed, // CreateChannel. - kViEBaseInvalidChannelId, // The channel does not exist. - kViEAPIDoesNotExist, // Release called on Interface that has not been created. - kViEBaseInvalidArgument, - kViEBaseAlreadySending, // StartSend called on channel that is already sending. - kViEBaseNotSending, // StopSend called on channel that is not sending. - kViEBaseReceiveOnlyChannel, // Can't send on a receive only channel. - kViEBaseAlreadyReceiving, // StartReceive called on channel that is already receiving. - kViEBaseObserverAlreadyRegistered, // RegisterObserver- an observer has already been set. - kViEBaseObserverNotRegistered, // DeregisterObserver - no observer has been registered. - kViEBaseUnknownError, // An unknown error has occurred. Check the log file. - - // ViECodec. - kViECodecInvalidArgument = 12100, // Wrong input parameter to function. - kViECodecObserverAlreadyRegistered, // RegisterEncoderObserver, RegisterDecoderObserver. - kViECodecObserverNotRegistered, // DeregisterEncoderObserver, DeregisterDecoderObserver. - kViECodecInvalidCodec, // SetSendCodec,SetReceiveCodec- The codec structure is invalid. - kViECodecInvalidChannelId, // The channel does not exist. - kViECodecInUse, // SetSendCodec- Can't change codec size or type when multiple channels use the same encoder. - kViECodecReceiveOnlyChannel, // SetSendCodec, can't change receive only channel. - kViECodecUnknownError, // An unknown error has occurred. Check the log file. - - // ViERender. - kViERenderInvalidRenderId = 12200, // No renderer with the ID exist. In AddRenderer - The render ID is invalid. No capture device, channel or file is allocated with that id. - kViERenderAlreadyExists, // AddRenderer: the renderer already exist. - kViERenderInvalidFrameFormat, // AddRender (external renderer). The user has requested a frame format that we don't support. - kViERenderUnknownError, // An unknown error has occurred. Check the log file. - - // ViECapture. - kViECaptureDeviceAlreadyConnected = 12300, // ConnectCaptureDevice - A capture device has already been connected to this video channel. - kViECaptureDeviceDoesNotExist, // No capture device exist with the provided capture id or unique name. - kViECaptureDeviceInvalidChannelId, // ConnectCaptureDevice, DisconnectCaptureDevice- No Channel exist with the provided channel id. - kViECaptureDeviceNotConnected, // DisconnectCaptureDevice- No capture device is connected to the channel. - kViECaptureDeviceNotStarted, // Stop- The capture device is not started. - kViECaptureDeviceAlreadyStarted, // Start- The capture device is already started. - kViECaptureDeviceAlreadyAllocated, // AllocateCaptureDevice The device is already allocated. - kViECaptureDeviceMaxNoDevicesAllocated, // AllocateCaptureDevice Max number of devices already allocated. - kViECaptureObserverAlreadyRegistered, // RegisterObserver- An observer is already registered. Need to deregister first. - kViECaptureDeviceObserverNotRegistered, // DeregisterObserver- No observer is registered. - kViECaptureDeviceUnknownError, // An unknown error has occurred. Check the log file. - kViECaptureDeviceMacQtkitNotSupported, // QTKit handles the capture devices automatically. Thus querying capture capabilities is not supported. - - // ViEFile. - kViEFileInvalidChannelId = 12400, // No Channel exist with the provided channel id. - kViEFileInvalidArgument, // Incorrect input argument - kViEFileAlreadyRecording, // StartRecordOutgoingVideo - already recording channel - kViEFileVoENotSet, // StartRecordOutgoingVideo. Failed to access voice engine. Has SetVoiceEngine been called? - kViEFileNotRecording, // StopRecordOutgoingVideo - kViEFileMaxNoOfFilesOpened, // StartPlayFile - kViEFileNotPlaying, // StopPlayFile. The file with the provided id is not playing. - kViEFileObserverAlreadyRegistered, // RegisterObserver - kViEFileObserverNotRegistered, // DeregisterObserver - kViEFileInputAlreadyConnected, // SendFileOnChannel- the video channel already have a connected input. - kViEFileNotConnected, // StopSendFileOnChannel- No file is being sent on the channel. - kViEFileVoEFailure, // SendFileOnChannel,StartPlayAudioLocally - failed to play audio stream - kViEFileInvalidRenderId, // SetRenderTimeoutImage and SetRenderStartImage: Renderer with the provided render id does not exist. - kViEFileInvalidFile, // Can't open the file with provided filename. Is the path and file format correct? - kViEFileInvalidCapture, // Can't use ViEPicture. Is the object correct? - kViEFileSetRenderTimeoutError, // SetRenderTimeoutImage- Please see log file. - kViEFileSetStartImageError, // SetRenderStartImage error. Please see log file. - kViEFileUnknownError, // An unknown error has occurred. Check the log file. - - // ViENetwork. - kViENetworkInvalidChannelId = 12500, // No Channel exist with the provided channel id. - kViENetworkAlreadyReceiving, // SetLocalReceiver: Can not change ports while receiving. - kViENetworkLocalReceiverNotSet, // GetLocalReceiver: SetLocalReceiver not called. - kViENetworkAlreadySending, // SetSendDestination - kViENetworkDestinationNotSet, // GetSendDestination - kViENetworkInvalidArgument, // GetLocalIP- Check function arguments. - kViENetworkSendCodecNotSet, // SetSendGQoS- Need to set the send codec first. - kViENetworkServiceTypeNotSupported, // SetSendGQoS - kViENetworkNotSupported, // SetSendGQoS Not supported on this OS. - kViENetworkUnknownError, // An unknown error has occurred. Check the log file. - - // ViERTP_RTCP. - kViERtpRtcpInvalidChannelId = 12600, // No Channel exist with the provided channel id. - kViERtpRtcpAlreadySending, // The channel is already sending. Need to stop send before calling this API. - kViERtpRtcpNotSending, // The channel needs to be sending in order for this function to work. - kViERtpRtcpRtcpDisabled, // Functions failed because RTCP is disabled. - kViERtpRtcpObserverAlreadyRegistered, // An observer is already registered. Need to deregister the old first. - kViERtpRtcpObserverNotRegistered, // No observer registered. - kViERtpRtcpUnknownError, // An unknown error has occurred. Check the log file. - - // ViEImageProcess. - kViEImageProcessInvalidChannelId = 12800, // No Channel exist with the provided channel id. - kViEImageProcessInvalidCaptureId, // No capture device exist with the provided capture id. - kViEImageProcessFilterExists, // RegisterCaptureEffectFilter,RegisterSendEffectFilter,RegisterRenderEffectFilter - Effect filter already registered. - kViEImageProcessFilterDoesNotExist, // DeRegisterCaptureEffectFilter,DeRegisterSendEffectFilter,DeRegisterRenderEffectFilter - Effect filter not registered. - kViEImageProcessAlreadyEnabled, // EnableDeflickering,EnableColorEnhancement- Function already enabled. - kViEImageProcessAlreadyDisabled, // EnableDeflickering,EnableColorEnhancement- Function already disabled. - kViEImageProcessUnknownError // An unknown error has occurred. Check the log file. -}; - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_ERRORS_H_ diff --git a/webrtc/video_engine/include/vie_external_codec.h b/webrtc/video_engine/include/vie_external_codec.h deleted file mode 100644 index 99018dbcd2..0000000000 --- a/webrtc/video_engine/include/vie_external_codec.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_EXTERNAL_CODEC_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_EXTERNAL_CODEC_H_ - -#include "webrtc/common_types.h" - -namespace webrtc { - -class VideoDecoder; -class VideoEncoder; -class VideoEngine; - -class WEBRTC_DLLEXPORT ViEExternalCodec { - public: - static ViEExternalCodec* GetInterface(VideoEngine* video_engine); - - virtual int Release() = 0; - - virtual int RegisterExternalSendCodec(const int video_channel, - const unsigned char pl_type, - VideoEncoder* encoder, - bool internal_source) = 0; - - virtual int DeRegisterExternalSendCodec(const int video_channel, - const unsigned char pl_type) = 0; - - virtual int RegisterExternalReceiveCodec(const int video_channel, - const unsigned char pl_type, - VideoDecoder* decoder, - bool decoder_render = false, - int render_delay = 0) = 0; - - virtual int DeRegisterExternalReceiveCodec(const int video_channel, - const unsigned char pl_type) = 0; - - protected: - ViEExternalCodec() {} - virtual ~ViEExternalCodec() {} -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_EXTERNAL_CODEC_H_ diff --git a/webrtc/video_engine/include/vie_image_process.h b/webrtc/video_engine/include/vie_image_process.h deleted file mode 100644 index 4a05a062e5..0000000000 --- a/webrtc/video_engine/include/vie_image_process.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This sub-API supports the following functionalities: -// - Effect filters -// - Deflickering -// - Color enhancement - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ - -#include "webrtc/common_types.h" - -namespace webrtc { - -class EncodedImageCallback; -class I420FrameCallback; -class VideoEngine; - -// This class declares an abstract interface for a user defined effect filter. -// The effect filter is registered using RegisterCaptureEffectFilter(), -// RegisterSendEffectFilter() or RegisterRenderEffectFilter() and deregistered -// with the corresponding deregister function. -class WEBRTC_DLLEXPORT ViEEffectFilter { - public: - // This method is called with an I420 video frame allowing the user to - // modify the video frame. - virtual int Transform(size_t size, - unsigned char* frame_buffer, - int64_t ntp_time_ms, - unsigned int timestamp, - unsigned int width, - unsigned int height) = 0; - protected: - ViEEffectFilter() {} - virtual ~ViEEffectFilter() {} -}; - -class WEBRTC_DLLEXPORT ViEImageProcess { - public: - // Factory for the ViEImageProcess sub‐API and increases an internal - // reference counter if successful. Returns NULL if the API is not supported - // or if construction fails. - static ViEImageProcess* GetInterface(VideoEngine* video_engine); - - // Releases the ViEImageProcess sub-API and decreases an internal reference - // counter. Returns the new reference count. This value should be zero - // for all sub-API:s before the VideoEngine object can be safely deleted. - virtual int Release() = 0; - - // This function registers a EffectFilter to use for a specified capture - // device. - virtual int RegisterCaptureEffectFilter(const int capture_id, - ViEEffectFilter& capture_filter) = 0; - - // This function deregisters a EffectFilter for a specified capture device. - virtual int DeregisterCaptureEffectFilter(const int capture_id) = 0; - - // This function registers an EffectFilter to use for a specified channel. - virtual int RegisterSendEffectFilter(const int video_channel, - ViEEffectFilter& send_filter) = 0; - - // This function deregisters a send effect filter for a specified channel. - virtual int DeregisterSendEffectFilter(const int video_channel) = 0; - - // This function registers a EffectFilter to use for the rendered video - // stream on an incoming channel. - virtual int RegisterRenderEffectFilter(const int video_channel, - ViEEffectFilter& render_filter) = 0; - - // This function deregisters a render effect filter for a specified channel. - virtual int DeregisterRenderEffectFilter(const int video_channel) = 0; - - // All cameras run the risk of getting in almost perfect sync with - // florescent lamps, which will result in a very annoying flickering of the - // image. Most cameras have some type of filter to protect against this but - // not all of them succeed. Enabling this function will remove the flicker. - virtual int EnableDeflickering(const int capture_id, const bool enable) = 0; - - // TODO(pbos): Remove this function when removed from fakewebrtcvideoengine.h. - virtual int EnableDenoising(const int capture_id, const bool enable) { - return -1; - } - - // This function enhances the colors on the decoded video stream, enabled by - // default. - virtual int EnableColorEnhancement(const int video_channel, - const bool enable) = 0; - - protected: - ViEImageProcess() {} - virtual ~ViEImageProcess() {} -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_IMAGE_PROCESS_H_ diff --git a/webrtc/video_engine/include/vie_network.h b/webrtc/video_engine/include/vie_network.h deleted file mode 100644 index e962e729aa..0000000000 --- a/webrtc/video_engine/include/vie_network.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_ - -// This sub-API supports the following functionalities: -// - Configuring send and receive addresses. -// - External transport support. -// - Port and address filters. -// - Windows GQoS functions and ToS functions. -// - Packet timeout notification. -// - Dead‐or‐Alive connection observations. - -#include "webrtc/common_types.h" - -namespace webrtc { - -class Transport; -class VideoEngine; - -// This enumerator describes VideoEngine packet timeout states. -enum ViEPacketTimeout { - NoPacket = 0, - PacketReceived = 1 -}; - -class WEBRTC_DLLEXPORT ViENetwork { - public: - // Default values. - enum { KDefaultSampleTimeSeconds = 2 }; - - // Factory for the ViENetwork sub‐API and increases an internal reference - // counter if successful. Returns NULL if the API is not supported or if - // construction fails. - static ViENetwork* GetInterface(VideoEngine* video_engine); - - // Releases the ViENetwork sub-API and decreases an internal reference - // counter.Returns the new reference count. This value should be zero - // for all sub-API:s before the VideoEngine object can be safely deleted. - virtual int Release() = 0; - - virtual void SetBitrateConfig(int video_channel, - int min_bitrate_bps, - int start_bitrate_bps, - int max_bitrate_bps) = 0; - - // Inform the engine about if the network adapter is currently transmitting - // packets or not. - virtual void SetNetworkTransmissionState(const int video_channel, - const bool is_transmitting) = 0; - - // This function registers a user implementation of Transport to use for - // sending RTP and RTCP packets on this channel. - virtual int RegisterSendTransport(const int video_channel, - Transport& transport) = 0; - - // This function deregisters a used Transport for a specified channel. - virtual int DeregisterSendTransport(const int video_channel) = 0; - - // When using external transport for a channel, received RTP packets should - // be passed to VideoEngine using this function. The input should contain - // the RTP header and payload. - virtual int ReceivedRTPPacket(const int video_channel, - const void* data, - const size_t length, - const PacketTime& packet_time) = 0; - - // When using external transport for a channel, received RTCP packets should - // be passed to VideoEngine using this function. - virtual int ReceivedRTCPPacket(const int video_channel, - const void* data, - const size_t length) = 0; - - // This function sets the Maximum Transition Unit (MTU) for a channel. The - // RTP packet will be packetized based on this MTU to optimize performance - // over the network. - virtual int SetMTU(int video_channel, unsigned int mtu) = 0; - - // Forward (audio) packet to bandwidth estimator for the given video channel, - // for aggregated audio+video BWE. - virtual int ReceivedBWEPacket(const int video_channel, - int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header) { - return 0; - } - - protected: - ViENetwork() {} - virtual ~ViENetwork() {} -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_NETWORK_H_ diff --git a/webrtc/video_engine/include/vie_render.h b/webrtc/video_engine/include/vie_render.h deleted file mode 100644 index a38d20b8c0..0000000000 --- a/webrtc/video_engine/include/vie_render.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This sub-API supports the following functionalities: -// - Specify render destinations for incoming video streams, capture devices -// and files. -// - Configuring render streams. - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_ - -#include "webrtc/common_types.h" - -namespace webrtc { - -class I420VideoFrame; -class VideoEngine; -class VideoRender; -class VideoRenderCallback; - -// This class declares an abstract interface to be used for external renderers. -// The user implemented derived class is registered using AddRenderer(). -class ExternalRenderer { - public: - // This method will be called when the stream to be rendered changes in - // resolution or number of streams mixed in the image. - virtual int FrameSizeChange(unsigned int width, - unsigned int height, - unsigned int number_of_streams) = 0; - - // This method is called when a new frame should be rendered. - virtual int DeliverFrame(unsigned char* buffer, - size_t buffer_size, - // RTP timestamp in 90kHz. - uint32_t timestamp, - // NTP time of the capture time in local timebase - // in milliseconds. - int64_t ntp_time_ms, - // Wallclock render time in milliseconds. - int64_t render_time_ms, - // Handle of the underlying video frame. - void* handle) = 0; - - // Alternative interface for I420 frames. - virtual int DeliverI420Frame(const I420VideoFrame& webrtc_frame) = 0; - - // Returns true if the renderer supports textures. DeliverFrame can be called - // with NULL |buffer| and non-NULL |handle|. - virtual bool IsTextureSupported() = 0; - - protected: - virtual ~ExternalRenderer() {} -}; - -class ViERender { - public: - // Factory for the ViERender sub‐API and increases an internal reference - // counter if successful. Returns NULL if the API is not supported or if - // construction fails. - static ViERender* GetInterface(VideoEngine* video_engine); - - // Releases the ViERender sub-API and decreases an internal reference - // counter. Returns the new reference count. This value should be zero - // for all sub-API:s before the VideoEngine object can be safely deleted. - virtual int Release() = 0; - - // Registers render module. - virtual int RegisterVideoRenderModule(VideoRender& render_module) = 0; - - // Deregisters render module. - virtual int DeRegisterVideoRenderModule(VideoRender& render_module) = 0; - - // Sets the render destination for a given render ID. - virtual int AddRenderer(const int render_id, - void* window, - const unsigned int z_order, - const float left, - const float top, - const float right, - const float bottom) = 0; - - // Removes the renderer for a stream. - virtual int RemoveRenderer(const int render_id) = 0; - - // Starts rendering a render stream. - virtual int StartRender(const int render_id) = 0; - - // Stops rendering a render stream. - virtual int StopRender(const int render_id) = 0; - - // Set expected render time needed by graphics card or external renderer, i.e. - // the number of ms a frame will be sent to rendering before the actual render - // time. - virtual int SetExpectedRenderDelay(int render_id, int render_delay) = 0; - - // Configures an already added render stream. - virtual int ConfigureRender(int render_id, - const unsigned int z_order, - const float left, - const float top, - const float right, - const float bottom) = 0; - - // External render. - virtual int AddRenderer(const int render_id, - RawVideoType video_input_format, - ExternalRenderer* renderer) = 0; - - protected: - ViERender() {} - virtual ~ViERender() {} -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_ diff --git a/webrtc/video_engine/include/vie_rtp_rtcp.h b/webrtc/video_engine/include/vie_rtp_rtcp.h deleted file mode 100644 index 7b72b80817..0000000000 --- a/webrtc/video_engine/include/vie_rtp_rtcp.h +++ /dev/null @@ -1,469 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This sub-API supports the following functionalities: -// - Callbacks for RTP and RTCP events such as modified SSRC or CSRC. -// - SSRC handling. -// - Transmission of RTCP reports. -// - Obtaining RTCP data from incoming RTCP sender reports. -// - RTP and RTCP statistics (jitter, packet loss, RTT etc.). -// - Forward Error Correction (FEC). -// - Writing RTP and RTCP packets to binary files for off‐line analysis of the -// call quality. -// - Inserting extra RTP packets into active audio stream. - -#ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RTP_RTCP_H_ -#define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RTP_RTCP_H_ - -#include "webrtc/common_types.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" - -namespace webrtc { - -class VideoEngine; -struct ReceiveBandwidthEstimatorStats; - -// This enumerator sets the RTCP mode. -enum ViERTCPMode { - kRtcpNone = 0, - kRtcpCompound_RFC4585 = 1, - kRtcpNonCompound_RFC5506 = 2 -}; - -// This enumerator describes the key frame request mode. -enum ViEKeyFrameRequestMethod { - kViEKeyFrameRequestNone = 0, - kViEKeyFrameRequestPliRtcp = 1, - kViEKeyFrameRequestFirRtp = 2, - kViEKeyFrameRequestFirRtcp = 3 -}; - -enum StreamType { - kViEStreamTypeNormal = 0, // Normal media stream - kViEStreamTypeRtx = 1 // Retransmission media stream -}; - -// This class declares an abstract interface for a user defined observer. It is -// up to the VideoEngine user to implement a derived class which implements the -// observer class. The observer is registered using RegisterRTPObserver() and -// deregistered using DeregisterRTPObserver(). -class WEBRTC_DLLEXPORT ViERTPObserver { - public: - // This method is called if SSRC of the incoming stream is changed. - virtual void IncomingSSRCChanged(const int video_channel, - const unsigned int SSRC) = 0; - - // This method is called if a field in CSRC changes or if the number of - // CSRCs changes. - virtual void IncomingCSRCChanged(const int video_channel, - const unsigned int CSRC, - const bool added) = 0; - protected: - virtual ~ViERTPObserver() {} -}; - -class WEBRTC_DLLEXPORT ViERTP_RTCP { - public: - enum { KDefaultDeltaTransmitTimeSeconds = 15 }; - enum { KMaxRTCPCNameLength = 256 }; - - // Factory for the ViERTP_RTCP sub‐API and increases an internal reference - // counter if successful. Returns NULL if the API is not supported or if - // construction fails. - static ViERTP_RTCP* GetInterface(VideoEngine* video_engine); - - // Releases the ViERTP_RTCP sub-API and decreases an internal reference - // counter. Returns the new reference count. This value should be zero - // for all sub-API:s before the VideoEngine object can be safely deleted. - virtual int Release() = 0; - - // This function enables you to specify the RTP synchronization source - // identifier (SSRC) explicitly. - virtual int SetLocalSSRC(const int video_channel, - const unsigned int SSRC, - const StreamType usage = kViEStreamTypeNormal, - const unsigned char simulcast_idx = 0) = 0; - - // This function gets the SSRC for the outgoing RTP stream for the specified - // channel. - virtual int GetLocalSSRC(const int video_channel, - unsigned int& SSRC) const = 0; - - // This function map a incoming SSRC to a StreamType so that the engine - // can know which is the normal stream and which is the RTX - virtual int SetRemoteSSRCType(const int video_channel, - const StreamType usage, - const unsigned int SSRC) const = 0; - - // This function gets the SSRC for the incoming RTP stream for the specified - // channel. - virtual int GetRemoteSSRC(const int video_channel, - unsigned int& SSRC) const = 0; - - // This function returns the CSRCs of the incoming RTP packets. - virtual int GetRemoteCSRCs(const int video_channel, - unsigned int CSRCs[kRtpCsrcSize]) const = 0; - - // This sets a specific payload type for the RTX stream. Note that this - // doesn't enable RTX, SetLocalSSRC must still be called to enable RTX. - virtual int SetRtxSendPayloadType(const int video_channel, - const uint8_t payload_type, - const uint8_t associated_payload_type) = 0; - - virtual int SetRtxReceivePayloadType( - const int video_channel, - const uint8_t payload_type, - const uint8_t associated_payload_type) = 0; - - // This function enables manual initialization of the sequence number. The - // start sequence number is normally a random number. - virtual int SetStartSequenceNumber(const int video_channel, - unsigned short sequence_number) = 0; - - // TODO(pbos): Remove default implementation once this has been implemented - // in libjingle. - virtual void SetRtpStateForSsrc(int video_channel, - uint32_t ssrc, - const RtpState& rtp_state) {} - // TODO(pbos): Remove default implementation once this has been implemented - // in libjingle. - virtual RtpState GetRtpStateForSsrc(int video_channel, uint32_t ssrc) { - return RtpState(); - } - - // This function sets the RTCP status for the specified channel. - // Default mode is kRtcpCompound_RFC4585. - virtual int SetRTCPStatus(const int video_channel, - const ViERTCPMode rtcp_mode) = 0; - - // This function gets the RTCP status for the specified channel. - virtual int GetRTCPStatus(const int video_channel, - ViERTCPMode& rtcp_mode) const = 0; - - // This function sets the RTCP canonical name (CNAME) for the RTCP reports - // on a specific channel. - virtual int SetRTCPCName(const int video_channel, - const char rtcp_cname[KMaxRTCPCNameLength]) = 0; - - // TODO(holmer): Remove this API once it has been removed from - // fakewebrtcvideoengine.h. - virtual int GetRTCPCName(const int video_channel, - char rtcp_cname[KMaxRTCPCNameLength]) const { - return -1; - } - - // This function gets the RTCP canonical name (CNAME) for the RTCP reports - // received on the specified channel. - virtual int GetRemoteRTCPCName( - const int video_channel, - char rtcp_cname[KMaxRTCPCNameLength]) const = 0; - - // This function sends an RTCP APP packet on a specific channel. - virtual int SendApplicationDefinedRTCPPacket( - const int video_channel, - const unsigned char sub_type, - unsigned int name, - const char* data, - unsigned short data_length_in_bytes) = 0; - - // This function enables Negative Acknowledgment (NACK) using RTCP, - // implemented based on RFC 4585. NACK retransmits RTP packets if lost on - // the network. This creates a lossless transport at the expense of delay. - // If using NACK, NACK should be enabled on both endpoints in a call. - virtual int SetNACKStatus(const int video_channel, const bool enable) = 0; - - // This function enables Forward Error Correction (FEC) using RTCP, - // implemented based on RFC 5109, to improve packet loss robustness. Extra - // FEC packets are sent together with the usual media packets, hence - // part of the bitrate will be used for FEC packets. - virtual int SetFECStatus(const int video_channel, - const bool enable, - const unsigned char payload_typeRED, - const unsigned char payload_typeFEC) = 0; - - // This function enables hybrid Negative Acknowledgment using RTCP - // and Forward Error Correction (FEC) implemented based on RFC 5109, - // to improve packet loss robustness. Extra - // FEC packets are sent together with the usual media packets, hence will - // part of the bitrate be used for FEC packets. - // The hybrid mode will choose between nack only, fec only and both based on - // network conditions. When both are applied, only packets that were not - // recovered by the FEC will be nacked. - virtual int SetHybridNACKFECStatus(const int video_channel, - const bool enable, - const unsigned char payload_typeRED, - const unsigned char payload_typeFEC) = 0; - - // Sets send side support for delayed video buffering (actual delay will - // be exhibited on the receiver side). - // Target delay should be set to zero for real-time mode. - virtual int SetSenderBufferingMode(int video_channel, - int target_delay_ms) = 0; - // Sets receive side support for delayed video buffering. Target delay should - // be set to zero for real-time mode. - virtual int SetReceiverBufferingMode(int video_channel, - int target_delay_ms) = 0; - - // This function enables RTCP key frame requests. - virtual int SetKeyFrameRequestMethod( - const int video_channel, const ViEKeyFrameRequestMethod method) = 0; - - // This function enables signaling of temporary bitrate constraints using - // RTCP, implemented based on RFC4585. - virtual int SetTMMBRStatus(const int video_channel, const bool enable) = 0; - - // Enables and disables REMB packets for this channel. |sender| indicates - // this channel is encoding, |receiver| tells the bitrate estimate for - // this channel should be included in the REMB packet. - virtual int SetRembStatus(int video_channel, - bool sender, - bool receiver) = 0; - - // Enables RTP timestamp extension offset described in RFC 5450. This call - // must be done before ViECodec::SetSendCodec is called. - virtual int SetSendTimestampOffsetStatus(int video_channel, - bool enable, - int id) = 0; - - virtual int SetReceiveTimestampOffsetStatus(int video_channel, - bool enable, - int id) = 0; - - // Enables RTP absolute send time header extension. This call must be done - // before ViECodec::SetSendCodec is called. - virtual int SetSendAbsoluteSendTimeStatus(int video_channel, - bool enable, - int id) = 0; - - // When enabled for a channel, *all* channels on the same transport will be - // expected to include the absolute send time header extension. - virtual int SetReceiveAbsoluteSendTimeStatus(int video_channel, - bool enable, - int id) = 0; - - virtual int SetSendVideoRotationStatus(int video_channel, - bool enable, - int id) = 0; - - virtual int SetReceiveVideoRotationStatus(int video_channel, - bool enable, - int id) = 0; - - // Enables/disables RTCP Receiver Reference Time Report Block extension/ - // DLRR Report Block extension (RFC 3611). - virtual int SetRtcpXrRrtrStatus(int video_channel, bool enable) = 0; - - // Enables transmission smoothening, i.e. packets belonging to the same frame - // will be sent over a longer period of time instead of sending them - // back-to-back. - virtual int SetTransmissionSmoothingStatus(int video_channel, - bool enable) = 0; - - // Sets a minimal bitrate which will be padded to when the encoder doesn't - // produce enough bitrate. - // TODO(pbos): Remove default implementation when libjingle's - // FakeWebRtcVideoEngine is updated. - virtual int SetMinTransmitBitrate(int video_channel, - int min_transmit_bitrate_kbps) { - return -1; - }; - - // Set a constant amount to deduct from received bitrate estimates before - // using it to allocate capacity among outgoing video streams. - virtual int SetReservedTransmitBitrate( - int video_channel, unsigned int reserved_transmit_bitrate_bps) { - return 0; - } - - // This function returns our locally created statistics of the received RTP - // stream. - virtual int GetReceiveChannelRtcpStatistics(const int video_channel, - RtcpStatistics& basic_stats, - int64_t& rtt_ms) const = 0; - - // This function returns statistics reported by the remote client in RTCP - // report blocks. If several streams are reported, the statistics will be - // aggregated. - // If statistics are aggregated, extended_max_sequence_number is not reported, - // and will always be set to 0. - virtual int GetSendChannelRtcpStatistics(const int video_channel, - RtcpStatistics& basic_stats, - int64_t& rtt_ms) const = 0; - - // TODO(sprang): Temporary hacks to prevent libjingle build from failing, - // remove when libjingle has been lifted to support webrtc issue 2589 - virtual int GetReceivedRTCPStatistics(const int video_channel, - unsigned short& fraction_lost, - unsigned int& cumulative_lost, - unsigned int& extended_max, - unsigned int& jitter, - int64_t& rtt_ms) const { - RtcpStatistics stats; - int ret_code = GetReceiveChannelRtcpStatistics(video_channel, - stats, - rtt_ms); - fraction_lost = stats.fraction_lost; - cumulative_lost = stats.cumulative_lost; - extended_max = stats.extended_max_sequence_number; - jitter = stats.jitter; - return ret_code; - } - virtual int GetSentRTCPStatistics(const int video_channel, - unsigned short& fraction_lost, - unsigned int& cumulative_lost, - unsigned int& extended_max, - unsigned int& jitter, - int64_t& rtt_ms) const { - RtcpStatistics stats; - int ret_code = GetSendChannelRtcpStatistics(video_channel, - stats, - rtt_ms); - fraction_lost = stats.fraction_lost; - cumulative_lost = stats.cumulative_lost; - extended_max = stats.extended_max_sequence_number; - jitter = stats.jitter; - return ret_code; - } - - - virtual int RegisterSendChannelRtcpStatisticsCallback( - int video_channel, RtcpStatisticsCallback* callback) = 0; - - virtual int DeregisterSendChannelRtcpStatisticsCallback( - int video_channel, RtcpStatisticsCallback* callback) = 0; - - virtual int RegisterReceiveChannelRtcpStatisticsCallback( - int video_channel, RtcpStatisticsCallback* callback) = 0; - - virtual int DeregisterReceiveChannelRtcpStatisticsCallback( - int video_channel, RtcpStatisticsCallback* callback) = 0; - - // The function gets statistics from the sent and received RTP streams. - virtual int GetRtpStatistics(const int video_channel, - StreamDataCounters& sent, - StreamDataCounters& received) const = 0; - - // TODO(sprang): Temporary hacks to prevent libjingle build from failing, - // remove when libjingle has been lifted to support webrtc issue 2589 - virtual int GetRTPStatistics(const int video_channel, - size_t& bytes_sent, - unsigned int& packets_sent, - size_t& bytes_received, - unsigned int& packets_received) const { - StreamDataCounters sent; - StreamDataCounters received; - int ret_code = GetRtpStatistics(video_channel, sent, received); - bytes_sent = sent.transmitted.payload_bytes; - packets_sent = sent.transmitted.packets; - bytes_received = received.transmitted.payload_bytes; - packets_received = received.transmitted.packets; - return ret_code; - } - - virtual int RegisterSendChannelRtpStatisticsCallback( - int video_channel, StreamDataCountersCallback* callback) = 0; - - virtual int DeregisterSendChannelRtpStatisticsCallback( - int video_channel, StreamDataCountersCallback* callback) = 0; - - virtual int RegisterReceiveChannelRtpStatisticsCallback( - int video_channel, StreamDataCountersCallback* callback) = 0; - - virtual int DeregisterReceiveChannelRtpStatisticsCallback( - int video_channel, StreamDataCountersCallback* callback) = 0; - - - // Gets RTCP packet type statistics from a sent/received stream. - virtual int GetSendRtcpPacketTypeCounter( - int video_channel, - RtcpPacketTypeCounter* packet_counter) const = 0; - - virtual int GetReceiveRtcpPacketTypeCounter( - int video_channel, - RtcpPacketTypeCounter* packet_counter) const = 0; - - // The function gets bandwidth usage statistics from the sent RTP streams in - // bits/s. - virtual int GetBandwidthUsage(const int video_channel, - unsigned int& total_bitrate_sent, - unsigned int& video_bitrate_sent, - unsigned int& fec_bitrate_sent, - unsigned int& nackBitrateSent) const = 0; - - // (De)Register an observer, called whenever the send bitrate is updated - virtual int RegisterSendBitrateObserver( - int video_channel, - BitrateStatisticsObserver* observer) = 0; - - virtual int DeregisterSendBitrateObserver( - int video_channel, - BitrateStatisticsObserver* observer) = 0; - - // This function gets the send-side estimated bandwidth available for video, - // including overhead, in bits/s. - virtual int GetEstimatedSendBandwidth( - const int video_channel, - unsigned int* estimated_bandwidth) const = 0; - - // This function gets the receive-side estimated bandwidth available for - // video, including overhead, in bits/s. |estimated_bandwidth| is 0 if there - // is no valid estimate. - virtual int GetEstimatedReceiveBandwidth( - const int video_channel, - unsigned int* estimated_bandwidth) const = 0; - - // This function gets the PacedSender queuing delay for the last sent frame. - // TODO(jiayl): remove the default impl when libjingle is updated. - virtual int GetPacerQueuingDelayMs( - const int video_channel, int64_t* delay_ms) const { - return -1; - } - - // This function enables capturing of RTP packets to a binary file on a - // specific channel and for a given direction. The file can later be - // replayed using e.g. RTP Tools rtpplay since the binary file format is - // compatible with the rtpdump format. - virtual int StartRTPDump(const int video_channel, - const char file_nameUTF8[1024], - RTPDirections direction) = 0; - - // This function disables capturing of RTP packets to a binary file on a - // specific channel and for a given direction. - virtual int StopRTPDump(const int video_channel, - RTPDirections direction) = 0; - - // Registers an instance of a user implementation of the ViERTPObserver. - virtual int RegisterRTPObserver(const int video_channel, - ViERTPObserver& observer) = 0; - - // Removes a registered instance of ViERTPObserver. - virtual int DeregisterRTPObserver(const int video_channel) = 0; - - // Registers and instance of a user implementation of ViEFrameCountObserver - virtual int RegisterSendFrameCountObserver( - int video_channel, FrameCountObserver* observer) = 0; - - // Removes a registered instance of a ViEFrameCountObserver - virtual int DeregisterSendFrameCountObserver( - int video_channel, FrameCountObserver* observer) = 0; - - // Called when RTCP packet type counters might have been changed. User has to - // filter on SSRCs to determine whether it's status sent or received. - virtual int RegisterRtcpPacketTypeCounterObserver( - int video_channel, - RtcpPacketTypeCounterObserver* observer) = 0; - - protected: - virtual ~ViERTP_RTCP() {} -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RTP_RTCP_H_ diff --git a/webrtc/video_engine/overuse_frame_detector.h b/webrtc/video_engine/overuse_frame_detector.h index 7c04cf7752..122cce505c 100644 --- a/webrtc/video_engine/overuse_frame_detector.h +++ b/webrtc/video_engine/overuse_frame_detector.h @@ -18,12 +18,113 @@ #include "webrtc/base/thread_annotations.h" #include "webrtc/base/thread_checker.h" #include "webrtc/modules/interface/module.h" -#include "webrtc/video_engine/include/vie_base.h" namespace webrtc { class Clock; -class CpuOveruseObserver; + +// CpuOveruseObserver is called when a system overuse is detected and +// VideoEngine cannot keep up the encoding frequency. +class CpuOveruseObserver { + public: + // Called as soon as an overuse is detected. + virtual void OveruseDetected() = 0; + // Called periodically when the system is not overused any longer. + virtual void NormalUsage() = 0; + + protected: + virtual ~CpuOveruseObserver() {} +}; + +struct CpuOveruseOptions { + CpuOveruseOptions() + : enable_capture_jitter_method(false), + low_capture_jitter_threshold_ms(20.0f), + high_capture_jitter_threshold_ms(30.0f), + enable_encode_usage_method(true), + low_encode_usage_threshold_percent(55), + high_encode_usage_threshold_percent(85), + low_encode_time_rsd_threshold(-1), + high_encode_time_rsd_threshold(-1), + enable_extended_processing_usage(true), + frame_timeout_interval_ms(1500), + min_frame_samples(120), + min_process_count(3), + high_threshold_consecutive_count(2) {} + + // Method based on inter-arrival jitter of captured frames. + bool enable_capture_jitter_method; + float low_capture_jitter_threshold_ms; // Threshold for triggering underuse. + float high_capture_jitter_threshold_ms; // Threshold for triggering overuse. + // Method based on encode time of frames. + bool enable_encode_usage_method; + int low_encode_usage_threshold_percent; // Threshold for triggering underuse. + int high_encode_usage_threshold_percent; // Threshold for triggering overuse. + // TODO(asapersson): Remove options, not used. + int low_encode_time_rsd_threshold; // Additional threshold for triggering + // underuse (used in addition to + // threshold above if configured). + int high_encode_time_rsd_threshold; // Additional threshold for triggering + // overuse (used in addition to + // threshold above if configured). + bool enable_extended_processing_usage; // Include a larger time span (in + // addition to encode time) for + // measuring the processing time of a + // frame. + // General settings. + int frame_timeout_interval_ms; // The maximum allowed interval between two + // frames before resetting estimations. + int min_frame_samples; // The minimum number of frames required. + int min_process_count; // The number of initial process times required before + // triggering an overuse/underuse. + int high_threshold_consecutive_count; // The number of consecutive checks + // above the high threshold before + // triggering an overuse. + + bool Equals(const CpuOveruseOptions& o) const { + return enable_capture_jitter_method == o.enable_capture_jitter_method && + low_capture_jitter_threshold_ms == o.low_capture_jitter_threshold_ms && + high_capture_jitter_threshold_ms == + o.high_capture_jitter_threshold_ms && + enable_encode_usage_method == o.enable_encode_usage_method && + low_encode_usage_threshold_percent == + o.low_encode_usage_threshold_percent && + high_encode_usage_threshold_percent == + o.high_encode_usage_threshold_percent && + low_encode_time_rsd_threshold == o.low_encode_time_rsd_threshold && + high_encode_time_rsd_threshold == o.high_encode_time_rsd_threshold && + enable_extended_processing_usage == + o.enable_extended_processing_usage && + frame_timeout_interval_ms == o.frame_timeout_interval_ms && + min_frame_samples == o.min_frame_samples && + min_process_count == o.min_process_count && + high_threshold_consecutive_count == o.high_threshold_consecutive_count; + } +}; + +struct CpuOveruseMetrics { + CpuOveruseMetrics() + : capture_jitter_ms(-1), + avg_encode_time_ms(-1), + encode_usage_percent(-1), + capture_queue_delay_ms_per_s(-1) {} + + int capture_jitter_ms; // The current estimated jitter in ms based on + // incoming captured frames. + int avg_encode_time_ms; // The average encode time in ms. + int encode_usage_percent; // The average encode time divided by the average + // time difference between incoming captured frames. + int capture_queue_delay_ms_per_s; // The current time delay between an + // incoming captured frame until the frame + // is being processed. The delay is + // expressed in ms delay per second. +}; + +class CpuOveruseMetricsObserver { + public: + virtual ~CpuOveruseMetricsObserver() {} + virtual void CpuOveruseMetricsUpdated(const CpuOveruseMetrics& metrics) = 0; +}; // TODO(pbos): Move this somewhere appropriate. class Statistics { diff --git a/webrtc/video_engine/overuse_frame_detector_unittest.cc b/webrtc/video_engine/overuse_frame_detector_unittest.cc index cfb7f01d4f..05b242be95 100644 --- a/webrtc/video_engine/overuse_frame_detector_unittest.cc +++ b/webrtc/video_engine/overuse_frame_detector_unittest.cc @@ -8,13 +8,13 @@ * be found in the AUTHORS file in the root of the source tree. */ +#include "webrtc/video_engine/overuse_frame_detector.h" + #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/system_wrappers/interface/clock.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/overuse_frame_detector.h" namespace webrtc { namespace { diff --git a/webrtc/video_engine/test/auto_test/OWNERS b/webrtc/video_engine/test/auto_test/OWNERS deleted file mode 100644 index bbffda7e49..0000000000 --- a/webrtc/video_engine/test/auto_test/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -per-file *.isolate=kjellander@webrtc.org - -# These are for the common case of adding or renaming files. If you're doing -# structural changes, please get a review from a reviewer in this file. -per-file *.gyp=* -per-file *.gypi=* diff --git a/webrtc/video_engine/test/auto_test/android/.classpath b/webrtc/video_engine/test/auto_test/android/.classpath deleted file mode 100644 index f2adf55d20..0000000000 --- a/webrtc/video_engine/test/auto_test/android/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/webrtc/video_engine/test/auto_test/android/.project b/webrtc/video_engine/test/auto_test/android/.project deleted file mode 100644 index aca793b3b4..0000000000 --- a/webrtc/video_engine/test/auto_test/android/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - ViEAutotest - - - - - - com.android.ide.eclipse.adt.ResourceManagerBuilder - - - - - com.android.ide.eclipse.adt.PreCompilerBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.android.ide.eclipse.adt.ApkBuilder - - - - - - com.android.ide.eclipse.adt.AndroidNature - org.eclipse.jdt.core.javanature - - diff --git a/webrtc/video_engine/test/auto_test/android/AndroidManifest.xml b/webrtc/video_engine/test/auto_test/android/AndroidManifest.xml deleted file mode 100644 index 11b3e27d92..0000000000 --- a/webrtc/video_engine/test/auto_test/android/AndroidManifest.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/webrtc/video_engine/test/auto_test/android/default.properties b/webrtc/video_engine/test/auto_test/android/default.properties deleted file mode 100644 index 2ad44a49fa..0000000000 --- a/webrtc/video_engine/test/auto_test/android/default.properties +++ /dev/null @@ -1,11 +0,0 @@ -# This file is automatically generated by Android Tools. -# Do not modify this file -- YOUR CHANGES WILL BE ERASED! -# -# This file must be checked in Version Control Systems. -# -# To customize properties used by the Ant build system use, -# "build.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-9 diff --git a/webrtc/video_engine/test/auto_test/android/gen/org/webrtc/vieautotest/R.java b/webrtc/video_engine/test/auto_test/android/gen/org/webrtc/vieautotest/R.java deleted file mode 100644 index 4b46020ef2..0000000000 --- a/webrtc/video_engine/test/auto_test/android/gen/org/webrtc/vieautotest/R.java +++ /dev/null @@ -1,37 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.webrtc.vieautotest; - -public final class R { - public static final class array { - public static final int subtest_array=0x7f050001; - public static final int test_array=0x7f050000; - } - public static final class attr { - } - public static final class drawable { - public static final int logo=0x7f020000; - } - public static final class id { - public static final int Button01=0x7f060004; - public static final int LocalView=0x7f060001; - public static final int RemoteView=0x7f060000; - public static final int subtestSpinner=0x7f060003; - public static final int testSpinner=0x7f060002; - } - public static final class layout { - public static final int main=0x7f030000; - } - public static final class string { - public static final int SpinnerSubtest=0x7f040004; - public static final int SpinnerTitle=0x7f040003; - public static final int TitleName=0x7f040001; - public static final int app_name=0x7f040000; - public static final int run_button=0x7f040002; - } -} diff --git a/webrtc/video_engine/test/auto_test/android/jni/org_webrtc_vieautotest_vie_autotest.h b/webrtc/video_engine/test/auto_test/android/jni/org_webrtc_vieautotest_vie_autotest.h deleted file mode 100644 index 68ec6014b5..0000000000 --- a/webrtc/video_engine/test/auto_test/android/jni/org_webrtc_vieautotest_vie_autotest.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* DO NOT EDIT THIS FILE - it is machine generated */ -#include -/* Header for class org_webrtc_vieautotest_ViEAutotest */ - -#ifndef _Included_org_webrtc_vieautotest_ViEAutotest -#define _Included_org_webrtc_vieautotest_ViEAutotest -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * Class: org_webrtc_vieautotest_ViEAutotest - * Method: RunTest - * Signature: (IILandroid/view/SurfaceView;Landroid/view/SurfaceView;)I - */ -JNIEXPORT jint JNICALL -Java_org_webrtc_vieautotest_ViEAutotest_RunTest__IILandroid_view_SurfaceView_2Landroid_view_SurfaceView_2 -(JNIEnv *, jobject, jint, jint, jobject, jobject); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/webrtc/video_engine/test/auto_test/android/jni/vie_autotest_jni.cc b/webrtc/video_engine/test/auto_test/android/jni/vie_autotest_jni.cc deleted file mode 100644 index 657db863f4..0000000000 --- a/webrtc/video_engine/test/auto_test/android/jni/vie_autotest_jni.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include -#include -#include -#include -#include - -#include "webrtc/video_engine/test/auto_test/android/jni/org_webrtc_vieautotest_vie_autotest.h" - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_android.h" - -#define WEBRTC_LOG_TAG "*WEBRTCN*" - -// VideoEngine data struct -typedef struct -{ - JavaVM* jvm; -} VideoEngineData; - -// Global variables -JavaVM* webrtcGlobalVM; - -// Global variables visible in this file -static VideoEngineData vieData; - -// "Local" functions (i.e. not Java accessible) -#define WEBRTC_TRACE_MAX_MESSAGE_SIZE 1024 - -static bool GetSubAPIs(VideoEngineData& vieData); -static bool ReleaseSubAPIs(VideoEngineData& vieData); - -// -// General functions -// - -// JNI_OnLoad -jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/) { - if (!vm) { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "JNI_OnLoad did not receive a valid VM pointer"); - return -1; - } - - JNIEnv* env; - if (JNI_OK != vm->GetEnv(reinterpret_cast (&env), - JNI_VERSION_1_4)) { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "JNI_OnLoad could not get JNI env"); - return -1; - } - - // Init ViE data - vieData.jvm = vm; - - return JNI_VERSION_1_4; -} - -// Class: org_webrtc_vieautotest_ViEAutotest -// Method: RunTest -// Signature: (IILandroid/opengl/GLSurfaceView;Landroid/opengl/GLSurfaceView;)I -JNIEXPORT jint JNICALL -Java_org_webrtc_vieautotest_ViEAutotest_RunTest__IILandroid_opengl_GLSurfaceView_2Landroid_opengl_GLSurfaceView_2( - JNIEnv* env, - jobject context, - jint testType, - jint subtestType, - jobject glView1, - jobject glView2) -{ - int numErrors = -1; - numErrors = ViEAutoTestAndroid::RunAutotest(testType, subtestType, glView1, - glView2, vieData.jvm, env, - context); - return numErrors; -} - -// Class: org_webrtc_vieautotest_ViEAutotest -// Method: RunTest -// Signature: (IILandroid/view/SurfaceView;Landroid/view/SurfaceView;)I -JNIEXPORT jint JNICALL -Java_org_webrtc_vieautotest_ViEAutotest_RunTest__IILandroid_view_SurfaceView_2Landroid_view_SurfaceView_2( - JNIEnv* env, - jobject context, - jint testType, - jint subtestType, - jobject surfaceHolder1, - jobject surfaceHolder2) -{ - int numErrors = -1; - numErrors = ViEAutoTestAndroid::RunAutotest(testType, subtestType, - surfaceHolder1, surfaceHolder2, - vieData.jvm, env, context); - return numErrors; -} - -// -//local function -// - -bool GetSubAPIs(VideoEngineData& vieData) { - bool retVal = true; - //vieData.base = ViEBase::GetInterface(vieData.vie); - //if (vieData.base == NULL) - { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Could not get Base API"); - retVal = false; - } - return retVal; -} - -bool ReleaseSubAPIs(VideoEngineData& vieData) { - bool releaseOk = true; - //if (vieData.base) - { - //if (vieData.base->Release() != 0) - if (false) { - __android_log_write(ANDROID_LOG_ERROR, WEBRTC_LOG_TAG, - "Release base sub-API failed"); - releaseOk = false; - } - else { - //vieData.base = NULL; - } - } - - return releaseOk; -} diff --git a/webrtc/video_engine/test/auto_test/android/res/drawable/logo.png b/webrtc/video_engine/test/auto_test/android/res/drawable/logo.png deleted file mode 100644 index c3e0a123b5..0000000000 Binary files a/webrtc/video_engine/test/auto_test/android/res/drawable/logo.png and /dev/null differ diff --git a/webrtc/video_engine/test/auto_test/android/res/layout/main.xml b/webrtc/video_engine/test/auto_test/android/res/layout/main.xml deleted file mode 100644 index 1f2aaf9e75..0000000000 --- a/webrtc/video_engine/test/auto_test/android/res/layout/main.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/webrtc/video_engine/test/auto_test/android/res/values/strings.xml b/webrtc/video_engine/test/auto_test/android/res/values/strings.xml deleted file mode 100644 index 48cfe926e6..0000000000 --- a/webrtc/video_engine/test/auto_test/android/res/values/strings.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - -ViEAutotest -ViEAutotest -Run Test -Test type... - - Standard - API - Extended - Loopback - Custom - -Run... - - All - Base - Capture - Codec - Mix - External Codec - File - Image Process - Network - Render - RTP/RTCP - - - diff --git a/webrtc/video_engine/test/auto_test/android/src/org/webrtc/vieautotest/ViEAutotest.java b/webrtc/video_engine/test/auto_test/android/src/org/webrtc/vieautotest/ViEAutotest.java deleted file mode 100644 index de228a8768..0000000000 --- a/webrtc/video_engine/test/auto_test/android/src/org/webrtc/vieautotest/ViEAutotest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -package org.webrtc.vieautotest; - -import org.webrtc.vieautotest.R; - -import android.app.Activity; -import android.os.Bundle; -import android.util.Log; -import android.widget.Button; -import android.view.SurfaceView; -import android.view.View; -import android.view.SurfaceHolder; -import android.widget.LinearLayout; -import android.opengl.GLSurfaceView; -import android.widget.Spinner; -import android.widget.ArrayAdapter; -import android.widget.AdapterView; - -public class ViEAutotest extends Activity - implements - AdapterView.OnItemSelectedListener, - View.OnClickListener { - - private Thread testThread; - private Spinner testSpinner; - private Spinner subtestSpinner; - private int testSelection; - private int subTestSelection; - - // View for remote video - private LinearLayout remoteSurface = null; - private GLSurfaceView glSurfaceView = null; - private SurfaceView surfaceView = null; - - private LinearLayout localSurface = null; - private GLSurfaceView glLocalSurfaceView = null; - private SurfaceView localSurfaceView = null; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - - Log.d("*WEBRTC*", "onCreate called"); - - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - - // Set the Start button action - final Button buttonStart = (Button) findViewById(R.id.Button01); - buttonStart.setOnClickListener(this); - - // Set test spinner - testSpinner = (Spinner) findViewById(R.id.testSpinner); - ArrayAdapter adapter = - ArrayAdapter.createFromResource(this, R.array.test_array, - android.R.layout.simple_spinner_item); - - int resource = android.R.layout.simple_spinner_dropdown_item; - adapter.setDropDownViewResource(resource); - testSpinner.setAdapter(adapter); - testSpinner.setOnItemSelectedListener(this); - - // Set sub test spinner - subtestSpinner = (Spinner) findViewById(R.id.subtestSpinner); - ArrayAdapter subtestAdapter = - ArrayAdapter.createFromResource(this, R.array.subtest_array, - android.R.layout.simple_spinner_item); - - subtestAdapter.setDropDownViewResource(resource); - subtestSpinner.setAdapter(subtestAdapter); - subtestSpinner.setOnItemSelectedListener(this); - - remoteSurface = (LinearLayout) findViewById(R.id.RemoteView); - surfaceView = new SurfaceView(this); - remoteSurface.addView(surfaceView); - - localSurface = (LinearLayout) findViewById(R.id.LocalView); - localSurfaceView = new SurfaceView(this); - localSurfaceView.setZOrderMediaOverlay(true); - localSurface.addView(localSurfaceView); - - // Set members - testSelection = 0; - subTestSelection = 0; - } - - public void onClick(View v) { - Log.d("*WEBRTC*", "Button clicked..."); - switch (v.getId()) { - case R.id.Button01: - new Thread(new Runnable() { - public void run() { - Log.d("*WEBRTC*", "Calling RunTest..."); - RunTest(testSelection, subTestSelection, - localSurfaceView, surfaceView); - Log.d("*WEBRTC*", "RunTest done"); - } - }).start(); - } - } - - public void onItemSelected(AdapterView parent, View v, - int position, long id) { - - if (parent == (Spinner) findViewById(R.id.testSpinner)) { - testSelection = position; - } else { - subTestSelection = position; - } - } - - public void onNothingSelected(AdapterView parent) { - } - - @Override - protected void onStart() { - super.onStart(); - } - - @Override - protected void onResume() { - super.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - } - - @Override - protected void onDestroy() { - - super.onDestroy(); - } - - // C++ function performing the chosen test - // private native int RunTest(int testSelection, int subtestSelection, - // GLSurfaceView window1, GLSurfaceView window2); - private native int RunTest(int testSelection, int subtestSelection, - SurfaceView window1, SurfaceView window2); - - // this is used to load the 'ViEAutotestJNIAPI' library on application - // startup. - static { - Log.d("*WEBRTC*", "Loading ViEAutotest..."); - System.loadLibrary("webrtc-video-autotest-jni"); - } -} diff --git a/webrtc/video_engine/test/auto_test/automated/legacy_fixture.cc b/webrtc/video_engine/test/auto_test/automated/legacy_fixture.cc deleted file mode 100644 index 08c49d8d6e..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/legacy_fixture.cc +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/automated/legacy_fixture.h" - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" - -void LegacyFixture::SetUpTestCase() { - TwoWindowsFixture::SetUpTestCase(); - - // Create the test cases - tests_ = new ViEAutoTest(window_1_, window_2_); -} - -void LegacyFixture::TearDownTestCase() { - delete tests_; - - TwoWindowsFixture::TearDownTestCase(); -} - -ViEAutoTest* LegacyFixture::tests_ = NULL; diff --git a/webrtc/video_engine/test/auto_test/automated/legacy_fixture.h b/webrtc/video_engine/test/auto_test/automated/legacy_fixture.h deleted file mode 100644 index 2386f4ba6c..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/legacy_fixture.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_AUTOMATED_VIE_LEGACY_FIXTURE_H_ -#define WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_AUTOMATED_VIE_LEGACY_FIXTURE_H_ - -#include "webrtc/video_engine/test/auto_test/automated/two_windows_fixture.h" - -// Inherited by old-style standard integration tests based on ViEAutoTest. -class LegacyFixture : public TwoWindowsFixture { - public: - // Initializes ViEAutoTest in addition to the work done by ViEIntegrationTest. - static void SetUpTestCase(); - - // Releases anything allocated by SetupTestCase. - static void TearDownTestCase(); - - protected: - static ViEAutoTest* tests_; -}; - -#endif // WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_AUTOMATED_VIE_LEGACY_FIXTURE_H_ diff --git a/webrtc/video_engine/test/auto_test/automated/two_windows_fixture.cc b/webrtc/video_engine/test/auto_test/automated/two_windows_fixture.cc deleted file mode 100644 index d190920d75..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/two_windows_fixture.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/automated/two_windows_fixture.h" - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_window_creator.h" - -void TwoWindowsFixture::SetUpTestCase() { - window_creator_ = new ViEWindowCreator(); - - ViEAutoTestWindowManagerInterface* window_manager = - window_creator_->CreateTwoWindows(); - - window_1_ = window_manager->GetWindow1(); - window_2_ = window_manager->GetWindow2(); -} - -void TwoWindowsFixture::TearDownTestCase() { - window_creator_->TerminateWindows(); - delete window_creator_; -} - -ViEWindowCreator* TwoWindowsFixture::window_creator_ = NULL; -void* TwoWindowsFixture::window_1_ = NULL; -void* TwoWindowsFixture::window_2_ = NULL; diff --git a/webrtc/video_engine/test/auto_test/automated/two_windows_fixture.h b/webrtc/video_engine/test/auto_test/automated/two_windows_fixture.h deleted file mode 100644 index 44ef257e2a..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/two_windows_fixture.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_AUTOMATED_TWO_WINDOWS_FIXTURE_H_ -#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_AUTOMATED_TWO_WINDOWS_FIXTURE_H_ - -#include "testing/gtest/include/gtest/gtest.h" - -class ViEWindowCreator; -class ViEAutoTest; - -// Meant to be inherited by all standard test who require two windows. -class TwoWindowsFixture : public testing::Test { - public: - // Launches two windows in a platform-dependent manner and stores the handles - // in the window_1_ and window_2_ fields. - static void SetUpTestCase(); - - // Releases anything allocated by SetupTestCase. - static void TearDownTestCase(); - - protected: - static void* window_1_; - static void* window_2_; - static ViEWindowCreator* window_creator_; -}; - -#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_AUTOMATED_TWO_WINDOWS_FIXTURE_H_ diff --git a/webrtc/video_engine/test/auto_test/automated/vie_api_integration_test.cc b/webrtc/video_engine/test/auto_test/automated/vie_api_integration_test.cc deleted file mode 100644 index 3067a80bc0..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/vie_api_integration_test.cc +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/test/testsupport/gtest_disable.h" -#include "webrtc/video_engine/test/auto_test/automated/legacy_fixture.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" - -namespace { - -// TODO(phoglund): These tests are generally broken on mac. -// http://code.google.com/p/webrtc/issues/detail?id=1268 -class DISABLED_ON_MAC(ViEApiIntegrationTest) : public LegacyFixture { -}; - -TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest), RunsBaseTestWithoutErrors) { - tests_->ViEBaseAPITest(); -} - -// TODO(phoglund): Crashes on the v4l2loopback camera. -TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest), - DISABLED_RunsCaptureTestWithoutErrors) { - tests_->ViECaptureAPITest(); -} - -TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest), RunsCodecTestWithoutErrors) { - tests_->ViECodecAPITest(); -} - -TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest), - RunsImageProcessTestWithoutErrors) { - tests_->ViEImageProcessAPITest(); -} - -TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest), RunsRenderTestWithoutErrors) { - tests_->ViERenderAPITest(); -} - -// See: https://code.google.com/p/webrtc/issues/detail?id=2415 -TEST_F(DISABLED_ON_MAC(ViEApiIntegrationTest), - DISABLED_RunsRtpRtcpTestWithoutErrors) { - tests_->ViERtpRtcpAPITest(); -} - -} // namespace diff --git a/webrtc/video_engine/test/auto_test/automated/vie_extended_integration_test.cc b/webrtc/video_engine/test/auto_test/automated/vie_extended_integration_test.cc deleted file mode 100644 index 4508d8e791..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/vie_extended_integration_test.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/test/testsupport/gtest_disable.h" -#include "webrtc/video_engine/test/auto_test/automated/legacy_fixture.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" - -namespace { - -// TODO(phoglund): These tests are generally broken on mac. -// http://code.google.com/p/webrtc/issues/detail?id=1268 -class DISABLED_ON_MAC(ViEExtendedIntegrationTest) : public LegacyFixture { -}; - -TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest), RunsBaseTestWithoutErrors) { - tests_->ViEBaseExtendedTest(); -} - -// TODO(phoglund): Crashes on the v4l2loopback camera. -TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest), - DISABLED_RunsCaptureTestWithoutErrors) { - tests_->ViECaptureExtendedTest(); -} - -// Flaky on Windows: http://code.google.com/p/webrtc/issues/detail?id=1925 -// (in addition to being disabled on Mac due to webrtc:1268). -#if defined(_WIN32) -#define MAYBE_RunsCodecTestWithoutErrors DISABLED_RunsCodecTestWithoutErrors -#else -#define MAYBE_RunsCodecTestWithoutErrors RunsCodecTestWithoutErrors -#endif -TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest), - MAYBE_RunsCodecTestWithoutErrors) { - tests_->ViECodecExtendedTest(); -} - -TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest), - RunsImageProcessTestWithoutErrors) { - tests_->ViEImageProcessExtendedTest(); -} - -TEST_F(DISABLED_ON_MAC(ViEExtendedIntegrationTest), - RunsRenderTestWithoutErrors) { - tests_->ViERenderExtendedTest(); -} - -} // namespace diff --git a/webrtc/video_engine/test/auto_test/automated/vie_network_test.cc b/webrtc/video_engine/test/auto_test/automated/vie_network_test.cc deleted file mode 100644 index 4fd2422a9c..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/vie_network_test.cc +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include - -#include "gflags/gflags.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/system_wrappers/interface/sleep.h" -#include "webrtc/system_wrappers/interface/tick_util.h" - -namespace { - -class RtcpCollectorTransport : public webrtc::Transport { - public: - RtcpCollectorTransport() : packets_() {} - virtual ~RtcpCollectorTransport() {} - - int SendPacket(int /*channel*/, - const void* /*data*/, - size_t /*len*/) override { - EXPECT_TRUE(false); - return 0; - } - int SendRTCPPacket(int channel, const void* data, size_t len) override { - const uint8_t* buf = static_cast(data); - webrtc::RtpUtility::RtpHeaderParser parser(buf, len); - if (parser.RTCP()) { - Packet p; - p.channel = channel; - p.length = len; - if (parser.ParseRtcp(&p.header)) { - if (p.header.payloadType == 201 && len >= 20) { - buf += 20; - len -= 20; - } else { - return 0; - } - if (TryParseREMB(buf, len, &p)) { - packets_.push_back(p); - } - } - } - return 0; - } - - bool FindREMBFor(uint32_t ssrc, double min_rate) const { - for (std::vector::const_iterator it = packets_.begin(); - it != packets_.end(); ++it) { - if (it->remb_bitrate >= min_rate && it->remb_ssrc.end() != - std::find(it->remb_ssrc.begin(), it->remb_ssrc.end(), ssrc)) { - return true; - } - } - return false; - } - - private: - struct Packet { - Packet() : channel(-1), length(0), header(), remb_bitrate(0), remb_ssrc() {} - int channel; - size_t length; - webrtc::RTPHeader header; - double remb_bitrate; - std::vector remb_ssrc; - }; - - bool TryParseREMB(const uint8_t* buf, size_t length, Packet* p) { - if (length < 8) { - return false; - } - if (buf[0] != 'R' || buf[1] != 'E' || buf[2] != 'M' || buf[3] != 'B') { - return false; - } - size_t ssrcs = buf[4]; - uint8_t exp = buf[5] >> 2; - uint32_t mantissa = ((buf[5] & 0x03) << 16) + (buf[6] << 8) + buf[7]; - double bitrate = mantissa * static_cast(1 << exp); - p->remb_bitrate = bitrate; - - if (length < (8 + 4 * ssrcs)) { - return false; - } - buf += 8; - for (size_t i = 0; i < ssrcs; ++i) { - uint32_t ssrc = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]; - p->remb_ssrc.push_back(ssrc); - buf += 4; - } - return true; - } - - std::vector packets_; -}; - -class ViENetworkTest : public testing::Test { - protected: - ViENetworkTest() : vie_("ViENetworkTest"), channel_(-1), transport() {} - virtual ~ViENetworkTest() {} - - void SetUp() override { - EXPECT_EQ(0, vie_.base->CreateChannel(channel_)); - EXPECT_EQ(0, vie_.rtp_rtcp->SetRembStatus(channel_, false, true)); - EXPECT_EQ(0, vie_.network->RegisterSendTransport(channel_, transport)); - } - - void TearDown() override { - EXPECT_EQ(0, vie_.network->DeregisterSendTransport(channel_)); - } - - void ReceiveASTPacketsForBWE() { - for (int i = 0; i < kPacketCount; ++i) { - int64_t time = webrtc::TickTime::MillisecondTimestamp(); - webrtc::RTPHeader header; - header.ssrc = kSsrc1; - header.timestamp = i * 45000; - header.extension.hasAbsoluteSendTime = true; - header.extension.absoluteSendTime = i << (18 - 6); - EXPECT_EQ(0, vie_.network->ReceivedBWEPacket(channel_, time, kPacketSize, - header)); - webrtc::SleepMs(kIntervalMs); - } - } - - enum { - kSsrc1 = 667, - kSsrc2 = 668, - kPacketCount = 100, - kPacketSize = 1000, - kIntervalMs = 22 - }; - TbInterfaces vie_; - int channel_; - RtcpCollectorTransport transport; -}; - -TEST_F(ViENetworkTest, ReceiveBWEPacket_NoExtension) { - for (int i = 0; i < kPacketCount; ++i) { - int64_t time = webrtc::TickTime::MillisecondTimestamp(); - webrtc::RTPHeader header; - header.ssrc = kSsrc1; - header.timestamp = i * 45000; - EXPECT_EQ(0, vie_.network->ReceivedBWEPacket(channel_, time, kPacketSize, - header)); - webrtc::SleepMs(kIntervalMs); - } - EXPECT_FALSE(transport.FindREMBFor(kSsrc1, 0.0)); - unsigned int bandwidth = 0; - EXPECT_EQ(0, vie_.rtp_rtcp->GetEstimatedReceiveBandwidth(channel_, - &bandwidth)); -} - -TEST_F(ViENetworkTest, ReceiveBWEPacket_TOF) { - EXPECT_EQ(0, vie_.rtp_rtcp->SetReceiveTimestampOffsetStatus(channel_, true, - 1)); - for (int i = 0; i < kPacketCount; ++i) { - int64_t time = webrtc::TickTime::MillisecondTimestamp(); - webrtc::RTPHeader header; - header.ssrc = kSsrc1; - header.timestamp = i * 45000; - header.extension.hasTransmissionTimeOffset = true; - header.extension.transmissionTimeOffset = 17; - EXPECT_EQ(0, vie_.network->ReceivedBWEPacket(channel_, time, kPacketSize, - header)); - webrtc::SleepMs(kIntervalMs); - } - EXPECT_FALSE(transport.FindREMBFor(kSsrc1, 0.0)); - unsigned int bandwidth = 0; - EXPECT_EQ(0, vie_.rtp_rtcp->GetEstimatedReceiveBandwidth(channel_, - &bandwidth)); -} - -TEST_F(ViENetworkTest, ReceiveBWEPacket_AST) { - EXPECT_EQ(0, vie_.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus(channel_, true, - 1)); - ReceiveASTPacketsForBWE(); - EXPECT_TRUE(transport.FindREMBFor(kSsrc1, 100000.0)); - unsigned int bandwidth = 0; - EXPECT_EQ(0, vie_.rtp_rtcp->GetEstimatedReceiveBandwidth(channel_, - &bandwidth)); - EXPECT_GT(bandwidth, 0u); -} - -TEST_F(ViENetworkTest, ReceiveBWEPacket_ASTx2) { - EXPECT_EQ(0, vie_.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus(channel_, true, - 1)); - for (int i = 0; i < kPacketCount; ++i) { - int64_t time = webrtc::TickTime::MillisecondTimestamp(); - webrtc::RTPHeader header; - header.ssrc = kSsrc1; - header.timestamp = i * 45000; - header.extension.hasAbsoluteSendTime = true; - header.extension.absoluteSendTime = i << (18 - 6); - EXPECT_EQ(0, vie_.network->ReceivedBWEPacket(channel_, time, kPacketSize, - header)); - header.ssrc = kSsrc2; - header.timestamp += 171717; - EXPECT_EQ(0, vie_.network->ReceivedBWEPacket(channel_, time, kPacketSize, - header)); - webrtc::SleepMs(kIntervalMs); - } - EXPECT_TRUE(transport.FindREMBFor(kSsrc1, 200000.0)); - EXPECT_TRUE(transport.FindREMBFor(kSsrc2, 200000.0)); - unsigned int bandwidth = 0; - EXPECT_EQ(0, vie_.rtp_rtcp->GetEstimatedReceiveBandwidth(channel_, - &bandwidth)); - EXPECT_GT(bandwidth, 0u); -} - -TEST_F(ViENetworkTest, ReceiveBWEPacket_AST_DisabledReceive) { - EXPECT_EQ(0, vie_.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus(channel_, false, - 1)); - ReceiveASTPacketsForBWE(); - EXPECT_FALSE(transport.FindREMBFor(kSsrc1, 0.0)); - unsigned int bandwidth = 0; - EXPECT_EQ(0, vie_.rtp_rtcp->GetEstimatedReceiveBandwidth(channel_, - &bandwidth)); -} -} // namespace diff --git a/webrtc/video_engine/test/auto_test/automated/vie_standard_integration_test.cc b/webrtc/video_engine/test/auto_test/automated/vie_standard_integration_test.cc deleted file mode 100644 index 584f9e92ff..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/vie_standard_integration_test.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// This file contains the "standard" suite of integration tests, implemented -// as a GUnit test. This file is a part of the effort to try to automate all -// tests in this section of the code. Currently, this code makes no attempt -// to verify any video output - it only checks for direct errors. - -#include - -#include "gflags/gflags.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/test/testsupport/metrics/video_metrics.h" -#include "webrtc/test/testsupport/metrics/video_metrics.h" -#include "webrtc/video_engine/test/auto_test/automated/legacy_fixture.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_window_creator.h" -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" - -namespace { - -class ViEStandardIntegrationTest : public LegacyFixture { -}; - -TEST_F(ViEStandardIntegrationTest, RunsBaseTestWithoutErrors) { - tests_->ViEBaseStandardTest(); -} - -// Flaky: https://code.google.com/p/webrtc/issues/detail?id=1734 -TEST_F(ViEStandardIntegrationTest, DISABLED_RunsCodecTestWithoutErrors) { - tests_->ViECodecStandardTest(); -} - -TEST_F(ViEStandardIntegrationTest, RunsCaptureTestWithoutErrors) { - tests_->ViECaptureStandardTest(); -} - -TEST_F(ViEStandardIntegrationTest, RunsImageProcessTestWithoutErrors) { - tests_->ViEImageProcessStandardTest(); -} - -TEST_F(ViEStandardIntegrationTest, RunsRenderTestWithoutErrors) { - tests_->ViERenderStandardTest(); -} - -// Flaky, see webrtc:1790. -TEST_F(ViEStandardIntegrationTest, DISABLED_RunsRtpRtcpTestWithoutErrors) { - tests_->ViERtpRtcpStandardTest(); -} - -} // namespace diff --git a/webrtc/video_engine/test/auto_test/automated/vie_video_verification_test.cc b/webrtc/video_engine/test/auto_test/automated/vie_video_verification_test.cc deleted file mode 100644 index 1653959470..0000000000 --- a/webrtc/video_engine/test/auto_test/automated/vie_video_verification_test.cc +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include -#include -#include - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/test/testsupport/fileutils.h" -#include "webrtc/test/testsupport/metrics/video_metrics.h" -#include "webrtc/test/testsupport/perf_test.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_file_based_comparison_tests.h" -#include "webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" - -namespace { - -// The input file must be QCIF since I420 gets scaled to that in the tests -// (it is so bandwidth-heavy we have no choice). Our comparison algorithms -// wouldn't like scaling, so this will work when we compare with the original. -const int kInputWidth = 176; -const int kInputHeight = 144; - -class ViEVideoVerificationTest : public testing::Test { - protected: - void SetUp() { - input_file_ = webrtc::test::ResourcePath("paris_qcif", "yuv"); - local_file_renderer_ = NULL; - remote_file_renderer_ = NULL; - } - - void InitializeFileRenderers() { - local_file_renderer_ = new ViEToFileRenderer(); - remote_file_renderer_ = new ViEToFileRenderer(); - SetUpLocalFileRenderer(local_file_renderer_); - SetUpRemoteFileRenderer(remote_file_renderer_); - } - - void SetUpLocalFileRenderer(ViEToFileRenderer* file_renderer) { - SetUpFileRenderer(file_renderer, "-local-preview.yuv"); - } - - void SetUpRemoteFileRenderer(ViEToFileRenderer* file_renderer) { - SetUpFileRenderer(file_renderer, "-remote.yuv"); - } - - // Must be called manually inside the tests. - void StopRenderers() { - local_file_renderer_->StopRendering(); - remote_file_renderer_->StopRendering(); - } - - void CompareFiles(const std::string& reference_file, - const std::string& test_file, - double* psnr_result, double *ssim_result) { - webrtc::test::QualityMetricsResult psnr; - int error = I420PSNRFromFiles(reference_file.c_str(), test_file.c_str(), - kInputWidth, kInputHeight, &psnr); - - EXPECT_EQ(0, error) << "PSNR routine failed - output files missing?"; - *psnr_result = psnr.average; - - webrtc::test::QualityMetricsResult ssim; - error = I420SSIMFromFiles(reference_file.c_str(), test_file.c_str(), - kInputWidth, kInputHeight, &ssim); - EXPECT_EQ(0, error) << "SSIM routine failed - output files missing?"; - *ssim_result = ssim.average; - - ViETest::Log("Results: PSNR is %f (dB; 48 is max), " - "SSIM is %f (1 is perfect)", - psnr.average, ssim.average); - } - - // Note: must call AFTER CompareFiles. - void TearDownFileRenderers() { - TearDownFileRenderer(local_file_renderer_); - TearDownFileRenderer(remote_file_renderer_); - } - - std::string input_file_; - ViEToFileRenderer* local_file_renderer_; - ViEToFileRenderer* remote_file_renderer_; - ViEFileBasedComparisonTests tests_; - - private: - void SetUpFileRenderer(ViEToFileRenderer* file_renderer, - const std::string& suffix) { - std::string output_path = ViETest::GetResultOutputPath(); - std::string filename = "render_output" + suffix; - - if (!file_renderer->PrepareForRendering(output_path, filename)) { - FAIL() << "Could not open output file " << filename << - " for writing."; - } - } - - void TearDownFileRenderer(ViEToFileRenderer* file_renderer) { - assert(file_renderer); - bool test_failed = ::testing::UnitTest::GetInstance()-> - current_test_info()->result()->Failed(); - if (test_failed) { - // Leave the files for analysis if the test failed. - file_renderer->SaveOutputFile("failed-"); - } - delete file_renderer; - } -}; - -TEST_F(ViEVideoVerificationTest, RunsBaseStandardTestWithoutErrors) { - // I420 is lossless, so the I420 test should obviously get perfect results - - // the local preview and remote output files should be bit-exact. This test - // runs on external transport to ensure we do not drop packets. - // However, it's hard to make 100% stringent requirements on the video engine - // since for instance the jitter buffer has non-deterministic elements. If it - // breaks five times in a row though, you probably introduced a bug. - const double kReasonablePsnr = webrtc::test::kMetricsPerfectPSNR - 2.0f; - const double kReasonableSsim = 0.99f; - const int kNumAttempts = 5; - for (int attempt = 0; attempt < kNumAttempts; ++attempt) { - InitializeFileRenderers(); - ASSERT_TRUE(tests_.TestCallSetup(input_file_, kInputWidth, kInputHeight, - local_file_renderer_, - remote_file_renderer_)); - std::string remote_file = remote_file_renderer_->GetFullOutputPath(); - std::string local_preview = local_file_renderer_->GetFullOutputPath(); - StopRenderers(); - - double actual_psnr = 0; - double actual_ssim = 0; - CompareFiles(local_preview, remote_file, &actual_psnr, &actual_ssim); - - TearDownFileRenderers(); - - if (actual_psnr > kReasonablePsnr && actual_ssim > kReasonableSsim) { - // Test successful. - return; - } else { - ViETest::Log("Retrying; attempt %d of %d.", attempt + 1, kNumAttempts); - } - } - - FAIL() << "Failed to achieve near-perfect PSNR and SSIM results after " << - kNumAttempts << " attempts."; -} - -} // namespace diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest.h deleted file mode 100644 index 0ee26a5732..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest.h -// - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_H_ - -#include "gflags/gflags.h" -#include "webrtc/common_types.h" -#include "webrtc/modules/video_render/include/video_render_defines.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/voice_engine/include/voe_audio_processing.h" -#include "webrtc/voice_engine/include/voe_base.h" -#include "webrtc/voice_engine/include/voe_codec.h" -#include "webrtc/voice_engine/include/voe_hardware.h" - -#ifndef WEBRTC_ANDROID -#include -#endif - -class TbCaptureDevice; -class TbInterfaces; -class TbVideoChannel; -class ViEToFileRenderer; - -DECLARE_bool(include_timing_dependent_tests); - -// This class provides a bunch of methods, implemented across several .cc -// files, which runs tests on the video engine. All methods will report -// errors using standard googletest macros, except when marked otherwise. -class ViEAutoTest -{ -public: - ViEAutoTest(void* window1, void* window2); - ~ViEAutoTest(); - - // These three are special and should not be run in a googletest harness. - // They keep track of their errors by themselves and return the number - // of errors. - int ViELoopbackCall(); - int ViESimulcastCall(); - int ViECustomCall(); - int ViERecordCall(); - - // All functions except the three above are meant to run in a - // googletest harness. - void ViEStandardTest(); - void ViEExtendedTest(); - void ViEAPITest(); - - // vie_autotest_base.cc - void ViEBaseStandardTest(); - void ViEBaseExtendedTest(); - void ViEBaseAPITest(); - - // vie_autotest_capture.cc - void ViECaptureStandardTest(); - void ViECaptureExtendedTest(); - void ViECaptureAPITest(); - void ViECaptureExternalCaptureTest(); - - // vie_autotest_codec.cc - void ViECodecStandardTest(); - void ViECodecExtendedTest(); - void ViECodecExternalCodecTest(); - void ViECodecAPITest(); - - // vie_autotest_image_process.cc - void ViEImageProcessStandardTest(); - void ViEImageProcessExtendedTest(); - void ViEImageProcessAPITest(); - - // vie_autotest_network.cc - void ViENetworkStandardTest(); - void ViENetworkExtendedTest(); - void ViENetworkAPITest(); - - // vie_autotest_render.cc - void ViERenderStandardTest(); - void ViERenderExtendedTest(); - void ViERenderAPITest(); - - // vie_autotest_rtp_rtcp.cc - void ViERtpRtcpStandardTest(); - void ViERtpRtcpAPITest(); - -private: - void PrintAudioCodec(const webrtc::CodecInst audioCodec); - void PrintVideoCodec(const webrtc::VideoCodec videoCodec); - - // Sets up rendering so the capture device output goes to window 1 and - // the video engine output goes to window 2. - void RenderCaptureDeviceAndOutputStream(TbInterfaces* video_engine, - TbVideoChannel* video_channel, - TbCaptureDevice* capture_device); - - // Stops rendering into the two windows as was set up by a call to - // RenderCaptureDeviceAndOutputStream. - void StopRenderCaptureDeviceAndOutputStream( - TbInterfaces* video_engine, - TbVideoChannel* video_channel, - TbCaptureDevice* capture_device); - - void* _window1; - void* _window2; - - webrtc::VideoRenderType _renderType; - webrtc::VideoRender* _vrm1; - webrtc::VideoRender* _vrm2; -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest_android.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest_android.h deleted file mode 100644 index 6eff9d8f15..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest_android.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_ANDROID_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_ANDROID_H_ - -#include - -class ViEAutoTestAndroid { - public: - static int RunAutotest(int testSelection, - int subTestSelection, - void* window1, - void* window2, - JavaVM* javaVM, - void* env, - void* context); -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_ANDROID_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h deleted file mode 100644 index 3e8d762087..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_defines.h -// - - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_DEFINES_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_DEFINES_H_ - -#include -#include -#include - -#include - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/system_wrappers/interface/sleep.h" - -#if defined(_WIN32) -#include -#elif defined (WEBRTC_ANDROID) -#include -#elif defined(WEBRTC_LINUX) || defined(WEBRTC_MAC) -#include -#include -#include -#include -#endif - -// Choose how to log -//#define VIE_LOG_TO_FILE -#define VIE_LOG_TO_STDOUT - -// Choose one way to test error -#define VIE_ASSERT_ERROR - -#define VIE_LOG_FILE_NAME "ViEAutotestLog.txt" - -#undef RGB -#define RGB(r,g,b) r|g<<8|b<<16 - -enum { kAutoTestSleepTimeMs = 5000 }; -enum { kAutoTestFullStackSleepTimeMs = 20000 }; - -struct AutoTestSize { - unsigned int width; - unsigned int height; - AutoTestSize() : - width(0), height(0) { - } - AutoTestSize(unsigned int iWidth, unsigned int iHeight) : - width(iWidth), height(iHeight) { - } -}; - -struct AutoTestOrigin { - unsigned int x; - unsigned int y; - AutoTestOrigin() : - x(0), y(0) { - } - AutoTestOrigin(unsigned int iX, unsigned int iY) : - x(iX), y(iY) { - } -}; - -struct AutoTestRect { - AutoTestSize size; - AutoTestOrigin origin; - AutoTestRect() : - size(), origin() { - } - - AutoTestRect(unsigned int iX, unsigned int iY, unsigned int iWidth, unsigned int iHeight) : - size(iX, iY), origin(iWidth, iHeight) { - } - - void Copy(AutoTestRect iRect) { - origin.x = iRect.origin.x; - origin.y = iRect.origin.y; - size.width = iRect.size.width; - size.height = iRect.size.height; - } -}; - -// ============================================ - -class ViETest { - public: - static int Init() { -#ifdef VIE_LOG_TO_FILE - log_file_ = fopen(VIE_LOG_FILE_NAME, "w+t"); -#else - log_file_ = NULL; -#endif - log_str_ = new char[kMaxLogSize]; - memset(log_str_, 0, kMaxLogSize); - return 0; - } - - static int Terminate() { - if (log_file_) { - fclose(log_file_); - log_file_ = NULL; - } - if (log_str_) { - delete[] log_str_; - log_str_ = NULL; - } - return 0; - } - - static void Log(const char* fmt, ...) { - va_list va; - va_start(va, fmt); - memset(log_str_, 0, kMaxLogSize); - vsprintf(log_str_, fmt, va); - va_end(va); - - WriteToSuitableOutput(log_str_); - } - - // Writes to a suitable output, depending on platform and log mode. - static void WriteToSuitableOutput(const char* message) { -#ifdef VIE_LOG_TO_FILE - if (log_file_) - { - fwrite(log_str_, 1, strlen(log_str_), log_file_); - fwrite("\n", 1, 1, log_file_); - fflush(log_file_); - } -#endif -#ifdef VIE_LOG_TO_STDOUT -#if WEBRTC_ANDROID - __android_log_write(ANDROID_LOG_DEBUG, "*WebRTCN*", log_str_); -#else - printf("%s\n", log_str_); -#endif -#endif - } - - // Deprecated(phoglund): Prefer to use googletest macros in all cases - // except the custom call case. - static int TestError(bool expr, const char* fmt, ...) { - if (!expr) { - va_list va; - va_start(va, fmt); - memset(log_str_, 0, kMaxLogSize); - vsprintf(log_str_, fmt, va); -#ifdef WEBRTC_ANDROID - __android_log_write(ANDROID_LOG_ERROR, "*WebRTCN*", log_str_); -#endif - WriteToSuitableOutput(log_str_); - va_end(va); - - AssertError(log_str_); - return 1; - } - return 0; - } - - // Returns a suitable path to write trace and result files to. - // You should always use this when you want to write output files. - // The returned path is guaranteed to end with a path separator. - // This function may be run at any time during the program's execution. - // Implemented in vie_autotest.cc - static std::string GetResultOutputPath(); - -private: - static void AssertError(const char* message) { -#ifdef VIE_ASSERT_ERROR - assert(false); -#endif - } - - static FILE* log_file_; - enum { - kMaxLogSize = 512 - }; - static char* log_str_; -}; - -#define AutoTestSleep webrtc::SleepMs - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_DEFINES_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest_linux.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest_linux.h deleted file mode 100644 index 6af87e8b3e..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest_linux.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_LINUX_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_LINUX_H_ - -// Note(pbos): This MUST be included before the X11 headers -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h" - -#include -#include - -// Forward declaration - -class ViEAutoTestWindowManager: public ViEAutoTestWindowManagerInterface -{ -public: - ViEAutoTestWindowManager(); - virtual ~ViEAutoTestWindowManager(); - virtual void* GetWindow1(); - virtual void* GetWindow2(); - virtual int TerminateWindows(); - virtual int CreateWindows(AutoTestRect window1Size, - AutoTestRect window2Size, void* window1Title, - void* window2Title); - virtual bool SetTopmostWindow(); - -private: - int ViECreateWindow(Window *outWindow, Display **outDisplay, int xpos, - int ypos, int width, int height, char* title); - int ViEDestroyWindow(Window *window, Display *display); - - Window _hwnd1; - Window _hwnd2; - Display* _hdsp1; - Display* _hdsp2; -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_LINUX_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest_mac_cocoa.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest_mac_cocoa.h deleted file mode 100644 index ba1cb5c31b..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest_mac_cocoa.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/engine_configurations.h" - -#if defined(COCOA_RENDERING) - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAC_COCOA_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAC_COCOA_H_ - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h" - -@class CocoaRenderView; - -#import - -@interface TestCocoaUi : NSObject { - CocoaRenderView* cocoaRenderView1_; - CocoaRenderView* cocoaRenderView2_; - NSWindow* window1_; - NSWindow* window2_; - - AutoTestRect window1Size_; - AutoTestRect window2Size_; - void* window1Title_; - void* window2Title_; -} - -// Must be called as a selector in the main thread. -- (void)createWindows:(NSObject*)ignored; - -// Used to transfer parameters from background thread. -- (void)prepareToCreateWindowsWithSize:(AutoTestRect)window1Size - andSize:(AutoTestRect)window2Size - withTitle:(void*)window1Title - andTitle:(void*)window2Title; - -- (NSWindow*)window1; -- (NSWindow*)window2; -- (CocoaRenderView*)cocoaRenderView1; -- (CocoaRenderView*)cocoaRenderView2; - -@end - -class ViEAutoTestWindowManager: public ViEAutoTestWindowManagerInterface { - public: - ViEAutoTestWindowManager(); - virtual ~ViEAutoTestWindowManager(); - virtual void* GetWindow1(); - virtual void* GetWindow2(); - virtual int CreateWindows(AutoTestRect window1Size, - AutoTestRect window2Size, - void* window1Title, - void* window2Title); - virtual int TerminateWindows(); - virtual bool SetTopmostWindow(); - - private: - TestCocoaUi* cocoa_ui_; -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAC_COCOA_H_ -#endif // COCOA_RENDERING diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h deleted file mode 100644 index 68d0079f39..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAIN_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAIN_H_ - -#include -#include - -class ViEAutoTestMain { - public: - ViEAutoTestMain(); - - // Runs the test according to the specified arguments. - // Pass in --automated to run in automated mode; interactive - // mode is default. All usual googletest flags also apply. - int RunTests(int argc, char** argv); - - private: - std::map index_to_test_method_map_; - - static const int kInvalidChoice = -1; - - // Starts interactive mode. - int RunInteractiveMode(); - // Prompts the user for a specific test method in the provided test case. - // Returns 0 on success, nonzero otherwise. - int RunSpecificTestCaseIn(const std::string test_case_name); - // Asks the user for a particular test case to run. - int AskUserForTestCase(); - // Retrieves a number from the user in the interval - // [min_allowed, max_allowed]. Returns kInvalidChoice on failure. - int AskUserForNumber(int min_allowed, int max_allowed); - // Runs all tests matching the provided filter. * are wildcards. - // Returns the test runner result (0 == OK). - int RunTestMatching(const std::string test_case, - const std::string test_method); - // Runs a non-gtest test case. Choice must be [7,9]. Returns 0 on success. - int RunSpecialTestCase(int choice); -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_MAIN_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h deleted file mode 100644 index 3f53815284..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * vie_autotest_window_manager_interface.h - */ - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_WINDOW_MANAGER_INTERFACE_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_WINDOW_MANAGER_INTERFACE_H_ - -class ViEAutoTestWindowManagerInterface -{ -public: - virtual int CreateWindows(AutoTestRect window1Size, - AutoTestRect window2Size, void* window1Title, - void* window2Title) = 0; - virtual int TerminateWindows() = 0; - virtual void* GetWindow1() = 0; - virtual void* GetWindow2() = 0; - virtual bool SetTopmostWindow() = 0; - virtual ~ViEAutoTestWindowManagerInterface() {} -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_WINDOW_MANAGER_INTERFACE_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_autotest_windows.h b/webrtc/video_engine/test/auto_test/interface/vie_autotest_windows.h deleted file mode 100644 index fffd9484fe..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_autotest_windows.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_WINDOWS_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_WINDOWS_H_ - -#include "webrtc/engine_configurations.h" -#include "webrtc/system_wrappers/interface/thread_wrapper.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h" - -#include -#define TITLE_LENGTH 1024 - -// Forward declaration -namespace webrtc { -class CriticalSectionWrapper; -} - -class ViEAutoTestWindowManager: public ViEAutoTestWindowManagerInterface -{ -public: - ViEAutoTestWindowManager(); - virtual ~ViEAutoTestWindowManager(); - virtual void* GetWindow1(); - virtual void* GetWindow2(); - virtual int CreateWindows(AutoTestRect window1Size, - AutoTestRect window2Size, void* window1Title, - void* window2Title); - virtual int TerminateWindows(); - virtual bool SetTopmostWindow(); -protected: - static bool EventProcess(void* obj); - bool EventLoop(); - -private: - int ViECreateWindow(HWND &hwndMain, int xPos, int yPos, int width, - int height, TCHAR* className); - int ViEDestroyWindow(HWND& hwnd); - - void* _window1; - void* _window2; - - bool _terminate; - rtc::scoped_ptr _eventThread; - webrtc::CriticalSectionWrapper& _crit; - HWND _hwndMain; - HWND _hwnd1; - HWND _hwnd2; - - AutoTestRect _hwnd1Size; - AutoTestRect _hwnd2Size; - TCHAR _hwnd1Title[TITLE_LENGTH]; - TCHAR _hwnd2Title[TITLE_LENGTH]; - -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_AUTOTEST_WINDOWS_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_file_based_comparison_tests.h b/webrtc/video_engine/test/auto_test/interface/vie_file_based_comparison_tests.h deleted file mode 100644 index 116ad26bde..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_file_based_comparison_tests.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef SRC_VIDEO_ENGINE_TEST_AUTO_TEST_INTERFACE_VIE_COMPARISON_TESTS_H_ -#define SRC_VIDEO_ENGINE_TEST_AUTO_TEST_INTERFACE_VIE_COMPARISON_TESTS_H_ - -#include - -#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h" - -class FrameDropDetector; -struct NetworkParameters; -class ViEToFileRenderer; - -// This class contains comparison tests, which will exercise video engine -// functionality and then run comparison tests on the result using PSNR and -// SSIM algorithms. These tests are intended mostly as sanity checks so that -// we know we are outputting roughly the right thing and not random noise or -// black screens. -// -// We will set up a fake ExternalCapture device which will pose as a webcam -// and read the input from the provided raw YUV file. Output will be written -// as a local preview in the local file renderer; the remote side output gets -// written to the provided remote file renderer. -// -// The local preview is a straight, unaltered copy of the input. This can be -// useful for comparisons if the test method contains several stages where the -// input is restarted between stages. -class ViEFileBasedComparisonTests { - public: - // Test a typical simple call setup. Returns false if the input file - // could not be opened; reports errors using googletest macros otherwise. - bool TestCallSetup( - const std::string& i420_test_video_path, - int width, - int height, - ViEToFileRenderer* local_file_renderer, - ViEToFileRenderer* remote_file_renderer); - - // Runs a full stack test using the VP8 codec. Tests the full stack and uses - // RTP timestamps to sync frames between the endpoints. - void TestFullStack( - const std::string& i420_video_file, - int width, - int height, - int bit_rate_kbps, - ProtectionMethod protection_method, - const NetworkParameters& network, - ViEToFileRenderer* local_file_renderer, - ViEToFileRenderer* remote_file_renderer, - FrameDropDetector* frame_drop_detector); -}; - -#endif // SRC_VIDEO_ENGINE_TEST_AUTO_TEST_INTERFACE_VIE_COMPARISON_TESTS_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_window_creator.h b/webrtc/video_engine/test/auto_test/interface/vie_window_creator.h deleted file mode 100644 index c13a8889b7..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_window_creator.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_WINDOW_CREATOR_H_ -#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_WINDOW_CREATOR_H_ - -class ViEAutoTestWindowManagerInterface; - -class ViEWindowCreator { - public: - ViEWindowCreator(); - virtual ~ViEWindowCreator(); - - // The pointer returned here will still be owned by this object. - // Only use it to retrieve the created windows. - ViEAutoTestWindowManagerInterface* CreateTwoWindows(); - - // Terminates windows opened by CreateTwoWindows, which must - // have been called before this method. - void TerminateWindows(); - private: - ViEAutoTestWindowManagerInterface* window_manager_; -}; - -#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_WINDOW_CREATOR_H_ diff --git a/webrtc/video_engine/test/auto_test/interface/vie_window_manager_factory.h b/webrtc/video_engine/test/auto_test/interface/vie_window_manager_factory.h deleted file mode 100644 index a85280dfe3..0000000000 --- a/webrtc/video_engine/test/auto_test/interface/vie_window_manager_factory.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_WINDOW_MANAGER_FACTORY_H_ -#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_WINDOW_MANAGER_FACTORY_H_ - -class ViEAutoTestWindowManagerInterface; - -class ViEWindowManagerFactory { - public: - // This method is implemented in different files depending on platform. - // The caller is responsible for freeing the resulting object using - // the delete operator. - static ViEAutoTestWindowManagerInterface* - CreateWindowManagerForCurrentPlatform(); -}; - -#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_VIE_WINDOW_MANAGER_FACTORY_H_ diff --git a/webrtc/video_engine/test/auto_test/primitives/base_primitives.cc b/webrtc/video_engine/test/auto_test/primitives/base_primitives.cc deleted file mode 100644 index 32f4b2107d..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/base_primitives.cc +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/primitives/base_primitives.h" - -#include "webrtc/modules/video_capture/include/video_capture_factory.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" - -static void ConfigureCodecsToI420(int video_channel, - webrtc::VideoCodec video_codec, - webrtc::ViECodec* codec_interface) { - // Set up the codec interface with all known receive codecs and with - // I420 as the send codec. - for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) { - EXPECT_EQ(0, codec_interface->GetCodec(i, video_codec)); - - // Try to keep the test frame size small and bit rate generous when I420. - if (video_codec.codecType == webrtc::kVideoCodecI420) { - video_codec.width = 176; - video_codec.height = 144; - video_codec.maxBitrate = 32000; - video_codec.startBitrate = 32000; - EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, video_codec)); - } - - EXPECT_EQ(0, codec_interface->SetReceiveCodec(video_channel, video_codec)); - } - // Verify that we really found the I420 codec. - EXPECT_EQ(0, codec_interface->GetSendCodec(video_channel, video_codec)); - EXPECT_EQ(webrtc::kVideoCodecI420, video_codec.codecType); -} - -void TestI420CallSetup(webrtc::ViECodec* codec_interface, - webrtc::VideoEngine* video_engine, - webrtc::ViEBase* base_interface, - webrtc::ViENetwork* network_interface, - webrtc::ViERTP_RTCP* rtp_rtcp_interface, - int video_channel, - const char* device_name) { - webrtc::VideoCodec video_codec; - memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); - EXPECT_EQ(0, rtp_rtcp_interface->SetTransmissionSmoothingStatus(video_channel, - false)); - - ConfigureCodecsToI420(video_channel, video_codec, codec_interface); - - TbExternalTransport external_transport( - *network_interface, video_channel, NULL); - EXPECT_EQ(0, network_interface->RegisterSendTransport( - video_channel, external_transport)); - EXPECT_EQ(0, base_interface->StartReceive(video_channel)); - EXPECT_EQ(0, base_interface->StartSend(video_channel)); - - // Let the call run for a while. - ViETest::Log("Call started"); - AutoTestSleep(kAutoTestSleepTimeMs); - - // Stop the call. - ViETest::Log("Stopping call."); - EXPECT_EQ(0, base_interface->StopSend(video_channel)); - - // Make sure we receive all packets. - AutoTestSleep(1000); - - EXPECT_EQ(0, base_interface->StopReceive(video_channel)); - EXPECT_EQ(0, network_interface->DeregisterSendTransport(video_channel)); -} diff --git a/webrtc/video_engine/test/auto_test/primitives/base_primitives.h b/webrtc/video_engine/test/auto_test/primitives/base_primitives.h deleted file mode 100644 index 956871747f..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/base_primitives.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_SOURCE_BASE_PRIMITIVES_H_ -#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_SOURCE_BASE_PRIMITIVES_H_ - -namespace webrtc { -class VideoEngine; -class ViEBase; -class ViECodec; -class ViENetwork; -class ViERTP_RTCP; -} - -// Tests a I420-to-I420 call. This test exercises the most basic WebRTC -// functionality by training the codec interface to recognize the most common -// codecs, and the initiating a I420 call. A video channel with a capture device -// must be set up prior to this call. -void TestI420CallSetup(webrtc::ViECodec* codec_interface, - webrtc::VideoEngine* video_engine, - webrtc::ViEBase* base_interface, - webrtc::ViENetwork* network_interface, - webrtc::ViERTP_RTCP* rtp_rtcp_interface, - int video_channel, - const char* device_name); - -#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_SOURCE_BASE_PRIMITIVES_H_ diff --git a/webrtc/video_engine/test/auto_test/primitives/choice_helpers.cc b/webrtc/video_engine/test/auto_test/primitives/choice_helpers.cc deleted file mode 100644 index 8cc686af9e..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/choice_helpers.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/primitives/choice_helpers.h" - -#include -#include -#include - -#include -#include - -namespace webrtc { - -ChoiceBuilder::ChoiceBuilder(const std::string& title, const Choices& choices) - : choices_(choices), - input_helper_(TypedInput(title)) { - input_helper_.WithInputValidator( - new IntegerWithinRangeValidator(1, choices.size())); - input_helper_.WithAdditionalInfo(MakeHumanReadableOptions()); -} - -int ChoiceBuilder::Choose() { - std::string input = input_helper_.AskForInput(); - return atoi(input.c_str()); -} - -ChoiceBuilder& ChoiceBuilder::WithDefault(const std::string& default_choice) { - Choices::const_iterator iterator = std::find( - choices_.begin(), choices_.end(), default_choice); - assert(iterator != choices_.end() && "No such choice."); - - // Store the value as the choice number, e.g. its index + 1. - int choice_index = (iterator - choices_.begin()) + 1; - char number[16]; - sprintf(number, "%d", choice_index); - - input_helper_.WithDefault(number); - return *this; -} - -ChoiceBuilder& ChoiceBuilder::WithInputSource(FILE* input_source) { - input_helper_.WithInputSource(input_source); - return *this; -} - -std::string ChoiceBuilder::MakeHumanReadableOptions() { - std::string result = ""; - Choices::const_iterator iterator = choices_.begin(); - for (int number = 1; iterator != choices_.end(); ++iterator, ++number) { - std::ostringstream os; - os << "\n " << number << ". " << (*iterator).c_str(); - result += os.str(); - } - return result; -} - -Choices SplitChoices(const std::string& raw_choices) { - return Split(raw_choices, "\n"); -} - -ChoiceBuilder FromChoices( - const std::string& title, const std::string& raw_choices) { - return ChoiceBuilder(title, SplitChoices(raw_choices)); -} - -} // namespace webrtc diff --git a/webrtc/video_engine/test/auto_test/primitives/choice_helpers.h b/webrtc/video_engine/test/auto_test/primitives/choice_helpers.h deleted file mode 100644 index 777aae57c2..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/choice_helpers.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_CHOICE_HELPERS_H_ -#define WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_CHOICE_HELPERS_H_ - -#include -#include - -#include "webrtc/video_engine/test/auto_test/primitives/input_helpers.h" - -namespace webrtc { - -typedef std::vector Choices; - -/** - * Used to ask the user to make a choice. This class will allow you to - * configure how to ask the question, and then ask it. For instance, - * - * int choice = FromChoices("Choice 1\n" - * "Choice 2\n").WithDefault("Choice 1").Choose(); - * - * will print a menu presenting the two choices and ask for input. The user, - * can input 1, 2 or just hit enter since we specified a default in this case. - * The Choose call will block until the user gives valid input one way or the - * other. The choice variable is guaranteed to contain either 1 or 2 after - * this particular call. - * - * The class uses stdout and stdin by default, but stdin can be replaced using - * WithInputSource for unit tests. - */ -class ChoiceBuilder { - public: - explicit ChoiceBuilder(const std::string& title, const Choices& choices); - - // Specifies the choice as the default. The choice must be one of the choices - // passed in the constructor. If this method is not called, the user has to - // choose an option explicitly. - ChoiceBuilder& WithDefault(const std::string& default_choice); - - // Replaces the input source where we ask for input. Default is stdin. - ChoiceBuilder& WithInputSource(FILE* input_source); - - // Prints the choice list and requests input from the input source. Returns - // the choice number (choices start at 1). - int Choose(); - private: - std::string MakeHumanReadableOptions(); - - Choices choices_; - InputBuilder input_helper_; -}; - -// Convenience function that creates a choice builder given a string where -// choices are separated by \n. -ChoiceBuilder FromChoices(const std::string& title, - const std::string& raw_choices); - -// Creates choices from a string where choices are separated by \n. -Choices SplitChoices(const std::string& raw_choices); - -} // namespace webrtc - -#endif // CHOICE_HELPERS_H_ diff --git a/webrtc/video_engine/test/auto_test/primitives/choice_helpers_unittest.cc b/webrtc/video_engine/test/auto_test/primitives/choice_helpers_unittest.cc deleted file mode 100644 index 469a375eb2..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/choice_helpers_unittest.cc +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/video_engine/test/auto_test/primitives/choice_helpers.h" -#include "webrtc/video_engine/test/auto_test/primitives/fake_stdin.h" - -namespace webrtc { - -class ChoiceHelpersTest : public testing::Test { -}; - -TEST_F(ChoiceHelpersTest, SplitReturnsEmptyChoicesForEmptyInput) { - EXPECT_TRUE(SplitChoices("").empty()); -} - -TEST_F(ChoiceHelpersTest, SplitHandlesSingleChoice) { - Choices choices = SplitChoices("Single Choice"); - EXPECT_EQ(1u, choices.size()); - EXPECT_EQ("Single Choice", choices[0]); -} - -TEST_F(ChoiceHelpersTest, SplitHandlesSingleChoiceWithEndingNewline) { - Choices choices = SplitChoices("Single Choice\n"); - EXPECT_EQ(1u, choices.size()); - EXPECT_EQ("Single Choice", choices[0]); -} - -TEST_F(ChoiceHelpersTest, SplitHandlesMultipleChoices) { - Choices choices = SplitChoices( - "Choice 1\n" - "Choice 2\n" - "Choice 3"); - EXPECT_EQ(3u, choices.size()); - EXPECT_EQ("Choice 1", choices[0]); - EXPECT_EQ("Choice 2", choices[1]); - EXPECT_EQ("Choice 3", choices[2]); -} - -TEST_F(ChoiceHelpersTest, SplitHandlesMultipleChoicesWithEndingNewline) { - Choices choices = SplitChoices( - "Choice 1\n" - "Choice 2\n" - "Choice 3\n"); - EXPECT_EQ(3u, choices.size()); - EXPECT_EQ("Choice 1", choices[0]); - EXPECT_EQ("Choice 2", choices[1]); - EXPECT_EQ("Choice 3", choices[2]); -} - -TEST_F(ChoiceHelpersTest, CanSelectUsingChoiceBuilder) { - FILE* fake_stdin = FakeStdin("1\n2\n"); - EXPECT_EQ(1, FromChoices("Title", - "Choice 1\n" - "Choice 2").WithInputSource(fake_stdin).Choose()); - EXPECT_EQ(2, FromChoices("","Choice 1\n" - "Choice 2").WithInputSource(fake_stdin).Choose()); - fclose(fake_stdin); -} - -TEST_F(ChoiceHelpersTest, RetriesIfGivenInvalidChoice) { - FILE* fake_stdin = FakeStdin("3\n0\n99\n23409234809\na\nwhatever\n1\n"); - EXPECT_EQ(1, FromChoices("Title", - "Choice 1\n" - "Choice 2").WithInputSource(fake_stdin).Choose()); - fclose(fake_stdin); -} - -TEST_F(ChoiceHelpersTest, RetriesOnEnterIfNoDefaultSet) { - FILE* fake_stdin = FakeStdin("\n2\n"); - EXPECT_EQ(2, FromChoices("Title", - "Choice 1\n" - "Choice 2").WithInputSource(fake_stdin).Choose()); - fclose(fake_stdin); -} - -TEST_F(ChoiceHelpersTest, PicksDefaultOnEnterIfDefaultSet) { - FILE* fake_stdin = FakeStdin("\n"); - EXPECT_EQ(2, FromChoices("Title", - "Choice 1\n" - "Choice 2").WithInputSource(fake_stdin) - .WithDefault("Choice 2").Choose()); - fclose(fake_stdin); -} - -} // namespace webrtc diff --git a/webrtc/video_engine/test/auto_test/primitives/fake_stdin.cc b/webrtc/video_engine/test/auto_test/primitives/fake_stdin.cc deleted file mode 100644 index 26705f27d4..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/fake_stdin.cc +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/primitives/fake_stdin.h" - -namespace webrtc { - -FILE* FakeStdin(const std::string& input) { - FILE* fake_stdin = tmpfile(); - - EXPECT_EQ(input.size(), - fwrite(input.c_str(), sizeof(char), input.size(), fake_stdin)); - rewind(fake_stdin); - - return fake_stdin; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/test/auto_test/primitives/fake_stdin.h b/webrtc/video_engine/test/auto_test/primitives/fake_stdin.h deleted file mode 100644 index c298fe2e09..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/fake_stdin.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#ifndef FAKE_STDIN_H_ -#define FAKE_STDIN_H_ - -#include - -#include - -#include "testing/gtest/include/gtest/gtest.h" - -namespace webrtc { - -// Creates a fake stdin-like FILE* for unit test usage. -FILE* FakeStdin(const std::string& input); - -} // namespace webrtc - -#endif // FAKE_STDIN_H_ diff --git a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.cc b/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.cc deleted file mode 100644 index e9ff5378e9..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.cc +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include -#include - -#include -#include - -#include "webrtc/modules/video_capture/include/video_capture_factory.h" -#include "webrtc/system_wrappers/interface/tick_util.h" -#include "webrtc/test/testsupport/fileutils.h" -#include "webrtc/test/testsupport/frame_reader.h" -#include "webrtc/test/testsupport/frame_writer.h" -#include "webrtc/test/testsupport/perf_test.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h" -#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h" -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" - -enum { kWaitTimeForFinalDecodeMs = 100 }; - -// Writes the frames to be encoded to file and tracks which frames are sent in -// external transport on the local side and reports them to the -// FrameDropDetector class. -class LocalRendererEffectFilter : public webrtc::ExternalRendererEffectFilter { - public: - LocalRendererEffectFilter(webrtc::ExternalRenderer* renderer, - FrameDropDetector* frame_drop_detector) - : ExternalRendererEffectFilter(renderer), - frame_drop_detector_(frame_drop_detector) {} - int Transform(size_t size, - unsigned char* frame_buffer, - int64_t ntp_time_ms, - unsigned int timestamp, - unsigned int width, - unsigned int height) { - frame_drop_detector_->ReportFrameState( - FrameDropDetector::kCreated, - timestamp, - webrtc::TickTime::MicrosecondTimestamp()); - return webrtc::ExternalRendererEffectFilter::Transform( - size, frame_buffer, ntp_time_ms, timestamp, width, height); - } - private: - FrameDropDetector* frame_drop_detector_; -}; - -// Tracks which frames are sent in external transport on the local side -// and reports them to the FrameDropDetector class. -class FrameSentCallback : public SendFrameCallback { - public: - explicit FrameSentCallback(FrameDropDetector* frame_drop_detector) - : frame_drop_detector_(frame_drop_detector) {} - virtual ~FrameSentCallback() {} - virtual void FrameSent(unsigned int rtp_timestamp) { - frame_drop_detector_->ReportFrameState( - FrameDropDetector::kSent, - rtp_timestamp, - webrtc::TickTime::MicrosecondTimestamp()); - } - - private: - FrameDropDetector* frame_drop_detector_; -}; - -// Tracks which frames are received in external transport on the remote side -// and reports them to the FrameDropDetector class. -class FrameReceivedCallback : public ReceiveFrameCallback { - public: - explicit FrameReceivedCallback(FrameDropDetector* frame_drop_detector) - : frame_drop_detector_(frame_drop_detector) {} - virtual ~FrameReceivedCallback() {} - virtual void FrameReceived(unsigned int rtp_timestamp) { - frame_drop_detector_->ReportFrameState( - FrameDropDetector::kReceived, - rtp_timestamp, - webrtc::TickTime::MicrosecondTimestamp()); - } - - private: - FrameDropDetector* frame_drop_detector_; -}; - -// Tracks when frames are decoded on the remote side (received from the -// jitter buffer) and reports them to the FrameDropDetector class. -class DecodedTimestampEffectFilter : public webrtc::ViEEffectFilter { - public: - explicit DecodedTimestampEffectFilter(FrameDropDetector* frame_drop_detector) - : frame_drop_detector_(frame_drop_detector) {} - virtual ~DecodedTimestampEffectFilter() {} - virtual int Transform(size_t size, - unsigned char* frame_buffer, - int64_t ntp_time_ms, - unsigned int timestamp, - unsigned int width, - unsigned int height) { - frame_drop_detector_->ReportFrameState( - FrameDropDetector::kDecoded, - timestamp, - webrtc::TickTime::MicrosecondTimestamp()); - return 0; - } - - private: - FrameDropDetector* frame_drop_detector_; -}; - -class Statistics { - public: - Statistics() : sum_(0.0f), sum_squared_(0.0f), count_(0) {}; - - void AddSample(float sample) { - sum_ += sample; - sum_squared_ += sample * sample; - ++count_; - } - - float Mean() { - if (count_ == 0) - return -1.0f; - return sum_ / count_; - } - - float Variance() { - if (count_ == 0) - return -1.0f; - return sum_squared_ / count_ - Mean() * Mean(); - } - - std::string AsString() { - std::stringstream ss; - ss << (Mean() >= 0 ? Mean() : -1) << ", " << - (Variance() >= 0 ? sqrt(Variance()) : -1); - return ss.str(); - } - - private: - float sum_; - float sum_squared_; - int count_; -}; - -void TestFullStack(const TbInterfaces& interfaces, - int capture_id, - int video_channel, - int width, - int height, - int bit_rate_kbps, - const NetworkParameters& network, - FrameDropDetector* frame_drop_detector, - ViEToFileRenderer* remote_file_renderer, - ViEToFileRenderer* local_file_renderer) { - webrtc::VideoEngine *video_engine_interface = interfaces.video_engine; - webrtc::ViEBase *base_interface = interfaces.base; - webrtc::ViECapture *capture_interface = interfaces.capture; - webrtc::ViERender *render_interface = interfaces.render; - webrtc::ViECodec *codec_interface = interfaces.codec; - webrtc::ViENetwork *network_interface = interfaces.network; - - // *************************************************************** - // Engine ready. Begin testing class - // *************************************************************** - webrtc::VideoCodec video_codec; - memset(&video_codec, 0, sizeof (webrtc::VideoCodec)); - - // Set up all receive codecs. This basically setup the codec interface - // to be able to recognize all receive codecs based on payload type. - for (int idx = 0; idx < codec_interface->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, codec_interface->GetCodec(idx, video_codec)); - SetSuitableResolution(&video_codec, width, height); - - EXPECT_EQ(0, codec_interface->SetReceiveCodec(video_channel, video_codec)); - } - - // Configure External transport to simulate network interference: - TbExternalTransport external_transport(*interfaces.network, video_channel, - NULL); - external_transport.SetNetworkParameters(network); - - FrameSentCallback frame_sent_callback(frame_drop_detector); - FrameReceivedCallback frame_received_callback(frame_drop_detector); - external_transport.RegisterSendFrameCallback(&frame_sent_callback); - external_transport.RegisterReceiveFrameCallback(&frame_received_callback); - EXPECT_EQ(0, network_interface->RegisterSendTransport(video_channel, - external_transport)); - RenderToFile(interfaces.render, video_channel, remote_file_renderer); - EXPECT_EQ(0, base_interface->StartReceive(video_channel)); - - // Setup only the VP8 codec, which is what we'll use. - webrtc::VideoCodec codec; - EXPECT_TRUE(FindSpecificCodec(webrtc::kVideoCodecVP8, codec_interface, - &codec)); - codec.startBitrate = bit_rate_kbps; - codec.maxBitrate = bit_rate_kbps; - codec.width = width; - codec.height = height; - EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, codec)); - - webrtc::ViEImageProcess *image_process = - webrtc::ViEImageProcess::GetInterface(video_engine_interface); - EXPECT_TRUE(image_process); - - // Setup the effect filters. - // Local rendering at the send-side is done in an effect filter to avoid - // synchronization issues with the remote renderer. - LocalRendererEffectFilter local_renderer_filter(local_file_renderer, - frame_drop_detector); - EXPECT_EQ(0, image_process->RegisterSendEffectFilter(video_channel, - local_renderer_filter)); - DecodedTimestampEffectFilter decode_filter(frame_drop_detector); - EXPECT_EQ(0, image_process->RegisterRenderEffectFilter(video_channel, - decode_filter)); - // Send video. - EXPECT_EQ(0, base_interface->StartSend(video_channel)); - AutoTestSleep(kAutoTestFullStackSleepTimeMs); - - ViETest::Log("Done!"); - - // *************************************************************** - // Testing finished. Tear down Video Engine - // *************************************************************** - EXPECT_EQ(0, capture_interface->DisconnectCaptureDevice(video_channel)); - - const int one_way_delay_99_percentile = network.mean_one_way_delay + - 3 * network.std_dev_one_way_delay; - - // Wait for the last packet to arrive before we tear down the receiver. - AutoTestSleep(2 * one_way_delay_99_percentile); - EXPECT_EQ(0, base_interface->StopSend(video_channel)); - while (!external_transport.EmptyQueue()) { - AutoTestSleep(one_way_delay_99_percentile); - } - EXPECT_EQ(0, base_interface->StopReceive(video_channel)); - EXPECT_EQ(0, network_interface->DeregisterSendTransport(video_channel)); - // Wait for the last frame to be decoded and rendered. There is no guarantee - // this wait time will be long enough. Ideally we would wait for at least one - // "receive-side delay", which is what the video coding module calculates - // based on network statistics etc. We don't have access to that value here. - AutoTestSleep(kWaitTimeForFinalDecodeMs); - // Must stop the frame drop detectors in the right order to avoid getting - // frames which for instance are rendered but not decoded. - EXPECT_EQ(0, render_interface->StopRender(video_channel)); - EXPECT_EQ(0, render_interface->RemoveRenderer(video_channel)); - EXPECT_EQ(0, image_process->DeregisterRenderEffectFilter(video_channel)); - EXPECT_EQ(0, image_process->DeregisterSendEffectFilter(video_channel)); - image_process->Release(); - EXPECT_EQ(0, base_interface->DeleteChannel(video_channel)); - - // Collect transport statistics. - int32_t num_rtp_packets = 0; - int32_t num_dropped_packets = 0; - int32_t num_rtcp_packets = 0; - std::map packet_counters; - external_transport.GetStats(num_rtp_packets, num_dropped_packets, - num_rtcp_packets, &packet_counters); - ViETest::Log("RTP packets : %5d", num_rtp_packets); - ViETest::Log("Dropped packets: %5d", num_dropped_packets); - ViETest::Log("RTCP packets : %5d", num_rtcp_packets); -} - -void FixOutputFileForComparison(const std::string& output_file, - int frame_length_in_bytes, - const std::vector& frames) { - webrtc::test::FrameReaderImpl frame_reader(output_file, - frame_length_in_bytes); - const std::string temp_file = output_file + ".fixed"; - webrtc::test::FrameWriterImpl frame_writer(temp_file, frame_length_in_bytes); - frame_reader.Init(); - frame_writer.Init(); - - ASSERT_FALSE(frames.front()->dropped_at_render) << "It should not be " - "possible to drop the first frame. Both because we don't have anything " - "useful to fill that gap with and it is impossible to detect it without " - "any previous timestamps to compare with."; - - uint8_t* last_frame_data = new uint8_t[frame_length_in_bytes]; - - // Process the file and write frame duplicates for all dropped frames. - for (std::vector::const_iterator it = frames.begin(); - it != frames.end(); ++it) { - if ((*it)->dropped_at_render) { - // Write the previous frame to the output file: - EXPECT_TRUE(frame_writer.WriteFrame(last_frame_data)); - } else { - EXPECT_TRUE(frame_reader.ReadFrame(last_frame_data)); - EXPECT_TRUE(frame_writer.WriteFrame(last_frame_data)); - } - } - delete[] last_frame_data; - frame_reader.Close(); - frame_writer.Close(); - ASSERT_EQ(0, remove(output_file.c_str())); - ASSERT_EQ(0, rename(temp_file.c_str(), output_file.c_str())); -} - -void FrameDropDetector::ReportFrameState(State state, unsigned int timestamp, - int64_t report_time_us) { - dirty_ = true; - switch (state) { - case kCreated: { - int number = created_frames_vector_.size(); - Frame* frame = new Frame(number, timestamp); - frame->created_timestamp_in_us_ = report_time_us; - created_frames_vector_.push_back(frame); - created_frames_[timestamp] = frame; - num_created_frames_++; - break; - } - case kSent: - sent_frames_[timestamp] = report_time_us; - if (timestamp_diff_ == 0) { - // When the first created frame arrives we calculate the fixed - // difference between the timestamps of the frames entering and leaving - // the encoder. This diff is used to identify the frames from the - // created_frames_ map. - timestamp_diff_ = - timestamp - created_frames_vector_.front()->frame_timestamp_; - } - num_sent_frames_++; - break; - case kReceived: - received_frames_[timestamp] = report_time_us; - num_received_frames_++; - break; - case kDecoded: - decoded_frames_[timestamp] = report_time_us; - num_decoded_frames_++; - break; - case kRendered: - rendered_frames_[timestamp] = report_time_us; - num_rendered_frames_++; - break; - } -} - -void FrameDropDetector::CalculateResults() { - // Fill in all fields of the Frame objects in the created_frames_ map. - // Iterate over the maps from converted timestamps to the arrival timestamps. - std::map::const_iterator it; - for (it = sent_frames_.begin(); it != sent_frames_.end(); ++it) { - unsigned int created_timestamp = it->first - timestamp_diff_; - created_frames_[created_timestamp]->sent_timestamp_in_us_ = it->second; - } - for (it = received_frames_.begin(); it != received_frames_.end(); ++it) { - unsigned int created_timestamp = it->first - timestamp_diff_; - created_frames_[created_timestamp]->received_timestamp_in_us_ = it->second; - } - for (it = decoded_frames_.begin(); it != decoded_frames_.end(); ++it) { - unsigned int created_timestamp = it->first - timestamp_diff_; - created_frames_[created_timestamp]->decoded_timestamp_in_us_ =it->second; - } - for (it = rendered_frames_.begin(); it != rendered_frames_.end(); ++it) { - unsigned int created_timestamp = it->first - timestamp_diff_; - created_frames_[created_timestamp]->rendered_timestamp_in_us_ = it->second; - } - // Find out where the frames were not present in the different states. - dropped_frames_at_send_ = 0; - dropped_frames_at_receive_ = 0; - dropped_frames_at_decode_ = 0; - dropped_frames_at_render_ = 0; - for (std::vector::const_iterator it = created_frames_vector_.begin(); - it != created_frames_vector_.end(); ++it) { - int encoded_timestamp = (*it)->frame_timestamp_ + timestamp_diff_; - if (sent_frames_.find(encoded_timestamp) == sent_frames_.end()) { - (*it)->dropped_at_send = true; - dropped_frames_at_send_++; - } - if (received_frames_.find(encoded_timestamp) == received_frames_.end()) { - (*it)->dropped_at_receive = true; - dropped_frames_at_receive_++; - } - if (decoded_frames_.find(encoded_timestamp) == decoded_frames_.end()) { - (*it)->dropped_at_decode = true; - dropped_frames_at_decode_++; - } - if (rendered_frames_.find(encoded_timestamp) == rendered_frames_.end()) { - (*it)->dropped_at_render = true; - dropped_frames_at_render_++; - } - } - dirty_ = false; -} - -void FrameDropDetector::PrintReport(const std::string& test_label) { - assert(!dirty_); - ViETest::Log("Frame Drop Detector report:"); - ViETest::Log(" Created frames: %ld", created_frames_.size()); - ViETest::Log(" Sent frames: %ld", sent_frames_.size()); - ViETest::Log(" Received frames: %ld", received_frames_.size()); - ViETest::Log(" Decoded frames: %ld", decoded_frames_.size()); - ViETest::Log(" Rendered frames: %ld", rendered_frames_.size()); - - // Display all frames and stats for them: - long last_created = 0; - long last_sent = 0; - long last_received = 0; - long last_decoded = 0; - long last_rendered = 0; - ViETest::Log("\nDeltas between sent frames and drop status:"); - ViETest::Log("Unit: Microseconds"); - ViETest::Log("Frame Created Sent Received Decoded Rendered " - "Dropped at Dropped at Dropped at Dropped at"); - ViETest::Log(" nbr delta delta delta delta delta " - " Send? Receive? Decode? Render?"); - Statistics rendering_stats; - for (std::vector::const_iterator it = created_frames_vector_.begin(); - it != created_frames_vector_.end(); ++it) { - int created_delta = - static_cast((*it)->created_timestamp_in_us_ - last_created); - int sent_delta = (*it)->dropped_at_send ? -1 : - static_cast((*it)->sent_timestamp_in_us_ - last_sent); - int received_delta = (*it)->dropped_at_receive ? -1 : - static_cast((*it)->received_timestamp_in_us_ - last_received); - int decoded_delta = (*it)->dropped_at_decode ? -1 : - static_cast((*it)->decoded_timestamp_in_us_ - last_decoded); - int rendered_delta = (*it)->dropped_at_render ? -1 : - static_cast((*it)->rendered_timestamp_in_us_ - last_rendered); - - // Set values to -1 for the first frame: - if ((*it)->number_ == 0) { - created_delta = -1; - sent_delta = -1; - received_delta = -1; - decoded_delta = -1; - rendered_delta = -1; - } - ViETest::Log("%5d %8d %8d %8d %8d %8d %10s %10s %10s %10s", - (*it)->number_, - created_delta, - sent_delta, - received_delta, - decoded_delta, - rendered_delta, - (*it)->dropped_at_send ? "DROPPED" : " ", - (*it)->dropped_at_receive ? "DROPPED" : " ", - (*it)->dropped_at_decode ? "DROPPED" : " ", - (*it)->dropped_at_render ? "DROPPED" : " "); - last_created = (*it)->created_timestamp_in_us_; - if (!(*it)->dropped_at_send) { - last_sent = (*it)->sent_timestamp_in_us_; - } - if (!(*it)->dropped_at_receive) { - last_received = (*it)->received_timestamp_in_us_; - } - if (!(*it)->dropped_at_decode) { - last_decoded = (*it)->decoded_timestamp_in_us_; - } - if (!(*it)->dropped_at_render) { - last_rendered = (*it)->rendered_timestamp_in_us_; - rendering_stats.AddSample(rendered_delta / 1000.0f); - } - } - ViETest::Log("\nLatency between states (-1 means N/A because of drop):"); - ViETest::Log("Unit: Microseconds"); - ViETest::Log("Frame Created Sent Received Decoded Total " - " Total"); - ViETest::Log(" nbr ->Sent ->Received ->Decoded ->Rendered latency " - " latency"); - ViETest::Log(" (incl network)" - "(excl network)"); - Statistics latency_incl_network_stats; - for (std::vector::const_iterator it = created_frames_vector_.begin(); - it != created_frames_vector_.end(); ++it) { - int created_to_sent = (*it)->dropped_at_send ? -1 : - static_cast((*it)->sent_timestamp_in_us_ - - (*it)->created_timestamp_in_us_); - int sent_to_received = (*it)->dropped_at_receive ? -1 : - static_cast((*it)->received_timestamp_in_us_ - - (*it)->sent_timestamp_in_us_); - int received_to_decoded = (*it)->dropped_at_decode ? -1 : - static_cast((*it)->decoded_timestamp_in_us_ - - (*it)->received_timestamp_in_us_); - int decoded_to_render = (*it)->dropped_at_render ? -1 : - static_cast((*it)->rendered_timestamp_in_us_ - - (*it)->decoded_timestamp_in_us_); - int total_latency_incl_network = (*it)->dropped_at_render ? -1 : - static_cast((*it)->rendered_timestamp_in_us_ - - (*it)->created_timestamp_in_us_); - int total_latency_excl_network = (*it)->dropped_at_render ? -1 : - static_cast((*it)->rendered_timestamp_in_us_ - - (*it)->created_timestamp_in_us_ - sent_to_received); - if (total_latency_incl_network >= 0) - latency_incl_network_stats.AddSample(total_latency_incl_network / - 1000.0f); - ViETest::Log("%5d %9d %9d %9d %9d %12d %12d", - (*it)->number_, - created_to_sent, - sent_to_received, - received_to_decoded, - decoded_to_render, - total_latency_incl_network, - total_latency_excl_network); - } - - // Plot all measurements in the same graph since they share the same value - // range. - webrtc::test::PrintResultMeanAndError( - "total_delay_incl_network", "", test_label, - latency_incl_network_stats.AsString(), "ms", false); - webrtc::test::PrintResultMeanAndError( - "time_between_rendered_frames", "", test_label, - rendering_stats.AsString(), "ms", false); - - - // Find and print the dropped frames. - ViETest::Log("\nTotal # dropped frames at:"); - ViETest::Log(" Send : %d", dropped_frames_at_send_); - ViETest::Log(" Receive: %d", dropped_frames_at_receive_); - ViETest::Log(" Decode : %d", dropped_frames_at_decode_); - ViETest::Log(" Render : %d", dropped_frames_at_render_); -} - -void FrameDropDetector::PrintDebugDump() { - assert(!dirty_); - ViETest::Log("\nPrintDebugDump: Frame objects:"); - ViETest::Log("Frame FrTimeStamp Created Sent Received Decoded" - " Rendered "); - for (std::vector::const_iterator it = created_frames_vector_.begin(); - it != created_frames_vector_.end(); ++it) { - ViETest::Log("%5d %11u %11lld %11lld %11lld %11lld %11lld", - (*it)->number_, - (*it)->frame_timestamp_, - (*it)->created_timestamp_in_us_, - (*it)->sent_timestamp_in_us_, - (*it)->received_timestamp_in_us_, - (*it)->decoded_timestamp_in_us_, - (*it)->rendered_timestamp_in_us_); - } - std::vector mismatch_frame_num_list; - for (std::vector::const_iterator it = created_frames_vector_.begin(); - it != created_frames_vector_.end(); ++it) { - if ((*it)->dropped_at_render != (*it)->dropped_at_decode) { - mismatch_frame_num_list.push_back((*it)->number_); - } - } - if (mismatch_frame_num_list.size() > 0) { - ViETest::Log("\nDecoded/Rendered mismatches:"); - ViETest::Log("Frame FrTimeStamp Created Sent Received " - "Decoded Rendered "); - for (std::vector::const_iterator it = mismatch_frame_num_list.begin(); - it != mismatch_frame_num_list.end(); ++it) { - Frame* frame = created_frames_vector_[*it]; - ViETest::Log("%5d %11u %11lld %11lld %11lld %11lld %11lld", - frame->number_, - frame->frame_timestamp_, - frame->created_timestamp_in_us_, - frame->sent_timestamp_in_us_, - frame->received_timestamp_in_us_, - frame->decoded_timestamp_in_us_, - frame->rendered_timestamp_in_us_); - } - } - - ViETest::Log("\nReportFrameState method invocations:"); - ViETest::Log(" Created : %d", num_created_frames_); - ViETest::Log(" Send : %d", num_sent_frames_); - ViETest::Log(" Received: %d", num_received_frames_); - ViETest::Log(" Decoded : %d", num_decoded_frames_); - ViETest::Log(" Rendered: %d", num_rendered_frames_); -} - -const std::vector& FrameDropDetector::GetAllFrames() { - assert(!dirty_); - return created_frames_vector_; -} - -int FrameDropDetector::GetNumberOfFramesDroppedAt(State state) { - assert(!dirty_); - switch (state) { - case kSent: - return dropped_frames_at_send_; - case kReceived: - return dropped_frames_at_receive_; - case kDecoded: - return dropped_frames_at_decode_; - case kRendered: - return dropped_frames_at_render_; - default: - return 0; - } -} - -int FrameDropMonitoringRemoteFileRenderer::DeliverFrame( - unsigned char *buffer, size_t buffer_size, uint32_t time_stamp, - int64_t ntp_time_ms, int64_t render_time, void* /*handle*/) { - ReportFrameStats(time_stamp, render_time); - return ViEToFileRenderer::DeliverFrame(buffer, buffer_size, - time_stamp, ntp_time_ms, - render_time, NULL); -} - -void FrameDropMonitoringRemoteFileRenderer::ReportFrameStats( - uint32_t time_stamp, - int64_t render_time) { - // |render_time| provides the ideal render time for this frame. If that time - // has already passed we will render it immediately. - int64_t report_render_time_us = render_time * 1000; - int64_t time_now_us = webrtc::TickTime::MicrosecondTimestamp(); - if (render_time < (time_now_us + 500) / 1000) { - report_render_time_us = time_now_us; - } - // Register that this frame has been rendered. - frame_drop_detector_->ReportFrameState(FrameDropDetector::kRendered, - time_stamp, report_render_time_us); -} - -int FrameDropMonitoringRemoteFileRenderer::DeliverI420Frame( - const webrtc::I420VideoFrame& webrtc_frame) { - ReportFrameStats(webrtc_frame.timestamp(), webrtc_frame.render_time_ms()); - return ViEToFileRenderer::DeliverI420Frame(webrtc_frame); -} - -int FrameDropMonitoringRemoteFileRenderer::FrameSizeChange( - unsigned int width, unsigned int height, unsigned int number_of_streams) { - return ViEToFileRenderer::FrameSizeChange(width, height, number_of_streams); -} diff --git a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h b/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h deleted file mode 100644 index 92d7bcc33d..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_SOURCE_FRAMEDROP_PRIMITIVES_H_ -#define WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_SOURCE_FRAMEDROP_PRIMITIVES_H_ - -#include -#include - -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_image_process.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" - -class FrameDropDetector; -struct NetworkParameters; -class TbInterfaces; - -// Initializes the Video engine and its components, runs video playback using -// for KAutoTestSleepTimeMs milliseconds, then shuts down everything. -// The bit rate and packet loss parameters should be configured so that -// frames are dropped, in order to test the frame drop detection that is -// performed by the FrameDropDetector class. -void TestFullStack(const TbInterfaces& interfaces, - int capture_id, - int video_channel, - int width, - int height, - int bit_rate_kbps, - const NetworkParameters& network, - FrameDropDetector* frame_drop_detector, - ViEToFileRenderer* remote_file_renderer, - ViEToFileRenderer* local_file_renderer); - -// A frame in a video file. The four different points in the stack when -// register the frame state are (in time order): created, transmitted, decoded, -// rendered. -class Frame { - public: - Frame(int number, unsigned int timestamp) - : number_(number), - frame_timestamp_(timestamp), - created_timestamp_in_us_(-1), - sent_timestamp_in_us_(-1), - received_timestamp_in_us_(-1), - decoded_timestamp_in_us_(-1), - rendered_timestamp_in_us_(-1), - dropped_at_send(false), - dropped_at_receive(false), - dropped_at_decode(false), - dropped_at_render(false) {} - - // Frame number, starting at 0. - int number_; - - // Frame timestamp, that is used by Video Engine and RTP headers and set when - // the frame is sent into the stack. - unsigned int frame_timestamp_; - - // Timestamps for our measurements of when the frame is in different states. - int64_t created_timestamp_in_us_; - int64_t sent_timestamp_in_us_; - int64_t received_timestamp_in_us_; - int64_t decoded_timestamp_in_us_; - int64_t rendered_timestamp_in_us_; - - // Where the frame was dropped (more than one may be true). - bool dropped_at_send; - bool dropped_at_receive; - bool dropped_at_decode; - bool dropped_at_render; -}; - -// Fixes the output file by copying the last successful frame into the place -// where the dropped frame would be, for all dropped frames (if any). -// This method will not be able to fix data for the first frame if that is -// dropped, since there'll be no previous frame to copy. This case should never -// happen because of encoder frame dropping at least. -// Parameters: -// output_file The output file to modify (pad with frame copies -// for all dropped frames) -// frame_length_in_bytes Byte length of each frame. -// frames A vector of all Frame objects. Must be sorted by -// frame number. If empty this method will do nothing. -void FixOutputFileForComparison(const std::string& output_file, - int frame_length_in_bytes, - const std::vector& frames); - -// Handles statistics about dropped frames. Frames travel through the stack -// with different timestamps. The frames created and sent to the encoder have -// one timestamp on the sending side while the decoded/rendered frames have -// another timestamp on the receiving side. The difference between these -// timestamps is fixed, which we can use to identify the frames when they -// arrive, since the FrameDropDetector class gets data reported from both sides. -// The four different points in the stack when this class examines the frame -// states are (in time order): created, sent, received, decoded, rendered. -// -// The flow can be visualized like this: -// -// Created Sent Received Decoded Rendered -// +-------+ | +-------+ | +---------+ | +------+ +-------+ | +--------+ -// |Capture| | |Encoder| | | Ext. | | |Jitter| |Decoder| | | Ext. | -// | device|---->| |-->|transport|-->|buffer|->| |---->|renderer| -// +-------+ +-------+ +---------+ +------+ +-------+ +--------+ -// -// This class has no intention of being thread-safe. -class FrameDropDetector { - public: - enum State { - // A frame being created, i.e. sent to the encoder; the first step of - // a frame's life cycle. This timestamp becomes the frame timestamp in the - // Frame objects. - kCreated, - // A frame being sent in external transport (to the simulated network). This - // timestamp differs from the one in the Created state by a constant diff. - kSent, - // A frame being received in external transport (from the simulated - // network). This timestamp differs from the one in the Created state by a - // constant diff. - kReceived, - // A frame that has been decoded in the decoder. This timestamp differs - // from the one in the Created state by a constant diff. - kDecoded, - // A frame that has been rendered; the last step of a frame's life cycle. - // This timestamp differs from the one in the Created state by a constant - // diff. - kRendered - }; - - FrameDropDetector() - : dirty_(true), - dropped_frames_at_send_(0), - dropped_frames_at_receive_(0), - dropped_frames_at_decode_(0), - dropped_frames_at_render_(0), - num_created_frames_(0), - num_sent_frames_(0), - num_received_frames_(0), - num_decoded_frames_(0), - num_rendered_frames_(0), - timestamp_diff_(0) {} - - // Reports a frame has reached a state in the frame life cycle. - void ReportFrameState(State state, unsigned int timestamp, - int64_t report_time_us); - - // Uses all the gathered timestamp information to calculate which frames have - // been dropped during the test and where they were dropped. Not until - // this method has been executed, the Frame objects will have all fields - // filled with the proper timestamp information. - void CalculateResults(); - - // Calculates the number of frames have been registered as dropped at the - // specified state of the frame life cycle. - // CalculateResults() must be called before calling this method. - int GetNumberOfFramesDroppedAt(State state); - - // Gets a vector of all the created frames. - // CalculateResults() must be called before calling this method to have all - // fields of the Frame objects to represent the current state. - const std::vector& GetAllFrames(); - - // Prints a detailed report about all the different frame states and which - // ones are detected as dropped, using ViETest::Log. Also prints - // perf-formatted output and adds |test_label| as a modifier to the perf - // output. - // CalculateResults() must be called before calling this method. - void PrintReport(const std::string& test_label); - - // Prints all the timestamp maps. Mainly used for debugging purposes to find - // missing timestamps. - void PrintDebugDump(); - private: - // Will be false until CalculateResults() is called. Switches to true - // as soon as new timestamps are reported using ReportFrameState(). - bool dirty_; - - // Map of frame creation timestamps to all Frame objects. - std::map created_frames_; - - // Maps converted frame timestamps (differ from creation timestamp) to the - // time they arrived in the different states of the frame's life cycle. - std::map sent_frames_; - std::map received_frames_; - std::map decoded_frames_; - std::map rendered_frames_; - - // A vector with the frames sorted in their created order. - std::vector created_frames_vector_; - - // Statistics. - int dropped_frames_at_send_; - int dropped_frames_at_receive_; - int dropped_frames_at_decode_; - int dropped_frames_at_render_; - - int num_created_frames_; - int num_sent_frames_; - int num_received_frames_; - int num_decoded_frames_; - int num_rendered_frames_; - - // The constant diff between the created and transmitted frames, since their - // timestamps are converted. - unsigned int timestamp_diff_; -}; - -// Tracks which frames are received on the remote side and reports back to the -// FrameDropDetector class when they are rendered. -class FrameDropMonitoringRemoteFileRenderer : public ViEToFileRenderer { - public: - explicit FrameDropMonitoringRemoteFileRenderer( - FrameDropDetector* frame_drop_detector) - : frame_drop_detector_(frame_drop_detector) {} - virtual ~FrameDropMonitoringRemoteFileRenderer() {} - - // Implementation of ExternalRenderer: - int FrameSizeChange(unsigned int width, - unsigned int height, - unsigned int number_of_streams) override; - int DeliverFrame(unsigned char* buffer, - size_t buffer_size, - uint32_t time_stamp, - int64_t ntp_time_ms, - int64_t render_time, - void* handle) override; - int DeliverI420Frame(const webrtc::I420VideoFrame& webrtc_frame) override; - - private: - void ReportFrameStats(uint32_t time_stamp, int64_t render_time); - - FrameDropDetector* frame_drop_detector_; -}; - -#endif // WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_SOURCE_FRAMEDROP_PRIMITIVES_H_ diff --git a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives_unittest.cc b/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives_unittest.cc deleted file mode 100644 index c1501e5a41..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/framedrop_primitives_unittest.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h" - -#include - -#include - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/test/testsupport/fileutils.h" -#include "webrtc/test/testsupport/frame_reader.h" -#include "webrtc/test/testsupport/frame_writer.h" - -namespace webrtc { - -const std::string kOutputFilename = "temp_outputfile.tmp"; -const int kFrameLength = 1000; - -class FrameDropPrimitivesTest: public testing::Test { - protected: - FrameDropPrimitivesTest() {} - virtual ~FrameDropPrimitivesTest() {} - void SetUp() { - // Cleanup any previous output file. - remove(kOutputFilename.c_str()); - } - void TearDown() { - // Cleanup the temporary file. - remove(kOutputFilename.c_str()); - } -}; - -TEST_F(FrameDropPrimitivesTest, FixOutputFileForComparison) { - // Create test frame objects, where the second and fourth frame is marked - // as dropped at rendering. - std::vector frames; - Frame first_frame(0, kFrameLength); - Frame second_frame(0, kFrameLength); - Frame third_frame(0, kFrameLength); - Frame fourth_frame(0, kFrameLength); - - second_frame.dropped_at_render = true; - fourth_frame.dropped_at_render = true; - - frames.push_back(&first_frame); - frames.push_back(&second_frame); - frames.push_back(&third_frame); - frames.push_back(&fourth_frame); - - // Prepare data for the first and third frames: - uint8_t first_frame_data[kFrameLength]; - memset(first_frame_data, 5, kFrameLength); // Fill it with 5's to identify. - uint8_t third_frame_data[kFrameLength]; - memset(third_frame_data, 7, kFrameLength); // Fill it with 7's to identify. - - // Write the first and third frames to the temporary file. This means the fix - // method should add two frames of data by filling the file with data from - // the first and third frames after executing. - webrtc::test::FrameWriterImpl frame_writer(kOutputFilename, kFrameLength); - EXPECT_TRUE(frame_writer.Init()); - EXPECT_TRUE(frame_writer.WriteFrame(first_frame_data)); - EXPECT_TRUE(frame_writer.WriteFrame(third_frame_data)); - frame_writer.Close(); - EXPECT_EQ(2 * kFrameLength, - static_cast(webrtc::test::GetFileSize(kOutputFilename))); - - FixOutputFileForComparison(kOutputFilename, kFrameLength, frames); - - // Verify that the output file has correct size. - EXPECT_EQ(4 * kFrameLength, - static_cast(webrtc::test::GetFileSize(kOutputFilename))); - - webrtc::test::FrameReaderImpl frame_reader(kOutputFilename, kFrameLength); - frame_reader.Init(); - uint8_t read_buffer[kFrameLength]; - EXPECT_TRUE(frame_reader.ReadFrame(read_buffer)); - EXPECT_EQ(0, memcmp(read_buffer, first_frame_data, kFrameLength)); - EXPECT_TRUE(frame_reader.ReadFrame(read_buffer)); - EXPECT_EQ(0, memcmp(read_buffer, first_frame_data, kFrameLength)); - - EXPECT_TRUE(frame_reader.ReadFrame(read_buffer)); - EXPECT_EQ(0, memcmp(read_buffer, third_frame_data, kFrameLength)); - EXPECT_TRUE(frame_reader.ReadFrame(read_buffer)); - EXPECT_EQ(0, memcmp(read_buffer, third_frame_data, kFrameLength)); - - frame_reader.Close(); -} - -} // namespace webrtc diff --git a/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc b/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc deleted file mode 100644 index 908345d14e..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h" - -#include "webrtc/modules/video_capture/include/video_capture_factory.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" - -void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, - char* device_name, - unsigned int device_name_length, - int* device_id, - webrtc::VideoCaptureModule** device_video) { - - bool capture_device_set = false; - webrtc::VideoCaptureModule::DeviceInfo *dev_info = - webrtc::VideoCaptureFactory::CreateDeviceInfo(0); - - const unsigned int kMaxUniqueIdLength = 256; - char unique_id[kMaxUniqueIdLength]; - memset(unique_id, 0, kMaxUniqueIdLength); - - for (unsigned int i = 0; i < dev_info->NumberOfDevices(); i++) { - EXPECT_EQ(0, dev_info->GetDeviceName(i, device_name, device_name_length, - unique_id, kMaxUniqueIdLength)); - - *device_video = webrtc::VideoCaptureFactory::Create(4571, unique_id); - EXPECT_TRUE(*device_video != NULL); - - if (*device_video) { - (*device_video)->AddRef(); - - int error = capture->AllocateCaptureDevice(**device_video, *device_id); - if (error == 0) { - ViETest::Log("Using capture device: %s, captureId: %d.", - device_name, *device_id); - capture_device_set = true; - break; - } else { - (*device_video)->Release(); - (*device_video) = NULL; - } - } - } - delete dev_info; - EXPECT_TRUE(capture_device_set) << "Found no suitable camera on your system."; -} - -void RenderInWindow(webrtc::ViERender* video_render_interface, - int frame_provider_id, - void* os_window, - float z_index) { - EXPECT_EQ(0, - video_render_interface->AddRenderer(frame_provider_id, os_window, - z_index, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, video_render_interface->StartRender(frame_provider_id)); -} - -void StopRenderInWindow(webrtc::ViERender* video_render_interface, - int frame_provider_id) { - EXPECT_EQ(0, video_render_interface->StopRender(frame_provider_id)); - EXPECT_EQ(0, video_render_interface->RemoveRenderer(frame_provider_id)); -} - -void RenderToFile(webrtc::ViERender* renderer_interface, - int frame_provider_id, - ViEToFileRenderer *to_file_renderer) { - EXPECT_EQ(0, renderer_interface->AddRenderer( - frame_provider_id, webrtc::kVideoI420, to_file_renderer)); - EXPECT_EQ(0, renderer_interface->StartRender(frame_provider_id)); -} - -void ConfigureRtpRtcp(webrtc::ViERTP_RTCP* rtcp_interface, - ProtectionMethod protection_method, - int video_channel) { - EXPECT_EQ(0, rtcp_interface->SetRTCPStatus(video_channel, - webrtc::kRtcpCompound_RFC4585)); - EXPECT_EQ(0, rtcp_interface->SetKeyFrameRequestMethod( - video_channel, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, rtcp_interface->SetTMMBRStatus(video_channel, true)); - switch (protection_method) { - case kNack: - EXPECT_EQ(0, rtcp_interface->SetNACKStatus(video_channel, true)); - break; - case kHybridNackFec: - const int kRedPayloadType = 96; - const int kUlpFecPayloadType = 97; - EXPECT_EQ(0, rtcp_interface->SetHybridNACKFECStatus(video_channel, - true, - kRedPayloadType, - kUlpFecPayloadType)); - break; - } -} - -bool FindSpecificCodec(webrtc::VideoCodecType of_type, - webrtc::ViECodec* codec_interface, - webrtc::VideoCodec* result) { - - memset(result, 0, sizeof(webrtc::VideoCodec)); - - for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) { - webrtc::VideoCodec codec; - memset(&codec, 0, sizeof(webrtc::VideoCodec)); - if (codec_interface->GetCodec(i, codec) != 0) { - return false; - } - if (codec.codecType == of_type) { - // Done - *result = codec; - return true; - } - } - // Didn't find it - return false; -} - -void SetSuitableResolution(webrtc::VideoCodec* video_codec, - int forced_codec_width, - int forced_codec_height) { - if (forced_codec_width != kDoNotForceResolution && - forced_codec_height != kDoNotForceResolution) { - video_codec->width = forced_codec_width; - video_codec->height = forced_codec_height; - } else if (video_codec->codecType == webrtc::kVideoCodecI420) { - // I420 is very bandwidth heavy, so limit it here. - video_codec->width = 176; - video_codec->height = 144; - } else { - // Otherwise go with 640x480. - video_codec->width = 640; - video_codec->height = 480; - } -} diff --git a/webrtc/video_engine/test/auto_test/primitives/general_primitives.h b/webrtc/video_engine/test/auto_test/primitives/general_primitives.h deleted file mode 100644 index cb55eb610a..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/general_primitives.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_GENERAL_PRIMITIVES_H_ -#define WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_GENERAL_PRIMITIVES_H_ - -class ViEToFileRenderer; - -#include "webrtc/common_types.h" - -namespace webrtc { -class VideoCaptureModule; -class ViEBase; -class ViECapture; -class ViECodec; -class ViERender; -class ViERTP_RTCP; -struct VideoCodec; -} - -enum ProtectionMethod { - kNack, - kHybridNackFec, -}; - -// This constant can be used as input to various functions to not force the -// codec resolution. -const int kDoNotForceResolution = 0; - -// Finds a suitable capture device (e.g. camera) on the current system -// and allocates it. Details about the found device are filled into the out -// parameters. If this operation fails, device_id is assigned a negative value -// and number_of_errors is incremented. -void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, - char* device_name, - const unsigned int kDeviceNameLength, - int* device_id, - webrtc::VideoCaptureModule** device_video); - -// Sets up rendering in a window previously created using a Window Manager -// (See vie_window_manager_factory.h for more details on how to make one of -// those). The frame provider id is a source of video frames, for instance -// a capture device or a video channel. -// NOTE: A call to StopRenderInWindow needs to be done in order to clear -// up the configuration applied by this function. -void RenderInWindow(webrtc::ViERender* video_render_interface, - int frame_provider_id, - void* os_window, - float z_index); - -// Stops rendering into a window as previously set up by calling RenderInWindow. -void StopRenderInWindow(webrtc::ViERender* video_render_interface, - int frame_provider_id); - -// Similar in function to RenderInWindow, this function instead renders to -// a file using a to-file-renderer. The frame provider id is a source of -// video frames, for instance a capture device or a video channel. -void RenderToFile(webrtc::ViERender* renderer_interface, - int frame_provider_id, - ViEToFileRenderer* to_file_renderer); - -// Configures RTP-RTCP. -void ConfigureRtpRtcp(webrtc::ViERTP_RTCP* rtcp_interface, - ProtectionMethod protection_method, - int video_channel); - -// Finds a codec in the codec list. Returns true on success, false otherwise. -// The resulting codec is filled into result on success but is zeroed out -// on failure. -bool FindSpecificCodec(webrtc::VideoCodecType of_type, - webrtc::ViECodec* codec_interface, - webrtc::VideoCodec* result); - -// Sets up the provided codec with a resolution that takes individual codec -// quirks into account (except if the forced* variables are -// != kDoNotForceResolution) -void SetSuitableResolution(webrtc::VideoCodec* video_codec, - int forced_codec_width, - int forced_codec_height); - -#endif // WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_GENERAL_PRIMITIVES_H_ diff --git a/webrtc/video_engine/test/auto_test/primitives/input_helpers.cc b/webrtc/video_engine/test/auto_test/primitives/input_helpers.cc deleted file mode 100644 index b5c4ae203d..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/input_helpers.cc +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/primitives/input_helpers.h" - -#include -#include -#include - -#include - -#include "gflags/gflags.h" - -namespace webrtc { - -DEFINE_string(override, "", - "Makes it possible to override choices or inputs. All choices and " - "inputs will use their default values unless you override them in this " - "flag's argument. There can be several comma-separated overrides specified:" - " Overrides are specified as \"title=option text\" for choices and " - "\"title=value\" for regular inputs. Note that the program will stop if " - "you provide input not accepted by the input's validator through this flag." - "\n\nExample: --override \"Enter destination IP=192.168.0.1, " - "Select a codec=VP8\""); - -class AcceptAllNonEmptyValidator : public InputValidator { - public: - bool InputOk(const std::string& value) const { - return value.length() > 0; - } -}; - -InputBuilder::InputBuilder(const std::string& title, - const InputValidator* input_validator, - const OverrideRegistry& override_registry) - : input_source_(stdin), input_validator_(input_validator), - override_registry_(override_registry), default_value_(""), title_(title) { -} - -InputBuilder::~InputBuilder() { - delete input_validator_; -} - -std::string InputBuilder::AskForInput() const { - if (override_registry_.HasOverrideFor(title_)) - return GetOverride(); - if (!FLAGS_override.empty() && !default_value_.empty()) - return default_value_; - - // We don't know the answer already, so ask the user. - return ActuallyAskUser(); -} - -std::string InputBuilder::ActuallyAskUser() const { - printf("\n%s%s\n", title_.c_str(), additional_info_.c_str()); - - if (!default_value_.empty()) - printf("Hit enter for default (%s):\n", default_value_.c_str()); - - printf("# "); - char raw_input[128]; - if (!fgets(raw_input, 128, input_source_)) { - // If we get here the user probably hit CTRL+D. - exit(1); - } - - std::string input = raw_input; - input = input.substr(0, input.size() - 1); // Strip last \n. - - if (input.empty() && !default_value_.empty()) - return default_value_; - - if (!input_validator_->InputOk(input)) { - printf("Invalid input. Please try again.\n"); - return ActuallyAskUser(); - } - return input; -} - -InputBuilder& InputBuilder::WithInputSource(FILE* input_source) { - input_source_ = input_source; - return *this; -} - -InputBuilder& InputBuilder::WithInputValidator( - const InputValidator* input_validator) { - // If there's a default value, it must be accepted by the input validator. - assert(default_value_.empty() || input_validator->InputOk(default_value_)); - delete input_validator_; - input_validator_ = input_validator; - return *this; -} - -InputBuilder& InputBuilder::WithDefault(const std::string& default_value) { - assert(input_validator_->InputOk(default_value)); - default_value_ = default_value; - return *this; -} - -InputBuilder& InputBuilder::WithAdditionalInfo(const std::string& info) { - additional_info_ = info; - return *this; -} - -const std::string& InputBuilder::GetOverride() const { - const std::string& override = override_registry_.GetOverrideFor(title_); - if (!input_validator_->InputOk(override)) { - printf("Fatal: Input validator for \"%s\" does not accept override %s.\n", - title_.c_str(), override.c_str()); - exit(1); - } - return override; -} - -OverrideRegistry::OverrideRegistry(const std::string& overrides) { - std::vector all_overrides = Split(overrides, ","); - std::vector::const_iterator override = all_overrides.begin(); - for (; override != all_overrides.end(); ++override) { - std::vector key_value = Split(*override, "="); - if (key_value.size() != 2) { - printf("Fatal: Override %s is malformed.", (*override).c_str()); - exit(1); - } - std::string key = key_value[0]; - std::string value = key_value[1]; - overrides_[key] = value; - } -} - -bool OverrideRegistry::HasOverrideFor(const std::string& title) const { - return overrides_.find(title) != overrides_.end(); -} - -const std::string& OverrideRegistry::GetOverrideFor( - const std::string& title) const { - assert(HasOverrideFor(title)); - return (*overrides_.find(title)).second; -} - -InputBuilder TypedInput(const std::string& title) { - static OverrideRegistry override_registry_(FLAGS_override); - return InputBuilder( - title, new AcceptAllNonEmptyValidator(), override_registry_); -} - -std::vector Split(const std::string& to_split, - const std::string& delimiter) { - std::vector result; - size_t current_pos = 0; - size_t next_delimiter = 0; - while ((next_delimiter = to_split.find(delimiter, current_pos)) != - std::string::npos) { - std::string part = to_split.substr( - current_pos, next_delimiter - current_pos); - result.push_back(part); - current_pos = next_delimiter + 1; - } - std::string last_part = to_split.substr(current_pos); - if (!last_part.empty()) - result.push_back(last_part); - - return result; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/test/auto_test/primitives/input_helpers.h b/webrtc/video_engine/test/auto_test/primitives/input_helpers.h deleted file mode 100644 index 536e708a0f..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/input_helpers.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_ -#define WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_ - -#include - -#include -#include -#include - -#include "gflags/gflags.h" - -namespace webrtc { - -class InputValidator; -class OverrideRegistry; - -// This class handles general user input to the application. -class InputBuilder { - public: - // The input builder takes ownership of the validator (but not the - // override registry). - InputBuilder(const std::string& title, - const InputValidator* input_validator, - const OverrideRegistry& override_registry); - ~InputBuilder(); - - // Ask the user for input, reads input from the input source and returns - // the answer. This method will keep asking the user until a correct answer - // is returned and is thereby guaranteed to return a response that is - // acceptable to the input validator. - // - // In some cases we will not actually ask the user for input, for instance - // if the --choose-defaults or --override flags are specified. See the - // definition of those flags in the .cc file for more information. - std::string AskForInput() const; - - // Replaces the input source where we ask for input. Default is stdin. - InputBuilder& WithInputSource(FILE* input_source); - // Sets the input validator. The input builder takes ownership. If a default - // value has been set, it must be acceptable to this validator. - InputBuilder& WithInputValidator(const InputValidator* input_validator); - // Sets a default value if the user doesn't want to give input. This value - // must be acceptable to the input validator. - InputBuilder& WithDefault(const std::string& default_value); - // Prints additional info after the title. - InputBuilder& WithAdditionalInfo(const std::string& title); - - private: - const std::string& GetOverride() const; - std::string ActuallyAskUser() const; - - FILE* input_source_; - const InputValidator* input_validator_; - const OverrideRegistry& override_registry_; - std::string default_value_; - std::string title_; - std::string additional_info_; -}; - -// Keeps track of overrides for any input points. Overrides are passed in the -// format Title 1=Value 1,Title 2=Value 2. Spaces are not trimmed anywhere. -class OverrideRegistry { - public: - OverrideRegistry(const std::string& overrides); - bool HasOverrideFor(const std::string& title) const; - const std::string& GetOverrideFor(const std::string& title) const; - private: - typedef std::map OverrideMap; - OverrideMap overrides_; -}; - -class InputValidator { - public: - virtual ~InputValidator() {} - - virtual bool InputOk(const std::string& value) const = 0; -}; - -// Ensures input is an integer between low and high (inclusive). -class IntegerWithinRangeValidator : public InputValidator { - public: - IntegerWithinRangeValidator(int low, int high) - : low_(low), high_(high) {} - - bool InputOk(const std::string& input) const { - int value = atoi(input.c_str()); - // Note: atoi returns 0 on failure. - if (value == 0 && input.length() > 0 && input[0] != '0') - return false; // Probably bad input. - return value >= low_ && value <= high_; - } - - private: - int low_; - int high_; -}; - -std::vector Split(const std::string& to_split, - const std::string& delimiter); - -// Convenience method for creating an input builder. -InputBuilder TypedInput(const std::string& title); - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_TEST_AUTO_TEST_PRIMITIVES_ diff --git a/webrtc/video_engine/test/auto_test/primitives/input_helpers_unittest.cc b/webrtc/video_engine/test/auto_test/primitives/input_helpers_unittest.cc deleted file mode 100644 index 111764ace2..0000000000 --- a/webrtc/video_engine/test/auto_test/primitives/input_helpers_unittest.cc +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/video_engine/test/auto_test/primitives/fake_stdin.h" -#include "webrtc/video_engine/test/auto_test/primitives/input_helpers.h" - -namespace webrtc { - -class InputHelpersTest: public testing::Test { -}; - -TEST_F(InputHelpersTest, AcceptsAnyInputExceptEmptyByDefault) { - FILE* fake_stdin = FakeStdin("\n\nWhatever\n"); - std::string result = TypedInput("Title") - .WithInputSource(fake_stdin).AskForInput(); - EXPECT_EQ("Whatever", result); - fclose(fake_stdin); -} - -TEST_F(InputHelpersTest, ReturnsDefaultOnEmptyInputIfDefaultSet) { - FILE* fake_stdin = FakeStdin("\n\nWhatever\n"); - std::string result = TypedInput("Title") - .WithInputSource(fake_stdin) - .WithDefault("MyDefault") - .AskForInput(); - EXPECT_EQ("MyDefault", result); - fclose(fake_stdin); -} - -TEST_F(InputHelpersTest, ObeysInputValidator) { - class ValidatorWhichOnlyAcceptsFooBar : public InputValidator { - public: - bool InputOk(const std::string& input) const { - return input == "FooBar"; - } - }; - FILE* fake_stdin = FakeStdin("\nFoo\nBar\nFoo Bar\nFooBar\n"); - std::string result = TypedInput("Title") - .WithInputSource(fake_stdin) - .WithInputValidator(new ValidatorWhichOnlyAcceptsFooBar()) - .AskForInput(); - EXPECT_EQ("FooBar", result); - fclose(fake_stdin); -} - -TEST_F(InputHelpersTest, OverrideRegistryParsesOverridesCorrectly) { - // TODO(phoglund): Ignore spaces where appropriate - OverrideRegistry override_registry("My Title=Value,My Choice=1"); - EXPECT_TRUE(override_registry.HasOverrideFor("My Title")); - EXPECT_EQ("Value", override_registry.GetOverrideFor("My Title")); - EXPECT_TRUE(override_registry.HasOverrideFor("My Choice")); - EXPECT_EQ("1", override_registry.GetOverrideFor("My Choice")); - EXPECT_FALSE(override_registry.HasOverrideFor("Not Overridden")); -} - -TEST_F(InputHelpersTest, ObeysOverridesBeforeAnythingElse) { - class CarelessValidator : public InputValidator { - public: - bool InputOk(const std::string& input) const { - return true; - } - }; - FILE* fake_stdin = FakeStdin("\nFoo\nBar\nFoo Bar\nFooBar\n"); - OverrideRegistry override_registry("My Title=Value,My Choice=1"); - EXPECT_EQ("Value", InputBuilder("My Title", - new CarelessValidator(), override_registry) - .WithDefault("Whatever") - .WithInputSource(fake_stdin).AskForInput()); - fclose(fake_stdin); -} - -}; diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest.cc deleted file mode 100644 index 9ae4d4fce7..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest.cc -// - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" - -#include - -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/video_render/include/video_render.h" -#include "webrtc/test/testsupport/fileutils.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h" -#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" - -DEFINE_bool(include_timing_dependent_tests, true, - "If true, we will include tests / parts of tests that are known " - "to break in slow execution environments (such as valgrind)."); - -// ViETest implementation -FILE* ViETest::log_file_ = NULL; -char* ViETest::log_str_ = NULL; - -std::string ViETest::GetResultOutputPath() { - return webrtc::test::OutputPath(); -} - -// ViEAutoTest implementation -ViEAutoTest::ViEAutoTest(void* window1, void* window2) : - _window1(window1), - _window2(window2), - _renderType(webrtc::kRenderDefault), - _vrm1(webrtc::VideoRender::CreateVideoRender( - 4561, window1, false, _renderType)), - _vrm2(webrtc::VideoRender::CreateVideoRender( - 4562, window2, false, _renderType)) -{ - assert(_vrm1); - assert(_vrm2); -} - -ViEAutoTest::~ViEAutoTest() -{ - webrtc::VideoRender::DestroyVideoRender(_vrm1); - _vrm1 = NULL; - webrtc::VideoRender::DestroyVideoRender(_vrm2); - _vrm2 = NULL; -} - -void ViEAutoTest::ViEStandardTest() -{ - ViEBaseStandardTest(); - ViECaptureStandardTest(); - ViECodecStandardTest(); - ViEImageProcessStandardTest(); - ViERenderStandardTest(); - ViERtpRtcpStandardTest(); -} - -void ViEAutoTest::ViEExtendedTest() -{ - ViEBaseExtendedTest(); - ViECaptureExtendedTest(); - ViECodecExtendedTest(); - ViEImageProcessExtendedTest(); - ViERenderExtendedTest(); -} - -void ViEAutoTest::ViEAPITest() -{ - ViEBaseAPITest(); - ViECaptureAPITest(); - ViECodecAPITest(); - ViEImageProcessAPITest(); - ViERenderAPITest(); - ViERtpRtcpAPITest(); -} - -void ViEAutoTest::PrintVideoCodec(const webrtc::VideoCodec videoCodec) -{ - ViETest::Log("Video Codec Information:"); - - switch (videoCodec.codecType) - { - case webrtc::kVideoCodecVP8: - ViETest::Log("\tcodecType: VP8"); - break; - case webrtc::kVideoCodecVP9: - ViETest::Log("\tcodecType: VP9"); - break; - case webrtc::kVideoCodecI420: - ViETest::Log("\tcodecType: I420"); - break; - case webrtc::kVideoCodecH264: - ViETest::Log("\tcodecType: H264"); - break; - case webrtc::kVideoCodecRED: - ViETest::Log("\tcodecType: RED"); - break; - case webrtc::kVideoCodecULPFEC: - ViETest::Log("\tcodecType: ULPFEC"); - break; - case webrtc::kVideoCodecGeneric: - ViETest::Log("\tcodecType: GENERIC"); - break; - case webrtc::kVideoCodecUnknown: - ViETest::Log("\tcodecType: UNKNOWN"); - break; - } - - ViETest::Log("\theight: %u", videoCodec.height); - ViETest::Log("\tmaxBitrate: %u", videoCodec.maxBitrate); - ViETest::Log("\tmaxFramerate: %u", videoCodec.maxFramerate); - ViETest::Log("\tminBitrate: %u", videoCodec.minBitrate); - ViETest::Log("\tplName: %s", videoCodec.plName); - ViETest::Log("\tplType: %u", videoCodec.plType); - ViETest::Log("\tstartBitrate: %u", videoCodec.startBitrate); - ViETest::Log("\twidth: %u", videoCodec.width); - ViETest::Log(""); -} - -void ViEAutoTest::PrintAudioCodec(const webrtc::CodecInst audioCodec) -{ - ViETest::Log("Audio Codec Information:"); - ViETest::Log("\tchannels: %u", audioCodec.channels); - ViETest::Log("\t: %u", audioCodec.pacsize); - ViETest::Log("\t: %u", audioCodec.plfreq); - ViETest::Log("\t: %s", audioCodec.plname); - ViETest::Log("\t: %d", audioCodec.pltype); - ViETest::Log("\t: %u", audioCodec.rate); - ViETest::Log(""); -} - -void ViEAutoTest::RenderCaptureDeviceAndOutputStream( - TbInterfaces* video_engine, - TbVideoChannel* video_channel, - TbCaptureDevice* capture_device) { - RenderInWindow( - video_engine->render, capture_device->captureId, _window1, 0); - RenderInWindow( - video_engine->render, video_channel->videoChannel, _window2, 1); -} - -void ViEAutoTest::StopRenderCaptureDeviceAndOutputStream( - TbInterfaces* video_engine, - TbVideoChannel* video_channel, - TbCaptureDevice* capture_device) { - StopRenderInWindow(video_engine->render, capture_device->captureId); - StopRenderInWindow(video_engine->render, video_channel->videoChannel); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_android.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_android.cc deleted file mode 100644 index e69a3ebc9f..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_android.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_android.h" - -#include -#include - -#include "webrtc/modules/video_capture/video_capture_internal.h" -#include "webrtc/modules/video_render/video_render_internal.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" - -int ViEAutoTestAndroid::RunAutotest(int testSelection, int subTestSelection, - void* window1, void* window2, - JavaVM* javaVM, void* env, void* context) { - ViEAutoTest vieAutoTest(window1, window2); - ViETest::Log("RunAutoTest(%d, %d)", testSelection, subTestSelection); - webrtc::SetCaptureAndroidVM(javaVM, static_cast(context)); - webrtc::SetRenderAndroidVM(javaVM); -#ifndef WEBRTC_ANDROID_OPENSLES - // voice engine calls into ADM directly - webrtc::VoiceEngine::SetAndroidObjects(javaVM, context); -#endif - - if (subTestSelection == 0) { - // Run all selected test - switch (testSelection) { - case 0: - vieAutoTest.ViEStandardTest(); - break; - case 1: - vieAutoTest.ViEAPITest(); - break; - case 2: - vieAutoTest.ViEExtendedTest(); - break; - case 3: - vieAutoTest.ViELoopbackCall(); - break; - default: - break; - } - } - - switch (testSelection) { - case 0: // Specific standard test - switch (subTestSelection) { - case 1: // base - vieAutoTest.ViEBaseStandardTest(); - break; - - case 2: // capture - vieAutoTest.ViECaptureStandardTest(); - break; - - case 3: // codec - vieAutoTest.ViECodecStandardTest(); - break; - - case 6: // image process - vieAutoTest.ViEImageProcessStandardTest(); - break; - -#if 0 // vie_autotest_network.cc isn't actually pulled into the build at all! - case 7: // network - vieAutoTest.ViENetworkStandardTest(); - break; -#endif - - case 8: // Render - vieAutoTest.ViERenderStandardTest(); - break; - - case 9: // RTP/RTCP - vieAutoTest.ViERtpRtcpStandardTest(); - break; - - default: - break; - } - break; - - case 1:// specific API - switch (subTestSelection) { - case 1: // base - vieAutoTest.ViEBaseAPITest(); - break; - - case 2: // capture - vieAutoTest.ViECaptureAPITest(); - break; - - case 3: // codec - vieAutoTest.ViECodecAPITest(); - break; - - case 6: // image process - vieAutoTest.ViEImageProcessAPITest(); - break; - -#if 0 // vie_autotest_network.cc isn't actually pulled into the build at all! - case 7: // network - vieAutoTest.ViENetworkAPITest(); - break; -#endif - - case 8: // Render - vieAutoTest.ViERenderAPITest(); - break; - - case 9: // RTP/RTCP - vieAutoTest.ViERtpRtcpAPITest(); - break; - case 10: - break; - - default: - break; - } - break; - - case 2:// specific extended - switch (subTestSelection) { - case 1: // base - vieAutoTest.ViEBaseExtendedTest(); - break; - - case 2: // capture - vieAutoTest.ViECaptureExtendedTest(); - break; - - case 3: // codec - vieAutoTest.ViECodecExtendedTest(); - break; - - case 6: // image process - vieAutoTest.ViEImageProcessExtendedTest(); - break; - - case 7: // Render - vieAutoTest.ViERenderExtendedTest(); - break; - - case 8: // RTP/RTCP - // Note that this test is removed. It hasn't been properly cleaned up - // because this hopefully going away soon. - break; - - default: - break; - } - break; - - case 3: - vieAutoTest.ViELoopbackCall(); - break; - - default: - break; - } - - return 0; -} - -int main(int argc, char** argv) { - // TODO(leozwang): Add real tests here - return 0; -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc deleted file mode 100644 index 3a94e051be..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/video_capture/include/video_capture_factory.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/primitives/base_primitives.h" -#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" - -void ViEAutoTest::ViEBaseStandardTest() { - // *************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - // *************************************************************** - - TbInterfaces interfaces("ViEBaseStandardTest"); - - // *************************************************************** - // Engine ready. Set up the test case: - // *************************************************************** - int video_channel = -1; - EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); - - webrtc::VideoCaptureModule* video_capture_module = NULL; - const unsigned int kMaxDeviceNameLength = 128; - char device_name[kMaxDeviceNameLength]; - memset(device_name, 0, kMaxDeviceNameLength); - int capture_id; - - webrtc::ViEBase* base_interface = interfaces.base; - webrtc::ViERender* render_interface = interfaces.render; - webrtc::ViECapture* capture_interface = interfaces.capture; - - FindCaptureDeviceOnSystem(capture_interface, - device_name, - kMaxDeviceNameLength, - &capture_id, - &video_capture_module); - - EXPECT_TRUE(video_capture_module); - if (!video_capture_module) - return; - - EXPECT_EQ(0, capture_interface->ConnectCaptureDevice(capture_id, - video_channel)); - EXPECT_EQ(0, capture_interface->StartCapture(capture_id)); - - ConfigureRtpRtcp(interfaces.rtp_rtcp, kNack, video_channel); - - EXPECT_EQ(0, render_interface->RegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, render_interface->RegisterVideoRenderModule(*_vrm2)); - - RenderInWindow(render_interface, capture_id, _window1, 0); - RenderInWindow(render_interface, video_channel, _window2, 1); - - // *************************************************************** - // Run the actual test: - // *************************************************************** - ViETest::Log("You should shortly see a local preview from camera %s" - " in window 1 and the remote video in window 2.", device_name); - ::TestI420CallSetup(interfaces.codec, interfaces.video_engine, - base_interface, interfaces.network, interfaces.rtp_rtcp, - video_channel, device_name); - - // *************************************************************** - // Testing finished. Tear down Video Engine - // *************************************************************** - EXPECT_EQ(0, capture_interface->DisconnectCaptureDevice(video_channel)); - EXPECT_EQ(0, capture_interface->StopCapture(capture_id)); - EXPECT_EQ(0, base_interface->StopReceive(video_channel)); - - EXPECT_EQ(0, render_interface->StopRender(video_channel)); - EXPECT_EQ(0, render_interface->RemoveRenderer(video_channel)); - EXPECT_EQ(0, render_interface->RemoveRenderer(capture_id)); - - EXPECT_EQ(0, render_interface->DeRegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, render_interface->DeRegisterVideoRenderModule(*_vrm2)); - - EXPECT_EQ(0, capture_interface->ReleaseCaptureDevice(capture_id)); - - video_capture_module->Release(); - video_capture_module = NULL; - - EXPECT_EQ(0, base_interface->DeleteChannel(video_channel)); -} - -void ViEAutoTest::ViEBaseExtendedTest() { - // Start with standard test - ViEBaseAPITest(); - ViEBaseStandardTest(); -} - -void ViEAutoTest::ViEBaseAPITest() { - // *************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - // *************************************************************** - // Get the ViEBase API - webrtc::ViEBase* vie_base = webrtc::ViEBase::GetInterface(NULL); - EXPECT_EQ(NULL, vie_base) << "Should return null for a bad ViE pointer"; - - webrtc::VideoEngine* video_engine = webrtc::VideoEngine::Create(); - EXPECT_TRUE(NULL != video_engine); - - std::string trace_file_path = - ViETest::GetResultOutputPath() + "ViEBaseAPI_trace.txt"; - EXPECT_EQ(0, video_engine->SetTraceFile(trace_file_path.c_str())); - - vie_base = webrtc::ViEBase::GetInterface(video_engine); - EXPECT_TRUE(NULL != vie_base); - - webrtc::ViENetwork* vie_network = - webrtc::ViENetwork::GetInterface(video_engine); - EXPECT_TRUE(vie_network != NULL); - - webrtc::ViERTP_RTCP* vie_rtp = - webrtc::ViERTP_RTCP::GetInterface(video_engine); - EXPECT_TRUE(vie_rtp != NULL); - - // *************************************************************** - // Engine ready. Begin testing class - // *************************************************************** - char version[1024] = ""; - EXPECT_EQ(0, vie_base->GetVersion(version)); - EXPECT_EQ(0, vie_base->LastError()); - - int video_channel = -1; - EXPECT_EQ(0, vie_base->Init()); - EXPECT_EQ(0, vie_base->CreateChannel(video_channel)); - - int video_channel2 = -1; - int video_channel3 = -1; - EXPECT_EQ(0, vie_base->CreateChannel(video_channel2)); - EXPECT_NE(video_channel, video_channel2) << - "Should allocate new number for independent channel"; - - EXPECT_EQ(0, vie_base->DeleteChannel(video_channel2)); - - EXPECT_EQ(-1, vie_base->CreateChannel(video_channel2, video_channel + 1)) - << "Should fail since neither channel exists (the second must)"; - - // Create a receive only channel and a send channel. Verify we can't send on - // the receive only channel. - EXPECT_EQ(0, vie_base->CreateReceiveChannel(video_channel2, - video_channel)); - EXPECT_EQ(0, vie_base->CreateChannel(video_channel3, video_channel)); - - const char* ip_address = "127.0.0.1\0"; - const int send_port = 1234; - - EXPECT_EQ(0, vie_rtp->SetLocalSSRC(video_channel, 1)); - EXPECT_EQ(0, vie_rtp->SetLocalSSRC(video_channel, 2)); - EXPECT_EQ(0, vie_rtp->SetLocalSSRC(video_channel, 3)); - - webrtc::test::VideoChannelTransport* video_channel_transport_1 = - new webrtc::test::VideoChannelTransport(vie_network, video_channel); - - ASSERT_EQ(0, video_channel_transport_1->SetSendDestination(ip_address, - send_port)); - - webrtc::test::VideoChannelTransport* video_channel_transport_2 = - new webrtc::test::VideoChannelTransport(vie_network, video_channel2); - - webrtc::test::VideoChannelTransport* video_channel_transport_3 = - new webrtc::test::VideoChannelTransport(vie_network, video_channel3); - - ASSERT_EQ(0, video_channel_transport_3->SetSendDestination(ip_address, - send_port + 4)); - - EXPECT_EQ(0, vie_base->StartSend(video_channel)); - EXPECT_EQ(-1, vie_base->StartSend(video_channel2)); - EXPECT_EQ(0, vie_base->StartSend(video_channel3)); - EXPECT_EQ(0, vie_base->StopSend(video_channel)); - EXPECT_EQ(0, vie_base->StopSend(video_channel3)); - - // Test Voice Engine integration with Video Engine. - webrtc::VoiceEngine* voice_engine = NULL; - webrtc::VoEBase* voe_base = NULL; - int audio_channel = -1; - - voice_engine = webrtc::VoiceEngine::Create(); - EXPECT_TRUE(NULL != voice_engine); - - voe_base = webrtc::VoEBase::GetInterface(voice_engine); - EXPECT_TRUE(NULL != voe_base); - EXPECT_EQ(0, voe_base->Init()); - - audio_channel = voe_base->CreateChannel(); - EXPECT_NE(-1, audio_channel); - - // Connect before setting VoE. - EXPECT_NE(0, vie_base->ConnectAudioChannel(video_channel, audio_channel)) - << "Should fail since Voice Engine is not set yet."; - - // Then do it right. - EXPECT_EQ(0, vie_base->SetVoiceEngine(voice_engine)); - EXPECT_EQ(0, vie_base->ConnectAudioChannel(video_channel, audio_channel)); - - // *************************************************************** - // Testing finished. Tear down Video Engine - // *************************************************************** - EXPECT_NE(0, vie_base->DisconnectAudioChannel(video_channel + 5)) << - "Should fail: disconnecting bogus channel"; - - EXPECT_EQ(0, vie_base->DisconnectAudioChannel(video_channel)); - - // Clean up voice engine - EXPECT_EQ(0, vie_rtp->Release()); - EXPECT_EQ(0, vie_network->Release()); - EXPECT_EQ(0, vie_base->SetVoiceEngine(NULL)); - // VoiceEngine reference counting is per object, not per interface, so - // Release should return != 0. - EXPECT_NE(0, voe_base->Release()); - EXPECT_TRUE(webrtc::VoiceEngine::Delete(voice_engine)); - - webrtc::ViEBase* vie_base2 = webrtc::ViEBase::GetInterface(video_engine); - EXPECT_TRUE(NULL != vie_base2); - - EXPECT_EQ(1, vie_base->Release()) << - "There should be one interface left."; - - EXPECT_FALSE(webrtc::VideoEngine::Delete(video_engine)) << - "Should fail since there are interfaces left."; - - delete video_channel_transport_1; - delete video_channel_transport_2; - delete video_channel_transport_3; - EXPECT_EQ(0, vie_base->Release()); - EXPECT_TRUE(webrtc::VideoEngine::Delete(video_engine)); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc deleted file mode 100644 index 68b1afda02..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc +++ /dev/null @@ -1,542 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "gflags/gflags.h" -#include "webrtc/common_types.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/video_capture/include/video_capture_factory.h" -#include "webrtc/system_wrappers/interface/tick_util.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" -#include "webrtc/voice_engine/include/voe_base.h" - -DEFINE_bool(capture_test_ensure_resolution_alignment_in_capture_device, true, - "If true, we will give resolutions slightly below a reasonable " - "value to test the camera's ability to choose a good resolution. " - "If false, we will provide reasonable resolutions instead."); - -class CaptureObserver : public webrtc::ViECaptureObserver { - public: - CaptureObserver() - : brightness_(webrtc::Normal), - alarm_(webrtc::AlarmCleared), - frame_rate_(0) {} - - virtual void BrightnessAlarm(const int capture_id, - const webrtc::Brightness brightness) { - brightness_ = brightness; - switch (brightness) { - case webrtc::Normal: - ViETest::Log(" BrightnessAlarm Normal"); - break; - case webrtc::Bright: - ViETest::Log(" BrightnessAlarm Bright"); - break; - case webrtc::Dark: - ViETest::Log(" BrightnessAlarm Dark"); - break; - } - } - - virtual void CapturedFrameRate(const int capture_id, - const unsigned char frame_rate) { - ViETest::Log(" CapturedFrameRate %u", frame_rate); - frame_rate_ = frame_rate; - } - - virtual void NoPictureAlarm(const int capture_id, - const webrtc::CaptureAlarm alarm) { - alarm_ = alarm; - if (alarm == webrtc::AlarmRaised) { - ViETest::Log("NoPictureAlarm CARaised."); - } else { - ViETest::Log("NoPictureAlarm CACleared."); - } - } - - webrtc::Brightness brightness_; - webrtc::CaptureAlarm alarm_; - unsigned char frame_rate_; -}; - -class CaptureEffectFilter : public webrtc::ViEEffectFilter { - public: - CaptureEffectFilter(unsigned int expected_width, unsigned int expected_height) - : number_of_captured_frames_(0), - expected_width_(expected_width), - expected_height_(expected_height) { - } - - // Implements video_engineEffectFilter. - virtual int Transform(size_t size, - unsigned char* frame_buffer, - int64_t ntp_time_ms, - unsigned int timestamp, - unsigned int width, - unsigned int height) { - EXPECT_TRUE(frame_buffer != NULL); - EXPECT_EQ(expected_width_, width); - EXPECT_EQ(expected_height_, height); - ++number_of_captured_frames_; - return 0; - } - - int number_of_captured_frames_; - - protected: - unsigned int expected_width_; - unsigned int expected_height_; -}; - -void ViEAutoTest::ViECaptureStandardTest() { - /// ************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - /// ************************************************************** - - /// ************************************************************** - // Engine ready. Begin testing class - /// ************************************************************** - - TbInterfaces video_engine("video_engineCaptureStandardTest"); - - webrtc::VideoCaptureModule::DeviceInfo* dev_info = - webrtc::VideoCaptureFactory::CreateDeviceInfo(0); - ASSERT_TRUE(dev_info != NULL); - - int number_of_capture_devices = dev_info->NumberOfDevices(); - ViETest::Log("Number of capture devices %d", - number_of_capture_devices); - ASSERT_GT(number_of_capture_devices, 0) - << "This test requires a capture device (i.e. a webcam)"; - -#if !defined(WEBRTC_MAC) - int capture_device_id[10] = {0}; - webrtc::VideoCaptureModule* vcpms[10] = {0}; -#endif - - // Check capabilities - for (int device_index = 0; device_index < number_of_capture_devices; - ++device_index) { - char device_name[128]; - char device_unique_name[512]; - - EXPECT_EQ(0, dev_info->GetDeviceName(device_index, - device_name, - sizeof(device_name), - device_unique_name, - sizeof(device_unique_name))); - ViETest::Log("Found capture device %s\nUnique name %s", - device_name, device_unique_name); - -#if !defined(WEBRTC_MAC) // these functions will return -1 - int number_of_capabilities = - dev_info->NumberOfCapabilities(device_unique_name); - EXPECT_GT(number_of_capabilities, 0); - - for (int cap_index = 0; cap_index < number_of_capabilities; ++cap_index) { - webrtc::VideoCaptureCapability capability; - EXPECT_EQ(0, dev_info->GetCapability(device_unique_name, cap_index, - capability)); - ViETest::Log("Capture capability %d (of %u)", cap_index + 1, - number_of_capabilities); - ViETest::Log("width %d, height %d, frame rate %d", - capability.width, capability.height, capability.maxFPS); - ViETest::Log("expected delay %d, color type %d, encoding %d", - capability.expectedCaptureDelay, capability.rawType, - capability.codecType); - EXPECT_GT(capability.width, 0); - EXPECT_GT(capability.height, 0); - EXPECT_GT(capability.maxFPS, -1); // >= 0 - EXPECT_GT(capability.expectedCaptureDelay, 0); - } -#endif - } - // Capture Capability Functions are not supported on WEBRTC_MAC. -#if !defined(WEBRTC_MAC) - - // Check allocation. Try to allocate them all after each other. - for (int device_index = 0; device_index < number_of_capture_devices; - ++device_index) { - char device_name[128]; - char device_unique_name[512]; - EXPECT_EQ(0, dev_info->GetDeviceName(device_index, - device_name, - sizeof(device_name), - device_unique_name, - sizeof(device_unique_name))); - webrtc::VideoCaptureModule* vcpm = - webrtc::VideoCaptureFactory::Create(device_index, device_unique_name); - EXPECT_TRUE(vcpm != NULL); - if (!vcpm) - continue; - - vcpm->AddRef(); - vcpms[device_index] = vcpm; - - EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice( - *vcpm, capture_device_id[device_index])); - - webrtc::VideoCaptureCapability capability; - EXPECT_EQ(0, dev_info->GetCapability(device_unique_name, 0, capability)); - - // Test that the camera select the closest capability to the selected - // width and height. - CaptureEffectFilter filter(capability.width, capability.height); - EXPECT_EQ(0, video_engine.image_process->RegisterCaptureEffectFilter( - capture_device_id[device_index], filter)); - - ViETest::Log("Testing Device %s capability width %d height %d", - device_unique_name, capability.width, capability.height); - - if (FLAGS_capture_test_ensure_resolution_alignment_in_capture_device) { - // This tests that the capture device properly aligns to a - // multiple of 16 (or at least 8). - capability.height = capability.height - 2; - capability.width = capability.width - 2; - } - - webrtc::CaptureCapability vie_capability; - vie_capability.width = capability.width; - vie_capability.height = capability.height; - vie_capability.codecType = capability.codecType; - vie_capability.maxFPS = capability.maxFPS; - vie_capability.rawType = capability.rawType; - - EXPECT_EQ(0, video_engine.capture->StartCapture( - capture_device_id[device_index], vie_capability)); - webrtc::TickTime start_time = webrtc::TickTime::Now(); - - while (filter.number_of_captured_frames_ < 10 && - (webrtc::TickTime::Now() - start_time).Milliseconds() < 10000) { - AutoTestSleep(100); - } - - EXPECT_GT(filter.number_of_captured_frames_, 9) - << "Should capture at least some frames"; - - EXPECT_EQ(0, video_engine.image_process->DeregisterCaptureEffectFilter( - capture_device_id[device_index])); - -#ifdef WEBRTC_ANDROID // Can only allocate one camera at the time on Android. - EXPECT_EQ(0, video_engine.capture->StopCapture( - capture_device_id[device_index])); - EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice( - capture_device_id[device_index])); -#endif - } - - /// ************************************************************** - // Testing finished. Tear down Video Engine - /// ************************************************************** - delete dev_info; - - // Stop all started capture devices. - for (int device_index = 0; device_index < number_of_capture_devices; - ++device_index) { -#if !defined(WEBRTC_ANDROID) - // Don't stop on Android since we can only allocate one camera. - EXPECT_EQ(0, video_engine.capture->StopCapture( - capture_device_id[device_index])); - EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice( - capture_device_id[device_index])); -#endif // !WEBRTC_ANDROID - if (vcpms[device_index]) - vcpms[device_index]->Release(); - } -#endif // !WEBRTC_MAC -} - -void ViEAutoTest::ViECaptureExtendedTest() { - ViECaptureExternalCaptureTest(); -} - -void ViEAutoTest::ViECaptureAPITest() { - /// ************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - /// ************************************************************** - - /// ************************************************************** - // Engine ready. Begin testing class - /// ************************************************************** - TbInterfaces video_engine("video_engineCaptureAPITest"); - - video_engine.capture->NumberOfCaptureDevices(); - - char device_name[128]; - char device_unique_name[512]; - int capture_id = 0; - - webrtc::VideoCaptureModule::DeviceInfo* dev_info = - webrtc::VideoCaptureFactory::CreateDeviceInfo(0); - ASSERT_TRUE(dev_info != NULL); - ASSERT_GT(dev_info->NumberOfDevices(), 0u) - << "This test requires a capture device (i.e. a webcam)"; - - // Get the first capture device - EXPECT_EQ(0, dev_info->GetDeviceName(0, device_name, - sizeof(device_name), - device_unique_name, - sizeof(device_unique_name))); - - webrtc::VideoCaptureModule* vcpm = - webrtc::VideoCaptureFactory::Create(0, device_unique_name); - vcpm->AddRef(); - EXPECT_TRUE(vcpm != NULL); - - // Allocate capture device. - EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice(*vcpm, capture_id)); - - // Start the capture device. - EXPECT_EQ(0, video_engine.capture->StartCapture(capture_id)); - - // Start again. Should fail. - EXPECT_NE(0, video_engine.capture->StartCapture(capture_id)); - EXPECT_EQ(kViECaptureDeviceAlreadyStarted, video_engine.LastError()); - - // Start invalid capture device. - EXPECT_NE(0, video_engine.capture->StartCapture(capture_id + 1)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - - // Stop invalid capture device. - EXPECT_NE(0, video_engine.capture->StopCapture(capture_id + 1)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - - // Stop the capture device. - EXPECT_EQ(0, video_engine.capture->StopCapture(capture_id)); - - // Stop the capture device again. - EXPECT_NE(0, video_engine.capture->StopCapture(capture_id)); - EXPECT_EQ(kViECaptureDeviceNotStarted, video_engine.LastError()); - - // Connect to invalid channel. - EXPECT_NE(0, video_engine.capture->ConnectCaptureDevice(capture_id, 0)); - EXPECT_EQ(kViECaptureDeviceInvalidChannelId, - video_engine.LastError()); - - TbVideoChannel channel(video_engine); - - // Connect invalid capture_id. - EXPECT_NE(0, video_engine.capture->ConnectCaptureDevice(capture_id + 1, - channel.videoChannel)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - - // Connect the capture device to the channel. - EXPECT_EQ(0, video_engine.capture->ConnectCaptureDevice(capture_id, - channel.videoChannel)); - - // Connect the channel again. - EXPECT_NE(0, video_engine.capture->ConnectCaptureDevice(capture_id, - channel.videoChannel)); - EXPECT_EQ(kViECaptureDeviceAlreadyConnected, - video_engine.LastError()); - - // Start the capture device. - EXPECT_EQ(0, video_engine.capture->StartCapture(capture_id)); - - // Release invalid capture device. - EXPECT_NE(0, video_engine.capture->ReleaseCaptureDevice(capture_id + 1)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - - // Release the capture device. - EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - - // Release the capture device again. - EXPECT_NE(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - - // Test GetOrientation. - webrtc::VideoRotation orientation; - char dummy_name[5]; - EXPECT_NE(0, dev_info->GetOrientation(dummy_name, orientation)); - - // Test SetRotation. - EXPECT_NE(0, video_engine.capture->SetVideoRotation( - capture_id, webrtc::kVideoRotation_90)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - - // Allocate capture device. - EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice(*vcpm, capture_id)); - - EXPECT_EQ(0, video_engine.capture->SetVideoRotation( - capture_id, webrtc::kVideoRotation_0)); - EXPECT_EQ(0, video_engine.capture->SetVideoRotation( - capture_id, webrtc::kVideoRotation_90)); - EXPECT_EQ(0, video_engine.capture->SetVideoRotation( - capture_id, webrtc::kVideoRotation_180)); - EXPECT_EQ(0, video_engine.capture->SetVideoRotation( - capture_id, webrtc::kVideoRotation_270)); - - // Release the capture device - EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - - /// ************************************************************** - // Testing finished. Tear down Video Engine - /// ************************************************************** - delete dev_info; - vcpm->Release(); -} - -void ViEAutoTest::ViECaptureExternalCaptureTest() { - /// ************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - /// ************************************************************** - - TbInterfaces video_engine("video_engineCaptureExternalCaptureTest"); - TbVideoChannel channel(video_engine); - channel.StartReceive(); - channel.StartSend(); - - webrtc::VideoCaptureExternal* external_capture = NULL; - int capture_id = 0; - - // Allocate the external capture device. - webrtc::VideoCaptureModule* vcpm = - webrtc::VideoCaptureFactory::Create(0, external_capture); - EXPECT_TRUE(vcpm != NULL); - EXPECT_TRUE(external_capture != NULL); - vcpm->AddRef(); - - EXPECT_EQ(0, video_engine.capture->AllocateCaptureDevice(*vcpm, capture_id)); - - // Connect the capture device to the channel. - EXPECT_EQ(0, video_engine.capture->ConnectCaptureDevice(capture_id, - channel.videoChannel)); - - // Render the local capture. - EXPECT_EQ(0, video_engine.render->AddRenderer(capture_id, _window1, 1, 0.0, - 0.0, 1.0, 1.0)); - - // Render the remote capture. - EXPECT_EQ(0, video_engine.render->AddRenderer(channel.videoChannel, _window2, - 1, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, video_engine.render->StartRender(capture_id)); - EXPECT_EQ(0, video_engine.render->StartRender(channel.videoChannel)); - - // Register observer. - CaptureObserver observer; - EXPECT_EQ(0, video_engine.capture->RegisterObserver(capture_id, observer)); - - // Enable brightness alarm. - EXPECT_EQ(0, video_engine.capture->EnableBrightnessAlarm(capture_id, true)); - - CaptureEffectFilter effect_filter(176, 144); - EXPECT_EQ(0, video_engine.image_process->RegisterCaptureEffectFilter( - capture_id, effect_filter)); - - // Call started. - ViETest::Log("You should see local preview from external capture\n" - "in window 1 and the remote video in window 2.\n"); - - /// ************************************************************** - // Engine ready. Begin testing class - /// ************************************************************** - const size_t video_frame_length = (176 * 144 * 3) / 2; - unsigned char* video_frame = new unsigned char[video_frame_length]; - memset(video_frame, 128, 176 * 144); - - int frame_count = 0; - webrtc::VideoCaptureCapability capability; - capability.width = 176; - capability.height = 144; - capability.rawType = webrtc::kVideoI420; - - ViETest::Log("Testing external capturing and frame rate callbacks."); - // TODO(mflodman) Change when using a real file! - // while (fread(video_frame, video_frame_length, 1, foreman) == 1) - while (frame_count < 120) { - external_capture->IncomingFrame( - video_frame, video_frame_length, capability, - webrtc::TickTime::MillisecondTimestamp()); - AutoTestSleep(33); - - if (effect_filter.number_of_captured_frames_ > 2) { - EXPECT_EQ(webrtc::Normal, observer.brightness_) << - "Brightness or picture alarm should not have been called yet."; - EXPECT_EQ(webrtc::AlarmCleared, observer.alarm_) << - "Brightness or picture alarm should not have been called yet."; - } - frame_count++; - } - - // Test brightness alarm. - // Test bright image. - for (int i = 0; i < 176 * 144; ++i) { - if (video_frame[i] <= 155) - video_frame[i] = video_frame[i] + 100; - else - video_frame[i] = 255; - } - ViETest::Log("Testing Brighness alarm"); - for (int frame = 0; frame < 30; ++frame) { - external_capture->IncomingFrame( - video_frame, video_frame_length, capability, - webrtc::TickTime::MillisecondTimestamp()); - AutoTestSleep(33); - } - EXPECT_EQ(webrtc::Bright, observer.brightness_) << - "Should be bright at this point since we are using a bright image."; - - // Test Dark image - for (int i = 0; i < 176 * 144; ++i) { - video_frame[i] = video_frame[i] > 200 ? video_frame[i] - 200 : 0; - } - for (int frame = 0; frame < 30; ++frame) { - external_capture->IncomingFrame( - video_frame, video_frame_length, capability, - webrtc::TickTime::MillisecondTimestamp()); - AutoTestSleep(33); - } - EXPECT_EQ(webrtc::Dark, observer.brightness_) << - "Should be dark at this point since we are using a dark image."; - EXPECT_GT(effect_filter.number_of_captured_frames_, 150) << - "Frames should have been played."; - - EXPECT_GE(observer.frame_rate_, 29) << - "Frame rate callback should be approximately correct."; - EXPECT_LE(observer.frame_rate_, 30) << - "Frame rate callback should be approximately correct."; - - // Test no picture alarm - ViETest::Log("Testing NoPictureAlarm."); - AutoTestSleep(1050); - - EXPECT_EQ(webrtc::AlarmRaised, observer.alarm_) << - "No picture alarm should be raised."; - for (int frame = 0; frame < 10; ++frame) { - external_capture->IncomingFrame( - video_frame, video_frame_length, capability, - webrtc::TickTime::MillisecondTimestamp()); - AutoTestSleep(33); - } - EXPECT_EQ(webrtc::AlarmCleared, observer.alarm_) << - "Alarm should be cleared since ge just got some data."; - - delete video_frame; - - // Release the capture device - EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - - // Release the capture device again - EXPECT_NE(0, video_engine.capture->ReleaseCaptureDevice(capture_id)); - EXPECT_EQ(kViECaptureDeviceDoesNotExist, video_engine.LastError()); - vcpm->Release(); - - /// ************************************************************** - // Testing finished. Tear down Video Engine - /// ************************************************************** -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_cocoa_mac.mm b/webrtc/video_engine/test/auto_test/source/vie_autotest_cocoa_mac.mm deleted file mode 100644 index 15afe5ceb7..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_cocoa_mac.mm +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/engine_configurations.h" - -#import "webrtc/modules/video_render/mac/cocoa_render_view.h" -#import "webrtc/test/testsupport/mac/run_threaded_main_mac.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_mac_cocoa.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h" - -@implementation TestCocoaUi - -// TODO(phoglund): This file probably leaks memory like crazy. Find someone -// who understands objective-c memory management and fix it. - -- (void)prepareToCreateWindowsWithSize:(AutoTestRect)window1Size - andSize:(AutoTestRect)window2Size - withTitle:(void*)window1_title - andTitle:(void*)window2_title { - window1Size_ = window1Size; - window2Size_ = window2Size; - window1Title_ = window1_title; - window2Title_ = window2_title; -} - -- (void)createWindows:(NSObject*)ignored { - NSRect window1Frame = NSMakeRect( - window1Size_.origin.x, window1Size_.origin.y, - window1Size_.size.width, window1Size_.size.height); - - window1_ = [[NSWindow alloc] - initWithContentRect:window1Frame - styleMask:NSTitledWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - [window1_ orderOut:nil]; - - NSRect render_view1_frame = NSMakeRect( - 0, 0, window1Size_.size.width, window1Size_.size.height); - cocoaRenderView1_ = - [[CocoaRenderView alloc] initWithFrame:render_view1_frame]; - - [[window1_ contentView] addSubview:(NSView*)cocoaRenderView1_]; - [window1_ setTitle:[NSString stringWithFormat:@"%s", window1Title_]]; - [window1_ makeKeyAndOrderFront:NSApp]; - - NSRect window2_frame = NSMakeRect( - window2Size_.origin.x, window2Size_.origin.y, - window2Size_.size.width, window2Size_.size.height); - - window2_ = [[NSWindow alloc] - initWithContentRect:window2_frame - styleMask:NSTitledWindowMask - backing:NSBackingStoreBuffered - defer:NO]; - [window2_ orderOut:nil]; - - NSRect render_view2_frame = NSMakeRect( - 0, 0, window1Size_.size.width, window1Size_.size.height); - cocoaRenderView2_ = - [[CocoaRenderView alloc] initWithFrame:render_view2_frame]; - [[window2_ contentView] addSubview:(NSView*)cocoaRenderView2_]; - [window2_ setTitle:[NSString stringWithFormat:@"%s", window2Title_]]; - [window2_ makeKeyAndOrderFront:NSApp]; -} - -- (NSWindow*)window1 { - return window1_; -} - -- (NSWindow*)window2 { - return window2_; -} - -- (CocoaRenderView*)cocoaRenderView1 { - return cocoaRenderView1_; -} - -- (CocoaRenderView*)cocoaRenderView2 { - return cocoaRenderView2_; -} - -@end - -ViEAutoTestWindowManager::ViEAutoTestWindowManager() { - cocoa_ui_ = [[TestCocoaUi alloc] init]; -} - -ViEAutoTestWindowManager::~ViEAutoTestWindowManager() { - [cocoa_ui_ release]; -} - -int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size, - AutoTestRect window2Size, - void* window1_title, - void* window2_title) { - [cocoa_ui_ prepareToCreateWindowsWithSize:window1Size - andSize:window2Size - withTitle:window1_title - andTitle:window2_title]; - [cocoa_ui_ performSelectorOnMainThread:@selector(createWindows:) - withObject:nil - waitUntilDone:YES]; - return 0; -} - -int ViEAutoTestWindowManager::TerminateWindows() { - [[cocoa_ui_ window1] close]; - [[cocoa_ui_ window2] close]; - return 0; -} - -void* ViEAutoTestWindowManager::GetWindow1() { - return [cocoa_ui_ cocoaRenderView1]; -} - -void* ViEAutoTestWindowManager::GetWindow2() { - return [cocoa_ui_ cocoaRenderView2]; -} - -bool ViEAutoTestWindowManager::SetTopmostWindow() { - return true; -} - -// This is acts as our "main" for mac. The actual (reusable) main is defined in -// testsupport/mac/run_threaded_main_mac.mm. -int ImplementThisToRunYourTest(int argc, char** argv) { - ViEAutoTestMain auto_test; - return auto_test.RunTests(argc, argv); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_codec.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_codec.cc deleted file mode 100644 index f5ff771a70..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_codec.cc +++ /dev/null @@ -1,830 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/common_types.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/video_coding/codecs/i420/main/interface/i420.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_external_codec.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/tb_I420_codec.h" -#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" -#include "webrtc/voice_engine/include/voe_base.h" - -class TestCodecObserver : public webrtc::ViEEncoderObserver, - public webrtc::ViEDecoderObserver { - public: - int incoming_codec_called_; - int incoming_rate_called_; - int decoder_timing_called_; - int outgoing_rate_called_; - - unsigned char last_payload_type_; - uint16_t last_width_; - uint16_t last_height_; - - unsigned int last_outgoing_framerate_; - unsigned int last_outgoing_bitrate_; - unsigned int last_incoming_framerate_; - unsigned int last_incoming_bitrate_; - unsigned int suspend_change_called_; - - webrtc::VideoCodec incoming_codec_; - - TestCodecObserver() - : incoming_codec_called_(0), - incoming_rate_called_(0), - decoder_timing_called_(0), - outgoing_rate_called_(0), - last_payload_type_(0), - last_width_(0), - last_height_(0), - last_outgoing_framerate_(0), - last_outgoing_bitrate_(0), - last_incoming_framerate_(0), - last_incoming_bitrate_(0), - suspend_change_called_(0) { - memset(&incoming_codec_, 0, sizeof(incoming_codec_)); - } - virtual void IncomingCodecChanged(const int video_channel, - const webrtc::VideoCodec& video_codec) { - incoming_codec_called_++; - last_payload_type_ = video_codec.plType; - last_width_ = video_codec.width; - last_height_ = video_codec.height; - - memcpy(&incoming_codec_, &video_codec, sizeof(video_codec)); - } - - virtual void IncomingRate(const int video_channel, - const unsigned int framerate, - const unsigned int bitrate) { - incoming_rate_called_++; - last_incoming_framerate_ += framerate; - last_incoming_bitrate_ += bitrate; - } - - virtual void DecoderTiming(int decode_ms, - int max_decode_ms, - int current_delay_ms, - int target_delay_ms, - int jitter_buffer_ms, - int min_playout_delay_ms, - int render_delay_ms) { - ++decoder_timing_called_; - // TODO(fischman): anything useful to be done with the data here? - } - - virtual void OutgoingRate(const int video_channel, - const unsigned int framerate, - const unsigned int bitrate) { - outgoing_rate_called_++; - last_outgoing_framerate_ += framerate; - last_outgoing_bitrate_ += bitrate; - } - - void SuspendChange(int video_channel, bool is_suspended) override { - suspend_change_called_++; - } - - virtual void RequestNewKeyFrame(const int video_channel) { - } -}; - -class RenderFilter : public webrtc::ViEEffectFilter { - public: - int num_frames_; - unsigned int last_render_width_; - unsigned int last_render_height_; - - RenderFilter() - : num_frames_(0), - last_render_width_(0), - last_render_height_(0) { - } - - virtual ~RenderFilter() { - } - virtual int Transform(size_t size, - unsigned char* frame_buffer, - int64_t ntp_time_ms, - unsigned int timestamp, - unsigned int width, - unsigned int height) { - num_frames_++; - last_render_width_ = width; - last_render_height_ = height; - return 0; - } -}; - -void ViEAutoTest::ViECodecStandardTest() { - TbInterfaces interfaces("ViECodecStandardTest"); - - TbCaptureDevice capture_device = TbCaptureDevice(interfaces); - int capture_id = capture_device.captureId; - - webrtc::VideoEngine* video_engine = interfaces.video_engine; - webrtc::ViEBase* base = interfaces.base; - webrtc::ViECapture* capture = interfaces.capture; - webrtc::ViERender* render = interfaces.render; - webrtc::ViECodec* codec = interfaces.codec; - webrtc::ViERTP_RTCP* rtp_rtcp = interfaces.rtp_rtcp; - webrtc::ViENetwork* network = interfaces.network; - - int video_channel = -1; - EXPECT_EQ(0, base->CreateChannel(video_channel)); - EXPECT_EQ(0, capture->ConnectCaptureDevice(capture_id, video_channel)); - EXPECT_EQ(0, rtp_rtcp->SetRTCPStatus( - video_channel, webrtc::kRtcpCompound_RFC4585)); - - EXPECT_EQ(0, rtp_rtcp->SetKeyFrameRequestMethod( - video_channel, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, rtp_rtcp->SetTMMBRStatus(video_channel, true)); - EXPECT_EQ(0, render->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, 1.0, - 1.0)); - EXPECT_EQ(0, render->AddRenderer(video_channel, _window2, 1, 0.0, 0.0, 1.0, - 1.0)); - EXPECT_EQ(0, render->StartRender(capture_id)); - EXPECT_EQ(0, render->StartRender(video_channel)); - - webrtc::VideoCodec video_codec; - memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); - for (int idx = 0; idx < codec->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, codec->GetCodec(idx, video_codec)); - if (video_codec.codecType != webrtc::kVideoCodecI420) { - video_codec.width = 640; - video_codec.height = 480; - } - if (video_codec.codecType == webrtc::kVideoCodecI420) { - video_codec.width = 176; - video_codec.height = 144; - } - EXPECT_EQ(0, codec->SetReceiveCodec(video_channel, video_codec)); - } - - for (int idx = 0; idx < codec->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, codec->GetCodec(idx, video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecVP8) { - EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); - break; - } - } - const char* ip_address = "127.0.0.1"; - const uint16_t rtp_port = 6000; - - rtc::scoped_ptr video_channel_transport( - new webrtc::test::VideoChannelTransport(network, video_channel)); - - ASSERT_EQ(0, video_channel_transport->SetSendDestination(ip_address, - rtp_port)); - ASSERT_EQ(0, video_channel_transport->SetLocalReceiver(rtp_port)); - - EXPECT_EQ(0, base->StartReceive(video_channel)); - EXPECT_EQ(0, base->StartSend(video_channel)); - - // Make sure all codecs runs - { - webrtc::ViEImageProcess* image_process = - webrtc::ViEImageProcess::GetInterface(video_engine); - TestCodecObserver codec_observer; - EXPECT_EQ(0, codec->RegisterDecoderObserver(video_channel, codec_observer)); - ViETest::Log("Loop through all codecs for %d seconds", - kAutoTestSleepTimeMs / 1000); - - for (int i = 0; i < codec->NumberOfCodecs() - 2; i++) { - EXPECT_EQ(0, codec->GetCodec(i, video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecI420) { - // Lower resolution to sockets keep up. - video_codec.width = 176; - video_codec.height = 144; - video_codec.maxFramerate = 15; - } - EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); - ViETest::Log("\t %d. %s", i, video_codec.plName); - - RenderFilter frame_counter; - EXPECT_EQ(0, image_process->RegisterRenderEffectFilter(video_channel, - frame_counter)); - AutoTestSleep(kAutoTestSleepTimeMs); - - // Verify we've received and decoded correct payload. - EXPECT_EQ(video_codec.codecType, - codec_observer.incoming_codec_.codecType); - - // This requirement is quite relaxed, but it's hard to say what's an - // acceptable number of received frames when we take into account the - // wide variety of devices (and that we run under valgrind). - EXPECT_GT(frame_counter.num_frames_, 0); - - EXPECT_EQ(0, image_process->DeregisterRenderEffectFilter( - video_channel)); - } - image_process->Release(); - EXPECT_EQ(0, codec->DeregisterDecoderObserver(video_channel)); - ViETest::Log("Done!"); - } - - // Test Callbacks - TestCodecObserver codec_observer; - EXPECT_EQ(0, codec->RegisterEncoderObserver(video_channel, codec_observer)); - EXPECT_EQ(0, codec->RegisterDecoderObserver(video_channel, codec_observer)); - - ViETest::Log("\nTesting codec callbacks..."); - - for (int idx = 0; idx < codec->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, codec->GetCodec(idx, video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecVP8) { - EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); - break; - } - } - AutoTestSleep(kAutoTestSleepTimeMs); - - // Verify the delay estimates are larger than 0. - int avg_send_delay = 0; - int max_send_delay = 0; - EXPECT_TRUE(codec->GetSendSideDelay(video_channel, &avg_send_delay, - &max_send_delay)); - EXPECT_GT(avg_send_delay, 0); - EXPECT_GE(max_send_delay, avg_send_delay); - int receive_delay_ms = 0; - EXPECT_EQ(0, codec->GetReceiveSideDelay(video_channel, &receive_delay_ms)); - EXPECT_GT(receive_delay_ms, 0); - - EXPECT_EQ(0, base->StopSend(video_channel)); - EXPECT_EQ(0, codec->DeregisterEncoderObserver(video_channel)); - EXPECT_EQ(0, codec->DeregisterDecoderObserver(video_channel)); - - EXPECT_GT(codec_observer.incoming_codec_called_, 0); - EXPECT_GT(codec_observer.incoming_rate_called_, 0); - EXPECT_GT(codec_observer.decoder_timing_called_, 0); - EXPECT_GT(codec_observer.outgoing_rate_called_, 0); - - EXPECT_EQ(0, base->StopReceive(video_channel)); - EXPECT_EQ(0, render->StopRender(video_channel)); - EXPECT_EQ(0, render->RemoveRenderer(capture_id)); - EXPECT_EQ(0, render->RemoveRenderer(video_channel)); - EXPECT_EQ(0, capture->DisconnectCaptureDevice(video_channel)); - EXPECT_EQ(0, base->DeleteChannel(video_channel)); -} - -void ViEAutoTest::ViECodecExtendedTest() { - { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViECodec Extended Test\n"); - - ViECodecExternalCodecTest(); - - TbInterfaces interfaces("ViECodecExtendedTest"); - webrtc::ViEBase* base = interfaces.base; - webrtc::ViECapture* capture = interfaces.capture; - webrtc::ViERender* render = interfaces.render; - webrtc::ViECodec* codec = interfaces.codec; - webrtc::ViERTP_RTCP* rtp_rtcp = interfaces.rtp_rtcp; - webrtc::ViENetwork* network = interfaces.network; - - TbCaptureDevice capture_device = TbCaptureDevice(interfaces); - int capture_id = capture_device.captureId; - - int video_channel = -1; - EXPECT_EQ(0, base->CreateChannel(video_channel)); - EXPECT_EQ(0, capture->ConnectCaptureDevice(capture_id, video_channel)); - EXPECT_EQ(0, rtp_rtcp->SetRTCPStatus( - video_channel, webrtc::kRtcpCompound_RFC4585)); - EXPECT_EQ(0, rtp_rtcp->SetKeyFrameRequestMethod( - video_channel, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, rtp_rtcp->SetTMMBRStatus(video_channel, true)); - EXPECT_EQ(0, render->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, 1.0, - 1.0)); - - EXPECT_EQ(0, render->AddRenderer(video_channel, _window2, 1, 0.0, 0.0, 1.0, - 1.0)); - EXPECT_EQ(0, render->StartRender(capture_id)); - EXPECT_EQ(0, render->StartRender(video_channel)); - - webrtc::VideoCodec video_codec; - memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); - for (int idx = 0; idx < codec->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, codec->GetCodec(idx, video_codec)); - if (video_codec.codecType != webrtc::kVideoCodecI420) { - video_codec.width = 640; - video_codec.height = 480; - } - EXPECT_EQ(0, codec->SetReceiveCodec(video_channel, video_codec)); - } - - const char* ip_address = "127.0.0.1"; - const uint16_t rtp_port = 6000; - - rtc::scoped_ptr - video_channel_transport( - new webrtc::test::VideoChannelTransport(network, video_channel)); - - ASSERT_EQ(0, video_channel_transport->SetSendDestination(ip_address, - rtp_port)); - ASSERT_EQ(0, video_channel_transport->SetLocalReceiver(rtp_port)); - - EXPECT_EQ(0, base->StartSend(video_channel)); - EXPECT_EQ(0, base->StartReceive(video_channel)); - - // Codec specific tests - memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); - EXPECT_EQ(0, base->StopSend(video_channel)); - - TestCodecObserver codec_observer; - EXPECT_EQ(0, codec->RegisterEncoderObserver(video_channel, codec_observer)); - EXPECT_EQ(0, codec->RegisterDecoderObserver(video_channel, codec_observer)); - EXPECT_EQ(0, base->StopReceive(video_channel)); - - EXPECT_EQ(0, render->StopRender(video_channel)); - EXPECT_EQ(0, render->RemoveRenderer(capture_id)); - EXPECT_EQ(0, render->RemoveRenderer(video_channel)); - EXPECT_EQ(0, capture->DisconnectCaptureDevice(video_channel)); - EXPECT_EQ(0, base->DeleteChannel(video_channel)); - } - - // Multiple send channels. - { - // Create two channels, where the second channel is created from the - // first channel. Send different resolutions on the channels and verify - // the received streams. - TbInterfaces video_engine("ViECodecExtendedTest2"); - TbCaptureDevice tb_capture(video_engine); - webrtc::ViENetwork* network = video_engine.network; - - // Create channel 1. - int video_channel_1 = -1; - EXPECT_EQ(0, video_engine.base->CreateChannel(video_channel_1)); - - // Create channel 2 based on the first channel. - int video_channel_2 = -1; - EXPECT_EQ(0, video_engine.base->CreateChannel( - video_channel_2, video_channel_1)); - EXPECT_NE(video_channel_1, video_channel_2) - << "Channel 2 should be unique."; - - const char* ip_address = "127.0.0.1"; - uint16_t rtp_port_1 = 12000; - uint16_t rtp_port_2 = 13000; - - rtc::scoped_ptr - video_channel_transport_1( - new webrtc::test::VideoChannelTransport(network, video_channel_1)); - - ASSERT_EQ(0, video_channel_transport_1->SetSendDestination(ip_address, - rtp_port_1)); - ASSERT_EQ(0, video_channel_transport_1->SetLocalReceiver(rtp_port_1)); - - rtc::scoped_ptr - video_channel_transport_2( - new webrtc::test::VideoChannelTransport(network, video_channel_2)); - - ASSERT_EQ(0, video_channel_transport_2->SetSendDestination(ip_address, - rtp_port_2)); - ASSERT_EQ(0, video_channel_transport_2->SetLocalReceiver(rtp_port_2)); - - EXPECT_EQ(0, video_engine.rtp_rtcp->SetLocalSSRC(video_channel_1, 1)); - EXPECT_EQ(0, video_engine.rtp_rtcp->SetLocalSSRC(video_channel_2, 2)); - tb_capture.ConnectTo(video_channel_1); - tb_capture.ConnectTo(video_channel_2); - EXPECT_EQ(0, video_engine.rtp_rtcp->SetKeyFrameRequestMethod( - video_channel_1, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, video_engine.rtp_rtcp->SetKeyFrameRequestMethod( - video_channel_2, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, video_engine.render->AddRenderer(video_channel_1, _window1, 0, - 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, video_engine.render->StartRender(video_channel_1)); - EXPECT_EQ(0, video_engine.render->AddRenderer(video_channel_2, _window2, 0, - 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, video_engine.render->StartRender(video_channel_2)); - - // Set Send codec. - uint16_t codec_width = 320; - uint16_t codec_height = 240; - bool codec_set = false; - webrtc::VideoCodec video_codec; - webrtc::VideoCodec send_codec1; - webrtc::VideoCodec send_codec2; - for (int idx = 0; idx < video_engine.codec->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, video_engine.codec->GetCodec(idx, video_codec)); - EXPECT_EQ(0, video_engine.codec->SetReceiveCodec(video_channel_1, - video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecVP8) { - memcpy(&send_codec1, &video_codec, sizeof(video_codec)); - send_codec1.width = codec_width; - send_codec1.height = codec_height; - EXPECT_EQ(0, video_engine.codec->SetSendCodec( - video_channel_1, send_codec1)); - memcpy(&send_codec2, &video_codec, sizeof(video_codec)); - send_codec2.width = 2 * codec_width; - send_codec2.height = 2 * codec_height; - EXPECT_EQ(0, video_engine.codec->SetSendCodec( - video_channel_2, send_codec2)); - codec_set = true; - break; - } - } - EXPECT_TRUE(codec_set); - - // We need to verify using render effect filter since we won't trigger - // a decode reset in loopback (due to using the same SSRC). - RenderFilter filter1; - RenderFilter filter2; - EXPECT_EQ(0, video_engine.image_process->RegisterRenderEffectFilter( - video_channel_1, filter1)); - EXPECT_EQ(0, video_engine.image_process->RegisterRenderEffectFilter( - video_channel_2, filter2)); - - EXPECT_EQ(0, video_engine.base->StartReceive(video_channel_1)); - EXPECT_EQ(0, video_engine.base->StartSend(video_channel_1)); - EXPECT_EQ(0, video_engine.base->StartReceive(video_channel_2)); - EXPECT_EQ(0, video_engine.base->StartSend(video_channel_2)); - - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, video_engine.base->StopReceive(video_channel_1)); - EXPECT_EQ(0, video_engine.base->StopSend(video_channel_1)); - EXPECT_EQ(0, video_engine.base->StopReceive(video_channel_2)); - EXPECT_EQ(0, video_engine.base->StopSend(video_channel_2)); - - EXPECT_EQ(0, video_engine.image_process->DeregisterRenderEffectFilter( - video_channel_1)); - EXPECT_EQ(0, video_engine.image_process->DeregisterRenderEffectFilter( - video_channel_2)); - EXPECT_EQ(send_codec1.width, filter1.last_render_width_); - EXPECT_EQ(send_codec1.height, filter1.last_render_height_); - EXPECT_EQ(send_codec2.width, filter2.last_render_width_); - EXPECT_EQ(send_codec2.height, filter2.last_render_height_); - - EXPECT_EQ(0, video_engine.base->DeleteChannel(video_channel_1)); - EXPECT_EQ(0, video_engine.base->DeleteChannel(video_channel_2)); - } -} - -void ViEAutoTest::ViECodecAPITest() { - webrtc::VideoEngine* video_engine = NULL; - video_engine = webrtc::VideoEngine::Create(); - EXPECT_TRUE(video_engine != NULL); - - webrtc::ViEBase* base = webrtc::ViEBase::GetInterface(video_engine); - EXPECT_EQ(0, base->Init()); - - int video_channel = -1; - EXPECT_EQ(0, base->CreateChannel(video_channel)); - - webrtc::ViECodec* codec = webrtc::ViECodec::GetInterface(video_engine); - EXPECT_TRUE(codec != NULL); - - webrtc::VideoCodec video_codec; - memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); - - const int number_of_codecs = codec->NumberOfCodecs(); - - for (int i = 0; i < number_of_codecs; i++) { - EXPECT_EQ(0, codec->GetCodec(i, video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecVP8) { - video_codec.codecSpecific.VP8.automaticResizeOn = true; - video_codec.codecSpecific.VP8.frameDroppingOn = true; - video_codec.codecSpecific.VP8.keyFrameInterval = 300; - EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); - break; - } - } - const unsigned int kMinBitrate = 123; - video_codec.minBitrate = kMinBitrate; - video_codec.startBitrate = 50; - EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); - EXPECT_EQ(0, codec->GetSendCodec(video_channel, video_codec)); - // We don't allow allocated start bitrate to be decreased via SetSendCodec, - // and the default bitrate available in the allocator is 300. - EXPECT_EQ(300u, video_codec.startBitrate); - - memset(&video_codec, 0, sizeof(video_codec)); - EXPECT_EQ(0, codec->GetSendCodec(video_channel, video_codec)); - EXPECT_EQ(webrtc::kVideoCodecVP8, video_codec.codecType); - EXPECT_TRUE(video_codec.codecSpecific.VP8.automaticResizeOn); - EXPECT_TRUE(video_codec.codecSpecific.VP8.frameDroppingOn); - EXPECT_EQ(300, video_codec.codecSpecific.VP8.keyFrameInterval); - - for (int i = 0; i < number_of_codecs; i++) { - EXPECT_EQ(0, codec->GetCodec(i, video_codec)); - if (video_codec.codecType == webrtc::kVideoCodecI420) { - EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); - break; - } - } - - memset(&video_codec, 0, sizeof(video_codec)); - EXPECT_EQ(0, codec->GetSendCodec(video_channel, video_codec)); - EXPECT_EQ(webrtc::kVideoCodecI420, video_codec.codecType); - - // Register a generic codec - memset(&video_codec, 0, sizeof(video_codec)); - video_codec.codecType = webrtc::kVideoCodecGeneric; - strcpy(video_codec.plName, "generic-codec"); - uint8_t payload_type = 127; - video_codec.plType = payload_type; - video_codec.minBitrate = 100; - video_codec.startBitrate = 500; - video_codec.maxBitrate = 10000; - video_codec.width = 1920; - video_codec.height = 1080; - video_codec.maxFramerate = 30; - video_codec.qpMax = 50; - - webrtc::ViEExternalCodec* external_codec = - webrtc::ViEExternalCodec::GetInterface(video_engine); - EXPECT_TRUE(external_codec != NULL); - - // Any encoder will do. - webrtc::I420Encoder encoder; - EXPECT_EQ(0, external_codec->RegisterExternalSendCodec(video_channel, - payload_type, &encoder, - false)); - EXPECT_EQ(0, codec->SetSendCodec(video_channel, video_codec)); - - memset(&video_codec, 0, sizeof(video_codec)); - EXPECT_EQ(0, codec->GetSendCodec(video_channel, video_codec)); - EXPECT_EQ(webrtc::kVideoCodecGeneric, video_codec.codecType); - - EXPECT_EQ(0, base->DeleteChannel(video_channel)); - - EXPECT_EQ(0, external_codec->Release()); - EXPECT_EQ(0, codec->Release()); - EXPECT_EQ(0, base->Release()); - EXPECT_TRUE(webrtc::VideoEngine::Delete(video_engine)); -} - -void ViEAutoTest::ViECodecExternalCodecTest() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViEExternalCodec Test\n"); - - /// ************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - /// ************************************************************** - - /// ************************************************************** - // Engine ready. Begin testing class - /// ************************************************************** - -#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - int number_of_errors = 0; - { - int error = 0; - TbInterfaces ViE("ViEExternalCodec"); - TbCaptureDevice capture_device(ViE); - TbVideoChannel channel(ViE, webrtc::kVideoCodecI420, 352, 288, 30, - (352 * 288 * 3 * 8 * 30) / (2 * 1000)); - capture_device.ConnectTo(channel.videoChannel); - - error = ViE.render->AddRenderer(channel.videoChannel, _window1, 0, 0.0, 0.0, - 1.0, 1.0); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = ViE.render->StartRender(channel.videoChannel); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - channel.StartReceive(); - channel.StartSend(); - - ViETest::Log("Using internal I420 codec"); - AutoTestSleep(kAutoTestSleepTimeMs / 2); - - webrtc::ViEExternalCodec* vie_external_codec = - webrtc::ViEExternalCodec::GetInterface(ViE.video_engine); - number_of_errors += ViETest::TestError(vie_external_codec != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - webrtc::VideoCodec codec; - error = ViE.codec->GetSendCodec(channel.videoChannel, codec); - number_of_errors += ViETest::TestError(vie_external_codec != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Use external encoder instead. - { - TbI420Encoder ext_encoder; - - // Test to register on wrong channel. - error = vie_external_codec->RegisterExternalSendCodec( - channel.videoChannel + 5, codec.plType, &ext_encoder, false); - number_of_errors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - ViE.LastError() == kViECodecInvalidArgument, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - - error = vie_external_codec->RegisterExternalSendCodec( - channel.videoChannel, codec.plType, &ext_encoder, false); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Use new external encoder - error = ViE.codec->SetSendCodec(channel.videoChannel, codec); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - TbI420Decoder ext_decoder; - error = vie_external_codec->RegisterExternalReceiveCodec( - channel.videoChannel, codec.plType, &ext_decoder); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.codec->SetReceiveCodec(channel.videoChannel, codec); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - ViETest::Log("Using external I420 codec"); - AutoTestSleep(kAutoTestSleepTimeMs); - - // Test to deregister on wrong channel - error = vie_external_codec->DeRegisterExternalSendCodec( - channel.videoChannel + 5, codec.plType); - number_of_errors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - ViE.LastError() == kViECodecInvalidArgument, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Test to deregister wrong payload type. - error = vie_external_codec->DeRegisterExternalSendCodec( - channel.videoChannel, codec.plType - 1); - number_of_errors += ViETest::TestError(error == -1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Deregister external send codec - error = vie_external_codec->DeRegisterExternalSendCodec( - channel.videoChannel, codec.plType); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_external_codec->DeRegisterExternalReceiveCodec( - channel.videoChannel, codec.plType); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Verify that the encoder and decoder has been used - TbI420Encoder::FunctionCalls encode_calls = - ext_encoder.GetFunctionCalls(); - number_of_errors += ViETest::TestError(encode_calls.InitEncode == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(encode_calls.Release == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(encode_calls.Encode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - encode_calls.RegisterEncodeCompleteCallback == 1, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - encode_calls.SetChannelParameters > 1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(encode_calls.SetRates > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - TbI420Decoder::FunctionCalls decode_calls = - ext_decoder.GetFunctionCalls(); - number_of_errors += ViETest::TestError(decode_calls.InitDecode == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(decode_calls.Release == 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(decode_calls.Decode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - decode_calls.RegisterDecodeCompleteCallback == 1, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - - ViETest::Log("Changing payload type Using external I420 codec"); - - codec.plType = codec.plType - 1; - error = vie_external_codec->RegisterExternalReceiveCodec( - channel.videoChannel, codec.plType, &ext_decoder); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = ViE.codec->SetReceiveCodec(channel.videoChannel, - codec); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_external_codec->RegisterExternalSendCodec( - channel.videoChannel, codec.plType, &ext_encoder, false); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Use new external encoder - error = ViE.codec->SetSendCodec(channel.videoChannel, - codec); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - AutoTestSleep(kAutoTestSleepTimeMs / 2); - - /// ************************************************************** - // Testing finished. Tear down Video Engine - /// ************************************************************** - - error = vie_external_codec->DeRegisterExternalSendCodec( - channel.videoChannel, codec.plType); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_external_codec->DeRegisterExternalReceiveCodec( - channel.videoChannel, codec.plType); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Verify that the encoder and decoder has been used - encode_calls = ext_encoder.GetFunctionCalls(); - number_of_errors += ViETest::TestError(encode_calls.InitEncode == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(encode_calls.Release == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(encode_calls.Encode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - encode_calls.RegisterEncodeCompleteCallback == 2, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - encode_calls.SetChannelParameters > 1, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(encode_calls.SetRates > 1, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - decode_calls = ext_decoder.GetFunctionCalls(); - number_of_errors += ViETest::TestError(decode_calls.InitDecode == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(decode_calls.Release == 2, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError(decode_calls.Decode > 30, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - number_of_errors += ViETest::TestError( - decode_calls.RegisterDecodeCompleteCallback == 2, - "ERROR: %s at line %d", __FUNCTION__, __LINE__); - - int remaining_interfaces = vie_external_codec->Release(); - number_of_errors += ViETest::TestError(remaining_interfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } // tbI420Encoder and ext_decoder goes out of scope. - - ViETest::Log("Using internal I420 codec"); - AutoTestSleep(kAutoTestSleepTimeMs / 2); - } - if (number_of_errors > 0) { - // Test failed - ViETest::Log(" "); - ViETest::Log(" ERROR ViEExternalCodec Test FAILED!"); - ViETest::Log(" Number of errors: %d", number_of_errors); - ViETest::Log("========================================"); - ViETest::Log(" "); - return; - } - - ViETest::Log(" "); - ViETest::Log(" ViEExternalCodec Test PASSED!"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return; - -#else - ViETest::Log(" ViEExternalCodec not enabled\n"); - return; -#endif -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_custom_call.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_custom_call.cc deleted file mode 100644 index dd4eae5a30..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_custom_call.cc +++ /dev/null @@ -1,1698 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include -#include -#include - -#include - -#include "gflags/gflags.h" -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/primitives/choice_helpers.h" -#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h" -#include "webrtc/video_engine/test/auto_test/primitives/input_helpers.h" -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" -#include "webrtc/voice_engine/include/voe_network.h" - -#define VCM_RED_PAYLOAD_TYPE 96 -#define VCM_ULPFEC_PAYLOAD_TYPE 97 -#define DEFAULT_SEND_IP "127.0.0.1" -#define DEFAULT_VIDEO_PORT "11111" -#define DEFAULT_VIDEO_CODEC "VP8" -#define DEFAULT_VIDEO_CODEC_WIDTH "640" -#define DEFAULT_VIDEO_CODEC_HEIGHT "480" -#define DEFAULT_VIDEO_CODEC_BITRATE "300" -#define DEFAULT_VIDEO_CODEC_MIN_BITRATE "100" -#define DEFAULT_VIDEO_CODEC_MAX_BITRATE "1000" -#define DEFAULT_AUDIO_PORT "11113" -#define DEFAULT_AUDIO_CODEC "ISAC" -#define DEFAULT_VIDEO_CODEC_MAX_FRAMERATE "30" -#define DEFAULT_VIDEO_PROTECTION_METHOD "None" -#define DEFAULT_TEMPORAL_LAYER "0" -#define DEFAULT_BUFFERING_DELAY_MS "0" - -DEFINE_string(render_custom_call_remote_to, "", "Specify to render the remote " - "stream of a custom call to the provided filename instead of showing it in " - "window 2. The file will end up in the default output directory (out/)."); - -enum StatisticsType { - kSendStatistic, - kReceivedStatistic -}; - -enum VideoProtectionMethod { - kProtectionMethodNone = 1, - kProtectionMethodFecOnly, - kProtectionMethodNackOnly, - kProtectionMethodHybridNackAndFec, -}; - -using webrtc::FromChoices; -using webrtc::TypedInput; - -class ViEAutotestEncoderObserver : public webrtc::ViEEncoderObserver { - public: - ViEAutotestEncoderObserver() {} - ~ViEAutotestEncoderObserver() {} - - void OutgoingRate(const int video_channel, - const unsigned int framerate, - const unsigned int bitrate) { - std::cout << "Send FR: " << framerate - << " BR: " << bitrate << std::endl; - } - - void SuspendChange(int video_channel, bool is_suspended) override { - std::cout << "SuspendChange: " << is_suspended << std::endl; - } -}; - -class ViEAutotestDecoderObserver : public webrtc::ViEDecoderObserver { - public: - ViEAutotestDecoderObserver() {} - ~ViEAutotestDecoderObserver() {} - - void IncomingRate(const int video_channel, - const unsigned int framerate, - const unsigned int bitrate) { - std::cout << "Received FR: " << framerate - << " BR: " << bitrate << std::endl; - } - - virtual void DecoderTiming(int decode_ms, - int max_decode_ms, - int current_delay_ms, - int target_delay_ms, - int jitter_buffer_ms, - int min_playout_delay_ms, - int render_delay_ms) { - std::cout << "Decoder timing: DecodeMS: " << decode_ms - << ", MaxDecodeMS: " << max_decode_ms - << ", CurrentDelayMS: " << current_delay_ms - << ", TargetDelayMS: " << target_delay_ms - << ", JitterBufferMS: " << jitter_buffer_ms - << ", MinPlayoutDelayMS: " << min_playout_delay_ms - << ", RenderDelayMS: " << render_delay_ms; - } - - void IncomingCodecChanged(const int video_channel, - const webrtc::VideoCodec& codec) {} - void RequestNewKeyFrame(const int video_channel) { - std::cout << "Decoder requesting a new key frame." << std::endl; - } -}; - -// The following are general helper functions. -bool GetVideoDevice(webrtc::ViEBase* vie_base, - webrtc::ViECapture* vie_capture, - char* capture_device_name, char* capture_device_unique_id); -std::string GetIPAddress(); -bool ValidateIP(std::string i_str); - -// The following are Print to stdout functions. -void PrintCallInformation(const char* IP, - const char* video_capture_device_name, - const char* video_capture_unique_id, - webrtc::VideoCodec video_codec, - int video_tx_port, - int video_rx_port, - const char* audio_capture_device_name, - const char* audio_playbackDeviceName, - webrtc::CodecInst audio_codec, - int audio_tx_port, - int audio_rx_port, - int protection_method); -void PrintRTCCPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel, - StatisticsType stat_type); -void PrintRTPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel); -void PrintBandwidthUsage(webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel); -void PrintCodecStatistics(webrtc::ViECodec* vie_codec, - int video_channel, - StatisticsType stat_type); -void PrintGetDiscardedPackets(webrtc::ViECodec* vie_codec, - int video_channel); -void PrintVideoStreamInformation(webrtc::ViECodec* vie_codec, - int video_channel); -void PrintVideoCodec(webrtc::VideoCodec video_codec); - -// The following are video functions. -void GetVideoPorts(int* tx_port, int* rx_port); -void SetVideoCodecType(webrtc::ViECodec* vie_codec, - webrtc::VideoCodec* video_codec); -void SetVideoCodecResolution(webrtc::VideoCodec* video_codec); -void SetVideoCodecSize(webrtc::VideoCodec* video_codec); -void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec); -void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec); -void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec); -void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec); -void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec); -VideoProtectionMethod GetVideoProtection(); -bool SetVideoProtection(webrtc::ViECodec* vie_codec, - webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel, - VideoProtectionMethod protection_method); -bool GetBitrateSignaling(); -int GetBufferingDelay(); - -// The following are audio helper functions. -bool GetAudioDevices(webrtc::VoEBase* voe_base, - webrtc::VoEHardware* voe_hardware, - char* recording_device_name, int& recording_device_index, - char* playback_device_name, int& playback_device_index); -bool GetAudioDevices(webrtc::VoEBase* voe_base, - webrtc::VoEHardware* voe_hardware, - int& recording_device_index, int& playback_device_index); -void GetAudioPorts(int* tx_port, int* rx_port); -bool GetAudioCodec(webrtc::VoECodec* voe_codec, - webrtc::CodecInst& audio_codec); - -int ViEAutoTest::ViECustomCall() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" Enter values to use custom settings\n"); - - int error = 0; - int number_of_errors = 0; - std::string str; - - // Create the VoE and get the VoE interfaces. - webrtc::VoiceEngine* voe = webrtc::VoiceEngine::Create(); - number_of_errors += ViETest::TestError(voe != NULL, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - webrtc::VoEBase* voe_base = webrtc::VoEBase::GetInterface(voe); - number_of_errors += ViETest::TestError(voe_base != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - error = voe_base->Init(); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - webrtc::VoECodec* voe_codec = webrtc::VoECodec::GetInterface(voe); - number_of_errors += ViETest::TestError(voe_codec != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - webrtc::VoEHardware* voe_hardware = - webrtc::VoEHardware::GetInterface(voe); - number_of_errors += ViETest::TestError(voe_hardware != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - webrtc::VoENetwork* voe_network= - webrtc::VoENetwork::GetInterface(voe); - number_of_errors += ViETest::TestError(voe_network != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - webrtc::VoEAudioProcessing* voe_apm = - webrtc::VoEAudioProcessing::GetInterface(voe); - number_of_errors += ViETest::TestError(voe_apm != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - // Create the ViE and get the ViE Interfaces. - webrtc::VideoEngine* vie = webrtc::VideoEngine::Create(); - number_of_errors += ViETest::TestError(vie != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - webrtc::ViEBase* vie_base = webrtc::ViEBase::GetInterface(vie); - number_of_errors += ViETest::TestError(vie_base != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - error = vie_base->Init(); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - webrtc::ViECapture* vie_capture = - webrtc::ViECapture::GetInterface(vie); - number_of_errors += ViETest::TestError(vie_capture != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - webrtc::ViERender* vie_renderer = webrtc::ViERender::GetInterface(vie); - number_of_errors += ViETest::TestError(vie_renderer != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - webrtc::ViECodec* vie_codec = webrtc::ViECodec::GetInterface(vie); - number_of_errors += ViETest::TestError(vie_codec != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - webrtc::ViENetwork* vie_network = webrtc::ViENetwork::GetInterface(vie); - number_of_errors += ViETest::TestError(vie_network != NULL, - "ERROR: %s at line %d", __FUNCTION__, - __LINE__); - - bool start_call = false; - std::string ip_address; - const unsigned int KMaxUniqueIdLength = 256; - char unique_id[KMaxUniqueIdLength] = ""; - char device_name[KMaxUniqueIdLength] = ""; - int video_tx_port = 0; - int video_rx_port = 0; - int video_channel = -1; - webrtc::VideoCodec video_send_codec; - char audio_capture_device_name[KMaxUniqueIdLength] = ""; - char audio_playbackDeviceName[KMaxUniqueIdLength] = ""; - int audio_capture_device_index = -1; - int audio_playback_device_index = -1; - int audio_tx_port = 0; - int audio_rx_port = 0; - webrtc::CodecInst audio_codec; - int audio_channel = -1; - VideoProtectionMethod protection_method = kProtectionMethodNone; - int buffer_delay_ms = 0; - bool is_image_scale_enabled = false; - bool remb = true; - rtc::scoped_ptr video_channel_transport; - rtc::scoped_ptr voice_channel_transport; - - while (!start_call) { - // Get the IP address to use from call. - ip_address = GetIPAddress(); - - // Get the video device to use for call. - memset(device_name, 0, KMaxUniqueIdLength); - memset(unique_id, 0, KMaxUniqueIdLength); - if (!GetVideoDevice(vie_base, vie_capture, device_name, unique_id)) - return number_of_errors; - - // Get and set the video ports for the call. - video_tx_port = 0; - video_rx_port = 0; - GetVideoPorts(&video_tx_port, &video_rx_port); - - // Get and set the video codec parameters for the call. - memset(&video_send_codec, 0, sizeof(webrtc::VideoCodec)); - SetVideoCodecType(vie_codec, &video_send_codec); - SetVideoCodecSize(&video_send_codec); - SetVideoCodecBitrate(&video_send_codec); - SetVideoCodecMinBitrate(&video_send_codec); - SetVideoCodecMaxBitrate(&video_send_codec); - SetVideoCodecMaxFramerate(&video_send_codec); - SetVideoCodecTemporalLayer(&video_send_codec); - remb = GetBitrateSignaling(); - - // Get the video protection method for the call. - protection_method = GetVideoProtection(); - - // Get the call mode (Real-Time/Buffered). - buffer_delay_ms = GetBufferingDelay(); - - // Get the audio device for the call. - memset(audio_capture_device_name, 0, KMaxUniqueIdLength); - memset(audio_playbackDeviceName, 0, KMaxUniqueIdLength); - GetAudioDevices(voe_base, voe_hardware, audio_capture_device_name, - audio_capture_device_index, audio_playbackDeviceName, - audio_playback_device_index); - - // Get the audio port for the call. - audio_tx_port = 0; - audio_rx_port = 0; - GetAudioPorts(&audio_tx_port, &audio_rx_port); - - // Get the audio codec for the call. - memset(static_cast(&audio_codec), 0, sizeof(audio_codec)); - GetAudioCodec(voe_codec, audio_codec); - - // Now ready to start the call. Check user wants to continue. - PrintCallInformation(ip_address.c_str(), device_name, unique_id, - video_send_codec, video_tx_port, video_rx_port, - audio_capture_device_name, audio_playbackDeviceName, - audio_codec, audio_tx_port, audio_rx_port, - protection_method); - - printf("\n"); - int selection = - FromChoices("Ready to start:", - "Start the call\n" - "Reconfigure call settings\n") - .WithDefault("Start the call").Choose(); - start_call = (selection == 1); - } - /// ************************************************************** - // Begin create/initialize WebRTC Video Engine for testing. - /// ************************************************************** - if (start_call == true) { - // Configure audio channel first. - audio_channel = voe_base->CreateChannel(); - - voice_channel_transport.reset( - new webrtc::test::VoiceChannelTransport(voe_network, audio_channel)); - - error = voice_channel_transport->SetSendDestination(ip_address.c_str(), - audio_tx_port); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voice_channel_transport->SetLocalReceiver(audio_rx_port); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_hardware->SetRecordingDevice(audio_capture_device_index); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_hardware->SetPlayoutDevice(audio_playback_device_index); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_codec->SetSendCodec(audio_channel, audio_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_apm->SetAgcStatus(true, webrtc::kAgcDefault); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_apm->SetNsStatus(true, webrtc::kNsHighSuppression); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Now configure the video channel. - error = vie->SetTraceFilter(webrtc::kTraceAll); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - std::string trace_file = - ViETest::GetResultOutputPath() + "ViECustomCall_trace.txt"; - error = vie->SetTraceFile(trace_file.c_str()); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_base->SetVoiceEngine(voe); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_base->CreateChannel(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_base->ConnectAudioChannel(video_channel, audio_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - int capture_id = 0; - error = vie_capture->AllocateCaptureDevice(unique_id, - KMaxUniqueIdLength, - capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_capture->ConnectCaptureDevice(capture_id, video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_capture->StartCapture(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - webrtc::ViERTP_RTCP* vie_rtp_rtcp = - webrtc::ViERTP_RTCP::GetInterface(vie); - number_of_errors += ViETest::TestError(vie != NULL, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_rtp_rtcp->SetRTCPStatus(video_channel, - webrtc::kRtcpCompound_RFC4585); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_rtp_rtcp->SetKeyFrameRequestMethod( - video_channel, webrtc::kViEKeyFrameRequestPliRtcp); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - if (remb) { - error = vie_rtp_rtcp->SetRembStatus(video_channel, true, true); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } else { - error = vie_rtp_rtcp->SetTMMBRStatus(video_channel, true); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } - - error = vie_renderer->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, 1.0, - 1.0); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - - ViEToFileRenderer file_renderer; - if (FLAGS_render_custom_call_remote_to == "") { - error = vie_renderer->AddRenderer(video_channel, _window2, 1, 0.0, 0.0, - 1.0, 1.0); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } else { - std::string output_path = ViETest::GetResultOutputPath(); - std::string filename = FLAGS_render_custom_call_remote_to; - ViETest::Log("Rendering remote stream to %s: you will not see any output " - "in the second window.", (output_path + filename).c_str()); - - file_renderer.PrepareForRendering(output_path, filename); - RenderToFile(vie_renderer, video_channel, &file_renderer); - } - - video_channel_transport.reset( - new webrtc::test::VideoChannelTransport(vie_network, video_channel)); - - error = video_channel_transport->SetSendDestination(ip_address.c_str(), - video_tx_port); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = video_channel_transport->SetLocalReceiver(video_rx_port); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_codec->SetSendCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Set the call mode (conferencing/buffering) - error = vie_rtp_rtcp->SetSenderBufferingMode(video_channel, - buffer_delay_ms); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_rtp_rtcp->SetReceiverBufferingMode(video_channel, - buffer_delay_ms); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Set the Video Protection before start send and receive. - SetVideoProtection(vie_codec, vie_rtp_rtcp, - video_channel, protection_method); - - // Start Voice Playout and Receive. - error = voe_base->StartReceive(audio_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_base->StartPlayout(audio_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_base->StartSend(audio_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Now start the Video Send & Receive. - error = vie_base->StartSend(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_base->StartReceive(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_renderer->StartRender(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_renderer->StartRender(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - ViEAutotestEncoderObserver* codec_encoder_observer = NULL; - ViEAutotestDecoderObserver* codec_decoder_observer = NULL; - - // Engine ready, wait for input. - - // Call started. - std::cout << std::endl; - std::cout << "Custom call started" << std::endl; - - // Modify call or stop call. - printf("\n"); - int selection = FromChoices( - "And now?", - "Stop the call\n" - "Modify the call\n" - "Keep the call running indefinitely\n") - .WithDefault("Keep the call running indefinitely").Choose(); - if (selection == 3) { - AutoTestSleep(std::numeric_limits::max()); - } - - while (selection == 2) { - // Keep on modifying the call until user stops the call. - int modify_selection = FromChoices( - "Modify the call:", - "Stop call\n" - "Change Video Send Codec\n" - "Change Video Send Size by Common Resolutions\n" - "Change Video Send Size by Width & Height\n" - "Change Video Capture Device\n" - "Change Video Protection Method\n" - "Toggle Encoder Observer\n" - "Toggle Decoder Observer\n" - "Print Call Information\n" - "Print Call Statistics\n" - "Toggle Image Scaling (Warning: high CPU usage when enabled)\n") - .WithDefault("Stop call") - .Choose(); - - switch (modify_selection) { - case 1: - selection = 1; - break; - case 2: - // Change video codec. - SetVideoCodecType(vie_codec, &video_send_codec); - SetVideoCodecSize(&video_send_codec); - SetVideoCodecBitrate(&video_send_codec); - SetVideoCodecMinBitrate(&video_send_codec); - SetVideoCodecMaxBitrate(&video_send_codec); - SetVideoCodecMaxFramerate(&video_send_codec); - SetVideoCodecTemporalLayer(&video_send_codec); - PrintCallInformation(ip_address.c_str(), device_name, - unique_id, video_send_codec, - video_tx_port, video_rx_port, - audio_capture_device_name, - audio_playbackDeviceName, audio_codec, - audio_tx_port, audio_rx_port, protection_method); - error = vie_codec->SetSendCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case 3: - // Change Video codec size by common resolution. - SetVideoCodecResolution(&video_send_codec); - PrintCallInformation(ip_address.c_str(), device_name, - unique_id, video_send_codec, - video_tx_port, video_rx_port, - audio_capture_device_name, - audio_playbackDeviceName, audio_codec, - audio_tx_port, audio_rx_port, protection_method); - error = vie_codec->SetSendCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case 4: - // Change video codec by size height and width. - SetVideoCodecSize(&video_send_codec); - PrintCallInformation(ip_address.c_str(), device_name, - unique_id, video_send_codec, - video_tx_port, video_rx_port, - audio_capture_device_name, - audio_playbackDeviceName, audio_codec, - audio_tx_port, audio_rx_port, protection_method); - error = vie_codec->SetSendCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_codec->SetReceiveCodec(video_channel, video_send_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case 5: - error = vie_renderer->StopRender(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_renderer->RemoveRenderer(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_capture->StopCapture(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_capture->DisconnectCaptureDevice(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_capture->ReleaseCaptureDevice(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - memset(device_name, 0, KMaxUniqueIdLength); - memset(unique_id, 0, KMaxUniqueIdLength); - if (!GetVideoDevice(vie_base, vie_capture, device_name, unique_id)) - return number_of_errors; - capture_id = 0; - error = vie_capture->AllocateCaptureDevice(unique_id, - KMaxUniqueIdLength, - capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_capture->ConnectCaptureDevice(capture_id, - video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - assert(FLAGS_render_custom_call_remote_to == "" && - "Not implemented to change video capture device when " - "rendering to file!"); - - error = vie_capture->StartCapture(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_renderer->AddRenderer(capture_id, _window1, 0, 0.0, 0.0, - 1.0, 1.0); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_renderer->StartRender(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case 6: - // Change the Video Protection. - protection_method = GetVideoProtection(); - SetVideoProtection(vie_codec, vie_rtp_rtcp, - video_channel, protection_method); - break; - case 7: - // Toggle Encoder Observer. - if (!codec_encoder_observer) { - std::cout << "Registering Encoder Observer" << std::endl; - codec_encoder_observer = new ViEAutotestEncoderObserver(); - error = vie_codec->RegisterEncoderObserver(video_channel, - *codec_encoder_observer); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } else { - std::cout << "Deregistering Encoder Observer" << std::endl; - error = vie_codec->DeregisterEncoderObserver(video_channel); - delete codec_encoder_observer; - codec_encoder_observer = NULL; - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } - break; - case 8: - // Toggle Decoder Observer. - if (!codec_decoder_observer) { - std::cout << "Registering Decoder Observer" << std::endl; - codec_decoder_observer = new ViEAutotestDecoderObserver(); - error = vie_codec->RegisterDecoderObserver(video_channel, - *codec_decoder_observer); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } else { - std::cout << "Deregistering Decoder Observer" << std::endl; - error = vie_codec->DeregisterDecoderObserver(video_channel); - delete codec_decoder_observer; - codec_decoder_observer = NULL; - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } - break; - case 9: - // Print Call information.. - PrintCallInformation(ip_address.c_str(), device_name, - unique_id, video_send_codec, - video_tx_port, video_rx_port, - audio_capture_device_name, - audio_playbackDeviceName, - audio_codec, audio_tx_port, - audio_rx_port, protection_method); - PrintVideoStreamInformation(vie_codec, - video_channel); - break; - case 10: - // Print Call statistics. - PrintRTCCPStatistics(vie_rtp_rtcp, video_channel, - kSendStatistic); - PrintRTCCPStatistics(vie_rtp_rtcp, video_channel, - kReceivedStatistic); - PrintRTPStatistics(vie_rtp_rtcp, video_channel); - PrintBandwidthUsage(vie_rtp_rtcp, video_channel); - PrintCodecStatistics(vie_codec, video_channel, - kSendStatistic); - PrintCodecStatistics(vie_codec, video_channel, - kReceivedStatistic); - PrintGetDiscardedPackets(vie_codec, video_channel); - break; - case 11: - is_image_scale_enabled = !is_image_scale_enabled; - vie_codec->SetImageScaleStatus(video_channel, is_image_scale_enabled); - if (is_image_scale_enabled) { - std::cout << "Image Scale is now enabled" << std::endl; - } else { - std::cout << "Image Scale is now disabled" << std::endl; - } - break; - default: - assert(false); - break; - } - } - - if (FLAGS_render_custom_call_remote_to != "") - file_renderer.StopRendering(); - - // Testing finished. Tear down Voice and Video Engine. - // Tear down the VoE first. - error = voe_base->StopReceive(audio_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_base->StopPlayout(audio_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = voe_base->DeleteChannel(audio_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Now tear down the ViE engine. - error = vie_base->DisconnectAudioChannel(video_channel); - - voice_channel_transport.reset(NULL); - - // If Encoder/Decoder Observer is running, delete them. - if (codec_encoder_observer) { - error = vie_codec->DeregisterEncoderObserver(video_channel); - delete codec_encoder_observer; - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } - if (codec_decoder_observer) { - error = vie_codec->DeregisterDecoderObserver(video_channel); - delete codec_decoder_observer; - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - } - - error = vie_base->StopReceive(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_base->StopSend(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_renderer->StopRender(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_renderer->StopRender(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_renderer->RemoveRenderer(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_renderer->RemoveRenderer(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_capture->StopCapture(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_capture->DisconnectCaptureDevice(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - error = vie_capture->ReleaseCaptureDevice(capture_id); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - video_channel_transport.reset(NULL); - - error = vie_base->DeleteChannel(video_channel); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - int remaining_interfaces = 0; - remaining_interfaces = vie_codec->Release(); - number_of_errors += ViETest::TestError(remaining_interfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - remaining_interfaces = vie_capture->Release(); - number_of_errors += ViETest::TestError(remaining_interfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - remaining_interfaces = vie_rtp_rtcp->Release(); - number_of_errors += ViETest::TestError(remaining_interfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - remaining_interfaces = vie_renderer->Release(); - number_of_errors += ViETest::TestError(remaining_interfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - remaining_interfaces = vie_network->Release(); - number_of_errors += ViETest::TestError(remaining_interfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - remaining_interfaces = vie_base->Release(); - number_of_errors += ViETest::TestError(remaining_interfaces == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - bool deleted = webrtc::VideoEngine::Delete(vie); - number_of_errors += ViETest::TestError(deleted == true, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - ViETest::Log(" "); - ViETest::Log(" ViE Autotest Custom Call Started"); - ViETest::Log("========================================"); - ViETest::Log(" "); - } - return number_of_errors; -} - -bool GetVideoDevice(webrtc::ViEBase* vie_base, - webrtc::ViECapture* vie_capture, - char* capture_device_name, - char* capture_device_unique_id) { - int error = 0; - int number_of_errors = 0; - - const unsigned int KMaxDeviceNameLength = 128; - const unsigned int KMaxUniqueIdLength = 256; - char device_name[KMaxDeviceNameLength]; - char unique_id[KMaxUniqueIdLength]; - - if (vie_capture->NumberOfCaptureDevices() == 0) { - printf("You have no capture devices plugged into your system.\n"); - return false; - } - - std::string capture_choices; - std::string first_device; - for (int i = 0; i < vie_capture->NumberOfCaptureDevices(); i++) { - memset(device_name, 0, KMaxDeviceNameLength); - memset(unique_id, 0, KMaxUniqueIdLength); - - error = vie_capture->GetCaptureDevice(i, device_name, - KMaxDeviceNameLength, - unique_id, - KMaxUniqueIdLength); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - const int kCaptureLineLength = - KMaxDeviceNameLength + KMaxUniqueIdLength + 8; - char capture_line[kCaptureLineLength]; - sprintf(capture_line, "%s (%s)", device_name, unique_id); - capture_choices += capture_line; - capture_choices += "\n"; - if (first_device.empty()) - first_device = capture_line; - } - - int choice = FromChoices("Available Video Capture Devices", capture_choices) - .WithDefault(first_device) - .Choose(); - - error = vie_capture->GetCaptureDevice( - choice - 1, device_name, KMaxDeviceNameLength, unique_id, - KMaxUniqueIdLength); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - strcpy(capture_device_unique_id, unique_id); - strcpy(capture_device_name, device_name); - return true; -} - -bool GetAudioDevices(webrtc::VoEBase* voe_base, - webrtc::VoEHardware* voe_hardware, - char* recording_device_name, - int& recording_device_index, - char* playback_device_name, - int& playback_device_index) { - int error = 0; - int number_of_errors = 0; - - const unsigned int KMaxDeviceNameLength = 128; - const unsigned int KMaxUniqueIdLength = 128; - char recording_device_unique_name[KMaxDeviceNameLength]; - char playback_device_unique_name[KMaxUniqueIdLength]; - - int number_of_recording_devices = -1; - error = voe_hardware->GetNumOfRecordingDevices(number_of_recording_devices); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - recording_device_index = -1; - playback_device_index = -1; - - std::string device_choices; - std::string default_recording_line; - for (int i = 0; i < number_of_recording_devices; ++i) { - error = voe_hardware->GetRecordingDeviceName( - i, recording_device_name, recording_device_unique_name); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - device_choices += recording_device_name; - device_choices += "\n"; - if (default_recording_line.empty()) - default_recording_line = recording_device_name; - } - - int choice = FromChoices("Available audio capture devices:", device_choices) - .WithDefault(default_recording_line) - .Choose(); - - recording_device_index = choice - 1; - error = voe_hardware->GetRecordingDeviceName( - recording_device_index, recording_device_name, - recording_device_unique_name); - number_of_errors += ViETest::TestError( - error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - - int number_of_playback_devices = -1; - error = voe_hardware->GetNumOfPlayoutDevices(number_of_playback_devices); - number_of_errors += ViETest::TestError(error == 0, "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - - std::string playback_choices; - std::string default_playback_line; - for (int i = 0; i < number_of_playback_devices; i++) { - error = voe_hardware->GetPlayoutDeviceName(i, - playback_device_name, - playback_device_unique_name); - number_of_errors += ViETest::TestError( - error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - playback_choices += playback_device_name; - playback_choices += "\n"; - if (default_playback_line.empty()) - default_playback_line = playback_device_name; - } - - choice = FromChoices("Available audio playout devices:", playback_choices) - .WithDefault(default_playback_line) - .Choose(); - - playback_device_index = choice - 1; - error = voe_hardware->GetPlayoutDeviceName(playback_device_index, - playback_device_name, - playback_device_unique_name); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - return true; -} - -// General helper functions. - -std::string GetIPAddress() { - class IpValidator : public webrtc::InputValidator { - public: - bool InputOk(const std::string& input) const { - // Just check quickly that it's on the form x.y.z.w - return std::count(input.begin(), input.end(), '.') == 3; - } - }; - return TypedInput("Enter destination IP.") - .WithDefault(DEFAULT_SEND_IP) - .WithInputValidator(new IpValidator()) - .AskForInput(); -} - -// Video settings functions. - -void GetVideoPorts(int* tx_port, int* rx_port) { - std::string tx_input = TypedInput("Enter video send port.") - .WithDefault(DEFAULT_VIDEO_PORT) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536)) - .AskForInput(); - *tx_port = atoi(tx_input.c_str()); - - std::string rx_input = TypedInput("Enter video receive port.") - .WithDefault(DEFAULT_VIDEO_PORT) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536)) - .AskForInput(); - *rx_port = atoi(rx_input.c_str()); -} - -// Audio settings functions. - -void GetAudioPorts(int* tx_port, int* rx_port) { - std::string tx_input = TypedInput("Enter audio send port.") - .WithDefault(DEFAULT_AUDIO_PORT) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536)) - .AskForInput(); - *tx_port = atoi(tx_input.c_str()); - - std::string rx_input = TypedInput("Enter audio receive port.") - .WithDefault(DEFAULT_AUDIO_PORT) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, 65536)) - .AskForInput(); - *rx_port = atoi(rx_input.c_str()); -} - -bool GetAudioCodec(webrtc::VoECodec* voe_codec, - webrtc::CodecInst& audio_codec) { - int error = 0; - memset(&audio_codec, 0, sizeof(webrtc::CodecInst)); - - std::string default_codec_line; - std::string codec_choices; - for (int codec_idx = 0; codec_idx < voe_codec->NumOfCodecs(); codec_idx++) { - error = voe_codec->GetCodec(codec_idx, audio_codec); - ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - char codec_line[128]; - sprintf(codec_line, "%s type: %d freq: %d chan: %d", - audio_codec.plname, audio_codec.pltype, audio_codec.plfreq, - audio_codec.channels); - codec_choices += codec_line; - codec_choices += "\n"; - - if (strcmp(audio_codec.plname, DEFAULT_AUDIO_CODEC) == 0) { - default_codec_line = codec_line; - } - } - assert(!default_codec_line.empty() && "Default codec doesn't exist."); - - int codec_selection = FromChoices("Available Audio Codecs:", codec_choices) - .WithDefault(default_codec_line) - .Choose(); - - error = voe_codec->GetCodec(codec_selection - 1, audio_codec); - ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - return true; -} - -void PrintCallInformation(const char* IP, const char* video_capture_device_name, - const char* video_capture_unique_id, - webrtc::VideoCodec video_codec, - int video_tx_port, int video_rx_port, - const char* audio_capture_device_name, - const char* audio_playbackDeviceName, - webrtc::CodecInst audio_codec, - int audio_tx_port, int audio_rx_port, - int protection_method) { - std::string str; - - std::cout << "************************************************" - << std::endl; - std::cout << "The call has the following settings: " << std::endl; - std::cout << "\tIP: " << IP << std::endl; - std::cout << "\tVideo Capture Device: " << video_capture_device_name - << std::endl; - std::cout << "\t\tName: " << video_capture_device_name << std::endl; - std::cout << "\t\tUniqueId: " << video_capture_unique_id << std::endl; - PrintVideoCodec(video_codec); - std::cout << "\t Video Tx Port: " << video_tx_port << std::endl; - std::cout << "\t Video Rx Port: " << video_rx_port << std::endl; - std::cout << "\t Video Protection Method (NOTE: Starts at 1 now): " - << protection_method << std::endl; - std::cout << "\tAudio Capture Device: " << audio_capture_device_name - << std::endl; - std::cout << "\tAudio Playback Device: " << audio_playbackDeviceName - << std::endl; - std::cout << "\tAudio Codec: " << std::endl; - std::cout << "\t\tplname: " << audio_codec.plname << std::endl; - std::cout << "\t\tpltype: " << static_cast(audio_codec.pltype) - << std::endl; - std::cout << "\t Audio Tx Port: " << audio_tx_port << std::endl; - std::cout << "\t Audio Rx Port: " << audio_rx_port << std::endl; - std::cout << "************************************************" - << std::endl; -} - -void SetVideoCodecType(webrtc::ViECodec* vie_codec, - webrtc::VideoCodec* video_codec) { - int error = 0; - int number_of_errors = 0; - memset(video_codec, 0, sizeof(webrtc::VideoCodec)); - - std::string codec_choices; - std::string default_codec_line; - for (int i = 0; i < vie_codec->NumberOfCodecs(); i++) { - error = vie_codec->GetCodec(i, *video_codec); - number_of_errors += ViETest::TestError( - error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - - codec_choices += video_codec->plName; - codec_choices += "\n"; - if (strcmp(video_codec->plName, DEFAULT_VIDEO_CODEC) == 0) - default_codec_line = video_codec->plName; - } - assert(!default_codec_line.empty() && "Default does not exist."); - - int choice = FromChoices("Available Video Codecs", codec_choices) - .WithDefault(default_codec_line) - .Choose(); - error = vie_codec->GetCodec(choice - 1, *video_codec); - number_of_errors += ViETest::TestError( - error == 0, "ERROR: %s at line %d", __FUNCTION__, __LINE__); - - if (video_codec->codecType == webrtc::kVideoCodecI420) { - video_codec->width = 176; - video_codec->height = 144; - } -} - -void SetVideoCodecResolution(webrtc::VideoCodec* video_codec) { - if (video_codec->codecType != webrtc::kVideoCodecVP8) { - printf("Can only change codec size if it's VP8\n"); - return; - } - - int choice = FromChoices( - "Available Common Resolutions:", - "SQCIF (128X96)\n" - "QQVGA (160X120)\n" - "QCIF (176X144)\n" - "CIF (352X288)\n" - "VGA (640X480)\n" - "WVGA (800x480)\n" - "4CIF (704X576)\n" - "SVGA (800X600)\n" - "HD (1280X720)\n" - "XGA (1024x768)\n") - .Choose(); - - switch (choice) { - case 1: - video_codec->width = 128; - video_codec->height = 96; - break; - case 2: - video_codec->width = 160; - video_codec->height = 120; - break; - case 3: - video_codec->width = 176; - video_codec->height = 144; - break; - case 4: - video_codec->width = 352; - video_codec->height = 288; - break; - case 5: - video_codec->width = 640; - video_codec->height = 480; - break; - case 6: - video_codec->width = 800; - video_codec->height = 480; - break; - case 7: - video_codec->width = 704; - video_codec->height = 576; - break; - case 8: - video_codec->width = 800; - video_codec->height = 600; - break; - case 9: - video_codec->width = 1280; - video_codec->height = 720; - break; - case 10: - video_codec->width = 1024; - video_codec->height = 768; - break; - } -} - -void SetVideoCodecSize(webrtc::VideoCodec* video_codec) { - if (video_codec->codecType != webrtc::kVideoCodecVP8) { - printf("Can only change codec size if it's VP8\n"); - return; - } - - std::string input = TypedInput("Choose video width.") - .WithDefault(DEFAULT_VIDEO_CODEC_WIDTH) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX)) - .AskForInput(); - video_codec->width = atoi(input.c_str()); - - input = TypedInput("Choose video height.") - .WithDefault(DEFAULT_VIDEO_CODEC_HEIGHT) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX)) - .AskForInput(); - video_codec->height = atoi(input.c_str()); -} - -void SetVideoCodecBitrate(webrtc::VideoCodec* video_codec) { - std::string input = TypedInput("Choose start rate (in kbps).") - .WithDefault(DEFAULT_VIDEO_CODEC_BITRATE) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX)) - .AskForInput(); - - video_codec->startBitrate = atoi(input.c_str()); -} - -void SetVideoCodecMaxBitrate(webrtc::VideoCodec* video_codec) { - std::string input = TypedInput("Choose max bitrate (in kbps).") - .WithDefault(DEFAULT_VIDEO_CODEC_MAX_BITRATE) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX)) - .AskForInput(); - - video_codec->maxBitrate = atoi(input.c_str()); -} - -void SetVideoCodecMinBitrate(webrtc::VideoCodec* video_codec) { - std::string input = TypedInput("Choose min bitrate (in kbps).") - .WithDefault(DEFAULT_VIDEO_CODEC_MIN_BITRATE) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX)) - .AskForInput(); - - video_codec->minBitrate = atoi(input.c_str()); -} - -void SetVideoCodecMaxFramerate(webrtc::VideoCodec* video_codec) { - std::string input = TypedInput("Choose max framerate (in fps).") - .WithDefault(DEFAULT_VIDEO_CODEC_MAX_FRAMERATE) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(1, INT_MAX)) - .AskForInput(); - video_codec->maxFramerate = atoi(input.c_str()); -} - -void SetVideoCodecTemporalLayer(webrtc::VideoCodec* video_codec) { - if (video_codec->codecType != webrtc::kVideoCodecVP8) - return; - - std::string input = TypedInput("Choose number of temporal layers (0 to 4).") - .WithDefault(DEFAULT_TEMPORAL_LAYER) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(0, 4)) - .AskForInput(); - video_codec->codecSpecific.VP8.numberOfTemporalLayers = atoi(input.c_str()); -} - -// GetVideoProtection only prints the prompt to get a number -// that SetVideoProtection method uses. -VideoProtectionMethod GetVideoProtection() { - int choice = FromChoices( - "Available Video Protection Methods:", - "None\n" - "FEC\n" - "NACK\n" - "NACK+FEC\n") - .WithDefault(DEFAULT_VIDEO_PROTECTION_METHOD) - .Choose(); - - assert(choice >= kProtectionMethodNone && - choice <= kProtectionMethodHybridNackAndFec); - return static_cast(choice); -} - -bool SetVideoProtection(webrtc::ViECodec* vie_codec, - webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel, - VideoProtectionMethod protection_method) { - int error = 0; - int number_of_errors = 0; - webrtc::VideoCodec video_codec; - - memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); - - // Set all video protection to false initially - error = vie_rtp_rtcp->SetHybridNACKFECStatus(video_channel, false, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_rtp_rtcp->SetFECStatus(video_channel, false, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - error = vie_rtp_rtcp->SetNACKStatus(video_channel, false); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - // Set video protection for FEC, NACK or Hybrid. - switch (protection_method) { - case kProtectionMethodNone: - // No protection selected, all protection already at false. - std::cout << "Call using None protection Method" << std::endl; - break; - case kProtectionMethodFecOnly: - std::cout << "Call using FEC protection Method" << std::endl; - error = vie_rtp_rtcp->SetFECStatus(video_channel, true, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case kProtectionMethodNackOnly: - std::cout << "Call using NACK protection Method" << std::endl; - error = vie_rtp_rtcp->SetNACKStatus(video_channel, true); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case kProtectionMethodHybridNackAndFec: - std::cout << "Call using Hybrid NACK and FEC protection Method" - << std::endl; - error = vie_rtp_rtcp->SetHybridNACKFECStatus(video_channel, true, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - } - - // Set receive codecs for FEC and hybrid NACK/FEC. - if (protection_method == kProtectionMethodFecOnly || - protection_method == kProtectionMethodHybridNackAndFec) { - // RED. - error = vie_codec->GetCodec(vie_codec->NumberOfCodecs() - 2, - video_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - video_codec.plType = VCM_RED_PAYLOAD_TYPE; - error = vie_codec->SetReceiveCodec(video_channel, video_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - std::cout << "RED Codec Information:" << std::endl; - PrintVideoCodec(video_codec); - // ULPFEC. - error = vie_codec->GetCodec(vie_codec->NumberOfCodecs() - 1, - video_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - video_codec.plType = VCM_ULPFEC_PAYLOAD_TYPE; - error = vie_codec->SetReceiveCodec(video_channel, video_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - std::cout << "ULPFEC Codec Information:" << std::endl; - PrintVideoCodec(video_codec); - } - - return true; -} - -// Returns true if REMB, false if TMMBR. -bool GetBitrateSignaling() { - int choice = FromChoices( - "Available Bitrate Signaling Methods:", - "REMB\n" - "TMMBR\n") - .WithDefault("REMB") - .Choose(); - return choice == 1; -} - -int GetBufferingDelay() { - std::string input = TypedInput("Choose buffering delay (mS).") - .WithDefault(DEFAULT_BUFFERING_DELAY_MS) - .WithInputValidator(new webrtc::IntegerWithinRangeValidator(0, 10000)) - .AskForInput(); - std::string delay_ms = input; - return atoi(delay_ms.c_str()); -} - -void PrintRTCCPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel, - StatisticsType stat_type) { - int error = 0; - int number_of_errors = 0; - webrtc::RtcpStatistics rtcp_stats; - int64_t rtt_ms = 0; - - switch (stat_type) { - case kReceivedStatistic: - std::cout << "RTCP Received statistics" - << std::endl; - // Get and print the Received RTCP Statistics - error = vie_rtp_rtcp->GetReceiveChannelRtcpStatistics(video_channel, - rtcp_stats, - rtt_ms); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case kSendStatistic: - std::cout << "RTCP Sent statistics" - << std::endl; - // Get and print the Sent RTCP Statistics - error = vie_rtp_rtcp->GetSendChannelRtcpStatistics(video_channel, - rtcp_stats, - rtt_ms); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - } - std::cout << "\tRTCP fraction of lost packets: " - << rtcp_stats.fraction_lost << std::endl; - std::cout << "\tRTCP cumulative number of lost packets: " - << rtcp_stats.cumulative_lost << std::endl; - std::cout << "\tRTCP max received sequence number " - << rtcp_stats.extended_max_sequence_number << std::endl; - std::cout << "\tRTCP jitter: " - << rtcp_stats.jitter << std::endl; - std::cout << "\tRTCP round trip (ms): " - << rtt_ms << std::endl; -} - -void PrintRTPStatistics(webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel) { - int error = 0; - int number_of_errors = 0; - webrtc::StreamDataCounters sent; - webrtc::StreamDataCounters received; - - std::cout << "RTP statistics" - << std::endl; - - // Get and print the RTP Statistics - error = vie_rtp_rtcp->GetRtpStatistics(video_channel, sent, received); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - std::cout << "\tRTP bytes sent: " - << sent.transmitted.payload_bytes << std::endl; - std::cout << "\tRTP packets sent: " - << sent.transmitted.packets << std::endl; - std::cout << "\tRTP bytes received: " - << received.transmitted.payload_bytes << std::endl; - std::cout << "\tRTP packets received: " - << received.transmitted.packets << std::endl; -} - -void PrintBandwidthUsage(webrtc::ViERTP_RTCP* vie_rtp_rtcp, - int video_channel) { - int error = 0; - int number_of_errors = 0; - unsigned int total_bitrate_sent = 0; - unsigned int video_bitrate_sent = 0; - unsigned int fec_bitrate_sent = 0; - unsigned int nack_bitrate_sent = 0; - double percentage_fec = 0; - double percentage_nack = 0; - - std::cout << "Bandwidth Usage" << std::endl; - - // Get and print Bandwidth usage - error = vie_rtp_rtcp->GetBandwidthUsage(video_channel, total_bitrate_sent, - video_bitrate_sent, fec_bitrate_sent, - nack_bitrate_sent); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - std::cout << "\tTotal bitrate sent (Kbit/s): " - << total_bitrate_sent << std::endl; - std::cout << "\tVideo bitrate sent (Kbit/s): " - << video_bitrate_sent << std::endl; - std::cout << "\tFEC bitrate sent (Kbit/s): " - << fec_bitrate_sent << std::endl; - percentage_fec = - (static_cast(fec_bitrate_sent) / - static_cast(total_bitrate_sent)) * 100; - std::cout << "\tPercentage FEC bitrate sent from total bitrate: " - << percentage_fec << std::endl; - std::cout << "\tNACK bitrate sent (Kbit/s): " - << nack_bitrate_sent << std::endl; - percentage_nack = - (static_cast(nack_bitrate_sent) / - static_cast(total_bitrate_sent)) * 100; - std::cout << "\tPercentage NACK bitrate sent from total bitrate: " - << percentage_nack << std::endl; -} - -void PrintCodecStatistics(webrtc::ViECodec* vie_codec, - int video_channel, - StatisticsType stat_type) { - int error = 0; - int number_of_errors = 0; - unsigned int key_frames = 0; - unsigned int delta_frames = 0; - switch (stat_type) { - case kReceivedStatistic: - std::cout << "Codec Receive statistics" - << std::endl; - // Get and print the Receive Codec Statistics - error = vie_codec->GetReceiveCodecStastistics(video_channel, key_frames, - delta_frames); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - case kSendStatistic: - std::cout << "Codec Send statistics" - << std::endl; - // Get and print the Send Codec Statistics - error = vie_codec->GetSendCodecStastistics(video_channel, key_frames, - delta_frames); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - break; - } - std::cout << "\tNumber of encoded key frames: " - << key_frames << std::endl; - std::cout << "\tNumber of encoded delta frames: " - << delta_frames << std::endl; -} - -void PrintGetDiscardedPackets(webrtc::ViECodec* vie_codec, int video_channel) { - std::cout << "Discarded Packets" << std::endl; - int discarded_packets = 0; - discarded_packets = vie_codec->GetNumDiscardedPackets(video_channel); - std::cout << "\tNumber of discarded packets: " - << discarded_packets << std::endl; -} - -void PrintVideoStreamInformation(webrtc::ViECodec* vie_codec, - int video_channel) { - webrtc::VideoCodec outgoing_codec; - webrtc::VideoCodec incoming_codec; - - memset(&outgoing_codec, 0, sizeof(webrtc::VideoCodec)); - memset(&incoming_codec, 0, sizeof(webrtc::VideoCodec)); - - vie_codec->GetSendCodec(video_channel, outgoing_codec); - vie_codec->GetReceiveCodec(video_channel, incoming_codec); - - std::cout << "************************************************" - << std::endl; - std::cout << "ChannelId: " << video_channel << std::endl; - std::cout << "Outgoing Stream information:" << std::endl; - PrintVideoCodec(outgoing_codec); - std::cout << "Incoming Stream information:" << std::endl; - PrintVideoCodec(incoming_codec); - std::cout << "************************************************" - << std::endl; -} - -void PrintVideoCodec(webrtc::VideoCodec video_codec) { - std::cout << "\t\tplName: " << video_codec.plName << std::endl; - std::cout << "\t\tplType: " << static_cast(video_codec.plType) - << std::endl; - std::cout << "\t\twidth: " << video_codec.width << std::endl; - std::cout << "\t\theight: " << video_codec.height << std::endl; - std::cout << "\t\tstartBitrate: " << video_codec.startBitrate - << std::endl; - std::cout << "\t\tminBitrate: " << video_codec.minBitrate - << std::endl; - std::cout << "\t\tmaxBitrate: " << video_codec.maxBitrate - << std::endl; - std::cout << "\t\tmaxFramerate: " - << static_cast(video_codec.maxFramerate) << std::endl; - if (video_codec.codecType == webrtc::kVideoCodecVP8) { - int number_of_layers = - static_cast(video_codec.codecSpecific.VP8.numberOfTemporalLayers); - std::cout << "\t\tVP8 Temporal Layer: " << number_of_layers << std::endl; - } -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_image_process.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_image_process.cc deleted file mode 100644 index de8d2d1dea..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_image_process.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_image_process.cc -// - -// Settings -#include "webrtc/engine_configurations.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" - -#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" - -class MyEffectFilter: public webrtc::ViEEffectFilter -{ -public: - MyEffectFilter() {} - - ~MyEffectFilter() {} - - virtual int Transform(size_t size, - unsigned char* frame_buffer, - int64_t ntp_time_ms, - unsigned int timestamp, - unsigned int width, - unsigned int height) - { - // Black and white - memset(frame_buffer + (2 * size) / 3, 0x7f, size / 3); - return 0; - } -}; - -void ViEAutoTest::ViEImageProcessStandardTest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** - int rtpPort = 6000; - // Create VIE - TbInterfaces ViE("ViEImageProcessStandardTest"); - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - // Create a capture device - TbCaptureDevice tbCapture(ViE); - - tbCapture.ConnectTo(tbChannel.videoChannel); - tbChannel.StartReceive(rtpPort); - tbChannel.StartSend(rtpPort); - - MyEffectFilter effectFilter; - - RenderCaptureDeviceAndOutputStream(&ViE, &tbChannel, &tbCapture); - - ViETest::Log("Capture device is renderered in Window 1"); - ViETest::Log("Remote stream is renderered in Window 2"); - AutoTestSleep(kAutoTestSleepTimeMs); - - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** - - - EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( - tbCapture.captureId, effectFilter)); - - ViETest::Log("Black and white filter registered for capture device, " - "affects both windows"); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId)); - - EXPECT_EQ(0, ViE.image_process->RegisterRenderEffectFilter( - tbChannel.videoChannel, effectFilter)); - - ViETest::Log("Remove capture effect filter, adding filter for incoming " - "stream"); - ViETest::Log("Only Window 2 should be black and white"); - AutoTestSleep(kAutoTestSleepTimeMs); - - StopRenderCaptureDeviceAndOutputStream(&ViE, &tbChannel, &tbCapture); - - tbCapture.Disconnect(tbChannel.videoChannel); - - int rtpPort2 = rtpPort + 100; - // Create a video channel - TbVideoChannel tbChannel2(ViE, webrtc::kVideoCodecVP8); - - tbCapture.ConnectTo(tbChannel2.videoChannel); - tbChannel2.StartReceive(rtpPort2); - tbChannel2.StartSend(rtpPort2); - - EXPECT_EQ(0, ViE.render->AddRenderer( - tbChannel2.videoChannel, _window1, 1, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbChannel2.videoChannel)); - EXPECT_EQ(0, ViE.image_process->DeregisterRenderEffectFilter( - tbChannel.videoChannel)); - - ViETest::Log("Local renderer removed, added new channel and rendering in " - "Window1."); - - EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( - tbCapture.captureId, effectFilter)); - - ViETest::Log("Black and white filter registered for capture device, " - "affects both windows"); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId)); - - EXPECT_EQ(0, ViE.image_process->RegisterSendEffectFilter( - tbChannel.videoChannel, effectFilter)); - - ViETest::Log("Capture filter removed."); - ViETest::Log("Black and white filter registered for one channel, Window2 " - "should be black and white"); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.image_process->DeregisterSendEffectFilter( - tbChannel.videoChannel)); - - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel2.videoChannel)); - - tbCapture.Disconnect(tbChannel2.videoChannel); - - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** -} - -void ViEAutoTest::ViEImageProcessExtendedTest() -{ -} - -void ViEAutoTest::ViEImageProcessAPITest() -{ - TbInterfaces ViE("ViEImageProcessAPITest"); - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - TbCaptureDevice tbCapture(ViE); - - tbCapture.ConnectTo(tbChannel.videoChannel); - - MyEffectFilter effectFilter; - - // - // Capture effect filter - // - // Add effect filter - EXPECT_EQ(0, ViE.image_process->RegisterCaptureEffectFilter( - tbCapture.captureId, effectFilter)); - // Add again -> error - EXPECT_NE(0, ViE.image_process->RegisterCaptureEffectFilter( - tbCapture.captureId, effectFilter)); - EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId)); - EXPECT_EQ(0, ViE.image_process->DeregisterCaptureEffectFilter( - tbCapture.captureId)); - - // Non-existing capture device - EXPECT_NE(0, ViE.image_process->RegisterCaptureEffectFilter( - tbChannel.videoChannel, effectFilter)); - - // - // Render effect filter - // - EXPECT_EQ(0, ViE.image_process->RegisterRenderEffectFilter( - tbChannel.videoChannel, effectFilter)); - EXPECT_NE(0, ViE.image_process->RegisterRenderEffectFilter( - tbChannel.videoChannel, effectFilter)); - EXPECT_EQ(0, ViE.image_process->DeregisterRenderEffectFilter( - tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.image_process->DeregisterRenderEffectFilter( - tbChannel.videoChannel)); - - // Non-existing channel id - EXPECT_NE(0, ViE.image_process->RegisterRenderEffectFilter( - tbCapture.captureId, effectFilter)); - - // - // Send effect filter - // - EXPECT_EQ(0, ViE.image_process->RegisterSendEffectFilter( - tbChannel.videoChannel, effectFilter)); - EXPECT_NE(0, ViE.image_process->RegisterSendEffectFilter( - tbChannel.videoChannel, effectFilter)); - EXPECT_EQ(0, ViE.image_process->DeregisterSendEffectFilter( - tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.image_process->DeregisterSendEffectFilter( - tbChannel.videoChannel)); - EXPECT_NE(0, ViE.image_process->RegisterSendEffectFilter( - tbCapture.captureId, effectFilter)); - - // - // Deflickering - // - EXPECT_EQ(0, ViE.image_process->EnableDeflickering( - tbCapture.captureId, true)); - EXPECT_NE(0, ViE.image_process->EnableDeflickering( - tbCapture.captureId, true)); - EXPECT_EQ(0, ViE.image_process->EnableDeflickering( - tbCapture.captureId, false)); - EXPECT_NE(0, ViE.image_process->EnableDeflickering( - tbCapture.captureId, false)); - EXPECT_NE(0, ViE.image_process->EnableDeflickering( - tbChannel.videoChannel, true)); - - // - // Color enhancement - // - EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, false)); - EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, true)); - EXPECT_EQ(0, ViE.image_process->EnableColorEnhancement( - tbChannel.videoChannel, false)); - EXPECT_NE(0, ViE.image_process->EnableColorEnhancement( - tbCapture.captureId, true)); - - tbCapture.Disconnect(tbChannel.videoChannel); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_linux.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_linux.cc deleted file mode 100644 index 337bf8a656..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_linux.cc +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_linux.cc -// -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_linux.h" - -#include - -#include "webrtc/engine_configurations.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h" - -ViEAutoTestWindowManager::ViEAutoTestWindowManager() - : _hdsp1(NULL), - _hdsp2(NULL) { -} - -ViEAutoTestWindowManager::~ViEAutoTestWindowManager() { - TerminateWindows(); -} - -void* ViEAutoTestWindowManager::GetWindow1() { - return reinterpret_cast(_hwnd1); -} - -void* ViEAutoTestWindowManager::GetWindow2() { - return reinterpret_cast(_hwnd2); -} - -int ViEAutoTestWindowManager::TerminateWindows() { - if (_hdsp1) { - ViEDestroyWindow(&_hwnd1, _hdsp1); - _hdsp1 = NULL; - } - if (_hdsp2) { - ViEDestroyWindow(&_hwnd2, _hdsp2); - _hdsp2 = NULL; - } - return 0; -} - -int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size, - AutoTestRect window2Size, - void* window1Title, - void* window2Title) { - ViECreateWindow(&_hwnd1, &_hdsp1, window1Size.origin.x, - window1Size.origin.y, window1Size.size.width, - window1Size.size.height, - reinterpret_cast(window1Title)); - ViECreateWindow(&_hwnd2, &_hdsp2, window2Size.origin.x, - window2Size.origin.y, window2Size.size.width, - window2Size.size.height, - reinterpret_cast(window2Title)); - - return 0; -} - -int ViEAutoTestWindowManager::ViECreateWindow(Window *out_window, - Display **out_display, int x_pos, - int y_pos, int width, int height, - char* title) { - Display* display = XOpenDisplay(NULL); - if (display == NULL) { - // There's no point to continue if this happens: nothing will work anyway. - printf("Failed to connect to X server: X environment likely broken\n"); - exit(-1); - } - - int screen = DefaultScreen(display); - - // Try to establish a 24-bit TrueColor display - // (our environment must allow this). - XVisualInfo visual_info; - if (XMatchVisualInfo(display, screen, 24, TrueColor, &visual_info) == 0) { - printf("Failed to establish 24-bit TrueColor in X environment.\n"); - exit(-1); - } - - // Create suitable window attributes. - XSetWindowAttributes window_attributes; - window_attributes.colormap = XCreateColormap( - display, DefaultRootWindow(display), visual_info.visual, AllocNone); - window_attributes.event_mask = StructureNotifyMask | ExposureMask; - window_attributes.background_pixel = 0; - window_attributes.border_pixel = 0; - - unsigned long attribute_mask = CWBackPixel | CWBorderPixel | CWColormap | - CWEventMask; - - Window _window = XCreateWindow(display, DefaultRootWindow(display), x_pos, - y_pos, width, height, 0, visual_info.depth, - InputOutput, visual_info.visual, - attribute_mask, &window_attributes); - - // Set window name. - XStoreName(display, _window, title); - XSetIconName(display, _window, title); - - // Make x report events for mask. - XSelectInput(display, _window, StructureNotifyMask); - - // Map the window to the display. - XMapWindow(display, _window); - - // Wait for map event. - XEvent event; - do { - XNextEvent(display, &event); - } while (event.type != MapNotify || event.xmap.event != _window); - - *out_window = _window; - *out_display = display; - return 0; -} - -int ViEAutoTestWindowManager::ViEDestroyWindow(Window *window, - Display *display) { - XUnmapWindow(display, *window); - XDestroyWindow(display, *window); - XSync(display, false); - XCloseDisplay(display); - return 0; -} - -bool ViEAutoTestWindowManager::SetTopmostWindow() { - return 0; -} - -int main(int argc, char** argv) { - ViEAutoTestMain auto_test; - return auto_test.RunTests(argc, argv); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_loopback.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_loopback.cc deleted file mode 100644 index 52cf078d89..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_loopback.cc +++ /dev/null @@ -1,763 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_loopback.cc -// -// This code is also used as sample code for ViE 3.0 -// - -// =================================================================== -// -// BEGIN: VideoEngine 3.0 Sample Code -// - -#include - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/common_types.h" -#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_external_codec.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/voice_engine/include/voe_base.h" - -const uint32_t kSsrc = 0x01234567; -const uint32_t kRtxSsrc = 0x01234568; -const int kRtxPayloadType = 98; -const int kPayloadType = 100; -#define VCM_RED_PAYLOAD_TYPE 96 -#define VCM_ULPFEC_PAYLOAD_TYPE 97 - -int VideoEngineSampleCode(void* window1, void* window2) -{ - //******************************************************** - // Begin create/initialize Video Engine for testing - //******************************************************** - - int error = 0; - - // - // Create a VideoEngine instance - // - webrtc::VideoEngine* ptrViE = NULL; - ptrViE = webrtc::VideoEngine::Create(); - if (ptrViE == NULL) - { - printf("ERROR in VideoEngine::Create\n"); - return -1; - } - - error = ptrViE->SetTraceFilter(webrtc::kTraceAll); - if (error == -1) - { - printf("ERROR in VideoEngine::SetTraceFilter\n"); - return -1; - } - - std::string trace_file = - ViETest::GetResultOutputPath() + "ViELoopbackCall_trace.txt"; - error = ptrViE->SetTraceFile(trace_file.c_str()); - if (error == -1) - { - printf("ERROR in VideoEngine::SetTraceFile\n"); - return -1; - } - - // - // Init VideoEngine and create a channel - // - webrtc::ViEBase* ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE); - if (ptrViEBase == NULL) - { - printf("ERROR in ViEBase::GetInterface\n"); - return -1; - } - - error = ptrViEBase->Init(); - if (error == -1) - { - printf("ERROR in ViEBase::Init\n"); - return -1; - } - - webrtc::ViERTP_RTCP* ptrViERtpRtcp = - webrtc::ViERTP_RTCP::GetInterface(ptrViE); - if (ptrViERtpRtcp == NULL) - { - printf("ERROR in ViERTP_RTCP::GetInterface\n"); - return -1; - } - - int videoChannel = -1; - error = ptrViEBase->CreateChannel(videoChannel); - if (error == -1) - { - printf("ERROR in ViEBase::CreateChannel\n"); - return -1; - } - - // - // List available capture devices, allocate and connect. - // - webrtc::ViECapture* ptrViECapture = - webrtc::ViECapture::GetInterface(ptrViE); - if (ptrViEBase == NULL) - { - printf("ERROR in ViECapture::GetInterface\n"); - return -1; - } - - const unsigned int KMaxDeviceNameLength = 128; - const unsigned int KMaxUniqueIdLength = 256; - char deviceName[KMaxDeviceNameLength]; - memset(deviceName, 0, KMaxDeviceNameLength); - char uniqueId[KMaxUniqueIdLength]; - memset(uniqueId, 0, KMaxUniqueIdLength); - - printf("Available capture devices:\n"); - int captureIdx = 0; - for (captureIdx = 0; - captureIdx < ptrViECapture->NumberOfCaptureDevices(); - captureIdx++) - { - memset(deviceName, 0, KMaxDeviceNameLength); - memset(uniqueId, 0, KMaxUniqueIdLength); - - error = ptrViECapture->GetCaptureDevice(captureIdx, deviceName, - KMaxDeviceNameLength, uniqueId, - KMaxUniqueIdLength); - if (error == -1) - { - printf("ERROR in ViECapture::GetCaptureDevice\n"); - return -1; - } - printf("\t %d. %s\n", captureIdx + 1, deviceName); - } - printf("\nChoose capture device: "); -#ifdef WEBRTC_ANDROID - captureIdx = 0; - printf("0\n"); -#else - if (scanf("%d", &captureIdx) != 1) - { - printf("Error in scanf()\n"); - return -1; - } - getc(stdin); - captureIdx = captureIdx - 1; // Compensate for idx start at 1. -#endif - error = ptrViECapture->GetCaptureDevice(captureIdx, deviceName, - KMaxDeviceNameLength, uniqueId, - KMaxUniqueIdLength); - if (error == -1) - { - printf("ERROR in ViECapture::GetCaptureDevice\n"); - return -1; - } - - int captureId = 0; - error = ptrViECapture->AllocateCaptureDevice(uniqueId, KMaxUniqueIdLength, - captureId); - if (error == -1) - { - printf("ERROR in ViECapture::AllocateCaptureDevice\n"); - return -1; - } - - error = ptrViECapture->ConnectCaptureDevice(captureId, videoChannel); - if (error == -1) - { - printf("ERROR in ViECapture::ConnectCaptureDevice\n"); - return -1; - } - - error = ptrViECapture->StartCapture(captureId); - if (error == -1) - { - printf("ERROR in ViECapture::StartCapture\n"); - return -1; - } - - // - // RTP/RTCP settings - // - - error = ptrViERtpRtcp->SetRTCPStatus(videoChannel, - webrtc::kRtcpCompound_RFC4585); - if (error == -1) - { - printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n"); - return -1; - } - - error = ptrViERtpRtcp->SetKeyFrameRequestMethod( - videoChannel, webrtc::kViEKeyFrameRequestPliRtcp); - if (error == -1) - { - printf("ERROR in ViERTP_RTCP::SetKeyFrameRequestMethod\n"); - return -1; - } - - error = ptrViERtpRtcp->SetRembStatus(videoChannel, true, true); - if (error == -1) - { - printf("ERROR in ViERTP_RTCP::SetTMMBRStatus\n"); - return -1; - } - - // Setting SSRC manually (arbitrary value), as otherwise we will get a clash - // (loopback), and a new SSRC will be set, which will reset the receiver. - error = ptrViERtpRtcp->SetLocalSSRC(videoChannel, kSsrc); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetLocalSSRC\n"); - return -1; - } - - error = ptrViERtpRtcp->SetLocalSSRC(videoChannel, kRtxSsrc, - webrtc::kViEStreamTypeRtx, 0); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetLocalSSRC\n"); - return -1; - } - - error = ptrViERtpRtcp->SetRemoteSSRCType(videoChannel, - webrtc::kViEStreamTypeRtx, - kRtxSsrc); - - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRtxReceivePayloadType\n"); - return -1; - } - - error = ptrViERtpRtcp->SetRtxSendPayloadType(videoChannel, kRtxPayloadType, - kPayloadType); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRtxSendPayloadType\n"); - return -1; - } - - error = ptrViERtpRtcp->SetRtxReceivePayloadType( - videoChannel, kRtxPayloadType, kPayloadType); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRtxReceivePayloadType\n"); - return -1; - } - // - // Set up rendering - // - webrtc::ViERender* ptrViERender = webrtc::ViERender::GetInterface(ptrViE); - if (ptrViERender == NULL) { - printf("ERROR in ViERender::GetInterface\n"); - return -1; - } - - error - = ptrViERender->AddRenderer(captureId, window1, 0, 0.0, 0.0, 1.0, 1.0); - if (error == -1) - { - printf("ERROR in ViERender::AddRenderer\n"); - return -1; - } - - error = ptrViERender->StartRender(captureId); - if (error == -1) - { - printf("ERROR in ViERender::StartRender\n"); - return -1; - } - - error = ptrViERender->AddRenderer(videoChannel, window2, 1, 0.0, 0.0, 1.0, - 1.0); - if (error == -1) - { - printf("ERROR in ViERender::AddRenderer\n"); - return -1; - } - - error = ptrViERender->StartRender(videoChannel); - if (error == -1) - { - printf("ERROR in ViERender::StartRender\n"); - return -1; - } - - // - // Setup codecs - // - webrtc::ViECodec* ptrViECodec = webrtc::ViECodec::GetInterface(ptrViE); - if (ptrViECodec == NULL) - { - printf("ERROR in ViECodec::GetInterface\n"); - return -1; - } - - // Check available codecs and prepare receive codecs - printf("\nAvailable codecs:\n"); - webrtc::VideoCodec videoCodec; - memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); - int codecIdx = 0; - for (codecIdx = 0; codecIdx < ptrViECodec->NumberOfCodecs(); codecIdx++) - { - error = ptrViECodec->GetCodec(codecIdx, videoCodec); - if (error == -1) - { - printf("ERROR in ViECodec::GetCodec\n"); - return -1; - } - - // try to keep the test frame size small when I420 - if (videoCodec.codecType == webrtc::kVideoCodecI420) - { - videoCodec.width = 176; - videoCodec.height = 144; - } - - error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec); - if (error == -1) - { - printf("ERROR in ViECodec::SetReceiveCodec\n"); - return -1; - } - if (videoCodec.codecType != webrtc::kVideoCodecRED - && videoCodec.codecType != webrtc::kVideoCodecULPFEC) - { - printf("\t %d. %s\n", codecIdx + 1, videoCodec.plName); - } - } - printf("%d. VP8 over Generic.\n", ptrViECodec->NumberOfCodecs() + 1); - - printf("Choose codec: "); -#ifdef WEBRTC_ANDROID - codecIdx = 0; - printf("0\n"); -#else - if (scanf("%d", &codecIdx) != 1) - { - printf("Error in scanf()\n"); - return -1; - } - getc(stdin); - codecIdx = codecIdx - 1; // Compensate for idx start at 1. -#endif - // VP8 over generic transport gets this special one. - if (codecIdx == ptrViECodec->NumberOfCodecs()) { - for (codecIdx = 0; codecIdx < ptrViECodec->NumberOfCodecs(); ++codecIdx) { - error = ptrViECodec->GetCodec(codecIdx, videoCodec); - assert(error != -1); - if (videoCodec.codecType == webrtc::kVideoCodecVP8) - break; - } - assert(videoCodec.codecType == webrtc::kVideoCodecVP8); - videoCodec.codecType = webrtc::kVideoCodecGeneric; - - // Any plName should work with generic - strcpy(videoCodec.plName, "VP8-GENERIC"); - uint8_t pl_type = 127; - videoCodec.plType = pl_type; - webrtc::ViEExternalCodec* external_codec = webrtc::ViEExternalCodec - ::GetInterface(ptrViE); - assert(external_codec != NULL); - error = external_codec->RegisterExternalSendCodec(videoChannel, pl_type, - webrtc::VP8Encoder::Create(), false); - assert(error != -1); - error = external_codec->RegisterExternalReceiveCodec(videoChannel, - pl_type, webrtc::VP8Decoder::Create(), false); - assert(error != -1); - } else { - error = ptrViECodec->GetCodec(codecIdx, videoCodec); - if (error == -1) { - printf("ERROR in ViECodec::GetCodec\n"); - return -1; - } - } - - // Set spatial resolution option - std::string str; - std::cout << std::endl; - std::cout << "Enter frame size option (default is CIF):" << std::endl; - std::cout << "1. QCIF (176X144) " << std::endl; - std::cout << "2. CIF (352X288) " << std::endl; - std::cout << "3. VGA (640X480) " << std::endl; - std::cout << "4. 4CIF (704X576) " << std::endl; - std::cout << "5. WHD (1280X720) " << std::endl; - std::cout << "6. FHD (1920X1080) " << std::endl; - std::getline(std::cin, str); - int resolnOption = atoi(str.c_str()); - switch (resolnOption) - { - case 1: - videoCodec.width = 176; - videoCodec.height = 144; - break; - case 2: - videoCodec.width = 352; - videoCodec.height = 288; - break; - case 3: - videoCodec.width = 640; - videoCodec.height = 480; - break; - case 4: - videoCodec.width = 704; - videoCodec.height = 576; - break; - case 5: - videoCodec.width = 1280; - videoCodec.height = 720; - break; - case 6: - videoCodec.width = 1920; - videoCodec.height = 1080; - break; - } - - // Set number of temporal layers. - std::cout << std::endl; - std::cout << "Choose number of temporal layers for VP8 (1 to 4). "; - std::cout << "Press enter for default (=1) for other codecs: \n"; - std::getline(std::cin, str); - int numTemporalLayers = atoi(str.c_str()); - if (numTemporalLayers != 0 && - videoCodec.codecType == webrtc::kVideoCodecVP8) { - videoCodec.codecSpecific.VP8.numberOfTemporalLayers = numTemporalLayers; - } else if (videoCodec.codecType == webrtc::kVideoCodecVP9) { - // Temporal layers for vp9 not yet supported in webrtc. - numTemporalLayers = 1; - videoCodec.codecSpecific.VP9.numberOfTemporalLayers = 1; - } - - // Set start bit rate - std::cout << std::endl; - std::cout << "Choose start rate (in kbps). Press enter for default: "; - std::getline(std::cin, str); - int startRate = atoi(str.c_str()); - if(startRate != 0) - { - videoCodec.startBitrate=startRate; - } - - error = ptrViECodec->SetSendCodec(videoChannel, videoCodec); - assert(error != -1); - error = ptrViECodec->SetReceiveCodec(videoChannel, videoCodec); - assert(error != -1); - - // - // Choose Protection Mode - // - std::cout << std::endl; - std::cout << "Enter Protection Method:" << std::endl; - std::cout << "0. None" << std::endl; - std::cout << "1. FEC" << std::endl; - std::cout << "2. NACK" << std::endl; - std::cout << "3. NACK+FEC" << std::endl; - std::getline(std::cin, str); - int protectionMethod = atoi(str.c_str()); - error = 0; - bool temporalToggling = true; - switch (protectionMethod) - { - case 0: // None: default is no protection - break; - - case 1: // FEC only - error = ptrViERtpRtcp->SetFECStatus(videoChannel, - true, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - temporalToggling = false; - break; - - case 2: // Nack only - error = ptrViERtpRtcp->SetNACKStatus(videoChannel, true); - - break; - - case 3: // Hybrid NAck and FEC - error = ptrViERtpRtcp->SetHybridNACKFECStatus( - videoChannel, - true, - VCM_RED_PAYLOAD_TYPE, - VCM_ULPFEC_PAYLOAD_TYPE); - temporalToggling = false; - break; - } - - if (error < 0) - { - printf("ERROR in ViERTP_RTCP::SetProtectionStatus\n"); - } - - // Set up buffering delay. - std::cout << std::endl; - std::cout << "Set buffering delay (mS). Press enter for default(0mS): "; - std::getline(std::cin, str); - int buffering_delay = atoi(str.c_str()); - if (buffering_delay != 0) { - error = ptrViERtpRtcp->SetSenderBufferingMode(videoChannel, - buffering_delay); - if (error < 0) - printf("ERROR in ViERTP_RTCP::SetSenderBufferingMode\n"); - - error = ptrViERtpRtcp->SetReceiverBufferingMode(videoChannel, - buffering_delay); - if (error < 0) - printf("ERROR in ViERTP_RTCP::SetReceiverBufferingMode\n"); - } - - // - // Address settings - // - webrtc::ViENetwork* ptrViENetwork = - webrtc::ViENetwork::GetInterface(ptrViE); - if (ptrViENetwork == NULL) - { - printf("ERROR in ViENetwork::GetInterface\n"); - return -1; - } - - // Setup transport. - TbExternalTransport* extTransport = NULL; - webrtc::test::VideoChannelTransport* video_channel_transport = NULL; - - int testMode = 0; - std::cout << std::endl; - std::cout << "Enter 1 for testing packet loss and delay with " - "external transport: "; - std::string test_str; - std::getline(std::cin, test_str); - testMode = atoi(test_str.c_str()); - if (testMode == 1) - { - // Avoid changing SSRC due to collision. - error = ptrViERtpRtcp->SetLocalSSRC(videoChannel, 1); - - extTransport = new TbExternalTransport(*ptrViENetwork, videoChannel, - NULL); - - error = ptrViENetwork->RegisterSendTransport(videoChannel, - *extTransport); - if (error == -1) - { - printf("ERROR in ViECodec::RegisterSendTransport \n"); - return -1; - } - - // Setting uniform loss. Actual values will be set by user. - NetworkParameters network; - network.loss_model = kUniformLoss; - // Set up packet loss value - std::cout << "Enter Packet Loss Percentage" << std::endl; - std::string rate_str; - std::getline(std::cin, rate_str); - network.packet_loss_rate = atoi(rate_str.c_str()); - if (network.packet_loss_rate > 0) { - temporalToggling = false; - } - - // Set network delay value - std::cout << "Enter network delay value [mS]" << std::endl; - std::string delay_str; - std::getline(std::cin, delay_str); - network.mean_one_way_delay = atoi(delay_str.c_str()); - extTransport->SetNetworkParameters(network); - if (numTemporalLayers > 1 && temporalToggling) { - extTransport->SetTemporalToggle(numTemporalLayers); - } else { - // Disabled - extTransport->SetTemporalToggle(0); - } - } - else - { - video_channel_transport = new webrtc::test::VideoChannelTransport( - ptrViENetwork, videoChannel); - - const char* ipAddress = "127.0.0.1"; - const unsigned short rtpPort = 6000; - std::cout << std::endl; - std::cout << "Using rtp port: " << rtpPort << std::endl; - std::cout << std::endl; - - error = video_channel_transport->SetLocalReceiver(rtpPort); - if (error == -1) - { - printf("ERROR in SetLocalReceiver\n"); - return -1; - } - error = video_channel_transport->SetSendDestination(ipAddress, rtpPort); - if (error == -1) - { - printf("ERROR in SetSendDestination\n"); - return -1; - } - } - - error = ptrViEBase->StartReceive(videoChannel); - if (error == -1) - { - printf("ERROR in ViENetwork::StartReceive\n"); - return -1; - } - - error = ptrViEBase->StartSend(videoChannel); - if (error == -1) - { - printf("ERROR in ViENetwork::StartSend\n"); - return -1; - } - - //******************************************************** - // Engine started - //******************************************************** - - - // Call started - printf("\nLoopback call started\n\n"); - printf("Press enter to stop..."); - while ((getc(stdin)) != '\n') - ; - - //******************************************************** - // Testing finished. Tear down Video Engine - //******************************************************** - - error = ptrViEBase->StopReceive(videoChannel); - if (error == -1) - { - printf("ERROR in ViEBase::StopReceive\n"); - return -1; - } - - error = ptrViEBase->StopSend(videoChannel); - if (error == -1) - { - printf("ERROR in ViEBase::StopSend\n"); - return -1; - } - - error = ptrViERender->StopRender(captureId); - if (error == -1) - { - printf("ERROR in ViERender::StopRender\n"); - return -1; - } - - error = ptrViERender->RemoveRenderer(captureId); - if (error == -1) - { - printf("ERROR in ViERender::RemoveRenderer\n"); - return -1; - } - - error = ptrViERender->StopRender(videoChannel); - if (error == -1) - { - printf("ERROR in ViERender::StopRender\n"); - return -1; - } - - error = ptrViERender->RemoveRenderer(videoChannel); - if (error == -1) - { - printf("ERROR in ViERender::RemoveRenderer\n"); - return -1; - } - - error = ptrViECapture->StopCapture(captureId); - if (error == -1) - { - printf("ERROR in ViECapture::StopCapture\n"); - return -1; - } - - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - if (error == -1) - { - printf("ERROR in ViECapture::DisconnectCaptureDevice\n"); - return -1; - } - - error = ptrViECapture->ReleaseCaptureDevice(captureId); - if (error == -1) - { - printf("ERROR in ViECapture::ReleaseCaptureDevice\n"); - return -1; - } - - error = ptrViEBase->DeleteChannel(videoChannel); - if (error == -1) - { - printf("ERROR in ViEBase::DeleteChannel\n"); - return -1; - } - - delete video_channel_transport; - delete extTransport; - - int remainingInterfaces = 0; - remainingInterfaces = ptrViECodec->Release(); - remainingInterfaces += ptrViECapture->Release(); - remainingInterfaces += ptrViERtpRtcp->Release(); - remainingInterfaces += ptrViERender->Release(); - remainingInterfaces += ptrViENetwork->Release(); - remainingInterfaces += ptrViEBase->Release(); - if (remainingInterfaces > 0) - { - printf("ERROR: Could not release all interfaces\n"); - return -1; - } - - bool deleted = webrtc::VideoEngine::Delete(ptrViE); - if (deleted == false) - { - printf("ERROR in VideoEngine::Delete\n"); - return -1; - } - - return 0; - - // - // END: VideoEngine 3.0 Sample Code - // - // =================================================================== -} - -int ViEAutoTest::ViELoopbackCall() -{ - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViE Autotest Loopback Call\n"); - - if (VideoEngineSampleCode(_window1, _window2) == 0) - { - ViETest::Log(" "); - ViETest::Log(" ViE Autotest Loopback Call Done"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; - } - - ViETest::Log(" "); - ViETest::Log(" ViE Autotest Loopback Call Failed"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 1; - -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_main.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_main.cc deleted file mode 100644 index 1617258547..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_main.cc +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h" - -#include "gflags/gflags.h" -#include "testing/gtest/include/gtest/gtest.h" - -#include "webrtc/test/field_trial.h" -#include "webrtc/test/testsupport/fileutils.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_window_creator.h" - -DEFINE_bool(automated, false, "Run Video engine tests in noninteractive mode."); -DEFINE_bool(auto_custom_call, false, "Run custom call directly."); -DEFINE_string(force_fieldtrials, "", - "Field trials control experimental feature code which can be forced. " - "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/" - " will assign the group Enable to field trial WebRTC-FooFeature."); - -static const std::string kStandardTest = "ViEStandardIntegrationTest"; -static const std::string kExtendedTest = "ViEExtendedIntegrationTest"; -static const std::string kApiTest = "ViEApiIntegrationTest"; - -ViEAutoTestMain::ViEAutoTestMain() { - index_to_test_method_map_[1] = "RunsBaseTestWithoutErrors"; - index_to_test_method_map_[2] = "RunsCaptureTestWithoutErrors"; - index_to_test_method_map_[3] = "RunsCodecTestWithoutErrors"; - index_to_test_method_map_[4] = "[unused]"; - index_to_test_method_map_[5] = "RunsImageProcessTestWithoutErrors"; - index_to_test_method_map_[6] = "RunsNetworkTestWithoutErrors"; - index_to_test_method_map_[7] = "RunsRenderTestWithoutErrors"; - index_to_test_method_map_[8] = "RunsRtpRtcpTestWithoutErrors"; -} - -int ViEAutoTestMain::RunTests(int argc, char** argv) { - // Initialize logging. - ViETest::Init(); - // Initialize WebRTC testing framework so paths to resources can be resolved. - webrtc::test::SetExecutablePath(argv[0]); - // Initialize the testing framework. - testing::InitGoogleTest(&argc, argv); - // AllowCommandLineParsing allows us to ignore flags passed on to us by - // Chromium build bots without having to explicitly disable them. - google::AllowCommandLineReparsing(); - // Parse remaining flags: - google::ParseCommandLineFlags(&argc, &argv, true); - // Initialize field trial - webrtc::test::InitFieldTrialsFromString(FLAGS_force_fieldtrials); - - int result; - if (FLAGS_automated) { - // Run in automated mode. -#if defined(WEBRTC_LINUX) - // All window-related tests are disabled on Linux for now. - // See https://code.google.com/p/chromium/issues/detail?id=318760 - return 0; -#endif - result = RUN_ALL_TESTS(); - } else if (FLAGS_auto_custom_call) { - // Run automated custom call. - result = RunSpecialTestCase(8); - } else { - // Run in interactive mode. - result = RunInteractiveMode(); - } - - ViETest::Terminate(); - return result; -} - -int ViEAutoTestMain::AskUserForTestCase() { - int choice; - std::string answer; - - do { - ViETest::Log("\nSpecific tests:"); - ViETest::Log("\t 0. Go back to previous menu."); - - // Print all test method choices. Assumes that map sorts on its key. - int last_valid_choice = 0; - std::map::const_iterator iterator; - for (iterator = index_to_test_method_map_.begin(); - iterator != index_to_test_method_map_.end(); - ++iterator) { - ViETest::Log("\t %d. %s", iterator->first, iterator->second.c_str()); - last_valid_choice = iterator->first; - } - - ViETest::Log("Choose specific test:"); - choice = AskUserForNumber(0, last_valid_choice); - } while (choice == kInvalidChoice); - - return choice; -} - -int ViEAutoTestMain::AskUserForNumber(int min_allowed, int max_allowed) { - int result; - if (scanf("%d", &result) <= 0) { - ViETest::Log("\nPlease enter a number instead, then hit enter."); - getc(stdin); - return kInvalidChoice; - } - getc(stdin); // Consume enter key. - - if (result < min_allowed || result > max_allowed) { - ViETest::Log("%d-%d are valid choices. Please try again.", min_allowed, - max_allowed); - return kInvalidChoice; - } - - return result; -} - -int ViEAutoTestMain::RunTestMatching(const std::string test_case, - const std::string test_method) { - testing::FLAGS_gtest_filter = test_case + "." + test_method; - return RUN_ALL_TESTS(); -} - -int ViEAutoTestMain::RunSpecificTestCaseIn(const std::string test_case_name) -{ - // If user says 0, it means don't run anything. - int specific_choice = AskUserForTestCase(); - if (specific_choice != 0){ - return RunTestMatching(test_case_name, - index_to_test_method_map_[specific_choice]); - } - return 0; -} - -int ViEAutoTestMain::RunSpecialTestCase(int choice) { - // 7-10 don't run in GTest and need to initialize by themselves. - assert(choice >= 7 && choice <= 10); - - // Create the windows - ViEWindowCreator windowCreator; - ViEAutoTestWindowManagerInterface* windowManager = - windowCreator.CreateTwoWindows(); - - // Create the test cases - ViEAutoTest vieAutoTest(windowManager->GetWindow1(), - windowManager->GetWindow2()); - - int errors = 0; - switch (choice) { - case 7: errors = vieAutoTest.ViELoopbackCall(); break; - case 8: errors = vieAutoTest.ViECustomCall(); break; - case 9: errors = vieAutoTest.ViESimulcastCall(); break; - case 10: errors = vieAutoTest.ViERecordCall(); break; - } - - windowCreator.TerminateWindows(); - return errors; -} - -int ViEAutoTestMain::RunInteractiveMode() { - ViETest::Log(" ============================== "); - ViETest::Log(" WebRTC ViE 3.x Autotest "); - ViETest::Log(" ============================== \n"); - - int choice = 0; - int errors = 0; - do { - ViETest::Log("Test types: "); - ViETest::Log("\t 0. Quit"); - ViETest::Log("\t 1. All standard tests (delivery test)"); - ViETest::Log("\t 2. All API tests"); - ViETest::Log("\t 3. All extended test"); - ViETest::Log("\t 4. Specific standard test"); - ViETest::Log("\t 5. Specific API test"); - ViETest::Log("\t 6. Specific extended test"); - ViETest::Log("\t 7. Simple loopback call"); - ViETest::Log("\t 8. Custom configure a call"); - ViETest::Log("\t 9. Simulcast in loopback"); - ViETest::Log("\t 10. Record"); - ViETest::Log("Select type of test:"); - - choice = AskUserForNumber(0, 10); - if (choice == kInvalidChoice) { - continue; - } - switch (choice) { - case 0: break; - case 1: errors = RunTestMatching(kStandardTest, "*"); break; - case 2: errors = RunTestMatching(kApiTest, "*"); break; - case 3: errors = RunTestMatching(kExtendedTest, "*"); break; - case 4: errors = RunSpecificTestCaseIn(kStandardTest); break; - case 5: errors = RunSpecificTestCaseIn(kApiTest); break; - case 6: errors = RunSpecificTestCaseIn(kExtendedTest); break; - default: errors = RunSpecialTestCase(choice); break; - } - } while (choice != 0); - - if (errors) { - ViETest::Log("Test done with errors, see ViEAutotestLog.txt for test " - "result.\n"); - return 1; - } else { - ViETest::Log("Test done without errors, see ViEAutotestLog.txt for " - "test result.\n"); - return 0; - } -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_network.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_network.cc deleted file mode 100644 index 1ccac70168..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_network.cc +++ /dev/null @@ -1,535 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_network.cc -// - -#include "webrtc/engine_configurations.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" - -#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" - -#if defined(_WIN32) -#include -#endif - -void ViEAutoTest::ViENetworkStandardTest() -{ - TbInterfaces ViE("ViENetworkStandardTest"); // Create VIE - TbCaptureDevice tbCapture(ViE); - { - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - tbCapture.ConnectTo(tbChannel.videoChannel); - - RenderCaptureDeviceAndOutputStream(&ViE, &tbChannel, &tbCapture); - - // *************************************************************** - // Engine ready. Begin testing class - // *************************************************************** - - // - // Transport - // - TbExternalTransport testTransport(*ViE.network, tbChannel.videoChannel, - NULL); - EXPECT_EQ(0, ViE.network->RegisterSendTransport( - tbChannel.videoChannel, testTransport)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); - - ViETest::Log("Call started using external transport, video should " - "see video in both windows\n"); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.network->DeregisterSendTransport( - tbChannel.videoChannel)); - - char myIpAddress[64]; - memset(myIpAddress, 0, 64); - unsigned short rtpPort = 1234; - memcpy(myIpAddress, "127.0.0.1", sizeof("127.0.0.1")); - EXPECT_EQ(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, rtpPort, rtpPort + 1, myIpAddress)); - EXPECT_EQ(0, ViE.network->SetSendDestination( - tbChannel.videoChannel, myIpAddress, rtpPort, - rtpPort + 1, rtpPort)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - ViETest::Log("Changed to WebRTC SocketTransport, you should still see " - "video in both windows\n"); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.network->SetSourceFilter( - tbChannel.videoChannel, rtpPort + 10, rtpPort + 11, myIpAddress)); - ViETest::Log("Added UDP port filter for incorrect ports, you should " - "not see video in Window2"); - AutoTestSleep(2000); - EXPECT_EQ(0, ViE.network->SetSourceFilter( - tbChannel.videoChannel, rtpPort, rtpPort + 1, "123.1.1.0")); - ViETest::Log("Added IP filter for incorrect IP address, you should not " - "see video in Window2"); - AutoTestSleep(2000); - EXPECT_EQ(0, ViE.network->SetSourceFilter( - tbChannel.videoChannel, rtpPort, rtpPort + 1, myIpAddress)); - ViETest::Log("Added IP filter for this computer, you should see video " - "in Window2 again\n"); - AutoTestSleep(kAutoTestSleepTimeMs); - - tbCapture.Disconnect(tbChannel.videoChannel); - } -} - -void ViEAutoTest::ViENetworkExtendedTest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** - - TbInterfaces ViE("ViENetworkExtendedTest"); // Create VIE - TbCaptureDevice tbCapture(ViE); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - - { - // - // ToS - // - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - tbCapture.ConnectTo(tbChannel.videoChannel); - const char* remoteIp = "192.168.200.1"; - int DSCP = 0; - bool useSetSockOpt = false; - - webrtc::VideoCodec videoCodec; - EXPECT_EQ(0, ViE.codec->GetSendCodec( - tbChannel.videoChannel, videoCodec)); - videoCodec.maxFramerate = 5; - EXPECT_EQ(0, ViE.codec->SetSendCodec( - tbChannel.videoChannel, videoCodec)); - - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** - - char myIpAddress[64]; - memset(myIpAddress, 0, 64); - unsigned short rtpPort = 9000; - EXPECT_EQ(0, ViE.network->GetLocalIP(myIpAddress, false)); - EXPECT_EQ(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, rtpPort, rtpPort + 1, myIpAddress)); - EXPECT_EQ(0, ViE.network->SetSendDestination( - tbChannel.videoChannel, remoteIp, rtpPort, rtpPort + 1, rtpPort)); - - // ToS - int tos_result = ViE.network->SetSendToS(tbChannel.videoChannel, 2); - EXPECT_EQ(0, tos_result); - if (tos_result != 0) - { - ViETest::Log("ViESetSendToS error!."); - ViETest::Log("You must be admin to run these tests."); - ViETest::Log("On Win7 and late Vista, you need to right click the " - "exe and choose"); - ViETest::Log("\"Run as administrator\"\n"); - getc(stdin); - } - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set - - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - ViETest::Log("Use Wireshark to capture the outgoing video stream and " - "verify ToS settings\n"); - ViETest::Log(" DSCP set to 0x%x\n", DSCP); - AutoTestSleep(1000); - - EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 63)); - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set - ViETest::Log(" DSCP set to 0x%x\n", DSCP); - AutoTestSleep(1000); - - EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 0)); - EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 2, true)); - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set - ViETest::Log(" DSCP set to 0x%x\n", DSCP); - AutoTestSleep(1000); - - EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 63, true)); - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set - ViETest::Log(" DSCP set to 0x%x\n", DSCP); - AutoTestSleep(1000); - - tbCapture.Disconnect(tbChannel.videoChannel); - } - - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** -} - -void ViEAutoTest::ViENetworkAPITest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** - - TbInterfaces ViE("ViENetworkAPITest"); // Create VIE - { - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecI420); - - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** - - // - // External transport - // - TbExternalTransport testTransport(*ViE.network, tbChannel.videoChannel, - NULL); - EXPECT_EQ(0, ViE.network->RegisterSendTransport( - tbChannel.videoChannel, testTransport)); - EXPECT_NE(0, ViE.network->RegisterSendTransport( - tbChannel.videoChannel, testTransport)); - - // Create a empty RTP packet. - unsigned char packet[3000]; - memset(packet, 0, sizeof(packet)); - packet[0] = 0x80; // V=2, P=0, X=0, CC=0 - packet[1] = 0x7C; // M=0, PT = 124 (I420) - - // Create a empty RTCP app packet. - unsigned char rtcpacket[3000]; - memset(rtcpacket,0, sizeof(rtcpacket)); - rtcpacket[0] = 0x80; // V=2, P=0, X=0, CC=0 - rtcpacket[1] = 0xCC; // M=0, PT = 204 (RTCP app) - rtcpacket[2] = 0x0; - rtcpacket[3] = 0x03; // 3 Octets long. - - EXPECT_NE(0, ViE.network->ReceivedRTPPacket( - tbChannel.videoChannel, packet, 1500)); - EXPECT_NE(0, ViE.network->ReceivedRTCPPacket( - tbChannel.videoChannel, rtcpacket, 1500)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.network->ReceivedRTPPacket( - tbChannel.videoChannel, packet, 1500)); - EXPECT_EQ(0, ViE.network->ReceivedRTCPPacket( - tbChannel.videoChannel, rtcpacket, 1500)); - EXPECT_NE(0, ViE.network->ReceivedRTPPacket( - tbChannel.videoChannel, packet, 11)); - EXPECT_NE(0, ViE.network->ReceivedRTPPacket( - tbChannel.videoChannel, packet, 11)); - EXPECT_EQ(0, ViE.network->ReceivedRTPPacket( - tbChannel.videoChannel, packet, 3000)); - EXPECT_EQ(0, ViE.network->ReceivedRTPPacket( - tbChannel.videoChannel, packet, 3000)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - EXPECT_NE(0, ViE.network->DeregisterSendTransport( - tbChannel.videoChannel)); // Sending - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.network->DeregisterSendTransport( - tbChannel.videoChannel)); - EXPECT_NE(0, ViE.network->DeregisterSendTransport( - tbChannel.videoChannel)); // Already deregistered - - // - // Local receiver - // - EXPECT_EQ(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, 1234, 1235, "127.0.0.1")); - EXPECT_EQ(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, 1234, 1235, "127.0.0.1")); - EXPECT_EQ(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, 1236, 1237, "127.0.0.1")); - - unsigned short rtpPort = 0; - unsigned short rtcpPort = 0; - char ipAddress[64]; - memset(ipAddress, 0, 64); - EXPECT_EQ(0, ViE.network->GetLocalReceiver( - tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_NE(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, 1234, 1235, "127.0.0.1")); - EXPECT_EQ(0, ViE.network->GetLocalReceiver( - tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - - // - // Send destination - // - EXPECT_EQ(0, ViE.network->SetSendDestination( - tbChannel.videoChannel, "127.0.0.1", 1234, 1235, 1234, 1235)); - EXPECT_EQ(0, ViE.network->SetSendDestination( - tbChannel.videoChannel, "127.0.0.1", 1236, 1237, 1234, 1235)); - - unsigned short sourceRtpPort = 0; - unsigned short sourceRtcpPort = 0; - EXPECT_EQ(0, ViE.network->GetSendDestination( - tbChannel.videoChannel, ipAddress, rtpPort, rtcpPort, - sourceRtpPort, sourceRtcpPort)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - // Not allowed while sending - EXPECT_NE(0, ViE.network->SetSendDestination( - tbChannel.videoChannel, "127.0.0.1", 1234, 1235, 1234, 1235)); - EXPECT_EQ(kViENetworkAlreadySending, ViE.base->LastError()); - - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.network->SetSendDestination( - tbChannel.videoChannel, "127.0.0.1", 1234, 1235, 1234, 1235)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.network->GetSendDestination( - tbChannel.videoChannel, ipAddress, rtpPort, rtcpPort, - sourceRtpPort, sourceRtcpPort)); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - - // - // Address information - // - - // GetSourceInfo: Tested in functional test - EXPECT_EQ(0, ViE.network->GetLocalIP(ipAddress, false)); - - // TODO(unknown): IPv6 - - // - // Filter - // - EXPECT_NE(0, ViE.network->GetSourceFilter( - tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); - EXPECT_EQ(0, ViE.network->SetSourceFilter( - tbChannel.videoChannel, 1234, 1235, "10.10.10.10")); - EXPECT_EQ(0, ViE.network->SetSourceFilter( - tbChannel.videoChannel, 1236, 1237, "127.0.0.1")); - EXPECT_EQ(0, ViE.network->GetSourceFilter( - tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); - EXPECT_EQ(0, ViE.network->SetSourceFilter( - tbChannel.videoChannel, 0, 0, NULL)); - EXPECT_NE(0, ViE.network->GetSourceFilter( - tbChannel.videoChannel, rtpPort, rtcpPort, ipAddress)); - } - { - TbVideoChannel tbChannel(ViE); // Create a video channel - EXPECT_EQ(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, 1234)); - - int DSCP = 0; - bool useSetSockOpt = false; - // SetSockOpt should work without a locally bind socket - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set - EXPECT_EQ(0, DSCP); - - // Invalid input - EXPECT_NE(0, ViE.network->SetSendToS(tbChannel.videoChannel, -1, true)); - - // Invalid input - EXPECT_NE(0, ViE.network->SetSendToS(tbChannel.videoChannel, 64, true)); - - // Valid - EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 20, true)); - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); - - EXPECT_EQ(20, DSCP); - EXPECT_TRUE(useSetSockOpt); - - // Disable - EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 0, true)); - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); - EXPECT_EQ(0, DSCP); - - char myIpAddress[64]; - memset(myIpAddress, 0, 64); - // Get local ip to be able to set ToS withtou setSockOpt - EXPECT_EQ(0, ViE.network->GetLocalIP(myIpAddress, false)); - EXPECT_EQ(0, ViE.network->SetLocalReceiver( - tbChannel.videoChannel, 1234, 1235, myIpAddress)); - - // Invalid input - EXPECT_NE(0, ViE.network->SetSendToS( - tbChannel.videoChannel, -1, false)); - EXPECT_NE(0, ViE.network->SetSendToS( - tbChannel.videoChannel, 64, false)); // Invalid input - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); // No ToS set - EXPECT_EQ(0, DSCP); - int tos_result = ViE.network->SetSendToS( - tbChannel.videoChannel, 20, false); // Valid - EXPECT_EQ(0, tos_result); - if (tos_result != 0) - { - ViETest::Log("ViESetSendToS error!."); - ViETest::Log("You must be admin to run these tests."); - ViETest::Log("On Win7 and late Vista, you need to right click the " - "exe and choose"); - ViETest::Log("\"Run as administrator\"\n"); - getc(stdin); - } - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); - EXPECT_EQ(20, DSCP); -#ifdef _WIN32 - EXPECT_FALSE(useSetSockOpt); -#else // useSetSockOpt is true on Linux and Mac - EXPECT_TRUE(useSetSockOpt); -#endif - EXPECT_EQ(0, ViE.network->SetSendToS(tbChannel.videoChannel, 0, false)); - EXPECT_EQ(0, ViE.network->GetSendToS( - tbChannel.videoChannel, DSCP, useSetSockOpt)); - EXPECT_EQ(0, DSCP); - } - { - // From qos.h. (*) -> supported by ViE - // - // #define SERVICETYPE_NOTRAFFIC 0x00000000 - // #define SERVICETYPE_BESTEFFORT 0x00000001 (*) - // #define SERVICETYPE_CONTROLLEDLOAD 0x00000002 (*) - // #define SERVICETYPE_GUARANTEED 0x00000003 (*) - // #define SERVICETYPE_NETWORK_UNAVAILABLE 0x00000004 - // #define SERVICETYPE_GENERAL_INFORMATION 0x00000005 - // #define SERVICETYPE_NOCHANGE 0x00000006 - // #define SERVICETYPE_NONCONFORMING 0x00000009 - // #define SERVICETYPE_NETWORK_CONTROL 0x0000000A - // #define SERVICETYPE_QUALITATIVE 0x0000000D (*) - // - // #define SERVICE_BESTEFFORT 0x80010000 - // #define SERVICE_CONTROLLEDLOAD 0x80020000 - // #define SERVICE_GUARANTEED 0x80040000 - // #define SERVICE_QUALITATIVE 0x80200000 - - TbVideoChannel tbChannel(ViE); // Create a video channel - - -#if defined(_WIN32) - // These tests are disabled since they currently fail on Windows. - // Exact reason is unkown. - // See https://code.google.com/p/webrtc/issues/detail?id=1266. - // TODO(mflodman): remove these APIs? - - //// No socket - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_BESTEFFORT)); - - //EXPECT_EQ(0, ViE.network->SetLocalReceiver( - // tbChannel.videoChannel, 1234)); - - //// Sender not initialized - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_BESTEFFORT)); - //EXPECT_EQ(0, ViE.network->SetSendDestination( - // tbChannel.videoChannel, "127.0.0.1", 12345)); - - //// Try to set all non-supported service types - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_NOTRAFFIC)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_NETWORK_UNAVAILABLE)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_GENERAL_INFORMATION)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_NOCHANGE)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_NONCONFORMING)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_NOTRAFFIC)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_NETWORK_CONTROL)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICE_BESTEFFORT)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICE_CONTROLLEDLOAD)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICE_GUARANTEED)); - //EXPECT_NE(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICE_QUALITATIVE)); - - //// Loop through valid service settings - //bool enabled = false; - //int serviceType = 0; - //int overrideDSCP = 0; - - //EXPECT_EQ(0, ViE.network->GetSendGQoS( - // tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); - //EXPECT_FALSE(enabled); - //EXPECT_EQ(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_BESTEFFORT)); - //EXPECT_EQ(0, ViE.network->GetSendGQoS( - // tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); - //EXPECT_TRUE(enabled); - //EXPECT_EQ(SERVICETYPE_BESTEFFORT, serviceType); - //EXPECT_FALSE(overrideDSCP); - - //EXPECT_EQ(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_CONTROLLEDLOAD)); - //EXPECT_EQ(0, ViE.network->GetSendGQoS( - // tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); - //EXPECT_TRUE(enabled); - //EXPECT_EQ(SERVICETYPE_CONTROLLEDLOAD, serviceType); - //EXPECT_FALSE(overrideDSCP); - - //EXPECT_EQ(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_GUARANTEED)); - //EXPECT_EQ(0, ViE.network->GetSendGQoS( - // tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); - //EXPECT_TRUE(enabled); - //EXPECT_EQ(SERVICETYPE_GUARANTEED, serviceType); - //EXPECT_FALSE(overrideDSCP); - - //EXPECT_EQ(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, true, SERVICETYPE_QUALITATIVE)); - //EXPECT_EQ(0, ViE.network->GetSendGQoS( - // tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); - //EXPECT_TRUE(enabled); - //EXPECT_EQ(SERVICETYPE_QUALITATIVE, serviceType); - //EXPECT_FALSE(overrideDSCP); - - //EXPECT_EQ(0, ViE.network->SetSendGQoS( - // tbChannel.videoChannel, false, SERVICETYPE_QUALITATIVE)); - //EXPECT_EQ(0, ViE.network->GetSendGQoS( - // tbChannel.videoChannel, enabled, serviceType, overrideDSCP)); - //EXPECT_FALSE(enabled); -#endif - } - { - // - // MTU and packet burst - // - // Create a video channel - TbVideoChannel tbChannel(ViE); - // Invalid input - EXPECT_NE(0, ViE.network->SetMTU(tbChannel.videoChannel, 1600)); - // Valid input - EXPECT_EQ(0, ViE.network->SetMTU(tbChannel.videoChannel, 800)); - } - - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_record.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_record.cc deleted file mode 100644 index 947939309b..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_record.cc +++ /dev/null @@ -1,597 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_record.cc -// -// This code is also used as sample code for ViE 3.0 -// - -#include -#include - -#include "webrtc/common_types.h" -#include "webrtc/system_wrappers/interface/tick_util.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/voice_engine/include/voe_base.h" -#include "webrtc/voice_engine/include/voe_network.h" -#include "webrtc/voice_engine/include/voe_rtp_rtcp.h" - -#define VCM_RED_PAYLOAD_TYPE 96 -#define VCM_ULPFEC_PAYLOAD_TYPE 97 -#define DEFAULT_AUDIO_PORT 11113 -#define DEFAULT_AUDIO_CODEC "ISAC" -#define DEFAULT_VIDEO_CODEC_WIDTH 640 -#define DEFAULT_VIDEO_CODEC_HEIGHT 480 -#define DEFAULT_VIDEO_CODEC_START_RATE 1000 -#define DEFAULT_RECORDING_FOLDER "RECORDING" -#define DEFAULT_RECORDING_AUDIO "/audio_debug.aec" -#define DEFAULT_RECORDING_VIDEO "/video_debug.yuv" -#define DEFAULT_RECORDING_AUDIO_RTP "/audio_rtpdump.rtp" -#define DEFAULT_RECORDING_VIDEO_RTP "/video_rtpdump.rtp" - -bool GetAudioDevices(webrtc::VoEBase* voe_base, - webrtc::VoEHardware* voe_hardware, - char* recording_device_name, - int& recording_device_index, - char* playbackDeviceName, - int& playback_device_index); -bool GetAudioCodecRecord(webrtc::VoECodec* voe_codec, - webrtc::CodecInst& audio_codec); - -int VideoEngineSampleRecordCode(void* window1, void* window2) { - int error = 0; - // Audio settings. - int audio_tx_port = DEFAULT_AUDIO_PORT; - int audio_rx_port = DEFAULT_AUDIO_PORT; - webrtc::CodecInst audio_codec; - int audio_channel = -1; - int audio_capture_device_index = -1; - int audio_playback_device_index = -1; - const unsigned int KMaxDeviceNameLength = 128; - const unsigned int KMaxUniqueIdLength = 256; - char deviceName[KMaxDeviceNameLength]; - char audio_capture_device_name[KMaxUniqueIdLength] = ""; - char audio_playbackDeviceName[KMaxUniqueIdLength] = ""; - - // Network settings. - const char* ipAddress = "127.0.0.1"; - const int rtpPort = 6000; - - // - // Create a VideoEngine instance - // - webrtc::VideoEngine* ptrViE = NULL; - ptrViE = webrtc::VideoEngine::Create(); - if (ptrViE == NULL) { - printf("ERROR in VideoEngine::Create\n"); - return -1; - } - - error = ptrViE->SetTraceFilter(webrtc::kTraceAll); - if (error == -1) { - printf("ERROR in VideoEngine::SetTraceLevel\n"); - return -1; - } - - std::string trace_file = - ViETest::GetResultOutputPath() + "ViERecordCall_trace.txt"; - error = ptrViE->SetTraceFile(trace_file.c_str()); - if (error == -1) { - printf("ERROR in VideoEngine::SetTraceFile\n"); - return -1; - } - - // - // Create a VoE instance - // - webrtc::VoiceEngine* voe = webrtc::VoiceEngine::Create(); - // - // Init VideoEngine and create a channel - // - webrtc::ViEBase* ptrViEBase = webrtc::ViEBase::GetInterface(ptrViE); - if (ptrViEBase == NULL) { - printf("ERROR in ViEBase::GetInterface\n"); - return -1; - } - - error = ptrViEBase->Init(); - if (error == -1) { - printf("ERROR in ViEBase::Init\n"); - return -1; - } - - webrtc::VoEBase* voe_base = webrtc::VoEBase::GetInterface(voe); - if (voe_base == NULL) { - printf("ERROR in VoEBase::GetInterface\n"); - return -1; - } - error = voe_base->Init(); - if (error == -1) { - printf("ERROR in VoEBase::Init\n"); - return -1; - } - - int videoChannel = -1; - error = ptrViEBase->CreateChannel(videoChannel); - if (error == -1) { - printf("ERROR in ViEBase::CreateChannel\n"); - return -1; - } - - webrtc::VoEHardware* voe_hardware = - webrtc::VoEHardware::GetInterface(voe); - webrtc::VoECodec* voe_codec = webrtc::VoECodec::GetInterface(voe); - webrtc::VoEAudioProcessing* voe_apm = - webrtc::VoEAudioProcessing::GetInterface(voe); - webrtc::VoENetwork* voe_network = - webrtc::VoENetwork::GetInterface(voe); - - // Get the audio device for the call. - memset(audio_capture_device_name, 0, KMaxUniqueIdLength); - memset(audio_playbackDeviceName, 0, KMaxUniqueIdLength); - GetAudioDevices(voe_base, voe_hardware, audio_capture_device_name, - audio_capture_device_index, audio_playbackDeviceName, - audio_playback_device_index); - - // Get the audio codec for the call. - memset(static_cast(&audio_codec), 0, sizeof(audio_codec)); - GetAudioCodecRecord(voe_codec, audio_codec); - - audio_channel = voe_base->CreateChannel(); - - rtc::scoped_ptr voice_channel_transport( - new webrtc::test::VoiceChannelTransport(voe_network, audio_channel)); - - voice_channel_transport->SetSendDestination(ipAddress, audio_tx_port); - voice_channel_transport->SetLocalReceiver(audio_rx_port); - - voe_hardware->SetRecordingDevice(audio_capture_device_index); - voe_hardware->SetPlayoutDevice(audio_playback_device_index); - voe_codec->SetSendCodec(audio_channel, audio_codec); - voe_apm->SetAgcStatus(true, webrtc::kAgcDefault); - voe_apm->SetNsStatus(true, webrtc::kNsHighSuppression); - - // - // List available capture devices, allocate and connect. - // - webrtc::ViECapture* ptrViECapture = - webrtc::ViECapture::GetInterface(ptrViE); - if (ptrViECapture == NULL) { - printf("ERROR in ViECapture::GetInterface\n"); - return -1; - } - - webrtc::VoERTP_RTCP* ptrVoERtpRtcp = - webrtc::VoERTP_RTCP::GetInterface(voe); - if (ptrVoERtpRtcp == NULL) { - printf("ERROR in VoERTP_RTCP::GetInterface\n"); - return -1; - } - - memset(deviceName, 0, KMaxDeviceNameLength); - char uniqueId[KMaxUniqueIdLength]; - memset(uniqueId, 0, KMaxUniqueIdLength); - - printf("Available capture devices:\n"); - int captureIdx = 0; - for (captureIdx = 0; - captureIdx < ptrViECapture->NumberOfCaptureDevices(); - captureIdx++) { - memset(deviceName, 0, KMaxDeviceNameLength); - memset(uniqueId, 0, KMaxUniqueIdLength); - - error = ptrViECapture->GetCaptureDevice(captureIdx, deviceName, - KMaxDeviceNameLength, uniqueId, - KMaxUniqueIdLength); - if (error == -1) { - printf("ERROR in ViECapture::GetCaptureDevice\n"); - return -1; - } - printf("\t %d. %s\n", captureIdx + 1, deviceName); - } - printf("\nChoose capture device: "); -#ifdef WEBRTC_ANDROID - captureIdx = 0; - printf("0\n"); -#else - if (scanf("%d", &captureIdx) != 1) { - printf("Error in scanf()\n"); - return -1; - } - getc(stdin); - captureIdx = captureIdx - 1; // Compensate for idx start at 1. -#endif - error = ptrViECapture->GetCaptureDevice(captureIdx, deviceName, - KMaxDeviceNameLength, uniqueId, - KMaxUniqueIdLength); - if (error == -1) { - printf("ERROR in ViECapture::GetCaptureDevice\n"); - return -1; - } - - int captureId = 0; - error = ptrViECapture->AllocateCaptureDevice(uniqueId, KMaxUniqueIdLength, - captureId); - if (error == -1) { - printf("ERROR in ViECapture::AllocateCaptureDevice\n"); - return -1; - } - - error = ptrViECapture->ConnectCaptureDevice(captureId, videoChannel); - if (error == -1) { - printf("ERROR in ViECapture::ConnectCaptureDevice\n"); - return -1; - } - - error = ptrViECapture->StartCapture(captureId); - if (error == -1) { - printf("ERROR in ViECapture::StartCapture\n"); - return -1; - } - - // - // RTP/RTCP settings - // - webrtc::ViERTP_RTCP* ptrViERtpRtcp = - webrtc::ViERTP_RTCP::GetInterface(ptrViE); - if (ptrViERtpRtcp == NULL) { - printf("ERROR in ViERTP_RTCP::GetInterface\n"); - return -1; - } - - error = ptrViERtpRtcp->SetRTCPStatus(videoChannel, - webrtc::kRtcpCompound_RFC4585); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n"); - return -1; - } - - error = ptrViERtpRtcp->SetKeyFrameRequestMethod( - videoChannel, webrtc::kViEKeyFrameRequestPliRtcp); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetKeyFrameRequestMethod\n"); - return -1; - } - - error = ptrViERtpRtcp->SetRembStatus(videoChannel, true, true); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetTMMBRStatus\n"); - return -1; - } - - // - // Set up rendering - // - webrtc::ViERender* ptrViERender = webrtc::ViERender::GetInterface(ptrViE); - if (ptrViERender == NULL) { - printf("ERROR in ViERender::GetInterface\n"); - return -1; - } - - error = ptrViERender->AddRenderer(captureId, window1, 0, 0.0, 0.0, 1.0, 1.0); - if (error == -1) { - printf("ERROR in ViERender::AddRenderer\n"); - return -1; - } - - error = ptrViERender->StartRender(captureId); - if (error == -1) { - printf("ERROR in ViERender::StartRender\n"); - return -1; - } - - error = ptrViERender->AddRenderer(videoChannel, window2, 1, 0.0, 0.0, 1.0, - 1.0); - if (error == -1) { - printf("ERROR in ViERender::AddRenderer\n"); - return -1; - } - - error = ptrViERender->StartRender(videoChannel); - if (error == -1) { - printf("ERROR in ViERender::StartRender\n"); - return -1; - } - - // - // Setup codecs - // - webrtc::ViECodec* ptrViECodec = webrtc::ViECodec::GetInterface(ptrViE); - if (ptrViECodec == NULL) { - printf("ERROR in ViECodec::GetInterface\n"); - return -1; - } - - webrtc::VideoCodec videoCodec; - memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); - int codecIdx = 0; - -#ifdef WEBRTC_ANDROID - codecIdx = 0; - printf("0\n"); -#else - codecIdx = 0; // Compensate for idx start at 1. -#endif - - error = ptrViECodec->GetCodec(codecIdx, videoCodec); - if (error == -1) { - printf("ERROR in ViECodec::GetCodec\n"); - return -1; - } - - // Set spatial resolution option - videoCodec.width = DEFAULT_VIDEO_CODEC_WIDTH; - videoCodec.height = DEFAULT_VIDEO_CODEC_HEIGHT; - - // Set start bit rate - videoCodec.startBitrate = DEFAULT_VIDEO_CODEC_START_RATE; - - error = ptrViECodec->SetSendCodec(videoChannel, videoCodec); - if (error == -1) { - printf("ERROR in ViECodec::SetSendCodec\n"); - return -1; - } - - // - // Address settings - // - webrtc::ViENetwork* ptrViENetwork = - webrtc::ViENetwork::GetInterface(ptrViE); - if (ptrViENetwork == NULL) { - printf("ERROR in ViENetwork::GetInterface\n"); - return -1; - } - webrtc::test::VideoChannelTransport* video_channel_transport = - new webrtc::test::VideoChannelTransport(ptrViENetwork, videoChannel); - - error = video_channel_transport->SetSendDestination(ipAddress, rtpPort); - if (error == -1) { - printf("ERROR in SetSendDestination\n"); - return -1; - } - error = video_channel_transport->SetLocalReceiver(rtpPort); - if (error == -1) { - printf("ERROR in SetLocalReceiver\n"); - return -1; - } - - std::string str; - int enable_labeling = 0; - std::cout << std::endl; - std::cout << "Do you want to label this recording?" << std::endl; - std::cout << "0. No (default)." << std::endl; - std::cout << "1. This call will be labeled on the fly." << std::endl; - std::getline(std::cin, str); - enable_labeling = atoi(str.c_str()); - - uint32_t folder_time = static_cast - (webrtc::TickTime::MillisecondTimestamp()); - std::stringstream folder_time_str; - folder_time_str << folder_time; - const std::string folder_name = "recording" + folder_time_str.str(); - printf("recording name = %s\n", folder_name.c_str()); - // TODO(mikhal): use file_utils. -#ifdef WIN32 - _mkdir(folder_name.c_str()); -#else - mkdir(folder_name.c_str(), 0777); -#endif - const std::string audio_filename = folder_name + DEFAULT_RECORDING_AUDIO; - const std::string video_filename = folder_name + DEFAULT_RECORDING_VIDEO; - const std::string audio_rtp_filename = folder_name + - DEFAULT_RECORDING_AUDIO_RTP; - const std::string video_rtp_filename = folder_name + - DEFAULT_RECORDING_VIDEO_RTP; - std::fstream timing; - if (enable_labeling == 1) { - std::cout << "Press enter to stamp current time."<< std::endl; - std::string timing_file = folder_name + "/labeling.txt"; - timing.open(timing_file.c_str(), std::fstream::out | std::fstream::app); - } - printf("\nPress enter to start recording\n"); - std::getline(std::cin, str); - printf("\nRecording started\n\n"); - - error = ptrViEBase->StartReceive(videoChannel); - if (error == -1) { - printf("ERROR in ViENetwork::StartReceive\n"); - return -1; - } - - error = ptrViEBase->StartSend(videoChannel); - if (error == -1) { - printf("ERROR in ViENetwork::StartSend\n"); - return -1; - } - error = voe_base->StartSend(audio_channel); - if (error == -1) { - printf("ERROR in VoENetwork::StartSend\n"); - return -1; - } - - // Engine started - - voe_apm->StartDebugRecording(audio_filename.c_str()); - ptrViECodec->StartDebugRecording(videoChannel, video_filename.c_str()); - ptrViERtpRtcp->StartRTPDump(videoChannel, - video_rtp_filename.c_str(), webrtc::kRtpOutgoing); - ptrVoERtpRtcp->StartRTPDump(audio_channel, - audio_rtp_filename.c_str(), webrtc::kRtpOutgoing); - printf("Press s + enter to stop..."); - int64_t clock_time; - if (enable_labeling == 1) { - clock_time = webrtc::TickTime::MillisecondTimestamp(); - timing << clock_time << std::endl; - } - char c = getc(stdin); - fflush(stdin); - while (c != 's') { - if (c == '\n' && enable_labeling == 1) { - clock_time = webrtc::TickTime::MillisecondTimestamp(); - timing << clock_time << std::endl; - } - c = getc(stdin); - } - if (enable_labeling == 1) { - clock_time = webrtc::TickTime::MillisecondTimestamp(); - timing << clock_time << std::endl; - } - - ptrViERtpRtcp->StopRTPDump(videoChannel, webrtc::kRtpOutgoing); - ptrVoERtpRtcp->StopRTPDump(audio_channel, webrtc::kRtpOutgoing); - voe_apm->StopDebugRecording(); - ptrViECodec->StopDebugRecording(videoChannel); - if (enable_labeling == 1) - timing.close(); - - // Recording finished. Tear down Video Engine. - - error = ptrViEBase->StopReceive(videoChannel); - if (error == -1) { - printf("ERROR in ViEBase::StopReceive\n"); - return -1; - } - - error = ptrViEBase->StopSend(videoChannel); - if (error == -1) { - printf("ERROR in ViEBase::StopSend\n"); - return -1; - } - error = voe_base->StopSend(audio_channel); - - error = ptrViERender->StopRender(captureId); - if (error == -1) { - printf("ERROR in ViERender::StopRender\n"); - return -1; - } - - error = ptrViERender->RemoveRenderer(captureId); - if (error == -1) { - printf("ERROR in ViERender::RemoveRenderer\n"); - return -1; - } - - error = ptrViERender->StopRender(videoChannel); - if (error == -1) { - printf("ERROR in ViERender::StopRender\n"); - return -1; - } - - error = ptrViERender->RemoveRenderer(videoChannel); - if (error == -1) { - printf("ERROR in ViERender::RemoveRenderer\n"); - return -1; - } - - error = ptrViECapture->StopCapture(captureId); - if (error == -1) { - printf("ERROR in ViECapture::StopCapture\n"); - return -1; - } - - error = ptrViECapture->DisconnectCaptureDevice(videoChannel); - if (error == -1) { - printf("ERROR in ViECapture::DisconnectCaptureDevice\n"); - return -1; - } - - error = ptrViECapture->ReleaseCaptureDevice(captureId); - if (error == -1) { - printf("ERROR in ViECapture::ReleaseCaptureDevice\n"); - return -1; - } - - error = ptrViEBase->DeleteChannel(videoChannel); - if (error == -1) { - printf("ERROR in ViEBase::DeleteChannel\n"); - return -1; - } - delete video_channel_transport; - - int remainingInterfaces = 0; - remainingInterfaces = ptrViECodec->Release(); - remainingInterfaces += ptrViECapture->Release(); - remainingInterfaces += ptrViERtpRtcp->Release(); - remainingInterfaces += ptrViERender->Release(); - remainingInterfaces += ptrViENetwork->Release(); - remainingInterfaces += ptrViEBase->Release(); - if (remainingInterfaces > 0) { - printf("ERROR: Could not release all interfaces\n"); - return -1; - } - bool deleted = webrtc::VideoEngine::Delete(ptrViE); - if (deleted == false) { - printf("ERROR in VideoEngine::Delete\n"); - return -1; - } - return 0; -} - - -// TODO(mikhal): Place above functionality under this class. -int ViEAutoTest::ViERecordCall() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViE Record Call\n"); - - if (VideoEngineSampleRecordCode(_window1, _window2) == 0) { - ViETest::Log(" "); - ViETest::Log(" ViE Autotest Record Call Done"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 0; - } - - ViETest::Log(" "); - ViETest::Log(" ViE Autotest Record Call Failed"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 1; -} - -bool GetAudioCodecRecord(webrtc::VoECodec* voe_codec, - webrtc::CodecInst& audio_codec) { - int error = 0; - int number_of_errors = 0; - memset(&audio_codec, 0, sizeof(webrtc::CodecInst)); - - while (1) { - int codec_idx = 0; - int default_codec_idx = 0; - for (codec_idx = 0; codec_idx < voe_codec->NumOfCodecs(); codec_idx++) { - error = voe_codec->GetCodec(codec_idx, audio_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - - // Test for default codec index. - if (strcmp(audio_codec.plname, DEFAULT_AUDIO_CODEC) == 0) { - default_codec_idx = codec_idx; - } - } - error = voe_codec->GetCodec(default_codec_idx, audio_codec); - number_of_errors += ViETest::TestError(error == 0, - "ERROR: %s at line %d", - __FUNCTION__, __LINE__); - return true; - } - assert(false); - return false; -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_render.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_render.cc deleted file mode 100644 index c30fbf32a4..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_render.cc +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_render.cc -// - -#include "webrtc/base/format_macros.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" - -#include "webrtc/modules/video_render/include/video_render.h" - -#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" -#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" - -#if defined(WIN32) -#include -#include -#include -#elif defined(WEBRTC_LINUX) - //From windgi.h - #undef RGB - #define RGB(r,g,b) ((unsigned long)(((unsigned char)(r)|((unsigned short)((unsigned char)(g))<<8))|(((unsigned long)(unsigned char)(b))<<16))) - //From ddraw.h -/* typedef struct _DDCOLORKEY - { - DWORD dwColorSpaceLowValue; // low boundary of color space that is to - DWORD dwColorSpaceHighValue; // high boundary of color space that is - } DDCOLORKEY;*/ -#elif defined(WEBRTC_MAC) -#endif - -class ViEAutoTestExternalRenderer: public webrtc::ExternalRenderer -{ -public: - ViEAutoTestExternalRenderer() : - _width(0), - _height(0) - { - } - virtual int FrameSizeChange(unsigned int width, unsigned int height, - unsigned int numberOfStreams) - { - _width = width; - _height = height; - return 0; - } - - virtual int DeliverFrame(unsigned char* buffer, - size_t bufferSize, - uint32_t time_stamp, - int64_t ntp_time_ms, - int64_t render_time, - void* /*handle*/) { - if (bufferSize != CalcBufferSize(webrtc::kI420, _width, _height)) { - ViETest::Log("Incorrect render buffer received, of length = %" PRIuS - "\n", bufferSize); - return 0; - } - return 0; - } - - virtual int DeliverI420Frame(const webrtc::I420VideoFrame& webrtc_frame) { - EXPECT_EQ(webrtc_frame.width(), _width); - EXPECT_EQ(webrtc_frame.height(), _height); - return 0; - } - - virtual bool IsTextureSupported() { return false; } - -public: - virtual ~ViEAutoTestExternalRenderer() - { - } -private: - int _width, _height; -}; - -void ViEAutoTest::ViERenderStandardTest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** - int rtpPort = 6000; - - TbInterfaces ViE("ViERenderStandardTest"); - - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - TbCaptureDevice tbCapture(ViE); // Create a capture device - tbCapture.ConnectTo(tbChannel.videoChannel); - tbChannel.StartReceive(rtpPort); - tbChannel.StartSend(rtpPort); - - EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm2)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); - - ViETest::Log("\nCapture device is renderered in Window 1"); - ViETest::Log("Remote stream is renderered in Window 2"); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - - // PIP and full screen rendering is not supported on Android -#ifndef WEBRTC_ANDROID - EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, _window2, 0, 0.75, 0.75, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - - ViETest::Log("\nCapture device is now rendered in Window 2, PiP."); - ViETest::Log("Switching to full screen rendering in %d seconds.\n", - kAutoTestSleepTimeMs / 1000); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm2)); - - // Destroy render module and create new in full screen mode - webrtc::VideoRender::DestroyVideoRender(_vrm1); - _vrm1 = NULL; - _vrm1 = webrtc::VideoRender::CreateVideoRender( - 4563, _window1, true, _renderType); - EXPECT_TRUE(_vrm1 != NULL); - - EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, _window1, 0, 0.75f, 0.75f, 1.0f, 1.0f)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbChannel.videoChannel, _window1, 1, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); - - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); - - // Destroy full screen render module and create new in normal mode - webrtc::VideoRender::DestroyVideoRender(_vrm1); - _vrm1 = NULL; - _vrm1 = webrtc::VideoRender::CreateVideoRender( - 4561, _window1, false, _renderType); - EXPECT_TRUE(_vrm1 != NULL); -#endif - - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** - - - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** - tbCapture.Disconnect(tbChannel.videoChannel); -} - -void ViEAutoTest::ViERenderExtendedTest() -{ - int rtpPort = 6000; - - TbInterfaces ViE("ViERenderExtendedTest"); - - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - TbCaptureDevice tbCapture(ViE); // Create a capture device - tbCapture.ConnectTo(tbChannel.videoChannel); - tbChannel.StartReceive(rtpPort); - tbChannel.StartSend(rtpPort); - - EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm2)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); - - ViETest::Log("\nCapture device is renderered in Window 1"); - ViETest::Log("Remote stream is renderered in Window 2"); - AutoTestSleep(kAutoTestSleepTimeMs); - -#ifdef _WIN32 - ViETest::Log("\nConfiguring Window2"); - ViETest::Log("you will see video only in first quadrant"); - EXPECT_EQ(0, ViE.render->ConfigureRender( - tbChannel.videoChannel, 0, 0.0f, 0.0f, 0.5f, 0.5f)); - AutoTestSleep(kAutoTestSleepTimeMs); - - ViETest::Log("you will see video only in fourth quadrant"); - EXPECT_EQ(0, ViE.render->ConfigureRender( - tbChannel.videoChannel, 0, 0.5f, 0.5f, 1.0f, 1.0f)); - AutoTestSleep(kAutoTestSleepTimeMs); - - ViETest::Log("normal video on Window2"); - EXPECT_EQ(0, ViE.render->ConfigureRender( - tbChannel.videoChannel, 0, 0.0f, 0.0f, 1.0f, 1.0f)); - AutoTestSleep(kAutoTestSleepTimeMs); -#endif - - ViETest::Log("\nEnabling Full Screen render in 5 sec"); - - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm2)); - - // Destroy render module and create new in full screen mode - webrtc::VideoRender::DestroyVideoRender(_vrm1); - _vrm1 = NULL; - _vrm1 = webrtc::VideoRender::CreateVideoRender( - 4563, _window1, true, _renderType); - EXPECT_TRUE(_vrm1 != NULL); - - EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, _window1, 0, 0.0f, 0.0f, 1.0f, 1.0f)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - AutoTestSleep(kAutoTestSleepTimeMs); - - ViETest::Log("\nStop renderer"); - EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId)); - ViETest::Log("\nRemove renderer"); - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - - EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); - - // Destroy full screen render module and create new for external rendering - webrtc::VideoRender::DestroyVideoRender(_vrm1); - _vrm1 = NULL; - _vrm1 = webrtc::VideoRender::CreateVideoRender(4564, NULL, false, - _renderType); - EXPECT_TRUE(_vrm1 != NULL); - - EXPECT_EQ(0, ViE.render->RegisterVideoRenderModule(*_vrm1)); - - ViETest::Log("\nExternal Render Test"); - ViEAutoTestExternalRenderer externalRenderObj; - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, webrtc::kVideoI420, &externalRenderObj)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.render->StopRender(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->DeRegisterVideoRenderModule(*_vrm1)); - - // Destroy render module for external rendering and create new in normal - // mode - webrtc::VideoRender::DestroyVideoRender(_vrm1); - _vrm1 = NULL; - _vrm1 = webrtc::VideoRender::CreateVideoRender( - 4561, _window1, false, _renderType); - EXPECT_TRUE(_vrm1 != NULL); - tbCapture.Disconnect(tbChannel.videoChannel); -} - -void ViEAutoTest::ViERenderAPITest() { - TbInterfaces ViE("ViERenderAPITest"); - - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - TbCaptureDevice tbCapture(ViE); - tbCapture.ConnectTo(tbChannel.videoChannel); - tbChannel.StartReceive(); - tbChannel.StartSend(); - - EXPECT_EQ(0, ViE.render->AddRenderer( - tbCapture.captureId, _window1, 0, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbCapture.captureId)); - EXPECT_EQ(0, ViE.render->AddRenderer( - tbChannel.videoChannel, _window2, 1, 0.0, 0.0, 1.0, 1.0)); - EXPECT_EQ(0, ViE.render->StartRender(tbChannel.videoChannel)); - - // Test setting HW render delay. - // Already started. - EXPECT_EQ(-1, ViE.render->SetExpectedRenderDelay(tbChannel.videoChannel, 50)); - EXPECT_EQ(0, ViE.render->StopRender(tbChannel.videoChannel)); - - // Invalid values. - EXPECT_EQ(-1, ViE.render->SetExpectedRenderDelay(tbChannel.videoChannel, 9)); - EXPECT_EQ(-1, ViE.render->SetExpectedRenderDelay(tbChannel.videoChannel, - 501)); - // Valid values. - EXPECT_EQ(0, ViE.render->SetExpectedRenderDelay(tbChannel.videoChannel, 11)); - EXPECT_EQ(0, ViE.render->SetExpectedRenderDelay(tbChannel.videoChannel, 499)); - - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.render->RemoveRenderer(tbCapture.captureId)); - tbCapture.Disconnect(tbChannel.videoChannel); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc deleted file mode 100644 index ee9c6a0628..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_rtp_rtcp.cc +++ /dev/null @@ -1,919 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include - -#include "webrtc/engine_configurations.h" -#include "webrtc/test/testsupport/fileutils.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" - -class ViERtpObserver: public webrtc::ViERTPObserver -{ -public: - ViERtpObserver() - { - } - virtual ~ViERtpObserver() - { - } - - virtual void IncomingSSRCChanged(const int videoChannel, - const unsigned int SSRC) - { - } - virtual void IncomingCSRCChanged(const int videoChannel, - const unsigned int CSRC, const bool added) - { - } -}; - -void ViEAutoTest::ViERtpRtcpStandardTest() -{ - // *************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - // *************************************************************** - - // Create VIE - TbInterfaces ViE("ViERtpRtcpStandardTest"); - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - - // Create a capture device - TbCaptureDevice tbCapture(ViE); - tbCapture.ConnectTo(tbChannel.videoChannel); - - ViETest::Log("\n"); - TbExternalTransport myTransport(*(ViE.network), tbChannel.videoChannel, - NULL); - - ViE.network->DeregisterSendTransport(tbChannel.videoChannel); - EXPECT_EQ(0, ViE.network->RegisterSendTransport( - tbChannel.videoChannel, myTransport)); - - // *************************************************************** - // Engine ready. Begin testing class - // *************************************************************** - unsigned short startSequenceNumber = 12345; - ViETest::Log("Set start sequence number: %u", startSequenceNumber); - EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, startSequenceNumber)); - const unsigned int kVideoSsrc = 123456; - // Set an SSRC to avoid issues with collisions. - EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC(tbChannel.videoChannel, kVideoSsrc, - webrtc::kViEStreamTypeNormal, 0)); - - myTransport.EnableSequenceNumberCheck(); - - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - AutoTestSleep(2000); - - unsigned short receivedSequenceNumber = - myTransport.GetFirstSequenceNumber(); - ViETest::Log("First received sequence number: %u\n", - receivedSequenceNumber); - EXPECT_EQ(startSequenceNumber, receivedSequenceNumber); - - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - - // - // RTCP CName - // - ViETest::Log("Testing CName\n"); - const char* sendCName = "ViEAutoTestCName\0"; - EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPCName(tbChannel.videoChannel, sendCName)); - - char returnCName[webrtc::ViERTP_RTCP::KMaxRTCPCNameLength]; - memset(returnCName, 0, webrtc::ViERTP_RTCP::KMaxRTCPCNameLength); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPCName( - tbChannel.videoChannel, returnCName)); - EXPECT_STRCASEEQ(sendCName, returnCName); - - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - AutoTestSleep(1000); - - if (FLAGS_include_timing_dependent_tests) { - char remoteCName[webrtc::ViERTP_RTCP::KMaxRTCPCNameLength]; - memset(remoteCName, 0, webrtc::ViERTP_RTCP::KMaxRTCPCNameLength); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRemoteRTCPCName( - tbChannel.videoChannel, remoteCName)); - EXPECT_STRCASEEQ(sendCName, remoteCName); - } - - - // - // Pacing - // - webrtc::RtcpStatistics received; - int64_t recRttMs = 0; - unsigned int sentTotalBitrate = 0; - unsigned int sentVideoBitrate = 0; - unsigned int sentFecBitrate = 0; - unsigned int sentNackBitrate = 0; - - ViETest::Log("Testing Pacing\n"); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - - myTransport.ClearStats(); - - EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - NetworkParameters network; - network.packet_loss_rate = 0; - network.loss_model = kUniformLoss; - myTransport.SetNetworkParameters(network); - - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.rtp_rtcp->GetReceiveChannelRtcpStatistics( - tbChannel.videoChannel, received, recRttMs)); - EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( - tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, - sentFecBitrate, sentNackBitrate)); - - int num_rtp_packets = 0; - int num_dropped_packets = 0; - int num_rtcp_packets = 0; - std::map packet_counters; - myTransport.GetStats(num_rtp_packets, num_dropped_packets, num_rtcp_packets, - &packet_counters); - EXPECT_GT(num_rtp_packets, 0); - EXPECT_EQ(num_dropped_packets, 0); - EXPECT_GT(num_rtcp_packets, 0); - EXPECT_GT(sentTotalBitrate, 0u); - EXPECT_EQ(sentNackBitrate, 0u); - EXPECT_EQ(received.cumulative_lost, 0u); - - // - // RTX - // - ViETest::Log("Testing NACK over RTX\n"); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - - myTransport.ClearStats(); - - const uint8_t kRtxPayloadType = 96; - const uint8_t kPayloadType = 100; - // Temporarily disable pacing. - EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( - tbChannel.videoChannel, false)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRtxSendPayloadType( - tbChannel.videoChannel, kRtxPayloadType, kPayloadType)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRtxReceivePayloadType( - tbChannel.videoChannel, kRtxPayloadType, kPayloadType)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC(tbChannel.videoChannel, 1234, - webrtc::kViEStreamTypeRtx, 0)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRemoteSSRCType(tbChannel.videoChannel, - webrtc::kViEStreamTypeRtx, - 1234)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, startSequenceNumber)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - // Make sure the first key frame gets through. - AutoTestSleep(100); - const int kPacketLossRate = 20; - network.packet_loss_rate = kPacketLossRate; - network.loss_model = kUniformLoss; - myTransport.SetNetworkParameters(network); - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.rtp_rtcp->GetReceiveChannelRtcpStatistics( - tbChannel.videoChannel, received, recRttMs)); - EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( - tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, - sentFecBitrate, sentNackBitrate)); - - packet_counters.clear(); - myTransport.GetStats(num_rtp_packets, num_dropped_packets, num_rtcp_packets, - &packet_counters); - EXPECT_GT(num_rtp_packets, 0); - EXPECT_GT(num_dropped_packets, 0); - EXPECT_GT(num_rtcp_packets, 0); - EXPECT_GT(packet_counters[kRtxPayloadType], 0); - - // Make sure we have lost packets and that they were retransmitted. - // TODO(holmer): Disabled due to being flaky. Could be a bug in our stats. - // EXPECT_GT(recCumulativeLost, 0u); - EXPECT_GT(sentTotalBitrate, 0u); - EXPECT_GT(sentNackBitrate, 0u); - - // - // Statistics - // - // Stop and restart to clear stats - ViETest::Log("Testing statistics\n"); - EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, false)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - - myTransport.ClearStats(); - network.packet_loss_rate = kPacketLossRate; - network.loss_model = kUniformLoss; - myTransport.SetNetworkParameters(network); - - // Start send to verify sending stats - - EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, startSequenceNumber)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - webrtc::RtcpStatistics sent; - int64_t sentRttMs = 0; - - // Fraction lost is a transient value that can get reset after a new rtcp - // report block. Make regular polls to make sure it is propagated. - // TODO(sprang): Replace with callbacks, when those are fully implemented. - int time_to_sleep = kAutoTestSleepTimeMs; - bool got_send_channel_frac_lost = false; - bool got_receive_channel_frac_lost = false; - while (time_to_sleep > 0) { - AutoTestSleep(500); - time_to_sleep -= 500; - EXPECT_EQ(0, - ViE.rtp_rtcp->GetSendChannelRtcpStatistics( - tbChannel.videoChannel, sent, sentRttMs)); - got_send_channel_frac_lost |= sent.fraction_lost > 0; - EXPECT_EQ(0, - ViE.rtp_rtcp->GetReceiveChannelRtcpStatistics( - tbChannel.videoChannel, received, recRttMs)); - got_receive_channel_frac_lost |= received.fraction_lost > 0; - } - EXPECT_TRUE(got_send_channel_frac_lost); - EXPECT_TRUE(got_receive_channel_frac_lost); - - EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( - tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, - sentFecBitrate, sentNackBitrate)); - - EXPECT_GT(sentTotalBitrate, 0u); - EXPECT_EQ(sentFecBitrate, 0u); - EXPECT_EQ(sentNackBitrate, 0u); - - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - - AutoTestSleep(2000); - - EXPECT_EQ(0, ViE.rtp_rtcp->GetSendChannelRtcpStatistics( - tbChannel.videoChannel, sent, sentRttMs)); - EXPECT_GT(sent.cumulative_lost, 0u); - EXPECT_GT(sent.extended_max_sequence_number, startSequenceNumber); - EXPECT_GT(sent.jitter, 0u); - EXPECT_GT(sentRttMs, 0); - - EXPECT_EQ(0, ViE.rtp_rtcp->GetReceiveChannelRtcpStatistics( - tbChannel.videoChannel, received, recRttMs)); - - EXPECT_GT(received.cumulative_lost, 0u); - EXPECT_GT(received.extended_max_sequence_number, startSequenceNumber); - EXPECT_GT(received.jitter, 0u); - EXPECT_GT(recRttMs, 0); - - unsigned int estimated_bandwidth = 0; - EXPECT_EQ(0, ViE.rtp_rtcp->GetEstimatedSendBandwidth( - tbChannel.videoChannel, - &estimated_bandwidth)); - EXPECT_GT(estimated_bandwidth, 0u); - - if (FLAGS_include_timing_dependent_tests) { - EXPECT_EQ(0, ViE.rtp_rtcp->GetEstimatedReceiveBandwidth( - tbChannel.videoChannel, - &estimated_bandwidth)); - EXPECT_GT(estimated_bandwidth, 0u); - - int passive_channel = -1; - EXPECT_EQ(ViE.base->CreateReceiveChannel(passive_channel, - tbChannel.videoChannel), 0); - EXPECT_EQ(ViE.base->StartReceive(passive_channel), 0); - EXPECT_EQ( - ViE.rtp_rtcp->GetEstimatedReceiveBandwidth(passive_channel, - &estimated_bandwidth), - 0); - EXPECT_EQ(estimated_bandwidth, 0u); - } - - // Check that rec stats extended max is greater than what we've sent. - EXPECT_GE(received.extended_max_sequence_number, - sent.extended_max_sequence_number); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - - // - // Test bandwidth statistics with reserved bitrate - // - - myTransport.ClearStats(); - network.packet_loss_rate = 0; - network.loss_model = kUniformLoss; - myTransport.SetNetworkParameters(network); - - ViE.rtp_rtcp->SetReservedTransmitBitrate(tbChannel.videoChannel, 2000000); - - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - AutoTestSleep(kAutoTestSleepTimeMs); - - estimated_bandwidth = 0; - EXPECT_EQ(0, ViE.rtp_rtcp->GetEstimatedSendBandwidth(tbChannel.videoChannel, - &estimated_bandwidth)); - if (FLAGS_include_timing_dependent_tests) { - EXPECT_EQ(0u, estimated_bandwidth); - } - - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - - // - // Test bandwidth statistics with NACK and FEC separately - // - - myTransport.ClearStats(); - network.packet_loss_rate = kPacketLossRate; - myTransport.SetNetworkParameters(network); - - EXPECT_EQ(0, ViE.rtp_rtcp->SetFECStatus( - tbChannel.videoChannel, true, 96, 97)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( - tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, - sentFecBitrate, sentNackBitrate)); - - if (FLAGS_include_timing_dependent_tests) { - EXPECT_GT(sentTotalBitrate, 0u); - EXPECT_GT(sentFecBitrate, 0u); - EXPECT_EQ(sentNackBitrate, 0u); - } - - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetFECStatus( - tbChannel.videoChannel, false, 96, 97)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - AutoTestSleep(4 * kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.rtp_rtcp->GetBandwidthUsage( - tbChannel.videoChannel, sentTotalBitrate, sentVideoBitrate, - sentFecBitrate, sentNackBitrate)); - - if (FLAGS_include_timing_dependent_tests) { - EXPECT_GT(sentTotalBitrate, 0u); - EXPECT_EQ(sentFecBitrate, 0u); - - // TODO(holmer): Test disabled due to being too flaky on buildbots. Tests - // for new API provide partial coverage. - // EXPECT_GT(sentNackBitrate, 0u); - } - - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, false)); - - - // Test to set SSRC - network.packet_loss_rate = 0; - myTransport.SetNetworkParameters(network); - myTransport.ClearStats(); - - unsigned int setSSRC = 0x01234567; - ViETest::Log("Set SSRC %u", setSSRC); - EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC(tbChannel.videoChannel, setSSRC)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - myTransport.EnableSSRCCheck(); - - AutoTestSleep(2000); - unsigned int receivedSSRC = myTransport.ReceivedSSRC(); - ViETest::Log("Received SSRC %u\n", receivedSSRC); - - if (FLAGS_include_timing_dependent_tests) { - EXPECT_EQ(setSSRC, receivedSSRC); - - unsigned int localSSRC = 0; - EXPECT_EQ(0, ViE.rtp_rtcp->GetLocalSSRC( - tbChannel.videoChannel, localSSRC)); - EXPECT_EQ(setSSRC, localSSRC); - - unsigned int remoteSSRC = 0; - EXPECT_EQ(0, ViE.rtp_rtcp->GetRemoteSSRC( - tbChannel.videoChannel, remoteSSRC)); - EXPECT_EQ(setSSRC, remoteSSRC); - } - - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - - ViETest::Log("Testing RTP dump...\n"); - - std::string inDumpName = - ViETest::GetResultOutputPath() + "IncomingRTPDump.rtp"; - std::string outDumpName = - ViETest::GetResultOutputPath() + "OutgoingRTPDump.rtp"; - EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( - tbChannel.videoChannel, inDumpName.c_str(), webrtc::kRtpIncoming)); - EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( - tbChannel.videoChannel, outDumpName.c_str(), webrtc::kRtpOutgoing)); - - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - AutoTestSleep(kAutoTestSleepTimeMs); - - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - - AutoTestSleep(1000); - - EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( - tbChannel.videoChannel, webrtc::kRtpIncoming)); - EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( - tbChannel.videoChannel, webrtc::kRtpOutgoing)); - - // Make sure data was actually saved to the file and we stored the same - // amount of data in both files - FILE* inDump = fopen(inDumpName.c_str(), "r"); - fseek(inDump, 0L, SEEK_END); - long inEndPos = ftell(inDump); - fclose(inDump); - FILE* outDump = fopen(outDumpName.c_str(), "r"); - fseek(outDump, 0L, SEEK_END); - // long outEndPos = ftell(outDump); - fclose(outDump); - - EXPECT_GT(inEndPos, 0); - - // TODO(phoglund): This is flaky for some reason. Are the sleeps too - // short above? - // EXPECT_LT(inEndPos, outEndPos + 100); - - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - - - ViETest::Log("Testing Network Down...\n"); - - EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true)); - // Reenable pacing. - EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( - tbChannel.videoChannel, true)); - - webrtc::StreamDataCounters sent_before; - webrtc::StreamDataCounters received_before; - webrtc::StreamDataCounters sent_after; - webrtc::StreamDataCounters received_after; - - EXPECT_EQ(0, ViE.rtp_rtcp->GetRtpStatistics(tbChannel.videoChannel, - sent_before, - received_before)); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - - // Real-time mode. - AutoTestSleep(kAutoTestSleepTimeMs); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRtpStatistics(tbChannel.videoChannel, - sent_after, received_after)); - if (FLAGS_include_timing_dependent_tests) { - EXPECT_GT(received_after.transmitted.payload_bytes, - received_before.transmitted.payload_bytes); - } - // Simulate lost reception and verify that nothing is sent during that time. - ViE.network->SetNetworkTransmissionState(tbChannel.videoChannel, false); - // Allow the encoder to finish the current frame before we expect that no - // additional packets will be sent. - AutoTestSleep(kAutoTestSleepTimeMs); - received_before.transmitted.payload_bytes = - received_after.transmitted.payload_bytes; - ViETest::Log("Network Down...\n"); - AutoTestSleep(kAutoTestSleepTimeMs); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRtpStatistics(tbChannel.videoChannel, - sent_before, - received_before)); - if (FLAGS_include_timing_dependent_tests) { - EXPECT_EQ(received_before.transmitted.payload_bytes, - received_after.transmitted.payload_bytes); - } - - // Network reception back. Video should now be sent. - ViE.network->SetNetworkTransmissionState(tbChannel.videoChannel, true); - ViETest::Log("Network Up...\n"); - AutoTestSleep(kAutoTestSleepTimeMs); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRtpStatistics(tbChannel.videoChannel, - sent_before, - received_before)); - if (FLAGS_include_timing_dependent_tests) { - EXPECT_GT(received_before.transmitted.payload_bytes, - received_after.transmitted.payload_bytes); - } - received_after.transmitted.payload_bytes = - received_before.transmitted.payload_bytes; - // Buffering mode. - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - ViE.rtp_rtcp->SetSenderBufferingMode(tbChannel.videoChannel, - kAutoTestSleepTimeMs / 2); - // Add extra delay to the receiver to make sure it doesn't flush due to - // too old packets being received (as the down-time introduced is longer - // than what we buffer at the sender). - ViE.rtp_rtcp->SetReceiverBufferingMode(tbChannel.videoChannel, - 3 * kAutoTestSleepTimeMs / 2); - EXPECT_EQ(0, ViE.base->StartReceive(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StartSend(tbChannel.videoChannel)); - AutoTestSleep(kAutoTestSleepTimeMs); - // Simulate lost reception and verify that nothing is sent during that time. - ViETest::Log("Network Down...\n"); - ViE.network->SetNetworkTransmissionState(tbChannel.videoChannel, false); - // Allow the encoder to finish the current frame before we expect that no - // additional packets will be sent. - AutoTestSleep(kAutoTestSleepTimeMs); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRtpStatistics(tbChannel.videoChannel, - sent_before, - received_before)); - if (FLAGS_include_timing_dependent_tests) { - EXPECT_GT(received_before.transmitted.payload_bytes, - received_after.transmitted.payload_bytes); - } - received_after.transmitted.payload_bytes = - received_before.transmitted.payload_bytes; - AutoTestSleep(kAutoTestSleepTimeMs); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRtpStatistics(tbChannel.videoChannel, - sent_before, - received_before)); - if (FLAGS_include_timing_dependent_tests) { - EXPECT_EQ(received_after.transmitted.payload_bytes, - received_before.transmitted.payload_bytes); - } - // Network reception back. Video should now be sent. - ViETest::Log("Network Up...\n"); - ViE.network->SetNetworkTransmissionState(tbChannel.videoChannel, true); - AutoTestSleep(kAutoTestSleepTimeMs); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRtpStatistics(tbChannel.videoChannel, - sent_before, - received_before)); - if (FLAGS_include_timing_dependent_tests) { - EXPECT_GT(received_before.transmitted.payload_bytes, - received_after.transmitted.payload_bytes); - } - // TODO(holmer): Verify that the decoded framerate doesn't decrease on an - // outage when in buffering mode. This isn't currently possible because we - // don't have an API to get decoded framerate. - - EXPECT_EQ(0, ViE.base->StopSend(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->StopReceive(tbChannel.videoChannel)); - - - // Deregister external transport - EXPECT_EQ(0, ViE.network->DeregisterSendTransport(tbChannel.videoChannel)); - - - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** -} - -void ViEAutoTest::ViERtpRtcpAPITest() -{ - //*************************************************************** - // Begin create/initialize WebRTC Video Engine for testing - //*************************************************************** - // Create VIE - TbInterfaces ViE("ViERtpRtcpAPITest"); - - // Create a video channel - TbVideoChannel tbChannel(ViE, webrtc::kVideoCodecVP8); - - // Create a capture device - TbCaptureDevice tbCapture(ViE); - tbCapture.ConnectTo(tbChannel.videoChannel); - - //*************************************************************** - // Engine ready. Begin testing class - //*************************************************************** - - // - // Check different RTCP modes - // - webrtc::ViERTCPMode rtcpMode = webrtc::kRtcpNone; - EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( - tbChannel.videoChannel, rtcpMode)); - EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, rtcpMode); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( - tbChannel.videoChannel, webrtc::kRtcpCompound_RFC4585)); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( - tbChannel.videoChannel, rtcpMode)); - EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, rtcpMode); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( - tbChannel.videoChannel, webrtc::kRtcpNonCompound_RFC5506)); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( - tbChannel.videoChannel, rtcpMode)); - EXPECT_EQ(webrtc::kRtcpNonCompound_RFC5506, rtcpMode); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( - tbChannel.videoChannel, webrtc::kRtcpNone)); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( - tbChannel.videoChannel, rtcpMode)); - EXPECT_EQ(webrtc::kRtcpNone, rtcpMode); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( - tbChannel.videoChannel, webrtc::kRtcpCompound_RFC4585)); - - // - // CName is testedn in SimpleTest - // Start sequence number is tested in SimplTEst - // - const char* testCName = "ViEAutotestCName"; - EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPCName( - tbChannel.videoChannel, testCName)); - - char returnCName[256]; - memset(returnCName, 0, 256); - EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPCName( - tbChannel.videoChannel, returnCName)); - EXPECT_STRCASEEQ(testCName, returnCName); - - // - // SSRC - // - EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC( - tbChannel.videoChannel, 0x01234567)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetLocalSSRC( - tbChannel.videoChannel, 0x76543210)); - - unsigned int ssrc = 0; - EXPECT_EQ(0, ViE.rtp_rtcp->GetLocalSSRC(tbChannel.videoChannel, ssrc)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, 1000)); - tbChannel.StartSend(); - EXPECT_NE(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, 12345)); - tbChannel.StopSend(); - - // - // Start sequence number - // - EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, 12345)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, 1000)); - tbChannel.StartSend(); - EXPECT_NE(0, ViE.rtp_rtcp->SetStartSequenceNumber( - tbChannel.videoChannel, 12345)); - tbChannel.StopSend(); - - // - // Application specific RTCP - // - { - unsigned char subType = 3; - unsigned int name = static_cast (0x41424344); // 'ABCD'; - const char* data = "ViEAutoTest Data of length 32 --"; - const unsigned short numBytes = 32; - - tbChannel.StartSend(); - EXPECT_EQ(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes)); - EXPECT_NE(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, NULL, numBytes)) << - "Should fail on NULL input."; - EXPECT_NE(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes - 1)) << - "Should fail on incorrect length."; - - EXPECT_EQ(0, ViE.rtp_rtcp->GetRTCPStatus( - tbChannel.videoChannel, rtcpMode)); - EXPECT_EQ(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetRTCPStatus( - tbChannel.videoChannel, webrtc::kRtcpCompound_RFC4585)); - tbChannel.StopSend(); - EXPECT_NE(0, ViE.rtp_rtcp->SendApplicationDefinedRTCPPacket( - tbChannel.videoChannel, subType, name, data, numBytes)); - } - - // - // Statistics - // - // Tested in SimpleTest(), we'll get errors if we haven't received a RTCP - // packet. - - // - // RTP Dump - // - { - std::string output_file = webrtc::test::OutputPath() + - "DumpFileName.rtp"; - const char* dumpName = output_file.c_str(); - - EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( - tbChannel.videoChannel, dumpName, webrtc::kRtpIncoming)); - EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( - tbChannel.videoChannel, webrtc::kRtpIncoming)); - EXPECT_NE(0, ViE.rtp_rtcp->StopRTPDump( - tbChannel.videoChannel, webrtc::kRtpIncoming)); - EXPECT_EQ(0, ViE.rtp_rtcp->StartRTPDump( - tbChannel.videoChannel, dumpName, webrtc::kRtpOutgoing)); - EXPECT_EQ(0, ViE.rtp_rtcp->StopRTPDump( - tbChannel.videoChannel, webrtc::kRtpOutgoing)); - EXPECT_NE(0, ViE.rtp_rtcp->StopRTPDump( - tbChannel.videoChannel, webrtc::kRtpOutgoing)); - EXPECT_NE(0, ViE.rtp_rtcp->StartRTPDump( - tbChannel.videoChannel, dumpName, (webrtc::RTPDirections) 3)); - } - // - // RTP/RTCP Observers - // - { - ViERtpObserver rtpObserver; - EXPECT_EQ(0, ViE.rtp_rtcp->RegisterRTPObserver( - tbChannel.videoChannel, rtpObserver)); - EXPECT_NE(0, ViE.rtp_rtcp->RegisterRTPObserver( - tbChannel.videoChannel, rtpObserver)); - EXPECT_EQ(0, ViE.rtp_rtcp->DeregisterRTPObserver( - tbChannel.videoChannel)); - EXPECT_NE(0, ViE.rtp_rtcp->DeregisterRTPObserver( - tbChannel.videoChannel)); - } - // - // PLI - // - { - EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestPliRtcp)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestNone)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetKeyFrameRequestMethod( - tbChannel.videoChannel, webrtc::kViEKeyFrameRequestNone)); - } - // - // NACK - // - { - EXPECT_EQ(0, ViE.rtp_rtcp->SetNACKStatus(tbChannel.videoChannel, true)); - } - - // Timestamp offset extension. - // Valid range is 1 to 14 inclusive. - EXPECT_EQ(-1, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, true, 0)); - EXPECT_EQ(-1, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, true, 15)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendTimestampOffsetStatus( - tbChannel.videoChannel, false, 3)); - - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, true, 0)); - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, true, 15)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveTimestampOffsetStatus( - tbChannel.videoChannel, false, 3)); - - // Absolute send time extension. - // Valid range is 1 to 14 inclusive. - EXPECT_EQ(-1, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 0)); - EXPECT_EQ(-1, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 15)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSendAbsoluteSendTimeStatus( - tbChannel.videoChannel, false, 3)); - - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 0)); - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 15)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, true, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, false, 3)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiveAbsoluteSendTimeStatus( - tbChannel.videoChannel, false, 3)); - - // Transmission smoothening. - const int invalid_channel_id = 17; - EXPECT_EQ(-1, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( - invalid_channel_id, true)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( - tbChannel.videoChannel, true)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( - tbChannel.videoChannel, true)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( - tbChannel.videoChannel, false)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetTransmissionSmoothingStatus( - tbChannel.videoChannel, false)); - - // Buffering mode - sender side. - EXPECT_EQ(-1, ViE.rtp_rtcp->SetSenderBufferingMode( - invalid_channel_id, 0)); - int invalid_delay = -1; - EXPECT_EQ(-1, ViE.rtp_rtcp->SetSenderBufferingMode( - tbChannel.videoChannel, invalid_delay)); - invalid_delay = 15000; - EXPECT_EQ(-1, ViE.rtp_rtcp->SetSenderBufferingMode( - tbChannel.videoChannel, invalid_delay)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetSenderBufferingMode( - tbChannel.videoChannel, 5000)); - - // Buffering mode - receiver side. - // Run without VoE to verify it that does not crash, but return an error. - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiverBufferingMode( - tbChannel.videoChannel, 0)); - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiverBufferingMode( - tbChannel.videoChannel, 2000)); - - // Set VoE (required to set up stream-sync). - webrtc::VoiceEngine* voice_engine = webrtc::VoiceEngine::Create(); - EXPECT_TRUE(NULL != voice_engine); - webrtc::VoEBase* voe_base = webrtc::VoEBase::GetInterface(voice_engine); - EXPECT_TRUE(NULL != voe_base); - EXPECT_EQ(0, voe_base->Init()); - int audio_channel = voe_base->CreateChannel(); - EXPECT_NE(-1, audio_channel); - EXPECT_EQ(0, ViE.base->SetVoiceEngine(voice_engine)); - EXPECT_EQ(0, ViE.base->ConnectAudioChannel(tbChannel.videoChannel, - audio_channel)); - - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiverBufferingMode( - invalid_channel_id, 0)); - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiverBufferingMode( - tbChannel.videoChannel, invalid_delay)); - invalid_delay = 15000; - EXPECT_EQ(-1, ViE.rtp_rtcp->SetReceiverBufferingMode( - tbChannel.videoChannel, invalid_delay)); - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiverBufferingMode( - tbChannel.videoChannel, 5000)); - - // Real-time mode - sender side. - EXPECT_EQ(0, ViE.rtp_rtcp->SetSenderBufferingMode( - tbChannel.videoChannel, 0)); - // Real-time mode - receiver side. - EXPECT_EQ(0, ViE.rtp_rtcp->SetReceiverBufferingMode( - tbChannel.videoChannel, 0)); - - EXPECT_EQ(0, ViE.base->DisconnectAudioChannel(tbChannel.videoChannel)); - EXPECT_EQ(0, ViE.base->SetVoiceEngine(NULL)); - EXPECT_EQ(0, voe_base->DeleteChannel(audio_channel)); - voe_base->Release(); - EXPECT_TRUE(webrtc::VoiceEngine::Delete(voice_engine)); - - //*************************************************************** - // Testing finished. Tear down Video Engine - //*************************************************************** -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_simulcast.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_simulcast.cc deleted file mode 100644 index 84d31dee2c..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_simulcast.cc +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include // NOLINT - -#include "webrtc/common_types.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/voice_engine/include/voe_base.h" - -enum RelayMode { - kRelayOneStream = 1, - kRelayAllStreams = 2 -}; - -#define VCM_RED_PAYLOAD_TYPE 96 -#define VCM_ULPFEC_PAYLOAD_TYPE 97 - -const int kNumStreams = 3; - -void InitialSingleStreamSettings(webrtc::VideoCodec* video_codec) { - video_codec->numberOfSimulcastStreams = 0; - video_codec->width = 1200; - video_codec->height = 800; -} - -void SetSimulcastSettings(webrtc::VideoCodec* video_codec) { - video_codec->width = 1280; - video_codec->height = 720; - - // Simulcast settings. - video_codec->numberOfSimulcastStreams = kNumStreams; - video_codec->simulcastStream[0].width = 320; - video_codec->simulcastStream[0].height = 180; - video_codec->simulcastStream[0].numberOfTemporalLayers = 0; - video_codec->simulcastStream[0].maxBitrate = 100; - video_codec->simulcastStream[0].targetBitrate = 100; - video_codec->simulcastStream[0].minBitrate = 0; - video_codec->simulcastStream[0].qpMax = video_codec->qpMax; - - video_codec->simulcastStream[1].width = 640; - video_codec->simulcastStream[1].height = 360; - video_codec->simulcastStream[1].numberOfTemporalLayers = 0; - video_codec->simulcastStream[1].maxBitrate = 500; - video_codec->simulcastStream[1].targetBitrate = 500; - video_codec->simulcastStream[1].minBitrate = 200; - video_codec->simulcastStream[1].qpMax = video_codec->qpMax; - - video_codec->simulcastStream[2].width = 1280; - video_codec->simulcastStream[2].height = 720; - video_codec->simulcastStream[2].numberOfTemporalLayers = 0; - video_codec->simulcastStream[2].maxBitrate = 1200; - video_codec->simulcastStream[2].targetBitrate = 1200; - video_codec->simulcastStream[2].minBitrate = 900; - video_codec->simulcastStream[2].qpMax = video_codec->qpMax; -} - -void RuntimeSingleStreamSettings(webrtc::VideoCodec* video_codec) { - SetSimulcastSettings(video_codec); - video_codec->width = 1200; - video_codec->height = 800; - video_codec->numberOfSimulcastStreams = kNumStreams; - video_codec->simulcastStream[0].maxBitrate = 0; - video_codec->simulcastStream[0].targetBitrate = 0; - video_codec->simulcastStream[0].minBitrate = 0; - video_codec->simulcastStream[1].maxBitrate = 0; - video_codec->simulcastStream[1].targetBitrate = 0; - video_codec->simulcastStream[1].minBitrate = 0; - video_codec->simulcastStream[2].maxBitrate = 0; - video_codec->simulcastStream[2].targetBitrate = 0; - video_codec->simulcastStream[2].minBitrate = 0; -} - -int VideoEngineSimulcastTest(void* window1, void* window2) { - // ******************************************************* - // Begin create/initialize Video Engine for testing - // ******************************************************* - - int error = 0; - int receive_channels[kNumStreams]; - - // Create a VideoEngine instance. - webrtc::VideoEngine* video_engine = NULL; - video_engine = webrtc::VideoEngine::Create(); - if (video_engine == NULL) { - printf("ERROR in VideoEngine::Create\n"); - return -1; - } - - error = video_engine->SetTraceFilter(webrtc::kTraceAll); - if (error == -1) { - printf("ERROR in VideoEngine::SetTraceLevel\n"); - return -1; - } - - std::string trace_file = - ViETest::GetResultOutputPath() + "ViESimulcast_trace.txt"; - error = video_engine->SetTraceFile(trace_file.c_str()); - if (error == -1) { - printf("ERROR in VideoEngine::SetTraceFile\n"); - return -1; - } - - // Init VideoEngine and create a channel. - webrtc::ViEBase* vie_base = webrtc::ViEBase::GetInterface(video_engine); - if (vie_base == NULL) { - printf("ERROR in ViEBase::GetInterface\n"); - return -1; - } - - error = vie_base->Init(); - if (error == -1) { - printf("ERROR in ViEBase::Init\n"); - return -1; - } - - RelayMode relay_mode = kRelayOneStream; - printf("Select relay mode:\n"); - printf("\t1. Relay one stream\n"); - printf("\t2. Relay all streams\n"); - if (scanf("%d", reinterpret_cast(&relay_mode)) != 1) { - printf("Error in scanf()\n"); - return -1; - } - getchar(); - - webrtc::ViERTP_RTCP* vie_rtp_rtcp = - webrtc::ViERTP_RTCP::GetInterface(video_engine); - if (vie_rtp_rtcp == NULL) { - printf("ERROR in ViERTP_RTCP::GetInterface\n"); - return -1; - } - - int video_channel = -1; - error = vie_base->CreateChannel(video_channel); - if (error == -1) { - printf("ERROR in ViEBase::CreateChannel\n"); - return -1; - } - - for (int i = 0; i < kNumStreams; ++i) { - receive_channels[i] = -1; - error = vie_base->CreateReceiveChannel(receive_channels[i], video_channel); - if (error == -1) { - printf("ERROR in ViEBase::CreateChannel\n"); - return -1; - } - } - - // List available capture devices, allocate and connect. - webrtc::ViECapture* vie_capture = - webrtc::ViECapture::GetInterface(video_engine); - if (vie_base == NULL) { - printf("ERROR in ViECapture::GetInterface\n"); - return -1; - } - - const unsigned int KMaxDeviceNameLength = 128; - const unsigned int KMaxUniqueIdLength = 256; - char device_name[KMaxDeviceNameLength]; - memset(device_name, 0, KMaxDeviceNameLength); - char unique_id[KMaxUniqueIdLength]; - memset(unique_id, 0, KMaxUniqueIdLength); - - printf("Available capture devices:\n"); - int capture_idx = 0; - for (capture_idx = 0; capture_idx < vie_capture->NumberOfCaptureDevices(); - capture_idx++) { - memset(device_name, 0, KMaxDeviceNameLength); - memset(unique_id, 0, KMaxUniqueIdLength); - - error = vie_capture->GetCaptureDevice(capture_idx, device_name, - KMaxDeviceNameLength, unique_id, - KMaxUniqueIdLength); - if (error == -1) { - printf("ERROR in ViECapture::GetCaptureDevice\n"); - return -1; - } - printf("\t %d. %s\n", capture_idx + 1, device_name); - } - printf("\nChoose capture device: "); -#ifdef WEBRTC_ANDROID - capture_idx = 0; - printf("0\n"); -#else - if (scanf("%d", &capture_idx) != 1) { - printf("Error in scanf()\n"); - return -1; - } - getchar(); - // Compensate for idx start at 1. - capture_idx = capture_idx - 1; -#endif - error = vie_capture->GetCaptureDevice(capture_idx, device_name, - KMaxDeviceNameLength, unique_id, - KMaxUniqueIdLength); - if (error == -1) { - printf("ERROR in ViECapture::GetCaptureDevice\n"); - return -1; - } - - int capture_id = 0; - error = vie_capture->AllocateCaptureDevice(unique_id, KMaxUniqueIdLength, - capture_id); - if (error == -1) { - printf("ERROR in ViECapture::AllocateCaptureDevice\n"); - return -1; - } - - error = vie_capture->ConnectCaptureDevice(capture_id, video_channel); - if (error == -1) { - printf("ERROR in ViECapture::ConnectCaptureDevice\n"); - return -1; - } - - error = vie_capture->StartCapture(capture_id); - if (error == -1) { - printf("ERROR in ViECapture::StartCapture\n"); - return -1; - } - - // RTP/RTCP settings. - error = vie_rtp_rtcp->SetRTCPStatus(video_channel, - webrtc::kRtcpCompound_RFC4585); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n"); - return -1; - } - - vie_rtp_rtcp->SetRembStatus(video_channel, true, false); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n"); - return -1; - } - - error = vie_rtp_rtcp->SetKeyFrameRequestMethod( - video_channel, webrtc::kViEKeyFrameRequestPliRtcp); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetKeyFrameRequestMethod\n"); - return -1; - } - - for (int i = 0; i < kNumStreams; ++i) { - error = vie_rtp_rtcp->SetRTCPStatus(receive_channels[i], - webrtc::kRtcpCompound_RFC4585); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n"); - return -1; - } - - vie_rtp_rtcp->SetRembStatus(receive_channels[i], false, true); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetRTCPStatus\n"); - return -1; - } - - error = vie_rtp_rtcp->SetKeyFrameRequestMethod( - receive_channels[i], webrtc::kViEKeyFrameRequestPliRtcp); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetKeyFrameRequestMethod\n"); - return -1; - } - } - - // Set up rendering. - webrtc::ViERender* vie_render = webrtc::ViERender::GetInterface(video_engine); - if (vie_render == NULL) { - printf("ERROR in ViERender::GetInterface\n"); - return -1; - } - - error = vie_render->AddRenderer(capture_id, window1, 0, 0.0, 0.0, 1.0, 1.0); - if (error == -1) { - printf("ERROR in ViERender::AddRenderer\n"); - return -1; - } - - error = vie_render->StartRender(capture_id); - if (error == -1) { - printf("ERROR in ViERender::StartRender\n"); - return -1; - } - - // Only rendering the thumbnail. - int channel_to_render = video_channel; - if (relay_mode == kRelayAllStreams) { - channel_to_render = receive_channels[0]; - } - error = vie_render->AddRenderer(channel_to_render, window2, 1, 0.0, 0.0, 1.0, - 1.0); - if (error == -1) { - printf("ERROR in ViERender::AddRenderer\n"); - return -1; - } - - error = vie_render->StartRender(channel_to_render); - if (error == -1) { - printf("ERROR in ViERender::StartRender\n"); - return -1; - } - - // Setup codecs. - webrtc::ViECodec* vie_codec = webrtc::ViECodec::GetInterface(video_engine); - if (vie_codec == NULL) { - printf("ERROR in ViECodec::GetInterface\n"); - return -1; - } - - // Check available codecs and prepare receive codecs. - printf("\nAvailable codecs:\n"); - webrtc::VideoCodec video_codec; - memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); - int codec_idx = 0; - for (codec_idx = 0; codec_idx < vie_codec->NumberOfCodecs(); codec_idx++) { - error = vie_codec->GetCodec(codec_idx, video_codec); - if (error == -1) { - printf("ERROR in ViECodec::GetCodec\n"); - return -1; - } - // Try to keep the test frame size small when I420. - if (video_codec.codecType != webrtc::kVideoCodecVP8) { - continue; - } - for (int i = 0; i < kNumStreams; ++i) { - error = vie_codec->SetReceiveCodec(receive_channels[i], video_codec); - if (error == -1) { - printf("ERROR in ViECodec::SetReceiveCodec\n"); - return -1; - } - } - if (video_codec.codecType != webrtc::kVideoCodecRED && - video_codec.codecType != webrtc::kVideoCodecULPFEC) { - printf("\t %d. %s\n", codec_idx + 1, video_codec.plName); - } - break; - } - error = vie_codec->GetCodec(codec_idx, video_codec); - if (error == -1) { - printf("ERROR in ViECodec::GetCodec\n"); - return -1; - } - - bool simulcast_mode = true; - int num_streams = 1; - // Set spatial resolution option. - if (simulcast_mode) { - SetSimulcastSettings(&video_codec); - num_streams = video_codec.numberOfSimulcastStreams; - } else { - InitialSingleStreamSettings(&video_codec); - num_streams = 1; - } - - // Set start bit rate. - std::string str; - std::cout << std::endl; - std::cout << "Choose start rate (in kbps). Press enter for default: "; - std::getline(std::cin, str); - int start_rate = atoi(str.c_str()); - if (start_rate != 0) { - video_codec.startBitrate = start_rate; - } - - error = vie_codec->SetSendCodec(video_channel, video_codec); - if (error == -1) { - printf("ERROR in ViECodec::SetSendCodec\n"); - return -1; - } - - // Address settings. - webrtc::ViENetwork* vie_network = - webrtc::ViENetwork::GetInterface(video_engine); - if (vie_network == NULL) { - printf("ERROR in ViENetwork::GetInterface\n"); - return -1; - } - - TbExternalTransport::SsrcChannelMap ssrc_channel_map; - for (int idx = 0; idx < num_streams; idx++) { - error = vie_rtp_rtcp->SetLocalSSRC(video_channel, idx + 1, // SSRC - webrtc::kViEStreamTypeNormal, idx); - ssrc_channel_map[idx + 1] = receive_channels[idx]; - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetLocalSSRC(idx:%d)\n", - idx); - return -1; - } - } - - TbExternalTransport::SsrcChannelMap* channel_map = &ssrc_channel_map; - if (relay_mode == kRelayOneStream) { - channel_map = NULL; - } - - // Setting External transport. - TbExternalTransport ext_transport(*vie_network, video_channel, channel_map); - - error = vie_network->RegisterSendTransport(video_channel, ext_transport); - if (error == -1) { - printf("ERROR in ViECodec::RegisterSendTransport \n"); - return -1; - } - - for (int i = 0; i < kNumStreams; ++i) { - error = vie_network->RegisterSendTransport(receive_channels[i], - ext_transport); - if (error == -1) { - printf("ERROR in ViECodec::RegisterSendTransport \n"); - return -1; - } - } - - // Set network one-way delay value. - // 10 ms one-way delay. - NetworkParameters network; - network.loss_model = kUniformLoss; - network.mean_one_way_delay = 10; - ext_transport.SetNetworkParameters(network); - - if (relay_mode == kRelayOneStream) { - ext_transport.SetSSRCFilter(num_streams); - } - - error = vie_base->StartSend(video_channel); - if (error == -1) { - printf("ERROR in ViENetwork::StartSend\n"); - return -1; - } - error = vie_base->StartReceive(video_channel); - if (error == -1) { - printf("ERROR in ViENetwork::StartReceive\n"); - return -1; - } - - for (int i = 0; i < kNumStreams; ++i) { - error = vie_base->StartReceive(receive_channels[i]); - if (error == -1) { - printf("ERROR in ViENetwork::StartReceive\n"); - return -1; - } - } - - // Create a receive channel to verify that it doesn't mess up toggling - // between single stream and simulcast. - int video_channel2 = -1; - error = vie_base->CreateReceiveChannel(video_channel2, video_channel); - if (error == -1) { - printf("ERROR in ViEBase::CreateReceiveChannel\n"); - return -1; - } - - // ******************************************************* - // Engine started - // ******************************************************* - - printf("\nSimulcast call started\n\n"); - do { - printf("Enter new SSRC filter 1,2 or 3\n"); - printf("... or 0 to switch between simulcast and a single stream\n"); - printf("Press enter to stop..."); - str.clear(); - std::getline(std::cin, str); - if (!str.empty()) { - int ssrc = atoi(str.c_str()); - if (ssrc == 0) { - // Toggle between simulcast and a single stream with different - // resolution. - if (simulcast_mode) { - RuntimeSingleStreamSettings(&video_codec); - num_streams = 1; - printf("Disabling simulcast\n"); - } else { - SetSimulcastSettings(&video_codec); - num_streams = video_codec.numberOfSimulcastStreams; - printf("Enabling simulcast\n"); - } - simulcast_mode = !simulcast_mode; - if (vie_codec->SetSendCodec(video_channel, video_codec) != 0) { - printf("ERROR switching between simulcast and single stream\n"); - return -1; - } - for (int idx = 0; idx < num_streams; idx++) { - error = vie_rtp_rtcp->SetLocalSSRC(video_channel, idx + 1, // SSRC - webrtc::kViEStreamTypeNormal, idx); - if (error == -1) { - printf("ERROR in ViERTP_RTCP::SetLocalSSRC(idx:%d)\n", idx); - return -1; - } - } - if (relay_mode == kRelayOneStream) { - ext_transport.SetSSRCFilter(num_streams); - } - } else if (ssrc > 0 && ssrc < 4) { - if (relay_mode == kRelayOneStream) { - ext_transport.SetSSRCFilter(ssrc); - } - } else { - printf("Invalid SSRC\n"); - } - } else { - break; - } - } while (true); - - // ******************************************************* - // Testing finished. Tear down Video Engine - // ******************************************************* - error = vie_base->DeleteChannel(video_channel2); - if (error == -1) { - printf("ERROR in ViEBase::DeleteChannel\n"); - return -1; - } - - for (int i = 0; i < kNumStreams; ++i) { - error = vie_base->StopReceive(receive_channels[i]); - if (error == -1) { - printf("ERROR in ViEBase::StopReceive\n"); - return -1; - } - } - - error = vie_base->StopReceive(video_channel); - if (error == -1) { - printf("ERROR in ViEBase::StopReceive\n"); - return -1; - } - - error = vie_base->StopSend(video_channel); - if (error == -1) { - printf("ERROR in ViEBase::StopSend\n"); - return -1; - } - - error = vie_render->StopRender(capture_id); - if (error == -1) { - printf("ERROR in ViERender::StopRender\n"); - return -1; - } - - error = vie_render->RemoveRenderer(capture_id); - if (error == -1) { - printf("ERROR in ViERender::RemoveRenderer\n"); - return -1; - } - - error = vie_render->StopRender(channel_to_render); - if (error == -1) { - printf("ERROR in ViERender::StopRender\n"); - return -1; - } - - error = vie_render->RemoveRenderer(channel_to_render); - if (error == -1) { - printf("ERROR in ViERender::RemoveRenderer\n"); - return -1; - } - - error = vie_capture->StopCapture(capture_id); - if (error == -1) { - printf("ERROR in ViECapture::StopCapture\n"); - return -1; - } - - error = vie_capture->DisconnectCaptureDevice(video_channel); - if (error == -1) { - printf("ERROR in ViECapture::DisconnectCaptureDevice\n"); - return -1; - } - - error = vie_capture->ReleaseCaptureDevice(capture_id); - if (error == -1) { - printf("ERROR in ViECapture::ReleaseCaptureDevice\n"); - return -1; - } - - for (int i = 0; i < kNumStreams; ++i) { - error = vie_base->DeleteChannel(receive_channels[i]); - if (error == -1) { - printf("ERROR in ViEBase::DeleteChannel\n"); - return -1; - } - } - - error = vie_base->DeleteChannel(video_channel); - if (error == -1) { - printf("ERROR in ViEBase::DeleteChannel\n"); - return -1; - } - - int remaining_interfaces = 0; - remaining_interfaces = vie_codec->Release(); - remaining_interfaces += vie_capture->Release(); - remaining_interfaces += vie_rtp_rtcp->Release(); - remaining_interfaces += vie_render->Release(); - remaining_interfaces += vie_network->Release(); - remaining_interfaces += vie_base->Release(); - if (remaining_interfaces > 0) { - printf("ERROR: Could not release all interfaces\n"); - return -1; - } - - bool deleted = webrtc::VideoEngine::Delete(video_engine); - if (deleted == false) { - printf("ERROR in VideoEngine::Delete\n"); - return -1; - } - return 0; -} - -int ViEAutoTest::ViESimulcastCall() { - ViETest::Log(" "); - ViETest::Log("========================================"); - ViETest::Log(" ViE Autotest Simulcast Call\n"); - - if (VideoEngineSimulcastTest(_window1, _window2) == 0) { - ViETest::Log(" "); - ViETest::Log(" ViE Autotest Simulcast Call Done"); - ViETest::Log("========================================"); - ViETest::Log(" "); - - return 0; - } - ViETest::Log(" "); - ViETest::Log(" ViE Autotest Simulcast Call Failed"); - ViETest::Log("========================================"); - ViETest::Log(" "); - return 1; -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_win.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_win.cc deleted file mode 100755 index 6e2bac3f9f..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_win.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// vie_autotest_windows.cc -// - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_windows.h" - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h" - -#include "webrtc/engine_configurations.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" - -#include - -#ifdef _DEBUG -//#include "vld.h" -#endif - -// Disable Visual studio warnings -// 'this' : used in base member initializer list -#pragma warning(disable: 4355) - -LRESULT CALLBACK ViEAutoTestWinProc(HWND hWnd, UINT uMsg, WPARAM wParam, - LPARAM lParam) { - switch (uMsg) { - case WM_DESTROY: - PostQuitMessage( WM_QUIT); - break; - case WM_COMMAND: - break; - } - return DefWindowProc(hWnd, uMsg, wParam, lParam); -} - -ViEAutoTestWindowManager::ViEAutoTestWindowManager() - : _window1(NULL), - _window2(NULL), - _terminate(false), - _eventThread(webrtc::ThreadWrapper::CreateThread( - EventProcess, this, "ViEAutotestEventThread")), - _crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()), - _hwnd1(NULL), - _hwnd2(NULL), - _hwnd1Size(), - _hwnd2Size(), - _hwnd1Title(), - _hwnd2Title() { -} - -ViEAutoTestWindowManager::~ViEAutoTestWindowManager() { - if (_hwnd1) { - ViEDestroyWindow(_hwnd1); - } - if (_hwnd2) { - ViEDestroyWindow(_hwnd2); - } - delete &_crit; -} - -void* ViEAutoTestWindowManager::GetWindow1() { - return _window1; -} - -void* ViEAutoTestWindowManager::GetWindow2() { - return _window2; -} - -int ViEAutoTestWindowManager::CreateWindows(AutoTestRect window1Size, - AutoTestRect window2Size, - void* window1Title, - void* window2Title) { - _hwnd1Size.Copy(window1Size); - _hwnd2Size.Copy(window2Size); - memcpy(_hwnd1Title, window1Title, TITLE_LENGTH); - memcpy(_hwnd2Title, window2Title, TITLE_LENGTH); - - _eventThread->Start(); - - do { - _crit.Enter(); - if (_window1 != NULL) { - break; - } - _crit.Leave(); - AutoTestSleep(10); - } while (true); - _crit.Leave(); - return 0; -} - -int ViEAutoTestWindowManager::TerminateWindows() { - _terminate = true; - _eventThread->Stop(); - _crit.Enter(); - _eventThread.reset(); - _crit.Leave(); - - return 0; -} - -bool ViEAutoTestWindowManager::EventProcess(void* obj) { - return static_cast (obj)->EventLoop(); -} - -bool ViEAutoTestWindowManager::EventLoop() { - _crit.Enter(); - - ViECreateWindow(_hwnd1, _hwnd1Size.origin.x, _hwnd1Size.origin.y, - _hwnd1Size.size.width, _hwnd1Size.size.height, _hwnd1Title); - ViECreateWindow(_hwnd2, _hwnd2Size.origin.x, _hwnd2Size.origin.y, - _hwnd2Size.size.width, _hwnd2Size.size.height, _hwnd2Title); - - _window1 = (void*) _hwnd1; - _window2 = (void*) _hwnd2; - MSG msg; - while (!_terminate) { - if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - _crit.Leave(); - AutoTestSleep(10); - _crit.Enter(); - } - ViEDestroyWindow(_hwnd1); - ViEDestroyWindow(_hwnd2); - _crit.Leave(); - - return false; -} - -int ViEAutoTestWindowManager::ViECreateWindow(HWND &hwndMain, int xPos, - int yPos, int width, int height, - TCHAR* className) { - HINSTANCE hinst = GetModuleHandle(0); - WNDCLASSEX wcx; - wcx.hInstance = hinst; - wcx.lpszClassName = className; - wcx.lpfnWndProc = (WNDPROC) ViEAutoTestWinProc; - wcx.style = CS_DBLCLKS; - wcx.hIcon = LoadIcon(NULL, IDI_APPLICATION); - wcx.hIconSm = LoadIcon(NULL, IDI_APPLICATION); - wcx.hCursor = LoadCursor(NULL, IDC_ARROW); - wcx.lpszMenuName = NULL; - wcx.cbSize = sizeof(WNDCLASSEX); - wcx.cbClsExtra = 0; - wcx.cbWndExtra = 0; - wcx.hbrBackground = GetSysColorBrush(COLOR_3DFACE); - - RegisterClassEx(&wcx); - - // Create the main window. - hwndMain = CreateWindowEx(0, // no extended styles - className, // class name - className, // window name - WS_OVERLAPPED | WS_THICKFRAME, // overlapped window - xPos, // horizontal position - yPos, // vertical position - width, // width - height, // height - (HWND) NULL, // no parent or owner window - (HMENU) NULL, // class menu used - hinst, // instance handle - NULL); // no window creation data - - if (!hwndMain) - return -1; - - // Show the window using the flag specified by the program - // that started the application, and send the application - // a WM_PAINT message. - ShowWindow(hwndMain, SW_SHOWDEFAULT); - UpdateWindow(hwndMain); - - ::SetWindowPos(hwndMain, HWND_TOP, xPos, yPos, width, height, - SWP_FRAMECHANGED); - - return 0; -} - -int ViEAutoTestWindowManager::ViEDestroyWindow(HWND& hwnd) { - ::DestroyWindow(hwnd); - return 0; -} - -bool ViEAutoTestWindowManager::SetTopmostWindow() { - // Meant to put terminal window on top - return true; -} - -int main(int argc, char* argv[]) { - ViEAutoTestMain auto_test; - return auto_test.RunTests(argc, argv); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_file_based_comparison_tests.cc b/webrtc/video_engine/test/auto_test/source/vie_file_based_comparison_tests.cc deleted file mode 100644 index 4f3a90a7a5..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_file_based_comparison_tests.cc +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/interface/vie_file_based_comparison_tests.h" - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" -#include "webrtc/video_engine/test/auto_test/primitives/base_primitives.h" -#include "webrtc/video_engine/test/auto_test/primitives/framedrop_primitives.h" -#include "webrtc/video_engine/test/auto_test/primitives/general_primitives.h" -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" -#include "webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h" -#include "webrtc/video_engine/test/libvietest/include/vie_fake_camera.h" -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" - -bool ViEFileBasedComparisonTests::TestCallSetup( - const std::string& i420_video_file, - int width, - int height, - ViEToFileRenderer* local_file_renderer, - ViEToFileRenderer* remote_file_renderer) { - - TbInterfaces interfaces("TestCallSetup"); - - int video_channel = -1; - EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); - - ViEFakeCamera fake_camera(interfaces.capture); - if (!fake_camera.StartCameraInNewThread(i420_video_file, - width, - height)) { - // No point in continuing if we have no proper video source - ADD_FAILURE() << "Could not open input video " << i420_video_file << - ": aborting test..."; - return false; - } - int capture_id = fake_camera.capture_id(); - - // Apparently, we need to connect external capture devices, but we should - // not start them since the external device is not a proper device. - EXPECT_EQ(0, interfaces.capture->ConnectCaptureDevice( - capture_id, video_channel)); - - ConfigureRtpRtcp(interfaces.rtp_rtcp, kNack, video_channel); - - webrtc::ViERender* render_interface = interfaces.render; - webrtc::ViEImageProcess* image_process = interfaces.image_process; - - RenderToFile(render_interface, video_channel, remote_file_renderer); - - // We make a special hookup of the local renderer to use an effect filter - // instead of using the render interface for the capture device. This way - // we will only render frames that actually get sent. - webrtc::ExternalRendererEffectFilter renderer_filter(local_file_renderer); - EXPECT_EQ(0, image_process->RegisterSendEffectFilter(video_channel, - renderer_filter)); - - // Run the test itself: - const char* device_name = "Fake Capture Device"; - - ::TestI420CallSetup(interfaces.codec, interfaces.video_engine, - interfaces.base, interfaces.network, interfaces.rtp_rtcp, - video_channel, device_name); - - EXPECT_EQ(0, render_interface->StopRender(video_channel)); - EXPECT_EQ(0, render_interface->RemoveRenderer(video_channel)); - - interfaces.capture->DisconnectCaptureDevice(video_channel); - - // Stop sending data, clean up the camera thread and release the capture - // device. Note that this all happens after StopEverything, so this - // tests that the system doesn't mind that the external capture device sends - // data after rendering has been stopped. - fake_camera.StopCamera(); - EXPECT_EQ(0, image_process->DeregisterSendEffectFilter(video_channel)); - - EXPECT_EQ(0, interfaces.base->DeleteChannel(video_channel)); - return true; -} - -void ViEFileBasedComparisonTests::TestFullStack( - const std::string& i420_video_file, - int width, - int height, - int bit_rate_kbps, - ProtectionMethod protection_method, - const NetworkParameters& network, - ViEToFileRenderer* local_file_renderer, - ViEToFileRenderer* remote_file_renderer, - FrameDropDetector* frame_drop_detector) { - TbInterfaces interfaces("TestFullStack"); - - // Setup camera capturing from file. - ViEFakeCamera fake_camera(interfaces.capture); - if (!fake_camera.StartCameraInNewThread(i420_video_file, width, height)) { - // No point in continuing if we have no proper video source - ADD_FAILURE() << "Could not open input video " << i420_video_file << - ": aborting test..."; - return; - } - int video_channel = -1; - int capture_id = fake_camera.capture_id(); - EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); - - // Must set SSRC to avoid SSRC collision detection since we're sending and - // receiving from the same machine (that would cause frames being discarded - // and decoder reset). - EXPECT_EQ(0, interfaces.rtp_rtcp->SetLocalSSRC(video_channel, 12345)); - - EXPECT_EQ(0, interfaces.capture->ConnectCaptureDevice( - capture_id, video_channel)); - ConfigureRtpRtcp(interfaces.rtp_rtcp, protection_method, video_channel); - - ::TestFullStack(interfaces, capture_id, video_channel, width, height, - bit_rate_kbps, network, frame_drop_detector, - remote_file_renderer, local_file_renderer); - EXPECT_TRUE(fake_camera.StopCamera()); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_window_creator.cc b/webrtc/video_engine/test/auto_test/source/vie_window_creator.cc deleted file mode 100644 index 55bdb4a88c..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_window_creator.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/interface/vie_window_creator.h" - -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_main.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_window_manager_interface.h" -#include "webrtc/video_engine/test/auto_test/interface/vie_window_manager_factory.h" -#include "webrtc/voice_engine/include/voe_codec.h" - -#if defined(WIN32) -#include -#endif - -ViEWindowCreator::ViEWindowCreator() { -#ifndef WEBRTC_ANDROID - window_manager_ = - ViEWindowManagerFactory::CreateWindowManagerForCurrentPlatform(); -#endif -} - -ViEWindowCreator::~ViEWindowCreator() { - delete window_manager_; -} - -ViEAutoTestWindowManagerInterface* - ViEWindowCreator::CreateTwoWindows() { -#if defined(WIN32) - TCHAR window1Title[1024] = _T("ViE Autotest Window 1"); - TCHAR window2Title[1024] = _T("ViE Autotest Window 2"); -#else - char window1Title[1024] = "ViE Autotest Window 1"; - char window2Title[1024] = "ViE Autotest Window 2"; -#endif - - AutoTestRect window1Size(352, 288, 600, 100); - AutoTestRect window2Size(352, 288, 1000, 100); - window_manager_->CreateWindows(window1Size, window2Size, window1Title, - window2Title); - window_manager_->SetTopmostWindow(); - - return window_manager_; -} - -void ViEWindowCreator::TerminateWindows() { - window_manager_->TerminateWindows(); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_linux.cc b/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_linux.cc deleted file mode 100644 index 88cc239c08..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_linux.cc +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/interface/vie_window_manager_factory.h" - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_linux.h" - -ViEAutoTestWindowManagerInterface* -ViEWindowManagerFactory::CreateWindowManagerForCurrentPlatform() { - return new ViEAutoTestWindowManager(); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_mac.mm b/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_mac.mm deleted file mode 100644 index a60fc900c3..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_mac.mm +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/auto_test/interface/vie_window_manager_factory.h" - -#include "webrtc/engine_configurations.h" -#if defined(COCOA_RENDERING) -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_mac_cocoa.h" -#endif - -ViEAutoTestWindowManagerInterface* -ViEWindowManagerFactory::CreateWindowManagerForCurrentPlatform() { - return new ViEAutoTestWindowManager(); -} diff --git a/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_win.cc b/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_win.cc deleted file mode 100644 index 020ef90317..0000000000 --- a/webrtc/video_engine/test/auto_test/source/vie_window_manager_factory_win.cc +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "webrtc/video_engine/test/auto_test/interface/vie_window_manager_factory.h" - -#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_windows.h" - -ViEAutoTestWindowManagerInterface* -ViEWindowManagerFactory::CreateWindowManagerForCurrentPlatform() { - return new ViEAutoTestWindowManager(); -} diff --git a/webrtc/video_engine/test/auto_test/vie_auto_test.gypi b/webrtc/video_engine/test/auto_test/vie_auto_test.gypi deleted file mode 100644 index e52b301651..0000000000 --- a/webrtc/video_engine/test/auto_test/vie_auto_test.gypi +++ /dev/null @@ -1,149 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. - -{ - 'targets': [ - { - 'target_name': 'vie_auto_test', - 'type': 'executable', - 'dependencies': [ - '<(webrtc_root)/common.gyp:webrtc_common', - '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers', - '<(webrtc_root)/system_wrappers/system_wrappers.gyp:metrics_default', - '<(webrtc_root)/modules/modules.gyp:video_capture_module_internal_impl', - '<(webrtc_root)/modules/modules.gyp:video_render_module_internal_impl', - '<(webrtc_root)/voice_engine/voice_engine.gyp:voice_engine', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(DEPTH)/third_party/gflags/gflags.gyp:gflags', - '<(webrtc_root)/test/metrics.gyp:metrics', - '<(webrtc_root)/test/test.gyp:channel_transport', - '<(webrtc_root)/test/test.gyp:test_support', - '<(webrtc_root)/test/test.gyp:field_trial', - 'video_engine_core', - 'libvietest', - ], - 'sources': [ - 'interface/vie_autotest.h', - 'interface/vie_autotest_defines.h', - 'interface/vie_autotest_linux.h', - 'interface/vie_autotest_mac_cocoa.h', - 'interface/vie_autotest_main.h', - 'interface/vie_autotest_window_manager_interface.h', - 'interface/vie_autotest_windows.h', - 'interface/vie_file_based_comparison_tests.h', - 'interface/vie_window_manager_factory.h', - 'interface/vie_window_creator.h', - - # New, fully automated tests - 'automated/legacy_fixture.cc', - 'automated/two_windows_fixture.cc', - 'automated/vie_api_integration_test.cc', - 'automated/vie_extended_integration_test.cc', - 'automated/vie_network_test.cc', - 'automated/vie_standard_integration_test.cc', - 'automated/vie_video_verification_test.cc', - - # Test primitives - 'primitives/base_primitives.cc', - 'primitives/base_primitives.h', - 'primitives/choice_helpers.cc', - 'primitives/choice_helpers.h', - 'primitives/choice_helpers_unittest.cc', - 'primitives/fake_stdin.h', - 'primitives/fake_stdin.cc', - 'primitives/framedrop_primitives.h', - 'primitives/framedrop_primitives.cc', - 'primitives/framedrop_primitives_unittest.cc', - 'primitives/general_primitives.cc', - 'primitives/general_primitives.h', - 'primitives/input_helpers.cc', - 'primitives/input_helpers.h', - 'primitives/input_helpers_unittest.cc', - - # Platform independent - 'source/vie_autotest.cc', - 'source/vie_autotest_base.cc', - 'source/vie_autotest_capture.cc', - 'source/vie_autotest_codec.cc', - 'source/vie_autotest_image_process.cc', - 'source/vie_autotest_loopback.cc', - 'source/vie_autotest_main.cc', - 'source/vie_autotest_render.cc', - 'source/vie_autotest_record.cc', - 'source/vie_autotest_rtp_rtcp.cc', - 'source/vie_autotest_custom_call.cc', - 'source/vie_autotest_simulcast.cc', - 'source/vie_file_based_comparison_tests.cc', - 'source/vie_window_creator.cc', - - # Platform dependent - # Android - 'source/vie_autotest_android.cc', - # Linux - 'source/vie_autotest_linux.cc', - 'source/vie_window_manager_factory_linux.cc', - # Mac - 'source/vie_autotest_cocoa_mac.mm', - 'source/vie_window_manager_factory_mac.mm', - # Windows - 'source/vie_autotest_win.cc', - 'source/vie_window_manager_factory_win.cc', - ], - 'conditions': [ - ['OS=="android"', { - 'libraries': [ - '-lGLESv2', - '-llog', - ], - }], - ['OS=="linux"', { - # TODO(andrew): These should be provided directly by the projects - # which require them instead. - 'libraries': [ - '-lXext', - '-lX11', - ], - }], - ['OS=="mac"', { - 'dependencies': [ - # Use a special main for mac so we can access the webcam. - '<(webrtc_root)/test/test.gyp:test_support_main_threaded_mac', - ], - 'xcode_settings': { - 'OTHER_LDFLAGS': [ - '-framework Foundation -framework AppKit -framework Cocoa -framework OpenGL -framework CoreVideo -framework CoreAudio -framework AudioToolbox', - ], - }, - }], - ], # conditions - # Disable warnings to enable Win64 build, issue 1323. - 'msvs_disabled_warnings': [ - 4267, # size_t to int truncation. - ], - }, - ], - 'conditions': [ - ['test_isolation_mode != "noop"', { - 'targets': [ - { - 'target_name': 'vie_auto_test_run', - 'type': 'none', - 'dependencies': [ - 'vie_auto_test', - ], - 'includes': [ - '../../../build/isolate.gypi', - ], - 'sources': [ - 'vie_auto_test.isolate', - ], - }, - ], - }], - ], -} diff --git a/webrtc/video_engine/test/auto_test/vie_auto_test.isolate b/webrtc/video_engine/test/auto_test/vie_auto_test.isolate deleted file mode 100644 index 2579a20b20..0000000000 --- a/webrtc/video_engine/test/auto_test/vie_auto_test.isolate +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -{ - 'conditions': [ - ['OS=="linux" or OS=="mac" or OS=="win"', { - 'variables': { - 'command': [ - '<(DEPTH)/testing/test_env.py', - '<(PRODUCT_DIR)/vie_auto_test<(EXECUTABLE_SUFFIX)', - ], - 'files': [ - '<(DEPTH)/DEPS', - '<(DEPTH)/testing/test_env.py', - '<(PRODUCT_DIR)/vie_auto_test<(EXECUTABLE_SUFFIX)', - ], - }, - }], - ], -} diff --git a/webrtc/video_engine/test/libvietest/OWNERS b/webrtc/video_engine/test/libvietest/OWNERS deleted file mode 100644 index 3ee6b4bf5f..0000000000 --- a/webrtc/video_engine/test/libvietest/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ - -# These are for the common case of adding or renaming files. If you're doing -# structural changes, please get a review from a reviewer in this file. -per-file *.gyp=* -per-file *.gypi=* diff --git a/webrtc/video_engine/test/libvietest/helpers/vie_fake_camera.cc b/webrtc/video_engine/test/libvietest/helpers/vie_fake_camera.cc deleted file mode 100644 index 1c18d498e0..0000000000 --- a/webrtc/video_engine/test/libvietest/helpers/vie_fake_camera.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "webrtc/video_engine/test/libvietest/include/vie_fake_camera.h" - -#include - -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/test/libvietest/include/vie_file_capture_device.h" - -// This callback runs the camera thread: -bool StreamVideoFileRepeatedlyIntoCaptureDevice(void* data) { - ViEFileCaptureDevice* file_capture_device = - reinterpret_cast(data); - - // We want to interrupt the camera feeding thread every now and then in order - // to follow the contract for the system_wrappers thread library. 1.5 seconds - // seems about right here. - uint64_t time_slice_ms = 1500; - uint32_t max_fps = 30; - - file_capture_device->ReadFileFor(time_slice_ms, max_fps); - - return true; -} - -ViEFakeCamera::ViEFakeCamera(webrtc::ViECapture* capture_interface) - : capture_interface_(capture_interface), - capture_id_(-1), - file_capture_device_(NULL) { -} - -ViEFakeCamera::~ViEFakeCamera() { -} - -bool ViEFakeCamera::StartCameraInNewThread( - const std::string& i420_test_video_path, int width, int height) { - - assert(file_capture_device_ == NULL && camera_thread_ == NULL); - - webrtc::ViEExternalCapture* externalCapture; - int result = capture_interface_-> - AllocateExternalCaptureDevice(capture_id_, externalCapture); - if (result != 0) { - return false; - } - - file_capture_device_ = new ViEFileCaptureDevice(externalCapture); - if (!file_capture_device_->OpenI420File(i420_test_video_path, - width, - height)) { - return false; - } - - // Set up a thread which runs the fake camera. The capturer object is - // thread-safe. - camera_thread_ = webrtc::ThreadWrapper::CreateThread( - StreamVideoFileRepeatedlyIntoCaptureDevice, file_capture_device_, - "StreamVideoFileRepeatedlyIntoCaptureDevice"); - camera_thread_->Start(); - - return true; -} - -bool ViEFakeCamera::StopCamera() { - assert(file_capture_device_ != NULL && camera_thread_ != NULL); - - camera_thread_->Stop(); - file_capture_device_->CloseFile(); - - int result = capture_interface_->ReleaseCaptureDevice(capture_id_); - - camera_thread_.reset(); - delete file_capture_device_; - camera_thread_ = NULL; - file_capture_device_ = NULL; - - return result == 0; -} diff --git a/webrtc/video_engine/test/libvietest/helpers/vie_file_capture_device.cc b/webrtc/video_engine/test/libvietest/helpers/vie_file_capture_device.cc deleted file mode 100644 index 4f2db75498..0000000000 --- a/webrtc/video_engine/test/libvietest/helpers/vie_file_capture_device.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "webrtc/video_engine/test/libvietest/include/vie_file_capture_device.h" - -#include - -#include "webrtc/common_types.h" -#include "webrtc/modules/interface/module_common_types.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/event_wrapper.h" -#include "webrtc/system_wrappers/interface/tick_util.h" -#include "webrtc/video_engine/include/vie_capture.h" - -// This class ensures we are not exceeding the max FPS. -class FramePacemaker { - public: - explicit FramePacemaker(uint32_t max_fps) - : time_per_frame_ms_(1000 / max_fps) { - frame_start_ = webrtc::TickTime::MillisecondTimestamp(); - } - - void SleepIfNecessary(webrtc::EventWrapper* sleeper) { - uint64_t now = webrtc::TickTime::MillisecondTimestamp(); - if (now - frame_start_ < time_per_frame_ms_) { - sleeper->Wait(time_per_frame_ms_ - (now - frame_start_)); - } - } - - private: - uint64_t frame_start_; - uint64_t time_per_frame_ms_; -}; - -ViEFileCaptureDevice::ViEFileCaptureDevice( - webrtc::ViEExternalCapture* input_sink) - : input_sink_(input_sink), - input_file_(NULL) { - mutex_ = webrtc::CriticalSectionWrapper::CreateCriticalSection(); -} - -ViEFileCaptureDevice::~ViEFileCaptureDevice() { - delete mutex_; -} - -bool ViEFileCaptureDevice::OpenI420File(const std::string& path, - int width, - int height) { - webrtc::CriticalSectionScoped cs(mutex_); - assert(input_file_ == NULL); - - input_file_ = fopen(path.c_str(), "rb"); - if (input_file_ == NULL) { - return false; - } - - frame_length_ = 3 * width * height / 2; - width_ = width; - height_ = height; - return true; -} - -void ViEFileCaptureDevice::ReadFileFor(uint64_t time_slice_ms, - uint32_t max_fps) { - webrtc::CriticalSectionScoped cs(mutex_); - assert(input_file_ != NULL); - - unsigned char* frame_buffer = new unsigned char[frame_length_]; - - webrtc::EventWrapper* sleeper = webrtc::EventWrapper::Create(); - - uint64_t start_time_ms = webrtc::TickTime::MillisecondTimestamp(); - uint64_t elapsed_ms = 0; - - while (elapsed_ms < time_slice_ms) { - FramePacemaker pacemaker(max_fps); - size_t read = fread(frame_buffer, 1, frame_length_, input_file_); - - if (feof(input_file_) || read != frame_length_) { - rewind(input_file_); - } - webrtc::I420VideoFrame frame; - frame.CreateFrame(frame_buffer, width_, height_, webrtc::kVideoRotation_0); - frame.set_render_time_ms(webrtc::TickTime::MillisecondTimestamp()); - input_sink_->IncomingFrame(frame); - - pacemaker.SleepIfNecessary(sleeper); - elapsed_ms = webrtc::TickTime::MillisecondTimestamp() - start_time_ms; - } - - delete sleeper; - delete[] frame_buffer; -} - -void ViEFileCaptureDevice::CloseFile() { - webrtc::CriticalSectionScoped cs(mutex_); - assert(input_file_ != NULL); - - fclose(input_file_); -} diff --git a/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc b/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc deleted file mode 100644 index d0aee84bd6..0000000000 --- a/webrtc/video_engine/test/libvietest/helpers/vie_to_file_renderer.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h" - -#include - -#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/event_wrapper.h" -#include "webrtc/system_wrappers/interface/thread_wrapper.h" - -namespace test { -struct Frame { - public: - Frame() : buffer(nullptr), buffer_size(0), timestamp(0), render_time(0) {} - - rtc::scoped_ptr buffer; - size_t buffer_size; - uint32_t timestamp; - int64_t render_time; - - private: - DISALLOW_COPY_AND_ASSIGN(Frame); -}; -}; // namespace test - -ViEToFileRenderer::ViEToFileRenderer() - : output_file_(NULL), - output_path_(), - output_filename_(), - thread_(webrtc::ThreadWrapper::CreateThread( - ViEToFileRenderer::RunRenderThread, this, "ViEToFileRendererThread")), - frame_queue_cs_(webrtc::CriticalSectionWrapper::CreateCriticalSection()), - frame_render_event_(webrtc::EventWrapper::Create()), - render_queue_(), - free_frame_queue_() { -} - -ViEToFileRenderer::~ViEToFileRenderer() { - while (!free_frame_queue_.empty()) { - delete free_frame_queue_.front(); - free_frame_queue_.pop_front(); - } -} - -bool ViEToFileRenderer::PrepareForRendering( - const std::string& output_path, - const std::string& output_filename) { - - assert(output_file_ == NULL); - - output_file_ = fopen((output_path + output_filename).c_str(), "wb"); - if (output_file_ == NULL) { - return false; - } - - output_filename_ = output_filename; - output_path_ = output_path; - return thread_->Start(); -} - -void ViEToFileRenderer::StopRendering() { - assert(output_file_ != NULL); - if (thread_.get() != NULL) { - // Signal that a frame is ready to be written to file. - frame_render_event_->Set(); - // Call Stop() repeatedly, waiting for ProcessRenderQueue() to finish. - while (!thread_->Stop()) continue; - } - fclose(output_file_); - output_file_ = NULL; -} - -bool ViEToFileRenderer::SaveOutputFile(const std::string& prefix) { - assert(output_file_ == NULL && output_filename_ != ""); - if (rename((output_path_ + output_filename_).c_str(), - (output_path_ + prefix + output_filename_).c_str()) != 0) { - perror("Failed to rename output file"); - return false; - } - ForgetOutputFile(); - return true; -} - -bool ViEToFileRenderer::DeleteOutputFile() { - assert(output_file_ == NULL && output_filename_ != ""); - if (remove((output_path_ + output_filename_).c_str()) != 0) { - perror("Failed to delete output file"); - return false; - } - ForgetOutputFile(); - return true; -} - -const std::string ViEToFileRenderer::GetFullOutputPath() const { - return output_path_ + output_filename_; -} - -void ViEToFileRenderer::ForgetOutputFile() { - output_filename_ = ""; - output_path_ = ""; -} - -test::Frame* ViEToFileRenderer::NewFrame(size_t buffer_size) { - test::Frame* frame; - if (free_frame_queue_.empty()) { - frame = new test::Frame(); - } else { - // Reuse an already allocated frame. - frame = free_frame_queue_.front(); - free_frame_queue_.pop_front(); - } - if (frame->buffer_size < buffer_size) { - frame->buffer.reset(new unsigned char[buffer_size]); - frame->buffer_size = buffer_size; - } - return frame; -} - -int ViEToFileRenderer::DeliverFrame(unsigned char *buffer, - size_t buffer_size, - uint32_t time_stamp, - int64_t ntp_time_ms, - int64_t render_time, - void* /*handle*/) { - webrtc::CriticalSectionScoped lock(frame_queue_cs_.get()); - test::Frame* frame = NewFrame(buffer_size); - memcpy(frame->buffer.get(), buffer, buffer_size); - frame->timestamp = time_stamp; - frame->render_time = render_time; - - render_queue_.push_back(frame); - // Signal that a frame is ready to be written to file. - frame_render_event_->Set(); - return 0; -} - -int ViEToFileRenderer::DeliverI420Frame( - const webrtc::I420VideoFrame& input_frame) { - const size_t buffer_size = - CalcBufferSize(webrtc::kI420, input_frame.width(), input_frame.height()); - webrtc::CriticalSectionScoped lock(frame_queue_cs_.get()); - test::Frame* frame = NewFrame(buffer_size); - const int length = - ExtractBuffer(input_frame, frame->buffer_size, frame->buffer.get()); - assert(static_cast(length) == buffer_size); - if (length < 0) - return -1; - frame->timestamp = input_frame.timestamp(); - frame->render_time = input_frame.render_time_ms(); - - render_queue_.push_back(frame); - // Signal that a frame is ready to be written to file. - frame_render_event_->Set(); - return 0; -} - -bool ViEToFileRenderer::IsTextureSupported() { return false; } - -int ViEToFileRenderer::FrameSizeChange(unsigned int width, - unsigned int height, - unsigned int number_of_streams) { - return 0; -} - -bool ViEToFileRenderer::RunRenderThread(void* obj) { - assert(obj); - ViEToFileRenderer* renderer = static_cast(obj); - return renderer->ProcessRenderQueue(); -} - -bool ViEToFileRenderer::ProcessRenderQueue() { - // Wait for a frame to be rendered. - frame_render_event_->Wait(WEBRTC_EVENT_INFINITE); - frame_queue_cs_->Enter(); - // Render all frames in the queue. - while (!render_queue_.empty()) { - test::Frame* frame = render_queue_.front(); - render_queue_.pop_front(); - // Leave the critical section before writing to file to not block calls to - // the renderer. - frame_queue_cs_->Leave(); - assert(output_file_); - size_t written = fwrite(frame->buffer.get(), sizeof(unsigned char), - frame->buffer_size, output_file_); - frame_queue_cs_->Enter(); - // Return the frame. - free_frame_queue_.push_front(frame); - if (written != frame->buffer_size) { - frame_queue_cs_->Leave(); - return false; - } - } - frame_queue_cs_->Leave(); - return true; -} diff --git a/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h b/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h deleted file mode 100644 index 918edf96c3..0000000000 --- a/webrtc/video_engine/test/libvietest/include/tb_I420_codec.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -/* - * This file contains the interface to I420 "codec" - * This is a dummy wrapper to allow VCM deal with raw I420 sequences - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_I420_CODEC_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_I420_CODEC_H_ - -#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" - -class TbI420Encoder: public webrtc::VideoEncoder -{ -public: - TbI420Encoder(); - virtual ~TbI420Encoder(); - - int32_t InitEncode(const webrtc::VideoCodec* codecSettings, - int32_t numberOfCores, - size_t maxPayloadSize) override; - - int32_t Encode( - const webrtc::I420VideoFrame& inputImage, - const webrtc::CodecSpecificInfo* codecSpecificInfo, - const std::vector* frameTypes) override; - - int32_t RegisterEncodeCompleteCallback( - webrtc::EncodedImageCallback* callback) override; - - int32_t Release() override; - - int32_t SetChannelParameters(uint32_t packetLoss, int64_t rtt) override; - - int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) override; - - int32_t SetPeriodicKeyFrames(bool enable) override; - - int32_t CodecConfigParameters(uint8_t* /*buffer*/, - int32_t /*size*/) override; - - struct FunctionCalls - { - int32_t InitEncode; - int32_t Encode; - int32_t RegisterEncodeCompleteCallback; - int32_t Release; - int32_t Reset; - int32_t SetChannelParameters; - int32_t SetRates; - int32_t SetPeriodicKeyFrames; - int32_t CodecConfigParameters; - - }; - - FunctionCalls GetFunctionCalls(); -private: - bool _inited; - webrtc::EncodedImage _encodedImage; - FunctionCalls _functionCalls; - webrtc::EncodedImageCallback* _encodedCompleteCallback; - -}; // end of tbI420Encoder class - - -/***************************/ -/* tbI420Decoder class */ -/***************************/ - -class TbI420Decoder: public webrtc::VideoDecoder -{ -public: - TbI420Decoder(); - virtual ~TbI420Decoder(); - - int32_t InitDecode(const webrtc::VideoCodec* inst, - int32_t numberOfCores) override; - int32_t Decode(const webrtc::EncodedImage& inputImage, - bool missingFrames, - const webrtc::RTPFragmentationHeader* fragmentation, - const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL, - int64_t renderTimeMs = -1) override; - - int32_t RegisterDecodeCompleteCallback( - webrtc::DecodedImageCallback* callback) override; - int32_t Release() override; - int32_t Reset() override; - - struct FunctionCalls - { - int32_t InitDecode; - int32_t Decode; - int32_t RegisterDecodeCompleteCallback; - int32_t Release; - int32_t Reset; - }; - - FunctionCalls GetFunctionCalls(); - -private: - - webrtc::I420VideoFrame _decodedImage; - int32_t _width; - int32_t _height; - bool _inited; - FunctionCalls _functionCalls; - webrtc::DecodedImageCallback* _decodeCompleteCallback; - -}; // end of tbI420Decoder class - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_I420_CODEC_H_ diff --git a/webrtc/video_engine/test/libvietest/include/tb_capture_device.h b/webrtc/video_engine/test/libvietest/include/tb_capture_device.h deleted file mode 100644 index 84d3f77d46..0000000000 --- a/webrtc/video_engine/test/libvietest/include/tb_capture_device.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_CAPTURE_DEVICE_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_CAPTURE_DEVICE_H_ - -#include - -#include "webrtc/modules/video_capture/include/video_capture_factory.h" - -class TbInterfaces; - -class TbCaptureDevice -{ -public: - TbCaptureDevice(TbInterfaces& Engine); - ~TbCaptureDevice(void); - - int captureId; - void ConnectTo(int videoChannel); - void Disconnect(int videoChannel); - std::string device_name() const; - -private: - TbInterfaces& ViE; - webrtc::VideoCaptureModule* vcpm_; - std::string device_name_; -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_CAPTURE_DEVICE_H_ diff --git a/webrtc/video_engine/test/libvietest/include/tb_external_transport.h b/webrtc/video_engine/test/libvietest/include/tb_external_transport.h deleted file mode 100644 index e11c02d181..0000000000 --- a/webrtc/video_engine/test/libvietest/include/tb_external_transport.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// -// tb_external_transport.h -// - -#ifndef WEBRTC_VIDEO_ENGINE_TEST_AUTOTEST_INTERFACE_TB_EXTERNAL_TRANSPORT_H_ -#define WEBRTC_VIDEO_ENGINE_TEST_AUTOTEST_INTERFACE_TB_EXTERNAL_TRANSPORT_H_ - -#include -#include - -#include "webrtc/common_types.h" -#include "webrtc/system_wrappers/interface/thread_wrapper.h" - -namespace webrtc -{ -class CriticalSectionWrapper; -class EventWrapper; -class ViENetwork; -} - -enum RandomLossModel { - kNoLoss, - kUniformLoss, - kGilbertElliotLoss -}; -struct NetworkParameters { - int packet_loss_rate; - int burst_length; // Only applicable for kGilbertElliotLoss. - int mean_one_way_delay; - int std_dev_one_way_delay; - RandomLossModel loss_model; - NetworkParameters(): - packet_loss_rate(0), burst_length(0), mean_one_way_delay(0), - std_dev_one_way_delay(0), loss_model(kNoLoss) {} -}; - -// Allows to subscribe for callback when a frame is started being sent. -class SendFrameCallback -{ -public: - // Called once per frame (when a new RTP timestamp is detected) when the - // first data packet of the frame is being sent using the - // TbExternalTransport.SendPacket method. - virtual void FrameSent(unsigned int rtp_timestamp) = 0; -protected: - SendFrameCallback() {} - virtual ~SendFrameCallback() {} -}; - -// Allows to subscribe for callback when the first packet of a frame is -// received. -class ReceiveFrameCallback -{ -public: - // Called once per frame (when a new RTP timestamp is detected) - // during the processing of the RTP packet queue in - // TbExternalTransport::ViEExternalTransportProcess. - virtual void FrameReceived(unsigned int rtp_timestamp) = 0; -protected: - ReceiveFrameCallback() {} - virtual ~ReceiveFrameCallback() {} -}; - -// External transport implementation for testing purposes. -// A packet loss probability must be set in order to drop packets from the data -// being sent to this class. -// Will never drop packets from the first frame of a video sequence. -class TbExternalTransport : public webrtc::Transport -{ -public: - typedef std::map SsrcChannelMap; - - TbExternalTransport(webrtc::ViENetwork& vieNetwork, - int sender_channel, - TbExternalTransport::SsrcChannelMap* receive_channels); - ~TbExternalTransport(void); - - int SendPacket(int channel, const void* data, size_t len) override; - int SendRTCPPacket(int channel, const void* data, size_t len) override; - - // Should only be called before/after traffic is being processed. - // Only one observer can be set (multiple calls will overwrite each other). - virtual void RegisterSendFrameCallback(SendFrameCallback* callback); - - // Should only be called before/after traffic is being processed. - // Only one observer can be set (multiple calls will overwrite each other). - virtual void RegisterReceiveFrameCallback(ReceiveFrameCallback* callback); - - // The network parameters of the link. Regarding packet losses, packets - // belonging to the first frame (same RTP timestamp) will never be dropped. - void SetNetworkParameters(const NetworkParameters& network_parameters); - void SetSSRCFilter(uint32_t SSRC); - - void ClearStats(); - // |packet_counters| is a map which counts the number of packets sent per - // payload type. - void GetStats(int32_t& numRtpPackets, - int32_t& numDroppedPackets, - int32_t& numRtcpPackets, - std::map* packet_counters); - - void SetTemporalToggle(unsigned char layers); - void EnableSSRCCheck(); - unsigned int ReceivedSSRC(); - - void EnableSequenceNumberCheck(); - unsigned short GetFirstSequenceNumber(); - - bool EmptyQueue() const; - -protected: - static bool ViEExternalTransportRun(void* object); - bool ViEExternalTransportProcess(); -private: - // TODO(mikhal): Break these out to classes. - static int GaussianRandom(int mean_ms, int standard_deviation_ms); - bool UniformLoss(int loss_rate); - bool GilbertElliotLoss(int loss_rate, int burst_length); - int64_t NowMs(); - - enum - { - KMaxPacketSize = 1650 - }; - enum - { - KMaxWaitTimeMs = 100 - }; - typedef struct - { - int8_t packetBuffer[KMaxPacketSize]; - size_t length; - int32_t channel; - int64_t receiveTime; - } VideoPacket; - - int sender_channel_; - SsrcChannelMap* receive_channels_; - webrtc::ViENetwork& _vieNetwork; - rtc::scoped_ptr _thread; - webrtc::EventWrapper& _event; - webrtc::CriticalSectionWrapper& _crit; - webrtc::CriticalSectionWrapper& _statCrit; - - NetworkParameters network_parameters_; - int32_t _rtpCount; - int32_t _rtcpCount; - int32_t _dropCount; - // |packet_counters| is a map which counts the number of packets sent per - // payload type. - std::map packet_counters_; - - std::list _rtpPackets; - std::list _rtcpPackets; - - SendFrameCallback* _send_frame_callback; - ReceiveFrameCallback* _receive_frame_callback; - - unsigned char _temporalLayers; - unsigned short _seqNum; - unsigned short _sendPID; - unsigned char _receivedPID; - bool _switchLayer; - unsigned char _currentRelayLayer; - unsigned int _lastTimeMs; - - bool _checkSSRC; - uint32_t _lastSSRC; - bool _filterSSRC; - uint32_t _SSRC; - bool _checkSequenceNumber; - uint16_t _firstSequenceNumber; - - // Keep track of the first RTP timestamp so we don't do packet loss on - // the first frame. - uint32_t _firstRTPTimestamp; - // Track RTP timestamps so we invoke callbacks properly (if registered). - uint32_t _lastSendRTPTimestamp; - uint32_t _lastReceiveRTPTimestamp; - int64_t last_receive_time_; - bool previous_drop_; -}; - -#endif // WEBRTC_VIDEO_ENGINE_TEST_AUTOTEST_INTERFACE_TB_EXTERNAL_TRANSPORT_H_ diff --git a/webrtc/video_engine/test/libvietest/include/tb_interfaces.h b/webrtc/video_engine/test/libvietest/include/tb_interfaces.h deleted file mode 100644 index 5b52a1e24e..0000000000 --- a/webrtc/video_engine/test/libvietest/include/tb_interfaces.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_INTERFACES_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_INTERFACES_H_ - -#include - -#include "webrtc/base/constructormagic.h" -#include "webrtc/common_types.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_image_process.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/vie_defines.h" - -// This class deals with all the tedium of setting up video engine interfaces. -// It does its work in constructor and destructor, so keeping it in scope is -// enough. It also sets up tracing. -class TbInterfaces -{ -public: - // Sets up all interfaces and creates a trace file - TbInterfaces(const std::string& test_name); - ~TbInterfaces(void); - - webrtc::VideoEngine* video_engine; - webrtc::ViEBase* base; - webrtc::ViECapture* capture; - webrtc::ViERender* render; - webrtc::ViERTP_RTCP* rtp_rtcp; - webrtc::ViECodec* codec; - webrtc::ViENetwork* network; - webrtc::ViEImageProcess* image_process; - - int LastError() { - return base->LastError(); - } - -private: - DISALLOW_COPY_AND_ASSIGN(TbInterfaces); -}; - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_INTERFACES_H_ diff --git a/webrtc/video_engine/test/libvietest/include/tb_video_channel.h b/webrtc/video_engine/test/libvietest/include/tb_video_channel.h deleted file mode 100644 index 7d2557e4ad..0000000000 --- a/webrtc/video_engine/test/libvietest/include/tb_video_channel.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_VIDEO_CHANNEL_H_ -#define WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_VIDEO_CHANNEL_H_ - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" - -namespace webrtc { -namespace test { -class VideoChannelTransport; -} // namespace test -} // namespace webrtc - -class TbVideoChannel { - public: - TbVideoChannel(TbInterfaces& Engine, - webrtc::VideoCodecType sendCodec = webrtc::kVideoCodecVP8, - int width = 352, int height = 288, int frameRate = 30, - int startBitrate = 300); - - ~TbVideoChannel(void); - - void SetFrameSettings(int width, int height, int frameRate); - - void StartSend(const unsigned short rtpPort = 11000, - const char* ipAddress = "127.0.0.1"); - - void StopSend(); - - void StartReceive(const unsigned short rtpPort = 11000); - - void StopReceive(); - - int videoChannel; - - private: - TbInterfaces& ViE; - rtc::scoped_ptr channel_transport_; -}; - - -#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_VIDEO_CHANNEL_H_ diff --git a/webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h b/webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h deleted file mode 100644 index 057f6c8011..0000000000 --- a/webrtc/video_engine/test/libvietest/include/vie_external_render_filter.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#ifndef WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_EXTERNAL_RENDER_H_ -#define WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_EXTERNAL_RENDER_H_ - -#include "webrtc/system_wrappers/interface/tick_util.h" -#include "webrtc/video_engine/include/vie_render.h" - -namespace webrtc { - -// A render filter which passes frames directly to an external renderer. This -// is different from plugging the external renderer directly into the sending -// side since this will only run on frames that actually get sent and not on -// frames that only get captured. -class ExternalRendererEffectFilter : public webrtc::ViEEffectFilter { - public: - explicit ExternalRendererEffectFilter(webrtc::ExternalRenderer* renderer) - : width_(0), height_(0), renderer_(renderer) {} - virtual ~ExternalRendererEffectFilter() {} - virtual int Transform(size_t size, - unsigned char* frame_buffer, - int64_t ntp_time_ms, - unsigned int timestamp, - unsigned int width, - unsigned int height) { - if (width != width_ || height_ != height) { - renderer_->FrameSizeChange(width, height, 1); - width_ = width; - height_ = height; - } - return renderer_->DeliverFrame(frame_buffer, - size, - ntp_time_ms, - timestamp, - webrtc::TickTime::MillisecondTimestamp(), - NULL); - } - - private: - unsigned int width_; - unsigned int height_; - webrtc::ExternalRenderer* renderer_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_EXTERNAL_RENDER_H_ diff --git a/webrtc/video_engine/test/libvietest/include/vie_fake_camera.h b/webrtc/video_engine/test/libvietest/include/vie_fake_camera.h deleted file mode 100644 index afb2752a91..0000000000 --- a/webrtc/video_engine/test/libvietest/include/vie_fake_camera.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FAKE_CAMERA_H_ -#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FAKE_CAMERA_H_ - -#include -#include "webrtc/system_wrappers/interface/thread_wrapper.h" - -namespace webrtc { -class ViECapture; -} - -class ViEFileCaptureDevice; - -// Registers an external capture device with the provided capture interface -// and starts running a fake camera by reading frames from a file. The frame- -// reading code runs in a separate thread which makes it possible to run tests -// while the fake camera feeds data into the system. This class is not thread- -// safe in itself (but handles its own thread in a safe manner). -class ViEFakeCamera { - public: - // The argument is the capture interface to register with. - explicit ViEFakeCamera(webrtc::ViECapture* capture_interface); - virtual ~ViEFakeCamera(); - - // Runs the scenario in the class comments. - bool StartCameraInNewThread(const std::string& i420_test_video_path, - int width, - int height); - // Stops the camera and cleans up everything allocated by the start method. - bool StopCamera(); - - int capture_id() const { return capture_id_; } - - private: - webrtc::ViECapture* capture_interface_; - - int capture_id_; - rtc::scoped_ptr camera_thread_; - ViEFileCaptureDevice* file_capture_device_; -}; - -#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FAKE_CAMERA_H_ diff --git a/webrtc/video_engine/test/libvietest/include/vie_file_capture_device.h b/webrtc/video_engine/test/libvietest/include/vie_file_capture_device.h deleted file mode 100644 index 2abd88c41c..0000000000 --- a/webrtc/video_engine/test/libvietest/include/vie_file_capture_device.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FILE_CAPTURE_DEVICE_H_ -#define SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FILE_CAPTURE_DEVICE_H_ - -#include - -#include - -#include "webrtc/typedefs.h" - -namespace webrtc { -class CriticalSectionWrapper; -class EventWrapper; -class ViEExternalCapture; -} - -// This class opens a i420 file and feeds it into a ExternalCapture instance, -// thereby acting as a faked capture device with deterministic input. -class ViEFileCaptureDevice { - public: - // The input sink is where to send the I420 video frames. - explicit ViEFileCaptureDevice(webrtc::ViEExternalCapture* input_sink); - virtual ~ViEFileCaptureDevice(); - - // Opens the provided I420 file and interprets it according to the provided - // width and height. Returns false if the file doesn't exist. - bool OpenI420File(const std::string& path, int width, int height); - - // Reads the previously opened file for at most time_slice_ms milliseconds, - // after which it will return. It will make sure to sleep accordingly so we - // do not send more than max_fps cap (we may send less, though). - void ReadFileFor(uint64_t time_slice_ms, uint32_t max_fps); - - // Closes the opened input file. - void CloseFile(); - - private: - webrtc::ViEExternalCapture* input_sink_; - - FILE* input_file_; - webrtc::CriticalSectionWrapper* mutex_; - - uint32_t frame_length_; - uint32_t width_; - uint32_t height_; -}; - -#endif // SRC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_HELPERS_VIE_FILE_CAPTURE_DEVICE_H_ diff --git a/webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h b/webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h deleted file mode 100644 index d873cd7a6a..0000000000 --- a/webrtc/video_engine/test/libvietest/include/vie_to_file_renderer.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_TO_FILE_RENDERER_H_ -#define WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_TO_FILE_RENDERER_H_ - -#include -#include - -#include -#include - -#include "webrtc/base/constructormagic.h" -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/video_engine/include/vie_render.h" - -namespace webrtc { -class CriticalSectionWrapper; -class EventWrapper; -class ThreadWrapper; -}; // namespace webrtc - -namespace test { -struct Frame; -}; // namespace test - -class ViEToFileRenderer: public webrtc::ExternalRenderer { - public: - ViEToFileRenderer(); - virtual ~ViEToFileRenderer(); - - // Returns false if we fail opening the output filename for writing. - bool PrepareForRendering(const std::string& output_path, - const std::string& output_filename); - - // Closes the output file. - void StopRendering(); - - // Deletes the closed output file from the file system. This is one option - // after calling StopRendering, the other being KeepOutputFile. This file - // renderer will forget about the file after this call and can be used again. - bool DeleteOutputFile(); - - // Renames the closed output file to its previous name with the provided - // prefix prepended. This file renderer will forget about the file after this - // call and can be used again. - bool SaveOutputFile(const std::string& prefix); - - // Implementation of ExternalRenderer: - int FrameSizeChange(unsigned int width, - unsigned int height, - unsigned int number_of_streams) override; - - int DeliverFrame(unsigned char* buffer, - size_t buffer_size, - uint32_t time_stamp, - int64_t ntp_time_ms, - int64_t render_time, - void* handle) override; - - int DeliverI420Frame(const webrtc::I420VideoFrame& webrtc_frame) override; - - bool IsTextureSupported() override; - - const std::string GetFullOutputPath() const; - - private: - typedef std::list FrameQueue; - - // Returns a frame with the specified |buffer_size|. Tries to avoid allocating - // new frames by reusing frames from |free_frame_queue_|. - test::Frame* NewFrame(size_t buffer_size); - static bool RunRenderThread(void* obj); - void ForgetOutputFile(); - bool ProcessRenderQueue(); - - FILE* output_file_; - std::string output_path_; - std::string output_filename_; - rtc::scoped_ptr thread_; - rtc::scoped_ptr frame_queue_cs_; - rtc::scoped_ptr frame_render_event_; - FrameQueue render_queue_; - FrameQueue free_frame_queue_; -}; - -#endif // WEBRTC_VIDEO_ENGINE_TEST_LIBVIETEST_INCLUDE_VIE_TO_FILE_RENDERER_H_ diff --git a/webrtc/video_engine/test/libvietest/libvietest.gypi b/webrtc/video_engine/test/libvietest/libvietest.gypi deleted file mode 100644 index 603cd4b1ea..0000000000 --- a/webrtc/video_engine/test/libvietest/libvietest.gypi +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. -# -# Use of this source code is governed by a BSD-style license -# that can be found in the LICENSE file in the root of the source -# tree. An additional intellectual property rights grant can be found -# in the file PATENTS. All contributing project authors may -# be found in the AUTHORS file in the root of the source tree. -{ - 'targets': [ - { - 'target_name': 'libvietest', - 'type': 'static_library', - 'dependencies': [ - '<(webrtc_root)/common.gyp:webrtc_common', - '<(webrtc_root)/system_wrappers/system_wrappers.gyp:system_wrappers', - '<(DEPTH)/testing/gtest.gyp:gtest', - '<(webrtc_root)/test/test.gyp:test_support', - 'video_engine_core', - ], - 'sources': [ - # Helper classes - 'include/vie_external_render_filter.h', - 'include/vie_fake_camera.h', - 'include/vie_file_capture_device.h', - 'include/vie_to_file_renderer.h', - - 'helpers/vie_fake_camera.cc', - 'helpers/vie_file_capture_device.cc', - 'helpers/vie_to_file_renderer.cc', - - # Testbed classes - 'include/tb_capture_device.h', - 'include/tb_external_transport.h', - 'include/tb_I420_codec.h', - 'include/tb_interfaces.h', - 'include/tb_video_channel.h', - - 'testbed/tb_capture_device.cc', - 'testbed/tb_external_transport.cc', - 'testbed/tb_I420_codec.cc', - 'testbed/tb_interfaces.cc', - 'testbed/tb_video_channel.cc', - ], - # Disable warnings to enable Win64 build, issue 1323. - 'msvs_disabled_warnings': [ - 4267, # size_t to int truncation. - ], - }, - ], -} diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc b/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc deleted file mode 100644 index e9cefcf84d..0000000000 --- a/webrtc/video_engine/test/libvietest/testbed/tb_I420_codec.cc +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/libvietest/include/tb_I420_codec.h" - -#include -#include - -#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" - -TbI420Encoder::TbI420Encoder() : - _inited(false), _encodedImage(), _encodedCompleteCallback(NULL) -{ - // - memset(&_functionCalls, 0, sizeof(_functionCalls)); -} - -TbI420Encoder::~TbI420Encoder() -{ - _inited = false; - if (_encodedImage._buffer != NULL) - { - delete[] _encodedImage._buffer; - _encodedImage._buffer = NULL; - } -} - -int32_t TbI420Encoder::Release() -{ - _functionCalls.Release++; - // should allocate an encoded frame and then release it here, for that we - // actaully need an init flag - if (_encodedImage._buffer != NULL) - { - delete[] _encodedImage._buffer; - _encodedImage._buffer = NULL; - } - _inited = false; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Encoder::SetChannelParameters(uint32_t packetLoss, int64_t rtt) { - _functionCalls.SetChannelParameters++; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Encoder::InitEncode(const webrtc::VideoCodec* inst, - int32_t /*numberOfCores*/, - size_t /*maxPayloadSize */) -{ - _functionCalls.InitEncode++; - if (inst == NULL) - { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } - if (inst->width < 1 || inst->height < 1) - { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } - - // allocating encoded memory - if (_encodedImage._buffer != NULL) - { - delete[] _encodedImage._buffer; - _encodedImage._buffer = NULL; - _encodedImage._size = 0; - } - const uint32_t newSize = (3 * inst->width * inst->height) >> 1; - uint8_t* newBuffer = new uint8_t[newSize]; - if (newBuffer == NULL) - { - return WEBRTC_VIDEO_CODEC_MEMORY; - } - _encodedImage._size = newSize; - _encodedImage._buffer = newBuffer; - - // if no memeory allocation, no point to init - _inited = true; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Encoder::Encode( - const webrtc::I420VideoFrame& inputImage, - const webrtc::CodecSpecificInfo* /*codecSpecificInfo*/, - const std::vector* /*frameTypes*/) -{ - _functionCalls.Encode++; - if (!_inited) - { - return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - } - if (_encodedCompleteCallback == NULL) - { - return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - } - - _encodedImage._frameType = webrtc::kKeyFrame; // no coding - _encodedImage._timeStamp = inputImage.timestamp(); - _encodedImage._encodedHeight = inputImage.height(); - _encodedImage._encodedWidth = inputImage.width(); - size_t reqSize = webrtc::CalcBufferSize(webrtc::kI420, - _encodedImage._encodedWidth, - _encodedImage._encodedHeight); - if (reqSize > _encodedImage._size) - { - - // allocating encoded memory - if (_encodedImage._buffer != NULL) - { - delete[] _encodedImage._buffer; - _encodedImage._buffer = NULL; - _encodedImage._size = 0; - } - uint8_t* newBuffer = new uint8_t[reqSize]; - if (newBuffer == NULL) - { - return WEBRTC_VIDEO_CODEC_MEMORY; - } - _encodedImage._size = reqSize; - _encodedImage._buffer = newBuffer; - } - if (ExtractBuffer(inputImage, _encodedImage._size, - _encodedImage._buffer) < 0) { - return -1; - } - - _encodedImage._length = reqSize; - _encodedCompleteCallback->Encoded(_encodedImage, NULL, NULL); - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Encoder::RegisterEncodeCompleteCallback( - webrtc::EncodedImageCallback* callback) -{ - _functionCalls.RegisterEncodeCompleteCallback++; - _encodedCompleteCallback = callback; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Encoder::SetRates(uint32_t newBitRate, uint32_t frameRate) -{ - _functionCalls.SetRates++; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Encoder::SetPeriodicKeyFrames(bool enable) -{ - _functionCalls.SetPeriodicKeyFrames++; - return WEBRTC_VIDEO_CODEC_ERROR; -} - -int32_t TbI420Encoder::CodecConfigParameters(uint8_t* /*buffer*/, - int32_t /*size*/) -{ - _functionCalls.CodecConfigParameters++; - return WEBRTC_VIDEO_CODEC_ERROR; -} -TbI420Encoder::FunctionCalls TbI420Encoder::GetFunctionCalls() -{ - return _functionCalls; -} - -TbI420Decoder::TbI420Decoder(): - _decodedImage(), _width(0), _height(0), _inited(false), - _decodeCompleteCallback(NULL) -{ - memset(&_functionCalls, 0, sizeof(_functionCalls)); -} - -TbI420Decoder::~TbI420Decoder() -{ - Release(); -} - -int32_t TbI420Decoder::Reset() -{ - _functionCalls.Reset++; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Decoder::InitDecode(const webrtc::VideoCodec* inst, - int32_t /*numberOfCores */) -{ - _functionCalls.InitDecode++; - if (inst == NULL) - { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } - else if (inst->width < 1 || inst->height < 1) - { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } - _width = inst->width; - _height = inst->height; - int half_width = (_width + 1 ) / 2 ; - _decodedImage.CreateEmptyFrame(_width, _height, - _width, half_width, half_width); - _inited = true; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Decoder::Decode( - const webrtc::EncodedImage& inputImage, - bool /*missingFrames*/, - const webrtc::RTPFragmentationHeader* /*fragmentation*/, - const webrtc::CodecSpecificInfo* /*codecSpecificInfo*/, - int64_t /*renderTimeMs*/) -{ - _functionCalls.Decode++; - if (inputImage._buffer == NULL) - { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } - if (_decodeCompleteCallback == NULL) - { - return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - } - if (inputImage._length <= 0) - { - return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; - } - if (!_inited) - { - return WEBRTC_VIDEO_CODEC_UNINITIALIZED; - } - - // Only send complete frames. - if (webrtc::CalcBufferSize(webrtc::kI420,_width,_height) != - inputImage._length) { - return WEBRTC_VIDEO_CODEC_ERROR; - } - - int ret = - ConvertToI420(webrtc::kI420, inputImage._buffer, 0, 0, _width, _height, - 0, webrtc::kVideoRotation_0, &_decodedImage); - - if (ret < 0) - return WEBRTC_VIDEO_CODEC_ERROR; - - _decodedImage.set_timestamp(inputImage._timeStamp); - - _decodeCompleteCallback->Decoded(_decodedImage); - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Decoder::RegisterDecodeCompleteCallback( - webrtc::DecodedImageCallback* callback) -{ - _functionCalls.RegisterDecodeCompleteCallback++; - _decodeCompleteCallback = callback; - return WEBRTC_VIDEO_CODEC_OK; -} - -int32_t TbI420Decoder::Release() -{ - _functionCalls.Release++; - _inited = false; - return WEBRTC_VIDEO_CODEC_OK; -} - -TbI420Decoder::FunctionCalls TbI420Decoder::GetFunctionCalls() -{ - return _functionCalls; -} diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc b/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc deleted file mode 100644 index faa70907cc..0000000000 --- a/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/libvietest/include/tb_capture_device.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" - -TbCaptureDevice::TbCaptureDevice(TbInterfaces& Engine) : - captureId(-1), - ViE(Engine), - vcpm_(NULL) -{ - const unsigned int KMaxDeviceNameLength = 128; - const unsigned int KMaxUniqueIdLength = 256; - char deviceName[KMaxDeviceNameLength]; - memset(deviceName, 0, KMaxDeviceNameLength); - char uniqueId[KMaxUniqueIdLength]; - memset(uniqueId, 0, KMaxUniqueIdLength); - - bool captureDeviceSet = false; - - webrtc::VideoCaptureModule::DeviceInfo* devInfo = - webrtc::VideoCaptureFactory::CreateDeviceInfo(0); - for (size_t captureIdx = 0; - captureIdx < devInfo->NumberOfDevices(); - captureIdx++) - { - EXPECT_EQ(0, devInfo->GetDeviceName(captureIdx, deviceName, - KMaxDeviceNameLength, uniqueId, - KMaxUniqueIdLength)); - - vcpm_ = webrtc::VideoCaptureFactory::Create( - captureIdx, uniqueId); - if (vcpm_ == NULL) // Failed to open this device. Try next. - { - continue; - } - vcpm_->AddRef(); - - int error = ViE.capture->AllocateCaptureDevice(*vcpm_, captureId); - if (error == 0) - { - captureDeviceSet = true; - break; - } - } - delete devInfo; - EXPECT_TRUE(captureDeviceSet); - if (!captureDeviceSet) { - return; - } - - device_name_ = deviceName; - EXPECT_EQ(0, ViE.capture->StartCapture(captureId)); -} - -TbCaptureDevice::~TbCaptureDevice(void) -{ - EXPECT_EQ(0, ViE.capture->StopCapture(captureId)); - EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); - if (vcpm_) - vcpm_->Release(); -} - -void TbCaptureDevice::ConnectTo(int videoChannel) -{ - EXPECT_EQ(0, ViE.capture->ConnectCaptureDevice(captureId, videoChannel)); -} - -void TbCaptureDevice::Disconnect(int videoChannel) -{ - EXPECT_EQ(0, ViE.capture->DisconnectCaptureDevice(videoChannel)); -} - -std::string TbCaptureDevice::device_name() const { - return device_name_; -} diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc b/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc deleted file mode 100644 index d406985ef4..0000000000 --- a/webrtc/video_engine/test/libvietest/testbed/tb_external_transport.cc +++ /dev/null @@ -1,577 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" - -#include - -#include -#include // printf -#include // rand - -#if defined(WEBRTC_LINUX) || defined(__linux__) -#include -#endif -#if defined(WEBRTC_MAC) -#include -#endif - -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/event_wrapper.h" -#include "webrtc/system_wrappers/interface/tick_util.h" -#include "webrtc/video_engine/include/vie_network.h" - -#if defined(_WIN32) -#pragma warning(disable: 4355) // 'this' : used in base member initializer list -#endif - -TbExternalTransport::TbExternalTransport( - webrtc::ViENetwork& vieNetwork, - int sender_channel, - TbExternalTransport::SsrcChannelMap* receive_channels) - : - sender_channel_(sender_channel), - receive_channels_(receive_channels), - _vieNetwork(vieNetwork), - _thread(webrtc::ThreadWrapper::CreateThread( - ViEExternalTransportRun, this, "AutotestTransport")), - _event(*webrtc::EventWrapper::Create()), - _crit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()), - _statCrit(*webrtc::CriticalSectionWrapper::CreateCriticalSection()), - network_parameters_(), - _rtpCount(0), - _rtcpCount(0), - _dropCount(0), - packet_counters_(), - _rtpPackets(), - _rtcpPackets(), - _send_frame_callback(NULL), - _receive_frame_callback(NULL), - _temporalLayers(0), - _seqNum(0), - _sendPID(0), - _receivedPID(0), - _switchLayer(false), - _currentRelayLayer(0), - _lastTimeMs(webrtc::TickTime::MillisecondTimestamp()), - _checkSSRC(false), - _lastSSRC(0), - _filterSSRC(false), - _SSRC(0), - _checkSequenceNumber(0), - _firstSequenceNumber(0), - _firstRTPTimestamp(0), - _lastSendRTPTimestamp(0), - _lastReceiveRTPTimestamp(0), - last_receive_time_(-1), - previous_drop_(false) -{ - srand((int) webrtc::TickTime::MicrosecondTimestamp()); - memset(&network_parameters_, 0, sizeof(NetworkParameters)); - _thread->Start(); - _thread->SetPriority(webrtc::kHighPriority); -} - -TbExternalTransport::~TbExternalTransport() -{ - _event.Set(); - _thread->Stop(); - delete &_event; - - for (std::list::iterator it = _rtpPackets.begin(); - it != _rtpPackets.end(); ++it) { - delete *it; - } - _rtpPackets.clear(); - for (std::list::iterator it = _rtcpPackets.begin(); - it != _rtcpPackets.end(); ++it) { - delete *it; - } - _rtcpPackets.clear(); - delete &_crit; - delete &_statCrit; -} - -int TbExternalTransport::SendPacket(int channel, const void *data, size_t len) -{ - // Parse timestamp from RTP header according to RFC 3550, section 5.1. - uint8_t* ptr = (uint8_t*)data; - uint8_t payload_type = ptr[1] & 0x7F; - uint32_t rtp_timestamp = ptr[4] << 24; - rtp_timestamp += ptr[5] << 16; - rtp_timestamp += ptr[6] << 8; - rtp_timestamp += ptr[7]; - _crit.Enter(); - if (_firstRTPTimestamp == 0) { - _firstRTPTimestamp = rtp_timestamp; - } - _crit.Leave(); - if (_send_frame_callback != NULL && - _lastSendRTPTimestamp != rtp_timestamp) { - _send_frame_callback->FrameSent(rtp_timestamp); - } - ++packet_counters_[payload_type]; - _lastSendRTPTimestamp = rtp_timestamp; - - if (_filterSSRC) - { - uint8_t* ptr = (uint8_t*)data; - uint32_t ssrc = ptr[8] << 24; - ssrc += ptr[9] << 16; - ssrc += ptr[10] << 8; - ssrc += ptr[11]; - if (ssrc != _SSRC) - { - return static_cast(len); // avoid error in trace file - } - } - if (_temporalLayers) { - // parse out vp8 temporal layers - // 12 bytes RTP - uint8_t* ptr = (uint8_t*)data; - - if (ptr[12] & 0x80 && // X-bit - ptr[13] & 0x20) // T-bit - { - int offset = 1; - if (ptr[13] & 0x80) // PID-bit - { - offset++; - if (ptr[14] & 0x80) // 2 byte PID - { - offset++; - } - } - if (ptr[13] & 0x40) - { - offset++; - } - unsigned char TID = (ptr[13 + offset] >> 5); - unsigned int timeMs = NowMs(); - - // Every 5 second switch layer - if (_lastTimeMs + 5000 < timeMs) - { - _lastTimeMs = timeMs; - _switchLayer = true; - } - // Switch at the non ref frame - if (_switchLayer && (ptr[12] & 0x20)) - { // N-bit - _currentRelayLayer++; - if (_currentRelayLayer >= _temporalLayers) - _currentRelayLayer = 0; - - _switchLayer = false; - printf("\t Switching to layer:%d\n", _currentRelayLayer); - } - if (_currentRelayLayer < TID) - { - return static_cast(len); // avoid error in trace file - } - if (ptr[14] & 0x80) // 2 byte PID - { - if(_receivedPID != ptr[15]) - { - _sendPID++; - _receivedPID = ptr[15]; - } - } else - { - if(_receivedPID != ptr[14]) - { - _sendPID++; - _receivedPID = ptr[14]; - } - } - } - } - _statCrit.Enter(); - _rtpCount++; - _statCrit.Leave(); - - // Packet loss. - switch (network_parameters_.loss_model) - { - case (kNoLoss): - previous_drop_ = false; - break; - case (kUniformLoss): - previous_drop_ = UniformLoss(network_parameters_.packet_loss_rate); - break; - case (kGilbertElliotLoss): - previous_drop_ = GilbertElliotLoss( - network_parameters_.packet_loss_rate, - network_parameters_.burst_length); - break; - } - // Never drop packets from the first RTP timestamp (first frame) - // transmitted. - if (previous_drop_ && _firstRTPTimestamp != rtp_timestamp) - { - _statCrit.Enter(); - _dropCount++; - _statCrit.Leave(); - return static_cast(len); - } - - VideoPacket* newPacket = new VideoPacket(); - assert(len <= sizeof(newPacket->packetBuffer)); - memcpy(newPacket->packetBuffer, data, len); - - if (_temporalLayers) - { - // rewrite seqNum - newPacket->packetBuffer[2] = _seqNum >> 8; - newPacket->packetBuffer[3] = _seqNum; - _seqNum++; - - // rewrite PID - if (newPacket->packetBuffer[14] & 0x80) // 2 byte PID - { - newPacket->packetBuffer[14] = (_sendPID >> 8) | 0x80; - newPacket->packetBuffer[15] = _sendPID; - } else - { - newPacket->packetBuffer[14] = (_sendPID & 0x7f); - } - } - newPacket->length = len; - newPacket->channel = channel; - - _crit.Enter(); - // Add jitter and make sure receiveTime isn't lower than receive time of - // last frame. - int network_delay_ms = GaussianRandom( - network_parameters_.mean_one_way_delay, - network_parameters_.std_dev_one_way_delay); - newPacket->receiveTime = NowMs() + network_delay_ms; - if (newPacket->receiveTime < last_receive_time_) { - newPacket->receiveTime = last_receive_time_; - } - _rtpPackets.push_back(newPacket); - _event.Set(); - _crit.Leave(); - return static_cast(len); -} - -void TbExternalTransport::RegisterSendFrameCallback( - SendFrameCallback* callback) { - _send_frame_callback = callback; -} - -void TbExternalTransport::RegisterReceiveFrameCallback( - ReceiveFrameCallback* callback) { - _receive_frame_callback = callback; -} - -// Set to 0 to disable. -void TbExternalTransport::SetTemporalToggle(unsigned char layers) -{ - _temporalLayers = layers; -} - -int TbExternalTransport::SendRTCPPacket(int channel, - const void *data, - size_t len) -{ - _statCrit.Enter(); - _rtcpCount++; - _statCrit.Leave(); - - VideoPacket* newPacket = new VideoPacket(); - assert(len <= sizeof(newPacket->packetBuffer)); - memcpy(newPacket->packetBuffer, data, len); - newPacket->length = len; - newPacket->channel = channel; - - _crit.Enter(); - int network_delay_ms = GaussianRandom( - network_parameters_.mean_one_way_delay, - network_parameters_.std_dev_one_way_delay); - newPacket->receiveTime = NowMs() + network_delay_ms; - _rtcpPackets.push_back(newPacket); - _event.Set(); - _crit.Leave(); - return static_cast(len); -} - -void TbExternalTransport::SetNetworkParameters( - const NetworkParameters& network_parameters) -{ - webrtc::CriticalSectionScoped cs(&_crit); - network_parameters_ = network_parameters; -} - -void TbExternalTransport::SetSSRCFilter(uint32_t ssrc) -{ - webrtc::CriticalSectionScoped cs(&_crit); - _filterSSRC = true; - _SSRC = ssrc; -} - -void TbExternalTransport::ClearStats() -{ - webrtc::CriticalSectionScoped cs(&_statCrit); - _rtpCount = 0; - _dropCount = 0; - _rtcpCount = 0; - packet_counters_.clear(); -} - -void TbExternalTransport::GetStats(int32_t& numRtpPackets, - int32_t& numDroppedPackets, - int32_t& numRtcpPackets, - std::map* packet_counters) -{ - webrtc::CriticalSectionScoped cs(&_statCrit); - numRtpPackets = _rtpCount; - numDroppedPackets = _dropCount; - numRtcpPackets = _rtcpCount; - *packet_counters = packet_counters_; -} - -void TbExternalTransport::EnableSSRCCheck() -{ - webrtc::CriticalSectionScoped cs(&_statCrit); - _checkSSRC = true; -} - -unsigned int TbExternalTransport::ReceivedSSRC() -{ - webrtc::CriticalSectionScoped cs(&_statCrit); - return _lastSSRC; -} - -void TbExternalTransport::EnableSequenceNumberCheck() -{ - webrtc::CriticalSectionScoped cs(&_statCrit); - _checkSequenceNumber = true; -} - -unsigned short TbExternalTransport::GetFirstSequenceNumber() -{ - webrtc::CriticalSectionScoped cs(&_statCrit); - return _firstSequenceNumber; -} - -bool TbExternalTransport::EmptyQueue() const { - webrtc::CriticalSectionScoped cs(&_crit); - return _rtpPackets.empty() && _rtcpPackets.empty(); -} - -bool TbExternalTransport::ViEExternalTransportRun(void* object) -{ - return static_cast - (object)->ViEExternalTransportProcess(); -} -bool TbExternalTransport::ViEExternalTransportProcess() -{ - unsigned int waitTime = KMaxWaitTimeMs; - - VideoPacket* packet = NULL; - - _crit.Enter(); - while (!_rtpPackets.empty()) - { - // Take first packet in queue - packet = _rtpPackets.front(); - int64_t timeToReceive = 0; - if (packet) - { - timeToReceive = packet->receiveTime - NowMs(); - } - else - { - // There should never be any empty packets in the list. - assert(false); - } - if (timeToReceive > 0) - { - // No packets to receive yet - if (timeToReceive < waitTime && timeToReceive > 0) - { - waitTime = (unsigned int) timeToReceive; - } - break; - } - _rtpPackets.pop_front(); - _crit.Leave(); - - // Send to ViE - if (packet) - { - unsigned int ssrc = 0; - { - webrtc::CriticalSectionScoped cs(&_statCrit); - ssrc = ((packet->packetBuffer[8]) << 24); - ssrc += (packet->packetBuffer[9] << 16); - ssrc += (packet->packetBuffer[10] << 8); - ssrc += packet->packetBuffer[11]; - if (_checkSSRC) - { - _lastSSRC = ((packet->packetBuffer[8]) << 24); - _lastSSRC += (packet->packetBuffer[9] << 16); - _lastSSRC += (packet->packetBuffer[10] << 8); - _lastSSRC += packet->packetBuffer[11]; - _checkSSRC = false; - } - if (_checkSequenceNumber) - { - _firstSequenceNumber - = (unsigned char) packet->packetBuffer[2] << 8; - _firstSequenceNumber - += (unsigned char) packet->packetBuffer[3]; - _checkSequenceNumber = false; - } - } - // Signal received packet of frame - uint8_t* ptr = (uint8_t*)packet->packetBuffer; - uint32_t rtp_timestamp = ptr[4] << 24; - rtp_timestamp += ptr[5] << 16; - rtp_timestamp += ptr[6] << 8; - rtp_timestamp += ptr[7]; - if (_receive_frame_callback != NULL && - _lastReceiveRTPTimestamp != rtp_timestamp) { - _receive_frame_callback->FrameReceived(rtp_timestamp); - } - _lastReceiveRTPTimestamp = rtp_timestamp; - int destination_channel = sender_channel_; - if (receive_channels_) { - SsrcChannelMap::iterator it = receive_channels_->find(ssrc); - if (it == receive_channels_->end()) { - return false; - } - destination_channel = it->second; - } - _vieNetwork.ReceivedRTPPacket(destination_channel, - packet->packetBuffer, - packet->length, - webrtc::PacketTime()); - delete packet; - packet = NULL; - } - _crit.Enter(); - } - _crit.Leave(); - _crit.Enter(); - while (!_rtcpPackets.empty()) - { - // Take first packet in queue - packet = _rtcpPackets.front(); - int64_t timeToReceive = 0; - if (packet) - { - timeToReceive = packet->receiveTime - NowMs(); - } - else - { - // There should never be any empty packets in the list. - assert(false); - } - if (timeToReceive > 0) - { - // No packets to receive yet - if (timeToReceive < waitTime && timeToReceive > 0) - { - waitTime = (unsigned int) timeToReceive; - } - break; - } - _rtcpPackets.pop_front(); - _crit.Leave(); - - // Send to ViE - if (packet) - { - uint8_t packet_type = static_cast(packet->packetBuffer[1]); - const uint8_t kSenderReportPacketType = 200; - const uint8_t kReceiverReportPacketType = 201; - if (packet_type == kSenderReportPacketType) { - // Sender report. - if (receive_channels_) { - for (SsrcChannelMap::iterator it = receive_channels_->begin(); - it != receive_channels_->end(); ++it) { - _vieNetwork.ReceivedRTCPPacket(it->second, - packet->packetBuffer, - packet->length); - } - } else { - _vieNetwork.ReceivedRTCPPacket(sender_channel_, - packet->packetBuffer, - packet->length); - } - } else if (packet_type == kReceiverReportPacketType) { - // Receiver report. - _vieNetwork.ReceivedRTCPPacket(sender_channel_, - packet->packetBuffer, - packet->length); - } - delete packet; - packet = NULL; - } - _crit.Enter(); - } - _crit.Leave(); - _event.Wait(waitTime + 1); // Add 1 ms to not call to early... - return true; -} - -int64_t TbExternalTransport::NowMs() -{ - return webrtc::TickTime::MillisecondTimestamp(); -} - -bool TbExternalTransport::UniformLoss(int loss_rate) { - int dropThis = rand() % 100; - return (dropThis < loss_rate); -} - -bool TbExternalTransport::GilbertElliotLoss(int loss_rate, int burst_length) { - // Simulate bursty channel (Gilbert model) - // (1st order) Markov chain model with memory of the previous/last - // packet state (loss or received) - - // 0 = received state - // 1 = loss state - - // probTrans10: if previous packet is lost, prob. to -> received state - // probTrans11: if previous packet is lost, prob. to -> loss state - - // probTrans01: if previous packet is received, prob. to -> loss state - // probTrans00: if previous packet is received, prob. to -> received - - // Map the two channel parameters (average loss rate and burst length) - // to the transition probabilities: - double probTrans10 = 100 * (1.0 / burst_length); - double probTrans11 = (100.0 - probTrans10); - double probTrans01 = (probTrans10 * ( loss_rate / (100.0 - loss_rate))); - - // Note: Random loss (Bernoulli) model is a special case where: - // burstLength = 100.0 / (100.0 - _lossPct) (i.e., p10 + p01 = 100) - - if (previous_drop_) { - // Previous packet was not received. - return UniformLoss(probTrans11); - } else { - return UniformLoss(probTrans01); - } -} - -#define PI 3.14159265 -int TbExternalTransport::GaussianRandom(int mean_ms, - int standard_deviation_ms) { - // Creating a Normal distribution variable from two independent uniform - // variables based on the Box-Muller transform. - double uniform1 = (rand() + 1.0) / (RAND_MAX + 1.0); - double uniform2 = (rand() + 1.0) / (RAND_MAX + 1.0); - return static_cast(mean_ms + standard_deviation_ms * - sqrt(-2 * log(uniform1)) * cos(2 * PI * uniform2)); -} diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_interfaces.cc b/webrtc/video_engine/test/libvietest/testbed/tb_interfaces.cc deleted file mode 100644 index fc95967015..0000000000 --- a/webrtc/video_engine/test/libvietest/testbed/tb_interfaces.cc +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/libvietest/include/tb_interfaces.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/test/testsupport/fileutils.h" - -TbInterfaces::TbInterfaces(const std::string& test_name) : - video_engine(NULL), - base(NULL), - capture(NULL), - render(NULL), - rtp_rtcp(NULL), - codec(NULL), - network(NULL), - image_process(NULL) -{ - std::string complete_path = - webrtc::test::OutputPath() + test_name + "_trace.txt"; - - video_engine = webrtc::VideoEngine::Create(); - EXPECT_TRUE(video_engine != NULL); - - EXPECT_EQ(0, video_engine->SetTraceFile(complete_path.c_str())); - EXPECT_EQ(0, video_engine->SetTraceFilter(webrtc::kTraceAll)); - - base = webrtc::ViEBase::GetInterface(video_engine); - EXPECT_TRUE(base != NULL); - - EXPECT_EQ(0, base->Init()); - - capture = webrtc::ViECapture::GetInterface(video_engine); - EXPECT_TRUE(capture != NULL); - - rtp_rtcp = webrtc::ViERTP_RTCP::GetInterface(video_engine); - EXPECT_TRUE(rtp_rtcp != NULL); - - render = webrtc::ViERender::GetInterface(video_engine); - EXPECT_TRUE(render != NULL); - - codec = webrtc::ViECodec::GetInterface(video_engine); - EXPECT_TRUE(codec != NULL); - - network = webrtc::ViENetwork::GetInterface(video_engine); - EXPECT_TRUE(network != NULL); - - image_process = webrtc::ViEImageProcess::GetInterface(video_engine); - EXPECT_TRUE(image_process != NULL); -} - -TbInterfaces::~TbInterfaces(void) -{ - EXPECT_EQ(0, image_process->Release()); - image_process = NULL; - EXPECT_EQ(0, codec->Release()); - codec = NULL; - EXPECT_EQ(0, capture->Release()); - capture = NULL; - EXPECT_EQ(0, render->Release()); - render = NULL; - EXPECT_EQ(0, rtp_rtcp->Release()); - rtp_rtcp = NULL; - EXPECT_EQ(0, network->Release()); - network = NULL; - EXPECT_EQ(0, base->Release()); - base = NULL; - EXPECT_TRUE(webrtc::VideoEngine::Delete(video_engine)) << - "Since we have released all interfaces at this point, deletion " - "should be successful."; - video_engine = NULL; -} diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_video_channel.cc b/webrtc/video_engine/test/libvietest/testbed/tb_video_channel.cc deleted file mode 100644 index 9c5feb11ea..0000000000 --- a/webrtc/video_engine/test/libvietest/testbed/tb_video_channel.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/test/libvietest/include/tb_video_channel.h" - -#include "testing/gtest/include/gtest/gtest.h" -#include "webrtc/test/channel_transport/include/channel_transport.h" - -TbVideoChannel::TbVideoChannel(TbInterfaces& Engine, - webrtc::VideoCodecType sendCodec, int width, - int height, int frameRate, int startBitrate) - : videoChannel(-1), - ViE(Engine) { - EXPECT_EQ(0, ViE.base->CreateChannel(videoChannel)); - channel_transport_.reset(new webrtc::test::VideoChannelTransport( - ViE.network, videoChannel)); - - webrtc::VideoCodec videoCodec; - memset(&videoCodec, 0, sizeof(webrtc::VideoCodec)); - bool sendCodecSet = false; - for (int idx = 0; idx < ViE.codec->NumberOfCodecs(); idx++) { - EXPECT_EQ(0, ViE.codec->GetCodec(idx, videoCodec)); - videoCodec.width = width; - videoCodec.height = height; - videoCodec.maxFramerate = frameRate; - - if (videoCodec.codecType == sendCodec && sendCodecSet == false) { - if (videoCodec.codecType != webrtc::kVideoCodecI420) { - videoCodec.startBitrate = startBitrate; - videoCodec.maxBitrate = startBitrate * 3; - } - EXPECT_EQ(0, ViE.codec->SetSendCodec(videoChannel, videoCodec)); - sendCodecSet = true; - } - if (videoCodec.codecType == webrtc::kVideoCodecVP8) { - videoCodec.width = 352; - videoCodec.height = 288; - } - EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel, videoCodec)); - } - EXPECT_TRUE(sendCodecSet); -} - -TbVideoChannel::~TbVideoChannel() { - EXPECT_EQ(0, ViE.base->DeleteChannel(videoChannel)); -} - -void TbVideoChannel::StartSend(const unsigned short rtp_port, - const char* ip_address) { - EXPECT_EQ(0, channel_transport_->SetSendDestination(ip_address, rtp_port)); - EXPECT_EQ(0, ViE.base->StartSend(videoChannel)); -} - -void TbVideoChannel::SetFrameSettings(int width, int height, int frameRate) { - webrtc::VideoCodec videoCodec; - EXPECT_EQ(0, ViE.codec->GetSendCodec(videoChannel, videoCodec)); - videoCodec.width = width; - videoCodec.height = height; - videoCodec.maxFramerate = frameRate; - - EXPECT_EQ(0, ViE.codec->SetSendCodec(videoChannel, videoCodec)); - EXPECT_EQ(0, ViE.codec->SetReceiveCodec(videoChannel, videoCodec)); -} - -void TbVideoChannel::StopSend() { - EXPECT_EQ(0, ViE.base->StopSend(videoChannel)); -} - -void TbVideoChannel::StartReceive(unsigned short rtp_port) { - EXPECT_EQ(0, channel_transport_->SetLocalReceiver(rtp_port)); - EXPECT_EQ(0, ViE.base->StartReceive(videoChannel)); -} - -void TbVideoChannel::StopReceive() { - EXPECT_EQ(0, ViE.base->StopReceive(videoChannel)); -} diff --git a/webrtc/video_engine/video_engine.gyp b/webrtc/video_engine/video_engine.gyp index 6e72dd551b..41621c6449 100644 --- a/webrtc/video_engine/video_engine.gyp +++ b/webrtc/video_engine/video_engine.gyp @@ -11,14 +11,5 @@ '../build/common.gypi', './video_engine_core.gypi', ], - - 'conditions': [ - ['include_tests==1', { - 'includes': [ - 'test/libvietest/libvietest.gypi', - 'test/auto_test/vie_auto_test.gypi', - ], - }], - ], } diff --git a/webrtc/video_engine/video_engine_core.gypi b/webrtc/video_engine/video_engine_core.gypi index 4dd8614e73..654845cd59 100644 --- a/webrtc/video_engine/video_engine_core.gypi +++ b/webrtc/video_engine/video_engine_core.gypi @@ -53,31 +53,14 @@ 'payload_router.h', 'report_block_stats.h', 'stream_synchronization.h', - 'vie_base_impl.h', - 'vie_capture_impl.h', - 'vie_codec_impl.h', 'vie_defines.h', - 'vie_external_codec_impl.h', - 'vie_image_process_impl.h', - 'vie_impl.h', - 'vie_network_impl.h', - 'vie_ref_count.h', 'vie_remb.h', - 'vie_render_impl.h', - 'vie_rtp_rtcp_impl.h', - 'vie_shared_data.h', 'vie_capturer.h', 'vie_channel.h', 'vie_channel_group.h', - 'vie_channel_manager.h', 'vie_encoder.h', - 'vie_file_image.h', 'vie_frame_provider_base.h', - 'vie_input_manager.h', - 'vie_manager_base.h', 'vie_receiver.h', - 'vie_renderer.h', - 'vie_render_manager.h', 'vie_sender.h', 'vie_sync_module.h', @@ -88,30 +71,13 @@ 'payload_router.cc', 'report_block_stats.cc', 'stream_synchronization.cc', - 'vie_base_impl.cc', - 'vie_capture_impl.cc', - 'vie_codec_impl.cc', - 'vie_external_codec_impl.cc', - 'vie_image_process_impl.cc', - 'vie_impl.cc', - 'vie_network_impl.cc', - 'vie_ref_count.cc', - 'vie_render_impl.cc', - 'vie_rtp_rtcp_impl.cc', - 'vie_shared_data.cc', 'vie_capturer.cc', 'vie_channel.cc', 'vie_channel_group.cc', - 'vie_channel_manager.cc', 'vie_encoder.cc', - 'vie_file_image.cc', 'vie_frame_provider_base.cc', - 'vie_input_manager.cc', - 'vie_manager_base.cc', 'vie_receiver.cc', 'vie_remb.cc', - 'vie_renderer.cc', - 'vie_render_manager.cc', 'vie_sender.cc', 'vie_sync_module.cc', ], # source diff --git a/webrtc/video_engine/vie_base_impl.cc b/webrtc/video_engine/vie_base_impl.cc deleted file mode 100644 index 6ea2d96763..0000000000 --- a/webrtc/video_engine/vie_base_impl.cc +++ /dev/null @@ -1,433 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_base_impl.h" - -#include -#include - -#include "webrtc/base/checks.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" -#include "webrtc/modules/video_coding/main/interface/video_coding.h" -#include "webrtc/modules/video_processing/main/interface/video_processing.h" -#include "webrtc/modules/video_render/include/video_render.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_capturer.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_input_manager.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -ViEBase* ViEBase::GetInterface(VideoEngine* video_engine) { - if (!video_engine) { - return NULL; - } - VideoEngineImpl* vie_impl = static_cast(video_engine); - ViEBaseImpl* vie_base_impl = vie_impl; - (*vie_base_impl)++; // Increase ref count. - - return vie_base_impl; -} - -int ViEBaseImpl::Release() { - (*this)--; // Decrease ref count. - - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_WARNING) << "ViEBase released too many times."; - return -1; - } - return ref_count; -} - -ViEBaseImpl::ViEBaseImpl(const Config& config) - : shared_data_(config) {} - -ViEBaseImpl::~ViEBaseImpl() {} - -int ViEBaseImpl::Init() { - return 0; -} - -int ViEBaseImpl::SetVoiceEngine(VoiceEngine* voice_engine) { - LOG_F(LS_INFO) << "SetVoiceEngine"; - if (shared_data_.channel_manager()->SetVoiceEngine(voice_engine) != 0) { - shared_data_.SetLastError(kViEBaseVoEFailure); - return -1; - } - return 0; -} - -int ViEBaseImpl::RegisterCpuOveruseObserver(int video_channel, - CpuOveruseObserver* observer) { - LOG_F(LS_INFO) << "RegisterCpuOveruseObserver on channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - assert(vie_encoder); - - ViEInputManagerScoped is(*(shared_data_.input_manager())); - ViEFrameProviderBase* provider = is.FrameProvider(vie_encoder); - if (provider) { - ViECapturer* capturer = is.Capture(provider->Id()); - assert(capturer); - capturer->RegisterCpuOveruseObserver(observer); - } - - shared_data_.overuse_observers()->insert( - std::pair(video_channel, observer)); - return 0; -} - -int ViEBaseImpl::SetCpuOveruseOptions(int video_channel, - const CpuOveruseOptions& options) { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - assert(vie_encoder); - - ViEInputManagerScoped is(*(shared_data_.input_manager())); - ViEFrameProviderBase* provider = is.FrameProvider(vie_encoder); - if (provider) { - ViECapturer* capturer = is.Capture(provider->Id()); - if (capturer) { - capturer->SetCpuOveruseOptions(options); - return 0; - } - } - return -1; -} - -void ViEBaseImpl::RegisterCpuOveruseMetricsObserver( - int video_channel, - CpuOveruseMetricsObserver* observer) { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - assert(vie_encoder); - - ViEInputManagerScoped is(*(shared_data_.input_manager())); - ViEFrameProviderBase* provider = is.FrameProvider(vie_encoder); - assert(provider != NULL); - - ViECapturer* capturer = is.Capture(provider->Id()); - assert(capturer); - - capturer->RegisterCpuOveruseMetricsObserver(observer); -} - -int ViEBaseImpl::GetCpuOveruseMetrics(int video_channel, - CpuOveruseMetrics* metrics) { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - assert(vie_encoder); - - ViEInputManagerScoped is(*(shared_data_.input_manager())); - ViEFrameProviderBase* provider = is.FrameProvider(vie_encoder); - if (provider) { - ViECapturer* capturer = is.Capture(provider->Id()); - if (capturer) { - capturer->GetCpuOveruseMetrics(metrics); - return 0; - } - } - return -1; -} - -void ViEBaseImpl::RegisterSendSideDelayObserver( - int channel, SendSideDelayObserver* observer) { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(channel); - assert(vie_channel); - vie_channel->RegisterSendSideDelayObserver(observer); -} - -int ViEBaseImpl::CreateChannel(int& video_channel) { // NOLINT - return CreateChannel(video_channel, static_cast(NULL)); -} - -int ViEBaseImpl::CreateChannel(int& video_channel, // NOLINT - const Config* config) { - if (shared_data_.channel_manager()->CreateChannel(&video_channel, - config) == -1) { - video_channel = -1; - shared_data_.SetLastError(kViEBaseChannelCreationFailed); - return -1; - } - LOG(LS_INFO) << "Video channel created: " << video_channel; - return 0; -} - -int ViEBaseImpl::CreateChannel(int& video_channel, // NOLINT - int original_channel) { - return CreateChannel(video_channel, original_channel, true, false); -} - -int ViEBaseImpl::CreateChannelWithoutDefaultEncoder( - int& video_channel, // NOLINT - int original_channel) { - return CreateChannel(video_channel, original_channel, true, true); -} - -ChannelGroup* ViEBaseImpl::GetChannelGroup(int channel_id) { - return shared_data_.channel_manager()->GetChannelGroup(channel_id); -} - -ViEChannel* ViEBaseImpl::GetChannel(int channel_id) { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(channel_id); - DCHECK(vie_channel); - return vie_channel; -} - -ViEEncoder* ViEBaseImpl::GetEncoder(int channel_id) { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(channel_id); - DCHECK(vie_encoder); - return vie_encoder; -} - -int ViEBaseImpl::CreateReceiveChannel(int& video_channel, // NOLINT - int original_channel) { - return CreateChannel(video_channel, original_channel, false, true); -} - -int ViEBaseImpl::DeleteChannel(const int video_channel) { - { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - - // Deregister the ViEEncoder if no other channel is using it. - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!cs.ChannelUsingViEEncoder(video_channel)) { - ViEInputManagerScoped is(*(shared_data_.input_manager())); - ViEFrameProviderBase* provider = is.FrameProvider(vie_encoder); - if (provider) { - provider->DeregisterFrameCallback(vie_encoder); - } - } - } - - if (shared_data_.channel_manager()->DeleteChannel(video_channel) == -1) { - shared_data_.SetLastError(kViEBaseUnknownError); - return -1; - } - LOG(LS_INFO) << "Channel deleted " << video_channel; - return 0; -} - -int ViEBaseImpl::ConnectAudioChannel(const int video_channel, - const int audio_channel) { - LOG_F(LS_INFO) << "ConnectAudioChannel, video channel " << video_channel - << ", audio channel " << audio_channel; - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - if (!cs.Channel(video_channel)) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - - if (shared_data_.channel_manager()->ConnectVoiceChannel(video_channel, - audio_channel) != 0) { - shared_data_.SetLastError(kViEBaseVoEFailure); - return -1; - } - return 0; -} - -int ViEBaseImpl::DisconnectAudioChannel(const int video_channel) { - LOG_F(LS_INFO) << "DisconnectAudioChannel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - if (!cs.Channel(video_channel)) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - - if (shared_data_.channel_manager()->DisconnectVoiceChannel( - video_channel) != 0) { - shared_data_.SetLastError(kViEBaseVoEFailure); - return -1; - } - return 0; -} - -int ViEBaseImpl::StartSend(const int video_channel) { - LOG_F(LS_INFO) << "StartSend: " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - assert(vie_encoder != NULL); - if (vie_encoder->Owner() != video_channel) { - LOG_F(LS_ERROR) << "Can't start send on a receive only channel."; - shared_data_.SetLastError(kViEBaseReceiveOnlyChannel); - return -1; - } - - // Pause and trigger a key frame. - vie_encoder->Pause(); - int32_t error = vie_channel->StartSend(); - if (error != 0) { - vie_encoder->Restart(); - if (error == kViEBaseAlreadySending) { - shared_data_.SetLastError(kViEBaseAlreadySending); - } - LOG_F(LS_ERROR) << "Could not start sending " << video_channel; - shared_data_.SetLastError(kViEBaseUnknownError); - return -1; - } - vie_encoder->SendKeyFrame(); - vie_encoder->Restart(); - return 0; -} - -int ViEBaseImpl::StopSend(const int video_channel) { - LOG_F(LS_INFO) << "StopSend " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - - int32_t error = vie_channel->StopSend(); - if (error != 0) { - if (error == kViEBaseNotSending) { - shared_data_.SetLastError(kViEBaseNotSending); - } else { - LOG_F(LS_ERROR) << "Could not stop sending " << video_channel; - shared_data_.SetLastError(kViEBaseUnknownError); - } - return -1; - } - return 0; -} - -int ViEBaseImpl::StartReceive(const int video_channel) { - LOG_F(LS_INFO) << "StartReceive " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - if (vie_channel->StartReceive() != 0) { - shared_data_.SetLastError(kViEBaseUnknownError); - return -1; - } - return 0; -} - -int ViEBaseImpl::StopReceive(const int video_channel) { - LOG_F(LS_INFO) << "StopReceive " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - if (vie_channel->StopReceive() != 0) { - shared_data_.SetLastError(kViEBaseUnknownError); - return -1; - } - return 0; -} - -int ViEBaseImpl::GetVersion(char version[1024]) { - assert(version != NULL); - strcpy(version, "VideoEngine 42"); - return 0; -} - -int ViEBaseImpl::LastError() { - return shared_data_.LastErrorInternal(); -} - -int ViEBaseImpl::CreateChannel(int& video_channel, // NOLINT - int original_channel, - bool sender, - bool disable_default_encoder) { - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - if (!cs.Channel(original_channel)) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return -1; - } - - if (shared_data_.channel_manager()->CreateChannel( - &video_channel, original_channel, sender, disable_default_encoder) == - -1) { - video_channel = -1; - shared_data_.SetLastError(kViEBaseChannelCreationFailed); - return -1; - } - LOG_F(LS_INFO) << "VideoChannel created: " << video_channel - << ", base channel " << original_channel - << ", is send channel : " << sender; - return 0; -} - -void ViEBaseImpl::RegisterSendStatisticsProxy( - int channel, - SendStatisticsProxy* send_statistics_proxy) { - LOG_F(LS_VERBOSE) << "RegisterSendStatisticsProxy on channel " << channel; - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return; - } - ViEEncoder* vie_encoder = cs.Encoder(channel); - assert(vie_encoder); - - vie_encoder->RegisterSendStatisticsProxy(send_statistics_proxy); -} - -void ViEBaseImpl::RegisterReceiveStatisticsProxy( - int channel, - ReceiveStatisticsProxy* receive_statistics_proxy) { - LOG_F(LS_VERBOSE) << "RegisterReceiveStatisticsProxy on channel " << channel; - ViEChannelManagerScoped cs(*(shared_data_.channel_manager())); - ViEChannel* vie_channel = cs.Channel(channel); - if (!vie_channel) { - shared_data_.SetLastError(kViEBaseInvalidChannelId); - return; - } - vie_channel->RegisterReceiveStatisticsProxy(receive_statistics_proxy); -} -} // namespace webrtc diff --git a/webrtc/video_engine/vie_base_impl.h b/webrtc/video_engine/vie_base_impl.h deleted file mode 100644 index 82c4a75459..0000000000 --- a/webrtc/video_engine/vie_base_impl.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_BASE_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_BASE_IMPL_H_ - -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_ref_count.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -class Config; -class Module; -class VoiceEngine; - -class ViEBaseImpl - : public ViEBase, - public ViERefCount { - public: - virtual int Release(); - - // Implements ViEBase. - virtual int Init(); - virtual int SetVoiceEngine(VoiceEngine* voice_engine); - virtual int RegisterCpuOveruseObserver(int channel, - CpuOveruseObserver* observer); - virtual int SetCpuOveruseOptions(int channel, - const CpuOveruseOptions& options); - void RegisterCpuOveruseMetricsObserver( - int channel, - CpuOveruseMetricsObserver* observer) override; - virtual int GetCpuOveruseMetrics(int channel, - CpuOveruseMetrics* metrics); - void RegisterSendSideDelayObserver(int channel, - SendSideDelayObserver* observer) override; - virtual int CreateChannel(int& video_channel); // NOLINT - virtual int CreateChannel(int& video_channel, // NOLINT - const Config* config); - virtual int CreateChannel(int& video_channel, // NOLINT - int original_channel); - virtual int CreateChannelWithoutDefaultEncoder(int& video_channel, // NOLINT - int original_channel); - - ChannelGroup* GetChannelGroup(int channel_id) override; - ViEChannel* GetChannel(int channel_id) override; - ViEEncoder* GetEncoder(int channel_id) override; - - virtual int CreateReceiveChannel(int& video_channel, // NOLINT - int original_channel); - virtual int DeleteChannel(const int video_channel); - virtual int ConnectAudioChannel(const int video_channel, - const int audio_channel); - virtual int DisconnectAudioChannel(const int video_channel); - virtual int StartSend(const int video_channel); - virtual int StopSend(const int video_channel); - virtual int StartReceive(const int video_channel); - virtual int StopReceive(const int video_channel); - virtual int GetVersion(char version[1024]); - virtual int LastError(); - - ViESharedData* shared_data() { return &shared_data_; } - - protected: - explicit ViEBaseImpl(const Config& config); - virtual ~ViEBaseImpl(); - - private: - int CreateChannel(int& video_channel, int original_channel, // NOLINT - bool sender, bool disable_default_encoder); - - void RegisterSendStatisticsProxy( - int channel, - SendStatisticsProxy* send_statistics_proxy) override; - void RegisterReceiveStatisticsProxy( - int channel, - ReceiveStatisticsProxy* receive_statistics_proxy) override; - // ViEBaseImpl owns ViESharedData used by all interface implementations. - ViESharedData shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_BASE_IMPL_H_ diff --git a/webrtc/video_engine/vie_capture_impl.cc b/webrtc/video_engine/vie_capture_impl.cc deleted file mode 100644 index aa330cc0d5..0000000000 --- a/webrtc/video_engine/vie_capture_impl.cc +++ /dev/null @@ -1,422 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_capture_impl.h" - -#include - -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_capturer.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_input_manager.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -class CpuOveruseObserver; - -ViECapture* ViECapture::GetInterface(VideoEngine* video_engine) { -#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API - if (!video_engine) { - return NULL; - } - VideoEngineImpl* vie_impl = static_cast(video_engine); - ViECaptureImpl* vie_capture_impl = vie_impl; - // Increase ref count. - (*vie_capture_impl)++; - return vie_capture_impl; -#else - return NULL; -#endif -} - -int ViECaptureImpl::Release() { - // Decrease ref count - (*this)--; - - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_WARNING) << "ViECapture released too many times."; - shared_data_->SetLastError(kViEAPIDoesNotExist); - return -1; - } - return ref_count; -} - -ViECaptureImpl::ViECaptureImpl(ViESharedData* shared_data) - : shared_data_(shared_data) {} - -ViECaptureImpl::~ViECaptureImpl() {} - -int ViECaptureImpl::NumberOfCaptureDevices() { - return shared_data_->input_manager()->NumberOfCaptureDevices(); -} - - -int ViECaptureImpl::GetCaptureDevice(unsigned int list_number, - char* device_nameUTF8, - unsigned int device_nameUTF8Length, - char* unique_idUTF8, - unsigned int unique_idUTF8Length) { - return shared_data_->input_manager()->GetDeviceName( - list_number, - device_nameUTF8, device_nameUTF8Length, - unique_idUTF8, unique_idUTF8Length); -} - -int ViECaptureImpl::AllocateCaptureDevice( - const char* unique_idUTF8, - const unsigned int unique_idUTF8Length, - int& capture_id) { - LOG(LS_INFO) << "AllocateCaptureDevice " << unique_idUTF8; - const int32_t result = - shared_data_->input_manager()->CreateCaptureDevice( - unique_idUTF8, - static_cast(unique_idUTF8Length), - capture_id); - if (result != 0) { - shared_data_->SetLastError(result); - return -1; - } - return 0; -} - -int ViECaptureImpl::AllocateExternalCaptureDevice( - int& capture_id, ViEExternalCapture*& external_capture) { - const int32_t result = - shared_data_->input_manager()->CreateExternalCaptureDevice( - external_capture, capture_id); - - if (result != 0) { - shared_data_->SetLastError(result); - return -1; - } - LOG(LS_INFO) << "External capture device allocated: " << capture_id; - return 0; -} - -int ViECaptureImpl::AllocateCaptureDevice( - VideoCaptureModule& capture_module, int& capture_id) { // NOLINT - int32_t result = shared_data_->input_manager()->CreateCaptureDevice( - &capture_module, capture_id); - if (result != 0) { - shared_data_->SetLastError(result); - return -1; - } - LOG(LS_INFO) << "External capture device, by module, allocated: " - << capture_id; - return 0; -} - - -int ViECaptureImpl::ReleaseCaptureDevice(const int capture_id) { - LOG(LS_INFO) << "ReleaseCaptureDevice " << capture_id; - { - ViEInputManagerScoped is((*(shared_data_->input_manager()))); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - } - return shared_data_->input_manager()->DestroyCaptureDevice(capture_id); -} - -int ViECaptureImpl::ConnectCaptureDevice(const int capture_id, - const int video_channel) { - LOG(LS_INFO) << "Connect capture id " << capture_id - << " to channel " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - LOG(LS_ERROR) << "Channel doesn't exist."; - shared_data_->SetLastError(kViECaptureDeviceInvalidChannelId); - return -1; - } - if (vie_encoder->Owner() != video_channel) { - LOG(LS_ERROR) << "Can't connect capture device to a receive device."; - shared_data_->SetLastError(kViECaptureDeviceInvalidChannelId); - return -1; - } - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - // Check if the encoder already has a connected frame provider - if (is.FrameProvider(vie_encoder) != NULL) { - LOG(LS_ERROR) << "Channel already connected to capture device."; - shared_data_->SetLastError(kViECaptureDeviceAlreadyConnected); - return -1; - } - if (vie_capture->RegisterFrameCallback(video_channel, vie_encoder) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - std::map::iterator it = - shared_data_->overuse_observers()->find(video_channel); - if (it != shared_data_->overuse_observers()->end()) { - vie_capture->RegisterCpuOveruseObserver(it->second); - } - return 0; -} - - -int ViECaptureImpl::DisconnectCaptureDevice(const int video_channel) { - LOG(LS_INFO) << "DisconnectCaptureDevice " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - LOG(LS_ERROR) << "Channel doesn't exist."; - shared_data_->SetLastError(kViECaptureDeviceInvalidChannelId); - return -1; - } - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViEFrameProviderBase* frame_provider = is.FrameProvider(vie_encoder); - if (!frame_provider) { - shared_data_->SetLastError(kViECaptureDeviceNotConnected); - return -1; - } - if (frame_provider->Id() < kViECaptureIdBase || - frame_provider->Id() > kViECaptureIdMax) { - shared_data_->SetLastError(kViECaptureDeviceNotConnected); - return -1; - } - - ViECapturer* vie_capture = is.Capture(frame_provider->Id()); - assert(vie_capture); - vie_capture->RegisterCpuOveruseObserver(NULL); - if (frame_provider->DeregisterFrameCallback(vie_encoder) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - - return 0; -} - -int ViECaptureImpl::StartCapture(const int capture_id, - const CaptureCapability& capture_capability) { - LOG(LS_INFO) << "StartCapture " << capture_id; - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - if (vie_capture->Started()) { - shared_data_->SetLastError(kViECaptureDeviceAlreadyStarted); - return -1; - } - if (vie_capture->Start(capture_capability) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -int ViECaptureImpl::StopCapture(const int capture_id) { - LOG(LS_INFO) << "StopCapture " << capture_id; - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - if (!vie_capture->Started()) { - shared_data_->SetLastError(kViECaptureDeviceNotStarted); - return 0; - } - if (vie_capture->Stop() != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -int ViECaptureImpl::SetVideoRotation(const int capture_id, - const VideoRotation rotation) { - LOG(LS_INFO) << "SetRotateCaptureFrames for " << capture_id << ", rotation " - << static_cast(rotation); - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - if (vie_capture->SetVideoRotation(rotation) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -int ViECaptureImpl::SetCaptureDelay(const int capture_id, - const unsigned int capture_delay_ms) { - LOG(LS_INFO) << "SetCaptureDelay " << capture_delay_ms - << ", for device " << capture_id; - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - - if (vie_capture->SetCaptureDelay(capture_delay_ms) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -int ViECaptureImpl::NumberOfCapabilities( - const char* unique_idUTF8, - const unsigned int unique_idUTF8Length) { - -#if defined(WEBRTC_MAC) - // TODO(mflodman) Move to capture module! - // QTKit framework handles all capabilities and capture settings - // automatically (mandatory). - // Thus this function cannot be supported on the Mac platform. - shared_data_->SetLastError(kViECaptureDeviceMacQtkitNotSupported); - LOG_F(LS_ERROR) << "API not supported on Mac OS X."; - return -1; -#endif - return shared_data_->input_manager()->NumberOfCaptureCapabilities( - unique_idUTF8); -} - - -int ViECaptureImpl::GetCaptureCapability(const char* unique_idUTF8, - const unsigned int unique_idUTF8Length, - const unsigned int capability_number, - CaptureCapability& capability) { - -#if defined(WEBRTC_MAC) - // TODO(mflodman) Move to capture module! - // QTKit framework handles all capabilities and capture settings - // automatically (mandatory). - // Thus this function cannot be supported on the Mac platform. - LOG_F(LS_ERROR) << "API not supported on Mac OS X."; - shared_data_->SetLastError(kViECaptureDeviceMacQtkitNotSupported); - return -1; -#endif - if (shared_data_->input_manager()->GetCaptureCapability( - unique_idUTF8, capability_number, capability) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -int ViECaptureImpl::ShowCaptureSettingsDialogBox( - const char* unique_idUTF8, - const unsigned int unique_idUTF8Length, - const char* dialog_title, - void* parent_window, - const unsigned int x, - const unsigned int y) { -#if defined(WEBRTC_MAC) - // TODO(mflodman) Move to capture module - // QTKit framework handles all capabilities and capture settings - // automatically (mandatory). - // Thus this function cannot be supported on the Mac platform. - shared_data_->SetLastError(kViECaptureDeviceMacQtkitNotSupported); - LOG_F(LS_ERROR) << "API not supported on Mac OS X."; - return -1; -#endif - return shared_data_->input_manager()->DisplayCaptureSettingsDialogBox( - unique_idUTF8, dialog_title, - parent_window, x, y); -} - -int ViECaptureImpl::GetOrientation(const char* unique_idUTF8, - VideoRotation& orientation) { - if (shared_data_->input_manager()->GetOrientation( - unique_idUTF8, - orientation) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - - -int ViECaptureImpl::EnableBrightnessAlarm(const int capture_id, - const bool enable) { - LOG(LS_INFO) << "EnableBrightnessAlarm for device " << capture_id - << ", status " << enable; - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - if (vie_capture->EnableBrightnessAlarm(enable) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -int ViECaptureImpl::RegisterObserver(const int capture_id, - ViECaptureObserver& observer) { - LOG(LS_INFO) << "Register capture observer " << capture_id; - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - if (vie_capture->IsObserverRegistered()) { - LOG_F(LS_ERROR) << "Observer already registered."; - shared_data_->SetLastError(kViECaptureObserverAlreadyRegistered); - return -1; - } - if (vie_capture->RegisterObserver(&observer) != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -int ViECaptureImpl::DeregisterObserver(const int capture_id) { - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViECaptureDeviceDoesNotExist); - return -1; - } - if (!vie_capture->IsObserverRegistered()) { - shared_data_->SetLastError(kViECaptureDeviceObserverNotRegistered); - return -1; - } - - if (vie_capture->DeRegisterObserver() != 0) { - shared_data_->SetLastError(kViECaptureDeviceUnknownError); - return -1; - } - return 0; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_capture_impl.h b/webrtc/video_engine/vie_capture_impl.h deleted file mode 100644 index 99be9366b6..0000000000 --- a/webrtc/video_engine/vie_capture_impl.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_CAPTURE_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_CAPTURE_IMPL_H_ - -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_ref_count.h" - -namespace webrtc { - -class ViESharedData; - -class ViECaptureImpl - : public ViECapture, - public ViERefCount { - public: - // Implements ViECapture. - virtual int Release(); - virtual int NumberOfCaptureDevices(); - virtual int GetCaptureDevice(unsigned int list_number, char* device_nameUTF8, - const unsigned int device_nameUTF8Length, - char* unique_idUTF8, - const unsigned int unique_idUTF8Length); - virtual int AllocateCaptureDevice(const char* unique_idUTF8, - const unsigned int unique_idUTF8Length, - int& capture_id); - virtual int AllocateCaptureDevice( - VideoCaptureModule& capture_module, int& capture_id); // NOLINT - virtual int AllocateExternalCaptureDevice( - int& capture_id, ViEExternalCapture *&external_capture); - virtual int ReleaseCaptureDevice(const int capture_id); - - virtual int ConnectCaptureDevice(const int capture_id, - const int video_channel); - virtual int DisconnectCaptureDevice(const int video_channel); - virtual int StartCapture( - const int capture_id, - const CaptureCapability& capture_capability = CaptureCapability()); - virtual int StopCapture(const int capture_id); - virtual int SetVideoRotation(const int capture_id, - const VideoRotation rotation); - virtual int SetCaptureDelay(const int capture_id, - const unsigned int capture_delay_ms); - virtual int NumberOfCapabilities(const char* unique_idUTF8, - const unsigned int unique_idUTF8Length); - virtual int GetCaptureCapability(const char* unique_idUTF8, - const unsigned int unique_idUTF8Length, - const unsigned int capability_number, - CaptureCapability& capability); - virtual int ShowCaptureSettingsDialogBox( - const char* unique_idUTF8, const unsigned int unique_idUTF8Length, - const char* dialog_title, void* parent_window = NULL, - const unsigned int x = 200, const unsigned int y = 200); - virtual int GetOrientation(const char* unique_idUTF8, - VideoRotation& orientation); - virtual int EnableBrightnessAlarm(const int capture_id, const bool enable); - virtual int RegisterObserver(const int capture_id, - ViECaptureObserver& observer); - virtual int DeregisterObserver(const int capture_id); - - protected: - explicit ViECaptureImpl(ViESharedData* shared_data); - virtual ~ViECaptureImpl(); - - private: - ViESharedData* shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_CAPTURE_IMPL_H_ diff --git a/webrtc/video_engine/vie_capturer.cc b/webrtc/video_engine/vie_capturer.cc index aa38b9f071..d47625afdc 100644 --- a/webrtc/video_engine/vie_capturer.cc +++ b/webrtc/video_engine/vie_capturer.cc @@ -23,7 +23,6 @@ #include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/tick_util.h" #include "webrtc/system_wrappers/interface/trace_event.h" -#include "webrtc/video_engine/include/vie_image_process.h" #include "webrtc/video_engine/overuse_frame_detector.h" #include "webrtc/video_engine/vie_defines.h" #include "webrtc/video_engine/vie_encoder.h" @@ -57,19 +56,15 @@ class RegistrableCpuOveruseMetricsObserver : public CpuOveruseMetricsObserver { CpuOveruseMetrics metrics_ GUARDED_BY(crit_); }; -ViECapturer::ViECapturer(int capture_id, - int engine_id, - ProcessThread* module_process_thread) - : ViEFrameProviderBase(capture_id, engine_id), - capture_cs_(CriticalSectionWrapper::CreateCriticalSection()), - effects_and_stats_cs_(CriticalSectionWrapper::CreateCriticalSection()), - capture_module_(NULL), - use_external_capture_(false), +ViECapturer::ViECapturer(ProcessThread* module_process_thread, + ViEFrameCallback* frame_callback) + : capture_cs_(CriticalSectionWrapper::CreateCriticalSection()), module_process_thread_(module_process_thread), - capture_id_(capture_id), + frame_callback_(frame_callback), incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()), - capture_thread_(ThreadWrapper::CreateThread( - ViECaptureThreadFunction, this, "ViECaptureThread")), + capture_thread_(ThreadWrapper::CreateThread(ViECaptureThreadFunction, + this, + "ViECaptureThread")), capture_event_(*EventWrapper::Create()), deliver_event_(*EventWrapper::Create()), stop_(0), @@ -77,15 +72,6 @@ ViECapturer::ViECapturer(int capture_id, delta_ntp_internal_ms_( Clock::GetRealTimeClock()->CurrentNtpInMilliseconds() - TickTime::MillisecondTimestamp()), - effect_filter_(NULL), - image_proc_module_(NULL), - image_proc_module_ref_counter_(0), - deflicker_frame_stats_(NULL), - brightness_frame_stats_(NULL), - current_brightness_level_(Normal), - reported_brightness_level_(Normal), - observer_cs_(CriticalSectionWrapper::CreateCriticalSection()), - observer_(NULL), cpu_overuse_metrics_observer_(new RegistrableCpuOveruseMetricsObserver()), overuse_detector_( new OveruseFrameDetector(Clock::GetRealTimeClock(), @@ -103,214 +89,21 @@ ViECapturer::~ViECapturer() { capture_event_.Set(); // Stop the camera input. - if (capture_module_) { - module_process_thread_->DeRegisterModule(capture_module_); - capture_module_->DeRegisterCaptureDataCallback(); - capture_module_->Release(); - capture_module_ = NULL; - } - capture_thread_->Stop(); delete &capture_event_; delete &deliver_event_; - - if (image_proc_module_) { - VideoProcessingModule::Destroy(image_proc_module_); - } - if (deflicker_frame_stats_) { - delete deflicker_frame_stats_; - deflicker_frame_stats_ = NULL; - } - delete brightness_frame_stats_; -} - -ViECapturer* ViECapturer::CreateViECapturer( - ProcessThread* module_process_thread) { - ViECapturer* capturer = new ViECapturer(0, 0, module_process_thread); - // Init with nullptr, 0 will set capture as an external capturer. - CHECK_EQ(0, capturer->Init(nullptr, 0)); - return capturer; -} - -ViECapturer* ViECapturer::CreateViECapture( - int capture_id, - int engine_id, - const Config& config, - VideoCaptureModule* capture_module, - ProcessThread& module_process_thread) { - ViECapturer* capture = new ViECapturer(capture_id, engine_id, - &module_process_thread); - if (!capture || capture->Init(capture_module) != 0) { - delete capture; - capture = NULL; - } - return capture; -} - -int32_t ViECapturer::Init(VideoCaptureModule* capture_module) { - assert(capture_module_ == NULL); - capture_module_ = capture_module; - capture_module_->RegisterCaptureDataCallback(*this); - capture_module_->AddRef(); - module_process_thread_->RegisterModule(capture_module_); - return 0; -} - -ViECapturer* ViECapturer::CreateViECapture( - int capture_id, - int engine_id, - const Config& config, - const char* device_unique_idUTF8, - const uint32_t device_unique_idUTF8Length, - ProcessThread& module_process_thread) { - ViECapturer* capture = new ViECapturer(capture_id, engine_id, - &module_process_thread); - if (!capture || - capture->Init(device_unique_idUTF8, device_unique_idUTF8Length) != 0) { - delete capture; - capture = NULL; - } - return capture; -} - -int32_t ViECapturer::Init(const char* device_unique_idUTF8, - uint32_t device_unique_idUTF8Length) { - assert(capture_module_ == NULL); - if (device_unique_idUTF8 == NULL) { - use_external_capture_ = true; - return 0; - } else { - capture_module_ = VideoCaptureFactory::Create( - ViEModuleId(engine_id_, capture_id_), device_unique_idUTF8); - } - if (!capture_module_) { - return -1; - } - capture_module_->AddRef(); - capture_module_->RegisterCaptureDataCallback(*this); - module_process_thread_->RegisterModule(capture_module_); - - return 0; -} - -int ViECapturer::FrameCallbackChanged() { - if (use_external_capture_) - return -1; - if (Started() && !CaptureCapabilityFixed()) { - // Reconfigure the camera if a new size is required and the capture device - // does not provide encoded frames. - int best_width; - int best_height; - int best_frame_rate; - VideoCaptureCapability capture_settings; - capture_module_->CaptureSettings(capture_settings); - GetBestFormat(&best_width, &best_height, &best_frame_rate); - if (best_width != 0 && best_height != 0 && best_frame_rate != 0) { - if (best_width != capture_settings.width || - best_height != capture_settings.height || - best_frame_rate != capture_settings.maxFPS || - capture_settings.codecType != kVideoCodecUnknown) { - Stop(); - Start(requested_capability_); - } - } - } - return 0; -} - -int32_t ViECapturer::Start(const CaptureCapability& capture_capability) { - if (use_external_capture_) - return -1; - int width; - int height; - int frame_rate; - VideoCaptureCapability capability; - requested_capability_ = capture_capability; - - if (!CaptureCapabilityFixed()) { - // Ask the observers for best size. - GetBestFormat(&width, &height, &frame_rate); - if (width == 0) { - width = kViECaptureDefaultWidth; - } - if (height == 0) { - height = kViECaptureDefaultHeight; - } - if (frame_rate == 0) { - frame_rate = kViECaptureDefaultFramerate; - } - capability.height = height; - capability.width = width; - capability.maxFPS = frame_rate; - capability.rawType = kVideoI420; - capability.codecType = kVideoCodecUnknown; - } else { - // Width, height and type specified with call to Start, not set by - // observers. - capability.width = requested_capability_.width; - capability.height = requested_capability_.height; - capability.maxFPS = requested_capability_.maxFPS; - capability.rawType = requested_capability_.rawType; - capability.interlaced = requested_capability_.interlaced; - } - return capture_module_->StartCapture(capability); -} - -int32_t ViECapturer::Stop() { - if (use_external_capture_) - return -1; - requested_capability_ = CaptureCapability(); - return capture_module_->StopCapture(); -} - -bool ViECapturer::Started() { - if (use_external_capture_) - return false; - return capture_module_->CaptureStarted(); -} - -const char* ViECapturer::CurrentDeviceName() const { - if (use_external_capture_) - return ""; - return capture_module_->CurrentDeviceName(); } void ViECapturer::RegisterCpuOveruseObserver(CpuOveruseObserver* observer) { overuse_detector_->SetObserver(observer); } -void ViECapturer::SetCpuOveruseOptions(const CpuOveruseOptions& options) { - overuse_detector_->SetOptions(options); -} - void ViECapturer::RegisterCpuOveruseMetricsObserver( CpuOveruseMetricsObserver* observer) { cpu_overuse_metrics_observer_->Set(observer); } -void ViECapturer::GetCpuOveruseMetrics(CpuOveruseMetrics* metrics) const { - *metrics = cpu_overuse_metrics_observer_->GetCpuOveruseMetrics(); -} - -int32_t ViECapturer::SetCaptureDelay(int32_t delay_ms) { - if (use_external_capture_) - return -1; - capture_module_->SetCaptureDelay(delay_ms); - return 0; -} - -int32_t ViECapturer::SetVideoRotation(const VideoRotation rotation) { - if (use_external_capture_) - return -1; - return capture_module_->SetCaptureRotation(rotation); -} - -void ViECapturer::IncomingFrame(const I420VideoFrame& frame) { - OnIncomingCapturedFrame(-1, frame); -} - -void ViECapturer::OnIncomingCapturedFrame(const int32_t capture_id, - const I420VideoFrame& video_frame) { +void ViECapturer::IncomingFrame(const I420VideoFrame& video_frame) { I420VideoFrame incoming_frame = video_frame; if (incoming_frame.ntp_time_ms() != 0) { @@ -321,10 +114,6 @@ void ViECapturer::OnIncomingCapturedFrame(const int32_t capture_id, int64_t render_time = incoming_frame.render_time_ms() != 0 ? incoming_frame.render_time_ms() : TickTime::MillisecondTimestamp(); - // Make sure we render this frame earlier since we know the render time set - // is slightly off since it's being set when the frame was received - // from the camera, and not when the camera actually captured the frame. - render_time -= FrameDelay(); incoming_frame.set_render_time_ms(render_time); incoming_frame.set_ntp_time_ms( render_time + delta_ntp_internal_ms_); @@ -355,93 +144,6 @@ void ViECapturer::OnIncomingCapturedFrame(const int32_t capture_id, capture_event_.Set(); } -void ViECapturer::OnCaptureDelayChanged(const int32_t id, - const int32_t delay) { - LOG(LS_INFO) << "Capture delayed change to " << delay - << " for device " << id; - - // Deliver the network delay to all registered callbacks. - ViEFrameProviderBase::SetFrameDelay(delay); -} - -int32_t ViECapturer::RegisterEffectFilter( - ViEEffectFilter* effect_filter) { - CriticalSectionScoped cs(effects_and_stats_cs_.get()); - - if (effect_filter != NULL && effect_filter_ != NULL) { - LOG_F(LS_ERROR) << "Effect filter already registered."; - return -1; - } - effect_filter_ = effect_filter; - return 0; -} - -int32_t ViECapturer::IncImageProcRefCount() { - if (!image_proc_module_) { - assert(image_proc_module_ref_counter_ == 0); - image_proc_module_ = VideoProcessingModule::Create( - ViEModuleId(engine_id_, capture_id_)); - if (!image_proc_module_) { - LOG_F(LS_ERROR) << "Could not create video processing module."; - return -1; - } - } - image_proc_module_ref_counter_++; - return 0; -} - -int32_t ViECapturer::DecImageProcRefCount() { - image_proc_module_ref_counter_--; - if (image_proc_module_ref_counter_ == 0) { - // Destroy module. - VideoProcessingModule::Destroy(image_proc_module_); - image_proc_module_ = NULL; - } - return 0; -} - -int32_t ViECapturer::EnableDeflickering(bool enable) { - CriticalSectionScoped cs(effects_and_stats_cs_.get()); - if (enable) { - if (deflicker_frame_stats_) { - return -1; - } - if (IncImageProcRefCount() != 0) { - return -1; - } - deflicker_frame_stats_ = new VideoProcessingModule::FrameStats(); - } else { - if (deflicker_frame_stats_ == NULL) { - return -1; - } - DecImageProcRefCount(); - delete deflicker_frame_stats_; - deflicker_frame_stats_ = NULL; - } - return 0; -} - -int32_t ViECapturer::EnableBrightnessAlarm(bool enable) { - CriticalSectionScoped cs(effects_and_stats_cs_.get()); - if (enable) { - if (brightness_frame_stats_) { - return -1; - } - if (IncImageProcRefCount() != 0) { - return -1; - } - brightness_frame_stats_ = new VideoProcessingModule::FrameStats(); - } else { - DecImageProcRefCount(); - if (brightness_frame_stats_ == NULL) { - return -1; - } - delete brightness_frame_stats_; - brightness_frame_stats_ = NULL; - } - return 0; -} - bool ViECapturer::ViECaptureThreadFunction(void* obj) { return static_cast(obj)->ViECaptureProcess(); } @@ -465,14 +167,7 @@ bool ViECapturer::ViECaptureProcess() { if (!deliver_frame.IsZeroSize()) { capture_time = deliver_frame.render_time_ms(); encode_start_time = Clock::GetRealTimeClock()->TimeInMilliseconds(); - DeliverI420Frame(&deliver_frame); - } - if (current_brightness_level_ != reported_brightness_level_) { - CriticalSectionScoped cs(observer_cs_.get()); - if (observer_) { - observer_->BrightnessAlarm(id_, current_brightness_level_); - reported_brightness_level_ = current_brightness_level_; - } + frame_callback_->DeliverFrame(0, deliver_frame, std::vector()); } // Update the overuse detector with the duration. if (encode_start_time != -1) { @@ -487,110 +182,4 @@ bool ViECapturer::ViECaptureProcess() { return true; } -void ViECapturer::DeliverI420Frame(I420VideoFrame* video_frame) { - if (video_frame->native_handle() != NULL) { - ViEFrameProviderBase::DeliverFrame(*video_frame, std::vector()); - return; - } - - // Apply image enhancement and effect filter. - { - CriticalSectionScoped cs(effects_and_stats_cs_.get()); - if (deflicker_frame_stats_) { - if (image_proc_module_->GetFrameStats(deflicker_frame_stats_, - *video_frame) == 0) { - image_proc_module_->Deflickering(video_frame, deflicker_frame_stats_); - } else { - LOG_F(LS_ERROR) << "Could not get frame stats."; - } - } - if (brightness_frame_stats_) { - if (image_proc_module_->GetFrameStats(brightness_frame_stats_, - *video_frame) == 0) { - int32_t brightness = image_proc_module_->BrightnessDetection( - *video_frame, *brightness_frame_stats_); - - switch (brightness) { - case VideoProcessingModule::kNoWarning: - current_brightness_level_ = Normal; - break; - case VideoProcessingModule::kDarkWarning: - current_brightness_level_ = Dark; - break; - case VideoProcessingModule::kBrightWarning: - current_brightness_level_ = Bright; - break; - default: - break; - } - } - } - if (effect_filter_) { - size_t length = - CalcBufferSize(kI420, video_frame->width(), video_frame->height()); - rtc::scoped_ptr video_buffer(new uint8_t[length]); - ExtractBuffer(*video_frame, length, video_buffer.get()); - effect_filter_->Transform(length, - video_buffer.get(), - video_frame->ntp_time_ms(), - video_frame->timestamp(), - video_frame->width(), - video_frame->height()); - } - } - // Deliver the captured frame to all observers (channels, renderer or file). - ViEFrameProviderBase::DeliverFrame(*video_frame, std::vector()); -} - -bool ViECapturer::CaptureCapabilityFixed() { - return requested_capability_.width != 0 && - requested_capability_.height != 0 && - requested_capability_.maxFPS != 0; -} - -int32_t ViECapturer::RegisterObserver(ViECaptureObserver* observer) { - { - CriticalSectionScoped cs(observer_cs_.get()); - if (observer_) { - LOG_F(LS_ERROR) << "Observer already registered."; - return -1; - } - observer_ = observer; - } - capture_module_->RegisterCaptureCallback(*this); - capture_module_->EnableFrameRateCallback(true); - capture_module_->EnableNoPictureAlarm(true); - return 0; -} - -int32_t ViECapturer::DeRegisterObserver() { - capture_module_->EnableFrameRateCallback(false); - capture_module_->EnableNoPictureAlarm(false); - capture_module_->DeRegisterCaptureCallback(); - - CriticalSectionScoped cs(observer_cs_.get()); - observer_ = NULL; - return 0; -} - -bool ViECapturer::IsObserverRegistered() { - CriticalSectionScoped cs(observer_cs_.get()); - return observer_ != NULL; -} - -void ViECapturer::OnCaptureFrameRate(const int32_t id, - const uint32_t frame_rate) { - CriticalSectionScoped cs(observer_cs_.get()); - observer_->CapturedFrameRate(id_, static_cast(frame_rate)); -} - -void ViECapturer::OnNoPictureAlarm(const int32_t id, - const VideoCaptureAlarm alarm) { - LOG(LS_WARNING) << "OnNoPictureAlarm " << id; - - CriticalSectionScoped cs(observer_cs_.get()); - CaptureAlarm vie_alarm = (alarm == Raised) ? AlarmRaised : AlarmCleared; - observer_->NoPictureAlarm(id, vie_alarm); -} - } // namespace webrtc diff --git a/webrtc/video_engine/vie_capturer.h b/webrtc/video_engine/vie_capturer.h index 055406d396..e68009a9bc 100644 --- a/webrtc/video_engine/vie_capturer.h +++ b/webrtc/video_engine/vie_capturer.h @@ -25,115 +25,40 @@ #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/thread_wrapper.h" #include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_base.h" -#include "webrtc/video_engine/include/vie_capture.h" #include "webrtc/video_engine/vie_defines.h" #include "webrtc/video_engine/vie_frame_provider_base.h" namespace webrtc { class Config; +class CpuOveruseMetricsObserver; +class CpuOveruseObserver; class CriticalSectionWrapper; class EventWrapper; -class CpuOveruseObserver; class OveruseFrameDetector; class ProcessThread; -class ViEEffectFilter; -class ViEEncoder; -struct ViEPicture; class RegistrableCpuOveruseMetricsObserver; +class ViEEffectFilter; +class ViEFrameCallback; -class ViECapturer - : public ViEFrameProviderBase, - public ViEExternalCapture, - protected VideoCaptureDataCallback, - protected VideoCaptureFeedBack { +class ViECapturer { public: - ViECapturer(int capture_id, - int engine_id, - ProcessThread* module_process_thread); - - static ViECapturer* CreateViECapturer(ProcessThread* module_process_thread); - - static ViECapturer* CreateViECapture(int capture_id, - int engine_id, - const Config& config, - VideoCaptureModule* capture_module, - ProcessThread& module_process_thread); - - static ViECapturer* CreateViECapture( - int capture_id, - int engine_id, - const Config& config, - const char* device_unique_idUTF8, - uint32_t device_unique_idUTF8Length, - ProcessThread& module_process_thread); - + ViECapturer(ProcessThread* module_process_thread, + ViEFrameCallback* frame_callback); ~ViECapturer(); - // Implements ViEFrameProviderBase. - int FrameCallbackChanged(); - - // Implements ExternalCapture. - void IncomingFrame(const I420VideoFrame& frame) override; - - // Start/Stop. - int32_t Start( - const CaptureCapability& capture_capability = CaptureCapability()); - int32_t Stop(); - bool Started(); - - // Overrides the capture delay. - int32_t SetCaptureDelay(int32_t delay_ms); - - // Sets rotation of the incoming captured frame. - int32_t SetVideoRotation(const VideoRotation rotation); - - // Effect filter. - int32_t RegisterEffectFilter(ViEEffectFilter* effect_filter); - int32_t EnableDeflickering(bool enable); - int32_t EnableBrightnessAlarm(bool enable); - - // Statistics observer. - int32_t RegisterObserver(ViECaptureObserver* observer); - int32_t DeRegisterObserver(); - bool IsObserverRegistered(); - - // Information. - const char* CurrentDeviceName() const; + void IncomingFrame(const I420VideoFrame& frame); void RegisterCpuOveruseObserver(CpuOveruseObserver* observer); - void SetCpuOveruseOptions(const CpuOveruseOptions& options); void RegisterCpuOveruseMetricsObserver(CpuOveruseMetricsObserver* observer); - void GetCpuOveruseMetrics(CpuOveruseMetrics* metrics) const; protected: - int32_t Init(VideoCaptureModule* capture_module); - int32_t Init(const char* device_unique_idUTF8, - uint32_t device_unique_idUTF8Length); - - // Implements VideoCaptureDataCallback. - virtual void OnIncomingCapturedFrame(const int32_t id, - const I420VideoFrame& video_frame); - virtual void OnCaptureDelayChanged(const int32_t id, - const int32_t delay); - - // Returns true if the capture capability has been set in |StartCapture| - // function and may not be changed. - bool CaptureCapabilityFixed(); - // Help function used for keeping track of VideoImageProcesingModule. // Creates the module if it is needed, returns 0 on success and guarantees // that the image proc module exist. int32_t IncImageProcRefCount(); int32_t DecImageProcRefCount(); - // Implements VideoCaptureFeedBack - virtual void OnCaptureFrameRate(const int32_t id, - const uint32_t frame_rate); - virtual void OnNoPictureAlarm(const int32_t id, - const VideoCaptureAlarm alarm); - // Thread functions for deliver captured frames to receivers. static bool ViECaptureThreadFunction(void* obj); bool ViECaptureProcess(); @@ -141,13 +66,10 @@ class ViECapturer private: void DeliverI420Frame(I420VideoFrame* video_frame); - // Never take capture_cs_ before effects_and_stats_cs_! rtc::scoped_ptr capture_cs_; - rtc::scoped_ptr effects_and_stats_cs_; - VideoCaptureModule* capture_module_; - bool use_external_capture_; ProcessThread* const module_process_thread_; - const int capture_id_; + + ViEFrameCallback* const frame_callback_; // Frame used in IncomingFrameI420. rtc::scoped_ptr incoming_frame_cs_; @@ -155,6 +77,7 @@ class ViECapturer // Capture thread. rtc::scoped_ptr capture_thread_; + // TODO(pbos): scoped_ptr EventWrapper& capture_event_; EventWrapper& deliver_event_; @@ -166,23 +89,6 @@ class ViECapturer // Delta used for translating between NTP and internal timestamps. const int64_t delta_ntp_internal_ms_; - // Image processing. - ViEEffectFilter* effect_filter_ GUARDED_BY(effects_and_stats_cs_.get()); - VideoProcessingModule* image_proc_module_; - int image_proc_module_ref_counter_; - VideoProcessingModule::FrameStats* deflicker_frame_stats_ - GUARDED_BY(effects_and_stats_cs_.get()); - VideoProcessingModule::FrameStats* brightness_frame_stats_ - GUARDED_BY(effects_and_stats_cs_.get()); - Brightness current_brightness_level_; - Brightness reported_brightness_level_; - - // Statistics observer. - rtc::scoped_ptr observer_cs_; - ViECaptureObserver* observer_ GUARDED_BY(observer_cs_.get()); - - CaptureCapability requested_capability_; - // Must be declared before overuse_detector_ where it's registered. const rtc::scoped_ptr cpu_overuse_metrics_observer_; diff --git a/webrtc/video_engine/vie_capturer_unittest.cc b/webrtc/video_engine/vie_capturer_unittest.cc index 0f20afc0f1..b32b3bc25c 100644 --- a/webrtc/video_engine/vie_capturer_unittest.cc +++ b/webrtc/video_engine/vie_capturer_unittest.cc @@ -50,40 +50,28 @@ I420VideoFrame* CreateI420VideoFrame(uint8_t length); class ViECapturerTest : public ::testing::Test { protected: ViECapturerTest() - : mock_capture_module_(new NiceMock()), - mock_process_thread_(new NiceMock), + : mock_process_thread_(new NiceMock), mock_frame_callback_(new NiceMock), - data_callback_(NULL), - output_frame_event_(EventWrapper::Create()) { - } + output_frame_event_(EventWrapper::Create()) {} virtual void SetUp() { - EXPECT_CALL(*mock_capture_module_, RegisterCaptureDataCallback(_)) - .WillRepeatedly(Invoke(this, &ViECapturerTest::SetCaptureDataCallback)); EXPECT_CALL(*mock_frame_callback_, DeliverFrame(_, _, _)) .WillRepeatedly( WithArg<1>(Invoke(this, &ViECapturerTest::AddOutputFrame))); Config config; - vie_capturer_.reset( - ViECapturer::CreateViECapture( - 0, 0, config, mock_capture_module_.get(), *mock_process_thread_)); - vie_capturer_->RegisterFrameCallback(0, mock_frame_callback_.get()); + vie_capturer_.reset(new ViECapturer(mock_process_thread_.get(), + mock_frame_callback_.get())); } virtual void TearDown() { - vie_capturer_->DeregisterFrameCallback(mock_frame_callback_.get()); // ViECapturer accesses |mock_process_thread_| in destructor and should // be deleted first. vie_capturer_.reset(); } - void SetCaptureDataCallback(VideoCaptureDataCallback& data_callback) { - data_callback_ = &data_callback; - } - void AddInputFrame(I420VideoFrame* frame) { - data_callback_->OnIncomingCapturedFrame(0, *frame); + vie_capturer_->IncomingFrame(*frame); } void AddOutputFrame(const I420VideoFrame& frame) { @@ -97,13 +85,10 @@ class ViECapturerTest : public ::testing::Test { EXPECT_EQ(kEventSignaled, output_frame_event_->Wait(FRAME_TIMEOUT_MS)); } - rtc::scoped_ptr mock_capture_module_; rtc::scoped_ptr mock_process_thread_; rtc::scoped_ptr mock_frame_callback_; // Used to send input capture frames to ViECapturer. - VideoCaptureDataCallback* data_callback_; - rtc::scoped_ptr vie_capturer_; // Input capture frames of ViECapturer. diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc index ab2c0d3526..fb80ed4040 100644 --- a/webrtc/video_engine/vie_channel.cc +++ b/webrtc/video_engine/vie_channel.cc @@ -33,10 +33,6 @@ #include "webrtc/system_wrappers/interface/thread_wrapper.h" #include "webrtc/video/receive_statistics_proxy.h" #include "webrtc/video_engine/call_stats.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/include/vie_image_process.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" #include "webrtc/video_engine/payload_router.h" #include "webrtc/video_engine/report_block_stats.h" #include "webrtc/video_engine/vie_defines.h" @@ -117,7 +113,6 @@ ViEChannel::ViEChannel(int32_t channel_id, module_process_thread_(module_process_thread), codec_observer_(NULL), do_key_frame_callbackRequest_(false), - rtp_observer_(NULL), intra_frame_observer_(intra_frame_observer), rtt_stats_(rtt_stats), paced_sender_(paced_sender), @@ -129,7 +124,6 @@ ViEChannel::ViEChannel(int32_t channel_id, external_transport_(NULL), decoder_reset_(true), wait_for_key_frame_(false), - effect_filter_(NULL), color_enhancement_(false), mtu_(0), sender_(sender), @@ -1123,20 +1117,6 @@ int32_t ViEChannel::GetRemoteRTCPCName(char rtcp_cname[]) { return rtp_rtcp_->RemoteCNAME(remoteSSRC, rtcp_cname); } -int32_t ViEChannel::RegisterRtpObserver(ViERTPObserver* observer) { - CriticalSectionScoped cs(callback_cs_.get()); - if (observer) { - if (rtp_observer_) { - LOG_F(LS_ERROR) << "Observer already registered."; - return -1; - } - rtp_observer_ = observer; - } else { - rtp_observer_ = NULL; - } - return 0; -} - int32_t ViEChannel::SendApplicationDefinedRTCPPacket( const uint8_t sub_type, uint32_t name, @@ -1490,7 +1470,7 @@ int32_t ViEChannel::StartSend() { rtp_rtcp_->SetSendingMediaStatus(true); if (rtp_rtcp_->Sending()) { - return kViEBaseAlreadySending; + return -1; } if (rtp_rtcp_->SetSendingStatus(true) != 0) { return -1; @@ -1519,7 +1499,7 @@ int32_t ViEChannel::StopSend() { rtp_rtcp->SetSendingMediaStatus(false); } if (!rtp_rtcp_->Sending()) { - return kViEBaseNotSending; + return -1; } // Reset. @@ -1674,18 +1654,6 @@ int32_t ViEChannel::FrameToRender( if (video_frame.native_handle() == NULL) { if (pre_render_callback_ != NULL) pre_render_callback_->FrameCallback(&video_frame); - if (effect_filter_) { - size_t length = - CalcBufferSize(kI420, video_frame.width(), video_frame.height()); - rtc::scoped_ptr video_buffer(new uint8_t[length]); - ExtractBuffer(video_frame, length, video_buffer.get()); - effect_filter_->Transform(length, - video_buffer.get(), - video_frame.ntp_time_ms(), - video_frame.timestamp(), - video_frame.width(), - video_frame.height()); - } if (color_enhancement_) { VideoProcessingModule::ColorEnhancement(&video_frame); } @@ -1918,16 +1886,6 @@ int32_t ViEChannel::VoiceChannel() { return vie_sync_.VoiceChannel(); } -int32_t ViEChannel::RegisterEffectFilter(ViEEffectFilter* effect_filter) { - CriticalSectionScoped cs(callback_cs_.get()); - if (effect_filter && effect_filter_) { - LOG(LS_ERROR) << "Effect filter already registered."; - return -1; - } - effect_filter_ = effect_filter; - return 0; -} - void ViEChannel::RegisterPreRenderCallback( I420FrameCallback* pre_render_callback) { CriticalSectionScoped cs(callback_cs_.get()); @@ -1959,12 +1917,6 @@ void ViEChannel::OnIncomingSSRCChanged(const int32_t id, const uint32_t ssrc) { assert(channel_id_ == ChannelId(id)); rtp_rtcp_->SetRemoteSSRC(ssrc); - CriticalSectionScoped cs(callback_cs_.get()); - { - if (rtp_observer_) { - rtp_observer_->IncomingSSRCChanged(channel_id_, ssrc); - } - } } void ViEChannel::OnIncomingCSRCChanged(const int32_t id, @@ -1972,11 +1924,6 @@ void ViEChannel::OnIncomingCSRCChanged(const int32_t id, const bool added) { assert(channel_id_ == ChannelId(id)); CriticalSectionScoped cs(callback_cs_.get()); - { - if (rtp_observer_) { - rtp_observer_->IncomingCSRCChanged(channel_id_, CSRC, added); - } - } } void ViEChannel::ResetStatistics(uint32_t ssrc) { @@ -1997,12 +1944,6 @@ void ViEChannel::RegisterReceiveStatisticsProxy( vcm_receive_stats_callback_ = receive_statistics_proxy; } -void ViEChannel::ReceivedBWEPacket(int64_t arrival_time_ms, - size_t payload_size, - const RTPHeader& header) { - vie_receiver_.ReceivedBWEPacket(arrival_time_ms, payload_size, header); -} - void ViEChannel::SetIncomingVideoStream( IncomingVideoStream* incoming_video_stream) { CriticalSectionScoped cs(callback_cs_.get()); diff --git a/webrtc/video_engine/vie_channel.h b/webrtc/video_engine/vie_channel.h index 985ad88466..c8b0174304 100644 --- a/webrtc/video_engine/vie_channel.h +++ b/webrtc/video_engine/vie_channel.h @@ -22,8 +22,6 @@ #include "webrtc/system_wrappers/interface/scoped_refptr.h" #include "webrtc/system_wrappers/interface/tick_util.h" #include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" #include "webrtc/video_engine/vie_defines.h" #include "webrtc/video_engine/vie_frame_provider_base.h" #include "webrtc/video_engine/vie_receiver.h" @@ -49,13 +47,51 @@ class RtcpRttStats; class ThreadWrapper; class ViEChannelProtectionCallback; class ViEDecoderObserver; -class ViEEffectFilter; class ViERTPObserver; class VideoCodingModule; class VideoDecoder; class VideoRenderCallback; class VoEVideoSync; +enum StreamType { + kViEStreamTypeNormal = 0, // Normal media stream + kViEStreamTypeRtx = 1 // Retransmission media stream +}; + +// This class declares an abstract interface for a user defined observer. It is +// up to the VideoEngine user to implement a derived class which implements the +// observer class. The observer is registered using RegisterDecoderObserver() +// and deregistered using DeregisterDecoderObserver(). +class ViEDecoderObserver { + public: + // This method is called when a new incoming stream is detected, normally + // triggered by a new incoming SSRC or payload type. + virtual void IncomingCodecChanged(const int video_channel, + const VideoCodec& video_codec) = 0; + + // This method is called once per second containing the frame rate and bit + // rate for the incoming stream + virtual void IncomingRate(const int video_channel, + const unsigned int framerate, + const unsigned int bitrate) = 0; + + // Called periodically with decoder timing information. All values are + // "current" snapshots unless decorated with a min_/max_ prefix. + virtual void DecoderTiming(int decode_ms, + int max_decode_ms, + int current_delay_ms, + int target_delay_ms, + int jitter_buffer_ms, + int min_playout_delay_ms, + int render_delay_ms) = 0; + + // This method is called when the decoder needs a new key frame from encoder + // on the sender. + virtual void RequestNewKeyFrame(const int video_channel) = 0; + + protected: + virtual ~ViEDecoderObserver() {} +}; class ViEChannel : public VCMFrameTypeCallback, public VCMReceiveCallback, @@ -169,7 +205,6 @@ class ViEChannel // Gets the CName of the incoming stream. int32_t GetRemoteRTCPCName(char rtcp_cname[]); - int32_t RegisterRtpObserver(ViERTPObserver* observer); int32_t SendApplicationDefinedRTCPPacket( const uint8_t sub_type, uint32_t name, @@ -360,8 +395,6 @@ class ViEChannel // Implements ViEFrameProviderBase. virtual int FrameCallbackChanged() {return -1;} - int32_t RegisterEffectFilter(ViEEffectFilter* effect_filter); - // New-style callbacks, used by VideoReceiveStream. void RegisterPreRenderCallback(I420FrameCallback* pre_render_callback); void RegisterPreDecodeImageCallback( @@ -372,8 +405,6 @@ class ViEChannel RtcpPacketTypeCounterObserver* observer); void RegisterReceiveStatisticsProxy( ReceiveStatisticsProxy* receive_statistics_proxy); - void ReceivedBWEPacket(int64_t arrival_time_ms, size_t payload_size, - const RTPHeader& header); void SetIncomingVideoStream(IncomingVideoStream* incoming_video_stream); protected: @@ -528,7 +559,6 @@ class ViEChannel ProcessThread& module_process_thread_; ViEDecoderObserver* codec_observer_; bool do_key_frame_callbackRequest_; - ViERTPObserver* rtp_observer_; RtcpIntraFrameObserver* intra_frame_observer_; RtcpRttStats* rtt_stats_; PacedSender* paced_sender_; @@ -547,7 +577,6 @@ class ViEChannel bool wait_for_key_frame_; rtc::scoped_ptr decode_thread_; - ViEEffectFilter* effect_filter_; bool color_enhancement_; // User set MTU, -1 if not set. diff --git a/webrtc/video_engine/vie_channel_manager.cc b/webrtc/video_engine/vie_channel_manager.cc deleted file mode 100644 index 3e091e1f28..0000000000 --- a/webrtc/video_engine/vie_channel_manager.cc +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_channel_manager.h" - -#include - -#include "webrtc/base/checks.h" -#include "webrtc/common.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp.h" -#include "webrtc/modules/utility/interface/process_thread.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/call_stats.h" -#include "webrtc/video_engine/encoder_state_feedback.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_group.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_remb.h" -#include "webrtc/voice_engine/include/voe_video_sync.h" - -namespace webrtc { - -ViEChannelManager::ViEChannelManager(int engine_id, - int number_of_cores, - const Config& config) - : channel_id_critsect_(CriticalSectionWrapper::CreateCriticalSection()), - engine_id_(engine_id), - number_of_cores_(number_of_cores), - free_channel_ids_(new bool[kViEMaxNumberOfChannels]), - free_channel_ids_size_(kViEMaxNumberOfChannels), - voice_sync_interface_(NULL), - module_process_thread_(NULL) { - for (int idx = 0; idx < free_channel_ids_size_; idx++) { - free_channel_ids_[idx] = true; - } -} - -ViEChannelManager::~ViEChannelManager() { - while (!channel_groups_.empty()) { - // The channel group is deleted by DeleteChannel when all its channels have - // been deleted. - for (int channel_id : channel_groups_.front()->GetChannelIds()) { - DeleteChannel(channel_id); - } - } - - if (voice_sync_interface_) { - voice_sync_interface_->Release(); - } - if (channel_id_critsect_) { - delete channel_id_critsect_; - channel_id_critsect_ = NULL; - } - if (free_channel_ids_) { - delete[] free_channel_ids_; - free_channel_ids_ = NULL; - free_channel_ids_size_ = 0; - } - assert(channel_groups_.empty()); -} - -void ViEChannelManager::SetModuleProcessThread( - ProcessThread* module_process_thread) { - assert(!module_process_thread_); - module_process_thread_ = module_process_thread; -} - -int ViEChannelManager::CreateChannel(int* channel_id, - const Config* channel_group_config) { - CriticalSectionScoped cs(channel_id_critsect_); - - // Get a new channel id. - int new_channel_id = FreeChannelId(); - if (new_channel_id == -1) { - return -1; - } - - // Create a new channel group and add this channel. - rtc::scoped_ptr group( - new ChannelGroup(module_process_thread_, channel_group_config)); - - if (!group->CreateSendChannel(new_channel_id, engine_id_, number_of_cores_, - false)) { - ReturnChannelId(new_channel_id); - return -1; - } - - *channel_id = new_channel_id; - group->AddChannel(*channel_id); - channel_groups_.push_back(group.release()); - return 0; -} - -int ViEChannelManager::CreateChannel(int* channel_id, - int original_channel, - bool sender, - bool disable_default_encoder) { - CriticalSectionScoped cs(channel_id_critsect_); - - ChannelGroup* channel_group = FindGroup(original_channel); - if (!channel_group) { - return -1; - } - int new_channel_id = FreeChannelId(); - if (new_channel_id == -1) { - return -1; - } - if (sender) { - if (!channel_group->CreateSendChannel(new_channel_id, engine_id_, - number_of_cores_, - disable_default_encoder)) { - ReturnChannelId(new_channel_id); - return -1; - } - } else { - if (!channel_group->CreateReceiveChannel(new_channel_id, engine_id_, - original_channel, number_of_cores_, - disable_default_encoder)) { - ReturnChannelId(new_channel_id); - return -1; - } - } - *channel_id = new_channel_id; - channel_group->AddChannel(*channel_id); - return 0; -} - -ChannelGroup* ViEChannelManager::GetChannelGroup(int channel_id) { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - DCHECK(group); - return group; -} - -int ViEChannelManager::DeleteChannel(int channel_id) { - ChannelGroup* group = NULL; - { - // Write lock to make sure no one is using the channel. - ViEManagerWriteScoped wl(this); - - // Protect the maps. - CriticalSectionScoped cs(channel_id_critsect_); - - group = FindGroup(channel_id); - if (group == NULL) - return -1; - ReturnChannelId(channel_id); - group->DeleteChannel(channel_id); - - if (group->Empty()) { - channel_groups_.remove(group); - } else { - group = NULL; // Prevent group from being deleted. - } - } - // If statment just to show that this object is not always deleted. - if (group) { - // Delete the group if empty last since the encoder holds a pointer to the - // BitrateController object that the group owns. - LOG(LS_VERBOSE) << "Channel group deleted for channel " << channel_id; - delete group; - } - return 0; -} - -int ViEChannelManager::SetVoiceEngine(VoiceEngine* voice_engine) { - // Write lock to make sure no one is using the channel. - ViEManagerWriteScoped wl(this); - - CriticalSectionScoped cs(channel_id_critsect_); - - VoEVideoSync* sync_interface = NULL; - if (voice_engine) { - // Get new sync interface. - sync_interface = VoEVideoSync::GetInterface(voice_engine); - if (!sync_interface) { - return -1; - } - } - - for (ChannelGroup* group : channel_groups_) { - group->SetSyncInterface(sync_interface); - } - if (voice_sync_interface_) { - voice_sync_interface_->Release(); - } - voice_sync_interface_ = sync_interface; - return 0; -} - -int ViEChannelManager::ConnectVoiceChannel(int channel_id, - int audio_channel_id) { - CriticalSectionScoped cs(channel_id_critsect_); - if (!voice_sync_interface_) { - LOG_F(LS_ERROR) << "No VoE set."; - return -1; - } - ViEChannel* channel = ViEChannelPtr(channel_id); - if (!channel) { - return -1; - } - return channel->SetVoiceChannel(audio_channel_id, voice_sync_interface_); -} - -int ViEChannelManager::DisconnectVoiceChannel(int channel_id) { - CriticalSectionScoped cs(channel_id_critsect_); - ViEChannel* channel = ViEChannelPtr(channel_id); - if (channel) { - channel->SetVoiceChannel(-1, NULL); - return 0; - } - return -1; -} - -bool ViEChannelManager::SetRembStatus(int channel_id, bool sender, - bool receiver) { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (!group) { - return false; - } - ViEChannel* channel = ViEChannelPtr(channel_id); - assert(channel); - - group->SetChannelRembStatus(sender, receiver, channel); - return true; -} - -bool ViEChannelManager::SetReservedTransmitBitrate( - int channel_id, uint32_t reserved_transmit_bitrate_bps) { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (!group) { - return false; - } - - BitrateController* bitrate_controller = group->GetBitrateController(); - bitrate_controller->SetReservedBitrate(reserved_transmit_bitrate_bps); - return true; -} - -void ViEChannelManager::UpdateSsrcs(int channel_id, - const std::list& ssrcs) { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* channel_group = FindGroup(channel_id); - if (channel_group == NULL) { - return; - } - ViEEncoder* encoder = ViEEncoderPtr(channel_id); - assert(encoder); - - EncoderStateFeedback* encoder_state_feedback = - channel_group->GetEncoderStateFeedback(); - // Remove a possible previous setting for this encoder before adding the new - // setting. - encoder_state_feedback->RemoveEncoder(encoder); - for (std::list::const_iterator it = ssrcs.begin(); - it != ssrcs.end(); ++it) { - encoder_state_feedback->AddEncoder(*it, encoder); - } -} - -bool ViEChannelManager::GetEstimatedSendBandwidth( - int channel_id, uint32_t* estimated_bandwidth) const { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (!group) { - return false; - } - group->GetBitrateController()->AvailableBandwidth(estimated_bandwidth); - return true; -} - -bool ViEChannelManager::GetEstimatedReceiveBandwidth( - int channel_id, uint32_t* estimated_bandwidth) const { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (!group) { - return false; - } - std::vector ssrcs; - if (!group->GetRemoteBitrateEstimator()->LatestEstimate( - &ssrcs, estimated_bandwidth) || ssrcs.empty()) { - *estimated_bandwidth = 0; - } - return true; -} - -bool ViEChannelManager::GetPacerQueuingDelayMs(int channel_id, - int64_t* delay_ms) const { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (!group) - return false; - *delay_ms = group->GetPacerQueuingDelayMs(); - return true; -} - -bool ViEChannelManager::SetBitrateConfig(int channel_id, - int min_bitrate_bps, - int start_bitrate_bps, - int max_bitrate_bps) { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (!group) - return false; - BitrateController* bitrate_controller = group->GetBitrateController(); - if (start_bitrate_bps > 0) - bitrate_controller->SetStartBitrate(start_bitrate_bps); - bitrate_controller->SetMinMaxBitrate(min_bitrate_bps, max_bitrate_bps); - return true; -} - -ViEChannel* ViEChannelManager::ViEChannelPtr(int channel_id) const { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (group == NULL) - return NULL; - return group->GetChannel(channel_id); -} - -ViEEncoder* ViEChannelManager::ViEEncoderPtr(int video_channel_id) const { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(video_channel_id); - if (group == NULL) { - return NULL; - } - return group->GetEncoder(video_channel_id); -} - -int ViEChannelManager::FreeChannelId() { - int idx = 0; - while (idx < free_channel_ids_size_) { - if (free_channel_ids_[idx] == true) { - // We've found a free id, allocate it and return. - free_channel_ids_[idx] = false; - return idx + kViEChannelIdBase; - } - idx++; - } - LOG(LS_ERROR) << "Max number of channels reached."; - return -1; -} - -void ViEChannelManager::ReturnChannelId(int channel_id) { - CriticalSectionScoped cs(channel_id_critsect_); - assert(channel_id < kViEMaxNumberOfChannels + kViEChannelIdBase && - channel_id >= kViEChannelIdBase); - free_channel_ids_[channel_id - kViEChannelIdBase] = true; -} - -ChannelGroup* ViEChannelManager::FindGroup(int channel_id) const { - for (ChannelGroups::const_iterator it = channel_groups_.begin(); - it != channel_groups_.end(); ++it) { - if ((*it)->HasChannel(channel_id)) { - return *it; - } - } - return NULL; -} - -bool ViEChannelManager::ChannelUsingViEEncoder(int channel_id) const { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (group == NULL) { - return false; - } - return group->OtherChannelsUsingEncoder(channel_id); -} - -void ViEChannelManager::ChannelsUsingViEEncoder(int channel_id, - ChannelList* channels) const { - CriticalSectionScoped cs(channel_id_critsect_); - ChannelGroup* group = FindGroup(channel_id); - if (group == NULL) - return; - group->GetChannelsUsingEncoder(channel_id, channels); -} - -ViEChannelManagerScoped::ViEChannelManagerScoped( - const ViEChannelManager& vie_channel_manager) - : ViEManagerScopedBase(vie_channel_manager) { -} - -ViEChannel* ViEChannelManagerScoped::Channel(int vie_channel_id) const { - return static_cast(vie_manager_)->ViEChannelPtr( - vie_channel_id); -} -ViEEncoder* ViEChannelManagerScoped::Encoder(int vie_channel_id) const { - return static_cast(vie_manager_)->ViEEncoderPtr( - vie_channel_id); -} - -bool ViEChannelManagerScoped::ChannelUsingViEEncoder(int channel_id) const { - return (static_cast(vie_manager_))-> - ChannelUsingViEEncoder(channel_id); -} - -void ViEChannelManagerScoped::ChannelsUsingViEEncoder( - int channel_id, ChannelList* channels) const { - (static_cast(vie_manager_))-> - ChannelsUsingViEEncoder(channel_id, channels); -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_channel_manager.h b/webrtc/video_engine/vie_channel_manager.h deleted file mode 100644 index 0fbbaf6e9a..0000000000 --- a/webrtc/video_engine/vie_channel_manager.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_ - -#include -#include - -#include "webrtc/engine_configurations.h" -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_manager_base.h" -#include "webrtc/video_engine/vie_remb.h" - -namespace webrtc { - -class ChannelGroup; -class Config; -class CriticalSectionWrapper; -class ProcessThread; -class RtcpRttStats; -class ViEChannel; -class ViEEncoder; -class VoEVideoSync; -class VoiceEngine; - -typedef std::list ChannelGroups; -typedef std::list ChannelList; - -class ViEChannelManager: private ViEManagerBase { - friend class ViEChannelManagerScoped; - public: - ViEChannelManager(int engine_id, - int number_of_cores, - const Config& config); - ~ViEChannelManager(); - - void SetModuleProcessThread(ProcessThread* module_process_thread); - - // Creates a new channel. 'channel_id' will be the id of the created channel. - int CreateChannel(int* channel_id, - const Config* config); - - // Creates a new channel grouped with |original_channel|. The new channel - // will get its own |ViEEncoder| if |sender| is set to true. It will be a - // receive only channel, without an own |ViEEncoder| if |sender| is false. - // Doesn't internally allocate an encoder if |disable_default_encoder|. - int CreateChannel(int* channel_id, - int original_channel, - bool sender, - bool disable_default_encoder); - - ChannelGroup* GetChannelGroup(int channel_id); - - // Deletes a channel. - int DeleteChannel(int channel_id); - - // Set the voice engine instance to be used by all video channels. - int SetVoiceEngine(VoiceEngine* voice_engine); - - // Enables lip sync of the channel. - int ConnectVoiceChannel(int channel_id, int audio_channel_id); - - // Disables lip sync of the channel. - int DisconnectVoiceChannel(int channel_id); - - // Adds a channel to include when sending REMB. - bool SetRembStatus(int channel_id, bool sender, bool receiver); - - bool SetReservedTransmitBitrate(int channel_id, - uint32_t reserved_transmit_bitrate_bps); - - // Updates the SSRCs for a channel. If one of the SSRCs already is registered, - // it will simply be ignored and no error is returned. - void UpdateSsrcs(int channel_id, const std::list& ssrcs); - - bool GetEstimatedSendBandwidth(int channel_id, - uint32_t* estimated_bandwidth) const; - bool GetEstimatedReceiveBandwidth(int channel_id, - uint32_t* estimated_bandwidth) const; - - bool GetPacerQueuingDelayMs(int channel_id, int64_t* delay_ms) const; - - bool SetBitrateConfig(int channel_id, - int min_bitrate_bps, - int start_bitrate_bps, - int max_bitrate_bps); - - bool ReAllocateBitrates(int channel_id); - - private: - // Used by ViEChannelScoped, forcing a manager user to use scoped. - // Returns a pointer to the channel with id 'channel_id'. - ViEChannel* ViEChannelPtr(int channel_id) const; - - // Methods used by ViECaptureScoped and ViEEncoderScoped. - // Gets the ViEEncoder used as input for video_channel_id - ViEEncoder* ViEEncoderPtr(int video_channel_id) const; - - // Returns a free channel id, -1 if failing. - int FreeChannelId(); - - // Returns a previously allocated channel id. - void ReturnChannelId(int channel_id); - - // Returns the iterator to the ChannelGroup containing |channel_id|. - ChannelGroup* FindGroup(int channel_id) const; - - // Returns true if at least one other channels uses the same ViEEncoder as - // channel_id. - bool ChannelUsingViEEncoder(int channel_id) const; - void ChannelsUsingViEEncoder(int channel_id, ChannelList* channels) const; - - // Protects channel_map_ and free_channel_ids_. - CriticalSectionWrapper* channel_id_critsect_; - int engine_id_; - int number_of_cores_; - - bool* free_channel_ids_; - int free_channel_ids_size_; - - // List with all channel groups. - std::list channel_groups_; - - // TODO(mflodman) Make part of channel group. - VoEVideoSync* voice_sync_interface_; - - ProcessThread* module_process_thread_; -}; - -class ViEChannelManagerScoped: private ViEManagerScopedBase { - public: - explicit ViEChannelManagerScoped( - const ViEChannelManager& vie_channel_manager); - ViEChannel* Channel(int vie_channel_id) const; - ViEEncoder* Encoder(int vie_channel_id) const; - - // Returns true if at least one other channels uses the same ViEEncoder as - // channel_id. - bool ChannelUsingViEEncoder(int channel_id) const; - - // Returns a list with pointers to all channels using the same encoder as the - // channel with |channel_id|, including the one with the specified id. - void ChannelsUsingViEEncoder(int channel_id, ChannelList* channels) const; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_CHANNEL_MANAGER_H_ diff --git a/webrtc/video_engine/vie_codec_impl.cc b/webrtc/video_engine/vie_codec_impl.cc deleted file mode 100644 index d746c2cb56..0000000000 --- a/webrtc/video_engine/vie_codec_impl.cc +++ /dev/null @@ -1,687 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_codec_impl.h" - -#include - -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/video_coding/main/interface/video_coding.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_capturer.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_input_manager.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -static void LogCodec(const VideoCodec& codec) { - LOG(LS_INFO) << "CodecType " << codec.codecType - << ", pl_type " << static_cast(codec.plType) - << ", resolution " << codec.width - << " x " << codec.height - << ", start br " << codec.startBitrate - << ", min br " << codec.minBitrate - << ", max br " << codec.maxBitrate - << ", max fps " << static_cast(codec.maxFramerate) - << ", max qp " << codec.qpMax - << ", number of streams " - << static_cast(codec.numberOfSimulcastStreams); - if (codec.codecType == kVideoCodecVP8) { - LOG(LS_INFO) << "VP8 specific settings"; - LOG(LS_INFO) << "pictureLossIndicationOn " - << codec.codecSpecific.VP8.pictureLossIndicationOn - << ", feedbackModeOn " - << codec.codecSpecific.VP8.feedbackModeOn - << ", complexity " - << codec.codecSpecific.VP8.complexity - << ", resilience " - << codec.codecSpecific.VP8.resilience - << ", numberOfTemporalLayers " - << static_cast( - codec.codecSpecific.VP8.numberOfTemporalLayers) - << ", keyFrameinterval " - << codec.codecSpecific.VP8.keyFrameInterval; - for (int idx = 0; idx < codec.numberOfSimulcastStreams; ++idx) { - LOG(LS_INFO) << "Stream " << codec.simulcastStream[idx].width - << " x " << codec.simulcastStream[idx].height; - LOG(LS_INFO) << "Temporal layers " - << static_cast( - codec.simulcastStream[idx].numberOfTemporalLayers) - << ", min br " - << codec.simulcastStream[idx].minBitrate - << ", target br " - << codec.simulcastStream[idx].targetBitrate - << ", max br " - << codec.simulcastStream[idx].maxBitrate - << ", qp max " - << codec.simulcastStream[idx].qpMax; - } - } else if (codec.codecType == kVideoCodecH264) { - LOG(LS_INFO) << "H264 specific settings"; - LOG(LS_INFO) << "profile: " - << codec.codecSpecific.H264.profile - << ", framedropping: " - << codec.codecSpecific.H264.frameDroppingOn - << ", keyFrameInterval: " - << codec.codecSpecific.H264.keyFrameInterval - << ", spslen: " - << codec.codecSpecific.H264.spsLen - << ", ppslen: " - << codec.codecSpecific.H264.ppsLen; - } -} - - -ViECodec* ViECodec::GetInterface(VideoEngine* video_engine) { -#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API - if (!video_engine) { - return NULL; - } - VideoEngineImpl* vie_impl = static_cast(video_engine); - ViECodecImpl* vie_codec_impl = vie_impl; - // Increase ref count. - (*vie_codec_impl)++; - return vie_codec_impl; -#else - return NULL; -#endif -} - -int ViECodecImpl::Release() { - LOG(LS_INFO) << "ViECodec::Release."; - // Decrease ref count. - (*this)--; - - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_WARNING) << "ViECodec released too many times."; - shared_data_->SetLastError(kViEAPIDoesNotExist); - return -1; - } - return ref_count; -} - -ViECodecImpl::ViECodecImpl(ViESharedData* shared_data) - : shared_data_(shared_data) { -} - -ViECodecImpl::~ViECodecImpl() { -} - -int ViECodecImpl::NumberOfCodecs() const { - // +2 because of FEC(RED and ULPFEC) - return static_cast((VideoCodingModule::NumberOfCodecs() + 2)); -} - -int ViECodecImpl::GetCodec(const unsigned char list_number, - VideoCodec& video_codec) const { - if (list_number == VideoCodingModule::NumberOfCodecs()) { - memset(&video_codec, 0, sizeof(VideoCodec)); - strcpy(video_codec.plName, "red"); - video_codec.codecType = kVideoCodecRED; - video_codec.plType = VCM_RED_PAYLOAD_TYPE; - } else if (list_number == VideoCodingModule::NumberOfCodecs() + 1) { - memset(&video_codec, 0, sizeof(VideoCodec)); - strcpy(video_codec.plName, "ulpfec"); - video_codec.codecType = kVideoCodecULPFEC; - video_codec.plType = VCM_ULPFEC_PAYLOAD_TYPE; - } else if (VideoCodingModule::Codec(list_number, &video_codec) != VCM_OK) { - shared_data_->SetLastError(kViECodecInvalidArgument); - return -1; - } - return 0; -} - -int ViECodecImpl::SetSendCodec(const int video_channel, - const VideoCodec& video_codec) { - LOG(LS_INFO) << "SetSendCodec for channel " << video_channel; - LogCodec(video_codec); - if (!CodecValid(video_codec)) { - // Error logged. - shared_data_->SetLastError(kViECodecInvalidCodec); - return -1; - } - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - assert(vie_encoder); - if (vie_encoder->Owner() != video_channel) { - LOG_F(LS_ERROR) << "Receive only channel."; - shared_data_->SetLastError(kViECodecReceiveOnlyChannel); - return -1; - } - // Set a max_bitrate if the user hasn't set one. - VideoCodec video_codec_internal; - memcpy(&video_codec_internal, &video_codec, sizeof(VideoCodec)); - if (video_codec_internal.maxBitrate == 0) { - // Max is one bit per pixel. - video_codec_internal.maxBitrate = (video_codec_internal.width * - video_codec_internal.height * - video_codec_internal.maxFramerate) - / 1000; - LOG(LS_INFO) << "New max bitrate set " << video_codec_internal.maxBitrate; - } - - if (video_codec_internal.startBitrate > 0) { - if (video_codec_internal.startBitrate < video_codec_internal.minBitrate) { - video_codec_internal.startBitrate = video_codec_internal.minBitrate; - } - if (video_codec_internal.startBitrate > video_codec_internal.maxBitrate) { - video_codec_internal.startBitrate = video_codec_internal.maxBitrate; - } - } - - // Make sure to generate a new SSRC if the codec type and/or resolution has - // changed. This won't have any effect if the user has set an SSRC. - bool new_rtp_stream = true; - VideoCodec encoder; - if (vie_encoder->GetEncoder(&encoder) == 0) - new_rtp_stream = encoder.codecType != video_codec_internal.codecType; - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - - // Stop the media flow while reconfiguring. - vie_encoder->Pause(); - - if (vie_encoder->SetEncoder(video_codec_internal) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - - // Give the channel(s) the new information. - ChannelList channels; - cs.ChannelsUsingViEEncoder(video_channel, &channels); - for (ChannelList::iterator it = channels.begin(); it != channels.end(); - ++it) { - bool ret = true; - if ((*it)->SetSendCodec(video_codec_internal, new_rtp_stream) != 0) { - ret = false; - } - if (!ret) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - } - - // TODO(mflodman) Break out this part in GetLocalSsrcList(). - // Update all SSRCs to ViEEncoder. - std::list ssrcs; - if (video_codec_internal.numberOfSimulcastStreams == 0) { - unsigned int ssrc = 0; - if (vie_channel->GetLocalSSRC(0, &ssrc) != 0) { - LOG_F(LS_ERROR) << "Could not get ssrc."; - } - ssrcs.push_back(ssrc); - } else { - for (int idx = 0; idx < video_codec_internal.numberOfSimulcastStreams; - ++idx) { - unsigned int ssrc = 0; - if (vie_channel->GetLocalSSRC(idx, &ssrc) != 0) { - LOG_F(LS_ERROR) << "Could not get ssrc for stream " << idx; - } - ssrcs.push_back(ssrc); - } - } - std::vector ssrc_vector(ssrcs.begin(), ssrcs.end()); - vie_encoder->SetSsrcs(ssrc_vector); - shared_data_->channel_manager()->UpdateSsrcs(video_channel, ssrcs); - - // Update the protection mode, we might be switching NACK/FEC. - vie_encoder->UpdateProtectionMethod(vie_encoder->nack_enabled(), - vie_channel->IsSendingFecEnabled()); - - // Get new best format for frame provider. - ViEFrameProviderBase* frame_provider = is.FrameProvider(vie_encoder); - if (frame_provider) { - frame_provider->FrameCallbackChanged(); - } - // Restart the media flow - if (new_rtp_stream) { - // Stream settings changed, make sure we get a key frame. - vie_encoder->SendKeyFrame(); - } - vie_encoder->Restart(); - return 0; -} - -int ViECodecImpl::GetSendCodec(const int video_channel, - VideoCodec& video_codec) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - return vie_encoder->GetEncoder(&video_codec); -} - -int ViECodecImpl::SetReceiveCodec(const int video_channel, - const VideoCodec& video_codec) { - LOG(LS_INFO) << "SetReceiveCodec for channel " << video_channel; - LOG(LS_INFO) << "Codec type " << video_codec.codecType - << ", payload type " << static_cast(video_codec.plType); - - if (CodecValid(video_codec) == false) { - shared_data_->SetLastError(kViECodecInvalidCodec); - return -1; - } - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - - if (vie_channel->SetReceiveCodec(video_codec) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::GetReceiveCodec(const int video_channel, - VideoCodec& video_codec) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - - if (vie_channel->GetReceiveCodec(&video_codec) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::GetCodecConfigParameters( - const int video_channel, - unsigned char config_parameters[kConfigParameterSize], - unsigned char& config_parameters_size) const { - LOG(LS_INFO) << "GetCodecConfigParameters " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - - if (vie_encoder->GetCodecConfigParameters(config_parameters, - config_parameters_size) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::SetImageScaleStatus(const int video_channel, - const bool enable) { - LOG(LS_INFO) << "SetImageScaleStates for channel " << video_channel - << ", enable: " << enable; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - - if (vie_encoder->ScaleInputImage(enable) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::GetSendCodecStastistics(const int video_channel, - unsigned int& key_frames, - unsigned int& delta_frames) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - - if (vie_encoder->SendCodecStatistics(&key_frames, &delta_frames) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::GetReceiveCodecStastistics(const int video_channel, - unsigned int& key_frames, - unsigned int& delta_frames) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_channel->ReceiveCodecStatistics(&key_frames, &delta_frames) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::GetReceiveSideDelay(const int video_channel, - int* delay_ms) const { - assert(delay_ms != NULL); - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - *delay_ms = vie_channel->ReceiveDelay(); - if (*delay_ms < 0) { - return -1; - } - return 0; -} - -uint32_t ViECodecImpl::GetLastObservedBitrateBps(int video_channel) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - assert(vie_encoder != nullptr); - return vie_encoder->LastObservedBitrateBps(); -} - -int ViECodecImpl::GetCodecTargetBitrate(const int video_channel, - unsigned int* bitrate) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - return vie_encoder->CodecTargetBitrate(static_cast(bitrate)); -} - -int ViECodecImpl::GetNumDiscardedPackets(int video_channel) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - return static_cast(vie_channel->DiscardedPackets()); -} - -int ViECodecImpl::SetKeyFrameRequestCallbackStatus(const int video_channel, - const bool enable) { - LOG(LS_INFO) << "SetKeyFrameRequestCallbackStatus for " << video_channel - << ", enable " << enable; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_channel->EnableKeyFrameRequestCallback(enable) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::SetSignalKeyPacketLossStatus(const int video_channel, - const bool enable, - const bool only_key_frames) { - LOG(LS_INFO) << "SetSignalKeyPacketLossStatus for " << video_channel - << "enable, " << enable - << ", only key frames " << only_key_frames; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_channel->SetSignalPacketLossStatus(enable, only_key_frames) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::RegisterEncoderObserver(const int video_channel, - ViEEncoderObserver& observer) { - LOG(LS_INFO) << "RegisterEncoderObserver for channel " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_encoder->RegisterCodecObserver(&observer) != 0) { - shared_data_->SetLastError(kViECodecObserverAlreadyRegistered); - return -1; - } - return 0; -} - -int ViECodecImpl::DeregisterEncoderObserver(const int video_channel) { - LOG(LS_INFO) << "DeregisterEncoderObserver for channel " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_encoder->RegisterCodecObserver(NULL) != 0) { - shared_data_->SetLastError(kViECodecObserverNotRegistered); - return -1; - } - return 0; -} - -int ViECodecImpl::RegisterDecoderObserver(const int video_channel, - ViEDecoderObserver& observer) { - LOG(LS_INFO) << "RegisterDecoderObserver for channel " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_channel->RegisterCodecObserver(&observer) != 0) { - shared_data_->SetLastError(kViECodecObserverAlreadyRegistered); - return -1; - } - return 0; -} - -int ViECodecImpl::DeregisterDecoderObserver(const int video_channel) { - LOG(LS_INFO) << "DeregisterDecodeObserver for channel " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_channel->RegisterCodecObserver(NULL) != 0) { - shared_data_->SetLastError(kViECodecObserverNotRegistered); - return -1; - } - return 0; -} - -int ViECodecImpl::SendKeyFrame(const int video_channel) { - LOG(LS_INFO) << "SendKeyFrame on channel " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_encoder->SendKeyFrame() != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::WaitForFirstKeyFrame(const int video_channel, - const bool wait) { - LOG(LS_INFO) << "WaitForFirstKeyFrame for channel " << video_channel - << ", wait " << wait; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return -1; - } - if (vie_channel->WaitForKeyFrame(wait) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViECodecImpl::StartDebugRecording(int video_channel, - const char* file_name_utf8) { - LOG(LS_INFO) << "StartDebugRecording for channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - return -1; - } - return vie_encoder->StartDebugRecording(file_name_utf8); -} - -int ViECodecImpl::StopDebugRecording(int video_channel) { - LOG(LS_INFO) << "StopDebugRecording for channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - return -1; - } - return vie_encoder->StopDebugRecording(); -} - -void ViECodecImpl::SuspendBelowMinBitrate(int video_channel) { - LOG(LS_INFO) << "SuspendBelowMinBitrate for channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - return; - } - vie_encoder->SuspendBelowMinBitrate(); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - return; - } - // Must enable pacing when enabling SuspendBelowMinBitrate. Otherwise, no - // padding will be sent when the video is suspended so the video will be - // unable to recover. - vie_channel->SetTransmissionSmoothingStatus(true); -} - -bool ViECodecImpl::GetSendSideDelay(int video_channel, int* avg_delay_ms, - int* max_delay_ms) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidChannelId); - return false; - } - return vie_channel->GetSendSideDelay(avg_delay_ms, max_delay_ms); -} - -bool ViECodecImpl::CodecValid(const VideoCodec& video_codec) { - // Check pl_name matches codec_type. - if (video_codec.codecType == kVideoCodecRED) { -#if defined(WIN32) - if (_strnicmp(video_codec.plName, "red", 3) == 0) { -#else - if (strncasecmp(video_codec.plName, "red", 3) == 0) { -#endif - // We only care about the type and name for red. - return true; - } - LOG_F(LS_ERROR) << "Invalid RED configuration."; - return false; - } else if (video_codec.codecType == kVideoCodecULPFEC) { -#if defined(WIN32) - if (_strnicmp(video_codec.plName, "ULPFEC", 6) == 0) { -#else - if (strncasecmp(video_codec.plName, "ULPFEC", 6) == 0) { -#endif - // We only care about the type and name for ULPFEC. - return true; - } - LOG_F(LS_ERROR) << "Invalid ULPFEC configuration."; - return false; - } else if ((video_codec.codecType == kVideoCodecVP8 && - strncmp(video_codec.plName, "VP8", 4) == 0) || - (video_codec.codecType == kVideoCodecVP9 && - strncmp(video_codec.plName, "VP9", 4) == 0) || - (video_codec.codecType == kVideoCodecI420 && - strncmp(video_codec.plName, "I420", 4) == 0) || - (video_codec.codecType == kVideoCodecH264 && - strncmp(video_codec.plName, "H264", 4) == 0)) { - // OK. - } else if (video_codec.codecType != kVideoCodecGeneric) { - LOG(LS_ERROR) << "Codec type and name mismatch."; - return false; - } - - if (video_codec.plType == 0 || video_codec.plType > 127) { - LOG(LS_ERROR) << "Invalid payload type: " - << static_cast(video_codec.plType); - return false; - } - - if (video_codec.width > kViEMaxCodecWidth || - video_codec.height > kViEMaxCodecHeight) { - LOG(LS_ERROR) << "Invalid codec resolution " << video_codec.width - << " x " << video_codec.height; - return false; - } - - if (video_codec.startBitrate > 0 && - video_codec.startBitrate < kViEMinCodecBitrate) { - LOG(LS_ERROR) << "Invalid start bitrate."; - return false; - } - if (video_codec.minBitrate < kViEMinCodecBitrate) { - LOG(LS_ERROR) << "Invalid min bitrate."; - return false; - } - return true; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_codec_impl.h b/webrtc/video_engine/vie_codec_impl.h deleted file mode 100644 index 8460fec095..0000000000 --- a/webrtc/video_engine/vie_codec_impl.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_CODEC_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_CODEC_IMPL_H_ - -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_ref_count.h" - -namespace webrtc { - -class ViESharedData; - -class ViECodecImpl - : public ViECodec, - public ViERefCount { - public: - virtual int Release(); - - // Implements ViECodec. - virtual int NumberOfCodecs() const; - virtual int GetCodec(const unsigned char list_number, - VideoCodec& video_codec) const; - virtual int SetSendCodec(const int video_channel, - const VideoCodec& video_codec); - virtual int GetSendCodec(const int video_channel, - VideoCodec& video_codec) const; - virtual int SetReceiveCodec(const int video_channel, - const VideoCodec& video_codec); - virtual int GetReceiveCodec(const int video_channel, - VideoCodec& video_codec) const; - virtual int GetCodecConfigParameters( - const int video_channel, - unsigned char config_parameters[kConfigParameterSize], - unsigned char& config_parameters_size) const; - virtual int SetImageScaleStatus(const int video_channel, const bool enable); - virtual int GetSendCodecStastistics(const int video_channel, - unsigned int& key_frames, - unsigned int& delta_frames) const; - virtual int GetReceiveCodecStastistics(const int video_channel, - unsigned int& key_frames, - unsigned int& delta_frames) const; - virtual int GetReceiveSideDelay(const int video_channel, - int* delay_ms) const; - uint32_t GetLastObservedBitrateBps(int video_channel) const override; - virtual int GetCodecTargetBitrate(const int video_channel, - unsigned int* bitrate) const; - virtual int GetNumDiscardedPackets(int video_channel) const; - virtual int SetKeyFrameRequestCallbackStatus(const int video_channel, - const bool enable); - virtual int SetSignalKeyPacketLossStatus(const int video_channel, - const bool enable, - const bool only_key_frames = false); - virtual int RegisterEncoderObserver(const int video_channel, - ViEEncoderObserver& observer); - virtual int DeregisterEncoderObserver(const int video_channel); - virtual int RegisterDecoderObserver(const int video_channel, - ViEDecoderObserver& observer); - virtual int DeregisterDecoderObserver(const int video_channel); - virtual int SendKeyFrame(const int video_channel); - virtual int WaitForFirstKeyFrame(const int video_channel, const bool wait); - virtual int StartDebugRecording(int video_channel, - const char* file_name_utf8); - virtual int StopDebugRecording(int video_channel); - virtual void SuspendBelowMinBitrate(int video_channel); - virtual bool GetSendSideDelay(int video_channel, int* avg_delay_ms, - int* max_delay_ms) const; - - protected: - explicit ViECodecImpl(ViESharedData* shared_data); - virtual ~ViECodecImpl(); - - private: - bool CodecValid(const VideoCodec& video_codec); - - ViESharedData* shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_CODEC_IMPL_H_ diff --git a/webrtc/video_engine/vie_encoder.cc b/webrtc/video_engine/vie_encoder.cc index 2e0fd231b1..285712cc14 100644 --- a/webrtc/video_engine/vie_encoder.cc +++ b/webrtc/video_engine/vie_encoder.cc @@ -31,8 +31,6 @@ #include "webrtc/system_wrappers/interface/tick_util.h" #include "webrtc/system_wrappers/interface/trace_event.h" #include "webrtc/video/send_statistics_proxy.h" -#include "webrtc/video_engine/include/vie_codec.h" -#include "webrtc/video_engine/include/vie_image_process.h" #include "webrtc/video_engine/payload_router.h" #include "webrtc/video_engine/vie_defines.h" @@ -133,7 +131,6 @@ ViEEncoder::ViEEncoder(int32_t channel_id, fec_enabled_(false), nack_enabled_(false), codec_observer_(NULL), - effect_filter_(NULL), module_process_thread_(module_process_thread), has_received_sli_(false), picture_id_sli_(0), @@ -518,22 +515,6 @@ void ViEEncoder::DeliverFrame(int id, I420VideoFrame* decimated_frame = NULL; // TODO(wuchengli): support texture frames. if (video_frame.native_handle() == NULL) { - { - CriticalSectionScoped cs(callback_cs_.get()); - if (effect_filter_) { - size_t length = - CalcBufferSize(kI420, video_frame.width(), video_frame.height()); - rtc::scoped_ptr video_buffer(new uint8_t[length]); - ExtractBuffer(video_frame, length, video_buffer.get()); - effect_filter_->Transform(length, - video_buffer.get(), - video_frame.ntp_time_ms(), - video_frame.timestamp(), - video_frame.width(), - video_frame.height()); - } - } - // Pass frame via preprocessor. const int ret = vpm_->PreprocessFrame(video_frame, &decimated_frame); if (ret == 1) { @@ -873,16 +854,6 @@ void ViEEncoder::OnNetworkChanged(uint32_t bitrate_bps, } } -int32_t ViEEncoder::RegisterEffectFilter(ViEEffectFilter* effect_filter) { - CriticalSectionScoped cs(callback_cs_.get()); - if (effect_filter != NULL && effect_filter_ != NULL) { - LOG_F(LS_ERROR) << "Filter already set."; - return -1; - } - effect_filter_ = effect_filter; - return 0; -} - int ViEEncoder::StartDebugRecording(const char* fileNameUTF8) { return vcm_->StartDebugRecording(fileNameUTF8); } diff --git a/webrtc/video_engine/vie_encoder.h b/webrtc/video_engine/vie_encoder.h index 27991e180e..2e208b5f03 100644 --- a/webrtc/video_engine/vie_encoder.h +++ b/webrtc/video_engine/vie_encoder.h @@ -43,6 +43,26 @@ class ViEEffectFilter; class ViEEncoderObserver; class VideoCodingModule; +// This class declares an abstract interface for a user defined observer. It is +// up to the VideoEngine user to implement a derived class which implements the +// observer class. The observer is registered using RegisterEncoderObserver() +// and deregistered using DeregisterEncoderObserver(). +class ViEEncoderObserver { + public: + // This method is called once per second with the current encoded frame rate + // and bit rate. + virtual void OutgoingRate(const int video_channel, + const unsigned int framerate, + const unsigned int bitrate) = 0; + + // This method is called whenever the state of the SuspendBelowMinBitrate + // changes, i.e., when |is_suspended| toggles. + virtual void SuspendChange(int video_channel, bool is_suspended) = 0; + + protected: + virtual ~ViEEncoderObserver() {} +}; + class ViEEncoder : public RtcpIntraFrameObserver, public VideoEncoderRateObserver, @@ -152,9 +172,6 @@ class ViEEncoder void SetMinTransmitBitrate(int min_transmit_bitrate_kbps); - // Effect filter. - int32_t RegisterEffectFilter(ViEEffectFilter* effect_filter); - // Enables recording of debugging information. int StartDebugRecording(const char* fileNameUTF8); @@ -225,7 +242,6 @@ class ViEEncoder bool nack_enabled_; ViEEncoderObserver* codec_observer_ GUARDED_BY(callback_cs_); - ViEEffectFilter* effect_filter_ GUARDED_BY(callback_cs_); ProcessThread& module_process_thread_; bool has_received_sli_ GUARDED_BY(data_cs_); diff --git a/webrtc/video_engine/vie_external_codec_impl.cc b/webrtc/video_engine/vie_external_codec_impl.cc deleted file mode 100644 index 1be2d31618..0000000000 --- a/webrtc/video_engine/vie_external_codec_impl.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_external_codec_impl.h" - -#include "webrtc/engine_configurations.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -ViEExternalCodec* ViEExternalCodec::GetInterface(VideoEngine* video_engine) { -#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - if (video_engine == NULL) { - return NULL; - } - VideoEngineImpl* vie_impl = static_cast(video_engine); - ViEExternalCodecImpl* vie_external_codec_impl = vie_impl; - // Increase ref count. - (*vie_external_codec_impl)++; - return vie_external_codec_impl; -#else - return NULL; -#endif -} - -int ViEExternalCodecImpl::Release() { - // Decrease ref count. - (*this)--; - - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_WARNING) << "ViEExternalCodec released too many times."; - shared_data_->SetLastError(kViEAPIDoesNotExist); - return -1; - } - return ref_count; -} - -ViEExternalCodecImpl::ViEExternalCodecImpl(ViESharedData* shared_data) - : shared_data_(shared_data) { -} - -ViEExternalCodecImpl::~ViEExternalCodecImpl() { -} - -int ViEExternalCodecImpl::RegisterExternalSendCodec(const int video_channel, - const unsigned char pl_type, - VideoEncoder* encoder, - bool internal_source) { - assert(encoder != NULL); - LOG(LS_INFO) << "Register external encoder for channel " << video_channel - << ", pl_type " << static_cast(pl_type) - << ", internal_source " << internal_source; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidArgument); - return -1; - } - if (vie_encoder->RegisterExternalEncoder(encoder, pl_type, - internal_source) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViEExternalCodecImpl::DeRegisterExternalSendCodec( - const int video_channel, const unsigned char pl_type) { - LOG(LS_INFO) << "Deregister external encoder for channel " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViECodecInvalidArgument); - return -1; - } - - if (vie_encoder->DeRegisterExternalEncoder(pl_type) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViEExternalCodecImpl::RegisterExternalReceiveCodec( - const int video_channel, - const unsigned char pl_type, - VideoDecoder* decoder, - bool decoder_render, - int render_delay) { - LOG(LS_INFO) << "Register external decoder for channel " << video_channel - << ", pl_type " << static_cast(pl_type) - << ", decoder_render " << decoder_render - << ", render_delay " << render_delay; - assert(decoder != NULL); - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidArgument); - return -1; - } - - if (vie_channel->RegisterExternalDecoder(pl_type, decoder, decoder_render, - render_delay) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -int ViEExternalCodecImpl::DeRegisterExternalReceiveCodec( - const int video_channel, const unsigned char pl_type) { - LOG(LS_INFO) << "DeRegisterExternalReceiveCodec for channel " << video_channel - << ", pl_type " << static_cast(pl_type); - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViECodecInvalidArgument); - return -1; - } - if (vie_channel->DeRegisterExternalDecoder(pl_type) != 0) { - shared_data_->SetLastError(kViECodecUnknownError); - return -1; - } - return 0; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_external_codec_impl.h b/webrtc/video_engine/vie_external_codec_impl.h deleted file mode 100644 index da5a445ddf..0000000000 --- a/webrtc/video_engine/vie_external_codec_impl.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_EXTERNAL_CODEC_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_EXTERNAL_CODEC_IMPL_H_ - -#include "webrtc/video_engine/include/vie_external_codec.h" -#include "webrtc/video_engine/vie_ref_count.h" - -namespace webrtc { - -class ViESharedData; - -class ViEExternalCodecImpl - : public ViEExternalCodec, - public ViERefCount { - public: - // Implements ViEExternalCodec. - virtual int Release(); - virtual int RegisterExternalSendCodec(const int video_channel, - const unsigned char pl_type, - VideoEncoder* encoder, - bool internal_source = false); - virtual int DeRegisterExternalSendCodec(const int video_channel, - const unsigned char pl_type); - virtual int RegisterExternalReceiveCodec(const int video_channel, - const unsigned char pl_type, - VideoDecoder* decoder, - bool decoder_render = false, - int render_delay = 0); - virtual int DeRegisterExternalReceiveCodec(const int video_channel, - const unsigned char pl_type); - - protected: - explicit ViEExternalCodecImpl(ViESharedData* shared_data); - virtual ~ViEExternalCodecImpl(); - - private: - ViESharedData* shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_EXTERNAL_CODEC_IMPL_H_ diff --git a/webrtc/video_engine/vie_file_image.cc b/webrtc/video_engine/vie_file_image.cc deleted file mode 100644 index cb6e206190..0000000000 --- a/webrtc/video_engine/vie_file_image.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// Placed first to get WEBRTC_VIDEO_ENGINE_FILE_API. -#include "webrtc/engine_configurations.h" - -#ifdef WEBRTC_VIDEO_ENGINE_FILE_API - -#include "webrtc/video_engine/vie_file_image.h" - -#include // NOLINT - -#include "webrtc/common_video/interface/video_image.h" -#include "webrtc/common_video/jpeg/include/jpeg.h" -#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" - -namespace webrtc { - -int ViEFileImage::ConvertJPEGToVideoFrame(int engine_id, - const char* file_nameUTF8, - I420VideoFrame* video_frame) { - // Read jpeg file into temporary buffer. - EncodedImage image_buffer; - - FILE* image_file = fopen(file_nameUTF8, "rb"); - if (!image_file) { - return -1; - } - if (fseek(image_file, 0, SEEK_END) != 0) { - fclose(image_file); - return -1; - } - int buffer_size = ftell(image_file); - if (buffer_size == -1) { - fclose(image_file); - return -1; - } - image_buffer._size = buffer_size; - if (fseek(image_file, 0, SEEK_SET) != 0) { - fclose(image_file); - return -1; - } - image_buffer._buffer = new uint8_t[ image_buffer._size + 1]; - if (image_buffer._size != fread(image_buffer._buffer, sizeof(uint8_t), - image_buffer._size, image_file)) { - fclose(image_file); - delete [] image_buffer._buffer; - return -1; - } - fclose(image_file); - - int ret = ConvertJpegToI420(image_buffer, video_frame); - - delete [] image_buffer._buffer; - image_buffer._buffer = NULL; - - if (ret == -1) { - return -1; - } else if (ret == -3) { - } - return 0; -} - -int ViEFileImage::ConvertPictureToI420VideoFrame(int engine_id, - const ViEPicture& picture, - I420VideoFrame* video_frame) { - int half_width = (picture.width + 1) / 2; - video_frame->CreateEmptyFrame(picture.width, picture.height, - picture.width, half_width, half_width); - return ConvertToI420(kI420, picture.data, 0, 0, picture.width, picture.height, - 0, kVideoRotation_0, video_frame); -} - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_FILE_API diff --git a/webrtc/video_engine/vie_file_image.h b/webrtc/video_engine/vie_file_image.h deleted file mode 100644 index f5c8b8762d..0000000000 --- a/webrtc/video_engine/vie_file_image.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_FILE_IMAGE_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_FILE_IMAGE_H_ - -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_file.h" -#include "webrtc/video_frame.h" - -namespace webrtc { - -class ViEFileImage { - public: - static int ConvertJPEGToVideoFrame(int engine_id, - const char* file_nameUTF8, - I420VideoFrame* video_frame); - static int ConvertPictureToI420VideoFrame(int engine_id, - const ViEPicture& picture, - I420VideoFrame* video_frame); -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_FILE_IMAGE_H_ diff --git a/webrtc/video_engine/vie_image_process_impl.cc b/webrtc/video_engine/vie_image_process_impl.cc deleted file mode 100644 index f8c3877c0b..0000000000 --- a/webrtc/video_engine/vie_image_process_impl.cc +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_image_process_impl.h" - -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_capturer.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_input_manager.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -ViEImageProcess* ViEImageProcess::GetInterface(VideoEngine* video_engine) { -#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API - if (!video_engine) { - return NULL; - } - VideoEngineImpl* vie_impl = static_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 -} - -int ViEImageProcessImpl::Release() { - // Decrease ref count. - (*this)--; - - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_ERROR) << "ViEImageProcess release too many times"; - shared_data_->SetLastError(kViEAPIDoesNotExist); - return -1; - } - return ref_count; -} - -ViEImageProcessImpl::ViEImageProcessImpl(ViESharedData* shared_data) - : shared_data_(shared_data) {} - -ViEImageProcessImpl::~ViEImageProcessImpl() {} - -int ViEImageProcessImpl::RegisterCaptureEffectFilter( - const int capture_id, - ViEEffectFilter& capture_filter) { - LOG_F(LS_INFO) << "capture_id: " << capture_id; - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViEImageProcessInvalidCaptureId); - return -1; - } - if (vie_capture->RegisterEffectFilter(&capture_filter) != 0) { - shared_data_->SetLastError(kViEImageProcessFilterExists); - return -1; - } - return 0; -} - -int ViEImageProcessImpl::DeregisterCaptureEffectFilter(const int capture_id) { - LOG_F(LS_INFO) << "capture_id: " << capture_id; - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViEImageProcessInvalidCaptureId); - return -1; - } - if (vie_capture->RegisterEffectFilter(NULL) != 0) { - shared_data_->SetLastError(kViEImageProcessFilterDoesNotExist); - return -1; - } - return 0; -} - -int ViEImageProcessImpl::RegisterSendEffectFilter( - const int video_channel, - ViEEffectFilter& send_filter) { - LOG_F(LS_INFO) << "video_channel: " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (vie_encoder == NULL) { - shared_data_->SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - - if (vie_encoder->RegisterEffectFilter(&send_filter) != 0) { - shared_data_->SetLastError(kViEImageProcessFilterExists); - return -1; - } - return 0; -} - -int ViEImageProcessImpl::DeregisterSendEffectFilter(const int video_channel) { - LOG_F(LS_INFO) << "video_channel: " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (vie_encoder == NULL) { - shared_data_->SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - if (vie_encoder->RegisterEffectFilter(NULL) != 0) { - shared_data_->SetLastError(kViEImageProcessFilterDoesNotExist); - return -1; - } - return 0; -} - -int ViEImageProcessImpl::RegisterRenderEffectFilter( - const int video_channel, - ViEEffectFilter& render_filter) { - LOG_F(LS_INFO) << "video_channel: " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - if (vie_channel->RegisterEffectFilter(&render_filter) != 0) { - shared_data_->SetLastError(kViEImageProcessFilterExists); - return -1; - } - return 0; -} - -int ViEImageProcessImpl::DeregisterRenderEffectFilter(const int video_channel) { - LOG_F(LS_INFO) << "video_channel: " << video_channel; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - - if (vie_channel->RegisterEffectFilter(NULL) != 0) { - shared_data_->SetLastError(kViEImageProcessFilterDoesNotExist); - return -1; - } - return 0; -} - -int ViEImageProcessImpl::EnableDeflickering(const int capture_id, - const bool enable) { - LOG_F(LS_INFO) << "capture_id: " << capture_id - << " enable: " << (enable ? "on" : "off"); - - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViECapturer* vie_capture = is.Capture(capture_id); - if (!vie_capture) { - shared_data_->SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - - if (vie_capture->EnableDeflickering(enable) != 0) { - if (enable) { - shared_data_->SetLastError(kViEImageProcessAlreadyEnabled); - } else { - shared_data_->SetLastError(kViEImageProcessAlreadyDisabled); - } - return -1; - } - return 0; -} - -int ViEImageProcessImpl::EnableColorEnhancement(const int video_channel, - const bool enable) { - LOG_F(LS_INFO) << "video_channel: " << video_channel - << " enable: " << (enable ? "on" : "off"); - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViEImageProcessInvalidChannelId); - return -1; - } - if (vie_channel->EnableColorEnhancement(enable) != 0) { - if (enable) { - shared_data_->SetLastError(kViEImageProcessAlreadyEnabled); - } else { - shared_data_->SetLastError(kViEImageProcessAlreadyDisabled); - } - return -1; - } - return 0; -} -} // namespace webrtc diff --git a/webrtc/video_engine/vie_image_process_impl.h b/webrtc/video_engine/vie_image_process_impl.h deleted file mode 100644 index 4806d79aed..0000000000 --- a/webrtc/video_engine/vie_image_process_impl.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_IMAGE_PROCESS_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_IMAGE_PROCESS_IMPL_H_ - -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_image_process.h" -#include "webrtc/video_engine/vie_ref_count.h" - -namespace webrtc { - -class ViESharedData; - -class ViEImageProcessImpl - : 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 EnableColorEnhancement(const int video_channel, - const bool enable); - protected: - explicit ViEImageProcessImpl(ViESharedData* shared_data); - virtual ~ViEImageProcessImpl(); - - private: - ViESharedData* shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_IMAGE_PROCESS_IMPL_H_ diff --git a/webrtc/video_engine/vie_impl.cc b/webrtc/video_engine/vie_impl.cc deleted file mode 100644 index 79f033b4e1..0000000000 --- a/webrtc/video_engine/vie_impl.cc +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_impl.h" - -#include "webrtc/common.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/system_wrappers/interface/trace.h" - -namespace webrtc { - -enum { kModuleId = 0 }; - -VideoEngine* VideoEngine::Create() { - return new VideoEngineImpl(new Config(), true /* owns_config */); -} - -VideoEngine* VideoEngine::Create(const Config& config) { - return new VideoEngineImpl(&config, false /* owns_config */); -} - -bool VideoEngine::Delete(VideoEngine*& video_engine) { - if (!video_engine) - return false; - - LOG_F(LS_INFO); - VideoEngineImpl* vie_impl = static_cast(video_engine); - - // Check all reference counters. - ViEBaseImpl* vie_base = vie_impl; - if (vie_base->GetCount() > 0) { - LOG(LS_ERROR) << "ViEBase ref count > 0: " << vie_base->GetCount(); - return false; - } -#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API - ViECaptureImpl* vie_capture = vie_impl; - if (vie_capture->GetCount() > 0) { - LOG(LS_ERROR) << "ViECapture ref count > 0: " << vie_capture->GetCount(); - return false; - } -#endif -#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API - ViECodecImpl* vie_codec = vie_impl; - if (vie_codec->GetCount() > 0) { - LOG(LS_ERROR) << "ViECodec ref count > 0: " << vie_codec->GetCount(); - return false; - } -#endif -#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - ViEExternalCodecImpl* vie_external_codec = vie_impl; - if (vie_external_codec->GetCount() > 0) { - LOG(LS_ERROR) << "ViEExternalCodec ref count > 0: " - << vie_external_codec->GetCount(); - return false; - } -#endif -#ifdef WEBRTC_VIDEO_ENGINE_FILE_API - ViEFileImpl* vie_file = vie_impl; - if (vie_file->GetCount() > 0) { - LOG(LS_ERROR) << "ViEFile ref count > 0: " << vie_file->GetCount(); - return false; - } -#endif -#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API - ViEImageProcessImpl* vie_image_process = vie_impl; - if (vie_image_process->GetCount() > 0) { - LOG(LS_ERROR) << "ViEImageProcess ref count > 0: " - << vie_image_process->GetCount(); - return false; - } -#endif - ViENetworkImpl* vie_network = vie_impl; - if (vie_network->GetCount() > 0) { - LOG(LS_ERROR) << "ViENetwork ref count > 0: " << vie_network->GetCount(); - return false; - } -#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API - ViERenderImpl* vie_render = vie_impl; - if (vie_render->GetCount() > 0) { - LOG(LS_ERROR) << "ViERender ref count > 0: " << vie_render->GetCount(); - return false; - } -#endif -#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API - ViERTP_RTCPImpl* vie_rtp_rtcp = vie_impl; - if (vie_rtp_rtcp->GetCount() > 0) { - LOG(LS_ERROR) << "ViERTP_RTCP ref count > 0: " << vie_rtp_rtcp->GetCount(); - return false; - } -#endif - - delete vie_impl; - vie_impl = NULL; - video_engine = NULL; - - return true; -} - -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; - } - LOG_F(LS_INFO) << "filename: " << file_nameUTF8 - << " add_file_counter: " << (add_file_counter ? "yes" : "no"); - return 0; -} - -int VideoEngine::SetTraceFilter(const unsigned int filter) { - uint32_t old_filter = Trace::level_filter(); - - if (filter == kTraceNone && old_filter != kTraceNone) { - // Do the logging before turning it off. - LOG_F(LS_INFO) << "filter: " << filter; - } - - Trace::set_level_filter(filter); - LOG_F(LS_INFO) << "filter: " << filter; - return 0; -} - -int VideoEngine::SetTraceCallback(TraceCallback* callback) { - LOG_F(LS_INFO); - return Trace::SetTraceCallback(callback); -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_impl.h b/webrtc/video_engine/vie_impl.h deleted file mode 100644 index 34fd7f7f3b..0000000000 --- a/webrtc/video_engine/vie_impl.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_ - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/common.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/video_engine/vie_defines.h" - -#include "webrtc/video_engine/vie_base_impl.h" - -#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API -#include "webrtc/video_engine/vie_capture_impl.h" -#endif -#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API -#include "webrtc/video_engine/vie_codec_impl.h" -#endif -#ifdef WEBRTC_VIDEO_ENGINE_FILE_API -#include "webrtc/video_engine/vie_file_impl.h" -#endif -#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API -#include "webrtc/video_engine/vie_image_process_impl.h" -#endif -#include "webrtc/video_engine/vie_network_impl.h" -#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API -#include "webrtc/video_engine/vie_render_impl.h" -#endif -#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API -#include "webrtc/video_engine/vie_rtp_rtcp_impl.h" -#endif -#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API -#include "webrtc/video_engine/vie_external_codec_impl.h" -#endif - -namespace webrtc { - -class VideoEngineImpl - : public ViEBaseImpl, -#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API - public ViECodecImpl, -#endif -#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API - public ViECaptureImpl, -#endif -#ifdef WEBRTC_VIDEO_ENGINE_FILE_API - public ViEFileImpl, -#endif -#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API - public ViEImageProcessImpl, -#endif - public ViENetworkImpl, -#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API - public ViERenderImpl, -#endif -#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API - public ViERTP_RTCPImpl, -#endif -#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - public ViEExternalCodecImpl, -#endif - public VideoEngine -{ // NOLINT - public: - VideoEngineImpl(const Config* config, bool owns_config) - : ViEBaseImpl(*config), -#ifdef WEBRTC_VIDEO_ENGINE_CODEC_API - ViECodecImpl(ViEBaseImpl::shared_data()), -#endif -#ifdef WEBRTC_VIDEO_ENGINE_CAPTURE_API - ViECaptureImpl(ViEBaseImpl::shared_data()), -#endif -#ifdef WEBRTC_VIDEO_ENGINE_FILE_API - ViEFileImpl(ViEBaseImpl::shared_data()), -#endif -#ifdef WEBRTC_VIDEO_ENGINE_IMAGE_PROCESS_API - ViEImageProcessImpl(ViEBaseImpl::shared_data()), -#endif - ViENetworkImpl(ViEBaseImpl::shared_data()), -#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API - ViERenderImpl(ViEBaseImpl::shared_data()), -#endif -#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API - ViERTP_RTCPImpl(ViEBaseImpl::shared_data()), -#endif -#ifdef WEBRTC_VIDEO_ENGINE_EXTERNAL_CODEC_API - ViEExternalCodecImpl(ViEBaseImpl::shared_data()), -#endif - own_config_(owns_config ? config : NULL) - {} - virtual ~VideoEngineImpl() {} - - private: - // Placeholder for the case where this owns the config. - rtc::scoped_ptr own_config_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_IMPL_H_ diff --git a/webrtc/video_engine/vie_input_manager.cc b/webrtc/video_engine/vie_input_manager.cc deleted file mode 100644 index aa64f2362f..0000000000 --- a/webrtc/video_engine/vie_input_manager.cc +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_input_manager.h" - -#include - -#include "webrtc/common_types.h" -#include "webrtc/modules/video_capture/include/video_capture_factory.h" -#include "webrtc/modules/video_coding/main/interface/video_coding.h" -#include "webrtc/modules/video_coding/main/interface/video_coding_defines.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_capturer.h" -#include "webrtc/video_engine/vie_defines.h" - -namespace webrtc { - -ViEInputManager::ViEInputManager(const int engine_id, const Config& config) - : config_(config), - engine_id_(engine_id), - map_cs_(CriticalSectionWrapper::CreateCriticalSection()), - device_info_cs_(CriticalSectionWrapper::CreateCriticalSection()), - vie_frame_provider_map_(), - capture_device_info_(NULL), - module_process_thread_(NULL) { - for (int idx = 0; idx < kViEMaxCaptureDevices; idx++) { - free_capture_device_id_[idx] = true; - } -} - -ViEInputManager::~ViEInputManager() { - for (FrameProviderMap::iterator it = vie_frame_provider_map_.begin(); - it != vie_frame_provider_map_.end(); - ++it) { - delete it->second; - } - - delete capture_device_info_; -} -void ViEInputManager::SetModuleProcessThread( - ProcessThread* module_process_thread) { - assert(!module_process_thread_); - module_process_thread_ = module_process_thread; -} - -int ViEInputManager::NumberOfCaptureDevices() { - CriticalSectionScoped cs(device_info_cs_.get()); - if (capture_device_info_ == NULL) - capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( - ViEModuleId(engine_id_)); - assert(capture_device_info_); - return capture_device_info_->NumberOfDevices(); -} - -int ViEInputManager::GetDeviceName(uint32_t device_number, - char* device_nameUTF8, - uint32_t device_name_length, - char* device_unique_idUTF8, - uint32_t device_unique_idUTF8Length) { - CriticalSectionScoped cs(device_info_cs_.get()); - if (capture_device_info_ == NULL) - capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( - ViEModuleId(engine_id_)); - assert(capture_device_info_); - return capture_device_info_->GetDeviceName(device_number, device_nameUTF8, - device_name_length, - device_unique_idUTF8, - device_unique_idUTF8Length); -} - -int ViEInputManager::NumberOfCaptureCapabilities( - const char* device_unique_idUTF8) { - CriticalSectionScoped cs(device_info_cs_.get()); - if (capture_device_info_ == NULL) - capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( - ViEModuleId(engine_id_)); - assert(capture_device_info_); - return capture_device_info_->NumberOfCapabilities(device_unique_idUTF8); -} - -int ViEInputManager::GetCaptureCapability( - const char* device_unique_idUTF8, - const uint32_t device_capability_number, - CaptureCapability& capability) { - CriticalSectionScoped cs(device_info_cs_.get()); - if (capture_device_info_ == NULL) - capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( - ViEModuleId(engine_id_)); - assert(capture_device_info_); - VideoCaptureCapability module_capability; - int result = capture_device_info_->GetCapability(device_unique_idUTF8, - device_capability_number, - module_capability); - if (result != 0) - return result; - - // Copy from module type to public type. - capability.expectedCaptureDelay = module_capability.expectedCaptureDelay; - capability.height = module_capability.height; - capability.width = module_capability.width; - capability.interlaced = module_capability.interlaced; - capability.rawType = module_capability.rawType; - capability.codecType = module_capability.codecType; - capability.maxFPS = module_capability.maxFPS; - return result; -} - -int ViEInputManager::GetOrientation(const char* device_unique_idUTF8, - VideoRotation& orientation) { - CriticalSectionScoped cs(device_info_cs_.get()); - if (capture_device_info_ == NULL) - capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( - ViEModuleId(engine_id_)); - assert(capture_device_info_); - return capture_device_info_->GetOrientation(device_unique_idUTF8, - orientation); -} - -int ViEInputManager::DisplayCaptureSettingsDialogBox( - const char* device_unique_idUTF8, - const char* dialog_titleUTF8, - void* parent_window, - uint32_t positionX, - uint32_t positionY) { - CriticalSectionScoped cs(device_info_cs_.get()); - if (capture_device_info_ == NULL) - capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( - ViEModuleId(engine_id_)); - assert(capture_device_info_); - return capture_device_info_->DisplayCaptureSettingsDialogBox( - device_unique_idUTF8, dialog_titleUTF8, parent_window, positionX, - positionY); -} - -int ViEInputManager::CreateCaptureDevice( - const char* device_unique_idUTF8, - const uint32_t device_unique_idUTF8Length, - int& capture_id) { - CriticalSectionScoped cs(map_cs_.get()); - - // Make sure the device is not already allocated. - for (FrameProviderMap::iterator it = vie_frame_provider_map_.begin(); - it != vie_frame_provider_map_.end(); - ++it) { - // Make sure this is a capture device. - if (it->first >= kViECaptureIdBase && it->first <= kViECaptureIdMax) { - ViECapturer* vie_capture = static_cast(it->second); - assert(vie_capture); - // TODO(mflodman) Can we change input to avoid this cast? - const char* device_name = - reinterpret_cast(vie_capture->CurrentDeviceName()); - if (strncmp(device_name, device_unique_idUTF8, - strlen(device_name)) == 0) { - return kViECaptureDeviceAlreadyAllocated; - } - } - } - - // Make sure the device name is valid. - bool found_device = false; - CriticalSectionScoped cs_devinfo(device_info_cs_.get()); - if (capture_device_info_ == NULL) - capture_device_info_ = VideoCaptureFactory::CreateDeviceInfo( - ViEModuleId(engine_id_)); - assert(capture_device_info_); - for (uint32_t device_index = 0; - device_index < capture_device_info_->NumberOfDevices(); ++device_index) { - if (device_unique_idUTF8Length > kVideoCaptureUniqueNameLength) { - // User's string length is longer than the max. - return -1; - } - - char found_name[kVideoCaptureDeviceNameLength] = ""; - char found_unique_name[kVideoCaptureUniqueNameLength] = ""; - capture_device_info_->GetDeviceName(device_index, found_name, - kVideoCaptureDeviceNameLength, - found_unique_name, - kVideoCaptureUniqueNameLength); - - // TODO(mflodman) Can we change input to avoid this cast? - const char* cast_id = reinterpret_cast(device_unique_idUTF8); - if (strncmp(cast_id, reinterpret_cast(found_unique_name), - strlen(cast_id)) == 0) { - found_device = true; - break; - } - } - if (!found_device) { - LOG(LS_ERROR) << "Capture device not found: " << device_unique_idUTF8; - return kViECaptureDeviceDoesNotExist; - } - - int newcapture_id = 0; - if (!GetFreeCaptureId(&newcapture_id)) { - LOG(LS_ERROR) << "All capture devices already allocated."; - return kViECaptureDeviceMaxNoDevicesAllocated; - } - ViECapturer* vie_capture = ViECapturer::CreateViECapture( - newcapture_id, engine_id_, config_, device_unique_idUTF8, - device_unique_idUTF8Length, *module_process_thread_); - if (!vie_capture) { - ReturnCaptureId(newcapture_id); - return kViECaptureDeviceUnknownError; - } - - vie_frame_provider_map_[newcapture_id] = vie_capture; - capture_id = newcapture_id; - return 0; -} - -int ViEInputManager::CreateCaptureDevice(VideoCaptureModule* capture_module, - int& capture_id) { - CriticalSectionScoped cs(map_cs_.get()); - int newcapture_id = 0; - if (!GetFreeCaptureId(&newcapture_id)) { - LOG(LS_ERROR) << "All capture devices already allocated."; - return kViECaptureDeviceMaxNoDevicesAllocated; - } - - ViECapturer* vie_capture = ViECapturer::CreateViECapture( - newcapture_id, engine_id_, config_, - capture_module, *module_process_thread_); - if (!vie_capture) { - ReturnCaptureId(newcapture_id); - return kViECaptureDeviceUnknownError; - } - vie_frame_provider_map_[newcapture_id] = vie_capture; - capture_id = newcapture_id; - return 0; -} - -int ViEInputManager::DestroyCaptureDevice(const int capture_id) { - ViECapturer* vie_capture = NULL; - { - // We need exclusive access to the object to delete it. - // Take this write lock first since the read lock is taken before map_cs_. - ViEManagerWriteScoped wl(this); - CriticalSectionScoped cs(map_cs_.get()); - - vie_capture = ViECapturePtr(capture_id); - if (!vie_capture) { - LOG(LS_ERROR) << "No such capture device id: " << capture_id; - return -1; - } - vie_frame_provider_map_.erase(capture_id); - ReturnCaptureId(capture_id); - // Leave cs before deleting the capture object. This is because deleting the - // object might cause deletions of renderers so we prefer to not have a lock - // at that time. - } - delete vie_capture; - return 0; -} - -int ViEInputManager::CreateExternalCaptureDevice( - ViEExternalCapture*& external_capture, - int& capture_id) { - CriticalSectionScoped cs(map_cs_.get()); - - int newcapture_id = 0; - if (GetFreeCaptureId(&newcapture_id) == false) { - LOG(LS_ERROR) << "All capture devices already allocated."; - return kViECaptureDeviceMaxNoDevicesAllocated; - } - - ViECapturer* vie_capture = ViECapturer::CreateViECapture( - newcapture_id, engine_id_, config_, NULL, 0, *module_process_thread_); - if (!vie_capture) { - ReturnCaptureId(newcapture_id); - return kViECaptureDeviceUnknownError; - } - - vie_frame_provider_map_[newcapture_id] = vie_capture; - capture_id = newcapture_id; - external_capture = vie_capture; - return 0; -} - -bool ViEInputManager::GetFreeCaptureId(int* freecapture_id) { - for (int id = 0; id < kViEMaxCaptureDevices; id++) { - if (free_capture_device_id_[id]) { - // We found a free capture device id. - free_capture_device_id_[id] = false; - *freecapture_id = id + kViECaptureIdBase; - return true; - } - } - return false; -} - -void ViEInputManager::ReturnCaptureId(int capture_id) { - CriticalSectionScoped cs(map_cs_.get()); - if (capture_id >= kViECaptureIdBase && - capture_id < kViEMaxCaptureDevices + kViECaptureIdBase) { - free_capture_device_id_[capture_id - kViECaptureIdBase] = true; - } - return; -} - -ViEFrameProviderBase* ViEInputManager::ViEFrameProvider( - const ViEFrameCallback* capture_observer) const { - assert(capture_observer); - CriticalSectionScoped cs(map_cs_.get()); - - for (FrameProviderMap::const_iterator it = vie_frame_provider_map_.begin(); - it != vie_frame_provider_map_.end(); - ++it) { - if (it->second->IsFrameCallbackRegistered(capture_observer)) - return it->second; - } - - // No capture device set for this channel. - return NULL; -} - -ViEFrameProviderBase* ViEInputManager::ViEFrameProvider(int provider_id) const { - CriticalSectionScoped cs(map_cs_.get()); - - FrameProviderMap::const_iterator it = - vie_frame_provider_map_.find(provider_id); - if (it == vie_frame_provider_map_.end()) - return NULL; - return it->second; -} - -ViECapturer* ViEInputManager::ViECapturePtr(int capture_id) const { - if (!(capture_id >= kViECaptureIdBase && - capture_id <= kViECaptureIdBase + kViEMaxCaptureDevices)) { - LOG(LS_ERROR) << "Capture device doesn't exist " << capture_id << "."; - return NULL; - } - - return static_cast(ViEFrameProvider(capture_id)); -} - -ViEInputManagerScoped::ViEInputManagerScoped( - const ViEInputManager& vie_input_manager) - : ViEManagerScopedBase(vie_input_manager) { -} - -ViECapturer* ViEInputManagerScoped::Capture(int capture_id) const { - return static_cast(vie_manager_)->ViECapturePtr( - capture_id); -} - -ViEFrameProviderBase* ViEInputManagerScoped::FrameProvider( - const ViEFrameCallback* capture_observer) const { - return static_cast(vie_manager_)->ViEFrameProvider( - capture_observer); -} - -ViEFrameProviderBase* ViEInputManagerScoped::FrameProvider( - int provider_id) const { - return static_cast(vie_manager_)->ViEFrameProvider( - provider_id); -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_input_manager.h b/webrtc/video_engine/vie_input_manager.h deleted file mode 100644 index fc5221bea2..0000000000 --- a/webrtc/video_engine/vie_input_manager.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ - -#include - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/modules/video_capture/include/video_capture.h" -#include "webrtc/typedefs.h" -#include "webrtc/common_video/rotation.h" -#include "webrtc/video_engine/include/vie_capture.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_frame_provider_base.h" -#include "webrtc/video_engine/vie_manager_base.h" - -namespace webrtc { - -class Config; -class CriticalSectionWrapper; -class ProcessThread; -class RWLockWrapper; -class ViECapturer; -class ViEExternalCapture; -class VoiceEngine; - -class ViEInputManager : private ViEManagerBase { - friend class ViEInputManagerScoped; - public: - ViEInputManager(int engine_id, const Config& config); - ~ViEInputManager(); - - void SetModuleProcessThread(ProcessThread* module_process_thread); - - // Returns number of capture devices. - int NumberOfCaptureDevices(); - - // Gets name and id for a capture device. - int GetDeviceName(uint32_t device_number, - char* device_nameUTF8, - uint32_t device_name_length, - char* device_unique_idUTF8, - uint32_t device_unique_idUTF8Length); - - // Returns the number of capture capabilities for a specified device. - int NumberOfCaptureCapabilities(const char* device_unique_idUTF8); - - // Gets a specific capability for a capture device. - int GetCaptureCapability(const char* device_unique_idUTF8, - const uint32_t device_capability_number, - CaptureCapability& capability); - - // Show OS specific Capture settings. - int DisplayCaptureSettingsDialogBox(const char* device_unique_idUTF8, - const char* dialog_titleUTF8, - void* parent_window, - uint32_t positionX, - uint32_t positionY); - int GetOrientation(const char* device_unique_idUTF8, - VideoRotation& orientation); - - // Creates a capture module for the specified capture device and assigns - // a capture device id for the device. - // Return zero on success, ViEError on failure. - int CreateCaptureDevice(const char* device_unique_idUTF8, - const uint32_t device_unique_idUTF8Length, - int& capture_id); - int CreateCaptureDevice(VideoCaptureModule* capture_module, - int& capture_id); - int CreateExternalCaptureDevice(ViEExternalCapture*& external_capture, - int& capture_id); - int DestroyCaptureDevice(int capture_id); - - private: - // Gets and allocates a free capture device id. Assumed protected by caller. - bool GetFreeCaptureId(int* freecapture_id); - - // Frees a capture id assigned in GetFreeCaptureId. - void ReturnCaptureId(int capture_id); - - // Gets the ViEFrameProvider for this capture observer. - ViEFrameProviderBase* ViEFrameProvider( - const ViEFrameCallback* capture_observer) const; - - // Gets the ViEFrameProvider for this capture observer. - ViEFrameProviderBase* ViEFrameProvider(int provider_id) const; - - // Gets the ViECapturer for the capture device id. - ViECapturer* ViECapturePtr(int capture_id) const; - - const Config& config_; - int engine_id_; - rtc::scoped_ptr map_cs_; - rtc::scoped_ptr device_info_cs_; - - typedef std::map FrameProviderMap; - FrameProviderMap vie_frame_provider_map_; - - // Capture devices. - VideoCaptureModule::DeviceInfo* capture_device_info_; - int free_capture_device_id_[kViEMaxCaptureDevices]; - - ProcessThread* module_process_thread_; // Weak. -}; - -// Provides protected access to ViEInputManater. -class ViEInputManagerScoped: private ViEManagerScopedBase { - public: - explicit ViEInputManagerScoped(const ViEInputManager& vie_input_manager); - - ViECapturer* Capture(int capture_id) const; - ViEFrameProviderBase* FrameProvider(int provider_id) const; - ViEFrameProviderBase* FrameProvider(const ViEFrameCallback* - capture_observer) const; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ diff --git a/webrtc/video_engine/vie_manager_base.cc b/webrtc/video_engine/vie_manager_base.cc deleted file mode 100644 index b9b5d1a79f..0000000000 --- a/webrtc/video_engine/vie_manager_base.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include - -#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" -#include "webrtc/video_engine/vie_manager_base.h" - -namespace webrtc { - -ViEManagerBase::ViEManagerBase() - : instance_rwlock_(*RWLockWrapper::CreateRWLock()) { -} - -ViEManagerBase::~ViEManagerBase() { - delete &instance_rwlock_; -} - -void ViEManagerBase::ReadLockManager() const { - instance_rwlock_.AcquireLockShared(); -} - -void ViEManagerBase::ReleaseLockManager() const { - instance_rwlock_.ReleaseLockShared(); -} - -void ViEManagerBase::WriteLockManager() { - instance_rwlock_.AcquireLockExclusive(); -} - -void ViEManagerBase::ReleaseWriteLockManager() { - instance_rwlock_.ReleaseLockExclusive(); -} - -ViEManagerScopedBase::ViEManagerScopedBase(const ViEManagerBase& ViEManagerBase) - : vie_manager_(&ViEManagerBase), - ref_count_(0) { - vie_manager_->ReadLockManager(); -} - -ViEManagerScopedBase::~ViEManagerScopedBase() { - assert(ref_count_ == 0); - vie_manager_->ReleaseLockManager(); -} - -ViEManagerWriteScoped::ViEManagerWriteScoped(ViEManagerBase* vie_manager) - : vie_manager_(vie_manager) { - vie_manager_->WriteLockManager(); -} - -ViEManagerWriteScoped::~ViEManagerWriteScoped() { - vie_manager_->ReleaseWriteLockManager(); -} - -ViEManagedItemScopedBase::ViEManagedItemScopedBase( - ViEManagerScopedBase* vie_scoped_manager) - : vie_scoped_manager_(vie_scoped_manager) { - vie_scoped_manager_->ref_count_++; -} - -ViEManagedItemScopedBase::~ViEManagedItemScopedBase() { - vie_scoped_manager_->ref_count_--; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_manager_base.h b/webrtc/video_engine/vie_manager_base.h deleted file mode 100644 index c5e92106ab..0000000000 --- a/webrtc/video_engine/vie_manager_base.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_MANAGER_BASE_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_MANAGER_BASE_H_ - -#include "webrtc/base/thread_annotations.h" - -namespace webrtc { - -class RWLockWrapper; - -class LOCKABLE ViEManagerBase { - friend class ViEManagedItemScopedBase; - friend class ViEManagerScopedBase; - friend class ViEManagerWriteScoped; - public: - ViEManagerBase(); - ~ViEManagerBase(); - - private: - // Exclusive lock, used by ViEManagerWriteScoped. - void WriteLockManager() EXCLUSIVE_LOCK_FUNCTION(); - - // Releases exclusive lock, used by ViEManagerWriteScoped. - void ReleaseWriteLockManager() UNLOCK_FUNCTION(); - - // Increases lock count, used by ViEManagerScopedBase. - void ReadLockManager() const SHARED_LOCK_FUNCTION(); - - // Releases the lock count, used by ViEManagerScopedBase. - void ReleaseLockManager() const UNLOCK_FUNCTION(); - - RWLockWrapper& instance_rwlock_; -}; - -class SCOPED_LOCKABLE ViEManagerWriteScoped { - public: - explicit ViEManagerWriteScoped(ViEManagerBase* vie_manager) - EXCLUSIVE_LOCK_FUNCTION(vie_manager); - ~ViEManagerWriteScoped() UNLOCK_FUNCTION(); - - private: - ViEManagerBase* vie_manager_; -}; - -class ViEManagerScopedBase { - friend class ViEManagedItemScopedBase; - public: - explicit ViEManagerScopedBase(const ViEManagerBase& vie_manager); - ~ViEManagerScopedBase(); - - protected: - const ViEManagerBase* vie_manager_; - - private: - int ref_count_; -}; - -class ViEManagedItemScopedBase { - public: - explicit ViEManagedItemScopedBase(ViEManagerScopedBase* vie_scoped_manager); - ~ViEManagedItemScopedBase(); - - protected: - ViEManagerScopedBase* vie_scoped_manager_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_MANAGER_BASE_H_ diff --git a/webrtc/video_engine/vie_network_impl.cc b/webrtc/video_engine/vie_network_impl.cc deleted file mode 100644 index 5d45187a61..0000000000 --- a/webrtc/video_engine/vie_network_impl.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_network_impl.h" - -#include -#if (defined(WIN32_) || defined(WIN64_)) -#include -#endif - -#include "webrtc/base/checks.h" -#include "webrtc/engine_configurations.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -ViENetwork* ViENetwork::GetInterface(VideoEngine* video_engine) { - if (!video_engine) { - return NULL; - } - VideoEngineImpl* vie_impl = static_cast(video_engine); - ViENetworkImpl* vie_networkImpl = vie_impl; - // Increase ref count. - (*vie_networkImpl)++; - return vie_networkImpl; -} - -int ViENetworkImpl::Release() { - // Decrease ref count. - (*this)--; - - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_ERROR) << "ViENetwork release too many times"; - shared_data_->SetLastError(kViEAPIDoesNotExist); - return -1; - } - return ref_count; -} - -ViENetworkImpl::ViENetworkImpl(ViESharedData* shared_data) - : shared_data_(shared_data) { -} - -ViENetworkImpl::~ViENetworkImpl() { -} - -void ViENetworkImpl::SetBitrateConfig(int video_channel, - int min_bitrate_bps, - int start_bitrate_bps, - int max_bitrate_bps) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " new bitrate config: min=" << min_bitrate_bps - << ", start=" << start_bitrate_bps - << ", max=" << max_bitrate_bps; - bool success = shared_data_->channel_manager()->SetBitrateConfig( - video_channel, min_bitrate_bps, start_bitrate_bps, max_bitrate_bps); - DCHECK(success); -} - -void ViENetworkImpl::SetNetworkTransmissionState(const int video_channel, - const bool is_transmitting) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " transmitting: " << (is_transmitting ? "yes" : "no"); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViENetworkInvalidChannelId); - return; - } - vie_encoder->SetNetworkTransmissionState(is_transmitting); -} - -int ViENetworkImpl::RegisterSendTransport(const int video_channel, - Transport& transport) { - LOG_F(LS_INFO) << "channel: " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (vie_channel->Sending()) { - LOG_F(LS_ERROR) << "Already sending on channel: " << video_channel; - shared_data_->SetLastError(kViENetworkAlreadySending); - return -1; - } - if (vie_channel->RegisterSendTransport(&transport) != 0) { - shared_data_->SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; -} - -int ViENetworkImpl::DeregisterSendTransport(const int video_channel) { - LOG_F(LS_INFO) << "channel: " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (vie_channel->Sending()) { - LOG_F(LS_ERROR) << "Actively sending on channel: " << video_channel; - shared_data_->SetLastError(kViENetworkAlreadySending); - return -1; - } - if (vie_channel->DeregisterSendTransport() != 0) { - shared_data_->SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; -} - -int ViENetworkImpl::ReceivedRTPPacket(const int video_channel, const void* data, - const size_t length, - const PacketTime& packet_time) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViENetworkInvalidChannelId); - return -1; - } - return vie_channel->ReceivedRTPPacket(data, length, packet_time); -} - -int ViENetworkImpl::ReceivedRTCPPacket(const int video_channel, - const void* data, const size_t length) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViENetworkInvalidChannelId); - return -1; - } - return vie_channel->ReceivedRTCPPacket(data, length); -} - -int ViENetworkImpl::SetMTU(int video_channel, unsigned int mtu) { - LOG_F(LS_INFO) << "channel: " << video_channel << " mtu: " << mtu; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViENetworkInvalidChannelId); - return -1; - } - if (vie_channel->SetMTU(mtu) != 0) { - shared_data_->SetLastError(kViENetworkUnknownError); - return -1; - } - return 0; -} - -int ViENetworkImpl::ReceivedBWEPacket(const int video_channel, - int64_t arrival_time_ms, - size_t payload_size, - const RTPHeader& header) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViENetworkInvalidChannelId); - return -1; - } - - vie_channel->ReceivedBWEPacket(arrival_time_ms, payload_size, header); - return 0; -} -} // namespace webrtc diff --git a/webrtc/video_engine/vie_network_impl.h b/webrtc/video_engine/vie_network_impl.h deleted file mode 100644 index 1354f8cf4a..0000000000 --- a/webrtc/video_engine/vie_network_impl.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_NETWORK_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_NETWORK_IMPL_H_ - -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_network.h" -#include "webrtc/video_engine/vie_ref_count.h" - -namespace webrtc { - -class ViESharedData; - -class ViENetworkImpl - : public ViENetwork, - public ViERefCount { - public: - // Implements ViENetwork. - int Release() override; - void SetBitrateConfig(int video_channel, - int min_bitrate_bps, - int start_bitrate_bps, - int max_bitrate_bps) override; - void SetNetworkTransmissionState(const int video_channel, - const bool is_transmitting) override; - int RegisterSendTransport(const int video_channel, - Transport& transport) override; - int DeregisterSendTransport(const int video_channel) override; - int ReceivedRTPPacket(const int video_channel, - const void* data, - const size_t length, - const PacketTime& packet_time) override; - int ReceivedRTCPPacket(const int video_channel, - const void* data, - const size_t length) override; - int SetMTU(int video_channel, unsigned int mtu) override; - - int ReceivedBWEPacket(const int video_channel, - int64_t arrival_time_ms, - size_t payload_size, - const RTPHeader& header) override; - - protected: - explicit ViENetworkImpl(ViESharedData* shared_data); - virtual ~ViENetworkImpl(); - - private: - ViESharedData* shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_NETWORK_IMPL_H_ diff --git a/webrtc/video_engine/vie_receiver.cc b/webrtc/video_engine/vie_receiver.cc index 0fe12b4770..2cf5678032 100644 --- a/webrtc/video_engine/vie_receiver.cc +++ b/webrtc/video_engine/vie_receiver.cc @@ -246,17 +246,6 @@ bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); } -void ViEReceiver::ReceivedBWEPacket( - int64_t arrival_time_ms, size_t payload_size, const RTPHeader& header) { - // Only forward if the incoming packet *and* the channel are both configured - // to receive absolute sender time. RTP time stamps may have different rates - // for audio and video and shouldn't be mixed. - if (header.extension.hasAbsoluteSendTime && receiving_ast_enabled_) { - remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, - header); - } -} - int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet, size_t rtp_packet_length, const PacketTime& packet_time) { diff --git a/webrtc/video_engine/vie_receiver.h b/webrtc/video_engine/vie_receiver.h index 0a5229321f..a1f82dfa17 100644 --- a/webrtc/video_engine/vie_receiver.h +++ b/webrtc/video_engine/vie_receiver.h @@ -18,7 +18,6 @@ #include "webrtc/modules/rtp_rtcp/interface/receive_statistics.h" #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" #include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_network.h" #include "webrtc/video_engine/vie_defines.h" namespace webrtc { @@ -84,9 +83,6 @@ class ViEReceiver : public RtpData { bool OnRecoveredPacket(const uint8_t* packet, size_t packet_length) override; ReceiveStatistics* GetReceiveStatistics() const; - - void ReceivedBWEPacket(int64_t arrival_time_ms, size_t payload_size, - const RTPHeader& header); private: int InsertRTPPacket(const uint8_t* rtp_packet, size_t rtp_packet_length, const PacketTime& packet_time); diff --git a/webrtc/video_engine/vie_ref_count.cc b/webrtc/video_engine/vie_ref_count.cc deleted file mode 100644 index b2fe7acfc4..0000000000 --- a/webrtc/video_engine/vie_ref_count.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_ref_count.h" - -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" - -namespace webrtc { - -ViERefCount::ViERefCount() - : count_(0), - crit_(CriticalSectionWrapper::CreateCriticalSection()) { -} - -ViERefCount::~ViERefCount() { -} - -ViERefCount& ViERefCount::operator++(int) { // NOLINT - CriticalSectionScoped lock(crit_.get()); - count_++; - return *this; -} - -ViERefCount& ViERefCount::operator--(int) { // NOLINT - CriticalSectionScoped lock(crit_.get()); - count_--; - return *this; -} - -void ViERefCount::Reset() { - CriticalSectionScoped lock(crit_.get()); - count_ = 0; -} - -int ViERefCount::GetCount() const { - return count_; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_ref_count.h b/webrtc/video_engine/vie_ref_count.h deleted file mode 100644 index 61533e10e2..0000000000 --- a/webrtc/video_engine/vie_ref_count.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// TODO(mflodman) Remove this class and use ref count class in system_wrappers. - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_REF_COUNT_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_REF_COUNT_H_ - -#include "webrtc/base/scoped_ptr.h" - -namespace webrtc { - -class CriticalSectionWrapper; - -class ViERefCount { - public: - ViERefCount(); - ~ViERefCount(); - - ViERefCount& operator++(int); // NOLINT - ViERefCount& operator--(int); // NOLINT - - void Reset(); - int GetCount() const; - - private: - volatile int count_; - rtc::scoped_ptr crit_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_REF_COUNT_H_ diff --git a/webrtc/video_engine/vie_render_impl.cc b/webrtc/video_engine/vie_render_impl.cc deleted file mode 100644 index 27920602b6..0000000000 --- a/webrtc/video_engine/vie_render_impl.cc +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_render_impl.h" - -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/video_render/include/video_render.h" -#include "webrtc/modules/video_render/include/video_render_defines.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_capturer.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_frame_provider_base.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_input_manager.h" -#include "webrtc/video_engine/vie_render_manager.h" -#include "webrtc/video_engine/vie_renderer.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -ViERender* ViERender::GetInterface(VideoEngine* video_engine) { -#ifdef WEBRTC_VIDEO_ENGINE_RENDER_API - if (!video_engine) { - return NULL; - } - VideoEngineImpl* vie_impl = static_cast(video_engine); - ViERenderImpl* vie_render_impl = vie_impl; - // Increase ref count. - (*vie_render_impl)++; - return vie_render_impl; -#else - return NULL; -#endif -} - -int ViERenderImpl::Release() { - // Decrease ref count - (*this)--; - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_ERROR) << "ViERender release too many times"; - return -1; - } - return ref_count; -} - -ViERenderImpl::ViERenderImpl(ViESharedData* shared_data) - : shared_data_(shared_data) {} - -ViERenderImpl::~ViERenderImpl() {} - -int ViERenderImpl::RegisterVideoRenderModule( - VideoRender& render_module) { - LOG_F(LS_INFO); - if (shared_data_->render_manager()->RegisterVideoRenderModule( - &render_module) != 0) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return 0; -} - -int ViERenderImpl::DeRegisterVideoRenderModule( - VideoRender& render_module) { - LOG_F(LS_INFO); - if (shared_data_->render_manager()->DeRegisterVideoRenderModule( - &render_module) != 0) { - // Error logging is done in ViERenderManager::DeRegisterVideoRenderModule. - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return 0; -} - -int ViERenderImpl::AddRenderer(const int render_id, void* window, - const unsigned int z_order, const float left, - const float top, const float right, - const float bottom) { - LOG_F(LS_INFO) << "render_id: " << render_id << " z_order: " << z_order - << " left: " << left << " top: " << top << " right: " << right - << " bottom: " << bottom; - { - ViERenderManagerScoped rs(*(shared_data_->render_manager())); - if (rs.Renderer(render_id)) { - LOG(LS_ERROR) << "Renderer for render_id: " << render_id - << " already exists."; - shared_data_->SetLastError(kViERenderAlreadyExists); - return -1; - } - } - if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) { - // This is a channel. - ViEChannelManagerScoped cm(*(shared_data_->channel_manager())); - ViEFrameProviderBase* frame_provider = cm.Channel(render_id); - if (!frame_provider) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream( - render_id, window, z_order, left, top, right, bottom); - if (!renderer) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return frame_provider->RegisterFrameCallback(render_id, renderer); - } else { - // Camera or file. - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViEFrameProviderBase* frame_provider = is.FrameProvider(render_id); - if (!frame_provider) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream( - render_id, window, z_order, left, top, right, bottom); - if (!renderer) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return frame_provider->RegisterFrameCallback(render_id, renderer); - } -} - -int ViERenderImpl::RemoveRenderer(const int render_id) { - LOG_F(LS_INFO) << "render_id: " << render_id; - ViERenderer* renderer = NULL; - { - ViERenderManagerScoped rs(*(shared_data_->render_manager())); - renderer = rs.Renderer(render_id); - if (!renderer) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - // Leave the scope lock since we don't want to lock two managers - // simultanousely. - } - if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) { - // This is a channel. - ViEChannelManagerScoped cm(*(shared_data_->channel_manager())); - ViEChannel* channel = cm.Channel(render_id); - if (!channel) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - channel->DeregisterFrameCallback(renderer); - } else { - // Provider owned by inputmanager, i.e. file or capture device. - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViEFrameProviderBase* provider = is.FrameProvider(render_id); - if (!provider) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - provider->DeregisterFrameCallback(renderer); - } - if (shared_data_->render_manager()->RemoveRenderStream(render_id) != 0) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return 0; -} - -int ViERenderImpl::StartRender(const int render_id) { - LOG_F(LS_INFO) << "render_id: " << render_id; - ViERenderManagerScoped rs(*(shared_data_->render_manager())); - ViERenderer* renderer = rs.Renderer(render_id); - if (!renderer) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - if (renderer->StartRender() != 0) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return 0; -} - -int ViERenderImpl::StopRender(const int render_id) { - LOG_F(LS_INFO) << "render_id: " << render_id; - ViERenderManagerScoped rs(*(shared_data_->render_manager())); - ViERenderer* renderer = rs.Renderer(render_id); - if (!renderer) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - if (renderer->StopRender() != 0) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return 0; -} - -int ViERenderImpl::SetExpectedRenderDelay(int render_id, int render_delay) { - LOG_F(LS_INFO) << "render_id: " << render_id - << " render_delay: " << render_delay; - ViERenderManagerScoped rs(*(shared_data_->render_manager())); - ViERenderer* renderer = rs.Renderer(render_id); - if (!renderer) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - if (renderer->SetExpectedRenderDelay(render_delay) != 0) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return 0; -} - -int ViERenderImpl::ConfigureRender(int render_id, const unsigned int z_order, - const float left, const float top, - const float right, const float bottom) { - LOG_F(LS_INFO) << "render_id: " << render_id << " z_order: " << z_order - << " left: " << left << " top: " << top << " right: " << right - << " bottom: " << bottom; - ViERenderManagerScoped rs(*(shared_data_->render_manager())); - ViERenderer* renderer = rs.Renderer(render_id); - if (!renderer) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - - if (renderer->ConfigureRenderer(z_order, left, top, right, bottom) != 0) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return 0; -} - -int ViERenderImpl::AddRenderer(const int render_id, - RawVideoType video_input_format, - ExternalRenderer* external_renderer) { - // Check if the client requested a format that we can convert the frames to. - if (video_input_format != kVideoI420 && - video_input_format != kVideoYV12 && - video_input_format != kVideoYUY2 && - video_input_format != kVideoUYVY && - video_input_format != kVideoARGB && - video_input_format != kVideoRGB24 && - video_input_format != kVideoRGB565 && - video_input_format != kVideoARGB4444 && - video_input_format != kVideoARGB1555) { - LOG(LS_ERROR) << "Unsupported video frame format requested."; - shared_data_->SetLastError(kViERenderInvalidFrameFormat); - return -1; - } - { - // Verify the renderer doesn't exist. - ViERenderManagerScoped rs(*(shared_data_->render_manager())); - if (rs.Renderer(render_id)) { - LOG_F(LS_ERROR) << "Renderer already exists for render_id: " << render_id; - shared_data_->SetLastError(kViERenderAlreadyExists); - return -1; - } - } - if (render_id >= kViEChannelIdBase && render_id <= kViEChannelIdMax) { - // This is a channel. - ViEChannelManagerScoped cm(*(shared_data_->channel_manager())); - ViEFrameProviderBase* frame_provider = cm.Channel(render_id); - if (!frame_provider) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream( - render_id, NULL, 0, 0.0f, 0.0f, 1.0f, 1.0f); - if (!renderer) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - if (renderer->SetExternalRenderer(render_id, video_input_format, - external_renderer) == -1) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - - return frame_provider->RegisterFrameCallback(render_id, renderer); - } else { - // Camera or file. - ViEInputManagerScoped is(*(shared_data_->input_manager())); - ViEFrameProviderBase* frame_provider = is.FrameProvider(render_id); - if (!frame_provider) { - shared_data_->SetLastError(kViERenderInvalidRenderId); - return -1; - } - ViERenderer* renderer = shared_data_->render_manager()->AddRenderStream( - render_id, NULL, 0, 0.0f, 0.0f, 1.0f, 1.0f); - if (!renderer) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - if (renderer->SetExternalRenderer(render_id, video_input_format, - external_renderer) == -1) { - shared_data_->SetLastError(kViERenderUnknownError); - return -1; - } - return frame_provider->RegisterFrameCallback(render_id, renderer); - } -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_render_impl.h b/webrtc/video_engine/vie_render_impl.h deleted file mode 100644 index 5b36d1686f..0000000000 --- a/webrtc/video_engine/vie_render_impl.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDER_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_RENDER_IMPL_H_ - -#include "webrtc/modules/video_render/include/video_render_defines.h" -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/vie_ref_count.h" - -namespace webrtc { - -class ViESharedData; - -class ViERenderImpl - : public ViERender, - public ViERefCount { - public: - // Implements ViERender - virtual int Release(); - virtual int RegisterVideoRenderModule(VideoRender& render_module); // NOLINT - virtual int DeRegisterVideoRenderModule( - VideoRender& render_module); // NOLINT - virtual int AddRenderer(const int render_id, void* window, - const unsigned int z_order, const float left, - const float top, const float right, - const float bottom); - virtual int RemoveRenderer(const int render_id); - virtual int StartRender(const int render_id); - virtual int StopRender(const int render_id); - virtual int SetExpectedRenderDelay(int render_id, int render_delay); - virtual int ConfigureRender(int render_id, const unsigned int z_order, - const float left, const float top, - const float right, const float bottom); - virtual int AddRenderer(const int render_id, RawVideoType video_input_format, - ExternalRenderer* renderer); - - protected: - explicit ViERenderImpl(ViESharedData* shared_data); - virtual ~ViERenderImpl(); - - private: - ViESharedData* shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_RENDER_IMPL_H_ diff --git a/webrtc/video_engine/vie_render_manager.cc b/webrtc/video_engine/vie_render_manager.cc deleted file mode 100644 index e044bfac92..0000000000 --- a/webrtc/video_engine/vie_render_manager.cc +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_render_manager.h" - -#include "webrtc/engine_configurations.h" -#include "webrtc/modules/video_render/include/video_render.h" -#include "webrtc/modules/video_render/include/video_render_defines.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_renderer.h" - -namespace webrtc { - -ViERenderManagerScoped::ViERenderManagerScoped( - const ViERenderManager& vie_render_manager) - : ViEManagerScopedBase(vie_render_manager) { -} - -ViERenderer* ViERenderManagerScoped::Renderer(int32_t render_id) const { - return static_cast(vie_manager_)->ViERenderPtr( - render_id); -} - -ViERenderManager::ViERenderManager(int32_t engine_id) - : list_cs_(CriticalSectionWrapper::CreateCriticalSection()), - engine_id_(engine_id), - use_external_render_module_(false) { -} - -ViERenderManager::~ViERenderManager() { - for (RendererMap::iterator it = stream_to_vie_renderer_.begin(); - it != stream_to_vie_renderer_.end(); - ++it) { - // The renderer is deleted in RemoveRenderStream. - RemoveRenderStream(it->first); - } -} - -int32_t ViERenderManager::RegisterVideoRenderModule( - VideoRender* render_module) { - // See if there is already a render module registered for the window that - // the registrant render module is associated with. - VideoRender* current_module = FindRenderModule(render_module->Window()); - if (current_module) { - LOG_F(LS_ERROR) << "A render module is already registered for this window."; - return -1; - } - - // Register module. - render_list_.push_back(render_module); - use_external_render_module_ = true; - return 0; -} - -int32_t ViERenderManager::DeRegisterVideoRenderModule( - VideoRender* render_module) { - // Check if there are streams in the module. - uint32_t n_streams = render_module->GetNumIncomingRenderStreams(); - if (n_streams != 0) { - LOG(LS_ERROR) << "There are still " << n_streams - << "in this module, cannot de-register."; - return -1; - } - - for (RenderList::iterator iter = render_list_.begin(); - iter != render_list_.end(); ++iter) { - if (render_module == *iter) { - // We've found our renderer. Erase the render module from the map. - render_list_.erase(iter); - return 0; - } - } - - LOG(LS_ERROR) << "Module not registered."; - return -1; -} - -ViERenderer* ViERenderManager::AddRenderStream(const int32_t render_id, - void* window, - const uint32_t z_order, - const float left, - const float top, - const float right, - const float bottom) { - CriticalSectionScoped cs(list_cs_.get()); - - if (stream_to_vie_renderer_.find(render_id) != - stream_to_vie_renderer_.end()) { - LOG(LS_ERROR) << "Render stream already exists"; - return NULL; - } - - // Get the render module for this window. - VideoRender* render_module = FindRenderModule(window); - if (render_module == NULL) { - // No render module for this window, create a new one. - render_module = VideoRender::CreateVideoRender(ViEModuleId(engine_id_, -1), - window, false); - if (!render_module) - return NULL; - - render_list_.push_back(render_module); - } - - ViERenderer* vie_renderer = ViERenderer::CreateViERenderer(render_id, - engine_id_, - *render_module, - *this, z_order, - left, top, right, - bottom); - if (!vie_renderer) - return NULL; - - stream_to_vie_renderer_[render_id] = vie_renderer; - return vie_renderer; -} - -int32_t ViERenderManager::RemoveRenderStream( - const int32_t render_id) { - // We need exclusive right to the items in the render manager to delete a - // stream. - ViEManagerWriteScoped scope(this); - CriticalSectionScoped cs(list_cs_.get()); - RendererMap::iterator it = stream_to_vie_renderer_.find(render_id); - if (it == stream_to_vie_renderer_.end()) { - LOG(LS_ERROR) << "No renderer found for render_id: " << render_id; - return 0; - } - - // Get the render module pointer for this vie_render object. - VideoRender& renderer = it->second->RenderModule(); - - // Delete the vie_render. - // This deletes the stream in the render module. - delete it->second; - - // Remove from the stream map. - stream_to_vie_renderer_.erase(it); - - // Check if there are other streams in the module. - if (!use_external_render_module_ && - renderer.GetNumIncomingRenderStreams() == 0) { - // Erase the render module from the map. - for (RenderList::iterator iter = render_list_.begin(); - iter != render_list_.end(); ++iter) { - if (&renderer == *iter) { - // We've found our renderer. - render_list_.erase(iter); - break; - } - } - // Destroy the module. - VideoRender::DestroyVideoRender(&renderer); - } - return 0; -} - -VideoRender* ViERenderManager::FindRenderModule(void* window) { - for (RenderList::iterator iter = render_list_.begin(); - iter != render_list_.end(); ++iter) { - if ((*iter)->Window() == window) { - // We've found the render module. - return *iter; - } - } - return NULL; -} - -ViERenderer* ViERenderManager::ViERenderPtr(int32_t render_id) const { - RendererMap::const_iterator it = stream_to_vie_renderer_.find(render_id); - if (it == stream_to_vie_renderer_.end()) - return NULL; - - return it->second; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_render_manager.h b/webrtc/video_engine/vie_render_manager.h deleted file mode 100644 index db1626a1e0..0000000000 --- a/webrtc/video_engine/vie_render_manager.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDER_MANAGER_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_RENDER_MANAGER_H_ - -#include -#include - -#include "webrtc/base/scoped_ptr.h" -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/vie_manager_base.h" - -namespace webrtc { - -class CriticalSectionWrapper; -class RWLockWrapper; -class VideoRender; -class VideoRenderCallback; -class ViERenderer; - -class ViERenderManager : private ViEManagerBase { - friend class ViERenderManagerScoped; - public: - explicit ViERenderManager(int32_t engine_id); - ~ViERenderManager(); - - int32_t RegisterVideoRenderModule(VideoRender* render_module); - int32_t DeRegisterVideoRenderModule(VideoRender* render_module); - - ViERenderer* AddRenderStream(const int32_t render_id, - void* window, - const uint32_t z_order, - const float left, - const float top, - const float right, - const float bottom); - - int32_t RemoveRenderStream(int32_t render_id); - - private: - typedef std::list RenderList; - // Returns a pointer to the render module if it exists in the render list. - // Assumed protected. - VideoRender* FindRenderModule(void* window); - - // Methods used by ViERenderScoped. - ViERenderer* ViERenderPtr(int32_t render_id) const; - - rtc::scoped_ptr list_cs_; - int32_t engine_id_; - // Protected by ViEManagerBase. - typedef std::map RendererMap; - RendererMap stream_to_vie_renderer_; - RenderList render_list_; - bool use_external_render_module_; -}; - -class ViERenderManagerScoped: private ViEManagerScopedBase { - public: - explicit ViERenderManagerScoped(const ViERenderManager& vie_render_manager); - - // Returns a pointer to the ViERender object. - ViERenderer* Renderer(int32_t render_id) const; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_RENDER_MANAGER_H_ diff --git a/webrtc/video_engine/vie_renderer.cc b/webrtc/video_engine/vie_renderer.cc deleted file mode 100644 index 0deaf2f4bc..0000000000 --- a/webrtc/video_engine/vie_renderer.cc +++ /dev/null @@ -1,253 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_renderer.h" - -#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" -#include "webrtc/modules/video_render/include/video_render.h" -#include "webrtc/modules/video_render/include/video_render_defines.h" -#include "webrtc/video_engine/vie_render_manager.h" - -namespace webrtc { - -ViERenderer* ViERenderer::CreateViERenderer(const int32_t render_id, - const int32_t engine_id, - VideoRender& render_module, - ViERenderManager& render_manager, - const uint32_t z_order, - const float left, - const float top, - const float right, - const float bottom) { - ViERenderer* self = new ViERenderer(render_id, engine_id, render_module, - render_manager); - if (!self || self->Init(z_order, left, top, right, bottom) != 0) { - delete self; - self = NULL; - } - return self; -} - -ViERenderer::~ViERenderer(void) { - if (render_callback_) - render_module_.DeleteIncomingRenderStream(render_id_); - - delete incoming_external_callback_; -} - -int32_t ViERenderer::StartRender() { - return render_module_.StartRender(render_id_); -} -int32_t ViERenderer::StopRender() { - return render_module_.StopRender(render_id_); -} - -int ViERenderer::SetExpectedRenderDelay(int render_delay) { - return render_module_.SetExpectedRenderDelay(render_id_, render_delay); -} - -int32_t ViERenderer::ConfigureRenderer(const unsigned int z_order, - const float left, - const float top, - const float right, - const float bottom) { - return render_module_.ConfigureRenderer(render_id_, z_order, left, top, right, - bottom); -} - -VideoRender& ViERenderer::RenderModule() { - return render_module_; -} - -int32_t ViERenderer::SetTimeoutImage(const I420VideoFrame& timeout_image, - const int32_t timeout_value) { - return render_module_.SetTimeoutImage(render_id_, timeout_image, - timeout_value); -} - -int32_t ViERenderer::SetRenderStartImage( - const I420VideoFrame& start_image) { - return render_module_.SetStartImage(render_id_, start_image); -} - -int32_t ViERenderer::SetExternalRenderer( - const int32_t render_id, - RawVideoType video_input_format, - ExternalRenderer* external_renderer) { - if (!incoming_external_callback_) - return -1; - - incoming_external_callback_->SetViEExternalRenderer(external_renderer, - video_input_format); - return render_module_.AddExternalRenderCallback(render_id, - incoming_external_callback_); -} - -int32_t ViERenderer::SetVideoRenderCallback(int32_t render_id, - VideoRenderCallback* callback) { - return render_module_.AddExternalRenderCallback(render_id, callback); -} - -ViERenderer::ViERenderer(const int32_t render_id, - const int32_t engine_id, - VideoRender& render_module, - ViERenderManager& render_manager) - : render_id_(render_id), - render_module_(render_module), - render_manager_(render_manager), - render_callback_(NULL), - incoming_external_callback_(new ViEExternalRendererImpl()) { -} - -int32_t ViERenderer::Init(const uint32_t z_order, - const float left, - const float top, - const float right, - const float bottom) { - render_callback_ = - static_cast(render_module_.AddIncomingRenderStream( - render_id_, z_order, left, top, right, bottom)); - if (!render_callback_) { - // Logging done. - return -1; - } - return 0; -} - -void ViERenderer::DeliverFrame(int id, - const I420VideoFrame& video_frame, - const std::vector& csrcs) { - render_callback_->RenderFrame(render_id_, video_frame); -} - -void ViERenderer::DelayChanged(int id, int frame_delay) {} - -int ViERenderer::GetPreferedFrameSettings(int* width, - int* height, - int* frame_rate) { - return -1; -} - -void ViERenderer::ProviderDestroyed(int id) { - // Remove the render stream since the provider is destroyed. - render_manager_.RemoveRenderStream(render_id_); -} - -ViEExternalRendererImpl::ViEExternalRendererImpl() - : external_renderer_(NULL), - external_renderer_format_(kVideoUnknown), - external_renderer_width_(0), - external_renderer_height_(0) { -} - -int ViEExternalRendererImpl::SetViEExternalRenderer( - ExternalRenderer* external_renderer, - RawVideoType video_input_format) { - external_renderer_ = external_renderer; - external_renderer_format_ = video_input_format; - return 0; -} - -int32_t ViEExternalRendererImpl::RenderFrame( - const uint32_t stream_id, - const I420VideoFrame& video_frame) { - if (external_renderer_format_ != kVideoI420) - return ConvertAndRenderFrame(stream_id, video_frame); - - // Fast path for I420 without frame copy. - NotifyFrameSizeChange(stream_id, video_frame); - if (video_frame.native_handle() == NULL || - external_renderer_->IsTextureSupported()) { - external_renderer_->DeliverI420Frame(video_frame); - } else { - // TODO(wuchengli): readback the pixels and deliver the frame. - } - return 0; -} - -int32_t ViEExternalRendererImpl::ConvertAndRenderFrame( - uint32_t stream_id, - const I420VideoFrame& video_frame) { - if (video_frame.native_handle() != NULL) { - NotifyFrameSizeChange(stream_id, video_frame); - - if (external_renderer_->IsTextureSupported()) { - external_renderer_->DeliverFrame(NULL, - 0, - video_frame.timestamp(), - video_frame.ntp_time_ms(), - video_frame.render_time_ms(), - video_frame.native_handle()); - } else { - // TODO(wuchengli): readback the pixels and deliver the frame. - } - return 0; - } - - // Convert to requested format. - VideoType type = - RawVideoTypeToCommonVideoVideoType(external_renderer_format_); - size_t buffer_size = CalcBufferSize(type, video_frame.width(), - video_frame.height()); - if (buffer_size == 0) { - // Unsupported video format. - assert(false); - return -1; - } - converted_frame_.resize(buffer_size); - uint8_t* out_frame = &converted_frame_[0]; - - switch (external_renderer_format_) { - case kVideoYV12: - case kVideoYUY2: - case kVideoUYVY: - case kVideoARGB: - case kVideoRGB24: - case kVideoRGB565: - case kVideoARGB4444: - case kVideoARGB1555: - if (ConvertFromI420(video_frame, type, 0, out_frame) < 0) - return -1; - break; - case kVideoIYUV: - // no conversion available - break; - default: - assert(false); - out_frame = NULL; - break; - } - - NotifyFrameSizeChange(stream_id, video_frame); - - if (out_frame) { - external_renderer_->DeliverFrame(out_frame, - converted_frame_.size(), - video_frame.timestamp(), - video_frame.ntp_time_ms(), - video_frame.render_time_ms(), - NULL); - } - return 0; -} - -void ViEExternalRendererImpl::NotifyFrameSizeChange( - const uint32_t stream_id, - const I420VideoFrame& video_frame) { - if (external_renderer_width_ != video_frame.width() || - external_renderer_height_ != video_frame.height()) { - external_renderer_width_ = video_frame.width(); - external_renderer_height_ = video_frame.height(); - external_renderer_->FrameSizeChange( - external_renderer_width_, external_renderer_height_, stream_id); - } -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_renderer.h b/webrtc/video_engine/vie_renderer.h deleted file mode 100644 index 55765a706d..0000000000 --- a/webrtc/video_engine/vie_renderer.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_ - -#include - -#include "webrtc/modules/video_render/include/video_render_defines.h" -#include "webrtc/video_engine/include/vie_render.h" -#include "webrtc/video_engine/vie_frame_provider_base.h" - -namespace webrtc { - -class VideoRender; -class VideoRenderCallback; -class ViERenderManager; - -class ViEExternalRendererImpl : public VideoRenderCallback { - public: - ViEExternalRendererImpl(); - virtual ~ViEExternalRendererImpl() {} - - int SetViEExternalRenderer(ExternalRenderer* external_renderer, - RawVideoType video_input_format); - - // Implements VideoRenderCallback. - virtual int32_t RenderFrame(const uint32_t stream_id, - const I420VideoFrame& video_frame); - - private: - void NotifyFrameSizeChange(const uint32_t stream_id, - const I420VideoFrame& video_frame); - int32_t ConvertAndRenderFrame(uint32_t stream_id, - const I420VideoFrame& video_frame); - ExternalRenderer* external_renderer_; - RawVideoType external_renderer_format_; - int external_renderer_width_; - int external_renderer_height_; - // Converted_frame_ in color format specified by render_format_. - std::vector converted_frame_; -}; - -class ViERenderer: public ViEFrameCallback { - public: - static ViERenderer* CreateViERenderer(const int32_t render_id, - const int32_t engine_id, - VideoRender& render_module, - ViERenderManager& render_manager, - const uint32_t z_order, - const float left, - const float top, - const float right, - const float bottom); - ~ViERenderer(void); - - int32_t StartRender(); - int32_t StopRender(); - - int SetExpectedRenderDelay(int render_delay); - - int32_t ConfigureRenderer(const unsigned int z_order, - const float left, - const float top, - const float right, - const float bottom); - - VideoRender& RenderModule(); - - int32_t SetTimeoutImage(const I420VideoFrame& timeout_image, - const int32_t timeout_value); - int32_t SetRenderStartImage(const I420VideoFrame& start_image); - int32_t SetExternalRenderer(const int32_t render_id, - RawVideoType video_input_format, - ExternalRenderer* external_renderer); - - int32_t SetVideoRenderCallback(const int32_t render_id, - VideoRenderCallback* callback); - - private: - ViERenderer(const int32_t render_id, const int32_t engine_id, - VideoRender& render_module, - ViERenderManager& render_manager); - - int32_t Init(const uint32_t z_order, - const float left, - const float top, - const float right, - const float bottom); - - // Implement ViEFrameCallback - virtual void DeliverFrame(int id, - const I420VideoFrame& video_frame, - const std::vector& csrcs); - virtual void DelayChanged(int id, int frame_delay); - virtual int GetPreferedFrameSettings(int* width, - int* height, - int* frame_rate); - virtual void ProviderDestroyed(int id); - - uint32_t render_id_; - VideoRender& render_module_; - ViERenderManager& render_manager_; - VideoRenderCallback* render_callback_; - ViEExternalRendererImpl* incoming_external_callback_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_RENDERER_H_ diff --git a/webrtc/video_engine/vie_rtp_rtcp_impl.cc b/webrtc/video_engine/vie_rtp_rtcp_impl.cc deleted file mode 100644 index 9b2a4391b6..0000000000 --- a/webrtc/video_engine/vie_rtp_rtcp_impl.cc +++ /dev/null @@ -1,1075 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/video_engine/vie_rtp_rtcp_impl.h" - -#include "webrtc/engine_configurations.h" -#include "webrtc/system_wrappers/interface/file_wrapper.h" -#include "webrtc/system_wrappers/interface/logging.h" -#include "webrtc/video_engine/include/vie_errors.h" -#include "webrtc/video_engine/vie_channel.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_encoder.h" -#include "webrtc/video_engine/vie_impl.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -// Helper methods for converting between module format and ViE API format. - -static RTCPMethod ViERTCPModeToRTCPMethod(ViERTCPMode api_mode) { - switch (api_mode) { - case kRtcpNone: - return kRtcpOff; - - case kRtcpCompound_RFC4585: - return kRtcpCompound; - - case kRtcpNonCompound_RFC5506: - return kRtcpNonCompound; - } - assert(false); - return kRtcpOff; -} - -static ViERTCPMode RTCPMethodToViERTCPMode(RTCPMethod module_method) { - switch (module_method) { - case kRtcpOff: - return kRtcpNone; - - case kRtcpCompound: - return kRtcpCompound_RFC4585; - - case kRtcpNonCompound: - return kRtcpNonCompound_RFC5506; - } - assert(false); - return kRtcpNone; -} - -static KeyFrameRequestMethod APIRequestToModuleRequest( - ViEKeyFrameRequestMethod api_method) { - switch (api_method) { - case kViEKeyFrameRequestNone: - return kKeyFrameReqFirRtp; - - case kViEKeyFrameRequestPliRtcp: - return kKeyFrameReqPliRtcp; - - case kViEKeyFrameRequestFirRtp: - return kKeyFrameReqFirRtp; - - case kViEKeyFrameRequestFirRtcp: - return kKeyFrameReqFirRtcp; - } - assert(false); - return kKeyFrameReqFirRtp; -} - -ViERTP_RTCP* ViERTP_RTCP::GetInterface(VideoEngine* video_engine) { -#ifdef WEBRTC_VIDEO_ENGINE_RTP_RTCP_API - if (!video_engine) { - return NULL; - } - VideoEngineImpl* vie_impl = static_cast(video_engine); - ViERTP_RTCPImpl* vie_rtpimpl = vie_impl; - // Increase ref count. - (*vie_rtpimpl)++; - return vie_rtpimpl; -#else - return NULL; -#endif -} - -int ViERTP_RTCPImpl::Release() { - // Decrease ref count. - (*this)--; - - int32_t ref_count = GetCount(); - if (ref_count < 0) { - LOG(LS_ERROR) << "ViERTP_RTCP released too many times."; - shared_data_->SetLastError(kViEAPIDoesNotExist); - return -1; - } - return ref_count; -} - -ViERTP_RTCPImpl::ViERTP_RTCPImpl(ViESharedData* shared_data) - : shared_data_(shared_data) {} - -ViERTP_RTCPImpl::~ViERTP_RTCPImpl() {} - -int ViERTP_RTCPImpl::SetLocalSSRC(const int video_channel, - const unsigned int SSRC, - const StreamType usage, - const unsigned char simulcast_idx) { - LOG_F(LS_INFO) << "channel: " << video_channel << " ssrc: " << SSRC << ""; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetSSRC(SSRC, usage, simulcast_idx) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetRemoteSSRCType(const int videoChannel, - const StreamType usage, - const unsigned int SSRC) const { - LOG_F(LS_INFO) << "channel: " << videoChannel - << " usage: " << static_cast(usage) << " ssrc: " << SSRC; - - // Get the channel - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* ptrViEChannel = cs.Channel(videoChannel); - if (ptrViEChannel == NULL) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (ptrViEChannel->SetRemoteSSRCType(usage, SSRC) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetLocalSSRC(const int video_channel, - unsigned int& SSRC) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - uint8_t idx = 0; - if (vie_channel->GetLocalSSRC(idx, &SSRC) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetRemoteSSRC(const int video_channel, - unsigned int& SSRC) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->GetRemoteSSRC(&SSRC) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetRemoteCSRCs(const int video_channel, - unsigned int CSRCs[kRtpCsrcSize]) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->GetRemoteCSRC(CSRCs) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetRtxSendPayloadType( - const int video_channel, - const uint8_t payload_type, - const uint8_t associated_payload_type) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " payload_type: " << static_cast(payload_type); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetRtxSendPayloadType(payload_type, - associated_payload_type) != 0) { - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetRtxReceivePayloadType( - const int video_channel, - const uint8_t payload_type, - const uint8_t associated_payload_type) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " payload_type: " << static_cast(payload_type); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->SetRtxReceivePayloadType(payload_type, associated_payload_type); - return 0; -} - -int ViERTP_RTCPImpl::SetStartSequenceNumber(const int video_channel, - uint16_t sequence_number) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->Sending()) { - LOG_F(LS_ERROR) << "channel " << video_channel << " is already sending."; - shared_data_->SetLastError(kViERtpRtcpAlreadySending); - return -1; - } - if (vie_channel->SetStartSequenceNumber(sequence_number) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -void ViERTP_RTCPImpl::SetRtpStateForSsrc(int video_channel, - uint32_t ssrc, - const RtpState& rtp_state) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) - return; - - if (vie_channel->Sending()) { - LOG_F(LS_ERROR) << "channel " << video_channel << " is already sending."; - return; - } - vie_channel->SetRtpStateForSsrc(ssrc, rtp_state); -} - -RtpState ViERTP_RTCPImpl::GetRtpStateForSsrc(int video_channel, uint32_t ssrc) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) - return RtpState(); - - return vie_channel->GetRtpStateForSsrc(ssrc); -} - -int ViERTP_RTCPImpl::SetRTCPStatus(const int video_channel, - const ViERTCPMode rtcp_mode) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " mode: " << static_cast(rtcp_mode); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - - RTCPMethod module_mode = ViERTCPModeToRTCPMethod(rtcp_mode); - vie_channel->SetRTCPMode(module_mode); - return 0; -} - -int ViERTP_RTCPImpl::GetRTCPStatus(const int video_channel, - ViERTCPMode& rtcp_mode) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - RTCPMethod module_mode = vie_channel->GetRTCPMode(); - rtcp_mode = RTCPMethodToViERTCPMode(module_mode); - return 0; -} - -int ViERTP_RTCPImpl::SetRTCPCName(const int video_channel, - const char rtcp_cname[KMaxRTCPCNameLength]) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " rtcp_cname: " << rtcp_cname; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->Sending()) { - LOG_F(LS_ERROR) << "channel " << video_channel << " is already sending."; - shared_data_->SetLastError(kViERtpRtcpAlreadySending); - return -1; - } - if (vie_channel->SetRTCPCName(rtcp_cname) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetRemoteRTCPCName( - const int video_channel, - char rtcp_cname[KMaxRTCPCNameLength]) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->GetRemoteRTCPCName(rtcp_cname) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SendApplicationDefinedRTCPPacket( - const int video_channel, - const unsigned char sub_type, - unsigned int name, - const char* data, - uint16_t data_length_in_bytes) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (!vie_channel->Sending()) { - shared_data_->SetLastError(kViERtpRtcpNotSending); - return -1; - } - RTCPMethod method = vie_channel->GetRTCPMode(); - if (method == kRtcpOff) { - shared_data_->SetLastError(kViERtpRtcpRtcpDisabled); - return -1; - } - if (vie_channel->SendApplicationDefinedRTCPPacket( - sub_type, name, reinterpret_cast(data), - data_length_in_bytes) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetNACKStatus(const int video_channel, const bool enable) { - LOG_F(LS_INFO) << "channel: " << video_channel << " " - << (enable ? "on" : "off"); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetNACKStatus(enable) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - - // Update the encoder - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - vie_encoder->UpdateProtectionMethod(enable, - vie_channel->IsSendingFecEnabled()); - return 0; -} - -int ViERTP_RTCPImpl::SetFECStatus(const int video_channel, const bool enable, - const unsigned char payload_typeRED, - const unsigned char payload_typeFEC) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off") - << " payload_typeRED: " << static_cast(payload_typeRED) - << " payload_typeFEC: " << static_cast(payload_typeFEC); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetFECStatus(enable, payload_typeRED, - payload_typeFEC) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - // Update the encoder. - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - vie_encoder->UpdateProtectionMethod(false, true); - return 0; -} - -int ViERTP_RTCPImpl::SetHybridNACKFECStatus( - const int video_channel, - const bool enable, - const unsigned char payload_typeRED, - const unsigned char payload_typeFEC) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off") - << " payload_typeRED: " << static_cast(payload_typeRED) - << " payload_typeFEC: " << static_cast(payload_typeFEC); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - - // Update the channel status with hybrid NACK FEC mode. - if (vie_channel->SetHybridNACKFECStatus(enable, payload_typeRED, - payload_typeFEC) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - - // Update the encoder. - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - vie_encoder->UpdateProtectionMethod(enable, enable); - return 0; -} - -int ViERTP_RTCPImpl::SetSenderBufferingMode(int video_channel, - int target_delay_ms) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " target_delay_ms: " << target_delay_ms; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (!vie_encoder) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - - // Update the channel with buffering mode settings. - if (vie_channel->SetSenderBufferingMode(target_delay_ms) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - - // Update the encoder's buffering mode settings. - vie_encoder->SetSenderBufferingMode(target_delay_ms); - return 0; -} - -int ViERTP_RTCPImpl::SetReceiverBufferingMode(int video_channel, - int target_delay_ms) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " target_delay_ms: " << target_delay_ms; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - - // Update the channel with buffering mode settings. - if (vie_channel->SetReceiverBufferingMode(target_delay_ms) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetKeyFrameRequestMethod( - const int video_channel, - const ViEKeyFrameRequestMethod method) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " method: " << static_cast(method); - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - KeyFrameRequestMethod module_method = APIRequestToModuleRequest(method); - if (vie_channel->SetKeyFrameRequestMethod(module_method) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetTMMBRStatus(const int video_channel, - const bool enable) { - LOG_F(LS_INFO) << "channel: " << video_channel - << "enable: " << (enable ? "on" : "off"); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->EnableTMMBR(enable); - return 0; -} - -int ViERTP_RTCPImpl::SetRembStatus(int video_channel, - bool sender, - bool receiver) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " sender: " << (sender ? "on" : "off") - << " receiver: " << (receiver ? "on" : "off"); - if (!shared_data_->channel_manager()->SetRembStatus(video_channel, sender, - receiver)) { - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetSendTimestampOffsetStatus(int video_channel, - bool enable, - int id) { - LOG_F(LS_INFO) << "channel: " << video_channel - << "enable: " << (enable ? "on" : "off") << " id: " << id; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetSendTimestampOffsetStatus(enable, id) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetReceiveTimestampOffsetStatus(int video_channel, - bool enable, - int id) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off") << " id: " << id; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetReceiveTimestampOffsetStatus(enable, id) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetSendAbsoluteSendTimeStatus(int video_channel, - bool enable, - int id) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off") << " id: " << id; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetSendAbsoluteSendTimeStatus(enable, id) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetReceiveAbsoluteSendTimeStatus(int video_channel, - bool enable, - int id) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off") << " id: " << id; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetReceiveAbsoluteSendTimeStatus(enable, id) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetSendVideoRotationStatus(int video_channel, - bool enable, - int id) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off") << " id: " << id; - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetSendVideoRotationStatus(enable, id) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetReceiveVideoRotationStatus(int video_channel, - bool enable, - int id) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off") << " id: " << id; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->SetReceiveVideoRotationStatus(enable, id) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::SetRtcpXrRrtrStatus(int video_channel, bool enable) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off"); - - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->SetRtcpXrRrtrStatus(enable); - return 0; -} - -int ViERTP_RTCPImpl::SetTransmissionSmoothingStatus(int video_channel, - bool enable) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " enable: " << (enable ? "on" : "off"); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->SetTransmissionSmoothingStatus(enable); - return 0; -} - -int ViERTP_RTCPImpl::SetMinTransmitBitrate(int video_channel, - int min_transmit_bitrate_kbps) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " min_transmit_bitrate_kbps: " << min_transmit_bitrate_kbps; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEEncoder* vie_encoder = cs.Encoder(video_channel); - if (vie_encoder == NULL) - return -1; - vie_encoder->SetMinTransmitBitrate(min_transmit_bitrate_kbps); - return 0; -} - -int ViERTP_RTCPImpl::SetReservedTransmitBitrate( - int video_channel, unsigned int reserved_transmit_bitrate_bps) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " reserved_transmit_bitrate_bps: " - << reserved_transmit_bitrate_bps; - if (!shared_data_->channel_manager()->SetReservedTransmitBitrate( - video_channel, reserved_transmit_bitrate_bps)) { - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetReceiveChannelRtcpStatistics( - const int video_channel, - RtcpStatistics& basic_stats, - int64_t& rtt_ms) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - - // TODO(sprang): Clean this up when stats struct is propagated all the way. - uint16_t frac_lost; - if (vie_channel->GetReceivedRtcpStatistics( - &frac_lost, - &basic_stats.cumulative_lost, - &basic_stats.extended_max_sequence_number, - &basic_stats.jitter, - &rtt_ms) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - basic_stats.fraction_lost = frac_lost; - return 0; -} - -int ViERTP_RTCPImpl::GetSendChannelRtcpStatistics(const int video_channel, - RtcpStatistics& basic_stats, - int64_t& rtt_ms) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - - // TODO(sprang): Clean this up when stats struct is propagated all the way. - uint16_t frac_lost; - if (vie_channel->GetSendRtcpStatistics( - &frac_lost, - &basic_stats.cumulative_lost, - &basic_stats.extended_max_sequence_number, - &basic_stats.jitter, - &rtt_ms) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - basic_stats.fraction_lost = frac_lost; - return 0; -} - -int ViERTP_RTCPImpl::GetRtpStatistics(const int video_channel, - StreamDataCounters& sent, - StreamDataCounters& received) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->GetRtpStatistics(&sent.transmitted.payload_bytes, - &sent.transmitted.packets, - &received.transmitted.payload_bytes, - &received.transmitted.packets) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetSendRtcpPacketTypeCounter( - int video_channel, - RtcpPacketTypeCounter* packet_counter) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->GetSendRtcpPacketTypeCounter(packet_counter); - return 0; -} - -int ViERTP_RTCPImpl::GetReceiveRtcpPacketTypeCounter( - int video_channel, - RtcpPacketTypeCounter* packet_counter) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->GetReceiveRtcpPacketTypeCounter(packet_counter); - return 0; -} - -int ViERTP_RTCPImpl::GetBandwidthUsage(const int video_channel, - unsigned int& total_bitrate_sent, - unsigned int& video_bitrate_sent, - unsigned int& fec_bitrate_sent, - unsigned int& nackBitrateSent) const { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->GetBandwidthUsage(&total_bitrate_sent, - &video_bitrate_sent, - &fec_bitrate_sent, - &nackBitrateSent); - return 0; -} - -int ViERTP_RTCPImpl::GetEstimatedSendBandwidth( - const int video_channel, - unsigned int* estimated_bandwidth) const { - if (!shared_data_->channel_manager()->GetEstimatedSendBandwidth( - video_channel, estimated_bandwidth)) { - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetEstimatedReceiveBandwidth( - const int video_channel, - unsigned int* estimated_bandwidth) const { - if (!shared_data_->channel_manager()->GetEstimatedReceiveBandwidth( - video_channel, estimated_bandwidth)) { - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::GetPacerQueuingDelayMs( - const int video_channel, int64_t* delay_ms) const { - if (!shared_data_->channel_manager()->GetPacerQueuingDelayMs(video_channel, - delay_ms)) { - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::StartRTPDump(const int video_channel, - const char file_nameUTF8[1024], - RTPDirections direction) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " filename: " << file_nameUTF8 - << " direction: " << static_cast(direction); - assert(FileWrapper::kMaxFileNameSize == 1024); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->StartRTPDump(file_nameUTF8, direction) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::StopRTPDump(const int video_channel, - RTPDirections direction) { - LOG_F(LS_INFO) << "channel: " << video_channel - << " direction: " << static_cast(direction); - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->StopRTPDump(direction) != 0) { - shared_data_->SetLastError(kViERtpRtcpUnknownError); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::RegisterRTPObserver(const int video_channel, - ViERTPObserver& observer) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->RegisterRtpObserver(&observer) != 0) { - shared_data_->SetLastError(kViERtpRtcpObserverAlreadyRegistered); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::DeregisterRTPObserver(const int video_channel) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - if (vie_channel->RegisterRtpObserver(NULL) != 0) { - shared_data_->SetLastError(kViERtpRtcpObserverNotRegistered); - return -1; - } - return 0; -} - -int ViERTP_RTCPImpl::RegisterSendChannelRtcpStatisticsCallback( - int video_channel, RtcpStatisticsCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->RegisterSendChannelRtcpStatisticsCallback(callback); - return 0; -} - -int ViERTP_RTCPImpl::DeregisterSendChannelRtcpStatisticsCallback( - int video_channel, RtcpStatisticsCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->RegisterSendChannelRtcpStatisticsCallback(NULL); - return 0; -} - -int ViERTP_RTCPImpl::RegisterReceiveChannelRtcpStatisticsCallback( - const int video_channel, - RtcpStatisticsCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterReceiveChannelRtcpStatisticsCallback(callback); - return 0; -} - -int ViERTP_RTCPImpl::DeregisterReceiveChannelRtcpStatisticsCallback( - const int video_channel, - RtcpStatisticsCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterReceiveChannelRtcpStatisticsCallback(NULL); - return 0; -} - -int ViERTP_RTCPImpl::RegisterSendChannelRtpStatisticsCallback( - int video_channel, StreamDataCountersCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterSendChannelRtpStatisticsCallback(callback); - return 0; -} - -int ViERTP_RTCPImpl::DeregisterSendChannelRtpStatisticsCallback( - int video_channel, StreamDataCountersCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterSendChannelRtpStatisticsCallback(NULL); - return 0; -} - -int ViERTP_RTCPImpl::RegisterReceiveChannelRtpStatisticsCallback( - const int video_channel, - StreamDataCountersCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterReceiveChannelRtpStatisticsCallback(callback); - return 0; -} - -int ViERTP_RTCPImpl::DeregisterReceiveChannelRtpStatisticsCallback( - const int video_channel, - StreamDataCountersCallback* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterReceiveChannelRtpStatisticsCallback(NULL); - return 0; -} - -// Called whenever the send bitrate is updated. -int ViERTP_RTCPImpl::RegisterSendBitrateObserver( - const int video_channel, - BitrateStatisticsObserver* observer) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterSendBitrateObserver(observer); - return 0; -} - -int ViERTP_RTCPImpl::DeregisterSendBitrateObserver( - const int video_channel, - BitrateStatisticsObserver* observer) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - assert(vie_channel != NULL); - vie_channel->RegisterSendBitrateObserver(NULL); - return 0; -} - -int ViERTP_RTCPImpl::RegisterSendFrameCountObserver( - int video_channel, FrameCountObserver* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->RegisterSendFrameCountObserver(callback); - return 0; -} - -int ViERTP_RTCPImpl::DeregisterSendFrameCountObserver( - int video_channel, FrameCountObserver* callback) { - LOG_F(LS_INFO) << "channel " << video_channel; - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->RegisterSendFrameCountObserver(NULL); - return 0; -} - -int ViERTP_RTCPImpl::RegisterRtcpPacketTypeCounterObserver( - int video_channel, - RtcpPacketTypeCounterObserver* observer) { - ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); - ViEChannel* vie_channel = cs.Channel(video_channel); - if (!vie_channel) { - shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); - return -1; - } - vie_channel->RegisterRtcpPacketTypeCounterObserver(observer); - return 0; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_rtp_rtcp_impl.h b/webrtc/video_engine/vie_rtp_rtcp_impl.h deleted file mode 100644 index e22747f918..0000000000 --- a/webrtc/video_engine/vie_rtp_rtcp_impl.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_RTP_RTCP_IMPL_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_RTP_RTCP_IMPL_H_ - -#include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h" -#include "webrtc/typedefs.h" -#include "webrtc/video_engine/include/vie_rtp_rtcp.h" -#include "webrtc/video_engine/vie_ref_count.h" - -namespace webrtc { - -class ViESharedData; - -class ViERTP_RTCPImpl - : public ViERTP_RTCP, - public ViERefCount { - public: - // Implements ViERTP_RTCP. - virtual int Release(); - virtual int SetLocalSSRC(const int video_channel, - const unsigned int SSRC, - const StreamType usage, - const unsigned char simulcast_idx); - virtual int GetLocalSSRC(const int video_channel, - unsigned int& SSRC) const; // NOLINT - virtual int SetRemoteSSRCType(const int video_channel, - const StreamType usage, - const unsigned int SSRC) const; - virtual int GetRemoteSSRC(const int video_channel, - unsigned int& SSRC) const; // NOLINT - virtual int GetRemoteCSRCs(const int video_channel, - unsigned int CSRCs[kRtpCsrcSize]) const; - virtual int SetRtxSendPayloadType(const int video_channel, - const uint8_t payload_type, - const uint8_t associated_payload_type); - virtual int SetRtxReceivePayloadType(const int video_channel, - const uint8_t payload_type, - const uint8_t associated_payload_type); - virtual int SetStartSequenceNumber(const int video_channel, - uint16_t sequence_number); - void SetRtpStateForSsrc(int video_channel, - uint32_t ssrc, - const RtpState& rtp_state) override; - RtpState GetRtpStateForSsrc(int video_channel, uint32_t ssrc) override; - virtual int SetRTCPStatus(const int video_channel, - const ViERTCPMode rtcp_mode); - virtual int GetRTCPStatus(const int video_channel, - ViERTCPMode& rtcp_mode) const; - virtual int SetRTCPCName(const int video_channel, - const char rtcp_cname[KMaxRTCPCNameLength]); - virtual int GetRemoteRTCPCName(const int video_channel, - char rtcp_cname[KMaxRTCPCNameLength]) const; - virtual int SendApplicationDefinedRTCPPacket( - const int video_channel, - const unsigned char sub_type, - unsigned int name, - const char* data, - uint16_t data_length_in_bytes); - virtual int SetNACKStatus(const int video_channel, const bool enable); - virtual int SetFECStatus(const int video_channel, const bool enable, - const unsigned char payload_typeRED, - const unsigned char payload_typeFEC); - virtual int SetHybridNACKFECStatus(const int video_channel, const bool enable, - const unsigned char payload_typeRED, - const unsigned char payload_typeFEC); - virtual int SetSenderBufferingMode(int video_channel, - int target_delay_ms); - virtual int SetReceiverBufferingMode(int video_channel, - int target_delay_ms); - virtual int SetKeyFrameRequestMethod(const int video_channel, - const ViEKeyFrameRequestMethod method); - virtual int SetTMMBRStatus(const int video_channel, const bool enable); - virtual int SetRembStatus(int video_channel, bool sender, bool receiver); - virtual int SetSendTimestampOffsetStatus(int video_channel, - bool enable, - int id); - virtual int SetReceiveTimestampOffsetStatus(int video_channel, - bool enable, - int id); - virtual int SetSendAbsoluteSendTimeStatus(int video_channel, - bool enable, - int id); - virtual int SetReceiveAbsoluteSendTimeStatus(int video_channel, - bool enable, - int id); - virtual int SetSendVideoRotationStatus(int video_channel, - bool enable, - int id); - virtual int SetReceiveVideoRotationStatus(int video_channel, - bool enable, - int id); - virtual int SetRtcpXrRrtrStatus(int video_channel, bool enable); - virtual int SetTransmissionSmoothingStatus(int video_channel, bool enable); - virtual int SetMinTransmitBitrate(int video_channel, - int min_transmit_bitrate_kbps); - virtual int SetReservedTransmitBitrate( - int video_channel, unsigned int reserved_transmit_bitrate_bps); - virtual int GetReceiveChannelRtcpStatistics(const int video_channel, - RtcpStatistics& basic_stats, - int64_t& rtt_ms) const; - virtual int GetSendChannelRtcpStatistics(const int video_channel, - RtcpStatistics& basic_stats, - int64_t& rtt_ms) const; - virtual int GetRtpStatistics(const int video_channel, - StreamDataCounters& sent, - StreamDataCounters& received) const; - virtual int GetSendRtcpPacketTypeCounter( - int video_channel, - RtcpPacketTypeCounter* packet_counter) const; - virtual int GetReceiveRtcpPacketTypeCounter( - int video_channel, - RtcpPacketTypeCounter* packet_counter) const; - virtual int GetBandwidthUsage(const int video_channel, - unsigned int& total_bitrate_sent, - unsigned int& video_bitrate_sent, - unsigned int& fec_bitrate_sent, - unsigned int& nackBitrateSent) const; - virtual int GetEstimatedSendBandwidth( - const int video_channel, - unsigned int* estimated_bandwidth) const; - virtual int GetEstimatedReceiveBandwidth( - const int video_channel, - unsigned int* estimated_bandwidth) const; - virtual int GetPacerQueuingDelayMs(const int video_channel, - int64_t* delay_ms) const; - virtual int StartRTPDump(const int video_channel, - const char file_nameUTF8[1024], - RTPDirections direction); - virtual int StopRTPDump(const int video_channel, RTPDirections direction); - virtual int RegisterRTPObserver(const int video_channel, - ViERTPObserver& observer); - virtual int DeregisterRTPObserver(const int video_channel); - - virtual int RegisterSendChannelRtcpStatisticsCallback( - int channel, RtcpStatisticsCallback* callback); - virtual int DeregisterSendChannelRtcpStatisticsCallback( - int channel, RtcpStatisticsCallback* callback); - virtual int RegisterReceiveChannelRtcpStatisticsCallback( - int channel, RtcpStatisticsCallback* callback); - virtual int DeregisterReceiveChannelRtcpStatisticsCallback( - int channel, RtcpStatisticsCallback* callback); - virtual int RegisterSendChannelRtpStatisticsCallback( - int channel, StreamDataCountersCallback* callback); - virtual int DeregisterSendChannelRtpStatisticsCallback( - int channel, StreamDataCountersCallback* callback); - virtual int RegisterReceiveChannelRtpStatisticsCallback( - int channel, StreamDataCountersCallback* callback); - virtual int DeregisterReceiveChannelRtpStatisticsCallback( - int channel, StreamDataCountersCallback* callback); - virtual int RegisterSendBitrateObserver( - int channel, BitrateStatisticsObserver* callback); - virtual int DeregisterSendBitrateObserver( - int channel, BitrateStatisticsObserver* callback); - virtual int RegisterSendFrameCountObserver( - int channel, FrameCountObserver* callback); - virtual int DeregisterSendFrameCountObserver( - int channel, FrameCountObserver* callback); - int RegisterRtcpPacketTypeCounterObserver( - int video_channel, - RtcpPacketTypeCounterObserver* observer) override; - - protected: - explicit ViERTP_RTCPImpl(ViESharedData* shared_data); - virtual ~ViERTP_RTCPImpl(); - - private: - ViESharedData* shared_data_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_RTP_RTCP_IMPL_H_ diff --git a/webrtc/video_engine/vie_shared_data.cc b/webrtc/video_engine/vie_shared_data.cc deleted file mode 100644 index bfb579b093..0000000000 --- a/webrtc/video_engine/vie_shared_data.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/utility/interface/process_thread.h" -#include "webrtc/system_wrappers/interface/cpu_info.h" -#include "webrtc/system_wrappers/interface/trace.h" -#include "webrtc/video_engine/vie_channel_manager.h" -#include "webrtc/video_engine/vie_defines.h" -#include "webrtc/video_engine/vie_input_manager.h" -#include "webrtc/video_engine/vie_render_manager.h" -#include "webrtc/video_engine/vie_shared_data.h" - -namespace webrtc { - -ViESharedData::ViESharedData(const Config& config) - : number_cores_(CpuInfo::DetectNumberOfCores()), - channel_manager_(new ViEChannelManager(0, number_cores_, config)), - input_manager_(new ViEInputManager(0, config)), - render_manager_(new ViERenderManager(0)), - module_process_thread_(ProcessThread::Create()), - last_error_(0) { - Trace::CreateTrace(); - channel_manager_->SetModuleProcessThread(module_process_thread_.get()); - input_manager_->SetModuleProcessThread(module_process_thread_.get()); - module_process_thread_->Start(); -} - -ViESharedData::~ViESharedData() { - // Release these ones before the process thread and the trace. - input_manager_.reset(); - channel_manager_.reset(); - render_manager_.reset(); - - module_process_thread_->Stop(); - Trace::ReturnTrace(); -} - -void ViESharedData::SetLastError(const int error) const { - last_error_ = error; -} - -int ViESharedData::LastErrorInternal() const { - int error = last_error_; - last_error_ = 0; - return error; -} - -int ViESharedData::NumberOfCores() const { - return number_cores_; -} - -} // namespace webrtc diff --git a/webrtc/video_engine/vie_shared_data.h b/webrtc/video_engine/vie_shared_data.h deleted file mode 100644 index d7c365edd0..0000000000 --- a/webrtc/video_engine/vie_shared_data.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -// ViESharedData contains data and instances common to all interface -// implementations. - -#ifndef WEBRTC_VIDEO_ENGINE_VIE_SHARED_DATA_H_ -#define WEBRTC_VIDEO_ENGINE_VIE_SHARED_DATA_H_ - -#include - -#include "webrtc/base/scoped_ptr.h" - -namespace webrtc { - -class Config; -class CpuOveruseObserver; -class ProcessThread; -class ViEChannelManager; -class ViEInputManager; -class ViERenderManager; - -class ViESharedData { - public: - explicit ViESharedData(const Config& config); - ~ViESharedData(); - - void SetLastError(const int error) const; - int LastErrorInternal() const; - int NumberOfCores() const; - - // TODO(mflodman) Remove all calls to 'instance_id()'. - int instance_id() { return 0;} - ViEChannelManager* channel_manager() { return channel_manager_.get(); } - ViEInputManager* input_manager() { return input_manager_.get(); } - ViERenderManager* render_manager() { return render_manager_.get(); } - ProcessThread* module_process_thread() { - return module_process_thread_.get(); - } - - std::map* overuse_observers() { - return &overuse_observers_; } - - private: - const int number_cores_; - - rtc::scoped_ptr channel_manager_; - rtc::scoped_ptr input_manager_; - rtc::scoped_ptr render_manager_; - rtc::scoped_ptr module_process_thread_; - mutable int last_error_; - - std::map overuse_observers_; -}; - -} // namespace webrtc - -#endif // WEBRTC_VIDEO_ENGINE_VIE_SHARED_DATA_H_ diff --git a/webrtc/voice_engine/channel.cc b/webrtc/voice_engine/channel.cc index c3fba0ddce..def39887e3 100644 --- a/webrtc/voice_engine/channel.cc +++ b/webrtc/voice_engine/channel.cc @@ -29,7 +29,6 @@ #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/logging.h" #include "webrtc/system_wrappers/interface/trace.h" -#include "webrtc/video_engine/include/vie_network.h" #include "webrtc/voice_engine/include/voe_base.h" #include "webrtc/voice_engine/include/voe_external_media.h" #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" @@ -814,8 +813,6 @@ Channel::Channel(int32_t channelId, _lastPayloadType(0), _includeAudioLevelIndication(false), _outputSpeechType(AudioFrame::kNormalSpeech), - vie_network_(NULL), - video_channel_(-1), _average_jitter_buffer_delay_us(0), least_required_delay_ms_(0), _previousTimestamp(0), @@ -928,10 +925,6 @@ Channel::~Channel() // End of modules shutdown // Delete other objects - if (vie_network_) { - vie_network_->Release(); - vie_network_ = NULL; - } RtpDump::DestroyRtpDump(&_rtpDumpIn); RtpDump::DestroyRtpDump(&_rtpDumpOut); delete &_callbackCritSect; @@ -1668,22 +1661,6 @@ int32_t Channel::ReceivedRTPPacket(const int8_t* data, size_t length, IsPacketRetransmitted(header, in_order)); rtp_payload_registry_->SetIncomingPayloadType(header); - // Forward any packets to ViE bandwidth estimator, if enabled. - { - CriticalSectionScoped cs(&_callbackCritSect); - if (vie_network_) { - int64_t arrival_time_ms; - if (packet_time.timestamp != -1) { - arrival_time_ms = (packet_time.timestamp + 500) / 1000; - } else { - arrival_time_ms = TickTime::MillisecondTimestamp(); - } - size_t payload_length = length - header.headerLength; - vie_network_->ReceivedBWEPacket(video_channel_, arrival_time_ms, - payload_length, header); - } - } - return ReceivePacket(received_packet, length, header, in_order) ? 0 : -1; } @@ -3468,21 +3445,6 @@ Channel::RTPDumpIsActive(RTPDirections direction) return rtpDumpPtr->IsActive(); } -void Channel::SetVideoEngineBWETarget(ViENetwork* vie_network, - int video_channel) { - CriticalSectionScoped cs(&_callbackCritSect); - if (vie_network_) { - vie_network_->Release(); - vie_network_ = NULL; - } - video_channel_ = -1; - - if (vie_network != NULL && video_channel != -1) { - vie_network_ = vie_network; - video_channel_ = video_channel; - } -} - uint32_t Channel::Demultiplex(const AudioFrame& audioFrame) { diff --git a/webrtc/voice_engine/channel.h b/webrtc/voice_engine/channel.h index 83924f3b14..d3d6d89ad9 100644 --- a/webrtc/voice_engine/channel.h +++ b/webrtc/voice_engine/channel.h @@ -57,7 +57,6 @@ class RtpReceiver; class RTPReceiverAudio; class RtpRtcp; class TelephoneEventHandler; -class ViENetwork; class VoEMediaProcess; class VoERTPObserver; class VoiceEngineObserver; @@ -343,8 +342,6 @@ public: int StartRTPDump(const char fileNameUTF8[1024], RTPDirections direction); int StopRTPDump(RTPDirections direction); bool RTPDumpIsActive(RTPDirections direction); - // Takes ownership of the ViENetwork. - void SetVideoEngineBWETarget(ViENetwork* vie_network, int video_channel); // From AudioPacketizationCallback in the ACM int32_t SendData(FrameType frameType, @@ -562,8 +559,6 @@ private: bool _includeAudioLevelIndication; // VoENetwork AudioFrame::SpeechType _outputSpeechType; - ViENetwork* vie_network_; - int video_channel_; // VoEVideoSync uint32_t _average_jitter_buffer_delay_us; int least_required_delay_ms_; diff --git a/webrtc/voice_engine/include/voe_rtp_rtcp.h b/webrtc/voice_engine/include/voe_rtp_rtcp.h index 421afd8849..a032cf8fe3 100644 --- a/webrtc/voice_engine/include/voe_rtp_rtcp.h +++ b/webrtc/voice_engine/include/voe_rtp_rtcp.h @@ -44,7 +44,6 @@ namespace webrtc { -class ViENetwork; class VoiceEngine; // VoERTPObserver @@ -240,15 +239,6 @@ class WEBRTC_DLLEXPORT VoERTP_RTCP { virtual int RTPDumpIsActive(int channel, RTPDirections direction = kRtpIncoming) = 0; - // Sets video engine channel to receive incoming audio packets for - // aggregated bandwidth estimation. Takes ownership of the ViENetwork - // interface. - virtual int SetVideoEngineBWETarget(int channel, - ViENetwork* vie_network, - int video_channel) { - return 0; - } - // Will be removed. Don't use. virtual int RegisterRTPObserver(int channel, VoERTPObserver& observer) { return -1; diff --git a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc index 18f064eb77..734433836f 100644 --- a/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc +++ b/webrtc/voice_engine/test/auto_test/standard/rtp_rtcp_extensions.cc @@ -12,7 +12,6 @@ #include "webrtc/modules/rtp_rtcp/interface/rtp_header_parser.h" #include "webrtc/system_wrappers/interface/atomic32.h" #include "webrtc/system_wrappers/interface/sleep.h" -#include "webrtc/video_engine/include/vie_network.h" #include "webrtc/voice_engine/test/auto_test/fixtures/before_streaming_fixture.h" using ::testing::_; @@ -152,156 +151,3 @@ TEST_F(SendRtpRtcpHeaderExtensionsTest, SentPacketsIncludeAllExtensions2) { ResumePlaying(); EXPECT_TRUE(verifying_transport_.Wait()); } - -class MockViENetwork : public webrtc::ViENetwork { - public: - MockViENetwork() {} - virtual ~MockViENetwork() {} - - MOCK_METHOD0(Release, int()); - MOCK_METHOD4(SetBitrateConfig, void(int, int, int, int)); - MOCK_METHOD2(SetNetworkTransmissionState, void(const int, const bool)); - MOCK_METHOD2(RegisterSendTransport, int(const int, webrtc::Transport&)); - MOCK_METHOD1(DeregisterSendTransport, int(const int)); - MOCK_METHOD4(ReceivedRTPPacket, int(const int, const void*, const size_t, - const webrtc::PacketTime&)); - MOCK_METHOD3(ReceivedRTCPPacket, int(const int, const void*, const size_t)); - MOCK_METHOD2(SetMTU, int(int, unsigned int)); - MOCK_METHOD4(ReceivedBWEPacket, int(const int, int64_t, size_t, - const webrtc::RTPHeader&)); -}; - -class ReceiveRtpRtcpHeaderExtensionsTest : public BeforeStreamingFixture { - protected: - void SetUp() override { - EXPECT_EQ(0, - voe_rtp_rtcp_->SetSendAbsoluteSenderTimeStatus(channel_, true, 11)); - EXPECT_EQ(0, - voe_rtp_rtcp_->SetReceiveAbsoluteSenderTimeStatus(channel_, true, 11)); - } - - void Wait() { - WaitForTransmittedPackets(kPacketsExpected); - } - - enum { - kPacketsExpected = 5, - kVideoChannelId1 = 667, - kVideoChannelId2 = 668 - }; - MockViENetwork mock_network_; -}; - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTDisabled) { - EXPECT_CALL(mock_network_, ReceivedBWEPacket(_, _, _, _)).Times(0); - ResumePlaying(); - Wait(); -} - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTFailSetTarget) { - EXPECT_CALL(mock_network_, Release()).Times(1); - EXPECT_EQ(-1, voe_rtp_rtcp_->SetVideoEngineBWETarget(-1, &mock_network_, - kVideoChannelId1)); - ResumePlaying(); - Wait(); -} - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabled) { - EXPECT_CALL(mock_network_, Release()).Times(1); - EXPECT_CALL(mock_network_, ReceivedBWEPacket(kVideoChannelId1, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(true))))) - .Times(AtLeast(1)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_, - kVideoChannelId1)); - ResumePlaying(); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1)); -} - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabledBadExtensionId) { - EXPECT_CALL(mock_network_, Release()).Times(1); - EXPECT_CALL(mock_network_, ReceivedBWEPacket(kVideoChannelId1, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(false))))) - .Times(AtLeast(1)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetReceiveAbsoluteSenderTimeStatus(channel_, true, - 1)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_, - kVideoChannelId1)); - ResumePlaying(); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1)); -} - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabledNotSending) { - EXPECT_CALL(mock_network_, Release()).Times(1); - EXPECT_CALL(mock_network_, ReceivedBWEPacket(kVideoChannelId1, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(false))))) - .Times(AtLeast(1)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetSendAbsoluteSenderTimeStatus(channel_, false, - 11)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_, - kVideoChannelId1)); - ResumePlaying(); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1)); -} - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTEnabledNotReceiving) { - EXPECT_CALL(mock_network_, Release()).Times(1); - EXPECT_CALL(mock_network_, ReceivedBWEPacket(kVideoChannelId1, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(false))))) - .Times(AtLeast(1)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetReceiveAbsoluteSenderTimeStatus(channel_, - false, 11)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_, - kVideoChannelId1)); - ResumePlaying(); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1)); -} - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTSwitchViENetwork) { - MockViENetwork mock_network_2; - EXPECT_CALL(mock_network_2, Release()).Times(1); - EXPECT_CALL(mock_network_2, ReceivedBWEPacket(kVideoChannelId1, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(true))))) - .Times(AtLeast(1)); - EXPECT_CALL(mock_network_, Release()).Times(1); - EXPECT_CALL(mock_network_, ReceivedBWEPacket(kVideoChannelId1, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(true))))) - .Times(AtLeast(1)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_2, - kVideoChannelId1)); - ResumePlaying(); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_, - kVideoChannelId1)); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1)); -} - -TEST_F(ReceiveRtpRtcpHeaderExtensionsTest, ReceiveASTSwitchVideoChannel) { - EXPECT_CALL(mock_network_, Release()).Times(2); - EXPECT_CALL(mock_network_, ReceivedBWEPacket(kVideoChannelId1, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(true))))) - .Times(AtLeast(1)); - EXPECT_CALL(mock_network_, ReceivedBWEPacket(kVideoChannelId2, _, _, - Field(&webrtc::RTPHeader::extension, - Field(&webrtc::RTPHeaderExtension::hasAbsoluteSendTime, Eq(true))))) - .Times(AtLeast(1)); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_, - kVideoChannelId1)); - ResumePlaying(); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, &mock_network_, - kVideoChannelId2)); - Wait(); - EXPECT_EQ(0, voe_rtp_rtcp_->SetVideoEngineBWETarget(channel_, NULL, -1)); -} diff --git a/webrtc/voice_engine/voe_rtp_rtcp_impl.cc b/webrtc/voice_engine/voe_rtp_rtcp_impl.cc index c4c70674fd..71f3c849f2 100644 --- a/webrtc/voice_engine/voe_rtp_rtcp_impl.cc +++ b/webrtc/voice_engine/voe_rtp_rtcp_impl.cc @@ -11,7 +11,6 @@ #include "webrtc/system_wrappers/interface/critical_section_wrapper.h" #include "webrtc/system_wrappers/interface/file_wrapper.h" #include "webrtc/system_wrappers/interface/trace.h" -#include "webrtc/video_engine/include/vie_network.h" #include "webrtc/voice_engine/include/voe_errors.h" #include "webrtc/voice_engine/voe_rtp_rtcp_impl.h" #include "webrtc/voice_engine/voice_engine_impl.h" @@ -500,28 +499,6 @@ int VoERTP_RTCPImpl::RTPDumpIsActive(int channel, RTPDirections direction) { return channelPtr->RTPDumpIsActive(direction); } -int VoERTP_RTCPImpl::SetVideoEngineBWETarget(int channel, - ViENetwork* vie_network, - int video_channel) { - WEBRTC_TRACE( - kTraceApiCall, kTraceVoice, VoEId(_shared->instance_id(), -1), - "SetVideoEngineBWETarget(channel=%d, vie_network=?, video_channel=%d)", - channel, vie_network, video_channel); - - voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); - voe::Channel* channelPtr = ch.channel(); - if (channelPtr == NULL) { - _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, - "SetVideoEngineBWETarget() failed to locate channel"); - if (vie_network) { - vie_network->Release(); - } - return -1; - } - channelPtr->SetVideoEngineBWETarget(vie_network, video_channel); - return 0; -} - #endif // #ifdef WEBRTC_VOICE_ENGINE_RTP_RTCP_API } // namespace webrtc diff --git a/webrtc/voice_engine/voe_rtp_rtcp_impl.h b/webrtc/voice_engine/voe_rtp_rtcp_impl.h index b83ab2d411..1d0978d335 100644 --- a/webrtc/voice_engine/voe_rtp_rtcp_impl.h +++ b/webrtc/voice_engine/voe_rtp_rtcp_impl.h @@ -89,10 +89,6 @@ class VoERTP_RTCPImpl : public VoERTP_RTCP { int RTPDumpIsActive(int channel, RTPDirections direction = kRtpIncoming) override; - int SetVideoEngineBWETarget(int channel, - ViENetwork* vie_network, - int video_channel) override; - protected: VoERTP_RTCPImpl(voe::SharedData* shared); ~VoERTP_RTCPImpl() override;