OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2008 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2008 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); | 43 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1); |
44 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1); | 44 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1); |
45 const cricket::AudioCodec kTelephoneEventCodec(106, | 45 const cricket::AudioCodec kTelephoneEventCodec(106, |
46 "telephone-event", | 46 "telephone-event", |
47 8000, | 47 8000, |
48 0, | 48 0, |
49 1); | 49 1); |
50 const uint32_t kSsrc1 = 0x99; | 50 const uint32_t kSsrc1 = 0x99; |
51 const uint32_t kSsrc2 = 2; | 51 const uint32_t kSsrc2 = 2; |
52 const uint32_t kSsrc3 = 3; | 52 const uint32_t kSsrc3 = 3; |
| 53 const uint32_t kSsrc4 = 0x42; |
53 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; | 54 const uint32_t kSsrcs4[] = { 1, 2, 3, 4 }; |
54 | 55 |
55 constexpr int kRtpHistoryMs = 5000; | 56 constexpr int kRtpHistoryMs = 5000; |
56 | 57 |
57 class FakeVoEWrapper : public cricket::VoEWrapper { | 58 class FakeVoEWrapper : public cricket::VoEWrapper { |
58 public: | 59 public: |
59 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) | 60 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) |
60 : cricket::VoEWrapper(engine, // processing | 61 : cricket::VoEWrapper(engine, // processing |
61 engine, // base | 62 engine, // base |
62 engine, // codec | 63 engine, // codec |
(...skipping 3169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3232 call_.GetAudioReceiveStream(kAudioSsrc); | 3233 call_.GetAudioReceiveStream(kAudioSsrc); |
3233 EXPECT_EQ(0, s->received_packets()); | 3234 EXPECT_EQ(0, s->received_packets()); |
3234 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); | 3235 channel_->OnPacketReceived(&kPcmuPacket, rtc::PacketTime()); |
3235 EXPECT_EQ(1, s->received_packets()); | 3236 EXPECT_EQ(1, s->received_packets()); |
3236 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); | 3237 channel_->OnRtcpReceived(&kRtcpPacket, rtc::PacketTime()); |
3237 EXPECT_EQ(2, s->received_packets()); | 3238 EXPECT_EQ(2, s->received_packets()); |
3238 } | 3239 } |
3239 | 3240 |
3240 // All receive channels should be associated with the first send channel, | 3241 // All receive channels should be associated with the first send channel, |
3241 // since they do not send RTCP SR. | 3242 // since they do not send RTCP SR. |
3242 TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel) { | 3243 TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel_SendCreatedFirst) { |
3243 EXPECT_TRUE(SetupSendStream()); | 3244 EXPECT_TRUE(SetupSendStream()); |
3244 SetSendParameters(send_parameters_); | 3245 EXPECT_TRUE(AddRecvStream(kSsrc2)); |
3245 int default_channel = voe_.GetLastChannel(); | 3246 EXPECT_EQ(kSsrc1, GetRecvStreamConfig(kSsrc2).rtp.local_ssrc); |
3246 EXPECT_TRUE(AddRecvStream(1)); | 3247 EXPECT_TRUE(channel_->AddSendStream( |
3247 int recv_ch = voe_.GetLastChannel(); | 3248 cricket::StreamParams::CreateLegacy(kSsrc3))); |
3248 EXPECT_NE(recv_ch, default_channel); | 3249 EXPECT_EQ(kSsrc1, GetRecvStreamConfig(kSsrc2).rtp.local_ssrc); |
3249 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | 3250 EXPECT_TRUE(AddRecvStream(kSsrc4)); |
3250 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | 3251 EXPECT_EQ(kSsrc1, GetRecvStreamConfig(kSsrc4).rtp.local_ssrc); |
3251 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | |
3252 EXPECT_TRUE(AddRecvStream(3)); | |
3253 recv_ch = voe_.GetLastChannel(); | |
3254 EXPECT_NE(recv_ch, default_channel); | |
3255 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), default_channel); | |
3256 } | 3252 } |
3257 | 3253 |
3258 TEST_F(WebRtcVoiceEngineTestFake, AssociateChannelResetUponDeleteChannnel) { | 3254 TEST_F(WebRtcVoiceEngineTestFake, AssociateFirstSendChannel_RecvCreatedFirst) { |
3259 EXPECT_TRUE(SetupSendStream()); | 3255 EXPECT_TRUE(SetupRecvStream()); |
3260 SetSendParameters(send_parameters_); | 3256 EXPECT_EQ(0xFA17FA17u, GetRecvStreamConfig(kSsrc1).rtp.local_ssrc); |
3261 | 3257 EXPECT_TRUE(channel_->AddSendStream( |
3262 EXPECT_TRUE(AddRecvStream(1)); | 3258 cricket::StreamParams::CreateLegacy(kSsrc2))); |
3263 int recv_ch = voe_.GetLastChannel(); | 3259 EXPECT_EQ(kSsrc2, GetRecvStreamConfig(kSsrc1).rtp.local_ssrc); |
3264 | 3260 EXPECT_TRUE(AddRecvStream(kSsrc3)); |
3265 EXPECT_TRUE(channel_->AddSendStream(cricket::StreamParams::CreateLegacy(2))); | 3261 EXPECT_EQ(kSsrc2, GetRecvStreamConfig(kSsrc3).rtp.local_ssrc); |
3266 int send_ch = voe_.GetLastChannel(); | 3262 EXPECT_TRUE(channel_->AddSendStream( |
3267 | 3263 cricket::StreamParams::CreateLegacy(kSsrc4))); |
3268 // Manually associate |recv_ch| to |send_ch|. This test is to verify a | 3264 EXPECT_EQ(kSsrc2, GetRecvStreamConfig(kSsrc1).rtp.local_ssrc); |
3269 // deleting logic, i.e., deleting |send_ch| will reset the associate send | 3265 EXPECT_EQ(kSsrc2, GetRecvStreamConfig(kSsrc3).rtp.local_ssrc); |
3270 // channel of |recv_ch|.This is not a common case, sinceļ¼ normally, only the | |
3271 // default channel can be associated. However, the default is not deletable. | |
3272 // So we force the |recv_ch| to associate with a non-default channel. | |
3273 EXPECT_EQ(0, voe_.AssociateSendChannel(recv_ch, send_ch)); | |
3274 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), send_ch); | |
3275 | |
3276 EXPECT_TRUE(channel_->RemoveSendStream(2)); | |
3277 EXPECT_EQ(voe_.GetAssociateSendChannel(recv_ch), -1); | |
3278 } | 3266 } |
3279 | 3267 |
3280 TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSink) { | 3268 TEST_F(WebRtcVoiceEngineTestFake, SetRawAudioSink) { |
3281 EXPECT_TRUE(SetupChannel()); | 3269 EXPECT_TRUE(SetupChannel()); |
3282 std::unique_ptr<FakeAudioSink> fake_sink_1(new FakeAudioSink()); | 3270 std::unique_ptr<FakeAudioSink> fake_sink_1(new FakeAudioSink()); |
3283 std::unique_ptr<FakeAudioSink> fake_sink_2(new FakeAudioSink()); | 3271 std::unique_ptr<FakeAudioSink> fake_sink_2(new FakeAudioSink()); |
3284 | 3272 |
3285 // Setting the sink before a recv stream exists should do nothing. | 3273 // Setting the sink before a recv stream exists should do nothing. |
3286 channel_->SetRawAudioSink(kSsrc1, std::move(fake_sink_1)); | 3274 channel_->SetRawAudioSink(kSsrc1, std::move(fake_sink_1)); |
3287 EXPECT_TRUE(AddRecvStream(kSsrc1)); | 3275 EXPECT_TRUE(AddRecvStream(kSsrc1)); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3509 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); | 3497 nullptr, webrtc::CreateBuiltinAudioDecoderFactory()); |
3510 webrtc::RtcEventLogNullImpl event_log; | 3498 webrtc::RtcEventLogNullImpl event_log; |
3511 std::unique_ptr<webrtc::Call> call( | 3499 std::unique_ptr<webrtc::Call> call( |
3512 webrtc::Call::Create(webrtc::Call::Config(&event_log))); | 3500 webrtc::Call::Create(webrtc::Call::Config(&event_log))); |
3513 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), | 3501 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), |
3514 cricket::AudioOptions(), call.get()); | 3502 cricket::AudioOptions(), call.get()); |
3515 cricket::AudioRecvParameters parameters; | 3503 cricket::AudioRecvParameters parameters; |
3516 parameters.codecs = engine.recv_codecs(); | 3504 parameters.codecs = engine.recv_codecs(); |
3517 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3505 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
3518 } | 3506 } |
OLD | NEW |