1/* 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#include "webrtc/video_engine/test/auto_test/primitives/base_primitives.h" 12 13#include "webrtc/modules/video_capture/include/video_capture_factory.h" 14#include "webrtc/video_engine/test/auto_test/interface/vie_autotest.h" 15#include "webrtc/video_engine/test/auto_test/interface/vie_autotest_defines.h" 16#include "webrtc/video_engine/test/libvietest/include/tb_external_transport.h" 17 18static void ConfigureCodecsToI420(int video_channel, 19 webrtc::VideoCodec video_codec, 20 webrtc::ViECodec* codec_interface) { 21 // Set up the codec interface with all known receive codecs and with 22 // I420 as the send codec. 23 for (int i = 0; i < codec_interface->NumberOfCodecs(); i++) { 24 EXPECT_EQ(0, codec_interface->GetCodec(i, video_codec)); 25 26 // Try to keep the test frame size small and bit rate generous when I420. 27 if (video_codec.codecType == webrtc::kVideoCodecI420) { 28 video_codec.width = 176; 29 video_codec.height = 144; 30 video_codec.maxBitrate = 32000; 31 video_codec.startBitrate = 32000; 32 EXPECT_EQ(0, codec_interface->SetSendCodec(video_channel, video_codec)); 33 } 34 35 EXPECT_EQ(0, codec_interface->SetReceiveCodec(video_channel, video_codec)); 36 } 37 // Verify that we really found the I420 codec. 38 EXPECT_EQ(0, codec_interface->GetSendCodec(video_channel, video_codec)); 39 EXPECT_EQ(webrtc::kVideoCodecI420, video_codec.codecType); 40} 41 42void TestI420CallSetup(webrtc::ViECodec* codec_interface, 43 webrtc::VideoEngine* video_engine, 44 webrtc::ViEBase* base_interface, 45 webrtc::ViENetwork* network_interface, 46 webrtc::ViERTP_RTCP* rtp_rtcp_interface, 47 int video_channel, 48 const char* device_name) { 49 webrtc::VideoCodec video_codec; 50 memset(&video_codec, 0, sizeof(webrtc::VideoCodec)); 51 EXPECT_EQ(0, rtp_rtcp_interface->SetTransmissionSmoothingStatus(video_channel, 52 false)); 53 54 ConfigureCodecsToI420(video_channel, video_codec, codec_interface); 55 56 TbExternalTransport external_transport( 57 *network_interface, video_channel, NULL); 58 EXPECT_EQ(0, network_interface->RegisterSendTransport( 59 video_channel, external_transport)); 60 EXPECT_EQ(0, base_interface->StartReceive(video_channel)); 61 EXPECT_EQ(0, base_interface->StartSend(video_channel)); 62 63 // Let the call run for a while. 64 ViETest::Log("Call started"); 65 AutoTestSleep(kAutoTestSleepTimeMs); 66 67 // Stop the call. 68 ViETest::Log("Stopping call."); 69 EXPECT_EQ(0, base_interface->StopSend(video_channel)); 70 71 // Make sure we receive all packets. 72 AutoTestSleep(1000); 73 74 EXPECT_EQ(0, base_interface->StopReceive(video_channel)); 75 EXPECT_EQ(0, network_interface->DeregisterSendTransport(video_channel)); 76} 77