OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2008 Google Inc. | 3 * Copyright 2008 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, |
11 * this list of conditions and the following disclaimer in the documentation | 11 * this list of conditions and the following disclaimer in the documentation |
12 * and/or other materials provided with the distribution. | 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 | 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. | 14 * derived from this software without specific prior written permission. |
15 * | 15 * |
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | 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 | 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | 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, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 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 | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #ifdef WIN32 | |
29 #include "webrtc/base/win32.h" | |
30 #include <objbase.h> | |
31 #endif | |
32 | |
33 #include "webrtc/base/byteorder.h" | 28 #include "webrtc/base/byteorder.h" |
34 #include "webrtc/base/gunit.h" | 29 #include "webrtc/base/gunit.h" |
35 #include "talk/media/base/constants.h" | 30 #include "talk/media/base/constants.h" |
36 #include "talk/media/base/fakemediaengine.h" | 31 #include "talk/media/base/fakemediaengine.h" |
37 #include "talk/media/base/fakemediaprocessor.h" | 32 #include "talk/media/base/fakemediaprocessor.h" |
38 #include "talk/media/base/fakenetworkinterface.h" | 33 #include "talk/media/base/fakenetworkinterface.h" |
39 #include "talk/media/base/fakertp.h" | 34 #include "talk/media/base/fakertp.h" |
40 #include "talk/media/webrtc/fakewebrtccall.h" | 35 #include "talk/media/webrtc/fakewebrtccall.h" |
41 #include "talk/media/webrtc/fakewebrtcvoiceengine.h" | 36 #include "talk/media/webrtc/fakewebrtcvoiceengine.h" |
42 #include "talk/media/webrtc/webrtcvoiceengine.h" | 37 #include "talk/media/webrtc/webrtcvoiceengine.h" |
(...skipping 3085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3128 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); | 3123 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); |
3129 // Verify previous value is not modified if dscp option is not set. | 3124 // Verify previous value is not modified if dscp option is not set. |
3130 cricket::AudioOptions options1; | 3125 cricket::AudioOptions options1; |
3131 EXPECT_TRUE(channel->SetOptions(options1)); | 3126 EXPECT_TRUE(channel->SetOptions(options1)); |
3132 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); | 3127 EXPECT_EQ(rtc::DSCP_EF, network_interface->dscp()); |
3133 options.dscp.Set(false); | 3128 options.dscp.Set(false); |
3134 EXPECT_TRUE(channel->SetOptions(options)); | 3129 EXPECT_TRUE(channel->SetOptions(options)); |
3135 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); | 3130 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); |
3136 } | 3131 } |
3137 | 3132 |
3138 TEST(WebRtcVoiceEngineTest, TestDefaultOptionsBeforeInit) { | |
3139 cricket::WebRtcVoiceEngine engine; | |
3140 cricket::AudioOptions options = engine.GetOptions(); | |
3141 // The default options should have at least a few things set. We purposefully | |
3142 // don't check the option values here, though. | |
3143 EXPECT_TRUE(options.echo_cancellation.IsSet()); | |
3144 EXPECT_TRUE(options.auto_gain_control.IsSet()); | |
3145 EXPECT_TRUE(options.noise_suppression.IsSet()); | |
3146 } | |
3147 | |
3148 // Test that GetReceiveChannelNum returns the default channel for the first | 3133 // Test that GetReceiveChannelNum returns the default channel for the first |
3149 // recv stream in 1-1 calls. | 3134 // recv stream in 1-1 calls. |
3150 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) { | 3135 TEST_F(WebRtcVoiceEngineTestFake, TestGetReceiveChannelNumIn1To1Calls) { |
3151 EXPECT_TRUE(SetupEngine()); | 3136 EXPECT_TRUE(SetupEngine()); |
3152 cricket::WebRtcVoiceMediaChannel* media_channel = | 3137 cricket::WebRtcVoiceMediaChannel* media_channel = |
3153 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | 3138 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
3154 // Test that GetChannelNum returns the default channel if the SSRC is unknown. | 3139 // Test that GetChannelNum returns the default channel if the SSRC is unknown. |
3155 EXPECT_EQ(media_channel->voe_channel(), | 3140 EXPECT_EQ(media_channel->voe_channel(), |
3156 media_channel->GetReceiveChannelNum(0)); | 3141 media_channel->GetReceiveChannelNum(0)); |
3157 cricket::StreamParams stream; | 3142 cricket::StreamParams stream; |
(...skipping 29 matching lines...) Expand all Loading... |
3187 cricket::StreamParams stream; | 3172 cricket::StreamParams stream; |
3188 stream.ssrcs.push_back(kSsrc2); | 3173 stream.ssrcs.push_back(kSsrc2); |
3189 EXPECT_TRUE(channel_->AddRecvStream(stream)); | 3174 EXPECT_TRUE(channel_->AddRecvStream(stream)); |
3190 | 3175 |
3191 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); | 3176 EXPECT_TRUE(channel_->SetOutputScaling(kSsrc2, 2, 1)); |
3192 EXPECT_TRUE(channel_->GetOutputScaling(kSsrc2, &left, &right)); | 3177 EXPECT_TRUE(channel_->GetOutputScaling(kSsrc2, &left, &right)); |
3193 EXPECT_DOUBLE_EQ(2, left); | 3178 EXPECT_DOUBLE_EQ(2, left); |
3194 EXPECT_DOUBLE_EQ(1, right); | 3179 EXPECT_DOUBLE_EQ(1, right); |
3195 } | 3180 } |
3196 | 3181 |
| 3182 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { |
| 3183 cricket::FakeCall call((webrtc::Call::Config())); |
| 3184 const uint32 kAudioSsrc = 123; |
| 3185 const std::string kSyncLabel = "AvSyncLabel"; |
| 3186 |
| 3187 EXPECT_TRUE(SetupEngine()); |
| 3188 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3189 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3190 media_channel->SetCall(&call); |
| 3191 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); |
| 3192 sp.sync_label = kSyncLabel; |
| 3193 // Creating two channels to make sure that sync label is set properly for both |
| 3194 // the default voice channel and following ones. |
| 3195 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 3196 sp.ssrcs[0] += 1; |
| 3197 EXPECT_TRUE(channel_->AddRecvStream(sp)); |
| 3198 |
| 3199 ASSERT_EQ(2, call.GetAudioReceiveStreams().size()); |
| 3200 EXPECT_EQ(kSyncLabel, |
| 3201 call.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) |
| 3202 << "SyncGroup should be set based on sync_label"; |
| 3203 EXPECT_EQ(kSyncLabel, |
| 3204 call.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) |
| 3205 << "SyncGroup should be set based on sync_label"; |
| 3206 |
| 3207 media_channel->SetCall(nullptr); |
| 3208 } |
| 3209 |
| 3210 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { |
| 3211 // Test that changing the combined_audio_video_bwe option results in the |
| 3212 // expected state changes on an associated Call. |
| 3213 cricket::FakeCall call((webrtc::Call::Config())); |
| 3214 const uint32 kAudioSsrc1 = 223; |
| 3215 const uint32 kAudioSsrc2 = 224; |
| 3216 |
| 3217 EXPECT_TRUE(SetupEngine()); |
| 3218 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3219 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3220 const auto& rtp_extensions = engine_.rtp_header_extensions(); |
| 3221 media_channel->SetRecvRtpHeaderExtensions(rtp_extensions); |
| 3222 media_channel->SetCall(&call); |
| 3223 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3224 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); |
| 3225 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3226 cricket::StreamParams::CreateLegacy(kAudioSsrc2))); |
| 3227 |
| 3228 // Combined BWE should not be set up yet. |
| 3229 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); |
| 3230 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1) |
| 3231 ->GetConfig() |
| 3232 .combined_audio_video_bwe); |
| 3233 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) |
| 3234 ->GetConfig() |
| 3235 .combined_audio_video_bwe); |
| 3236 |
| 3237 // Enable combined BWE option - now it should be set up. |
| 3238 cricket::AudioOptions options; |
| 3239 options.combined_audio_video_bwe.Set(true); |
| 3240 EXPECT_TRUE(media_channel->SetOptions(options)); |
| 3241 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); |
| 3242 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc1) |
| 3243 ->GetConfig() |
| 3244 .combined_audio_video_bwe); |
| 3245 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc2) |
| 3246 ->GetConfig() |
| 3247 .combined_audio_video_bwe); |
| 3248 |
| 3249 // Disable combined BWE option - should be disabled again. |
| 3250 options.combined_audio_video_bwe.Set(false); |
| 3251 EXPECT_TRUE(media_channel->SetOptions(options)); |
| 3252 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); |
| 3253 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1) |
| 3254 ->GetConfig() |
| 3255 .combined_audio_video_bwe); |
| 3256 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) |
| 3257 ->GetConfig() |
| 3258 .combined_audio_video_bwe); |
| 3259 |
| 3260 media_channel->SetCall(nullptr); |
| 3261 } |
| 3262 |
| 3263 TEST_F(WebRtcVoiceEngineTestFake, SetCallConfiguresAudioReceiveChannels) { |
| 3264 // Test that calling SetCall() on the voice media channel results in the |
| 3265 // expected state changes in Call. |
| 3266 cricket::FakeCall call((webrtc::Call::Config())); |
| 3267 cricket::FakeCall call2((webrtc::Call::Config())); |
| 3268 const uint32 kAudioSsrc1 = 223; |
| 3269 const uint32 kAudioSsrc2 = 224; |
| 3270 |
| 3271 EXPECT_TRUE(SetupEngine()); |
| 3272 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3273 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3274 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3275 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); |
| 3276 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3277 cricket::StreamParams::CreateLegacy(kAudioSsrc2))); |
| 3278 |
| 3279 // Combined BWE should not be set up yet. |
| 3280 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); |
| 3281 |
| 3282 // Register - should be enabled. |
| 3283 media_channel->SetCall(&call); |
| 3284 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); |
| 3285 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc1)); |
| 3286 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc2)); |
| 3287 |
| 3288 // Re-register - should now be enabled on new call. |
| 3289 media_channel->SetCall(&call2); |
| 3290 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); |
| 3291 EXPECT_EQ(2, call2.GetAudioReceiveStreams().size()); |
| 3292 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc1)); |
| 3293 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc2)); |
| 3294 |
| 3295 // Unregister - should be disabled again. |
| 3296 media_channel->SetCall(nullptr); |
| 3297 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); |
| 3298 } |
| 3299 |
| 3300 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { |
| 3301 // Test that adding receive streams after enabling combined bandwidth |
| 3302 // estimation will correctly configure each channel. |
| 3303 cricket::FakeCall call((webrtc::Call::Config())); |
| 3304 |
| 3305 EXPECT_TRUE(SetupEngine()); |
| 3306 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3307 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3308 media_channel->SetCall(&call); |
| 3309 cricket::AudioOptions options; |
| 3310 options.combined_audio_video_bwe.Set(true); |
| 3311 EXPECT_TRUE(media_channel->SetOptions(options)); |
| 3312 |
| 3313 static const uint32 kSsrcs[] = {1, 2, 3, 4}; |
| 3314 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { |
| 3315 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3316 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); |
| 3317 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kSsrcs[i])); |
| 3318 EXPECT_TRUE(call.GetAudioReceiveStream(kSsrcs[i]) |
| 3319 ->GetConfig() |
| 3320 .combined_audio_video_bwe); |
| 3321 } |
| 3322 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call.GetAudioReceiveStreams().size()); |
| 3323 |
| 3324 media_channel->SetCall(nullptr); |
| 3325 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); |
| 3326 } |
| 3327 |
| 3328 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { |
| 3329 // Test that setting the header extensions results in the expected state |
| 3330 // changes on an associated Call. |
| 3331 cricket::FakeCall call((webrtc::Call::Config())); |
| 3332 std::vector<uint32> ssrcs; |
| 3333 ssrcs.push_back(223); |
| 3334 ssrcs.push_back(224); |
| 3335 |
| 3336 EXPECT_TRUE(SetupEngine()); |
| 3337 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3338 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3339 media_channel->SetCall(&call); |
| 3340 for (uint32 ssrc : ssrcs) { |
| 3341 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3342 cricket::StreamParams::CreateLegacy(ssrc))); |
| 3343 } |
| 3344 |
| 3345 // Combined BWE should be set up, but with no configured extensions. |
| 3346 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); |
| 3347 for (uint32 ssrc : ssrcs) { |
| 3348 const auto* s = call.GetAudioReceiveStream(ssrc); |
| 3349 EXPECT_NE(nullptr, s); |
| 3350 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); |
| 3351 } |
| 3352 |
| 3353 // Set up receive extensions. |
| 3354 const auto& e_exts = engine_.rtp_header_extensions(); |
| 3355 channel_->SetRecvRtpHeaderExtensions(e_exts); |
| 3356 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); |
| 3357 for (uint32 ssrc : ssrcs) { |
| 3358 const auto* s = call.GetAudioReceiveStream(ssrc); |
| 3359 EXPECT_NE(nullptr, s); |
| 3360 const auto& s_exts = s->GetConfig().rtp.extensions; |
| 3361 EXPECT_EQ(e_exts.size(), s_exts.size()); |
| 3362 for (const auto& e_ext : e_exts) { |
| 3363 for (const auto& s_ext : s_exts) { |
| 3364 if (e_ext.id == s_ext.id) { |
| 3365 EXPECT_EQ(e_ext.uri, s_ext.name); |
| 3366 } |
| 3367 } |
| 3368 } |
| 3369 } |
| 3370 |
| 3371 // Disable receive extensions. |
| 3372 std::vector<cricket::RtpHeaderExtension> extensions; |
| 3373 channel_->SetRecvRtpHeaderExtensions(extensions); |
| 3374 for (uint32 ssrc : ssrcs) { |
| 3375 const auto* s = call.GetAudioReceiveStream(ssrc); |
| 3376 EXPECT_NE(nullptr, s); |
| 3377 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); |
| 3378 } |
| 3379 |
| 3380 media_channel->SetCall(nullptr); |
| 3381 } |
| 3382 |
| 3383 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { |
| 3384 // Test that packets are forwarded to the Call when configured accordingly. |
| 3385 cricket::FakeCall call((webrtc::Call::Config())); |
| 3386 const uint32 kAudioSsrc = 1; |
| 3387 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 3388 static const unsigned char kRtcp[] = { |
| 3389 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, |
| 3390 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, |
| 3391 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 3392 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 3393 }; |
| 3394 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); |
| 3395 |
| 3396 EXPECT_TRUE(SetupEngine()); |
| 3397 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3398 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3399 cricket::AudioOptions options; |
| 3400 options.combined_audio_video_bwe.Set(true); |
| 3401 EXPECT_TRUE(media_channel->SetOptions(options)); |
| 3402 EXPECT_TRUE(media_channel->AddRecvStream( |
| 3403 cricket::StreamParams::CreateLegacy(kAudioSsrc))); |
| 3404 |
| 3405 // Call not set on media channel, so no packets can be forwarded. |
| 3406 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); |
| 3407 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); |
| 3408 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); |
| 3409 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); |
| 3410 |
| 3411 // Set Call, now there should be a receive stream which is forwarded packets. |
| 3412 media_channel->SetCall(&call); |
| 3413 EXPECT_EQ(1, call.GetAudioReceiveStreams().size()); |
| 3414 const cricket::FakeAudioReceiveStream* s = |
| 3415 call.GetAudioReceiveStream(kAudioSsrc); |
| 3416 EXPECT_EQ(0, s->received_packets()); |
| 3417 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); |
| 3418 EXPECT_EQ(1, s->received_packets()); |
| 3419 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); |
| 3420 EXPECT_EQ(2, s->received_packets()); |
| 3421 |
| 3422 media_channel->SetCall(nullptr); |
| 3423 } |
| 3424 |
| 3425 // Associate channel should not set on 1:1 call, since the receive channel also |
| 3426 // sends RTCP SR. |
| 3427 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelUnset1On1) { |
| 3428 EXPECT_TRUE(SetupEngine()); |
| 3429 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 3430 int recv_ch = voe_.GetLastChannel(); |
| 3431 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); |
| 3432 } |
| 3433 |
| 3434 // This test is an extension of AssociateChannelUnset1On1. We create two receive |
| 3435 // channels. The second should be associated with the default channel, since it |
| 3436 // does not send RTCP SR. |
| 3437 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnSecondRecvChannel) { |
| 3438 EXPECT_TRUE(SetupEngine()); |
| 3439 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3440 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3441 int default_channel = media_channel->voe_channel(); |
| 3442 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 3443 int recv_ch_1 = voe_.GetLastChannel(); |
| 3444 EXPECT_EQ(recv_ch_1, default_channel); |
| 3445 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); |
| 3446 int recv_ch_2 = voe_.GetLastChannel(); |
| 3447 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); |
| 3448 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); |
| 3449 // Add send stream, the association remains. |
| 3450 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); |
| 3451 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); |
| 3452 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); |
| 3453 } |
| 3454 |
| 3455 // In conference mode, all receive channels should be associated with the |
| 3456 // default channel, since they do not send RTCP SR. |
| 3457 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { |
| 3458 EXPECT_TRUE(SetupEngine()); |
| 3459 EXPECT_TRUE(channel_->SetOptions(options_conference_)); |
| 3460 cricket::WebRtcVoiceMediaChannel* media_channel = |
| 3461 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); |
| 3462 int default_channel = media_channel->voe_channel(); |
| 3463 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 3464 int recv_ch = voe_.GetLastChannel(); |
| 3465 EXPECT_NE(recv_ch, default_channel); |
| 3466 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
| 3467 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
| 3468 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); |
| 3469 } |
| 3470 |
| 3471 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { |
| 3472 EXPECT_TRUE(SetupEngine()); |
| 3473 EXPECT_TRUE(channel_->SetOptions(options_conference_)); |
| 3474 |
| 3475 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); |
| 3476 int recv_ch = voe_.GetLastChannel(); |
| 3477 |
| 3478 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); |
| 3479 int send_ch = voe_.GetLastChannel(); |
| 3480 |
| 3481 // Manually associate |recv_ch| to |send_ch|. This test is to verify a |
| 3482 // deleting logic, i.e., deleting |send_ch| will reset the associate send |
| 3483 // channel of |recv_ch|.This is not a common case, sinceļ¼ normally, only the |
| 3484 // default channel can be associated. However, the default is not deletable. |
| 3485 // So we force the |recv_ch| to associate with a non-default channel. |
| 3486 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch)); |
| 3487 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch); |
| 3488 |
| 3489 EXPECT_TRUE(channel_->RemoveSendStream(2)); |
| 3490 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); |
| 3491 } |
| 3492 |
3197 // Tests for the actual WebRtc VoE library. | 3493 // Tests for the actual WebRtc VoE library. |
3198 | 3494 |
| 3495 TEST(WebRtcVoiceEngineTest, TestDefaultOptionsBeforeInit) { |
| 3496 cricket::WebRtcVoiceEngine engine; |
| 3497 cricket::AudioOptions options = engine.GetOptions(); |
| 3498 // The default options should have at least a few things set. We purposefully |
| 3499 // don't check the option values here, though. |
| 3500 EXPECT_TRUE(options.echo_cancellation.IsSet()); |
| 3501 EXPECT_TRUE(options.auto_gain_control.IsSet()); |
| 3502 EXPECT_TRUE(options.noise_suppression.IsSet()); |
| 3503 } |
| 3504 |
3199 // Tests that the library initializes and shuts down properly. | 3505 // Tests that the library initializes and shuts down properly. |
3200 TEST(WebRtcVoiceEngineTest, StartupShutdown) { | 3506 TEST(WebRtcVoiceEngineTest, StartupShutdown) { |
3201 cricket::WebRtcVoiceEngine engine; | 3507 cricket::WebRtcVoiceEngine engine; |
3202 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3508 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3203 cricket::VoiceMediaChannel* channel = | 3509 cricket::VoiceMediaChannel* channel = |
3204 engine.CreateChannel(cricket::AudioOptions()); | 3510 engine.CreateChannel(cricket::AudioOptions()); |
3205 EXPECT_TRUE(channel != nullptr); | 3511 EXPECT_TRUE(channel != nullptr); |
3206 delete channel; | 3512 delete channel; |
3207 engine.Terminate(); | 3513 engine.Terminate(); |
3208 | 3514 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3318 engine.Terminate(); | 3624 engine.Terminate(); |
3319 } | 3625 } |
3320 | 3626 |
3321 // Test that we set our preferred codecs properly. | 3627 // Test that we set our preferred codecs properly. |
3322 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { | 3628 TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { |
3323 cricket::WebRtcVoiceEngine engine; | 3629 cricket::WebRtcVoiceEngine engine; |
3324 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3630 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
3325 cricket::WebRtcVoiceMediaChannel channel(&engine); | 3631 cricket::WebRtcVoiceMediaChannel channel(&engine); |
3326 EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs())); | 3632 EXPECT_TRUE(channel.SetRecvCodecs(engine.codecs())); |
3327 } | 3633 } |
3328 | |
3329 #ifdef WIN32 | |
3330 // Test our workarounds to WebRtc VoE' munging of the coinit count | |
3331 TEST(WebRtcVoiceEngineTest, CoInitialize) { | |
3332 cricket::WebRtcVoiceEngine* engine = new cricket::WebRtcVoiceEngine(); | |
3333 | |
3334 // Initial refcount should be 0. | |
3335 EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED)); | |
3336 | |
3337 // Engine should start even with COM already inited. | |
3338 EXPECT_TRUE(engine->Init(rtc::Thread::Current())); | |
3339 engine->Terminate(); | |
3340 EXPECT_TRUE(engine->Init(rtc::Thread::Current())); | |
3341 engine->Terminate(); | |
3342 | |
3343 // Refcount after terminate should be 1 (in reality 3); test if it is nonzero. | |
3344 EXPECT_EQ(S_FALSE, CoInitializeEx(NULL, COINIT_MULTITHREADED)); | |
3345 // Decrement refcount to (hopefully) 0. | |
3346 CoUninitialize(); | |
3347 CoUninitialize(); | |
3348 delete engine; | |
3349 | |
3350 // Ensure refcount is 0. | |
3351 EXPECT_EQ(S_OK, CoInitializeEx(NULL, COINIT_MULTITHREADED)); | |
3352 CoUninitialize(); | |
3353 } | |
3354 #endif | |
3355 | |
3356 TEST_F(WebRtcVoiceEngineTestFake, SetsSyncGroupFromSyncLabel) { | |
3357 cricket::FakeCall call((webrtc::Call::Config())); | |
3358 const uint32 kAudioSsrc = 123; | |
3359 const std::string kSyncLabel = "AvSyncLabel"; | |
3360 | |
3361 EXPECT_TRUE(SetupEngine()); | |
3362 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3363 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3364 media_channel->SetCall(&call); | |
3365 cricket::StreamParams sp = cricket::StreamParams::CreateLegacy(kAudioSsrc); | |
3366 sp.sync_label = kSyncLabel; | |
3367 // Creating two channels to make sure that sync label is set properly for both | |
3368 // the default voice channel and following ones. | |
3369 EXPECT_TRUE(channel_->AddRecvStream(sp)); | |
3370 sp.ssrcs[0] += 1; | |
3371 EXPECT_TRUE(channel_->AddRecvStream(sp)); | |
3372 | |
3373 ASSERT_EQ(2, call.GetAudioReceiveStreams().size()); | |
3374 EXPECT_EQ(kSyncLabel, | |
3375 call.GetAudioReceiveStream(kAudioSsrc)->GetConfig().sync_group) | |
3376 << "SyncGroup should be set based on sync_label"; | |
3377 EXPECT_EQ(kSyncLabel, | |
3378 call.GetAudioReceiveStream(kAudioSsrc + 1)->GetConfig().sync_group) | |
3379 << "SyncGroup should be set based on sync_label"; | |
3380 | |
3381 media_channel->SetCall(nullptr); | |
3382 } | |
3383 | |
3384 TEST_F(WebRtcVoiceEngineTestFake, CanChangeCombinedBweOption) { | |
3385 // Test that changing the combined_audio_video_bwe option results in the | |
3386 // expected state changes on an associated Call. | |
3387 cricket::FakeCall call((webrtc::Call::Config())); | |
3388 const uint32 kAudioSsrc1 = 223; | |
3389 const uint32 kAudioSsrc2 = 224; | |
3390 | |
3391 EXPECT_TRUE(SetupEngine()); | |
3392 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3393 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3394 const auto& rtp_extensions = engine_.rtp_header_extensions(); | |
3395 media_channel->SetRecvRtpHeaderExtensions(rtp_extensions); | |
3396 media_channel->SetCall(&call); | |
3397 EXPECT_TRUE(media_channel->AddRecvStream( | |
3398 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); | |
3399 EXPECT_TRUE(media_channel->AddRecvStream( | |
3400 cricket::StreamParams::CreateLegacy(kAudioSsrc2))); | |
3401 | |
3402 // Combined BWE should not be set up yet. | |
3403 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); | |
3404 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1) | |
3405 ->GetConfig() | |
3406 .combined_audio_video_bwe); | |
3407 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) | |
3408 ->GetConfig() | |
3409 .combined_audio_video_bwe); | |
3410 | |
3411 // Enable combined BWE option - now it should be set up. | |
3412 cricket::AudioOptions options; | |
3413 options.combined_audio_video_bwe.Set(true); | |
3414 EXPECT_TRUE(media_channel->SetOptions(options)); | |
3415 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); | |
3416 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc1) | |
3417 ->GetConfig() | |
3418 .combined_audio_video_bwe); | |
3419 EXPECT_TRUE(call.GetAudioReceiveStream(kAudioSsrc2) | |
3420 ->GetConfig() | |
3421 .combined_audio_video_bwe); | |
3422 | |
3423 // Disable combined BWE option - should be disabled again. | |
3424 options.combined_audio_video_bwe.Set(false); | |
3425 EXPECT_TRUE(media_channel->SetOptions(options)); | |
3426 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); | |
3427 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc1) | |
3428 ->GetConfig() | |
3429 .combined_audio_video_bwe); | |
3430 EXPECT_FALSE(call.GetAudioReceiveStream(kAudioSsrc2) | |
3431 ->GetConfig() | |
3432 .combined_audio_video_bwe); | |
3433 | |
3434 media_channel->SetCall(nullptr); | |
3435 } | |
3436 | |
3437 TEST_F(WebRtcVoiceEngineTestFake, SetCallConfiguresAudioReceiveChannels) { | |
3438 // Test that calling SetCall() on the voice media channel results in the | |
3439 // expected state changes in Call. | |
3440 cricket::FakeCall call((webrtc::Call::Config())); | |
3441 cricket::FakeCall call2((webrtc::Call::Config())); | |
3442 const uint32 kAudioSsrc1 = 223; | |
3443 const uint32 kAudioSsrc2 = 224; | |
3444 | |
3445 EXPECT_TRUE(SetupEngine()); | |
3446 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3447 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3448 EXPECT_TRUE(media_channel->AddRecvStream( | |
3449 cricket::StreamParams::CreateLegacy(kAudioSsrc1))); | |
3450 EXPECT_TRUE(media_channel->AddRecvStream( | |
3451 cricket::StreamParams::CreateLegacy(kAudioSsrc2))); | |
3452 | |
3453 // Combined BWE should not be set up yet. | |
3454 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); | |
3455 | |
3456 // Register - should be enabled. | |
3457 media_channel->SetCall(&call); | |
3458 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); | |
3459 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc1)); | |
3460 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kAudioSsrc2)); | |
3461 | |
3462 // Re-register - should now be enabled on new call. | |
3463 media_channel->SetCall(&call2); | |
3464 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); | |
3465 EXPECT_EQ(2, call2.GetAudioReceiveStreams().size()); | |
3466 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc1)); | |
3467 EXPECT_NE(nullptr, call2.GetAudioReceiveStream(kAudioSsrc2)); | |
3468 | |
3469 // Unregister - should be disabled again. | |
3470 media_channel->SetCall(nullptr); | |
3471 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); | |
3472 } | |
3473 | |
3474 TEST_F(WebRtcVoiceEngineTestFake, ConfigureCombinedBweForNewRecvStreams) { | |
3475 // Test that adding receive streams after enabling combined bandwidth | |
3476 // estimation will correctly configure each channel. | |
3477 cricket::FakeCall call((webrtc::Call::Config())); | |
3478 | |
3479 EXPECT_TRUE(SetupEngine()); | |
3480 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3481 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3482 media_channel->SetCall(&call); | |
3483 cricket::AudioOptions options; | |
3484 options.combined_audio_video_bwe.Set(true); | |
3485 EXPECT_TRUE(media_channel->SetOptions(options)); | |
3486 | |
3487 static const uint32 kSsrcs[] = {1, 2, 3, 4}; | |
3488 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) { | |
3489 EXPECT_TRUE(media_channel->AddRecvStream( | |
3490 cricket::StreamParams::CreateLegacy(kSsrcs[i]))); | |
3491 EXPECT_NE(nullptr, call.GetAudioReceiveStream(kSsrcs[i])); | |
3492 EXPECT_TRUE(call.GetAudioReceiveStream(kSsrcs[i]) | |
3493 ->GetConfig() | |
3494 .combined_audio_video_bwe); | |
3495 } | |
3496 EXPECT_EQ(ARRAY_SIZE(kSsrcs), call.GetAudioReceiveStreams().size()); | |
3497 | |
3498 media_channel->SetCall(nullptr); | |
3499 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); | |
3500 } | |
3501 | |
3502 TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) { | |
3503 // Test that setting the header extensions results in the expected state | |
3504 // changes on an associated Call. | |
3505 cricket::FakeCall call((webrtc::Call::Config())); | |
3506 std::vector<uint32> ssrcs; | |
3507 ssrcs.push_back(223); | |
3508 ssrcs.push_back(224); | |
3509 | |
3510 EXPECT_TRUE(SetupEngine()); | |
3511 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3512 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3513 media_channel->SetCall(&call); | |
3514 for (uint32 ssrc : ssrcs) { | |
3515 EXPECT_TRUE(media_channel->AddRecvStream( | |
3516 cricket::StreamParams::CreateLegacy(ssrc))); | |
3517 } | |
3518 | |
3519 // Combined BWE should be set up, but with no configured extensions. | |
3520 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); | |
3521 for (uint32 ssrc : ssrcs) { | |
3522 const auto* s = call.GetAudioReceiveStream(ssrc); | |
3523 EXPECT_NE(nullptr, s); | |
3524 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); | |
3525 } | |
3526 | |
3527 // Set up receive extensions. | |
3528 const auto& e_exts = engine_.rtp_header_extensions(); | |
3529 channel_->SetRecvRtpHeaderExtensions(e_exts); | |
3530 EXPECT_EQ(2, call.GetAudioReceiveStreams().size()); | |
3531 for (uint32 ssrc : ssrcs) { | |
3532 const auto* s = call.GetAudioReceiveStream(ssrc); | |
3533 EXPECT_NE(nullptr, s); | |
3534 const auto& s_exts = s->GetConfig().rtp.extensions; | |
3535 EXPECT_EQ(e_exts.size(), s_exts.size()); | |
3536 for (const auto& e_ext : e_exts) { | |
3537 for (const auto& s_ext : s_exts) { | |
3538 if (e_ext.id == s_ext.id) { | |
3539 EXPECT_EQ(e_ext.uri, s_ext.name); | |
3540 } | |
3541 } | |
3542 } | |
3543 } | |
3544 | |
3545 // Disable receive extensions. | |
3546 std::vector<cricket::RtpHeaderExtension> extensions; | |
3547 channel_->SetRecvRtpHeaderExtensions(extensions); | |
3548 for (uint32 ssrc : ssrcs) { | |
3549 const auto* s = call.GetAudioReceiveStream(ssrc); | |
3550 EXPECT_NE(nullptr, s); | |
3551 EXPECT_EQ(0, s->GetConfig().rtp.extensions.size()); | |
3552 } | |
3553 | |
3554 media_channel->SetCall(nullptr); | |
3555 } | |
3556 | |
3557 TEST_F(WebRtcVoiceEngineTestFake, DeliverAudioPacket_Call) { | |
3558 // Test that packets are forwarded to the Call when configured accordingly. | |
3559 cricket::FakeCall call((webrtc::Call::Config())); | |
3560 const uint32 kAudioSsrc = 1; | |
3561 rtc::Buffer kPcmuPacket(kPcmuFrame, sizeof(kPcmuFrame)); | |
3562 static const unsigned char kRtcp[] = { | |
3563 0x80, 0xc9, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, | |
3564 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, | |
3565 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
3566 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
3567 }; | |
3568 rtc::Buffer kRtcpPacket(kRtcp, sizeof(kRtcp)); | |
3569 | |
3570 EXPECT_TRUE(SetupEngine()); | |
3571 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3572 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3573 cricket::AudioOptions options; | |
3574 options.combined_audio_video_bwe.Set(true); | |
3575 EXPECT_TRUE(media_channel->SetOptions(options)); | |
3576 EXPECT_TRUE(media_channel->AddRecvStream( | |
3577 cricket::StreamParams::CreateLegacy(kAudioSsrc))); | |
3578 | |
3579 // Call not set on media channel, so no packets can be forwarded. | |
3580 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); | |
3581 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); | |
3582 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); | |
3583 EXPECT_EQ(0, call.GetAudioReceiveStreams().size()); | |
3584 | |
3585 // Set Call, now there should be a receive stream which is forwarded packets. | |
3586 media_channel->SetCall(&call); | |
3587 EXPECT_EQ(1, call.GetAudioReceiveStreams().size()); | |
3588 const cricket::FakeAudioReceiveStream* s = | |
3589 call.GetAudioReceiveStream(kAudioSsrc); | |
3590 EXPECT_EQ(0, s->received_packets()); | |
3591 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); | |
3592 EXPECT_EQ(1, s->received_packets()); | |
3593 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); | |
3594 EXPECT_EQ(2, s->received_packets()); | |
3595 | |
3596 media_channel->SetCall(nullptr); | |
3597 } | |
3598 | |
3599 // Associate channel should not set on 1:1 call, since the receive channel also | |
3600 // sends RTCP SR. | |
3601 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelUnset1On1) { | |
3602 EXPECT_TRUE(SetupEngine()); | |
3603 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3604 int recv_ch = voe_.GetLastChannel(); | |
3605 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); | |
3606 } | |
3607 | |
3608 // This test is an extension of AssociateChannelUnset1On1. We create two receive | |
3609 // channels. The second should be associated with the default channel, since it | |
3610 // does not send RTCP SR. | |
3611 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnSecondRecvChannel) { | |
3612 EXPECT_TRUE(SetupEngine()); | |
3613 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3614 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3615 int default_channel = media_channel->voe_channel(); | |
3616 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3617 int recv_ch_1 = voe_.GetLastChannel(); | |
3618 EXPECT_EQ(recv_ch_1, default_channel); | |
3619 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(2))); | |
3620 int recv_ch_2 = voe_.GetLastChannel(); | |
3621 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); | |
3622 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); | |
3623 // Add send stream, the association remains. | |
3624 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(3))); | |
3625 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_1), -1); | |
3626 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch_2), default_channel); | |
3627 } | |
3628 | |
3629 // In conference mode, all receive channels should be associated with the | |
3630 // default channel, since they do not send RTCP SR. | |
3631 TEST_F(WebRtcVoiceEngineTestFake, AssociateDefaultChannelOnConference) { | |
3632 EXPECT_TRUE(SetupEngine()); | |
3633 EXPECT_TRUE(channel_->SetOptions(options_conference_)); | |
3634 cricket::WebRtcVoiceMediaChannel* media_channel = | |
3635 static_cast<cricket::WebRtcVoiceMediaChannel*>(channel_); | |
3636 int default_channel = media_channel->voe_channel(); | |
3637 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3638 int recv_ch = voe_.GetLastChannel(); | |
3639 EXPECT_NE(recv_ch, default_channel); | |
3640 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | |
3641 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | |
3642 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | |
3643 } | |
3644 | |
3645 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { | |
3646 EXPECT_TRUE(SetupEngine()); | |
3647 EXPECT_TRUE(channel_->SetOptions(options_conference_)); | |
3648 | |
3649 EXPECT_TRUE(channel_->AddRecvStream(cricket::StreamParams::CreateLegacy(1))); | |
3650 int recv_ch = voe_.GetLastChannel(); | |
3651 | |
3652 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | |
3653 int send_ch = voe_.GetLastChannel(); | |
3654 | |
3655 // Manually associate |recv_ch| to |send_ch|. This test is to verify a | |
3656 // deleting logic, i.e., deleting |send_ch| will reset the associate send | |
3657 // channel of |recv_ch|.This is not a common case, sinceļ¼ normally, only the | |
3658 // default channel can be associated. However, the default is not deletable. | |
3659 // So we force the |recv_ch| to associate with a non-default channel. | |
3660 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch)); | |
3661 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch); | |
3662 | |
3663 EXPECT_TRUE(channel_->RemoveSendStream(2)); | |
3664 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); | |
3665 } | |
OLD | NEW |