OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 #include "webrtc/audio/audio_receive_stream.h" | 16 #include "webrtc/audio/audio_receive_stream.h" |
17 #include "webrtc/audio/conversion.h" | 17 #include "webrtc/audio/conversion.h" |
| 18 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_decoder_factory.h" |
18 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" | 19 #include "webrtc/modules/bitrate_controller/include/mock/mock_bitrate_controller
.h" |
19 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont
roller.h" | 20 #include "webrtc/modules/congestion_controller/include/mock/mock_congestion_cont
roller.h" |
20 #include "webrtc/modules/pacing/packet_router.h" | 21 #include "webrtc/modules/pacing/packet_router.h" |
21 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitra
te_estimator.h" |
22 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" | 23 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
23 #include "webrtc/system_wrappers/include/clock.h" | 24 #include "webrtc/system_wrappers/include/clock.h" |
24 #include "webrtc/test/mock_voe_channel_proxy.h" | 25 #include "webrtc/test/mock_voe_channel_proxy.h" |
25 #include "webrtc/test/mock_voice_engine.h" | 26 #include "webrtc/test/mock_voice_engine.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
28 namespace test { | 29 namespace test { |
29 namespace { | 30 namespace { |
30 | 31 |
31 using testing::_; | 32 using testing::_; |
32 using testing::Return; | 33 using testing::Return; |
| 34 using testing::ReturnRef; |
33 | 35 |
34 AudioDecodingCallStats MakeAudioDecodeStatsForTest() { | 36 AudioDecodingCallStats MakeAudioDecodeStatsForTest() { |
35 AudioDecodingCallStats audio_decode_stats; | 37 AudioDecodingCallStats audio_decode_stats; |
36 audio_decode_stats.calls_to_silence_generator = 234; | 38 audio_decode_stats.calls_to_silence_generator = 234; |
37 audio_decode_stats.calls_to_neteq = 567; | 39 audio_decode_stats.calls_to_neteq = 567; |
38 audio_decode_stats.decoded_normal = 890; | 40 audio_decode_stats.decoded_normal = 890; |
39 audio_decode_stats.decoded_plc = 123; | 41 audio_decode_stats.decoded_plc = 123; |
40 audio_decode_stats.decoded_cng = 456; | 42 audio_decode_stats.decoded_cng = 456; |
41 audio_decode_stats.decoded_plc_cng = 789; | 43 audio_decode_stats.decoded_plc_cng = 789; |
42 return audio_decode_stats; | 44 return audio_decode_stats; |
(...skipping 14 matching lines...) Expand all Loading... |
57 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; | 59 345, 678, 901, 234, -12, 3456, 7890, 567, 890, 123}; |
58 const CodecInst kCodecInst = { | 60 const CodecInst kCodecInst = { |
59 123, "codec_name_recv", 96000, -187, 0, -103}; | 61 123, "codec_name_recv", 96000, -187, 0, -103}; |
60 const NetworkStatistics kNetworkStats = { | 62 const NetworkStatistics kNetworkStats = { |
61 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; | 63 123, 456, false, 0, 0, 789, 12, 345, 678, 901, -1, -1, -1, -1, -1, 0}; |
62 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); | 64 const AudioDecodingCallStats kAudioDecodeStats = MakeAudioDecodeStatsForTest(); |
63 | 65 |
64 struct ConfigHelper { | 66 struct ConfigHelper { |
65 ConfigHelper() | 67 ConfigHelper() |
66 : simulated_clock_(123456), | 68 : simulated_clock_(123456), |
| 69 decoder_factory_(new rtc::RefCountedObject<MockAudioDecoderFactory>), |
67 congestion_controller_(&simulated_clock_, | 70 congestion_controller_(&simulated_clock_, |
68 &bitrate_observer_, | 71 &bitrate_observer_, |
69 &remote_bitrate_observer_) { | 72 &remote_bitrate_observer_) { |
70 using testing::Invoke; | 73 using testing::Invoke; |
71 | 74 |
72 EXPECT_CALL(voice_engine_, | 75 EXPECT_CALL(voice_engine_, |
73 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); | 76 RegisterVoiceEngineObserver(_)).WillOnce(Return(0)); |
74 EXPECT_CALL(voice_engine_, | 77 EXPECT_CALL(voice_engine_, |
75 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); | 78 DeRegisterVoiceEngineObserver()).WillOnce(Return(0)); |
76 AudioState::Config config; | 79 AudioState::Config config; |
(...skipping 18 matching lines...) Expand all Loading... |
95 RegisterReceiverCongestionControlObjects(&packet_router_)) | 98 RegisterReceiverCongestionControlObjects(&packet_router_)) |
96 .Times(1); | 99 .Times(1); |
97 EXPECT_CALL(congestion_controller_, packet_router()) | 100 EXPECT_CALL(congestion_controller_, packet_router()) |
98 .WillOnce(Return(&packet_router_)); | 101 .WillOnce(Return(&packet_router_)); |
99 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()) | 102 EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects()) |
100 .Times(1); | 103 .Times(1); |
101 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)) | 104 EXPECT_CALL(*channel_proxy_, RegisterExternalTransport(nullptr)) |
102 .Times(1); | 105 .Times(1); |
103 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()) | 106 EXPECT_CALL(*channel_proxy_, DeRegisterExternalTransport()) |
104 .Times(1); | 107 .Times(1); |
| 108 EXPECT_CALL(*channel_proxy_, GetAudioDecoderFactory()) |
| 109 .WillOnce(ReturnRef(decoder_factory_)); |
105 return channel_proxy_; | 110 return channel_proxy_; |
106 })); | 111 })); |
107 stream_config_.voe_channel_id = kChannelId; | 112 stream_config_.voe_channel_id = kChannelId; |
108 stream_config_.rtp.local_ssrc = kLocalSsrc; | 113 stream_config_.rtp.local_ssrc = kLocalSsrc; |
109 stream_config_.rtp.remote_ssrc = kRemoteSsrc; | 114 stream_config_.rtp.remote_ssrc = kRemoteSsrc; |
110 stream_config_.rtp.extensions.push_back( | 115 stream_config_.rtp.extensions.push_back( |
111 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId)); | 116 RtpExtension(RtpExtension::kAbsSendTimeUri, kAbsSendTimeId)); |
112 stream_config_.rtp.extensions.push_back( | 117 stream_config_.rtp.extensions.push_back( |
113 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId)); | 118 RtpExtension(RtpExtension::kAudioLevelUri, kAudioLevelId)); |
114 stream_config_.rtp.extensions.push_back(RtpExtension( | 119 stream_config_.rtp.extensions.push_back(RtpExtension( |
115 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); | 120 RtpExtension::kTransportSequenceNumberUri, kTransportSequenceNumberId)); |
| 121 stream_config_.decoder_factory = decoder_factory_; |
116 } | 122 } |
117 | 123 |
118 MockCongestionController* congestion_controller() { | 124 MockCongestionController* congestion_controller() { |
119 return &congestion_controller_; | 125 return &congestion_controller_; |
120 } | 126 } |
121 MockRemoteBitrateEstimator* remote_bitrate_estimator() { | 127 MockRemoteBitrateEstimator* remote_bitrate_estimator() { |
122 return &remote_bitrate_estimator_; | 128 return &remote_bitrate_estimator_; |
123 } | 129 } |
124 AudioReceiveStream::Config& config() { return stream_config_; } | 130 AudioReceiveStream::Config& config() { return stream_config_; } |
125 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } | 131 rtc::scoped_refptr<AudioState> audio_state() { return audio_state_; } |
(...skipping 26 matching lines...) Expand all Loading... |
152 | 158 |
153 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _)) | 159 EXPECT_CALL(voice_engine_, GetRecCodec(kChannelId, _)) |
154 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); | 160 .WillOnce(DoAll(SetArgReferee<1>(kCodecInst), Return(0))); |
155 } | 161 } |
156 | 162 |
157 private: | 163 private: |
158 SimulatedClock simulated_clock_; | 164 SimulatedClock simulated_clock_; |
159 PacketRouter packet_router_; | 165 PacketRouter packet_router_; |
160 testing::NiceMock<MockCongestionObserver> bitrate_observer_; | 166 testing::NiceMock<MockCongestionObserver> bitrate_observer_; |
161 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; | 167 testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_; |
| 168 rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_; |
162 MockCongestionController congestion_controller_; | 169 MockCongestionController congestion_controller_; |
163 MockRemoteBitrateEstimator remote_bitrate_estimator_; | 170 MockRemoteBitrateEstimator remote_bitrate_estimator_; |
164 testing::StrictMock<MockVoiceEngine> voice_engine_; | 171 testing::StrictMock<MockVoiceEngine> voice_engine_; |
165 rtc::scoped_refptr<AudioState> audio_state_; | 172 rtc::scoped_refptr<AudioState> audio_state_; |
166 AudioReceiveStream::Config stream_config_; | 173 AudioReceiveStream::Config stream_config_; |
167 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; | 174 testing::StrictMock<MockVoEChannelProxy>* channel_proxy_ = nullptr; |
168 }; | 175 }; |
169 | 176 |
170 void BuildOneByteExtension(std::vector<uint8_t>::iterator it, | 177 void BuildOneByteExtension(std::vector<uint8_t>::iterator it, |
171 int id, | 178 int id, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); | 338 EXPECT_EQ(kAudioDecodeStats.calls_to_neteq, stats.decoding_calls_to_neteq); |
332 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); | 339 EXPECT_EQ(kAudioDecodeStats.decoded_normal, stats.decoding_normal); |
333 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); | 340 EXPECT_EQ(kAudioDecodeStats.decoded_plc, stats.decoding_plc); |
334 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); | 341 EXPECT_EQ(kAudioDecodeStats.decoded_cng, stats.decoding_cng); |
335 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); | 342 EXPECT_EQ(kAudioDecodeStats.decoded_plc_cng, stats.decoding_plc_cng); |
336 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, | 343 EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_, |
337 stats.capture_start_ntp_time_ms); | 344 stats.capture_start_ntp_time_ms); |
338 } | 345 } |
339 } // namespace test | 346 } // namespace test |
340 } // namespace webrtc | 347 } // namespace webrtc |
OLD | NEW |