OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1433 ASSERT_EQ(1u, voice_channel_->send_streams().size()); | 1433 ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
1434 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); | 1434 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); |
1435 | 1435 |
1436 // Create new offer without send streams. | 1436 // Create new offer without send streams. |
1437 mediastream_signaling_.SendNothing(); | 1437 mediastream_signaling_.SendNothing(); |
1438 offer = CreateOffer(); | 1438 offer = CreateOffer(); |
1439 | 1439 |
1440 // Verify the session id is the same and the session version is | 1440 // Verify the session id is the same and the session version is |
1441 // increased. | 1441 // increased. |
1442 EXPECT_EQ(session_id_orig, offer->session_id()); | 1442 EXPECT_EQ(session_id_orig, offer->session_id()); |
1443 EXPECT_LT(rtc::FromString<uint64>(session_version_orig), | 1443 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), |
1444 rtc::FromString<uint64>(offer->session_version())); | 1444 rtc::FromString<uint64_t>(offer->session_version())); |
1445 | 1445 |
1446 SetLocalDescriptionWithoutError(offer); | 1446 SetLocalDescriptionWithoutError(offer); |
1447 EXPECT_EQ(0u, video_channel_->send_streams().size()); | 1447 EXPECT_EQ(0u, video_channel_->send_streams().size()); |
1448 EXPECT_EQ(0u, voice_channel_->send_streams().size()); | 1448 EXPECT_EQ(0u, voice_channel_->send_streams().size()); |
1449 | 1449 |
1450 mediastream_signaling_.SendAudioVideoStream2(); | 1450 mediastream_signaling_.SendAudioVideoStream2(); |
1451 answer = CreateRemoteAnswer(session_->local_description()); | 1451 answer = CreateRemoteAnswer(session_->local_description()); |
1452 SetRemoteDescriptionWithoutError(answer); | 1452 SetRemoteDescriptionWithoutError(answer); |
1453 | 1453 |
1454 // Make sure the receive streams have not changed. | 1454 // Make sure the receive streams have not changed. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 offer = CreateOffer(); | 1493 offer = CreateOffer(); |
1494 SetRemoteDescriptionWithoutError(offer); | 1494 SetRemoteDescriptionWithoutError(offer); |
1495 | 1495 |
1496 // Answer by turning off all send streams. | 1496 // Answer by turning off all send streams. |
1497 mediastream_signaling_.SendNothing(); | 1497 mediastream_signaling_.SendNothing(); |
1498 answer = CreateAnswer(NULL); | 1498 answer = CreateAnswer(NULL); |
1499 | 1499 |
1500 // Verify the session id is the same and the session version is | 1500 // Verify the session id is the same and the session version is |
1501 // increased. | 1501 // increased. |
1502 EXPECT_EQ(session_id_orig, answer->session_id()); | 1502 EXPECT_EQ(session_id_orig, answer->session_id()); |
1503 EXPECT_LT(rtc::FromString<uint64>(session_version_orig), | 1503 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), |
1504 rtc::FromString<uint64>(answer->session_version())); | 1504 rtc::FromString<uint64_t>(answer->session_version())); |
1505 SetLocalDescriptionWithoutError(answer); | 1505 SetLocalDescriptionWithoutError(answer); |
1506 | 1506 |
1507 ASSERT_EQ(2u, video_channel_->recv_streams().size()); | 1507 ASSERT_EQ(2u, video_channel_->recv_streams().size()); |
1508 EXPECT_TRUE(kVideoTrack1 == video_channel_->recv_streams()[0].id); | 1508 EXPECT_TRUE(kVideoTrack1 == video_channel_->recv_streams()[0].id); |
1509 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[1].id); | 1509 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[1].id); |
1510 ASSERT_EQ(2u, voice_channel_->recv_streams().size()); | 1510 ASSERT_EQ(2u, voice_channel_->recv_streams().size()); |
1511 EXPECT_TRUE(kAudioTrack1 == voice_channel_->recv_streams()[0].id); | 1511 EXPECT_TRUE(kAudioTrack1 == voice_channel_->recv_streams()[0].id); |
1512 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[1].id); | 1512 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[1].id); |
1513 | 1513 |
1514 // Make sure we have no send streams. | 1514 // Make sure we have no send streams. |
(...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 SetLocalDescriptionWithoutError(offer); | 3003 SetLocalDescriptionWithoutError(offer); |
3004 } | 3004 } |
3005 | 3005 |
3006 TEST_F(WebRtcSessionTest, SetAudioPlayout) { | 3006 TEST_F(WebRtcSessionTest, SetAudioPlayout) { |
3007 Init(); | 3007 Init(); |
3008 mediastream_signaling_.SendAudioVideoStream1(); | 3008 mediastream_signaling_.SendAudioVideoStream1(); |
3009 CreateAndSetRemoteOfferAndLocalAnswer(); | 3009 CreateAndSetRemoteOfferAndLocalAnswer(); |
3010 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3010 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3011 ASSERT_TRUE(channel != NULL); | 3011 ASSERT_TRUE(channel != NULL); |
3012 ASSERT_EQ(1u, channel->recv_streams().size()); | 3012 ASSERT_EQ(1u, channel->recv_streams().size()); |
3013 uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); | 3013 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); |
3014 double left_vol, right_vol; | 3014 double left_vol, right_vol; |
3015 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); | 3015 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
3016 EXPECT_EQ(1, left_vol); | 3016 EXPECT_EQ(1, left_vol); |
3017 EXPECT_EQ(1, right_vol); | 3017 EXPECT_EQ(1, right_vol); |
3018 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3018 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
3019 session_->SetAudioPlayout(receive_ssrc, false, renderer.get()); | 3019 session_->SetAudioPlayout(receive_ssrc, false, renderer.get()); |
3020 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); | 3020 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
3021 EXPECT_EQ(0, left_vol); | 3021 EXPECT_EQ(0, left_vol); |
3022 EXPECT_EQ(0, right_vol); | 3022 EXPECT_EQ(0, right_vol); |
3023 EXPECT_EQ(0, renderer->channel_id()); | 3023 EXPECT_EQ(0, renderer->channel_id()); |
3024 session_->SetAudioPlayout(receive_ssrc, true, NULL); | 3024 session_->SetAudioPlayout(receive_ssrc, true, NULL); |
3025 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); | 3025 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
3026 EXPECT_EQ(1, left_vol); | 3026 EXPECT_EQ(1, left_vol); |
3027 EXPECT_EQ(1, right_vol); | 3027 EXPECT_EQ(1, right_vol); |
3028 EXPECT_EQ(-1, renderer->channel_id()); | 3028 EXPECT_EQ(-1, renderer->channel_id()); |
3029 } | 3029 } |
3030 | 3030 |
3031 TEST_F(WebRtcSessionTest, SetAudioSend) { | 3031 TEST_F(WebRtcSessionTest, SetAudioSend) { |
3032 Init(); | 3032 Init(); |
3033 mediastream_signaling_.SendAudioVideoStream1(); | 3033 mediastream_signaling_.SendAudioVideoStream1(); |
3034 CreateAndSetRemoteOfferAndLocalAnswer(); | 3034 CreateAndSetRemoteOfferAndLocalAnswer(); |
3035 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3035 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3036 ASSERT_TRUE(channel != NULL); | 3036 ASSERT_TRUE(channel != NULL); |
3037 ASSERT_EQ(1u, channel->send_streams().size()); | 3037 ASSERT_EQ(1u, channel->send_streams().size()); |
3038 uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3038 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3039 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3039 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3040 | 3040 |
3041 cricket::AudioOptions options; | 3041 cricket::AudioOptions options; |
3042 options.echo_cancellation.Set(true); | 3042 options.echo_cancellation.Set(true); |
3043 | 3043 |
3044 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3044 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
3045 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); | 3045 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); |
3046 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); | 3046 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); |
3047 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); | 3047 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); |
3048 EXPECT_EQ(0, renderer->channel_id()); | 3048 EXPECT_EQ(0, renderer->channel_id()); |
3049 EXPECT_TRUE(renderer->sink() != NULL); | 3049 EXPECT_TRUE(renderer->sink() != NULL); |
3050 | 3050 |
3051 // This will trigger SetSink(NULL) to the |renderer|. | 3051 // This will trigger SetSink(NULL) to the |renderer|. |
3052 session_->SetAudioSend(send_ssrc, true, options, NULL); | 3052 session_->SetAudioSend(send_ssrc, true, options, NULL); |
3053 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3053 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3054 bool value; | 3054 bool value; |
3055 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); | 3055 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); |
3056 EXPECT_TRUE(value); | 3056 EXPECT_TRUE(value); |
3057 EXPECT_EQ(-1, renderer->channel_id()); | 3057 EXPECT_EQ(-1, renderer->channel_id()); |
3058 EXPECT_TRUE(renderer->sink() == NULL); | 3058 EXPECT_TRUE(renderer->sink() == NULL); |
3059 } | 3059 } |
3060 | 3060 |
3061 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { | 3061 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { |
3062 Init(); | 3062 Init(); |
3063 mediastream_signaling_.SendAudioVideoStream1(); | 3063 mediastream_signaling_.SendAudioVideoStream1(); |
3064 CreateAndSetRemoteOfferAndLocalAnswer(); | 3064 CreateAndSetRemoteOfferAndLocalAnswer(); |
3065 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3065 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3066 ASSERT_TRUE(channel != NULL); | 3066 ASSERT_TRUE(channel != NULL); |
3067 ASSERT_EQ(1u, channel->send_streams().size()); | 3067 ASSERT_EQ(1u, channel->send_streams().size()); |
3068 uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3068 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3069 | 3069 |
3070 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3070 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
3071 cricket::AudioOptions options; | 3071 cricket::AudioOptions options; |
3072 session_->SetAudioSend(send_ssrc, true, options, renderer.get()); | 3072 session_->SetAudioSend(send_ssrc, true, options, renderer.get()); |
3073 EXPECT_TRUE(renderer->sink() != NULL); | 3073 EXPECT_TRUE(renderer->sink() != NULL); |
3074 | 3074 |
3075 // Delete the |renderer| and it will trigger OnClose() to the sink, and this | 3075 // Delete the |renderer| and it will trigger OnClose() to the sink, and this |
3076 // will invalidate the |renderer_| pointer in the sink and prevent getting a | 3076 // will invalidate the |renderer_| pointer in the sink and prevent getting a |
3077 // SetSink(NULL) callback afterwards. | 3077 // SetSink(NULL) callback afterwards. |
3078 renderer.reset(); | 3078 renderer.reset(); |
3079 | 3079 |
3080 // This will trigger SetSink(NULL) if no OnClose() callback. | 3080 // This will trigger SetSink(NULL) if no OnClose() callback. |
3081 session_->SetAudioSend(send_ssrc, true, options, NULL); | 3081 session_->SetAudioSend(send_ssrc, true, options, NULL); |
3082 } | 3082 } |
3083 | 3083 |
3084 TEST_F(WebRtcSessionTest, SetVideoPlayout) { | 3084 TEST_F(WebRtcSessionTest, SetVideoPlayout) { |
3085 Init(); | 3085 Init(); |
3086 mediastream_signaling_.SendAudioVideoStream1(); | 3086 mediastream_signaling_.SendAudioVideoStream1(); |
3087 CreateAndSetRemoteOfferAndLocalAnswer(); | 3087 CreateAndSetRemoteOfferAndLocalAnswer(); |
3088 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | 3088 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); |
3089 ASSERT_TRUE(channel != NULL); | 3089 ASSERT_TRUE(channel != NULL); |
3090 ASSERT_LT(0u, channel->renderers().size()); | 3090 ASSERT_LT(0u, channel->renderers().size()); |
3091 EXPECT_TRUE(channel->renderers().begin()->second == NULL); | 3091 EXPECT_TRUE(channel->renderers().begin()->second == NULL); |
3092 ASSERT_EQ(1u, channel->recv_streams().size()); | 3092 ASSERT_EQ(1u, channel->recv_streams().size()); |
3093 uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); | 3093 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); |
3094 cricket::FakeVideoRenderer renderer; | 3094 cricket::FakeVideoRenderer renderer; |
3095 session_->SetVideoPlayout(receive_ssrc, true, &renderer); | 3095 session_->SetVideoPlayout(receive_ssrc, true, &renderer); |
3096 EXPECT_TRUE(channel->renderers().begin()->second == &renderer); | 3096 EXPECT_TRUE(channel->renderers().begin()->second == &renderer); |
3097 session_->SetVideoPlayout(receive_ssrc, false, &renderer); | 3097 session_->SetVideoPlayout(receive_ssrc, false, &renderer); |
3098 EXPECT_TRUE(channel->renderers().begin()->second == NULL); | 3098 EXPECT_TRUE(channel->renderers().begin()->second == NULL); |
3099 } | 3099 } |
3100 | 3100 |
3101 TEST_F(WebRtcSessionTest, SetVideoSend) { | 3101 TEST_F(WebRtcSessionTest, SetVideoSend) { |
3102 Init(); | 3102 Init(); |
3103 mediastream_signaling_.SendAudioVideoStream1(); | 3103 mediastream_signaling_.SendAudioVideoStream1(); |
3104 CreateAndSetRemoteOfferAndLocalAnswer(); | 3104 CreateAndSetRemoteOfferAndLocalAnswer(); |
3105 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | 3105 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); |
3106 ASSERT_TRUE(channel != NULL); | 3106 ASSERT_TRUE(channel != NULL); |
3107 ASSERT_EQ(1u, channel->send_streams().size()); | 3107 ASSERT_EQ(1u, channel->send_streams().size()); |
3108 uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3108 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3109 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3109 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3110 cricket::VideoOptions* options = NULL; | 3110 cricket::VideoOptions* options = NULL; |
3111 session_->SetVideoSend(send_ssrc, false, options); | 3111 session_->SetVideoSend(send_ssrc, false, options); |
3112 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); | 3112 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); |
3113 session_->SetVideoSend(send_ssrc, true, options); | 3113 session_->SetVideoSend(send_ssrc, true, options); |
3114 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3114 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3115 } | 3115 } |
3116 | 3116 |
3117 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { | 3117 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { |
3118 TestCanInsertDtmf(false); | 3118 TestCanInsertDtmf(false); |
(...skipping 13 matching lines...) Expand all Loading... |
3132 | 3132 |
3133 // Insert DTMF | 3133 // Insert DTMF |
3134 const int expected_flags = DF_SEND; | 3134 const int expected_flags = DF_SEND; |
3135 const int expected_duration = 90; | 3135 const int expected_duration = 90; |
3136 session_->InsertDtmf(kAudioTrack1, 0, expected_duration); | 3136 session_->InsertDtmf(kAudioTrack1, 0, expected_duration); |
3137 session_->InsertDtmf(kAudioTrack1, 1, expected_duration); | 3137 session_->InsertDtmf(kAudioTrack1, 1, expected_duration); |
3138 session_->InsertDtmf(kAudioTrack1, 2, expected_duration); | 3138 session_->InsertDtmf(kAudioTrack1, 2, expected_duration); |
3139 | 3139 |
3140 // Verify | 3140 // Verify |
3141 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); | 3141 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); |
3142 const uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3142 const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3143 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, | 3143 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, |
3144 expected_duration, expected_flags)); | 3144 expected_duration, expected_flags)); |
3145 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, | 3145 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, |
3146 expected_duration, expected_flags)); | 3146 expected_duration, expected_flags)); |
3147 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, | 3147 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, |
3148 expected_duration, expected_flags)); | 3148 expected_duration, expected_flags)); |
3149 } | 3149 } |
3150 | 3150 |
3151 // This test verifies the |initiator| flag when session initiates the call. | 3151 // This test verifies the |initiator| flag when session initiates the call. |
3152 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { | 3152 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3937 } | 3937 } |
3938 } | 3938 } |
3939 | 3939 |
3940 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 3940 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
3941 // currently fails because upon disconnection and reconnection OnIceComplete is | 3941 // currently fails because upon disconnection and reconnection OnIceComplete is |
3942 // called more than once without returning to IceGatheringGathering. | 3942 // called more than once without returning to IceGatheringGathering. |
3943 | 3943 |
3944 INSTANTIATE_TEST_CASE_P( | 3944 INSTANTIATE_TEST_CASE_P( |
3945 WebRtcSessionTests, WebRtcSessionTest, | 3945 WebRtcSessionTests, WebRtcSessionTest, |
3946 testing::Values(ALREADY_GENERATED, DTLS_IDENTITY_STORE)); | 3946 testing::Values(ALREADY_GENERATED, DTLS_IDENTITY_STORE)); |
OLD | NEW |