OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "talk/media/webrtc/fakewebrtccall.h" | 28 #include "talk/media/webrtc/fakewebrtccall.h" |
29 | 29 |
30 #include <algorithm> | 30 #include <algorithm> |
31 | 31 |
32 #include "talk/media/base/rtputils.h" | 32 #include "talk/media/base/rtputils.h" |
33 #include "webrtc/base/checks.h" | 33 #include "webrtc/base/checks.h" |
34 #include "webrtc/base/gunit.h" | 34 #include "webrtc/base/gunit.h" |
35 | 35 |
36 namespace cricket { | 36 namespace cricket { |
| 37 FakeAudioSendStream::FakeAudioSendStream( |
| 38 const webrtc::AudioSendStream::Config& config) : config_(config) { |
| 39 RTC_DCHECK(config.voe_channel_id != -1); |
| 40 } |
| 41 |
| 42 webrtc::AudioSendStream::Stats FakeAudioSendStream::GetStats() const { |
| 43 return webrtc::AudioSendStream::Stats(); |
| 44 } |
| 45 |
| 46 const webrtc::AudioSendStream::Config& |
| 47 FakeAudioSendStream::GetConfig() const { |
| 48 return config_; |
| 49 } |
| 50 |
37 FakeAudioReceiveStream::FakeAudioReceiveStream( | 51 FakeAudioReceiveStream::FakeAudioReceiveStream( |
38 const webrtc::AudioReceiveStream::Config& config) | 52 const webrtc::AudioReceiveStream::Config& config) |
39 : config_(config), received_packets_(0) { | 53 : config_(config), received_packets_(0) { |
40 RTC_DCHECK(config.voe_channel_id != -1); | 54 RTC_DCHECK(config.voe_channel_id != -1); |
41 } | 55 } |
42 | 56 |
43 webrtc::AudioReceiveStream::Stats FakeAudioReceiveStream::GetStats() const { | 57 webrtc::AudioReceiveStream::Stats FakeAudioReceiveStream::GetStats() const { |
44 return webrtc::AudioReceiveStream::Stats(); | 58 return webrtc::AudioReceiveStream::Stats(); |
45 } | 59 } |
46 | 60 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 213 } |
200 | 214 |
201 FakeCall::FakeCall(const webrtc::Call::Config& config) | 215 FakeCall::FakeCall(const webrtc::Call::Config& config) |
202 : config_(config), | 216 : config_(config), |
203 network_state_(webrtc::kNetworkUp), | 217 network_state_(webrtc::kNetworkUp), |
204 num_created_send_streams_(0), | 218 num_created_send_streams_(0), |
205 num_created_receive_streams_(0) {} | 219 num_created_receive_streams_(0) {} |
206 | 220 |
207 FakeCall::~FakeCall() { | 221 FakeCall::~FakeCall() { |
208 EXPECT_EQ(0u, video_send_streams_.size()); | 222 EXPECT_EQ(0u, video_send_streams_.size()); |
| 223 EXPECT_EQ(0u, audio_send_streams_.size()); |
209 EXPECT_EQ(0u, video_receive_streams_.size()); | 224 EXPECT_EQ(0u, video_receive_streams_.size()); |
210 EXPECT_EQ(0u, audio_receive_streams_.size()); | 225 EXPECT_EQ(0u, audio_receive_streams_.size()); |
211 } | 226 } |
212 | 227 |
213 webrtc::Call::Config FakeCall::GetConfig() const { | 228 webrtc::Call::Config FakeCall::GetConfig() const { |
214 return config_; | 229 return config_; |
215 } | 230 } |
216 | 231 |
217 const std::vector<FakeVideoSendStream*>& FakeCall::GetVideoSendStreams() { | 232 const std::vector<FakeVideoSendStream*>& FakeCall::GetVideoSendStreams() { |
218 return video_send_streams_; | 233 return video_send_streams_; |
219 } | 234 } |
220 | 235 |
221 const std::vector<FakeVideoReceiveStream*>& FakeCall::GetVideoReceiveStreams() { | 236 const std::vector<FakeVideoReceiveStream*>& FakeCall::GetVideoReceiveStreams() { |
222 return video_receive_streams_; | 237 return video_receive_streams_; |
223 } | 238 } |
224 | 239 |
| 240 const std::vector<FakeAudioSendStream*>& FakeCall::GetAudioSendStreams() { |
| 241 return audio_send_streams_; |
| 242 } |
| 243 |
| 244 const FakeAudioSendStream* FakeCall::GetAudioSendStream(uint32_t ssrc) { |
| 245 for (const auto* p : GetAudioSendStreams()) { |
| 246 if (p->GetConfig().rtp.ssrc == ssrc) { |
| 247 return p; |
| 248 } |
| 249 } |
| 250 return nullptr; |
| 251 } |
| 252 |
225 const std::vector<FakeAudioReceiveStream*>& FakeCall::GetAudioReceiveStreams() { | 253 const std::vector<FakeAudioReceiveStream*>& FakeCall::GetAudioReceiveStreams() { |
226 return audio_receive_streams_; | 254 return audio_receive_streams_; |
227 } | 255 } |
228 | 256 |
229 const FakeAudioReceiveStream* FakeCall::GetAudioReceiveStream(uint32_t ssrc) { | 257 const FakeAudioReceiveStream* FakeCall::GetAudioReceiveStream(uint32_t ssrc) { |
230 for (const auto p : GetAudioReceiveStreams()) { | 258 for (const auto* p : GetAudioReceiveStreams()) { |
231 if (p->GetConfig().rtp.remote_ssrc == ssrc) { | 259 if (p->GetConfig().rtp.remote_ssrc == ssrc) { |
232 return p; | 260 return p; |
233 } | 261 } |
234 } | 262 } |
235 return nullptr; | 263 return nullptr; |
236 } | 264 } |
237 | 265 |
238 webrtc::NetworkState FakeCall::GetNetworkState() const { | 266 webrtc::NetworkState FakeCall::GetNetworkState() const { |
239 return network_state_; | 267 return network_state_; |
240 } | 268 } |
241 | 269 |
242 webrtc::AudioSendStream* FakeCall::CreateAudioSendStream( | 270 webrtc::AudioSendStream* FakeCall::CreateAudioSendStream( |
243 const webrtc::AudioSendStream::Config& config) { | 271 const webrtc::AudioSendStream::Config& config) { |
244 return nullptr; | 272 FakeAudioSendStream* fake_stream = new FakeAudioSendStream(config); |
| 273 audio_send_streams_.push_back(fake_stream); |
| 274 ++num_created_send_streams_; |
| 275 return fake_stream; |
245 } | 276 } |
246 | 277 |
247 void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { | 278 void FakeCall::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) { |
| 279 auto it = std::find(audio_send_streams_.begin(), |
| 280 audio_send_streams_.end(), |
| 281 static_cast<FakeAudioSendStream*>(send_stream)); |
| 282 if (it == audio_send_streams_.end()) { |
| 283 ADD_FAILURE() << "DestroyAudioSendStream called with unknown paramter."; |
| 284 } else { |
| 285 delete *it; |
| 286 audio_send_streams_.erase(it); |
| 287 } |
248 } | 288 } |
249 | 289 |
250 webrtc::AudioReceiveStream* FakeCall::CreateAudioReceiveStream( | 290 webrtc::AudioReceiveStream* FakeCall::CreateAudioReceiveStream( |
251 const webrtc::AudioReceiveStream::Config& config) { | 291 const webrtc::AudioReceiveStream::Config& config) { |
252 audio_receive_streams_.push_back(new FakeAudioReceiveStream(config)); | 292 audio_receive_streams_.push_back(new FakeAudioReceiveStream(config)); |
253 ++num_created_receive_streams_; | 293 ++num_created_receive_streams_; |
254 return audio_receive_streams_.back(); | 294 return audio_receive_streams_.back(); |
255 } | 295 } |
256 | 296 |
257 void FakeCall::DestroyAudioReceiveStream( | 297 void FakeCall::DestroyAudioReceiveStream( |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 404 } |
365 | 405 |
366 void FakeCall::SignalNetworkState(webrtc::NetworkState state) { | 406 void FakeCall::SignalNetworkState(webrtc::NetworkState state) { |
367 network_state_ = state; | 407 network_state_ = state; |
368 } | 408 } |
369 | 409 |
370 void FakeCall::OnSentPacket(const rtc::SentPacket& sent_packet) { | 410 void FakeCall::OnSentPacket(const rtc::SentPacket& sent_packet) { |
371 last_sent_packet_ = sent_packet; | 411 last_sent_packet_ = sent_packet; |
372 } | 412 } |
373 } // namespace cricket | 413 } // namespace cricket |
OLD | NEW |