OLD | NEW |
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 Loading... |
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 3112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3383 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); | 3378 EXPECT_TRUE((local_offer)->Initialize(offer_str, NULL)); |
3384 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); | 3379 SetLocalDescriptionOfferExpectError(kBundleWithoutRtcpMux, local_offer); |
3385 JsepSessionDescription* remote_offer = | 3380 JsepSessionDescription* remote_offer = |
3386 new JsepSessionDescription(JsepSessionDescription::kOffer); | 3381 new JsepSessionDescription(JsepSessionDescription::kOffer); |
3387 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); | 3382 EXPECT_TRUE((remote_offer)->Initialize(offer_str, NULL)); |
3388 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); | 3383 SetRemoteDescriptionOfferExpectError(kBundleWithoutRtcpMux, remote_offer); |
3389 // Trying unmodified SDP. | 3384 // Trying unmodified SDP. |
3390 SetLocalDescriptionWithoutError(offer); | 3385 SetLocalDescriptionWithoutError(offer); |
3391 } | 3386 } |
3392 | 3387 |
3393 TEST_F(WebRtcSessionTest, SetAudioPlayout) { | |
3394 Init(); | |
3395 SendAudioVideoStream1(); | |
3396 CreateAndSetRemoteOfferAndLocalAnswer(); | |
3397 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | |
3398 ASSERT_TRUE(channel != NULL); | |
3399 ASSERT_EQ(1u, channel->recv_streams().size()); | |
3400 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); | |
3401 double volume; | |
3402 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); | |
3403 EXPECT_EQ(1, volume); | |
3404 session_->SetAudioPlayout(receive_ssrc, false); | |
3405 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); | |
3406 EXPECT_EQ(0, volume); | |
3407 session_->SetAudioPlayout(receive_ssrc, true); | |
3408 EXPECT_TRUE(channel->GetOutputVolume(receive_ssrc, &volume)); | |
3409 EXPECT_EQ(1, volume); | |
3410 } | |
3411 | |
3412 TEST_F(WebRtcSessionTest, SetAudioMaxSendBitrate) { | |
3413 Init(); | |
3414 SendAudioVideoStream1(); | |
3415 CreateAndSetRemoteOfferAndLocalAnswer(); | |
3416 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | |
3417 ASSERT_TRUE(channel != NULL); | |
3418 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | |
3419 EXPECT_EQ(-1, channel->max_bps()); | |
3420 webrtc::RtpParameters params = session_->GetAudioRtpSendParameters(send_ssrc); | |
3421 EXPECT_EQ(1, params.encodings.size()); | |
3422 EXPECT_EQ(-1, params.encodings[0].max_bitrate_bps); | |
3423 params.encodings[0].max_bitrate_bps = 1000; | |
3424 EXPECT_TRUE(session_->SetAudioRtpSendParameters(send_ssrc, params)); | |
3425 | |
3426 // Read back the parameters and verify they have been changed. | |
3427 params = session_->GetAudioRtpSendParameters(send_ssrc); | |
3428 EXPECT_EQ(1, params.encodings.size()); | |
3429 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps); | |
3430 | |
3431 // Verify that the audio channel received the new parameters. | |
3432 params = channel->GetRtpSendParameters(send_ssrc); | |
3433 EXPECT_EQ(1, params.encodings.size()); | |
3434 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps); | |
3435 | |
3436 // Verify that the global bitrate limit has not been changed. | |
3437 EXPECT_EQ(-1, channel->max_bps()); | |
3438 } | |
3439 | |
3440 TEST_F(WebRtcSessionTest, SetAudioSend) { | |
3441 Init(); | |
3442 SendAudioVideoStream1(); | |
3443 CreateAndSetRemoteOfferAndLocalAnswer(); | |
3444 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | |
3445 ASSERT_TRUE(channel != NULL); | |
3446 ASSERT_EQ(1u, channel->send_streams().size()); | |
3447 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | |
3448 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | |
3449 | |
3450 cricket::AudioOptions options; | |
3451 options.echo_cancellation = rtc::Optional<bool>(true); | |
3452 | |
3453 std::unique_ptr<FakeAudioSource> source(new FakeAudioSource()); | |
3454 session_->SetAudioSend(send_ssrc, false, options, source.get()); | |
3455 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); | |
3456 EXPECT_EQ(rtc::Optional<bool>(), channel->options().echo_cancellation); | |
3457 EXPECT_TRUE(source->sink() != nullptr); | |
3458 | |
3459 // This will trigger SetSink(nullptr) to the |source|. | |
3460 session_->SetAudioSend(send_ssrc, true, options, nullptr); | |
3461 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | |
3462 EXPECT_EQ(rtc::Optional<bool>(true), channel->options().echo_cancellation); | |
3463 EXPECT_TRUE(source->sink() == nullptr); | |
3464 } | |
3465 | |
3466 TEST_F(WebRtcSessionTest, AudioSourceForLocalStream) { | |
3467 Init(); | |
3468 SendAudioVideoStream1(); | |
3469 CreateAndSetRemoteOfferAndLocalAnswer(); | |
3470 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | |
3471 ASSERT_TRUE(channel != NULL); | |
3472 ASSERT_EQ(1u, channel->send_streams().size()); | |
3473 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | |
3474 | |
3475 std::unique_ptr<FakeAudioSource> source(new FakeAudioSource()); | |
3476 cricket::AudioOptions options; | |
3477 session_->SetAudioSend(send_ssrc, true, options, source.get()); | |
3478 EXPECT_TRUE(source->sink() != nullptr); | |
3479 | |
3480 // Delete the |source| and it will trigger OnClose() to the sink, and this | |
3481 // will invalidate the |source_| pointer in the sink and prevent getting a | |
3482 // SetSink(nullptr) callback afterwards. | |
3483 source.reset(); | |
3484 | |
3485 // This will trigger SetSink(nullptr) if no OnClose() callback. | |
3486 session_->SetAudioSend(send_ssrc, true, options, nullptr); | |
3487 } | |
3488 | |
3489 TEST_F(WebRtcSessionTest, SetVideoPlayout) { | |
3490 Init(); | |
3491 SendAudioVideoStream1(); | |
3492 CreateAndSetRemoteOfferAndLocalAnswer(); | |
3493 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | |
3494 ASSERT_TRUE(channel != NULL); | |
3495 ASSERT_LT(0u, channel->sinks().size()); | |
3496 EXPECT_TRUE(channel->sinks().begin()->second == NULL); | |
3497 ASSERT_EQ(1u, channel->recv_streams().size()); | |
3498 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); | |
3499 cricket::FakeVideoRenderer renderer; | |
3500 session_->SetVideoPlayout(receive_ssrc, true, &renderer); | |
3501 EXPECT_TRUE(channel->sinks().begin()->second == &renderer); | |
3502 session_->SetVideoPlayout(receive_ssrc, false, &renderer); | |
3503 EXPECT_TRUE(channel->sinks().begin()->second == NULL); | |
3504 } | |
3505 | |
3506 TEST_F(WebRtcSessionTest, SetVideoMaxSendBitrate) { | |
3507 Init(); | |
3508 SendAudioVideoStream1(); | |
3509 CreateAndSetRemoteOfferAndLocalAnswer(); | |
3510 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | |
3511 ASSERT_TRUE(channel != NULL); | |
3512 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | |
3513 EXPECT_EQ(-1, channel->max_bps()); | |
3514 webrtc::RtpParameters params = session_->GetVideoRtpSendParameters(send_ssrc); | |
3515 EXPECT_EQ(1, params.encodings.size()); | |
3516 EXPECT_EQ(-1, params.encodings[0].max_bitrate_bps); | |
3517 params.encodings[0].max_bitrate_bps = 1000; | |
3518 EXPECT_TRUE(session_->SetVideoRtpSendParameters(send_ssrc, params)); | |
3519 | |
3520 // Read back the parameters and verify they have been changed. | |
3521 params = session_->GetVideoRtpSendParameters(send_ssrc); | |
3522 EXPECT_EQ(1, params.encodings.size()); | |
3523 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps); | |
3524 | |
3525 // Verify that the video channel received the new parameters. | |
3526 params = channel->GetRtpSendParameters(send_ssrc); | |
3527 EXPECT_EQ(1, params.encodings.size()); | |
3528 EXPECT_EQ(1000, params.encodings[0].max_bitrate_bps); | |
3529 | |
3530 // Verify that the global bitrate limit has not been changed. | |
3531 EXPECT_EQ(-1, channel->max_bps()); | |
3532 } | |
3533 | |
3534 TEST_F(WebRtcSessionTest, SetVideoSend) { | |
3535 Init(); | |
3536 SendAudioVideoStream1(); | |
3537 CreateAndSetRemoteOfferAndLocalAnswer(); | |
3538 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | |
3539 ASSERT_TRUE(channel != NULL); | |
3540 ASSERT_EQ(1u, channel->send_streams().size()); | |
3541 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); | |
3542 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | |
3543 cricket::VideoOptions* options = NULL; | |
3544 session_->SetVideoSend(send_ssrc, false, options, nullptr); | |
3545 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); | |
3546 session_->SetVideoSend(send_ssrc, true, options, nullptr); | |
3547 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | |
3548 } | |
3549 | |
3550 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { | 3388 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { |
3551 TestCanInsertDtmf(false); | 3389 TestCanInsertDtmf(false); |
3552 } | 3390 } |
3553 | 3391 |
3554 TEST_F(WebRtcSessionTest, CanInsertDtmf) { | 3392 TEST_F(WebRtcSessionTest, CanInsertDtmf) { |
3555 TestCanInsertDtmf(true); | 3393 TestCanInsertDtmf(true); |
3556 } | 3394 } |
3557 | 3395 |
3558 TEST_F(WebRtcSessionTest, InsertDtmf) { | 3396 TEST_F(WebRtcSessionTest, InsertDtmf) { |
3559 // Setup | 3397 // Setup |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4417 } | 4255 } |
4418 | 4256 |
4419 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4257 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4420 // currently fails because upon disconnection and reconnection OnIceComplete is | 4258 // currently fails because upon disconnection and reconnection OnIceComplete is |
4421 // called more than once without returning to IceGatheringGathering. | 4259 // called more than once without returning to IceGatheringGathering. |
4422 | 4260 |
4423 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4261 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4424 WebRtcSessionTest, | 4262 WebRtcSessionTest, |
4425 testing::Values(ALREADY_GENERATED, | 4263 testing::Values(ALREADY_GENERATED, |
4426 DTLS_IDENTITY_STORE)); | 4264 DTLS_IDENTITY_STORE)); |
OLD | NEW |