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 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 ASSERT_EQ(1u, voice_channel_->send_streams().size()); | 1458 ASSERT_EQ(1u, voice_channel_->send_streams().size()); |
1459 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); | 1459 EXPECT_TRUE(kAudioTrack1 == voice_channel_->send_streams()[0].id); |
1460 | 1460 |
1461 // Create new offer without send streams. | 1461 // Create new offer without send streams. |
1462 mediastream_signaling_.SendNothing(); | 1462 mediastream_signaling_.SendNothing(); |
1463 offer = CreateOffer(); | 1463 offer = CreateOffer(); |
1464 | 1464 |
1465 // Verify the session id is the same and the session version is | 1465 // Verify the session id is the same and the session version is |
1466 // increased. | 1466 // increased. |
1467 EXPECT_EQ(session_id_orig, offer->session_id()); | 1467 EXPECT_EQ(session_id_orig, offer->session_id()); |
1468 EXPECT_LT(rtc::FromString<uint64>(session_version_orig), | 1468 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), |
1469 rtc::FromString<uint64>(offer->session_version())); | 1469 rtc::FromString<uint64_t>(offer->session_version())); |
1470 | 1470 |
1471 SetLocalDescriptionWithoutError(offer); | 1471 SetLocalDescriptionWithoutError(offer); |
1472 EXPECT_EQ(0u, video_channel_->send_streams().size()); | 1472 EXPECT_EQ(0u, video_channel_->send_streams().size()); |
1473 EXPECT_EQ(0u, voice_channel_->send_streams().size()); | 1473 EXPECT_EQ(0u, voice_channel_->send_streams().size()); |
1474 | 1474 |
1475 mediastream_signaling_.SendAudioVideoStream2(); | 1475 mediastream_signaling_.SendAudioVideoStream2(); |
1476 answer = CreateRemoteAnswer(session_->local_description()); | 1476 answer = CreateRemoteAnswer(session_->local_description()); |
1477 SetRemoteDescriptionWithoutError(answer); | 1477 SetRemoteDescriptionWithoutError(answer); |
1478 | 1478 |
1479 // Make sure the receive streams have not changed. | 1479 // Make sure the receive streams have not changed. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 offer = CreateOffer(); | 1518 offer = CreateOffer(); |
1519 SetRemoteDescriptionWithoutError(offer); | 1519 SetRemoteDescriptionWithoutError(offer); |
1520 | 1520 |
1521 // Answer by turning off all send streams. | 1521 // Answer by turning off all send streams. |
1522 mediastream_signaling_.SendNothing(); | 1522 mediastream_signaling_.SendNothing(); |
1523 answer = CreateAnswer(NULL); | 1523 answer = CreateAnswer(NULL); |
1524 | 1524 |
1525 // Verify the session id is the same and the session version is | 1525 // Verify the session id is the same and the session version is |
1526 // increased. | 1526 // increased. |
1527 EXPECT_EQ(session_id_orig, answer->session_id()); | 1527 EXPECT_EQ(session_id_orig, answer->session_id()); |
1528 EXPECT_LT(rtc::FromString<uint64>(session_version_orig), | 1528 EXPECT_LT(rtc::FromString<uint64_t>(session_version_orig), |
1529 rtc::FromString<uint64>(answer->session_version())); | 1529 rtc::FromString<uint64_t>(answer->session_version())); |
1530 SetLocalDescriptionWithoutError(answer); | 1530 SetLocalDescriptionWithoutError(answer); |
1531 | 1531 |
1532 ASSERT_EQ(2u, video_channel_->recv_streams().size()); | 1532 ASSERT_EQ(2u, video_channel_->recv_streams().size()); |
1533 EXPECT_TRUE(kVideoTrack1 == video_channel_->recv_streams()[0].id); | 1533 EXPECT_TRUE(kVideoTrack1 == video_channel_->recv_streams()[0].id); |
1534 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[1].id); | 1534 EXPECT_TRUE(kVideoTrack2 == video_channel_->recv_streams()[1].id); |
1535 ASSERT_EQ(2u, voice_channel_->recv_streams().size()); | 1535 ASSERT_EQ(2u, voice_channel_->recv_streams().size()); |
1536 EXPECT_TRUE(kAudioTrack1 == voice_channel_->recv_streams()[0].id); | 1536 EXPECT_TRUE(kAudioTrack1 == voice_channel_->recv_streams()[0].id); |
1537 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[1].id); | 1537 EXPECT_TRUE(kAudioTrack2 == voice_channel_->recv_streams()[1].id); |
1538 | 1538 |
1539 // Make sure we have no send streams. | 1539 // Make sure we have no send streams. |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3100 SetLocalDescriptionWithoutError(offer); | 3100 SetLocalDescriptionWithoutError(offer); |
3101 } | 3101 } |
3102 | 3102 |
3103 TEST_F(WebRtcSessionTest, SetAudioPlayout) { | 3103 TEST_F(WebRtcSessionTest, SetAudioPlayout) { |
3104 Init(); | 3104 Init(); |
3105 mediastream_signaling_.SendAudioVideoStream1(); | 3105 mediastream_signaling_.SendAudioVideoStream1(); |
3106 CreateAndSetRemoteOfferAndLocalAnswer(); | 3106 CreateAndSetRemoteOfferAndLocalAnswer(); |
3107 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3107 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3108 ASSERT_TRUE(channel != NULL); | 3108 ASSERT_TRUE(channel != NULL); |
3109 ASSERT_EQ(1u, channel->recv_streams().size()); | 3109 ASSERT_EQ(1u, channel->recv_streams().size()); |
3110 uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); | 3110 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); |
3111 double left_vol, right_vol; | 3111 double left_vol, right_vol; |
3112 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); | 3112 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
3113 EXPECT_EQ(1, left_vol); | 3113 EXPECT_EQ(1, left_vol); |
3114 EXPECT_EQ(1, right_vol); | 3114 EXPECT_EQ(1, right_vol); |
3115 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3115 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
3116 session_->SetAudioPlayout(receive_ssrc, false, renderer.get()); | 3116 session_->SetAudioPlayout(receive_ssrc, false, renderer.get()); |
3117 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); | 3117 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
3118 EXPECT_EQ(0, left_vol); | 3118 EXPECT_EQ(0, left_vol); |
3119 EXPECT_EQ(0, right_vol); | 3119 EXPECT_EQ(0, right_vol); |
3120 EXPECT_EQ(0, renderer->channel_id()); | 3120 EXPECT_EQ(0, renderer->channel_id()); |
3121 session_->SetAudioPlayout(receive_ssrc, true, NULL); | 3121 session_->SetAudioPlayout(receive_ssrc, true, NULL); |
3122 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); | 3122 EXPECT_TRUE(channel->GetOutputScaling(receive_ssrc, &left_vol, &right_vol)); |
3123 EXPECT_EQ(1, left_vol); | 3123 EXPECT_EQ(1, left_vol); |
3124 EXPECT_EQ(1, right_vol); | 3124 EXPECT_EQ(1, right_vol); |
3125 EXPECT_EQ(-1, renderer->channel_id()); | 3125 EXPECT_EQ(-1, renderer->channel_id()); |
3126 } | 3126 } |
3127 | 3127 |
3128 TEST_F(WebRtcSessionTest, SetAudioSend) { | 3128 TEST_F(WebRtcSessionTest, SetAudioSend) { |
3129 Init(); | 3129 Init(); |
3130 mediastream_signaling_.SendAudioVideoStream1(); | 3130 mediastream_signaling_.SendAudioVideoStream1(); |
3131 CreateAndSetRemoteOfferAndLocalAnswer(); | 3131 CreateAndSetRemoteOfferAndLocalAnswer(); |
3132 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3132 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3133 ASSERT_TRUE(channel != NULL); | 3133 ASSERT_TRUE(channel != NULL); |
3134 ASSERT_EQ(1u, channel->send_streams().size()); | 3134 ASSERT_EQ(1u, channel->send_streams().size()); |
3135 uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3135 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3136 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3136 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3137 | 3137 |
3138 cricket::AudioOptions options; | 3138 cricket::AudioOptions options; |
3139 options.echo_cancellation.Set(true); | 3139 options.echo_cancellation.Set(true); |
3140 | 3140 |
3141 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3141 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
3142 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); | 3142 session_->SetAudioSend(send_ssrc, false, options, renderer.get()); |
3143 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); | 3143 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); |
3144 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); | 3144 EXPECT_FALSE(channel->options().echo_cancellation.IsSet()); |
3145 EXPECT_EQ(0, renderer->channel_id()); | 3145 EXPECT_EQ(0, renderer->channel_id()); |
3146 EXPECT_TRUE(renderer->sink() != NULL); | 3146 EXPECT_TRUE(renderer->sink() != NULL); |
3147 | 3147 |
3148 // This will trigger SetSink(NULL) to the |renderer|. | 3148 // This will trigger SetSink(NULL) to the |renderer|. |
3149 session_->SetAudioSend(send_ssrc, true, options, NULL); | 3149 session_->SetAudioSend(send_ssrc, true, options, NULL); |
3150 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3150 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3151 bool value; | 3151 bool value; |
3152 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); | 3152 EXPECT_TRUE(channel->options().echo_cancellation.Get(&value)); |
3153 EXPECT_TRUE(value); | 3153 EXPECT_TRUE(value); |
3154 EXPECT_EQ(-1, renderer->channel_id()); | 3154 EXPECT_EQ(-1, renderer->channel_id()); |
3155 EXPECT_TRUE(renderer->sink() == NULL); | 3155 EXPECT_TRUE(renderer->sink() == NULL); |
3156 } | 3156 } |
3157 | 3157 |
3158 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { | 3158 TEST_F(WebRtcSessionTest, AudioRendererForLocalStream) { |
3159 Init(); | 3159 Init(); |
3160 mediastream_signaling_.SendAudioVideoStream1(); | 3160 mediastream_signaling_.SendAudioVideoStream1(); |
3161 CreateAndSetRemoteOfferAndLocalAnswer(); | 3161 CreateAndSetRemoteOfferAndLocalAnswer(); |
3162 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); | 3162 cricket::FakeVoiceMediaChannel* channel = media_engine_->GetVoiceChannel(0); |
3163 ASSERT_TRUE(channel != NULL); | 3163 ASSERT_TRUE(channel != NULL); |
3164 ASSERT_EQ(1u, channel->send_streams().size()); | 3164 ASSERT_EQ(1u, channel->send_streams().size()); |
3165 uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3165 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3166 | 3166 |
3167 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); | 3167 rtc::scoped_ptr<FakeAudioRenderer> renderer(new FakeAudioRenderer()); |
3168 cricket::AudioOptions options; | 3168 cricket::AudioOptions options; |
3169 session_->SetAudioSend(send_ssrc, true, options, renderer.get()); | 3169 session_->SetAudioSend(send_ssrc, true, options, renderer.get()); |
3170 EXPECT_TRUE(renderer->sink() != NULL); | 3170 EXPECT_TRUE(renderer->sink() != NULL); |
3171 | 3171 |
3172 // Delete the |renderer| and it will trigger OnClose() to the sink, and this | 3172 // Delete the |renderer| and it will trigger OnClose() to the sink, and this |
3173 // will invalidate the |renderer_| pointer in the sink and prevent getting a | 3173 // will invalidate the |renderer_| pointer in the sink and prevent getting a |
3174 // SetSink(NULL) callback afterwards. | 3174 // SetSink(NULL) callback afterwards. |
3175 renderer.reset(); | 3175 renderer.reset(); |
3176 | 3176 |
3177 // This will trigger SetSink(NULL) if no OnClose() callback. | 3177 // This will trigger SetSink(NULL) if no OnClose() callback. |
3178 session_->SetAudioSend(send_ssrc, true, options, NULL); | 3178 session_->SetAudioSend(send_ssrc, true, options, NULL); |
3179 } | 3179 } |
3180 | 3180 |
3181 TEST_F(WebRtcSessionTest, SetVideoPlayout) { | 3181 TEST_F(WebRtcSessionTest, SetVideoPlayout) { |
3182 Init(); | 3182 Init(); |
3183 mediastream_signaling_.SendAudioVideoStream1(); | 3183 mediastream_signaling_.SendAudioVideoStream1(); |
3184 CreateAndSetRemoteOfferAndLocalAnswer(); | 3184 CreateAndSetRemoteOfferAndLocalAnswer(); |
3185 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | 3185 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); |
3186 ASSERT_TRUE(channel != NULL); | 3186 ASSERT_TRUE(channel != NULL); |
3187 ASSERT_LT(0u, channel->renderers().size()); | 3187 ASSERT_LT(0u, channel->renderers().size()); |
3188 EXPECT_TRUE(channel->renderers().begin()->second == NULL); | 3188 EXPECT_TRUE(channel->renderers().begin()->second == NULL); |
3189 ASSERT_EQ(1u, channel->recv_streams().size()); | 3189 ASSERT_EQ(1u, channel->recv_streams().size()); |
3190 uint32 receive_ssrc = channel->recv_streams()[0].first_ssrc(); | 3190 uint32_t receive_ssrc = channel->recv_streams()[0].first_ssrc(); |
3191 cricket::FakeVideoRenderer renderer; | 3191 cricket::FakeVideoRenderer renderer; |
3192 session_->SetVideoPlayout(receive_ssrc, true, &renderer); | 3192 session_->SetVideoPlayout(receive_ssrc, true, &renderer); |
3193 EXPECT_TRUE(channel->renderers().begin()->second == &renderer); | 3193 EXPECT_TRUE(channel->renderers().begin()->second == &renderer); |
3194 session_->SetVideoPlayout(receive_ssrc, false, &renderer); | 3194 session_->SetVideoPlayout(receive_ssrc, false, &renderer); |
3195 EXPECT_TRUE(channel->renderers().begin()->second == NULL); | 3195 EXPECT_TRUE(channel->renderers().begin()->second == NULL); |
3196 } | 3196 } |
3197 | 3197 |
3198 TEST_F(WebRtcSessionTest, SetVideoSend) { | 3198 TEST_F(WebRtcSessionTest, SetVideoSend) { |
3199 Init(); | 3199 Init(); |
3200 mediastream_signaling_.SendAudioVideoStream1(); | 3200 mediastream_signaling_.SendAudioVideoStream1(); |
3201 CreateAndSetRemoteOfferAndLocalAnswer(); | 3201 CreateAndSetRemoteOfferAndLocalAnswer(); |
3202 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); | 3202 cricket::FakeVideoMediaChannel* channel = media_engine_->GetVideoChannel(0); |
3203 ASSERT_TRUE(channel != NULL); | 3203 ASSERT_TRUE(channel != NULL); |
3204 ASSERT_EQ(1u, channel->send_streams().size()); | 3204 ASSERT_EQ(1u, channel->send_streams().size()); |
3205 uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3205 uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3206 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3206 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3207 cricket::VideoOptions* options = NULL; | 3207 cricket::VideoOptions* options = NULL; |
3208 session_->SetVideoSend(send_ssrc, false, options); | 3208 session_->SetVideoSend(send_ssrc, false, options); |
3209 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); | 3209 EXPECT_TRUE(channel->IsStreamMuted(send_ssrc)); |
3210 session_->SetVideoSend(send_ssrc, true, options); | 3210 session_->SetVideoSend(send_ssrc, true, options); |
3211 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); | 3211 EXPECT_FALSE(channel->IsStreamMuted(send_ssrc)); |
3212 } | 3212 } |
3213 | 3213 |
3214 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { | 3214 TEST_F(WebRtcSessionTest, CanNotInsertDtmf) { |
3215 TestCanInsertDtmf(false); | 3215 TestCanInsertDtmf(false); |
(...skipping 13 matching lines...) Expand all Loading... |
3229 | 3229 |
3230 // Insert DTMF | 3230 // Insert DTMF |
3231 const int expected_flags = DF_SEND; | 3231 const int expected_flags = DF_SEND; |
3232 const int expected_duration = 90; | 3232 const int expected_duration = 90; |
3233 session_->InsertDtmf(kAudioTrack1, 0, expected_duration); | 3233 session_->InsertDtmf(kAudioTrack1, 0, expected_duration); |
3234 session_->InsertDtmf(kAudioTrack1, 1, expected_duration); | 3234 session_->InsertDtmf(kAudioTrack1, 1, expected_duration); |
3235 session_->InsertDtmf(kAudioTrack1, 2, expected_duration); | 3235 session_->InsertDtmf(kAudioTrack1, 2, expected_duration); |
3236 | 3236 |
3237 // Verify | 3237 // Verify |
3238 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); | 3238 ASSERT_EQ(3U, channel->dtmf_info_queue().size()); |
3239 const uint32 send_ssrc = channel->send_streams()[0].first_ssrc(); | 3239 const uint32_t send_ssrc = channel->send_streams()[0].first_ssrc(); |
3240 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, | 3240 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[0], send_ssrc, 0, |
3241 expected_duration, expected_flags)); | 3241 expected_duration, expected_flags)); |
3242 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, | 3242 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[1], send_ssrc, 1, |
3243 expected_duration, expected_flags)); | 3243 expected_duration, expected_flags)); |
3244 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, | 3244 EXPECT_TRUE(CompareDtmfInfo(channel->dtmf_info_queue()[2], send_ssrc, 2, |
3245 expected_duration, expected_flags)); | 3245 expected_duration, expected_flags)); |
3246 } | 3246 } |
3247 | 3247 |
3248 // This test verifies the |initiator| flag when session initiates the call. | 3248 // This test verifies the |initiator| flag when session initiates the call. |
3249 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { | 3249 TEST_F(WebRtcSessionTest, TestInitiatorFlagAsOriginator) { |
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4033 } | 4033 } |
4034 | 4034 |
4035 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test | 4035 // TODO(bemasc): Add a TestIceStatesBundle with BUNDLE enabled. That test |
4036 // currently fails because upon disconnection and reconnection OnIceComplete is | 4036 // currently fails because upon disconnection and reconnection OnIceComplete is |
4037 // called more than once without returning to IceGatheringGathering. | 4037 // called more than once without returning to IceGatheringGathering. |
4038 | 4038 |
4039 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, | 4039 INSTANTIATE_TEST_CASE_P(WebRtcSessionTests, |
4040 WebRtcSessionTest, | 4040 WebRtcSessionTest, |
4041 testing::Values(ALREADY_GENERATED, | 4041 testing::Values(ALREADY_GENERATED, |
4042 DTLS_IDENTITY_STORE)); | 4042 DTLS_IDENTITY_STORE)); |
OLD | NEW |