henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2004 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include "talk/base/fakecpumonitor.h" |
| 29 | #include "talk/base/gunit.h" |
| 30 | #include "talk/base/logging.h" |
| 31 | #include "talk/base/scoped_ptr.h" |
| 32 | #include "talk/base/stream.h" |
| 33 | #include "talk/media/base/constants.h" |
| 34 | #include "talk/media/base/fakemediaprocessor.h" |
| 35 | #include "talk/media/base/fakenetworkinterface.h" |
| 36 | #include "talk/media/base/fakevideorenderer.h" |
| 37 | #include "talk/media/base/mediachannel.h" |
| 38 | #include "talk/media/base/testutils.h" |
mallinath@webrtc.org | 67ee6b9 | 2014-02-03 16:57:16 +0000 | [diff] [blame] | 39 | #include "talk/media/base/videoadapter.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | #include "talk/media/base/videoengine_unittest.h" |
| 41 | #include "talk/media/webrtc/fakewebrtcvideocapturemodule.h" |
| 42 | #include "talk/media/webrtc/fakewebrtcvideoengine.h" |
| 43 | #include "talk/media/webrtc/fakewebrtcvoiceengine.h" |
| 44 | #include "talk/media/webrtc/webrtcvideocapturer.h" |
| 45 | #include "talk/media/webrtc/webrtcvideoengine.h" |
| 46 | #include "talk/media/webrtc/webrtcvideoframe.h" |
| 47 | #include "talk/media/webrtc/webrtcvoiceengine.h" |
| 48 | #include "talk/session/media/mediasession.h" |
| 49 | #include "webrtc/system_wrappers/interface/trace.h" |
| 50 | |
| 51 | // Tests for the WebRtcVideoEngine/VideoChannel code. |
| 52 | |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 53 | using cricket::kRtpTimestampOffsetHeaderExtension; |
| 54 | using cricket::kRtpAbsoluteSenderTimeHeaderExtension; |
| 55 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 56 | static const cricket::VideoCodec kVP8Codec720p(100, "VP8", 1280, 720, 30, 0); |
| 57 | static const cricket::VideoCodec kVP8Codec360p(100, "VP8", 640, 360, 30, 0); |
| 58 | static const cricket::VideoCodec kVP8Codec270p(100, "VP8", 480, 270, 30, 0); |
| 59 | static const cricket::VideoCodec kVP8Codec180p(100, "VP8", 320, 180, 30, 0); |
| 60 | |
| 61 | static const cricket::VideoCodec kVP8Codec(100, "VP8", 640, 400, 30, 0); |
| 62 | static const cricket::VideoCodec kRedCodec(101, "red", 0, 0, 0, 0); |
| 63 | static const cricket::VideoCodec kUlpFecCodec(102, "ulpfec", 0, 0, 0, 0); |
| 64 | static const cricket::VideoCodec* const kVideoCodecs[] = { |
| 65 | &kVP8Codec, |
| 66 | &kRedCodec, |
| 67 | &kUlpFecCodec |
| 68 | }; |
| 69 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 70 | static const unsigned int kStartBandwidthKbps = 300; |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 71 | static const unsigned int kMinBandwidthKbps = 50; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 72 | static const unsigned int kMaxBandwidthKbps = 2000; |
| 73 | |
| 74 | static const unsigned int kNumberOfTemporalLayers = 1; |
| 75 | |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 76 | static const uint32 kSsrcs1[] = {1}; |
| 77 | static const uint32 kSsrcs2[] = {1, 2}; |
| 78 | static const uint32 kSsrcs3[] = {1, 2, 3}; |
| 79 | static const uint32 kRtxSsrc1[] = {4}; |
| 80 | static const uint32 kRtxSsrcs3[] = {4, 5, 6}; |
| 81 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 82 | |
| 83 | class FakeViEWrapper : public cricket::ViEWrapper { |
| 84 | public: |
| 85 | explicit FakeViEWrapper(cricket::FakeWebRtcVideoEngine* engine) |
| 86 | : cricket::ViEWrapper(engine, // base |
| 87 | engine, // codec |
| 88 | engine, // capture |
| 89 | engine, // network |
| 90 | engine, // render |
| 91 | engine, // rtp |
| 92 | engine, // image |
| 93 | engine) { // external decoder |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | // Test fixture to test WebRtcVideoEngine with a fake webrtc::VideoEngine. |
| 98 | // Useful for testing failure paths. |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 99 | class WebRtcVideoEngineTestFake : public testing::Test, |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 100 | public sigslot::has_slots<> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 101 | public: |
| 102 | WebRtcVideoEngineTestFake() |
| 103 | : vie_(kVideoCodecs, ARRAY_SIZE(kVideoCodecs)), |
| 104 | cpu_monitor_(new talk_base::FakeCpuMonitor( |
| 105 | talk_base::Thread::Current())), |
| 106 | engine_(NULL, // cricket::WebRtcVoiceEngine |
| 107 | new FakeViEWrapper(&vie_), cpu_monitor_), |
| 108 | channel_(NULL), |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 109 | voice_channel_(NULL), |
| 110 | last_error_(cricket::VideoMediaChannel::ERROR_NONE) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 111 | } |
| 112 | bool SetupEngine() { |
| 113 | bool result = engine_.Init(talk_base::Thread::Current()); |
| 114 | if (result) { |
| 115 | channel_ = engine_.CreateChannel(voice_channel_); |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 116 | channel_->SignalMediaError.connect(this, |
| 117 | &WebRtcVideoEngineTestFake::OnMediaError); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 118 | result = (channel_ != NULL); |
| 119 | } |
| 120 | return result; |
| 121 | } |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 122 | void OnMediaError(uint32 ssrc, cricket::VideoMediaChannel::Error error) { |
| 123 | last_error_ = error; |
| 124 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 125 | bool SendI420Frame(int width, int height) { |
| 126 | if (NULL == channel_) { |
| 127 | return false; |
| 128 | } |
| 129 | cricket::WebRtcVideoFrame frame; |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 130 | if (!frame.InitToBlack(width, height, 1, 1, 0, 0)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 131 | return false; |
| 132 | } |
| 133 | cricket::FakeVideoCapturer capturer; |
wu@webrtc.org | f7d501d | 2014-03-27 23:48:25 +0000 | [diff] [blame] | 134 | channel_->SendFrame(&capturer, &frame); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 135 | return true; |
| 136 | } |
| 137 | bool SendI420ScreencastFrame(int width, int height) { |
| 138 | return SendI420ScreencastFrameWithTimestamp(width, height, 0); |
| 139 | } |
| 140 | bool SendI420ScreencastFrameWithTimestamp( |
| 141 | int width, int height, int64 timestamp) { |
| 142 | if (NULL == channel_) { |
| 143 | return false; |
| 144 | } |
| 145 | cricket::WebRtcVideoFrame frame; |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 146 | if (!frame.InitToBlack(width, height, 1, 1, 0, 0)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 147 | return false; |
| 148 | } |
| 149 | cricket::FakeVideoCapturer capturer; |
| 150 | capturer.SetScreencast(true); |
wu@webrtc.org | f7d501d | 2014-03-27 23:48:25 +0000 | [diff] [blame] | 151 | channel_->SendFrame(&capturer, &frame); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 152 | return true; |
| 153 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 154 | void TestSetSendRtpHeaderExtensions(const std::string& ext) { |
| 155 | EXPECT_TRUE(SetupEngine()); |
| 156 | int channel_num = vie_.GetLastChannel(); |
| 157 | |
| 158 | // Verify extensions are off by default. |
| 159 | EXPECT_EQ(-1, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 160 | |
| 161 | // Enable extension. |
| 162 | const int id = 1; |
| 163 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 164 | extensions.push_back(cricket::RtpHeaderExtension(ext, id)); |
| 165 | |
| 166 | // Verify the send extension id. |
| 167 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 168 | EXPECT_EQ(id, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 169 | // Verify call with same set of extensions returns true. |
| 170 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 171 | EXPECT_EQ(id, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 172 | |
| 173 | // Add a new send stream and verify the extension is set. |
| 174 | // The first send stream to occupy the default channel. |
| 175 | EXPECT_TRUE( |
| 176 | channel_->AddSendStream(cricket::StreamParams::CreateLegacy(123))); |
| 177 | EXPECT_TRUE( |
| 178 | channel_->AddSendStream(cricket::StreamParams::CreateLegacy(234))); |
| 179 | int new_send_channel_num = vie_.GetLastChannel(); |
| 180 | EXPECT_NE(channel_num, new_send_channel_num); |
| 181 | EXPECT_EQ(id, vie_.GetSendRtpExtensionId(new_send_channel_num, ext)); |
| 182 | |
| 183 | // Remove the extension id. |
| 184 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
| 185 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(empty_extensions)); |
| 186 | EXPECT_EQ(-1, vie_.GetSendRtpExtensionId(channel_num, ext)); |
| 187 | EXPECT_EQ(-1, vie_.GetSendRtpExtensionId(new_send_channel_num, ext)); |
| 188 | } |
| 189 | void TestSetRecvRtpHeaderExtensions(const std::string& ext) { |
| 190 | EXPECT_TRUE(SetupEngine()); |
| 191 | int channel_num = vie_.GetLastChannel(); |
| 192 | |
| 193 | // Verify extensions are off by default. |
| 194 | EXPECT_EQ(-1, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 195 | |
| 196 | // Enable extension. |
| 197 | const int id = 2; |
| 198 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 199 | extensions.push_back(cricket::RtpHeaderExtension(ext, id)); |
| 200 | |
| 201 | // Verify receive extension id. |
| 202 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 203 | EXPECT_EQ(id, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 204 | // Verify call with same set of extensions returns true. |
| 205 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(extensions)); |
| 206 | EXPECT_EQ(id, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 207 | |
| 208 | // Add a new receive stream and verify the extension is set. |
| 209 | // The first send stream to occupy the default channel. |
| 210 | EXPECT_TRUE( |
| 211 | channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(345))); |
| 212 | EXPECT_TRUE( |
| 213 | channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(456))); |
| 214 | int new_recv_channel_num = vie_.GetLastChannel(); |
| 215 | EXPECT_NE(channel_num, new_recv_channel_num); |
| 216 | EXPECT_EQ(id, vie_.GetReceiveRtpExtensionId(new_recv_channel_num, ext)); |
| 217 | |
| 218 | // Remove the extension id. |
| 219 | std::vector<cricket::RtpHeaderExtension> empty_extensions; |
| 220 | EXPECT_TRUE(channel_->SetRecvRtpHeaderExtensions(empty_extensions)); |
| 221 | EXPECT_EQ(-1, vie_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 222 | EXPECT_EQ(-1, vie_.GetReceiveRtpExtensionId(new_recv_channel_num, ext)); |
| 223 | } |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 224 | void VerifyCodecFeedbackParams(const cricket::VideoCodec& codec) { |
| 225 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 226 | cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
| 227 | cricket::kParamValueEmpty))); |
| 228 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 229 | cricket::FeedbackParam(cricket::kRtcpFbParamNack, |
| 230 | cricket::kRtcpFbNackParamPli))); |
| 231 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 232 | cricket::FeedbackParam(cricket::kRtcpFbParamRemb, |
| 233 | cricket::kParamValueEmpty))); |
| 234 | EXPECT_TRUE(codec.HasFeedbackParam( |
| 235 | cricket::FeedbackParam(cricket::kRtcpFbParamCcm, |
| 236 | cricket::kRtcpFbCcmParamFir))); |
| 237 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 238 | void VerifyVP8SendCodec(int channel_num, |
| 239 | unsigned int width, |
| 240 | unsigned int height, |
| 241 | unsigned int layers = 0, |
| 242 | unsigned int max_bitrate = kMaxBandwidthKbps, |
| 243 | unsigned int min_bitrate = kMinBandwidthKbps, |
| 244 | unsigned int start_bitrate = kStartBandwidthKbps, |
| 245 | unsigned int fps = 30, |
| 246 | unsigned int max_quantization = 0 |
| 247 | ) { |
| 248 | webrtc::VideoCodec gcodec; |
| 249 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 250 | |
| 251 | // Video codec properties. |
| 252 | EXPECT_EQ(webrtc::kVideoCodecVP8, gcodec.codecType); |
| 253 | EXPECT_STREQ("VP8", gcodec.plName); |
| 254 | EXPECT_EQ(100, gcodec.plType); |
| 255 | EXPECT_EQ(width, gcodec.width); |
| 256 | EXPECT_EQ(height, gcodec.height); |
| 257 | EXPECT_EQ(talk_base::_min(start_bitrate, max_bitrate), gcodec.startBitrate); |
| 258 | EXPECT_EQ(max_bitrate, gcodec.maxBitrate); |
| 259 | EXPECT_EQ(min_bitrate, gcodec.minBitrate); |
| 260 | EXPECT_EQ(fps, gcodec.maxFramerate); |
| 261 | // VP8 specific. |
| 262 | EXPECT_FALSE(gcodec.codecSpecific.VP8.pictureLossIndicationOn); |
| 263 | EXPECT_FALSE(gcodec.codecSpecific.VP8.feedbackModeOn); |
| 264 | EXPECT_EQ(webrtc::kComplexityNormal, gcodec.codecSpecific.VP8.complexity); |
| 265 | EXPECT_EQ(webrtc::kResilienceOff, gcodec.codecSpecific.VP8.resilience); |
| 266 | EXPECT_EQ(max_quantization, gcodec.qpMax); |
| 267 | } |
| 268 | virtual void TearDown() { |
| 269 | delete channel_; |
| 270 | engine_.Terminate(); |
| 271 | } |
| 272 | |
| 273 | protected: |
| 274 | cricket::FakeWebRtcVideoEngine vie_; |
| 275 | cricket::FakeWebRtcVideoDecoderFactory decoder_factory_; |
| 276 | cricket::FakeWebRtcVideoEncoderFactory encoder_factory_; |
| 277 | talk_base::FakeCpuMonitor* cpu_monitor_; |
| 278 | cricket::WebRtcVideoEngine engine_; |
| 279 | cricket::WebRtcVideoMediaChannel* channel_; |
| 280 | cricket::WebRtcVoiceMediaChannel* voice_channel_; |
wu@webrtc.org | d64719d | 2013-08-01 00:00:07 +0000 | [diff] [blame] | 281 | cricket::VideoMediaChannel::Error last_error_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 282 | }; |
| 283 | |
| 284 | // Test fixtures to test WebRtcVideoEngine with a real webrtc::VideoEngine. |
| 285 | class WebRtcVideoEngineTest |
| 286 | : public VideoEngineTest<cricket::WebRtcVideoEngine> { |
| 287 | protected: |
| 288 | typedef VideoEngineTest<cricket::WebRtcVideoEngine> Base; |
| 289 | }; |
| 290 | class WebRtcVideoMediaChannelTest |
| 291 | : public VideoMediaChannelTest< |
| 292 | cricket::WebRtcVideoEngine, cricket::WebRtcVideoMediaChannel> { |
| 293 | protected: |
| 294 | typedef VideoMediaChannelTest<cricket::WebRtcVideoEngine, |
| 295 | cricket::WebRtcVideoMediaChannel> Base; |
| 296 | virtual cricket::VideoCodec DefaultCodec() { return kVP8Codec; } |
| 297 | virtual void SetUp() { |
| 298 | Base::SetUp(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 299 | } |
| 300 | virtual void TearDown() { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 301 | Base::TearDown(); |
| 302 | } |
| 303 | }; |
| 304 | |
| 305 | ///////////////////////// |
| 306 | // Tests with fake ViE // |
| 307 | ///////////////////////// |
| 308 | |
| 309 | // Tests that our stub library "works". |
| 310 | TEST_F(WebRtcVideoEngineTestFake, StartupShutdown) { |
| 311 | EXPECT_FALSE(vie_.IsInited()); |
| 312 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 313 | EXPECT_TRUE(vie_.IsInited()); |
| 314 | engine_.Terminate(); |
| 315 | } |
| 316 | |
| 317 | // Tests that webrtc logs are logged when they should be. |
| 318 | TEST_F(WebRtcVideoEngineTest, WebRtcShouldLog) { |
| 319 | const char webrtc_log[] = "WebRtcVideoEngineTest.WebRtcShouldLog"; |
| 320 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 321 | engine_.SetLogging(talk_base::LS_INFO, ""); |
| 322 | std::string str; |
| 323 | talk_base::StringStream stream(str); |
| 324 | talk_base::LogMessage::AddLogToStream(&stream, talk_base::LS_INFO); |
| 325 | EXPECT_EQ(talk_base::LS_INFO, talk_base::LogMessage::GetLogToStream(&stream)); |
| 326 | webrtc::Trace::Add(webrtc::kTraceStateInfo, webrtc::kTraceUndefined, 0, |
| 327 | webrtc_log); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 328 | talk_base::Thread::Current()->ProcessMessages(100); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 329 | talk_base::LogMessage::RemoveLogToStream(&stream); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 330 | // Access |str| after LogMessage is done with it to avoid data racing. |
| 331 | EXPECT_NE(std::string::npos, str.find(webrtc_log)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | // Tests that webrtc logs are not logged when they should't be. |
| 335 | TEST_F(WebRtcVideoEngineTest, WebRtcShouldNotLog) { |
| 336 | const char webrtc_log[] = "WebRtcVideoEngineTest.WebRtcShouldNotLog"; |
| 337 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 338 | // WebRTC should never be logged lower than LS_INFO. |
| 339 | engine_.SetLogging(talk_base::LS_WARNING, ""); |
| 340 | std::string str; |
| 341 | talk_base::StringStream stream(str); |
| 342 | // Make sure that WebRTC is not logged, even at lowest severity |
| 343 | talk_base::LogMessage::AddLogToStream(&stream, talk_base::LS_SENSITIVE); |
| 344 | EXPECT_EQ(talk_base::LS_SENSITIVE, |
| 345 | talk_base::LogMessage::GetLogToStream(&stream)); |
| 346 | webrtc::Trace::Add(webrtc::kTraceStateInfo, webrtc::kTraceUndefined, 0, |
| 347 | webrtc_log); |
| 348 | talk_base::Thread::Current()->ProcessMessages(10); |
| 349 | EXPECT_EQ(std::string::npos, str.find(webrtc_log)); |
| 350 | talk_base::LogMessage::RemoveLogToStream(&stream); |
| 351 | } |
| 352 | |
| 353 | // Tests that we can create and destroy a channel. |
| 354 | TEST_F(WebRtcVideoEngineTestFake, CreateChannel) { |
| 355 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 356 | channel_ = engine_.CreateChannel(voice_channel_); |
| 357 | EXPECT_TRUE(channel_ != NULL); |
| 358 | EXPECT_EQ(1, engine_.GetNumOfChannels()); |
| 359 | delete channel_; |
| 360 | channel_ = NULL; |
| 361 | EXPECT_EQ(0, engine_.GetNumOfChannels()); |
| 362 | } |
| 363 | |
| 364 | // Tests that we properly handle failures in CreateChannel. |
| 365 | TEST_F(WebRtcVideoEngineTestFake, CreateChannelFail) { |
| 366 | vie_.set_fail_create_channel(true); |
| 367 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 368 | channel_ = engine_.CreateChannel(voice_channel_); |
| 369 | EXPECT_TRUE(channel_ == NULL); |
| 370 | } |
| 371 | |
| 372 | // Tests that we properly handle failures in AllocateExternalCaptureDevice. |
| 373 | TEST_F(WebRtcVideoEngineTestFake, AllocateExternalCaptureDeviceFail) { |
| 374 | vie_.set_fail_alloc_capturer(true); |
| 375 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 376 | channel_ = engine_.CreateChannel(voice_channel_); |
| 377 | EXPECT_TRUE(channel_ == NULL); |
| 378 | } |
| 379 | |
| 380 | // Test that we apply our default codecs properly. |
| 381 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecs) { |
| 382 | EXPECT_TRUE(SetupEngine()); |
| 383 | int channel_num = vie_.GetLastChannel(); |
| 384 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 385 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 386 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 387 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 388 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 389 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 390 | // TODO(juberti): Check RTCP, PLI, TMMBR. |
| 391 | } |
| 392 | |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 393 | // Test that ViE Channel doesn't call SetSendCodec again if same codec is tried |
| 394 | // to apply. |
| 395 | TEST_F(WebRtcVideoEngineTestFake, DontResetSetSendCodec) { |
| 396 | EXPECT_TRUE(SetupEngine()); |
| 397 | int channel_num = vie_.GetLastChannel(); |
| 398 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 399 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 400 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 401 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 402 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
| 403 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
| 404 | // Try setting same code again. |
| 405 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 406 | // Since it's exact same codec which is already set, media channel shouldn't |
| 407 | // send the codec to ViE. |
| 408 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
| 409 | } |
| 410 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 411 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMinMaxBitrate) { |
| 412 | EXPECT_TRUE(SetupEngine()); |
| 413 | int channel_num = vie_.GetLastChannel(); |
| 414 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 415 | codecs[0].params[cricket::kCodecParamMinBitrate] = "10"; |
| 416 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 417 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 418 | |
| 419 | VerifyVP8SendCodec( |
| 420 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 421 | |
| 422 | cricket::VideoCodec codec; |
| 423 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 424 | EXPECT_EQ("10", codec.params[cricket::kCodecParamMinBitrate]); |
| 425 | EXPECT_EQ("20", codec.params[cricket::kCodecParamMaxBitrate]); |
| 426 | } |
| 427 | |
buildbot@webrtc.org | ed97bb0 | 2014-05-07 11:15:20 +0000 | [diff] [blame] | 428 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithStartBitrate) { |
| 429 | EXPECT_TRUE(SetupEngine()); |
| 430 | int channel_num = vie_.GetLastChannel(); |
| 431 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 432 | codecs[0].params[cricket::kCodecParamStartBitrate] = "450"; |
| 433 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 434 | |
| 435 | VerifyVP8SendCodec( |
| 436 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 2000, 50, 450); |
| 437 | |
| 438 | cricket::VideoCodec codec; |
| 439 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 440 | EXPECT_EQ("450", codec.params[cricket::kCodecParamStartBitrate]); |
| 441 | } |
| 442 | |
| 443 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMinMaxStartBitrate) { |
| 444 | EXPECT_TRUE(SetupEngine()); |
| 445 | int channel_num = vie_.GetLastChannel(); |
| 446 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 447 | codecs[0].params[cricket::kCodecParamMinBitrate] = "10"; |
| 448 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 449 | codecs[0].params[cricket::kCodecParamStartBitrate] = "14"; |
| 450 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 451 | |
| 452 | VerifyVP8SendCodec( |
| 453 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 14); |
| 454 | |
| 455 | cricket::VideoCodec codec; |
| 456 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 457 | EXPECT_EQ("10", codec.params[cricket::kCodecParamMinBitrate]); |
| 458 | EXPECT_EQ("20", codec.params[cricket::kCodecParamMaxBitrate]); |
| 459 | EXPECT_EQ("14", codec.params[cricket::kCodecParamStartBitrate]); |
| 460 | } |
| 461 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 462 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMinMaxBitrateInvalid) { |
| 463 | EXPECT_TRUE(SetupEngine()); |
| 464 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 465 | codecs[0].params[cricket::kCodecParamMinBitrate] = "30"; |
| 466 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 467 | EXPECT_FALSE(channel_->SetSendCodecs(codecs)); |
| 468 | } |
| 469 | |
| 470 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithLargeMinMaxBitrate) { |
| 471 | EXPECT_TRUE(SetupEngine()); |
| 472 | int channel_num = vie_.GetLastChannel(); |
| 473 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 474 | codecs[0].params[cricket::kCodecParamMinBitrate] = "1000"; |
| 475 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "2000"; |
| 476 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 477 | |
| 478 | VerifyVP8SendCodec( |
| 479 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 2000, 1000, |
| 480 | 1000); |
| 481 | } |
| 482 | |
| 483 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsWithMaxQuantization) { |
| 484 | EXPECT_TRUE(SetupEngine()); |
| 485 | int channel_num = vie_.GetLastChannel(); |
| 486 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 487 | codecs[0].params[cricket::kCodecParamMaxQuantization] = "21"; |
| 488 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 489 | |
| 490 | VerifyVP8SendCodec( |
| 491 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 2000, 50, 300, |
| 492 | 30, 21); |
| 493 | |
| 494 | cricket::VideoCodec codec; |
| 495 | EXPECT_TRUE(channel_->GetSendCodec(&codec)); |
| 496 | EXPECT_EQ("21", codec.params[cricket::kCodecParamMaxQuantization]); |
| 497 | } |
| 498 | |
| 499 | TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithMaxBitrate) { |
| 500 | EXPECT_TRUE(SetupEngine()); |
| 501 | int channel_num = vie_.GetLastChannel(); |
| 502 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 503 | codecs[0].params[cricket::kCodecParamMinBitrate] = "10"; |
| 504 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 505 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 506 | |
| 507 | VerifyVP8SendCodec( |
| 508 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 509 | |
| 510 | // Verify that max bitrate doesn't change after SetOptions(). |
| 511 | cricket::VideoOptions options; |
| 512 | options.video_noise_reduction.Set(true); |
| 513 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 514 | VerifyVP8SendCodec( |
| 515 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 516 | |
| 517 | options.video_noise_reduction.Set(false); |
| 518 | options.conference_mode.Set(false); |
| 519 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 520 | VerifyVP8SendCodec( |
| 521 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 522 | } |
| 523 | |
wu@webrtc.org | cecfd18 | 2013-10-30 05:18:12 +0000 | [diff] [blame] | 524 | TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithLoweredBitrate) { |
| 525 | EXPECT_TRUE(SetupEngine()); |
| 526 | int channel_num = vie_.GetLastChannel(); |
| 527 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 528 | codecs[0].params[cricket::kCodecParamMinBitrate] = "50"; |
| 529 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "100"; |
| 530 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 531 | |
| 532 | VerifyVP8SendCodec( |
| 533 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 100, 50, 100); |
| 534 | |
| 535 | // Verify that min bitrate changes after SetOptions(). |
| 536 | cricket::VideoOptions options; |
| 537 | options.lower_min_bitrate.Set(true); |
| 538 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 539 | VerifyVP8SendCodec( |
| 540 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 100, 30, 100); |
| 541 | } |
| 542 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 543 | TEST_F(WebRtcVideoEngineTestFake, MaxBitrateResetWithConferenceMode) { |
| 544 | EXPECT_TRUE(SetupEngine()); |
| 545 | int channel_num = vie_.GetLastChannel(); |
| 546 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 547 | codecs[0].params[cricket::kCodecParamMinBitrate] = "10"; |
| 548 | codecs[0].params[cricket::kCodecParamMaxBitrate] = "20"; |
| 549 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 550 | |
| 551 | VerifyVP8SendCodec( |
| 552 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, 20, 10, 20); |
| 553 | |
| 554 | cricket::VideoOptions options; |
| 555 | options.conference_mode.Set(true); |
| 556 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 557 | options.conference_mode.Set(false); |
| 558 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 559 | VerifyVP8SendCodec( |
| 560 | channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
buildbot@webrtc.org | d1ae89f | 2014-05-08 19:19:26 +0000 | [diff] [blame] | 561 | kMaxBandwidthKbps, 10, kStartBandwidthKbps); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | // Verify the current send bitrate is used as start bitrate when reconfiguring |
| 565 | // the send codec. |
| 566 | TEST_F(WebRtcVideoEngineTestFake, StartSendBitrate) { |
| 567 | EXPECT_TRUE(SetupEngine()); |
| 568 | EXPECT_TRUE(channel_->AddSendStream( |
| 569 | cricket::StreamParams::CreateLegacy(1))); |
| 570 | int send_channel = vie_.GetLastChannel(); |
| 571 | cricket::VideoCodec codec(kVP8Codec); |
| 572 | std::vector<cricket::VideoCodec> codec_list; |
| 573 | codec_list.push_back(codec); |
| 574 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 575 | const unsigned int kVideoMaxSendBitrateKbps = 2000; |
| 576 | const unsigned int kVideoMinSendBitrateKbps = 50; |
| 577 | const unsigned int kVideoDefaultStartSendBitrateKbps = 300; |
| 578 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 579 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 580 | kVideoDefaultStartSendBitrateKbps); |
| 581 | EXPECT_EQ(0, vie_.StartSend(send_channel)); |
| 582 | |
| 583 | // Increase the send bitrate and verify it is used as start bitrate. |
| 584 | const unsigned int kVideoSendBitrateBps = 768000; |
| 585 | vie_.SetSendBitrates(send_channel, kVideoSendBitrateBps, 0, 0); |
| 586 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 587 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 588 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 589 | kVideoSendBitrateBps / 1000); |
| 590 | |
| 591 | // Never set a start bitrate higher than the max bitrate. |
| 592 | vie_.SetSendBitrates(send_channel, kVideoMaxSendBitrateKbps + 500, 0, 0); |
| 593 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 594 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 595 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 596 | kVideoDefaultStartSendBitrateKbps); |
| 597 | |
| 598 | // Use the default start bitrate if the send bitrate is lower. |
| 599 | vie_.SetSendBitrates(send_channel, kVideoDefaultStartSendBitrateKbps - 50, 0, |
| 600 | 0); |
| 601 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 602 | VerifyVP8SendCodec(send_channel, kVP8Codec.width, kVP8Codec.height, 0, |
| 603 | kVideoMaxSendBitrateKbps, kVideoMinSendBitrateKbps, |
| 604 | kVideoDefaultStartSendBitrateKbps); |
| 605 | } |
| 606 | |
| 607 | |
| 608 | // Test that we constrain send codecs properly. |
| 609 | TEST_F(WebRtcVideoEngineTestFake, ConstrainSendCodecs) { |
| 610 | EXPECT_TRUE(SetupEngine()); |
| 611 | int channel_num = vie_.GetLastChannel(); |
| 612 | |
| 613 | // Set max settings of 640x400x30. |
| 614 | EXPECT_TRUE(engine_.SetDefaultEncoderConfig( |
| 615 | cricket::VideoEncoderConfig(kVP8Codec))); |
| 616 | |
| 617 | // Send codec format bigger than max setting. |
| 618 | cricket::VideoCodec codec(kVP8Codec); |
| 619 | codec.width = 1280; |
| 620 | codec.height = 800; |
| 621 | codec.framerate = 60; |
| 622 | std::vector<cricket::VideoCodec> codec_list; |
| 623 | codec_list.push_back(codec); |
| 624 | |
| 625 | // Set send codec and verify codec has been constrained. |
| 626 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 627 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 628 | } |
| 629 | |
| 630 | // Test that SetSendCodecs rejects bad format. |
| 631 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsRejectBadFormat) { |
| 632 | EXPECT_TRUE(SetupEngine()); |
| 633 | int channel_num = vie_.GetLastChannel(); |
| 634 | |
| 635 | // Set w = 0. |
| 636 | cricket::VideoCodec codec(kVP8Codec); |
| 637 | codec.width = 0; |
| 638 | std::vector<cricket::VideoCodec> codec_list; |
| 639 | codec_list.push_back(codec); |
| 640 | |
| 641 | // Verify SetSendCodecs failed and send codec is not changed on engine. |
| 642 | EXPECT_FALSE(channel_->SetSendCodecs(codec_list)); |
| 643 | webrtc::VideoCodec gcodec; |
| 644 | // Set plType to something other than the value to test against ensuring |
| 645 | // that failure will happen if it is not changed. |
| 646 | gcodec.plType = 1; |
| 647 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 648 | EXPECT_EQ(0, gcodec.plType); |
| 649 | |
| 650 | // Set h = 0. |
| 651 | codec_list[0].width = 640; |
| 652 | codec_list[0].height = 0; |
| 653 | |
| 654 | // Verify SetSendCodecs failed and send codec is not changed on engine. |
| 655 | EXPECT_FALSE(channel_->SetSendCodecs(codec_list)); |
| 656 | // Set plType to something other than the value to test against ensuring |
| 657 | // that failure will happen if it is not changed. |
| 658 | gcodec.plType = 1; |
| 659 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 660 | EXPECT_EQ(0, gcodec.plType); |
| 661 | } |
| 662 | |
| 663 | // Test that SetSendCodecs rejects bad codec. |
| 664 | TEST_F(WebRtcVideoEngineTestFake, SetSendCodecsRejectBadCodec) { |
| 665 | EXPECT_TRUE(SetupEngine()); |
| 666 | int channel_num = vie_.GetLastChannel(); |
| 667 | |
| 668 | // Set bad codec name. |
| 669 | cricket::VideoCodec codec(kVP8Codec); |
| 670 | codec.name = "bad"; |
| 671 | std::vector<cricket::VideoCodec> codec_list; |
| 672 | codec_list.push_back(codec); |
| 673 | |
| 674 | // Verify SetSendCodecs failed and send codec is not changed on engine. |
| 675 | EXPECT_FALSE(channel_->SetSendCodecs(codec_list)); |
| 676 | webrtc::VideoCodec gcodec; |
| 677 | // Set plType to something other than the value to test against ensuring |
| 678 | // that failure will happen if it is not changed. |
| 679 | gcodec.plType = 1; |
| 680 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 681 | EXPECT_EQ(0, gcodec.plType); |
| 682 | } |
| 683 | |
| 684 | // Test that vie send codec is reset on new video frame size. |
| 685 | TEST_F(WebRtcVideoEngineTestFake, ResetVieSendCodecOnNewFrameSize) { |
| 686 | EXPECT_TRUE(SetupEngine()); |
| 687 | int channel_num = vie_.GetLastChannel(); |
| 688 | |
| 689 | // Set send codec. |
| 690 | std::vector<cricket::VideoCodec> codec_list; |
| 691 | codec_list.push_back(kVP8Codec); |
| 692 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 693 | EXPECT_TRUE(channel_->AddSendStream( |
| 694 | cricket::StreamParams::CreateLegacy(123))); |
| 695 | EXPECT_TRUE(channel_->SetSend(true)); |
| 696 | |
| 697 | // Capture a smaller frame and verify vie send codec has been reset to |
| 698 | // the new size. |
| 699 | SendI420Frame(kVP8Codec.width / 2, kVP8Codec.height / 2); |
| 700 | VerifyVP8SendCodec(channel_num, kVP8Codec.width / 2, kVP8Codec.height / 2); |
| 701 | |
| 702 | // Capture a frame bigger than send_codec_ and verify vie send codec has been |
| 703 | // reset (and clipped) to send_codec_. |
| 704 | SendI420Frame(kVP8Codec.width * 2, kVP8Codec.height * 2); |
| 705 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 706 | } |
| 707 | |
| 708 | // Test that we set our inbound codecs properly. |
| 709 | TEST_F(WebRtcVideoEngineTestFake, SetRecvCodecs) { |
| 710 | EXPECT_TRUE(SetupEngine()); |
| 711 | int channel_num = vie_.GetLastChannel(); |
| 712 | |
| 713 | std::vector<cricket::VideoCodec> codecs; |
| 714 | codecs.push_back(kVP8Codec); |
| 715 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 716 | |
| 717 | webrtc::VideoCodec wcodec; |
| 718 | EXPECT_TRUE(engine_.ConvertFromCricketVideoCodec(kVP8Codec, &wcodec)); |
| 719 | EXPECT_TRUE(vie_.ReceiveCodecRegistered(channel_num, wcodec)); |
| 720 | } |
| 721 | |
buildbot@webrtc.org | dd4742a | 2014-05-07 14:50:35 +0000 | [diff] [blame] | 722 | // Test that we set our inbound RTX codecs properly. |
| 723 | TEST_F(WebRtcVideoEngineTestFake, SetRecvCodecsWithRtx) { |
| 724 | EXPECT_TRUE(SetupEngine()); |
| 725 | int channel_num = vie_.GetLastChannel(); |
| 726 | |
| 727 | std::vector<cricket::VideoCodec> codecs; |
| 728 | cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
| 729 | codecs.push_back(rtx_codec); |
| 730 | // Should fail since there's no associated payload type set. |
| 731 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 732 | |
| 733 | codecs[0].SetParam("apt", 97); |
| 734 | // Should still fail since the we don't support RTX on this APT. |
| 735 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 736 | |
| 737 | codecs[0].SetParam("apt", kVP8Codec.id); |
| 738 | // Should still fail since the associated payload type is unknown. |
| 739 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 740 | |
| 741 | codecs.push_back(kVP8Codec); |
| 742 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 743 | |
| 744 | webrtc::VideoCodec wcodec; |
| 745 | // Should not have been registered as a WebRTC codec. |
| 746 | EXPECT_TRUE(engine_.ConvertFromCricketVideoCodec(rtx_codec, &wcodec)); |
| 747 | EXPECT_STREQ("rtx", wcodec.plName); |
| 748 | EXPECT_FALSE(vie_.ReceiveCodecRegistered(channel_num, wcodec)); |
| 749 | |
| 750 | // The RTX payload type should have been set. |
| 751 | EXPECT_EQ(rtx_codec.id, vie_.GetRtxRecvPayloadType(channel_num)); |
| 752 | } |
| 753 | |
| 754 | // Test that RTX packets are routed to the correct video channel. |
| 755 | TEST_F(WebRtcVideoEngineTestFake, TestReceiveRtx) { |
| 756 | EXPECT_TRUE(SetupEngine()); |
| 757 | |
| 758 | // Setup three channels with associated RTX streams. |
| 759 | int channel_num[ARRAY_SIZE(kSsrcs3)]; |
| 760 | for (size_t i = 0; i < ARRAY_SIZE(kSsrcs3); ++i) { |
| 761 | cricket::StreamParams params = |
| 762 | cricket::StreamParams::CreateLegacy(kSsrcs3[i]); |
| 763 | params.AddFidSsrc(kSsrcs3[i], kRtxSsrcs3[i]); |
| 764 | EXPECT_TRUE(channel_->AddRecvStream(params)); |
| 765 | channel_num[i] = vie_.GetLastChannel(); |
| 766 | } |
| 767 | |
| 768 | // Register codecs. |
| 769 | std::vector<cricket::VideoCodec> codec_list; |
| 770 | codec_list.push_back(kVP8Codec720p); |
| 771 | cricket::VideoCodec rtx_codec(96, "rtx", 0, 0, 0, 0); |
| 772 | rtx_codec.SetParam("apt", kVP8Codec.id); |
| 773 | codec_list.push_back(rtx_codec); |
| 774 | EXPECT_TRUE(channel_->SetRecvCodecs(codec_list)); |
| 775 | |
| 776 | // Construct a fake RTX packet and verify that it is passed to the |
| 777 | // right WebRTC channel. |
| 778 | const size_t kDataLength = 12; |
| 779 | uint8_t data[kDataLength]; |
| 780 | memset(data, 0, sizeof(data)); |
| 781 | data[0] = 0x80; |
| 782 | data[1] = rtx_codec.id; |
| 783 | talk_base::SetBE32(&data[8], kRtxSsrcs3[1]); |
| 784 | talk_base::Buffer packet(data, kDataLength); |
| 785 | talk_base::PacketTime packet_time; |
| 786 | channel_->OnPacketReceived(&packet, packet_time); |
| 787 | EXPECT_NE(rtx_codec.id, vie_.GetLastRecvdPayloadType(channel_num[0])); |
| 788 | EXPECT_EQ(rtx_codec.id, vie_.GetLastRecvdPayloadType(channel_num[1])); |
| 789 | EXPECT_NE(rtx_codec.id, vie_.GetLastRecvdPayloadType(channel_num[2])); |
| 790 | } |
| 791 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 792 | // Test that channel connects and disconnects external capturer correctly. |
| 793 | TEST_F(WebRtcVideoEngineTestFake, HasExternalCapturer) { |
| 794 | EXPECT_TRUE(SetupEngine()); |
| 795 | int channel_num = vie_.GetLastChannel(); |
| 796 | |
| 797 | EXPECT_EQ(1, vie_.GetNumCapturers()); |
| 798 | int capture_id = vie_.GetCaptureId(channel_num); |
| 799 | EXPECT_EQ(channel_num, vie_.GetCaptureChannelId(capture_id)); |
| 800 | |
| 801 | // Delete the channel should disconnect the capturer. |
| 802 | delete channel_; |
| 803 | channel_ = NULL; |
| 804 | EXPECT_EQ(0, vie_.GetNumCapturers()); |
| 805 | } |
| 806 | |
| 807 | // Test that channel adds and removes renderer correctly. |
| 808 | TEST_F(WebRtcVideoEngineTestFake, HasRenderer) { |
| 809 | EXPECT_TRUE(SetupEngine()); |
| 810 | int channel_num = vie_.GetLastChannel(); |
| 811 | |
| 812 | EXPECT_TRUE(vie_.GetHasRenderer(channel_num)); |
| 813 | EXPECT_FALSE(vie_.GetRenderStarted(channel_num)); |
| 814 | } |
| 815 | |
| 816 | // Test that rtcp is enabled on the channel. |
| 817 | TEST_F(WebRtcVideoEngineTestFake, RtcpEnabled) { |
| 818 | EXPECT_TRUE(SetupEngine()); |
| 819 | int channel_num = vie_.GetLastChannel(); |
| 820 | EXPECT_EQ(webrtc::kRtcpCompound_RFC4585, vie_.GetRtcpStatus(channel_num)); |
| 821 | } |
| 822 | |
| 823 | // Test that key frame request method is set on the channel. |
| 824 | TEST_F(WebRtcVideoEngineTestFake, KeyFrameRequestEnabled) { |
| 825 | EXPECT_TRUE(SetupEngine()); |
| 826 | int channel_num = vie_.GetLastChannel(); |
| 827 | EXPECT_EQ(webrtc::kViEKeyFrameRequestPliRtcp, |
| 828 | vie_.GetKeyFrameRequestMethod(channel_num)); |
| 829 | } |
| 830 | |
| 831 | // Test that remb receive and send is enabled for the default channel in a 1:1 |
| 832 | // call. |
| 833 | TEST_F(WebRtcVideoEngineTestFake, RembEnabled) { |
| 834 | EXPECT_TRUE(SetupEngine()); |
| 835 | int channel_num = vie_.GetLastChannel(); |
| 836 | EXPECT_TRUE(channel_->AddSendStream( |
| 837 | cricket::StreamParams::CreateLegacy(1))); |
| 838 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 839 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 840 | EXPECT_TRUE(channel_->SetSend(true)); |
| 841 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 842 | EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num)); |
| 843 | } |
| 844 | |
| 845 | // When in conference mode, test that remb is enabled on a receive channel but |
| 846 | // not for the default channel and that it uses the default channel for sending |
| 847 | // remb packets. |
| 848 | TEST_F(WebRtcVideoEngineTestFake, RembEnabledOnReceiveChannels) { |
| 849 | EXPECT_TRUE(SetupEngine()); |
| 850 | int default_channel = vie_.GetLastChannel(); |
| 851 | cricket::VideoOptions options; |
| 852 | options.conference_mode.Set(true); |
| 853 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 854 | EXPECT_TRUE(channel_->AddSendStream( |
| 855 | cricket::StreamParams::CreateLegacy(1))); |
| 856 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 857 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel)); |
| 858 | EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel)); |
| 859 | EXPECT_TRUE(channel_->SetSend(true)); |
| 860 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 861 | int new_channel_num = vie_.GetLastChannel(); |
| 862 | EXPECT_NE(default_channel, new_channel_num); |
| 863 | |
| 864 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(default_channel)); |
| 865 | EXPECT_TRUE(vie_.GetRembStatusContribute(default_channel)); |
| 866 | EXPECT_FALSE(vie_.GetRembStatusBwPartition(new_channel_num)); |
| 867 | EXPECT_TRUE(vie_.GetRembStatusContribute(new_channel_num)); |
| 868 | } |
| 869 | |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 870 | TEST_F(WebRtcVideoEngineTestFake, RecvStreamWithRtx) { |
| 871 | EXPECT_TRUE(SetupEngine()); |
| 872 | int default_channel = vie_.GetLastChannel(); |
| 873 | cricket::VideoOptions options; |
| 874 | options.conference_mode.Set(true); |
| 875 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 876 | EXPECT_TRUE(channel_->AddSendStream( |
| 877 | cricket::CreateSimWithRtxStreamParams("cname", |
| 878 | MAKE_VECTOR(kSsrcs3), |
| 879 | MAKE_VECTOR(kRtxSsrcs3)))); |
| 880 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 881 | EXPECT_TRUE(channel_->SetSend(true)); |
| 882 | EXPECT_TRUE(channel_->AddRecvStream( |
| 883 | cricket::CreateSimWithRtxStreamParams("cname", |
| 884 | MAKE_VECTOR(kSsrcs1), |
| 885 | MAKE_VECTOR(kRtxSsrc1)))); |
| 886 | int new_channel_num = vie_.GetLastChannel(); |
| 887 | EXPECT_NE(default_channel, new_channel_num); |
| 888 | EXPECT_EQ(4, vie_.GetRemoteRtxSsrc(new_channel_num)); |
| 889 | } |
| 890 | |
| 891 | TEST_F(WebRtcVideoEngineTestFake, RecvStreamNoRtx) { |
| 892 | EXPECT_TRUE(SetupEngine()); |
| 893 | int default_channel = vie_.GetLastChannel(); |
| 894 | cricket::VideoOptions options; |
| 895 | options.conference_mode.Set(true); |
| 896 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 897 | EXPECT_TRUE(channel_->AddSendStream( |
| 898 | cricket::CreateSimWithRtxStreamParams("cname", |
| 899 | MAKE_VECTOR(kSsrcs3), |
| 900 | MAKE_VECTOR(kRtxSsrcs3)))); |
| 901 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 902 | EXPECT_TRUE(channel_->SetSend(true)); |
| 903 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 904 | int new_channel_num = vie_.GetLastChannel(); |
| 905 | EXPECT_NE(default_channel, new_channel_num); |
| 906 | EXPECT_EQ(-1, vie_.GetRemoteRtxSsrc(new_channel_num)); |
| 907 | } |
| 908 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 909 | // Test support for RTP timestamp offset header extension. |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 910 | TEST_F(WebRtcVideoEngineTestFake, SendRtpTimestampOffsetHeaderExtensions) { |
| 911 | TestSetSendRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension); |
| 912 | } |
| 913 | TEST_F(WebRtcVideoEngineTestFake, RecvRtpTimestampOffsetHeaderExtensions) { |
| 914 | TestSetRecvRtpHeaderExtensions(kRtpTimestampOffsetHeaderExtension); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 915 | } |
| 916 | |
| 917 | // Test support for absolute send time header extension. |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 918 | TEST_F(WebRtcVideoEngineTestFake, SendAbsoluteSendTimeHeaderExtensions) { |
| 919 | TestSetSendRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
| 920 | } |
| 921 | TEST_F(WebRtcVideoEngineTestFake, RecvAbsoluteSendTimeHeaderExtensions) { |
| 922 | TestSetRecvRtpHeaderExtensions(kRtpAbsoluteSenderTimeHeaderExtension); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | TEST_F(WebRtcVideoEngineTestFake, LeakyBucketTest) { |
| 926 | EXPECT_TRUE(SetupEngine()); |
| 927 | |
| 928 | // Verify this is off by default. |
| 929 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 930 | int first_send_channel = vie_.GetLastChannel(); |
| 931 | EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 932 | |
| 933 | // Enable the experiment and verify. |
| 934 | cricket::VideoOptions options; |
| 935 | options.conference_mode.Set(true); |
| 936 | options.video_leaky_bucket.Set(true); |
| 937 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 938 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 939 | |
| 940 | // Add a receive channel and verify leaky bucket isn't enabled. |
| 941 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 942 | int recv_channel_num = vie_.GetLastChannel(); |
| 943 | EXPECT_NE(first_send_channel, recv_channel_num); |
| 944 | EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(recv_channel_num)); |
| 945 | |
| 946 | // Add a new send stream and verify leaky bucket is enabled from start. |
| 947 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 948 | int second_send_channel = vie_.GetLastChannel(); |
| 949 | EXPECT_NE(first_send_channel, second_send_channel); |
| 950 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(second_send_channel)); |
| 951 | } |
| 952 | |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 953 | // Verify that SuspendBelowMinBitrate is enabled if it is set in the options. |
| 954 | TEST_F(WebRtcVideoEngineTestFake, SuspendBelowMinBitrateTest) { |
| 955 | EXPECT_TRUE(SetupEngine()); |
| 956 | |
| 957 | // Verify this is off by default. |
| 958 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 959 | int first_send_channel = vie_.GetLastChannel(); |
| 960 | EXPECT_FALSE(vie_.GetSuspendBelowMinBitrateStatus(first_send_channel)); |
| 961 | |
| 962 | // Enable the experiment and verify. |
| 963 | cricket::VideoOptions options; |
| 964 | options.suspend_below_min_bitrate.Set(true); |
| 965 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 966 | EXPECT_TRUE(vie_.GetSuspendBelowMinBitrateStatus(first_send_channel)); |
| 967 | |
| 968 | // Add a new send stream and verify suspend_below_min_bitrate is enabled. |
| 969 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
| 970 | int second_send_channel = vie_.GetLastChannel(); |
| 971 | EXPECT_NE(first_send_channel, second_send_channel); |
| 972 | EXPECT_TRUE(vie_.GetSuspendBelowMinBitrateStatus(second_send_channel)); |
| 973 | } |
| 974 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 975 | TEST_F(WebRtcVideoEngineTestFake, BufferedModeLatency) { |
| 976 | EXPECT_TRUE(SetupEngine()); |
| 977 | |
| 978 | // Verify this is off by default. |
| 979 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 980 | int first_send_channel = vie_.GetLastChannel(); |
| 981 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel)); |
| 982 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 983 | |
| 984 | // Enable the experiment and verify. The default channel will have both |
| 985 | // sender and receiver buffered mode enabled. |
| 986 | cricket::VideoOptions options; |
| 987 | options.conference_mode.Set(true); |
| 988 | options.buffered_mode_latency.Set(100); |
| 989 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 990 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel)); |
| 991 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 992 | |
| 993 | // Add a receive channel and verify sender buffered mode isn't enabled. |
| 994 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 995 | int recv_channel_num = vie_.GetLastChannel(); |
| 996 | EXPECT_NE(first_send_channel, recv_channel_num); |
| 997 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num)); |
| 998 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(recv_channel_num)); |
| 999 | |
| 1000 | // Add a new send stream and verify sender buffered mode is enabled. |
| 1001 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 1002 | int second_send_channel = vie_.GetLastChannel(); |
| 1003 | EXPECT_NE(first_send_channel, second_send_channel); |
| 1004 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(second_send_channel)); |
| 1005 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel)); |
| 1006 | |
| 1007 | // Disable sender buffered mode and verify. |
| 1008 | options.buffered_mode_latency.Set(cricket::kBufferedModeDisabled); |
| 1009 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1010 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel)); |
| 1011 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 1012 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(second_send_channel)); |
| 1013 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(second_send_channel)); |
| 1014 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(recv_channel_num)); |
| 1015 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(recv_channel_num)); |
| 1016 | } |
| 1017 | |
| 1018 | TEST_F(WebRtcVideoEngineTestFake, AdditiveVideoOptions) { |
| 1019 | EXPECT_TRUE(SetupEngine()); |
| 1020 | |
| 1021 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 1022 | int first_send_channel = vie_.GetLastChannel(); |
| 1023 | EXPECT_EQ(0, vie_.GetSenderTargetDelay(first_send_channel)); |
| 1024 | EXPECT_EQ(0, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 1025 | |
| 1026 | cricket::VideoOptions options1; |
| 1027 | options1.buffered_mode_latency.Set(100); |
| 1028 | EXPECT_TRUE(channel_->SetOptions(options1)); |
| 1029 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel)); |
| 1030 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 1031 | EXPECT_FALSE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 1032 | |
| 1033 | cricket::VideoOptions options2; |
| 1034 | options2.video_leaky_bucket.Set(true); |
| 1035 | EXPECT_TRUE(channel_->SetOptions(options2)); |
| 1036 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 1037 | // The buffered_mode_latency still takes effect. |
| 1038 | EXPECT_EQ(100, vie_.GetSenderTargetDelay(first_send_channel)); |
| 1039 | EXPECT_EQ(100, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 1040 | |
| 1041 | options1.buffered_mode_latency.Set(50); |
| 1042 | EXPECT_TRUE(channel_->SetOptions(options1)); |
| 1043 | EXPECT_EQ(50, vie_.GetSenderTargetDelay(first_send_channel)); |
| 1044 | EXPECT_EQ(50, vie_.GetReceiverTargetDelay(first_send_channel)); |
| 1045 | // The video_leaky_bucket still takes effect. |
| 1046 | EXPECT_TRUE(vie_.GetTransmissionSmoothingStatus(first_send_channel)); |
| 1047 | } |
| 1048 | |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 1049 | TEST_F(WebRtcVideoEngineTestFake, SetCpuOveruseOptionsWithCaptureJitterMethod) { |
| 1050 | EXPECT_TRUE(SetupEngine()); |
| 1051 | |
| 1052 | // Verify this is off by default. |
| 1053 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 1054 | int first_send_channel = vie_.GetLastChannel(); |
| 1055 | webrtc::CpuOveruseOptions cpu_option = |
| 1056 | vie_.GetCpuOveruseOptions(first_send_channel); |
| 1057 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 1058 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 1059 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1060 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1061 | |
| 1062 | // Set low and high threshold and verify that cpu options are set. |
| 1063 | cricket::VideoOptions options; |
| 1064 | options.conference_mode.Set(true); |
| 1065 | options.cpu_underuse_threshold.Set(10); |
| 1066 | options.cpu_overuse_threshold.Set(20); |
| 1067 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1068 | cpu_option = vie_.GetCpuOveruseOptions(first_send_channel); |
| 1069 | EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms); |
| 1070 | EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms); |
| 1071 | EXPECT_TRUE(cpu_option.enable_capture_jitter_method); |
| 1072 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1073 | |
| 1074 | // Add a receive channel and verify that cpu options are not set. |
| 1075 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 1076 | int recv_channel_num = vie_.GetLastChannel(); |
| 1077 | EXPECT_NE(first_send_channel, recv_channel_num); |
| 1078 | cpu_option = vie_.GetCpuOveruseOptions(recv_channel_num); |
| 1079 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 1080 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 1081 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1082 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1083 | |
| 1084 | // Add a new send stream and verify that cpu options are set from start. |
| 1085 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 1086 | int second_send_channel = vie_.GetLastChannel(); |
| 1087 | EXPECT_NE(first_send_channel, second_send_channel); |
| 1088 | cpu_option = vie_.GetCpuOveruseOptions(second_send_channel); |
| 1089 | EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms); |
| 1090 | EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms); |
| 1091 | EXPECT_TRUE(cpu_option.enable_capture_jitter_method); |
| 1092 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1093 | } |
| 1094 | |
| 1095 | TEST_F(WebRtcVideoEngineTestFake, SetInvalidCpuOveruseThresholds) { |
| 1096 | EXPECT_TRUE(SetupEngine()); |
| 1097 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 1098 | int channel_num = vie_.GetLastChannel(); |
| 1099 | |
| 1100 | // Only low threshold set. Verify that cpu options are not set. |
| 1101 | cricket::VideoOptions options; |
| 1102 | options.conference_mode.Set(true); |
| 1103 | options.cpu_underuse_threshold.Set(10); |
| 1104 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1105 | webrtc::CpuOveruseOptions cpu_option = vie_.GetCpuOveruseOptions(channel_num); |
| 1106 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 1107 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 1108 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1109 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1110 | |
| 1111 | // Set high threshold to a negative value. Verify that options are not set. |
| 1112 | options.cpu_overuse_threshold.Set(-1); |
| 1113 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1114 | cpu_option = vie_.GetCpuOveruseOptions(channel_num); |
| 1115 | EXPECT_EQ(0, cpu_option.low_capture_jitter_threshold_ms); |
| 1116 | EXPECT_EQ(0, cpu_option.high_capture_jitter_threshold_ms); |
| 1117 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1118 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1119 | |
| 1120 | // Low and high threshold valid. Verify that cpu options are set. |
| 1121 | options.cpu_overuse_threshold.Set(20); |
| 1122 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1123 | cpu_option = vie_.GetCpuOveruseOptions(channel_num); |
| 1124 | EXPECT_EQ(10, cpu_option.low_capture_jitter_threshold_ms); |
| 1125 | EXPECT_EQ(20, cpu_option.high_capture_jitter_threshold_ms); |
| 1126 | EXPECT_TRUE(cpu_option.enable_capture_jitter_method); |
| 1127 | EXPECT_FALSE(cpu_option.enable_encode_usage_method); |
| 1128 | } |
| 1129 | |
| 1130 | TEST_F(WebRtcVideoEngineTestFake, SetCpuOveruseOptionsWithEncodeUsageMethod) { |
| 1131 | EXPECT_TRUE(SetupEngine()); |
| 1132 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 1133 | int first_send_channel = vie_.GetLastChannel(); |
| 1134 | |
| 1135 | // Set low and high threshold and enable encode usage method. |
| 1136 | // Verify that cpu options are set. |
| 1137 | cricket::VideoOptions options; |
| 1138 | options.conference_mode.Set(true); |
| 1139 | options.cpu_underuse_threshold.Set(10); |
| 1140 | options.cpu_overuse_threshold.Set(20); |
| 1141 | options.cpu_overuse_encode_usage.Set(true); |
| 1142 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1143 | webrtc::CpuOveruseOptions cpu_option = |
| 1144 | vie_.GetCpuOveruseOptions(first_send_channel); |
| 1145 | EXPECT_EQ(10, cpu_option.low_encode_usage_threshold_percent); |
| 1146 | EXPECT_EQ(20, cpu_option.high_encode_usage_threshold_percent); |
| 1147 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1148 | EXPECT_TRUE(cpu_option.enable_encode_usage_method); |
| 1149 | |
| 1150 | // Add a new send stream and verify that cpu options are set from start. |
| 1151 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 1152 | int second_send_channel = vie_.GetLastChannel(); |
| 1153 | EXPECT_NE(first_send_channel, second_send_channel); |
| 1154 | cpu_option = vie_.GetCpuOveruseOptions(second_send_channel); |
| 1155 | EXPECT_EQ(10, cpu_option.low_encode_usage_threshold_percent); |
| 1156 | EXPECT_EQ(20, cpu_option.high_encode_usage_threshold_percent); |
| 1157 | EXPECT_FALSE(cpu_option.enable_capture_jitter_method); |
| 1158 | EXPECT_TRUE(cpu_option.enable_encode_usage_method); |
| 1159 | } |
henrike@webrtc.org | b0ecc1c | 2014-03-26 22:44:28 +0000 | [diff] [blame] | 1160 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1161 | // Test that AddRecvStream doesn't create new channel for 1:1 call. |
| 1162 | TEST_F(WebRtcVideoEngineTestFake, AddRecvStream1On1) { |
| 1163 | EXPECT_TRUE(SetupEngine()); |
| 1164 | int channel_num = vie_.GetLastChannel(); |
| 1165 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1166 | EXPECT_EQ(channel_num, vie_.GetLastChannel()); |
| 1167 | } |
| 1168 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1169 | // Test that NACK, PLI and REMB are enabled for internal codec. |
| 1170 | TEST_F(WebRtcVideoEngineTestFake, InternalCodecFeedbackParams) { |
| 1171 | EXPECT_TRUE(SetupEngine()); |
| 1172 | |
| 1173 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1174 | // Vp8 will appear at the beginning. |
| 1175 | size_t pos = 0; |
| 1176 | EXPECT_EQ("VP8", codecs[pos].name); |
| 1177 | VerifyCodecFeedbackParams(codecs[pos]); |
| 1178 | } |
| 1179 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1180 | // Test that AddRecvStream doesn't change remb for 1:1 call. |
| 1181 | TEST_F(WebRtcVideoEngineTestFake, NoRembChangeAfterAddRecvStream) { |
| 1182 | EXPECT_TRUE(SetupEngine()); |
| 1183 | int channel_num = vie_.GetLastChannel(); |
| 1184 | EXPECT_TRUE(channel_->AddSendStream( |
| 1185 | cricket::StreamParams::CreateLegacy(1))); |
| 1186 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1187 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1188 | EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num)); |
| 1189 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1190 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1191 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1192 | EXPECT_TRUE(vie_.GetRembStatusContribute(channel_num)); |
| 1193 | } |
| 1194 | |
| 1195 | // Verify default REMB setting and that it can be turned on and off. |
| 1196 | TEST_F(WebRtcVideoEngineTestFake, RembOnOff) { |
| 1197 | EXPECT_TRUE(SetupEngine()); |
| 1198 | int channel_num = vie_.GetLastChannel(); |
| 1199 | // Verify REMB sending is always off by default. |
| 1200 | EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1201 | |
| 1202 | // Verify that REMB is turned on when setting default codecs since the |
| 1203 | // default codecs have REMB enabled. |
| 1204 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1205 | EXPECT_TRUE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1206 | |
| 1207 | // Verify that REMB is turned off when codecs without REMB are set. |
| 1208 | std::vector<cricket::VideoCodec> codecs = engine_.codecs(); |
| 1209 | // Clearing the codecs' FeedbackParams and setting send codecs should disable |
| 1210 | // REMB. |
| 1211 | for (std::vector<cricket::VideoCodec>::iterator iter = codecs.begin(); |
| 1212 | iter != codecs.end(); ++iter) { |
| 1213 | // Intersecting with empty will clear the FeedbackParams. |
| 1214 | cricket::FeedbackParams empty_params; |
| 1215 | iter->feedback_params.Intersect(empty_params); |
| 1216 | EXPECT_TRUE(iter->feedback_params.params().empty()); |
| 1217 | } |
| 1218 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1219 | EXPECT_FALSE(vie_.GetRembStatusBwPartition(channel_num)); |
| 1220 | } |
| 1221 | |
| 1222 | // Test that nack is enabled on the channel if we don't offer red/fec. |
| 1223 | TEST_F(WebRtcVideoEngineTestFake, NackEnabled) { |
| 1224 | EXPECT_TRUE(SetupEngine()); |
| 1225 | int channel_num = vie_.GetLastChannel(); |
| 1226 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1227 | codecs.resize(1); // toss out red and ulpfec |
| 1228 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1229 | EXPECT_TRUE(vie_.GetNackStatus(channel_num)); |
| 1230 | } |
| 1231 | |
| 1232 | // Test that we enable hybrid NACK FEC mode. |
| 1233 | TEST_F(WebRtcVideoEngineTestFake, HybridNackFec) { |
| 1234 | EXPECT_TRUE(SetupEngine()); |
| 1235 | int channel_num = vie_.GetLastChannel(); |
| 1236 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
| 1237 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1238 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1239 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
| 1240 | } |
| 1241 | |
| 1242 | // Test that we enable hybrid NACK FEC mode when calling SetSendCodecs and |
| 1243 | // SetReceiveCodecs in reversed order. |
| 1244 | TEST_F(WebRtcVideoEngineTestFake, HybridNackFecReversedOrder) { |
| 1245 | EXPECT_TRUE(SetupEngine()); |
| 1246 | int channel_num = vie_.GetLastChannel(); |
| 1247 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1248 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
| 1249 | EXPECT_TRUE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1250 | EXPECT_FALSE(vie_.GetNackStatus(channel_num)); |
| 1251 | } |
| 1252 | |
| 1253 | // Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if |
| 1254 | // red/fec is offered as receive codec. |
| 1255 | TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInterop) { |
| 1256 | EXPECT_TRUE(SetupEngine()); |
| 1257 | int channel_num = vie_.GetLastChannel(); |
| 1258 | std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs()); |
| 1259 | std::vector<cricket::VideoCodec> send_codecs(engine_.codecs()); |
| 1260 | // Only add VP8 as send codec. |
| 1261 | send_codecs.resize(1); |
| 1262 | EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs)); |
| 1263 | EXPECT_TRUE(channel_->SetSendCodecs(send_codecs)); |
| 1264 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1265 | EXPECT_TRUE(vie_.GetNackStatus(channel_num)); |
| 1266 | } |
| 1267 | |
| 1268 | // Test NACK vs Hybrid NACK/FEC interop call setup, i.e. only use NACK even if |
| 1269 | // red/fec is offered as receive codec. Call order reversed compared to |
| 1270 | // VideoProtectionInterop. |
| 1271 | TEST_F(WebRtcVideoEngineTestFake, VideoProtectionInteropReversed) { |
| 1272 | EXPECT_TRUE(SetupEngine()); |
| 1273 | int channel_num = vie_.GetLastChannel(); |
| 1274 | std::vector<cricket::VideoCodec> recv_codecs(engine_.codecs()); |
| 1275 | std::vector<cricket::VideoCodec> send_codecs(engine_.codecs()); |
| 1276 | // Only add VP8 as send codec. |
| 1277 | send_codecs.resize(1); |
| 1278 | EXPECT_TRUE(channel_->SetSendCodecs(send_codecs)); |
| 1279 | EXPECT_TRUE(channel_->SetRecvCodecs(recv_codecs)); |
| 1280 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(channel_num)); |
| 1281 | EXPECT_TRUE(vie_.GetNackStatus(channel_num)); |
| 1282 | } |
| 1283 | |
| 1284 | // Test that NACK, not hybrid mode, is enabled in conference mode. |
| 1285 | TEST_F(WebRtcVideoEngineTestFake, HybridNackFecConference) { |
| 1286 | EXPECT_TRUE(SetupEngine()); |
| 1287 | // Setup the send channel. |
| 1288 | int send_channel_num = vie_.GetLastChannel(); |
| 1289 | cricket::VideoOptions options; |
| 1290 | options.conference_mode.Set(true); |
| 1291 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1292 | EXPECT_TRUE(channel_->SetRecvCodecs(engine_.codecs())); |
| 1293 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1294 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(send_channel_num)); |
| 1295 | EXPECT_TRUE(vie_.GetNackStatus(send_channel_num)); |
| 1296 | // Add a receive stream. |
| 1297 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1298 | int receive_channel_num = vie_.GetLastChannel(); |
| 1299 | EXPECT_FALSE(vie_.GetHybridNackFecStatus(receive_channel_num)); |
| 1300 | EXPECT_TRUE(vie_.GetNackStatus(receive_channel_num)); |
| 1301 | } |
| 1302 | |
| 1303 | // Test that when AddRecvStream in conference mode, a new channel is created |
| 1304 | // for receiving. And the new channel's "original channel" is the send channel. |
| 1305 | TEST_F(WebRtcVideoEngineTestFake, AddRemoveRecvStreamConference) { |
| 1306 | EXPECT_TRUE(SetupEngine()); |
| 1307 | // Setup the send channel. |
| 1308 | int send_channel_num = vie_.GetLastChannel(); |
| 1309 | cricket::VideoOptions options; |
| 1310 | options.conference_mode.Set(true); |
| 1311 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1312 | // Add a receive stream. |
| 1313 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1314 | int receive_channel_num = vie_.GetLastChannel(); |
| 1315 | EXPECT_EQ(send_channel_num, vie_.GetOriginalChannelId(receive_channel_num)); |
| 1316 | EXPECT_TRUE(channel_->RemoveRecvStream(1)); |
| 1317 | EXPECT_FALSE(vie_.IsChannel(receive_channel_num)); |
| 1318 | } |
| 1319 | |
henrike@webrtc.org | 6e3dbc2 | 2014-03-25 17:09:47 +0000 | [diff] [blame] | 1320 | // Test that adding/removing stream with 0 ssrc should fail (and not crash). |
| 1321 | // For crbug/351699 and 350988. |
| 1322 | TEST_F(WebRtcVideoEngineTestFake, AddRemoveRecvStreamWith0Ssrc) { |
| 1323 | EXPECT_TRUE(SetupEngine()); |
| 1324 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1325 | EXPECT_FALSE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(0))); |
| 1326 | EXPECT_FALSE(channel_->RemoveRecvStream(0)); |
| 1327 | EXPECT_TRUE(channel_->RemoveRecvStream(1)); |
| 1328 | } |
| 1329 | |
| 1330 | TEST_F(WebRtcVideoEngineTestFake, AddRemoveSendStreamWith0Ssrc) { |
| 1331 | EXPECT_TRUE(SetupEngine()); |
| 1332 | EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(1))); |
| 1333 | EXPECT_FALSE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(0))); |
| 1334 | EXPECT_FALSE(channel_->RemoveSendStream(0)); |
| 1335 | EXPECT_TRUE(channel_->RemoveSendStream(1)); |
| 1336 | } |
| 1337 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1338 | // Test that we can create a channel and start/stop rendering out on it. |
| 1339 | TEST_F(WebRtcVideoEngineTestFake, SetRender) { |
| 1340 | EXPECT_TRUE(SetupEngine()); |
| 1341 | int channel_num = vie_.GetLastChannel(); |
| 1342 | |
| 1343 | // Verify we can start/stop/start/stop rendering. |
| 1344 | EXPECT_TRUE(channel_->SetRender(true)); |
| 1345 | EXPECT_TRUE(vie_.GetRenderStarted(channel_num)); |
| 1346 | EXPECT_TRUE(channel_->SetRender(false)); |
| 1347 | EXPECT_FALSE(vie_.GetRenderStarted(channel_num)); |
| 1348 | EXPECT_TRUE(channel_->SetRender(true)); |
| 1349 | EXPECT_TRUE(vie_.GetRenderStarted(channel_num)); |
| 1350 | EXPECT_TRUE(channel_->SetRender(false)); |
| 1351 | EXPECT_FALSE(vie_.GetRenderStarted(channel_num)); |
| 1352 | } |
| 1353 | |
| 1354 | // Test that we can create a channel and start/stop sending out on it. |
| 1355 | TEST_F(WebRtcVideoEngineTestFake, SetSend) { |
| 1356 | EXPECT_TRUE(SetupEngine()); |
| 1357 | int channel_num = vie_.GetLastChannel(); |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1358 | // Verify receiving is also started. |
| 1359 | EXPECT_TRUE(vie_.GetReceive(channel_num)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1360 | |
| 1361 | // Set send codecs on the channel. |
| 1362 | std::vector<cricket::VideoCodec> codecs; |
| 1363 | codecs.push_back(kVP8Codec); |
| 1364 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1365 | EXPECT_TRUE(channel_->AddSendStream( |
| 1366 | cricket::StreamParams::CreateLegacy(123))); |
| 1367 | |
| 1368 | // Verify we can start/stop/start/stop sending. |
| 1369 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1370 | EXPECT_TRUE(vie_.GetSend(channel_num)); |
| 1371 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1372 | EXPECT_FALSE(vie_.GetSend(channel_num)); |
| 1373 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1374 | EXPECT_TRUE(vie_.GetSend(channel_num)); |
| 1375 | EXPECT_TRUE(channel_->SetSend(false)); |
| 1376 | EXPECT_FALSE(vie_.GetSend(channel_num)); |
| 1377 | } |
| 1378 | |
| 1379 | // Test that we set bandwidth properly when using full auto bandwidth mode. |
| 1380 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthAuto) { |
| 1381 | EXPECT_TRUE(SetupEngine()); |
| 1382 | int channel_num = vie_.GetLastChannel(); |
| 1383 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1384 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(cricket::kAutoBandwidth)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1385 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 1386 | } |
| 1387 | |
| 1388 | // Test that we set bandwidth properly when using auto with upper bound. |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1389 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthCapped) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1390 | EXPECT_TRUE(SetupEngine()); |
| 1391 | int channel_num = vie_.GetLastChannel(); |
| 1392 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1393 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(768000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1394 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, 768U); |
| 1395 | } |
| 1396 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1397 | // Test that we reduce the start bandwidth when the requested max is less than |
| 1398 | // the default start bandwidth. |
| 1399 | TEST_F(WebRtcVideoEngineTestFake, SetMaxBandwidthBelowDefaultStart) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1400 | EXPECT_TRUE(SetupEngine()); |
| 1401 | int channel_num = vie_.GetLastChannel(); |
| 1402 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1403 | int max_bandwidth_kbps = (kMinBandwidthKbps + kStartBandwidthKbps) / 2; |
| 1404 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1405 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1406 | max_bandwidth_kbps, kMinBandwidthKbps, max_bandwidth_kbps); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1409 | // Test that we reduce the min bandwidth when the requested max is less than |
| 1410 | // the min bandwidth. |
| 1411 | TEST_F(WebRtcVideoEngineTestFake, SetMaxBandwidthBelowMin) { |
| 1412 | EXPECT_TRUE(SetupEngine()); |
| 1413 | int channel_num = vie_.GetLastChannel(); |
| 1414 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1415 | int max_bandwidth_kbps = kMinBandwidthKbps / 2; |
| 1416 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000)); |
| 1417 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1418 | max_bandwidth_kbps, max_bandwidth_kbps, max_bandwidth_kbps); |
| 1419 | } |
| 1420 | |
| 1421 | // Test that the start bandwidth can be controlled separately from the max |
| 1422 | // bandwidth. |
| 1423 | TEST_F(WebRtcVideoEngineTestFake, SetStartBandwidth) { |
| 1424 | EXPECT_TRUE(SetupEngine()); |
| 1425 | int channel_num = vie_.GetLastChannel(); |
| 1426 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1427 | int start_bandwidth_kbps = kStartBandwidthKbps + 1; |
| 1428 | EXPECT_TRUE(channel_->SetStartSendBandwidth(start_bandwidth_kbps * 1000)); |
| 1429 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1430 | kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1431 | |
| 1432 | // Check that SetMaxSendBandwidth doesn't overwrite the start bandwidth. |
| 1433 | int max_bandwidth_kbps = kMaxBandwidthKbps + 1; |
| 1434 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(max_bandwidth_kbps * 1000)); |
| 1435 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1436 | max_bandwidth_kbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1437 | } |
| 1438 | |
wu@webrtc.org | 1e6cb2c | 2014-03-24 17:01:50 +0000 | [diff] [blame] | 1439 | // Test that the start bandwidth can be controlled by experiment. |
| 1440 | TEST_F(WebRtcVideoEngineTestFake, SetStartBandwidthOption) { |
| 1441 | EXPECT_TRUE(SetupEngine()); |
| 1442 | int channel_num = vie_.GetLastChannel(); |
| 1443 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1444 | int start_bandwidth_kbps = kStartBandwidthKbps; |
| 1445 | EXPECT_TRUE(channel_->SetStartSendBandwidth(start_bandwidth_kbps * 1000)); |
| 1446 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1447 | kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1448 | |
| 1449 | // Set the start bitrate option. |
| 1450 | start_bandwidth_kbps = 1000; |
| 1451 | cricket::VideoOptions options; |
| 1452 | options.video_start_bitrate.Set( |
| 1453 | start_bandwidth_kbps); |
| 1454 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1455 | |
| 1456 | // Check that start bitrate has changed to the new value. |
| 1457 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1458 | kMaxBandwidthKbps, kMinBandwidthKbps, start_bandwidth_kbps); |
| 1459 | } |
| 1460 | |
buildbot@webrtc.org | d1ae89f | 2014-05-08 19:19:26 +0000 | [diff] [blame] | 1461 | // Test that SetMaxSendBandwidth works as expected in conference mode. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1462 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthInConference) { |
| 1463 | EXPECT_TRUE(SetupEngine()); |
| 1464 | int channel_num = vie_.GetLastChannel(); |
| 1465 | cricket::VideoOptions options; |
| 1466 | options.conference_mode.Set(true); |
| 1467 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1468 | EXPECT_TRUE(channel_->SetSendCodecs(engine_.codecs())); |
| 1469 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height); |
| 1470 | |
| 1471 | // Set send bandwidth. |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1472 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(768000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1473 | |
buildbot@webrtc.org | d1ae89f | 2014-05-08 19:19:26 +0000 | [diff] [blame] | 1474 | // Verify that the max bitrate has changed. |
| 1475 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, |
| 1476 | 768, kMinBandwidthKbps, kStartBandwidthKbps); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1477 | } |
| 1478 | |
buildbot@webrtc.org | d1ae89f | 2014-05-08 19:19:26 +0000 | [diff] [blame] | 1479 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1480 | // Test that sending screencast frames doesn't change bitrate. |
| 1481 | TEST_F(WebRtcVideoEngineTestFake, SetBandwidthScreencast) { |
| 1482 | EXPECT_TRUE(SetupEngine()); |
| 1483 | int channel_num = vie_.GetLastChannel(); |
| 1484 | |
| 1485 | // Set send codec. |
| 1486 | cricket::VideoCodec codec(kVP8Codec); |
| 1487 | std::vector<cricket::VideoCodec> codec_list; |
| 1488 | codec_list.push_back(codec); |
| 1489 | EXPECT_TRUE(channel_->AddSendStream( |
| 1490 | cricket::StreamParams::CreateLegacy(123))); |
| 1491 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1492 | EXPECT_TRUE(channel_->SetMaxSendBandwidth(111000)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1493 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1494 | |
| 1495 | SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height); |
sergeyu@chromium.org | 4b26e2e | 2014-01-15 23:15:54 +0000 | [diff] [blame] | 1496 | VerifyVP8SendCodec(channel_num, kVP8Codec.width, kVP8Codec.height, 0, 111); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | |
| 1500 | // Test SetSendSsrc. |
| 1501 | TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAndCname) { |
| 1502 | EXPECT_TRUE(SetupEngine()); |
| 1503 | int channel_num = vie_.GetLastChannel(); |
| 1504 | |
| 1505 | cricket::StreamParams stream; |
| 1506 | stream.ssrcs.push_back(1234); |
| 1507 | stream.cname = "cname"; |
| 1508 | channel_->AddSendStream(stream); |
| 1509 | |
| 1510 | unsigned int ssrc = 0; |
| 1511 | EXPECT_EQ(0, vie_.GetLocalSSRC(channel_num, ssrc)); |
| 1512 | EXPECT_EQ(1234U, ssrc); |
| 1513 | EXPECT_EQ(1, vie_.GetNumSsrcs(channel_num)); |
| 1514 | |
| 1515 | char rtcp_cname[256]; |
| 1516 | EXPECT_EQ(0, vie_.GetRTCPCName(channel_num, rtcp_cname)); |
| 1517 | EXPECT_STREQ("cname", rtcp_cname); |
| 1518 | } |
| 1519 | |
| 1520 | |
| 1521 | // Test that the local SSRC is the same on sending and receiving channels if the |
| 1522 | // receive channel is created before the send channel. |
| 1523 | TEST_F(WebRtcVideoEngineTestFake, SetSendSsrcAfterCreatingReceiveChannel) { |
| 1524 | EXPECT_TRUE(SetupEngine()); |
| 1525 | |
| 1526 | EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 1527 | int receive_channel_num = vie_.GetLastChannel(); |
| 1528 | cricket::StreamParams stream = cricket::StreamParams::CreateLegacy(1234); |
| 1529 | EXPECT_TRUE(channel_->AddSendStream(stream)); |
| 1530 | int send_channel_num = vie_.GetLastChannel(); |
| 1531 | unsigned int ssrc = 0; |
| 1532 | EXPECT_EQ(0, vie_.GetLocalSSRC(send_channel_num, ssrc)); |
| 1533 | EXPECT_EQ(1234U, ssrc); |
| 1534 | EXPECT_EQ(1, vie_.GetNumSsrcs(send_channel_num)); |
| 1535 | ssrc = 0; |
| 1536 | EXPECT_EQ(0, vie_.GetLocalSSRC(receive_channel_num, ssrc)); |
| 1537 | EXPECT_EQ(1234U, ssrc); |
| 1538 | EXPECT_EQ(1, vie_.GetNumSsrcs(receive_channel_num)); |
| 1539 | } |
| 1540 | |
| 1541 | |
| 1542 | // Test SetOptions with denoising flag. |
| 1543 | TEST_F(WebRtcVideoEngineTestFake, SetOptionsWithDenoising) { |
| 1544 | EXPECT_TRUE(SetupEngine()); |
| 1545 | EXPECT_EQ(1, vie_.GetNumCapturers()); |
| 1546 | int channel_num = vie_.GetLastChannel(); |
| 1547 | int capture_id = vie_.GetCaptureId(channel_num); |
| 1548 | // Set send codecs on the channel. |
| 1549 | std::vector<cricket::VideoCodec> codecs; |
| 1550 | codecs.push_back(kVP8Codec); |
| 1551 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1552 | |
| 1553 | // Set options with OPT_VIDEO_NOISE_REDUCTION flag. |
| 1554 | cricket::VideoOptions options; |
| 1555 | options.video_noise_reduction.Set(true); |
| 1556 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1557 | |
| 1558 | // Verify capture has denoising turned on. |
| 1559 | webrtc::VideoCodec send_codec; |
| 1560 | memset(&send_codec, 0, sizeof(send_codec)); // avoid uninitialized warning |
| 1561 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec)); |
| 1562 | EXPECT_TRUE(send_codec.codecSpecific.VP8.denoisingOn); |
| 1563 | EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id)); |
| 1564 | |
| 1565 | // Set options back to zero. |
| 1566 | options.video_noise_reduction.Set(false); |
| 1567 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1568 | |
| 1569 | // Verify capture has denoising turned off. |
| 1570 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, send_codec)); |
| 1571 | EXPECT_FALSE(send_codec.codecSpecific.VP8.denoisingOn); |
| 1572 | EXPECT_FALSE(vie_.GetCaptureDenoising(capture_id)); |
| 1573 | } |
| 1574 | |
wu@webrtc.org | a8910d2 | 2014-01-23 22:12:45 +0000 | [diff] [blame] | 1575 | TEST_F(WebRtcVideoEngineTestFake, MultipleSendStreamsWithOneCapturer) { |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 1576 | EXPECT_TRUE(SetupEngine()); |
| 1577 | |
| 1578 | // Start the capturer |
| 1579 | cricket::FakeVideoCapturer capturer; |
| 1580 | cricket::VideoFormat capture_format_vga = cricket::VideoFormat(640, 480, |
| 1581 | cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420); |
| 1582 | EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_vga)); |
| 1583 | |
| 1584 | // Add send streams and connect the capturer |
| 1585 | for (unsigned int i = 0; i < sizeof(kSsrcs2)/sizeof(kSsrcs2[0]); ++i) { |
| 1586 | EXPECT_TRUE(channel_->AddSendStream( |
| 1587 | cricket::StreamParams::CreateLegacy(kSsrcs2[i]))); |
| 1588 | // Register the capturer to the ssrc. |
| 1589 | EXPECT_TRUE(channel_->SetCapturer(kSsrcs2[i], &capturer)); |
| 1590 | } |
| 1591 | |
| 1592 | const int channel0 = vie_.GetChannelFromLocalSsrc(kSsrcs2[0]); |
| 1593 | ASSERT_NE(-1, channel0); |
| 1594 | const int channel1 = vie_.GetChannelFromLocalSsrc(kSsrcs2[1]); |
| 1595 | ASSERT_NE(-1, channel1); |
| 1596 | ASSERT_NE(channel0, channel1); |
| 1597 | |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1598 | // Both channels should have started receiving after created. |
| 1599 | EXPECT_TRUE(vie_.GetReceive(channel0)); |
| 1600 | EXPECT_TRUE(vie_.GetReceive(channel1)); |
| 1601 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 1602 | // Set send codec. |
| 1603 | std::vector<cricket::VideoCodec> codecs; |
| 1604 | cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); |
| 1605 | codecs.push_back(send_codec); |
| 1606 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1607 | |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1608 | EXPECT_TRUE(channel_->SetSend(true)); |
| 1609 | EXPECT_TRUE(vie_.GetSend(channel0)); |
| 1610 | EXPECT_TRUE(vie_.GetSend(channel1)); |
| 1611 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 1612 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1613 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0)); |
| 1614 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel1)); |
| 1615 | |
| 1616 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs2[0])); |
| 1617 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1618 | // channel0 is the default channel, so it won't be deleted. |
| 1619 | // But it should be disconnected from the capturer. |
| 1620 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0)); |
| 1621 | EXPECT_EQ(2, vie_.GetIncomingFrameNum(channel1)); |
| 1622 | |
| 1623 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrcs2[1])); |
| 1624 | EXPECT_TRUE(capturer.CaptureFrame()); |
| 1625 | EXPECT_EQ(1, vie_.GetIncomingFrameNum(channel0)); |
| 1626 | // channel1 has already been deleted. |
| 1627 | EXPECT_EQ(-1, vie_.GetIncomingFrameNum(channel1)); |
| 1628 | } |
| 1629 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1630 | |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1631 | TEST_F(WebRtcVideoEngineTestFake, SendReceiveBitratesStats) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1632 | EXPECT_TRUE(SetupEngine()); |
| 1633 | cricket::VideoOptions options; |
| 1634 | options.conference_mode.Set(true); |
| 1635 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1636 | EXPECT_TRUE(channel_->AddSendStream( |
| 1637 | cricket::StreamParams::CreateLegacy(1))); |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1638 | int first_send_channel = vie_.GetLastChannel(); |
| 1639 | EXPECT_TRUE(channel_->AddSendStream( |
| 1640 | cricket::StreamParams::CreateLegacy(2))); |
| 1641 | int second_send_channel = vie_.GetLastChannel(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1642 | cricket::VideoCodec codec(kVP8Codec720p); |
| 1643 | std::vector<cricket::VideoCodec> codec_list; |
| 1644 | codec_list.push_back(codec); |
| 1645 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 1646 | |
| 1647 | EXPECT_TRUE(channel_->AddRecvStream( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1648 | cricket::StreamParams::CreateLegacy(3))); |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1649 | int first_receive_channel = vie_.GetLastChannel(); |
| 1650 | EXPECT_NE(first_send_channel, first_receive_channel); |
| 1651 | EXPECT_TRUE(channel_->AddRecvStream( |
| 1652 | cricket::StreamParams::CreateLegacy(4))); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1653 | int second_receive_channel = vie_.GetLastChannel(); |
| 1654 | EXPECT_NE(first_receive_channel, second_receive_channel); |
| 1655 | |
| 1656 | cricket::VideoMediaInfo info; |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1657 | EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1658 | ASSERT_EQ(1U, info.bw_estimations.size()); |
| 1659 | ASSERT_EQ(0, info.bw_estimations[0].actual_enc_bitrate); |
| 1660 | ASSERT_EQ(0, info.bw_estimations[0].transmit_bitrate); |
| 1661 | ASSERT_EQ(0, info.bw_estimations[0].retransmit_bitrate); |
| 1662 | ASSERT_EQ(0, info.bw_estimations[0].available_send_bandwidth); |
| 1663 | ASSERT_EQ(0, info.bw_estimations[0].available_recv_bandwidth); |
| 1664 | ASSERT_EQ(0, info.bw_estimations[0].target_enc_bitrate); |
| 1665 | |
| 1666 | // Start sending and receiving on one of the channels and verify bitrates. |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1667 | EXPECT_EQ(0, vie_.StartSend(first_send_channel)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1668 | int send_video_bitrate = 800; |
| 1669 | int send_fec_bitrate = 100; |
| 1670 | int send_nack_bitrate = 20; |
| 1671 | int send_total_bitrate = send_video_bitrate + send_fec_bitrate + |
| 1672 | send_nack_bitrate; |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1673 | int send_bandwidth = 1900; |
| 1674 | vie_.SetSendBitrates(first_send_channel, send_video_bitrate, send_fec_bitrate, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1675 | send_nack_bitrate); |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1676 | vie_.SetSendBandwidthEstimate(first_send_channel, send_bandwidth); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1677 | |
| 1678 | EXPECT_EQ(0, vie_.StartReceive(first_receive_channel)); |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1679 | int receive_bandwidth = 600; |
| 1680 | vie_.SetReceiveBandwidthEstimate(first_receive_channel, receive_bandwidth); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1681 | |
| 1682 | info.Clear(); |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1683 | EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1684 | ASSERT_EQ(1U, info.bw_estimations.size()); |
| 1685 | ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate); |
| 1686 | ASSERT_EQ(send_total_bitrate, info.bw_estimations[0].transmit_bitrate); |
| 1687 | ASSERT_EQ(send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate); |
| 1688 | ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth); |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1689 | ASSERT_EQ(receive_bandwidth, info.bw_estimations[0].available_recv_bandwidth); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1690 | ASSERT_EQ(send_video_bitrate, info.bw_estimations[0].target_enc_bitrate); |
| 1691 | |
| 1692 | // Start receiving on the second channel and verify received rate. |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1693 | EXPECT_EQ(0, vie_.StartSend(second_send_channel)); |
| 1694 | vie_.SetSendBitrates(second_send_channel, |
| 1695 | send_video_bitrate, |
| 1696 | send_fec_bitrate, |
| 1697 | send_nack_bitrate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1698 | EXPECT_EQ(0, vie_.StartReceive(second_receive_channel)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1699 | |
| 1700 | info.Clear(); |
wu@webrtc.org | b9a088b | 2014-02-13 23:18:49 +0000 | [diff] [blame] | 1701 | EXPECT_TRUE(channel_->GetStats(cricket::StatsOptions(), &info)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1702 | ASSERT_EQ(1U, info.bw_estimations.size()); |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1703 | ASSERT_EQ(2 * send_video_bitrate, info.bw_estimations[0].actual_enc_bitrate); |
| 1704 | ASSERT_EQ(2 * send_total_bitrate, info.bw_estimations[0].transmit_bitrate); |
| 1705 | ASSERT_EQ(2 * send_nack_bitrate, info.bw_estimations[0].retransmit_bitrate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1706 | ASSERT_EQ(send_bandwidth, info.bw_estimations[0].available_send_bandwidth); |
buildbot@webrtc.org | a18b4c9 | 2014-05-06 17:48:14 +0000 | [diff] [blame] | 1707 | ASSERT_EQ(receive_bandwidth, info.bw_estimations[0].available_recv_bandwidth); |
| 1708 | ASSERT_EQ(2 * send_video_bitrate, info.bw_estimations[0].target_enc_bitrate); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1709 | } |
| 1710 | |
| 1711 | TEST_F(WebRtcVideoEngineTestFake, TestSetAdaptInputToCpuUsage) { |
| 1712 | EXPECT_TRUE(SetupEngine()); |
| 1713 | cricket::VideoOptions options_in, options_out; |
| 1714 | bool cpu_adapt = false; |
| 1715 | channel_->SetOptions(options_in); |
| 1716 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1717 | EXPECT_FALSE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt)); |
| 1718 | // Set adapt input CPU usage option. |
| 1719 | options_in.adapt_input_to_cpu_usage.Set(true); |
| 1720 | EXPECT_TRUE(channel_->SetOptions(options_in)); |
| 1721 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1722 | EXPECT_TRUE(options_out.adapt_input_to_cpu_usage.Get(&cpu_adapt)); |
| 1723 | EXPECT_TRUE(cpu_adapt); |
| 1724 | } |
| 1725 | |
| 1726 | TEST_F(WebRtcVideoEngineTestFake, TestSetCpuThreshold) { |
| 1727 | EXPECT_TRUE(SetupEngine()); |
| 1728 | float low, high; |
| 1729 | cricket::VideoOptions options_in, options_out; |
| 1730 | // Verify that initial values are set. |
| 1731 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1732 | EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low)); |
| 1733 | EXPECT_EQ(low, 0.65f); |
| 1734 | EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high)); |
| 1735 | EXPECT_EQ(high, 0.85f); |
| 1736 | // Set new CPU threshold values. |
| 1737 | options_in.system_low_adaptation_threshhold.Set(0.45f); |
| 1738 | options_in.system_high_adaptation_threshhold.Set(0.95f); |
| 1739 | EXPECT_TRUE(channel_->SetOptions(options_in)); |
| 1740 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1741 | EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low)); |
| 1742 | EXPECT_EQ(low, 0.45f); |
| 1743 | EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high)); |
| 1744 | EXPECT_EQ(high, 0.95f); |
| 1745 | } |
| 1746 | |
| 1747 | TEST_F(WebRtcVideoEngineTestFake, TestSetInvalidCpuThreshold) { |
| 1748 | EXPECT_TRUE(SetupEngine()); |
| 1749 | float low, high; |
| 1750 | cricket::VideoOptions options_in, options_out; |
| 1751 | // Valid range is [0, 1]. |
| 1752 | options_in.system_low_adaptation_threshhold.Set(-1.5f); |
| 1753 | options_in.system_high_adaptation_threshhold.Set(1.5f); |
| 1754 | EXPECT_TRUE(channel_->SetOptions(options_in)); |
| 1755 | EXPECT_TRUE(channel_->GetOptions(&options_out)); |
| 1756 | EXPECT_TRUE(options_out.system_low_adaptation_threshhold.Get(&low)); |
| 1757 | EXPECT_EQ(low, 0.0f); |
| 1758 | EXPECT_TRUE(options_out.system_high_adaptation_threshhold.Get(&high)); |
| 1759 | EXPECT_EQ(high, 1.0f); |
| 1760 | } |
| 1761 | |
| 1762 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1763 | TEST_F(WebRtcVideoEngineTestFake, ResetCodecOnScreencast) { |
| 1764 | EXPECT_TRUE(SetupEngine()); |
| 1765 | cricket::VideoOptions options; |
| 1766 | options.video_noise_reduction.Set(true); |
| 1767 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 1768 | |
| 1769 | // Set send codec. |
| 1770 | cricket::VideoCodec codec(kVP8Codec); |
| 1771 | std::vector<cricket::VideoCodec> codec_list; |
| 1772 | codec_list.push_back(codec); |
| 1773 | EXPECT_TRUE(channel_->AddSendStream( |
| 1774 | cricket::StreamParams::CreateLegacy(123))); |
| 1775 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 1776 | EXPECT_TRUE(channel_->SetSend(true)); |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 1777 | EXPECT_EQ(1, vie_.GetNumSetSendCodecs()); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1778 | |
| 1779 | webrtc::VideoCodec gcodec; |
| 1780 | memset(&gcodec, 0, sizeof(gcodec)); |
| 1781 | int channel_num = vie_.GetLastChannel(); |
| 1782 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 1783 | EXPECT_TRUE(gcodec.codecSpecific.VP8.denoisingOn); |
| 1784 | |
| 1785 | // Send a screencast frame with the same size. |
| 1786 | // Verify that denoising is turned off. |
| 1787 | SendI420ScreencastFrame(kVP8Codec.width, kVP8Codec.height); |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 1788 | EXPECT_EQ(2, vie_.GetNumSetSendCodecs()); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1789 | EXPECT_EQ(0, vie_.GetSendCodec(channel_num, gcodec)); |
| 1790 | EXPECT_FALSE(gcodec.codecSpecific.VP8.denoisingOn); |
| 1791 | } |
| 1792 | |
| 1793 | |
| 1794 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderIfFactoryIsNotGiven) { |
| 1795 | engine_.SetExternalDecoderFactory(NULL); |
| 1796 | EXPECT_TRUE(SetupEngine()); |
| 1797 | int channel_num = vie_.GetLastChannel(); |
| 1798 | |
| 1799 | std::vector<cricket::VideoCodec> codecs; |
| 1800 | codecs.push_back(kVP8Codec); |
| 1801 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1802 | |
| 1803 | EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1804 | } |
| 1805 | |
| 1806 | TEST_F(WebRtcVideoEngineTestFake, RegisterDecoderIfFactoryIsGiven) { |
| 1807 | decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
| 1808 | engine_.SetExternalDecoderFactory(&decoder_factory_); |
| 1809 | EXPECT_TRUE(SetupEngine()); |
| 1810 | int channel_num = vie_.GetLastChannel(); |
| 1811 | |
| 1812 | std::vector<cricket::VideoCodec> codecs; |
| 1813 | codecs.push_back(kVP8Codec); |
| 1814 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1815 | |
| 1816 | EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100)); |
| 1817 | EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1818 | } |
| 1819 | |
| 1820 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderMultipleTimes) { |
| 1821 | decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
| 1822 | engine_.SetExternalDecoderFactory(&decoder_factory_); |
| 1823 | EXPECT_TRUE(SetupEngine()); |
| 1824 | int channel_num = vie_.GetLastChannel(); |
| 1825 | |
| 1826 | std::vector<cricket::VideoCodec> codecs; |
| 1827 | codecs.push_back(kVP8Codec); |
| 1828 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1829 | |
| 1830 | EXPECT_TRUE(vie_.ExternalDecoderRegistered(channel_num, 100)); |
| 1831 | EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1832 | EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders()); |
| 1833 | |
| 1834 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1835 | EXPECT_EQ(1, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1836 | EXPECT_EQ(1, decoder_factory_.GetNumCreatedDecoders()); |
| 1837 | } |
| 1838 | |
| 1839 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterDecoderForNonVP8) { |
| 1840 | decoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8); |
| 1841 | engine_.SetExternalDecoderFactory(&decoder_factory_); |
| 1842 | EXPECT_TRUE(SetupEngine()); |
| 1843 | int channel_num = vie_.GetLastChannel(); |
| 1844 | |
| 1845 | std::vector<cricket::VideoCodec> codecs; |
| 1846 | codecs.push_back(kRedCodec); |
| 1847 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 1848 | |
| 1849 | EXPECT_EQ(0, vie_.GetNumExternalDecoderRegistered(channel_num)); |
| 1850 | } |
| 1851 | |
| 1852 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderIfFactoryIsNotGiven) { |
| 1853 | engine_.SetExternalEncoderFactory(NULL); |
| 1854 | EXPECT_TRUE(SetupEngine()); |
| 1855 | int channel_num = vie_.GetLastChannel(); |
| 1856 | |
| 1857 | std::vector<cricket::VideoCodec> codecs; |
| 1858 | codecs.push_back(kVP8Codec); |
| 1859 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1860 | |
| 1861 | EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1862 | } |
| 1863 | |
| 1864 | TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderIfFactoryIsGiven) { |
| 1865 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1866 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1867 | EXPECT_TRUE(SetupEngine()); |
| 1868 | int channel_num = vie_.GetLastChannel(); |
| 1869 | |
| 1870 | std::vector<cricket::VideoCodec> codecs; |
| 1871 | codecs.push_back(kVP8Codec); |
| 1872 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1873 | |
| 1874 | EXPECT_TRUE(channel_->AddSendStream( |
| 1875 | cricket::StreamParams::CreateLegacy(kSsrc))); |
| 1876 | |
| 1877 | EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100)); |
| 1878 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1879 | |
| 1880 | // Remove stream previously added to free the external encoder instance. |
| 1881 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
| 1882 | } |
| 1883 | |
| 1884 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderMultipleTimes) { |
| 1885 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1886 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1887 | EXPECT_TRUE(SetupEngine()); |
| 1888 | int channel_num = vie_.GetLastChannel(); |
| 1889 | |
| 1890 | std::vector<cricket::VideoCodec> codecs; |
| 1891 | codecs.push_back(kVP8Codec); |
| 1892 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1893 | |
| 1894 | EXPECT_TRUE(channel_->AddSendStream( |
| 1895 | cricket::StreamParams::CreateLegacy(kSsrc))); |
| 1896 | |
| 1897 | EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100)); |
| 1898 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1899 | |
| 1900 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1901 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 1902 | |
| 1903 | // Remove stream previously added to free the external encoder instance. |
| 1904 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
| 1905 | } |
| 1906 | |
| 1907 | TEST_F(WebRtcVideoEngineTestFake, RegisterEncoderWithMultipleSendStreams) { |
| 1908 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 1909 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1910 | EXPECT_TRUE(SetupEngine()); |
| 1911 | |
| 1912 | std::vector<cricket::VideoCodec> codecs; |
| 1913 | codecs.push_back(kVP8Codec); |
| 1914 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1915 | EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1916 | |
| 1917 | // When we add the first stream (1234), it reuses the default send channel, |
| 1918 | // so it doesn't increase the registration count of external encoders. |
| 1919 | EXPECT_TRUE(channel_->AddSendStream( |
| 1920 | cricket::StreamParams::CreateLegacy(1234))); |
| 1921 | EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1922 | |
| 1923 | // When we add the second stream (2345), it creates a new channel and |
| 1924 | // increments the registration count. |
| 1925 | EXPECT_TRUE(channel_->AddSendStream( |
| 1926 | cricket::StreamParams::CreateLegacy(2345))); |
| 1927 | EXPECT_EQ(2, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1928 | |
| 1929 | // At this moment the total registration count is two, but only one encoder |
| 1930 | // is registered per channel. |
| 1931 | int channel_num = vie_.GetLastChannel(); |
| 1932 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1933 | |
| 1934 | // Removing send streams decrements the registration count. |
| 1935 | EXPECT_TRUE(channel_->RemoveSendStream(1234)); |
| 1936 | EXPECT_EQ(1, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1937 | |
| 1938 | // When we remove the last send stream, it also destroys the last send |
| 1939 | // channel and causes the registration count to drop to zero. It is a little |
| 1940 | // weird, but not a bug. |
| 1941 | EXPECT_TRUE(channel_->RemoveSendStream(2345)); |
| 1942 | EXPECT_EQ(0, vie_.GetTotalNumExternalEncoderRegistered()); |
| 1943 | } |
| 1944 | |
| 1945 | TEST_F(WebRtcVideoEngineTestFake, DontRegisterEncoderForNonVP8) { |
| 1946 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric, |
| 1947 | "GENERIC"); |
| 1948 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1949 | EXPECT_TRUE(SetupEngine()); |
| 1950 | int channel_num = vie_.GetLastChannel(); |
| 1951 | |
| 1952 | // Note: unlike the SetRecvCodecs, we must set a valid video codec for |
| 1953 | // channel_->SetSendCodecs() to succeed. |
| 1954 | std::vector<cricket::VideoCodec> codecs; |
| 1955 | codecs.push_back(kVP8Codec); |
| 1956 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 1957 | |
| 1958 | EXPECT_EQ(0, vie_.GetNumExternalEncoderRegistered(channel_num)); |
| 1959 | } |
| 1960 | |
| 1961 | // Test that NACK, PLI and REMB are enabled for external codec. |
| 1962 | TEST_F(WebRtcVideoEngineTestFake, ExternalCodecFeedbackParams) { |
| 1963 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric, |
| 1964 | "GENERIC"); |
| 1965 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1966 | encoder_factory_.NotifyCodecsAvailable(); |
| 1967 | EXPECT_TRUE(SetupEngine()); |
| 1968 | |
| 1969 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1970 | // The external codec will appear at last. |
| 1971 | size_t pos = codecs.size() - 1; |
| 1972 | EXPECT_EQ("GENERIC", codecs[pos].name); |
| 1973 | VerifyCodecFeedbackParams(codecs[pos]); |
| 1974 | } |
| 1975 | |
| 1976 | // Test external codec with be added to the end of the supported codec list. |
| 1977 | TEST_F(WebRtcVideoEngineTestFake, ExternalCodecAddedToTheEnd) { |
| 1978 | EXPECT_TRUE(SetupEngine()); |
| 1979 | |
| 1980 | std::vector<cricket::VideoCodec> codecs(engine_.codecs()); |
| 1981 | EXPECT_EQ("VP8", codecs[0].name); |
| 1982 | |
| 1983 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecGeneric, |
| 1984 | "GENERIC"); |
| 1985 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 1986 | encoder_factory_.NotifyCodecsAvailable(); |
| 1987 | |
| 1988 | codecs = engine_.codecs(); |
| 1989 | cricket::VideoCodec internal_codec = codecs[0]; |
| 1990 | cricket::VideoCodec external_codec = codecs[codecs.size() - 1]; |
| 1991 | // The external codec will appear at last. |
| 1992 | EXPECT_EQ("GENERIC", external_codec.name); |
| 1993 | // The internal codec is preferred. |
| 1994 | EXPECT_GE(internal_codec.preference, external_codec.preference); |
| 1995 | } |
| 1996 | |
| 1997 | // Test that external codec with be ignored if it has the same name as one of |
| 1998 | // the internal codecs. |
| 1999 | TEST_F(WebRtcVideoEngineTestFake, ExternalCodecIgnored) { |
| 2000 | EXPECT_TRUE(SetupEngine()); |
| 2001 | |
| 2002 | std::vector<cricket::VideoCodec> internal_codecs(engine_.codecs()); |
| 2003 | EXPECT_EQ("VP8", internal_codecs[0].name); |
| 2004 | |
| 2005 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 2006 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 2007 | encoder_factory_.NotifyCodecsAvailable(); |
| 2008 | |
| 2009 | std::vector<cricket::VideoCodec> codecs = engine_.codecs(); |
| 2010 | EXPECT_EQ("VP8", codecs[0].name); |
| 2011 | EXPECT_EQ(internal_codecs[0].height, codecs[0].height); |
| 2012 | EXPECT_EQ(internal_codecs[0].width, codecs[0].width); |
| 2013 | // Verify the last codec is not the external codec. |
| 2014 | EXPECT_NE("VP8", codecs[codecs.size() - 1].name); |
| 2015 | } |
| 2016 | |
| 2017 | TEST_F(WebRtcVideoEngineTestFake, UpdateEncoderCodecsAfterSetFactory) { |
| 2018 | engine_.SetExternalEncoderFactory(&encoder_factory_); |
| 2019 | EXPECT_TRUE(SetupEngine()); |
| 2020 | int channel_num = vie_.GetLastChannel(); |
| 2021 | |
| 2022 | encoder_factory_.AddSupportedVideoCodecType(webrtc::kVideoCodecVP8, "VP8"); |
| 2023 | encoder_factory_.NotifyCodecsAvailable(); |
| 2024 | std::vector<cricket::VideoCodec> codecs; |
| 2025 | codecs.push_back(kVP8Codec); |
| 2026 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 2027 | |
| 2028 | EXPECT_TRUE(channel_->AddSendStream( |
| 2029 | cricket::StreamParams::CreateLegacy(kSsrc))); |
| 2030 | |
| 2031 | EXPECT_TRUE(vie_.ExternalEncoderRegistered(channel_num, 100)); |
| 2032 | EXPECT_EQ(1, vie_.GetNumExternalEncoderRegistered(channel_num)); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 2033 | |
| 2034 | // Remove stream previously added to free the external encoder instance. |
| 2035 | EXPECT_TRUE(channel_->RemoveSendStream(kSsrc)); |
| 2036 | } |
| 2037 | |
| 2038 | // Tests that OnReadyToSend will be propagated into ViE. |
| 2039 | TEST_F(WebRtcVideoEngineTestFake, OnReadyToSend) { |
| 2040 | EXPECT_TRUE(SetupEngine()); |
| 2041 | int channel_num = vie_.GetLastChannel(); |
| 2042 | EXPECT_TRUE(vie_.GetIsTransmitting(channel_num)); |
| 2043 | |
| 2044 | channel_->OnReadyToSend(false); |
| 2045 | EXPECT_FALSE(vie_.GetIsTransmitting(channel_num)); |
| 2046 | |
| 2047 | channel_->OnReadyToSend(true); |
| 2048 | EXPECT_TRUE(vie_.GetIsTransmitting(channel_num)); |
| 2049 | } |
| 2050 | |
| 2051 | #if 0 |
| 2052 | TEST_F(WebRtcVideoEngineTestFake, CaptureFrameTimestampToNtpTimestamp) { |
| 2053 | EXPECT_TRUE(SetupEngine()); |
| 2054 | int capture_id = vie_.GetCaptureId(vie_.GetLastChannel()); |
| 2055 | |
| 2056 | // Set send codec. |
| 2057 | cricket::VideoCodec codec(kVP8Codec); |
| 2058 | std::vector<cricket::VideoCodec> codec_list; |
| 2059 | codec_list.push_back(codec); |
| 2060 | EXPECT_TRUE(channel_->AddSendStream( |
| 2061 | cricket::StreamParams::CreateLegacy(123))); |
| 2062 | EXPECT_TRUE(channel_->SetSendCodecs(codec_list)); |
| 2063 | EXPECT_TRUE(channel_->SetSend(true)); |
| 2064 | |
| 2065 | int64 timestamp = time(NULL) * talk_base::kNumNanosecsPerSec; |
| 2066 | SendI420ScreencastFrameWithTimestamp( |
| 2067 | kVP8Codec.width, kVP8Codec.height, timestamp); |
| 2068 | EXPECT_EQ(talk_base::UnixTimestampNanosecsToNtpMillisecs(timestamp), |
| 2069 | vie_.GetCaptureLastTimestamp(capture_id)); |
| 2070 | |
| 2071 | SendI420ScreencastFrameWithTimestamp(kVP8Codec.width, kVP8Codec.height, 0); |
| 2072 | EXPECT_EQ(0, vie_.GetCaptureLastTimestamp(capture_id)); |
| 2073 | } |
| 2074 | #endif |
| 2075 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2076 | ///////////////////////// |
| 2077 | // Tests with real ViE // |
| 2078 | ///////////////////////// |
| 2079 | |
| 2080 | // Tests that we can find codecs by name or id. |
| 2081 | TEST_F(WebRtcVideoEngineTest, FindCodec) { |
| 2082 | // We should not need to init engine in order to get codecs. |
| 2083 | const std::vector<cricket::VideoCodec>& c = engine_.codecs(); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 2084 | EXPECT_EQ(4U, c.size()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2085 | |
| 2086 | cricket::VideoCodec vp8(104, "VP8", 320, 200, 30, 0); |
| 2087 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 2088 | |
| 2089 | cricket::VideoCodec vp8_ci(104, "vp8", 320, 200, 30, 0); |
| 2090 | EXPECT_TRUE(engine_.FindCodec(vp8)); |
| 2091 | |
| 2092 | cricket::VideoCodec vp8_diff_fr_diff_pref(104, "VP8", 320, 200, 50, 50); |
| 2093 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_fr_diff_pref)); |
| 2094 | |
| 2095 | cricket::VideoCodec vp8_diff_id(95, "VP8", 320, 200, 30, 0); |
| 2096 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_id)); |
| 2097 | vp8_diff_id.id = 97; |
| 2098 | EXPECT_TRUE(engine_.FindCodec(vp8_diff_id)); |
| 2099 | |
| 2100 | cricket::VideoCodec vp8_diff_res(104, "VP8", 320, 111, 30, 0); |
| 2101 | EXPECT_FALSE(engine_.FindCodec(vp8_diff_res)); |
| 2102 | |
| 2103 | // PeerConnection doesn't negotiate the resolution at this point. |
| 2104 | // Test that FindCodec can handle the case when width/height is 0. |
| 2105 | cricket::VideoCodec vp8_zero_res(104, "VP8", 0, 0, 30, 0); |
| 2106 | EXPECT_TRUE(engine_.FindCodec(vp8_zero_res)); |
| 2107 | |
| 2108 | cricket::VideoCodec red(101, "RED", 0, 0, 30, 0); |
| 2109 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 2110 | |
| 2111 | cricket::VideoCodec red_ci(101, "red", 0, 0, 30, 0); |
| 2112 | EXPECT_TRUE(engine_.FindCodec(red)); |
| 2113 | |
| 2114 | cricket::VideoCodec fec(102, "ULPFEC", 0, 0, 30, 0); |
| 2115 | EXPECT_TRUE(engine_.FindCodec(fec)); |
| 2116 | |
| 2117 | cricket::VideoCodec fec_ci(102, "ulpfec", 0, 0, 30, 0); |
| 2118 | EXPECT_TRUE(engine_.FindCodec(fec)); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 2119 | |
| 2120 | cricket::VideoCodec rtx(96, "rtx", 0, 0, 30, 0); |
buildbot@webrtc.org | dd4742a | 2014-05-07 14:50:35 +0000 | [diff] [blame] | 2121 | rtx.SetParam("apt", kVP8Codec.id); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 2122 | EXPECT_TRUE(engine_.FindCodec(rtx)); |
| 2123 | } |
| 2124 | |
| 2125 | TEST_F(WebRtcVideoEngineTest, RtxCodecHasAptSet) { |
| 2126 | std::vector<cricket::VideoCodec>::const_iterator it; |
| 2127 | bool apt_checked = false; |
| 2128 | for (it = engine_.codecs().begin(); it != engine_.codecs().end(); ++it) { |
| 2129 | if (_stricmp(cricket::kRtxCodecName, it->name.c_str()) && it->id != 96) { |
| 2130 | continue; |
| 2131 | } |
| 2132 | int apt; |
| 2133 | EXPECT_TRUE(it->GetParam("apt", &apt)); |
| 2134 | EXPECT_EQ(100, apt); |
| 2135 | apt_checked = true; |
| 2136 | } |
| 2137 | EXPECT_TRUE(apt_checked); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2138 | } |
| 2139 | |
| 2140 | TEST_F(WebRtcVideoEngineTest, StartupShutdown) { |
| 2141 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 2142 | engine_.Terminate(); |
| 2143 | } |
| 2144 | |
| 2145 | TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec) |
| 2146 | TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainNewCodec) |
| 2147 | |
| 2148 | TEST_PRE_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec) |
| 2149 | TEST_POST_VIDEOENGINE_INIT(WebRtcVideoEngineTest, ConstrainRunningCodec) |
| 2150 | |
| 2151 | // TODO(juberti): Figure out why ViE is munging the COM refcount. |
| 2152 | #ifdef WIN32 |
| 2153 | TEST_F(WebRtcVideoEngineTest, DISABLED_CheckCoInitialize) { |
| 2154 | Base::CheckCoInitialize(); |
| 2155 | } |
| 2156 | #endif |
| 2157 | |
| 2158 | TEST_F(WebRtcVideoEngineTest, CreateChannel) { |
| 2159 | EXPECT_TRUE(engine_.Init(talk_base::Thread::Current())); |
| 2160 | cricket::VideoMediaChannel* channel = engine_.CreateChannel(NULL); |
| 2161 | EXPECT_TRUE(channel != NULL); |
| 2162 | delete channel; |
| 2163 | } |
| 2164 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2165 | TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecs) { |
| 2166 | std::vector<cricket::VideoCodec> codecs; |
| 2167 | codecs.push_back(kVP8Codec); |
| 2168 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 2169 | } |
| 2170 | TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsWrongPayloadType) { |
| 2171 | std::vector<cricket::VideoCodec> codecs; |
| 2172 | codecs.push_back(kVP8Codec); |
| 2173 | codecs[0].id = 99; |
| 2174 | EXPECT_TRUE(channel_->SetRecvCodecs(codecs)); |
| 2175 | } |
| 2176 | TEST_F(WebRtcVideoMediaChannelTest, SetRecvCodecsUnsupportedCodec) { |
| 2177 | std::vector<cricket::VideoCodec> codecs; |
| 2178 | codecs.push_back(kVP8Codec); |
| 2179 | codecs.push_back(cricket::VideoCodec(101, "VP1", 640, 400, 30, 0)); |
| 2180 | EXPECT_FALSE(channel_->SetRecvCodecs(codecs)); |
| 2181 | } |
| 2182 | |
mallinath@webrtc.org | 92fdfeb | 2014-02-17 18:49:41 +0000 | [diff] [blame] | 2183 | TEST_F(WebRtcVideoMediaChannelTest, GetRtpSendTimeExtension) { |
| 2184 | // Enable RTP timestamp extension. |
| 2185 | const int id = 12; |
| 2186 | std::vector<cricket::RtpHeaderExtension> extensions; |
| 2187 | extensions.push_back(cricket::RtpHeaderExtension( |
| 2188 | "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time", id)); |
| 2189 | |
| 2190 | // Verify the send extension id. |
| 2191 | EXPECT_TRUE(channel_->SetSendRtpHeaderExtensions(extensions)); |
| 2192 | EXPECT_EQ(id, channel_->GetRtpSendTimeExtnId()); |
| 2193 | } |
| 2194 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2195 | TEST_F(WebRtcVideoMediaChannelTest, SetSend) { |
| 2196 | Base::SetSend(); |
| 2197 | } |
| 2198 | TEST_F(WebRtcVideoMediaChannelTest, SetSendWithoutCodecs) { |
| 2199 | Base::SetSendWithoutCodecs(); |
| 2200 | } |
| 2201 | TEST_F(WebRtcVideoMediaChannelTest, SetSendSetsTransportBufferSizes) { |
| 2202 | Base::SetSendSetsTransportBufferSizes(); |
| 2203 | } |
| 2204 | |
| 2205 | TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Vga) { |
| 2206 | SendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 2207 | } |
| 2208 | TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveVp8Qvga) { |
| 2209 | SendAndReceive(cricket::VideoCodec(100, "VP8", 320, 200, 30, 0)); |
| 2210 | } |
| 2211 | TEST_F(WebRtcVideoMediaChannelTest, SendAndReceiveH264SvcQqvga) { |
| 2212 | SendAndReceive(cricket::VideoCodec(100, "VP8", 160, 100, 30, 0)); |
| 2213 | } |
| 2214 | TEST_F(WebRtcVideoMediaChannelTest, SendManyResizeOnce) { |
| 2215 | SendManyResizeOnce(); |
| 2216 | } |
| 2217 | |
buildbot@webrtc.org | ce4201d | 2014-05-21 16:22:51 +0000 | [diff] [blame^] | 2218 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_SendVp8HdAndReceiveAdaptedVp8Vga) { |
henrike@webrtc.org | 28654cb | 2013-07-22 21:07:49 +0000 | [diff] [blame] | 2219 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, NULL)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2220 | channel_->UpdateAspectRatio(1280, 720); |
| 2221 | video_capturer_.reset(new cricket::FakeVideoCapturer); |
| 2222 | const std::vector<cricket::VideoFormat>* formats = |
| 2223 | video_capturer_->GetSupportedFormats(); |
| 2224 | cricket::VideoFormat capture_format_hd = (*formats)[0]; |
| 2225 | EXPECT_EQ(cricket::CS_RUNNING, video_capturer_->Start(capture_format_hd)); |
| 2226 | EXPECT_TRUE(channel_->SetCapturer(kSsrc, video_capturer_.get())); |
| 2227 | |
| 2228 | // Capture format HD -> adapt (OnOutputFormatRequest VGA) -> VGA. |
| 2229 | cricket::VideoCodec codec(100, "VP8", 1280, 720, 30, 0); |
| 2230 | EXPECT_TRUE(SetOneCodec(codec)); |
| 2231 | codec.width /= 2; |
| 2232 | codec.height /= 2; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2233 | EXPECT_TRUE(SetSend(true)); |
| 2234 | EXPECT_TRUE(channel_->SetRender(true)); |
| 2235 | EXPECT_EQ(0, renderer_.num_rendered_frames()); |
| 2236 | EXPECT_TRUE(SendFrame()); |
| 2237 | EXPECT_FRAME_WAIT(1, codec.width, codec.height, kTimeout); |
| 2238 | } |
| 2239 | |
| 2240 | // TODO(juberti): Fix this test to tolerate missing stats. |
| 2241 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStats) { |
| 2242 | Base::GetStats(); |
| 2243 | } |
| 2244 | |
| 2245 | // TODO(juberti): Fix this test to tolerate missing stats. |
| 2246 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_GetStatsMultipleRecvStreams) { |
| 2247 | Base::GetStatsMultipleRecvStreams(); |
| 2248 | } |
| 2249 | |
| 2250 | TEST_F(WebRtcVideoMediaChannelTest, GetStatsMultipleSendStreams) { |
| 2251 | Base::GetStatsMultipleSendStreams(); |
| 2252 | } |
| 2253 | |
| 2254 | TEST_F(WebRtcVideoMediaChannelTest, SetSendBandwidth) { |
| 2255 | Base::SetSendBandwidth(); |
| 2256 | } |
| 2257 | TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrc) { |
| 2258 | Base::SetSendSsrc(); |
| 2259 | } |
| 2260 | TEST_F(WebRtcVideoMediaChannelTest, SetSendSsrcAfterSetCodecs) { |
| 2261 | Base::SetSendSsrcAfterSetCodecs(); |
| 2262 | } |
| 2263 | |
| 2264 | TEST_F(WebRtcVideoMediaChannelTest, SetRenderer) { |
| 2265 | Base::SetRenderer(); |
| 2266 | } |
| 2267 | |
| 2268 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreams) { |
| 2269 | Base::AddRemoveRecvStreams(); |
| 2270 | } |
| 2271 | |
| 2272 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamAndRender) { |
| 2273 | Base::AddRemoveRecvStreamAndRender(); |
| 2274 | } |
| 2275 | |
| 2276 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveRecvStreamsNoConference) { |
| 2277 | Base::AddRemoveRecvStreamsNoConference(); |
| 2278 | } |
| 2279 | |
| 2280 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveSendStreams) { |
| 2281 | Base::AddRemoveSendStreams(); |
| 2282 | } |
| 2283 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2284 | TEST_F(WebRtcVideoMediaChannelTest, SimulateConference) { |
| 2285 | Base::SimulateConference(); |
| 2286 | } |
| 2287 | |
| 2288 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturer) { |
| 2289 | Base::AddRemoveCapturer(); |
| 2290 | } |
| 2291 | |
| 2292 | TEST_F(WebRtcVideoMediaChannelTest, RemoveCapturerWithoutAdd) { |
| 2293 | Base::RemoveCapturerWithoutAdd(); |
| 2294 | } |
| 2295 | |
| 2296 | TEST_F(WebRtcVideoMediaChannelTest, AddRemoveCapturerMultipleSources) { |
| 2297 | Base::AddRemoveCapturerMultipleSources(); |
| 2298 | } |
| 2299 | |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 2300 | // This test verifies DSCP settings are properly applied on video media channel. |
| 2301 | TEST_F(WebRtcVideoMediaChannelTest, TestSetDscpOptions) { |
| 2302 | talk_base::scoped_ptr<cricket::FakeNetworkInterface> network_interface( |
| 2303 | new cricket::FakeNetworkInterface); |
| 2304 | channel_->SetInterface(network_interface.get()); |
| 2305 | cricket::VideoOptions options; |
| 2306 | options.dscp.Set(true); |
| 2307 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 2308 | EXPECT_EQ(talk_base::DSCP_AF41, network_interface->dscp()); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 +0000 | [diff] [blame] | 2309 | // Verify previous value is not modified if dscp option is not set. |
| 2310 | cricket::VideoOptions options1; |
| 2311 | EXPECT_TRUE(channel_->SetOptions(options1)); |
| 2312 | EXPECT_EQ(talk_base::DSCP_AF41, network_interface->dscp()); |
wu@webrtc.org | de30501 | 2013-10-31 15:40:38 +0000 | [diff] [blame] | 2313 | options.dscp.Set(false); |
| 2314 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 2315 | EXPECT_EQ(talk_base::DSCP_DEFAULT, network_interface->dscp()); |
| 2316 | channel_->SetInterface(NULL); |
| 2317 | } |
| 2318 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 2319 | |
| 2320 | TEST_F(WebRtcVideoMediaChannelTest, SetOptionsSucceedsWhenSending) { |
| 2321 | cricket::VideoOptions options; |
| 2322 | options.conference_mode.Set(true); |
| 2323 | EXPECT_TRUE(channel_->SetOptions(options)); |
| 2324 | |
| 2325 | // Verify SetOptions returns true on a different options. |
| 2326 | cricket::VideoOptions options2; |
| 2327 | options2.adapt_input_to_cpu_usage.Set(true); |
| 2328 | EXPECT_TRUE(channel_->SetOptions(options2)); |
| 2329 | |
| 2330 | // Set send codecs on the channel and start sending. |
| 2331 | std::vector<cricket::VideoCodec> codecs; |
| 2332 | codecs.push_back(kVP8Codec); |
| 2333 | EXPECT_TRUE(channel_->SetSendCodecs(codecs)); |
| 2334 | EXPECT_TRUE(channel_->SetSend(true)); |
| 2335 | |
| 2336 | // Verify SetOptions returns true if channel is already sending. |
| 2337 | cricket::VideoOptions options3; |
| 2338 | options3.conference_mode.Set(true); |
| 2339 | EXPECT_TRUE(channel_->SetOptions(options3)); |
| 2340 | } |
| 2341 | |
| 2342 | // Tests empty StreamParams is rejected. |
| 2343 | TEST_F(WebRtcVideoMediaChannelTest, RejectEmptyStreamParams) { |
| 2344 | Base::RejectEmptyStreamParams(); |
| 2345 | } |
| 2346 | |
| 2347 | |
| 2348 | TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution16x10) { |
| 2349 | Base::AdaptResolution16x10(); |
| 2350 | } |
| 2351 | |
| 2352 | TEST_F(WebRtcVideoMediaChannelTest, AdaptResolution4x3) { |
| 2353 | Base::AdaptResolution4x3(); |
| 2354 | } |
| 2355 | |
| 2356 | TEST_F(WebRtcVideoMediaChannelTest, MuteStream) { |
| 2357 | Base::MuteStream(); |
| 2358 | } |
| 2359 | |
| 2360 | TEST_F(WebRtcVideoMediaChannelTest, MultipleSendStreams) { |
| 2361 | Base::MultipleSendStreams(); |
| 2362 | } |
| 2363 | |
| 2364 | // TODO(juberti): Restore this test once we support sending 0 fps. |
| 2365 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptDropAllFrames) { |
| 2366 | Base::AdaptDropAllFrames(); |
| 2367 | } |
| 2368 | // TODO(juberti): Understand why we get decode errors on this test. |
| 2369 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_AdaptFramerate) { |
| 2370 | Base::AdaptFramerate(); |
| 2371 | } |
| 2372 | |
| 2373 | TEST_F(WebRtcVideoMediaChannelTest, SetSendStreamFormat0x0) { |
| 2374 | Base::SetSendStreamFormat0x0(); |
| 2375 | } |
| 2376 | |
| 2377 | // TODO(zhurunz): Fix the flakey test. |
| 2378 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_SetSendStreamFormat) { |
| 2379 | Base::SetSendStreamFormat(); |
| 2380 | } |
| 2381 | |
| 2382 | TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsSendAndReceive) { |
| 2383 | Base::TwoStreamsSendAndReceive(cricket::VideoCodec(100, "VP8", 640, 400, 30, |
| 2384 | 0)); |
| 2385 | } |
| 2386 | |
| 2387 | TEST_F(WebRtcVideoMediaChannelTest, TwoStreamsReUseFirstStream) { |
| 2388 | Base::TwoStreamsReUseFirstStream(cricket::VideoCodec(100, "VP8", 640, 400, 30, |
| 2389 | 0)); |
| 2390 | } |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2391 | |
buildbot@webrtc.org | 0b3c6c3 | 2014-04-17 10:03:57 +0000 | [diff] [blame] | 2392 | TEST_F(WebRtcVideoMediaChannelTest, DISABLED_TwoStreamsSendAndUnsignalledRecv) { |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2393 | Base::TwoStreamsSendAndUnsignalledRecv(cricket::VideoCodec(100, "VP8", 640, |
| 2394 | 400, 30, 0)); |
| 2395 | } |
| 2396 | |
henrike@webrtc.org | 806768a | 2014-02-27 21:03:09 +0000 | [diff] [blame] | 2397 | TEST_F(WebRtcVideoMediaChannelTest, |
henrike@webrtc.org | 18e5911 | 2014-03-14 17:19:38 +0000 | [diff] [blame] | 2398 | TwoStreamsSendAndFailUnsignalledRecv) { |
henrike@webrtc.org | 806768a | 2014-02-27 21:03:09 +0000 | [diff] [blame] | 2399 | webrtc::Trace::set_level_filter(webrtc::kTraceAll); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2400 | Base::TwoStreamsSendAndFailUnsignalledRecv( |
| 2401 | cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 2402 | } |
| 2403 | |
| 2404 | TEST_F(WebRtcVideoMediaChannelTest, |
henrike@webrtc.org | 18e5911 | 2014-03-14 17:19:38 +0000 | [diff] [blame] | 2405 | TwoStreamsSendAndFailUnsignalledRecvInOneToOne) { |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2406 | Base::TwoStreamsSendAndFailUnsignalledRecvInOneToOne( |
| 2407 | cricket::VideoCodec(100, "VP8", 640, 400, 30, 0)); |
| 2408 | } |
| 2409 | |
| 2410 | TEST_F(WebRtcVideoMediaChannelTest, |
henrike@webrtc.org | 18e5911 | 2014-03-14 17:19:38 +0000 | [diff] [blame] | 2411 | TwoStreamsAddAndRemoveUnsignalledRecv) { |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 2412 | Base::TwoStreamsAddAndRemoveUnsignalledRecv(cricket::VideoCodec(100, "VP8", |
| 2413 | 640, 400, 30, |
| 2414 | 0)); |
| 2415 | } |