Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: webrtc/api/webrtcsession_unittest.cc

Issue 2046173002: Use VoiceChannel/VideoChannel directly from RtpSender/RtpReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Moving code that needs to execute out of RTC_DCHECKs. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/media/base/fakemediaengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 246 }
247 247
248 cricket::TransportChannel* data_rtp_transport_channel() { 248 cricket::TransportChannel* data_rtp_transport_channel() {
249 return rtp_transport_channel(data_channel()); 249 return rtp_transport_channel(data_channel());
250 } 250 }
251 251
252 cricket::TransportChannel* data_rtcp_transport_channel() { 252 cricket::TransportChannel* data_rtcp_transport_channel() {
253 return rtcp_transport_channel(data_channel()); 253 return rtcp_transport_channel(data_channel());
254 } 254 }
255 255
256 using webrtc::WebRtcSession::SetAudioPlayout;
257 using webrtc::WebRtcSession::SetAudioSend;
258 using webrtc::WebRtcSession::SetVideoPlayout;
259 using webrtc::WebRtcSession::SetVideoSend;
260
261 private: 256 private:
262 cricket::TransportChannel* rtp_transport_channel(cricket::BaseChannel* ch) { 257 cricket::TransportChannel* rtp_transport_channel(cricket::BaseChannel* ch) {
263 if (!ch) { 258 if (!ch) {
264 return nullptr; 259 return nullptr;
265 } 260 }
266 return ch->transport_channel(); 261 return ch->transport_channel();
267 } 262 }
268 263
269 cricket::TransportChannel* rtcp_transport_channel(cricket::BaseChannel* ch) { 264 cricket::TransportChannel* rtcp_transport_channel(cricket::BaseChannel* ch) {
270 if (!ch) { 265 if (!ch) {
(...skipping 3114 matching lines...) Expand 10 before | Expand all | Expand 10 after
3385 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); 3380 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL));
3386 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); 3381 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer);
3387 JsepSessionDescription* remote_offer = 3382 JsepSessionDescription* remote_offer =
3388 new JsepSessionDescription(JsepSessionDescription::kOffer); 3383 new JsepSessionDescription(JsepSessionDescription::kOffer);
3389 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); 3384 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL));
3390 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); 3385 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer);
3391 // Trying unmodified SDP. 3386 // Trying unmodified SDP.
3392 SetLocalDescriptionWithoutError(offer); 3387 SetLocalDescriptionWithoutError(offer);
3393 } 3388 }
3394 3389
3395 TEST_F(WebRtcSessionTest, SetAudioPlayout) {
3396 Init();
3397 SendAudioVideoStream1();
3398 CreateAndSetRemoteOfferAndLocalAnswer();
3399 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3400 ASSERT_TRUE(channel != NULL);
3401 ASSERT_EQ(1u, channel->recv_streams().size());
3402 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
3403 double volume;
3404 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3405 EXPECT_EQ(1, volume);
3406 session_->SetAudioPlayout(receive_ssrc, false);
3407 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3408 EXPECT_EQ(0, volume);
3409 session_->SetAudioPlayout(receive_ssrc, true);
3410 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume));
3411 EXPECT_EQ(1, volume);
3412 }
3413
3414 TEST_F(WebRtcSessionTest, SetAudioMaxSendBitrate) {
3415 Init();
3416 SendAudioVideoStream1();
3417 CreateAndSetRemoteOfferAndLocalAnswer();
3418 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3419 ASSERT_TRUE(channel != NULL);
3420 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3421 EXPECT_EQ(-1, channel->max_bps());
3422 webrtc::RtpParameters params = session_->GetAudioRtpSendParameters(send_ssrc);
3423 EXPECT_EQ(1, params.encodings.size());
3424 EXPECT_EQ(-1, params.encodings[0].max_bitrate_bps);
3425 params.encodings[0].max_bitrate_bps = 1000;
3426 EXPECT_TRUE(session_->SetAudioRtpSendParameters(send_ssrc, params));
3427
3428 // Read back the parameters and verify they have been changed.
3429 params = session_->GetAudioRtpSendParameters(send_ssrc);
3430 EXPECT_EQ(1, params.encodings.size());
3431 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
3432
3433 // Verify that the audio channel received the new parameters.
3434 params = channel->GetRtpSendParameters(send_ssrc);
3435 EXPECT_EQ(1, params.encodings.size());
3436 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
3437
3438 // Verify that the global bitrate limit has not been changed.
3439 EXPECT_EQ(-1, channel->max_bps());
3440 }
3441
3442 TEST_F(WebRtcSessionTest, SetAudioSend) {
3443 Init();
3444 SendAudioVideoStream1();
3445 CreateAndSetRemoteOfferAndLocalAnswer();
3446 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3447 ASSERT_TRUE(channel != NULL);
3448 ASSERT_EQ(1u, channel->send_streams().size());
3449 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3450 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3451
3452 cricket::AudioOptions options;
3453 options.echo_cancellation = rtc::Optional<bool>(true);
3454
3455 std::unique_ptr<FakeAudioSource> source(new FakeAudioSource());
3456 session_->SetAudioSend(send_ssrc, false, options, source.get());
3457 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3458 EXPECT_EQ(rtc::Optional<bool>(), channel->options().echo_cancellation);
3459 EXPECT_TRUE(source->sink() != nullptr);
3460
3461 // This will trigger SetSink(nullptr) to the |source|.
3462 session_->SetAudioSend(send_ssrc, true, options, nullptr);
3463 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3464 EXPECT_EQ(rtc::Optional<bool>(true), channel->options().echo_cancellation);
3465 EXPECT_TRUE(source->sink() == nullptr);
3466 }
3467
3468 TEST_F(WebRtcSessionTest, AudioSourceForLocalStream) {
3469 Init();
3470 SendAudioVideoStream1();
3471 CreateAndSetRemoteOfferAndLocalAnswer();
3472 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0);
3473 ASSERT_TRUE(channel != NULL);
3474 ASSERT_EQ(1u, channel->send_streams().size());
3475 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3476
3477 std::unique_ptr<FakeAudioSource> source(new FakeAudioSource());
3478 cricket::AudioOptions options;
3479 session_->SetAudioSend(send_ssrc, true, options, source.get());
3480 EXPECT_TRUE(source->sink() != nullptr);
3481
3482 // Delete the |source| and it will trigger OnClose() to the sink, and this
3483 // will invalidate the |source_| pointer in the sink and prevent getting a
3484 // SetSink(nullptr) callback afterwards.
3485 source.reset();
3486
3487 // This will trigger SetSink(nullptr) if no OnClose() callback.
3488 session_->SetAudioSend(send_ssrc, true, options, nullptr);
3489 }
3490
3491 TEST_F(WebRtcSessionTest, SetVideoPlayout) {
3492 Init();
3493 SendAudioVideoStream1();
3494 CreateAndSetRemoteOfferAndLocalAnswer();
3495 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0);
3496 ASSERT_TRUE(channel != NULL);
3497 ASSERT_LT(0u, channel->sinks().size());
3498 EXPECT_TRUE(channel->sinks().begin()->second == NULL);
3499 ASSERT_EQ(1u, channel->recv_streams().size());
3500 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc();
3501 cricket::FakeVideoRenderer renderer;
3502 session_->SetVideoPlayout(receive_ssrc, true, &renderer);
3503 EXPECT_TRUE(channel->sinks().begin()->second == &renderer);
3504 session_->SetVideoPlayout(receive_ssrc, false, &renderer);
3505 EXPECT_TRUE(channel->sinks().begin()->second == NULL);
3506 }
3507
3508 TEST_F(WebRtcSessionTest, SetVideoMaxSendBitrate) {
3509 Init();
3510 SendAudioVideoStream1();
3511 CreateAndSetRemoteOfferAndLocalAnswer();
3512 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0);
3513 ASSERT_TRUE(channel != NULL);
3514 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3515 EXPECT_EQ(-1, channel->max_bps());
3516 webrtc::RtpParameters params = session_->GetVideoRtpSendParameters(send_ssrc);
3517 EXPECT_EQ(1, params.encodings.size());
3518 EXPECT_EQ(-1, params.encodings[0].max_bitrate_bps);
3519 params.encodings[0].max_bitrate_bps = 1000;
3520 EXPECT_TRUE(session_->SetVideoRtpSendParameters(send_ssrc, params));
3521
3522 // Read back the parameters and verify they have been changed.
3523 params = session_->GetVideoRtpSendParameters(send_ssrc);
3524 EXPECT_EQ(1, params.encodings.size());
3525 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
3526
3527 // Verify that the video channel received the new parameters.
3528 params = channel->GetRtpSendParameters(send_ssrc);
3529 EXPECT_EQ(1, params.encodings.size());
3530 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps);
3531
3532 // Verify that the global bitrate limit has not been changed.
3533 EXPECT_EQ(-1, channel->max_bps());
3534 }
3535
3536 TEST_F(WebRtcSessionTest, SetVideoSend) {
3537 Init();
3538 SendAudioVideoStream1();
3539 CreateAndSetRemoteOfferAndLocalAnswer();
3540 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0);
3541 ASSERT_TRUE(channel != NULL);
3542 ASSERT_EQ(1u, channel->send_streams().size());
3543 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc();
3544 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3545 cricket::VideoOptions* options = NULL;
3546 session_->SetVideoSend(send_ssrc, false, options, nullptr);
3547 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc));
3548 session_->SetVideoSend(send_ssrc, true, options, nullptr);
3549 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc));
3550 }
3551
3552 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { 3390 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) {
3553 TestCanInsertDtmf(false); 3391 TestCanInsertDtmf(false);
3554 } 3392 }
3555 3393
3556 TEST_F(WebRtcSessionTest, CanInsertDtmf) { 3394 TEST_F(WebRtcSessionTest, CanInsertDtmf) {
3557 TestCanInsertDtmf(true); 3395 TestCanInsertDtmf(true);
3558 } 3396 }
3559 3397
3560 TEST_F(WebRtcSessionTest, InsertDtmf) { 3398 TEST_F(WebRtcSessionTest, InsertDtmf) {
3561 // Setup 3399 // Setup
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 } 4257 }
4420 4258
4421 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test 4259 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test
4422 // currently fails because upon disconnection and reconnection OnIceComplete is 4260 // currently fails because upon disconnection and reconnection OnIceComplete is
4423 // called more than once without returning to IceGatheringGathering. 4261 // called more than once without returning to IceGatheringGathering.
4424 4262
4425 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, 4263 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests,
4426 WebRtcSessionTest, 4264 WebRtcSessionTest,
4427 testing::Values(ALREADY_GENERATED, 4265 testing::Values(ALREADY_GENERATED,
4428 DTLS_IDENTITY_STORE)); 4266 DTLS_IDENTITY_STORE));
OLDNEW
« no previous file with comments | « webrtc/api/webrtcsession.cc ('k') | webrtc/media/base/fakemediaengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698