Chromium Code Reviews| 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 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory = nullptr) | 25 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory = nullptr) |
| 26 : voice_engine_(decoder_factory) { | 26 : voice_engine_(decoder_factory) { |
| 27 webrtc::AudioState::Config audio_state_config; | 27 webrtc::AudioState::Config audio_state_config; |
| 28 audio_state_config.voice_engine = &voice_engine_; | 28 audio_state_config.voice_engine = &voice_engine_; |
| 29 webrtc::Call::Config config(&event_log_); | 29 webrtc::Call::Config config(&event_log_); |
| 30 config.audio_state = webrtc::AudioState::Create(audio_state_config); | 30 config.audio_state = webrtc::AudioState::Create(audio_state_config); |
| 31 call_.reset(webrtc::Call::Create(config)); | 31 call_.reset(webrtc::Call::Create(config)); |
| 32 } | 32 } |
| 33 | 33 |
| 34 webrtc::Call* operator->() { return call_.get(); } | 34 webrtc::Call* operator->() { return call_.get(); } |
| 35 webrtc::test::MockVoiceEngine* voice_engine() { return &voice_engine_; } | |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 testing::NiceMock<webrtc::test::MockVoiceEngine> voice_engine_; | 38 testing::NiceMock<webrtc::test::MockVoiceEngine> voice_engine_; |
| 38 webrtc::RtcEventLogNullImpl event_log_; | 39 webrtc::RtcEventLogNullImpl event_log_; |
| 39 std::unique_ptr<webrtc::Call> call_; | 40 std::unique_ptr<webrtc::Call> call_; |
| 40 }; | 41 }; |
| 41 } // namespace | 42 } // namespace |
| 42 | 43 |
| 43 namespace webrtc { | 44 namespace webrtc { |
| 44 | 45 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 streams.push_front(stream); | 112 streams.push_front(stream); |
| 112 } | 113 } |
| 113 } | 114 } |
| 114 for (auto s : streams) { | 115 for (auto s : streams) { |
| 115 call->DestroyAudioReceiveStream(s); | 116 call->DestroyAudioReceiveStream(s); |
| 116 } | 117 } |
| 117 streams.clear(); | 118 streams.clear(); |
| 118 } | 119 } |
| 119 } | 120 } |
| 120 | 121 |
| 122 TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_RecvFirst) { | |
| 123 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory( | |
| 124 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>); | |
| 125 CallHelper call(decoder_factory); | |
| 126 | |
| 127 constexpr int kRecvChannelId = 101; | |
| 128 | |
| 129 // Set up the mock create a channel proxy which we know of, so that we can add | |
| 130 // our expectations. | |
|
kwiberg-webrtc
2016/11/11 13:47:40
Bad grammar.
the sun
2016/11/11 20:03:39
Done.
| |
| 131 test::MockVoEChannelProxy* recv_channel_proxy = nullptr; | |
| 132 EXPECT_CALL(*call.voice_engine(), ChannelProxyFactory(testing::_)) | |
| 133 .WillRepeatedly(testing::Invoke([&](int channel_id) { | |
| 134 test::MockVoEChannelProxy* channel_proxy = | |
| 135 new testing::NiceMock<test::MockVoEChannelProxy>(); | |
| 136 EXPECT_CALL(*channel_proxy, GetAudioDecoderFactory()) | |
| 137 .WillRepeatedly(testing::ReturnRef(decoder_factory)); | |
| 138 // If being called for the send channel, save a pointer to the channel | |
| 139 // proxy for later. | |
| 140 if (channel_id == kRecvChannelId) { | |
| 141 EXPECT_FALSE(recv_channel_proxy); | |
| 142 recv_channel_proxy = channel_proxy; | |
| 143 } | |
| 144 return channel_proxy; | |
| 145 })); | |
| 146 | |
| 147 AudioReceiveStream::Config recv_config; | |
| 148 recv_config.rtp.remote_ssrc = 42; | |
| 149 recv_config.rtp.local_ssrc = 777; | |
| 150 recv_config.voe_channel_id = kRecvChannelId; | |
| 151 recv_config.decoder_factory = decoder_factory; | |
| 152 AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config); | |
| 153 EXPECT_NE(recv_stream, nullptr); | |
| 154 | |
| 155 EXPECT_CALL(*recv_channel_proxy, AssociateSendChannel(testing::_)).Times(1); | |
| 156 AudioSendStream::Config send_config(nullptr); | |
| 157 send_config.rtp.ssrc = 777; | |
| 158 send_config.voe_channel_id = 123; | |
| 159 AudioSendStream* send_stream = call->CreateAudioSendStream(send_config); | |
| 160 EXPECT_NE(send_stream, nullptr); | |
| 161 | |
| 162 EXPECT_CALL(*recv_channel_proxy, DisassociateSendChannel()).Times(1); | |
| 163 call->DestroyAudioSendStream(send_stream); | |
| 164 | |
| 165 EXPECT_CALL(*recv_channel_proxy, DisassociateSendChannel()).Times(1); | |
| 166 call->DestroyAudioReceiveStream(recv_stream); | |
| 167 } | |
| 168 | |
| 169 TEST(CallTest, CreateDestroy_AssociateAudioSendReceiveStreams_SendFirst) { | |
| 170 rtc::scoped_refptr<webrtc::AudioDecoderFactory> decoder_factory( | |
| 171 new rtc::RefCountedObject<webrtc::MockAudioDecoderFactory>); | |
| 172 CallHelper call(decoder_factory); | |
| 173 | |
| 174 constexpr int kRecvChannelId = 101; | |
| 175 | |
| 176 // Set up the mock create a channel proxy which we know of, so that we can add | |
| 177 // our expectations. | |
|
kwiberg-webrtc
2016/11/11 13:47:40
Same bad grammar here.
the sun
2016/11/11 20:03:39
Done.
| |
| 178 test::MockVoEChannelProxy* recv_channel_proxy = nullptr; | |
| 179 EXPECT_CALL(*call.voice_engine(), ChannelProxyFactory(testing::_)) | |
| 180 .WillRepeatedly(testing::Invoke([&](int channel_id) { | |
| 181 test::MockVoEChannelProxy* channel_proxy = | |
| 182 new testing::NiceMock<test::MockVoEChannelProxy>(); | |
| 183 EXPECT_CALL(*channel_proxy, GetAudioDecoderFactory()) | |
| 184 .WillRepeatedly(testing::ReturnRef(decoder_factory)); | |
| 185 // If being called for the send channel, save a pointer to the channel | |
| 186 // proxy for later. | |
| 187 if (channel_id == kRecvChannelId) { | |
| 188 EXPECT_FALSE(recv_channel_proxy); | |
| 189 recv_channel_proxy = channel_proxy; | |
| 190 // We need to set this expectation here since the channel proxy is | |
| 191 // created as a side effect of CreateAudioReceiveStream(). | |
| 192 EXPECT_CALL(*recv_channel_proxy, | |
| 193 AssociateSendChannel(testing::_)).Times(1); | |
| 194 } | |
| 195 return channel_proxy; | |
| 196 })); | |
| 197 | |
| 198 AudioSendStream::Config send_config(nullptr); | |
| 199 send_config.rtp.ssrc = 777; | |
| 200 send_config.voe_channel_id = 123; | |
| 201 AudioSendStream* send_stream = call->CreateAudioSendStream(send_config); | |
| 202 EXPECT_NE(send_stream, nullptr); | |
| 203 | |
| 204 AudioReceiveStream::Config recv_config; | |
| 205 recv_config.rtp.remote_ssrc = 42; | |
| 206 recv_config.rtp.local_ssrc = 777; | |
| 207 recv_config.voe_channel_id = kRecvChannelId; | |
| 208 recv_config.decoder_factory = decoder_factory; | |
| 209 AudioReceiveStream* recv_stream = call->CreateAudioReceiveStream(recv_config); | |
| 210 EXPECT_NE(recv_stream, nullptr); | |
| 211 | |
| 212 EXPECT_CALL(*recv_channel_proxy, DisassociateSendChannel()).Times(1); | |
| 213 call->DestroyAudioReceiveStream(recv_stream); | |
| 214 | |
| 215 call->DestroyAudioSendStream(send_stream); | |
| 216 } | |
| 217 | |
| 121 TEST(CallTest, CreateDestroy_FlexfecReceiveStream) { | 218 TEST(CallTest, CreateDestroy_FlexfecReceiveStream) { |
| 122 CallHelper call; | 219 CallHelper call; |
| 123 FlexfecReceiveStream::Config config; | 220 FlexfecReceiveStream::Config config; |
| 124 config.flexfec_payload_type = 118; | 221 config.flexfec_payload_type = 118; |
| 125 config.flexfec_ssrc = 38837212; | 222 config.flexfec_ssrc = 38837212; |
| 126 config.protected_media_ssrcs = {27273}; | 223 config.protected_media_ssrcs = {27273}; |
| 127 | 224 |
| 128 FlexfecReceiveStream* stream = call->CreateFlexfecReceiveStream(config); | 225 FlexfecReceiveStream* stream = call->CreateFlexfecReceiveStream(config); |
| 129 EXPECT_NE(stream, nullptr); | 226 EXPECT_NE(stream, nullptr); |
| 130 call->DestroyFlexfecReceiveStream(stream); | 227 call->DestroyFlexfecReceiveStream(stream); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 stream = call->CreateFlexfecReceiveStream(config); | 279 stream = call->CreateFlexfecReceiveStream(config); |
| 183 EXPECT_NE(stream, nullptr); | 280 EXPECT_NE(stream, nullptr); |
| 184 streams.push_back(stream); | 281 streams.push_back(stream); |
| 185 | 282 |
| 186 for (auto s : streams) { | 283 for (auto s : streams) { |
| 187 call->DestroyFlexfecReceiveStream(s); | 284 call->DestroyFlexfecReceiveStream(s); |
| 188 } | 285 } |
| 189 } | 286 } |
| 190 | 287 |
| 191 } // namespace webrtc | 288 } // namespace webrtc |
| OLD | NEW |