Chromium Code Reviews| 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, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 #include "talk/media/base/constants.h" | 31 #include "talk/media/base/constants.h" |
| 32 #include "talk/media/base/fakemediaengine.h" | 32 #include "talk/media/base/fakemediaengine.h" |
| 33 #include "talk/media/base/fakenetworkinterface.h" | 33 #include "talk/media/base/fakenetworkinterface.h" |
| 34 #include "talk/media/base/fakertp.h" | 34 #include "talk/media/base/fakertp.h" |
| 35 #include "talk/media/webrtc/fakewebrtccall.h" | 35 #include "talk/media/webrtc/fakewebrtccall.h" |
| 36 #include "talk/media/webrtc/fakewebrtcvoiceengine.h" | 36 #include "talk/media/webrtc/fakewebrtcvoiceengine.h" |
| 37 #include "talk/media/webrtc/webrtcvoiceengine.h" | 37 #include "talk/media/webrtc/webrtcvoiceengine.h" |
| 38 #include "webrtc/p2p/base/faketransportcontroller.h" | 38 #include "webrtc/p2p/base/faketransportcontroller.h" |
| 39 #include "talk/session/media/channel.h" | 39 #include "talk/session/media/channel.h" |
| 40 | 40 |
| 41 // Tests for the WebRtcVoiceEngine/VoiceChannel code. | |
| 42 | |
| 43 using cricket::kRtpAudioLevelHeaderExtension; | 41 using cricket::kRtpAudioLevelHeaderExtension; |
| 44 using cricket::kRtpAbsoluteSenderTimeHeaderExtension; | 42 using cricket::kRtpAbsoluteSenderTimeHeaderExtension; |
| 45 | 43 |
| 46 static const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1, 0); | 44 namespace { |
| 47 static const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0); | 45 |
| 48 static const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0); | 46 const cricket::AudioCodec kPcmuCodec(0, "PCMU", 8000, 64000, 1, 0); |
| 49 static const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0); | 47 const cricket::AudioCodec kIsacCodec(103, "ISAC", 16000, 32000, 1, 0); |
| 50 static const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); | 48 const cricket::AudioCodec kOpusCodec(111, "opus", 48000, 64000, 2, 0); |
| 51 static const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); | 49 const cricket::AudioCodec kG722CodecVoE(9, "G722", 16000, 64000, 1, 0); |
| 52 static const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); | 50 const cricket::AudioCodec kG722CodecSdp(9, "G722", 8000, 64000, 1, 0); |
| 53 static const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); | 51 const cricket::AudioCodec kRedCodec(117, "red", 8000, 0, 1, 0); |
| 54 static const cricket::AudioCodec | 52 const cricket::AudioCodec kCn8000Codec(13, "CN", 8000, 0, 1, 0); |
| 55 kTelephoneEventCodec(106, "telephone-event", 8000, 0, 1, 0); | 53 const cricket::AudioCodec kCn16000Codec(105, "CN", 16000, 0, 1, 0); |
| 56 static const cricket::AudioCodec* const kAudioCodecs[] = { | 54 const cricket::AudioCodec kTelephoneEventCodec(106, "telephone-event", 8000, 0, |
| 55 1, 0); | |
| 56 const cricket::AudioCodec* const kAudioCodecs[] = { | |
| 57 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, | 57 &kPcmuCodec, &kIsacCodec, &kOpusCodec, &kG722CodecVoE, &kRedCodec, |
| 58 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, | 58 &kCn8000Codec, &kCn16000Codec, &kTelephoneEventCodec, |
| 59 }; | 59 }; |
| 60 static uint32_t kSsrc1 = 0x99; | 60 const uint32_t kSsrc1 = 0x99; |
| 61 static uint32_t kSsrc2 = 0x98; | 61 const uint32_t kSsrc2 = 0x98; |
| 62 | 62 |
| 63 class FakeVoEWrapper : public cricket::VoEWrapper { | 63 class FakeVoEWrapper : public cricket::VoEWrapper { |
| 64 public: | 64 public: |
| 65 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) | 65 explicit FakeVoEWrapper(cricket::FakeWebRtcVoiceEngine* engine) |
| 66 : cricket::VoEWrapper(engine, // processing | 66 : cricket::VoEWrapper(engine, // processing |
| 67 engine, // base | 67 engine, // base |
| 68 engine, // codec | 68 engine, // codec |
| 69 engine, // dtmf | 69 engine, // dtmf |
| 70 engine, // hw | 70 engine, // hw |
| 71 engine, // neteq | |
| 72 engine, // network | 71 engine, // network |
| 73 engine, // rtp | 72 engine, // rtp |
| 74 engine, // sync | |
| 75 engine) { // volume | 73 engine) { // volume |
| 76 } | 74 } |
| 77 }; | 75 }; |
| 78 | 76 |
| 79 class FakeVoETraceWrapper : public cricket::VoETraceWrapper { | 77 class FakeVoETraceWrapper : public cricket::VoETraceWrapper { |
| 80 public: | 78 public: |
| 81 int SetTraceFilter(const unsigned int filter) override { | 79 int SetTraceFilter(const unsigned int filter) override { |
| 82 filter_ = filter; | 80 filter_ = filter; |
| 83 return 0; | 81 return 0; |
| 84 } | 82 } |
| 85 int SetTraceFile(const char* fileNameUTF8) override { return 0; } | 83 int SetTraceFile(const char* fileNameUTF8) override { return 0; } |
| 86 int SetTraceCallback(webrtc::TraceCallback* callback) override { return 0; } | 84 int SetTraceCallback(webrtc::TraceCallback* callback) override { return 0; } |
| 87 unsigned int filter_; | 85 unsigned int filter_; |
| 88 }; | 86 }; |
| 87 } // namespace | |
| 89 | 88 |
| 90 class WebRtcVoiceEngineTestFake : public testing::Test { | 89 class WebRtcVoiceEngineTestFake : public testing::Test { |
| 91 public: | 90 public: |
| 92 WebRtcVoiceEngineTestFake() | 91 WebRtcVoiceEngineTestFake() |
| 93 : call_(webrtc::Call::Config()), | 92 : call_(webrtc::Call::Config()), |
| 94 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), | 93 voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)), |
| 95 trace_wrapper_(new FakeVoETraceWrapper()), | 94 trace_wrapper_(new FakeVoETraceWrapper()), |
| 96 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), | 95 engine_(new FakeVoEWrapper(&voe_), trace_wrapper_), |
| 97 channel_(nullptr) { | 96 channel_(nullptr) { |
| 98 send_parameters_.codecs.push_back(kPcmuCodec); | 97 send_parameters_.codecs.push_back(kPcmuCodec); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 EXPECT_NE(channel_num, new_channel_num); | 282 EXPECT_NE(channel_num, new_channel_num); |
| 284 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 283 EXPECT_EQ(id, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
| 285 | 284 |
| 286 // Ensure all extensions go back off with an empty list. | 285 // Ensure all extensions go back off with an empty list. |
| 287 parameters.extensions.clear(); | 286 parameters.extensions.clear(); |
| 288 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); | 287 EXPECT_TRUE(channel_->SetRecvParameters(parameters)); |
| 289 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); | 288 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(channel_num, ext)); |
| 290 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); | 289 EXPECT_EQ(-1, voe_.GetReceiveRtpExtensionId(new_channel_num, ext)); |
| 291 } | 290 } |
| 292 | 291 |
| 292 const webrtc::AudioReceiveStream::Stats& GetAudioReceiveStreamStats() const { | |
| 293 static webrtc::AudioReceiveStream::Stats stats; | |
| 294 if (stats.remote_ssrc == 0) { | |
| 295 stats.remote_ssrc = 123; | |
| 296 stats.bytes_rcvd = 456; | |
| 297 stats.packets_rcvd = 768; | |
| 298 stats.packets_lost = 101; | |
| 299 stats.fraction_lost = 23.45f; | |
| 300 stats.codec_name = "codec_name"; | |
| 301 stats.ext_seqnum = 678; | |
| 302 stats.jitter_ms = 901; | |
| 303 stats.jitter_buffer_ms = 234; | |
| 304 stats.jitter_buffer_preferred_ms = 567; | |
| 305 stats.delay_estimate_ms = 890; | |
| 306 stats.audio_level = 1234; | |
| 307 stats.expand_rate = 5.67f; | |
| 308 stats.speech_expand_rate = 8.90f; | |
| 309 stats.secondary_decoded_rate = 1.23f; | |
| 310 stats.accelerate_rate = 4.56f; | |
| 311 stats.preemptive_expand_rate = 7.89f; | |
| 312 stats.decoding_calls_to_silence_generator = 012; | |
| 313 stats.decoding_calls_to_neteq = 345; | |
| 314 stats.decoding_normal = 67890; | |
| 315 stats.decoding_plc = 1234; | |
| 316 stats.decoding_cng = 5678; | |
| 317 stats.decoding_plc_cng = 9012; | |
| 318 stats.capture_start_ntp_time_ms = 3456; | |
| 319 } | |
| 320 return stats; | |
| 321 } | |
| 322 void SetAudioReceiveStreamStats() { | |
| 323 for (auto* s : call_.GetAudioReceiveStreams()) { | |
| 324 s->SetStats(GetAudioReceiveStreamStats()); | |
| 325 } | |
| 326 } | |
| 327 void VerifyVoiceReceiverInfo(const cricket::VoiceReceiverInfo& info) { | |
| 328 const auto& kStats = GetAudioReceiveStreamStats(); | |
| 329 EXPECT_EQ(info.local_stats.front().ssrc, kStats.remote_ssrc); | |
| 330 EXPECT_EQ(info.bytes_rcvd, kStats.bytes_rcvd); | |
| 331 EXPECT_EQ(info.packets_rcvd, kStats.packets_rcvd); | |
| 332 EXPECT_EQ(info.packets_lost, kStats.packets_lost); | |
| 333 EXPECT_EQ(info.fraction_lost, kStats.fraction_lost); | |
| 334 EXPECT_EQ(info.codec_name, kStats.codec_name); | |
| 335 EXPECT_EQ(info.ext_seqnum, kStats.ext_seqnum); | |
| 336 EXPECT_EQ(info.jitter_ms, kStats.jitter_ms); | |
| 337 EXPECT_EQ(info.jitter_buffer_ms, kStats.jitter_buffer_ms); | |
| 338 EXPECT_EQ(info.jitter_buffer_preferred_ms, | |
| 339 kStats.jitter_buffer_preferred_ms); | |
| 340 EXPECT_EQ(info.delay_estimate_ms, kStats.delay_estimate_ms); | |
| 341 EXPECT_EQ(info.audio_level, kStats.audio_level); | |
| 342 EXPECT_EQ(info.expand_rate, kStats.expand_rate); | |
| 343 EXPECT_EQ(info.speech_expand_rate, kStats.speech_expand_rate); | |
| 344 EXPECT_EQ(info.secondary_decoded_rate, kStats.secondary_decoded_rate); | |
| 345 EXPECT_EQ(info.accelerate_rate, kStats.accelerate_rate); | |
| 346 EXPECT_EQ(info.preemptive_expand_rate, kStats.preemptive_expand_rate); | |
| 347 EXPECT_EQ(info.decoding_calls_to_silence_generator, | |
| 348 kStats.decoding_calls_to_silence_generator); | |
| 349 EXPECT_EQ(info.decoding_calls_to_neteq, kStats.decoding_calls_to_neteq); | |
| 350 EXPECT_EQ(info.decoding_normal, kStats.decoding_normal); | |
| 351 EXPECT_EQ(info.decoding_plc, kStats.decoding_plc); | |
| 352 EXPECT_EQ(info.decoding_cng, kStats.decoding_cng); | |
| 353 EXPECT_EQ(info.decoding_plc_cng, kStats.decoding_plc_cng); | |
| 354 EXPECT_EQ(info.capture_start_ntp_time_ms, kStats.capture_start_ntp_time_ms); | |
| 355 } | |
| 356 | |
| 293 protected: | 357 protected: |
| 294 cricket::FakeCall call_; | 358 cricket::FakeCall call_; |
| 295 cricket::FakeWebRtcVoiceEngine voe_; | 359 cricket::FakeWebRtcVoiceEngine voe_; |
| 296 FakeVoETraceWrapper* trace_wrapper_; | 360 FakeVoETraceWrapper* trace_wrapper_; |
| 297 cricket::WebRtcVoiceEngine engine_; | 361 cricket::WebRtcVoiceEngine engine_; |
| 298 cricket::VoiceMediaChannel* channel_; | 362 cricket::VoiceMediaChannel* channel_; |
| 299 | 363 |
| 300 cricket::AudioSendParameters send_parameters_; | 364 cricket::AudioSendParameters send_parameters_; |
| 301 cricket::AudioRecvParameters recv_parameters_; | 365 cricket::AudioRecvParameters recv_parameters_; |
| 302 cricket::AudioOptions options_adjust_agc_; | 366 cricket::AudioOptions options_adjust_agc_; |
| (...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1977 // We need send codec to be set to get all stats. | 2041 // We need send codec to be set to get all stats. |
| 1978 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2042 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| 1979 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); | 2043 EXPECT_TRUE(channel_->SetRecvParameters(recv_parameters_)); |
| 1980 | 2044 |
| 1981 cricket::VoiceMediaInfo info; | 2045 cricket::VoiceMediaInfo info; |
| 1982 EXPECT_EQ(true, channel_->GetStats(&info)); | 2046 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 1983 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); | 2047 EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size()); |
| 1984 | 2048 |
| 1985 // Verify the statistic information is correct. | 2049 // Verify the statistic information is correct. |
| 1986 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { | 2050 for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs4); ++i) { |
| 1987 EXPECT_EQ(kSsrcs4[i], info.senders[i].ssrc()); | 2051 EXPECT_EQ(kSsrcs4[i], info.senders[i].ssrc()); |
|
the sun
2015/10/21 14:31:19
Q: hta@, is there any order requirement on the ret
hta-webrtc
2015/10/22 10:57:28
The JS API interface was created to be oblivious t
| |
| 1988 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | 2052 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); |
| 1989 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); | 2053 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].bytes_sent); |
| 1990 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_sent); | 2054 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_sent); |
| 1991 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_lost); | 2055 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].packets_lost); |
| 1992 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[i].fraction_lost); | 2056 EXPECT_EQ(cricket::kFractionLostStatValue, info.senders[i].fraction_lost); |
| 1993 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].ext_seqnum); | 2057 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].ext_seqnum); |
| 1994 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].rtt_ms); | 2058 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].rtt_ms); |
| 1995 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms); | 2059 EXPECT_EQ(cricket::kIntStatValue, info.senders[i].jitter_ms); |
| 1996 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); | 2060 EXPECT_EQ(kPcmuCodec.name, info.senders[i].codec_name); |
| 1997 } | 2061 } |
| 1998 EXPECT_EQ(0u, info.receivers.size()); | |
| 1999 | 2062 |
| 2000 // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1. | 2063 // We have added one receive stream. We should see empty stats. |
| 2001 // We should drop the packet and no stats should be available. | 2064 EXPECT_EQ(info.receivers.size(), 1u); |
| 2002 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2065 EXPECT_EQ(info.receivers[0].local_stats.front().ssrc, 0); |
| 2066 | |
| 2067 // Remove the kSsrc2 stream. No receiver stats. | |
| 2068 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); | |
| 2003 EXPECT_EQ(true, channel_->GetStats(&info)); | 2069 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2004 EXPECT_EQ(0u, info.receivers.size()); | 2070 EXPECT_EQ(0u, info.receivers.size()); |
| 2005 | 2071 |
| 2006 // Remove the kSsrc2 stream and deliver a new packet - a default receive | 2072 // Deliver a new packet - a default receive stream should be created and we |
| 2007 // stream should be created and we should see stats. | 2073 // should see stats again. |
| 2008 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); | |
| 2009 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2074 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2075 SetAudioReceiveStreamStats(); | |
| 2010 EXPECT_EQ(true, channel_->GetStats(&info)); | 2076 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2011 EXPECT_EQ(1u, info.receivers.size()); | 2077 EXPECT_EQ(1u, info.receivers.size()); |
| 2012 | 2078 VerifyVoiceReceiverInfo(info.receivers[0]); |
| 2013 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); | |
| 2014 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); | |
| 2015 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); | |
| 2016 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); | |
| 2017 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); | |
| 2018 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / | |
| 2019 (1 << 14), info.receivers[0].expand_rate); | |
| 2020 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / | |
| 2021 (1 << 14), info.receivers[0].speech_expand_rate); | |
| 2022 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / | |
| 2023 (1 << 14), info.receivers[0].secondary_decoded_rate); | |
| 2024 EXPECT_EQ( | |
| 2025 static_cast<float>(cricket::kNetStats.currentAccelerateRate) / (1 << 14), | |
| 2026 info.receivers[0].accelerate_rate); | |
| 2027 EXPECT_EQ( | |
| 2028 static_cast<float>(cricket::kNetStats.currentPreemptiveRate) / (1 << 14), | |
| 2029 info.receivers[0].preemptive_expand_rate); | |
| 2030 } | 2079 } |
| 2031 | 2080 |
| 2032 // Test that we can add and remove receive streams, and do proper send/playout. | 2081 // Test that we can add and remove receive streams, and do proper send/playout. |
| 2033 // We can receive on multiple streams while sending one stream. | 2082 // We can receive on multiple streams while sending one stream. |
| 2034 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { | 2083 TEST_F(WebRtcVoiceEngineTestFake, PlayoutWithMultipleStreams) { |
| 2035 EXPECT_TRUE(SetupEngineWithSendStream()); | 2084 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2036 int channel_num1 = voe_.GetLastChannel(); | 2085 int channel_num1 = voe_.GetLastChannel(); |
| 2037 | 2086 |
| 2038 // Start playout without a receive stream. | 2087 // Start playout without a receive stream. |
| 2039 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 2088 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2280 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].jitter_ms); | 2329 EXPECT_EQ(cricket::kIntStatValue, info.senders[0].jitter_ms); |
| 2281 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); | 2330 EXPECT_EQ(kPcmuCodec.name, info.senders[0].codec_name); |
| 2282 // TODO(sriniv): Add testing for more fields. These are not populated | 2331 // TODO(sriniv): Add testing for more fields. These are not populated |
| 2283 // in FakeWebrtcVoiceEngine yet. | 2332 // in FakeWebrtcVoiceEngine yet. |
| 2284 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].audio_level); | 2333 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].audio_level); |
| 2285 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_median_ms); | 2334 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_median_ms); |
| 2286 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_std_ms); | 2335 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_delay_std_ms); |
| 2287 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss); | 2336 // EXPECT_EQ(cricket::kIntStatValue, info.senders[0].echo_return_loss); |
| 2288 // EXPECT_EQ(cricket::kIntStatValue, | 2337 // EXPECT_EQ(cricket::kIntStatValue, |
| 2289 // info.senders[0].echo_return_loss_enhancement); | 2338 // info.senders[0].echo_return_loss_enhancement); |
| 2290 EXPECT_EQ(0u, info.receivers.size()); | 2339 // We have added one receive stream. We should see empty stats. |
| 2340 EXPECT_EQ(info.receivers.size(), 1u); | |
| 2341 EXPECT_EQ(info.receivers[0].local_stats.front().ssrc, 0); | |
| 2291 | 2342 |
| 2292 // Registered stream's remote SSRC is kSsrc2. Send a packet with SSRC=1. | 2343 // Remove the kSsrc2 stream. No receiver stats. |
| 2293 // We should drop the packet and no stats should be available. | 2344 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); |
| 2294 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | |
| 2295 EXPECT_EQ(true, channel_->GetStats(&info)); | 2345 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2296 EXPECT_EQ(0u, info.receivers.size()); | 2346 EXPECT_EQ(0u, info.receivers.size()); |
| 2297 | 2347 |
| 2298 // Remove the kSsrc2 stream and deliver a new packet - a default receive | 2348 // Deliver a new packet - a default receive stream should be created and we |
| 2299 // stream should be created and we should see stats. | 2349 // should see stats again. |
| 2300 EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2)); | |
| 2301 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); | 2350 DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame)); |
| 2351 SetAudioReceiveStreamStats(); | |
| 2302 EXPECT_EQ(true, channel_->GetStats(&info)); | 2352 EXPECT_EQ(true, channel_->GetStats(&info)); |
| 2303 EXPECT_EQ(1u, info.receivers.size()); | 2353 EXPECT_EQ(1u, info.receivers.size()); |
| 2304 | 2354 VerifyVoiceReceiverInfo(info.receivers[0]); |
| 2305 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].bytes_rcvd); | |
| 2306 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_rcvd); | |
| 2307 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].packets_lost); | |
| 2308 EXPECT_EQ(cricket::kIntStatValue, info.receivers[0].ext_seqnum); | |
| 2309 EXPECT_EQ(kPcmuCodec.name, info.receivers[0].codec_name); | |
| 2310 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentExpandRate) / | |
| 2311 (1 << 14), info.receivers[0].expand_rate); | |
| 2312 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSpeechExpandRate) / | |
| 2313 (1 << 14), info.receivers[0].speech_expand_rate); | |
| 2314 EXPECT_EQ(static_cast<float>(cricket::kNetStats.currentSecondaryDecodedRate) / | |
| 2315 (1 << 14), info.receivers[0].secondary_decoded_rate); | |
| 2316 // TODO(sriniv): Add testing for more receiver fields. | |
| 2317 } | 2355 } |
| 2318 | 2356 |
| 2319 // Test that we can set the outgoing SSRC properly with multiple streams. | 2357 // Test that we can set the outgoing SSRC properly with multiple streams. |
| 2320 // SSRC is set in SetupEngine by calling AddSendStream. | 2358 // SSRC is set in SetupEngine by calling AddSendStream. |
| 2321 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { | 2359 TEST_F(WebRtcVoiceEngineTestFake, SetSendSsrcWithMultipleStreams) { |
| 2322 EXPECT_TRUE(SetupEngineWithSendStream()); | 2360 EXPECT_TRUE(SetupEngineWithSendStream()); |
| 2323 int channel_num1 = voe_.GetLastChannel(); | 2361 int channel_num1 = voe_.GetLastChannel(); |
| 2324 unsigned int send_ssrc; | 2362 unsigned int send_ssrc; |
| 2325 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); | 2363 EXPECT_EQ(0, voe_.GetLocalSSRC(channel_num1, send_ssrc)); |
| 2326 EXPECT_EQ(kSsrc1, send_ssrc); | 2364 EXPECT_EQ(kSsrc1, send_ssrc); |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3251 cricket::WebRtcVoiceEngine engine; | 3289 cricket::WebRtcVoiceEngine engine; |
| 3252 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); | 3290 EXPECT_TRUE(engine.Init(rtc::Thread::Current())); |
| 3253 rtc::scoped_ptr<webrtc::Call> call( | 3291 rtc::scoped_ptr<webrtc::Call> call( |
| 3254 webrtc::Call::Create(webrtc::Call::Config())); | 3292 webrtc::Call::Create(webrtc::Call::Config())); |
| 3255 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), | 3293 cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::AudioOptions(), |
| 3256 call.get()); | 3294 call.get()); |
| 3257 cricket::AudioRecvParameters parameters; | 3295 cricket::AudioRecvParameters parameters; |
| 3258 parameters.codecs = engine.codecs(); | 3296 parameters.codecs = engine.codecs(); |
| 3259 EXPECT_TRUE(channel.SetRecvParameters(parameters)); | 3297 EXPECT_TRUE(channel.SetRecvParameters(parameters)); |
| 3260 } | 3298 } |
| OLD | NEW |