OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 void set_fail_set_send_codecs(bool fail) { fail_set_send_codecs_ = fail; } | 106 void set_fail_set_send_codecs(bool fail) { fail_set_send_codecs_ = fail; } |
107 void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; } | 107 void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; } |
108 virtual bool AddSendStream(const StreamParams& sp) { | 108 virtual bool AddSendStream(const StreamParams& sp) { |
109 if (std::find(send_streams_.begin(), send_streams_.end(), sp) != | 109 if (std::find(send_streams_.begin(), send_streams_.end(), sp) != |
110 send_streams_.end()) { | 110 send_streams_.end()) { |
111 return false; | 111 return false; |
112 } | 112 } |
113 send_streams_.push_back(sp); | 113 send_streams_.push_back(sp); |
114 return true; | 114 return true; |
115 } | 115 } |
116 virtual bool RemoveSendStream(uint32 ssrc) { | 116 virtual bool RemoveSendStream(uint32_t ssrc) { |
117 return RemoveStreamBySsrc(&send_streams_, ssrc); | 117 return RemoveStreamBySsrc(&send_streams_, ssrc); |
118 } | 118 } |
119 virtual bool AddRecvStream(const StreamParams& sp) { | 119 virtual bool AddRecvStream(const StreamParams& sp) { |
120 if (std::find(receive_streams_.begin(), receive_streams_.end(), sp) != | 120 if (std::find(receive_streams_.begin(), receive_streams_.end(), sp) != |
121 receive_streams_.end()) { | 121 receive_streams_.end()) { |
122 return false; | 122 return false; |
123 } | 123 } |
124 receive_streams_.push_back(sp); | 124 receive_streams_.push_back(sp); |
125 return true; | 125 return true; |
126 } | 126 } |
127 virtual bool RemoveRecvStream(uint32 ssrc) { | 127 virtual bool RemoveRecvStream(uint32_t ssrc) { |
128 return RemoveStreamBySsrc(&receive_streams_, ssrc); | 128 return RemoveStreamBySsrc(&receive_streams_, ssrc); |
129 } | 129 } |
130 bool IsStreamMuted(uint32 ssrc) const { | 130 bool IsStreamMuted(uint32_t ssrc) const { |
131 bool ret = muted_streams_.find(ssrc) != muted_streams_.end(); | 131 bool ret = muted_streams_.find(ssrc) != muted_streams_.end(); |
132 // If |ssrc = 0| check if the first send stream is muted. | 132 // If |ssrc = 0| check if the first send stream is muted. |
133 if (!ret && ssrc == 0 && !send_streams_.empty()) { | 133 if (!ret && ssrc == 0 && !send_streams_.empty()) { |
134 return muted_streams_.find(send_streams_[0].first_ssrc()) != | 134 return muted_streams_.find(send_streams_[0].first_ssrc()) != |
135 muted_streams_.end(); | 135 muted_streams_.end(); |
136 } | 136 } |
137 return ret; | 137 return ret; |
138 } | 138 } |
139 const std::vector<StreamParams>& send_streams() const { | 139 const std::vector<StreamParams>& send_streams() const { |
140 return send_streams_; | 140 return send_streams_; |
141 } | 141 } |
142 const std::vector<StreamParams>& recv_streams() const { | 142 const std::vector<StreamParams>& recv_streams() const { |
143 return receive_streams_; | 143 return receive_streams_; |
144 } | 144 } |
145 bool HasRecvStream(uint32 ssrc) const { | 145 bool HasRecvStream(uint32_t ssrc) const { |
146 return GetStreamBySsrc(receive_streams_, ssrc) != nullptr; | 146 return GetStreamBySsrc(receive_streams_, ssrc) != nullptr; |
147 } | 147 } |
148 bool HasSendStream(uint32 ssrc) const { | 148 bool HasSendStream(uint32_t ssrc) const { |
149 return GetStreamBySsrc(send_streams_, ssrc) != nullptr; | 149 return GetStreamBySsrc(send_streams_, ssrc) != nullptr; |
150 } | 150 } |
151 // TODO(perkj): This is to support legacy unit test that only check one | 151 // TODO(perkj): This is to support legacy unit test that only check one |
152 // sending stream. | 152 // sending stream. |
153 uint32 send_ssrc() const { | 153 uint32_t send_ssrc() const { |
154 if (send_streams_.empty()) | 154 if (send_streams_.empty()) |
155 return 0; | 155 return 0; |
156 return send_streams_[0].first_ssrc(); | 156 return send_streams_[0].first_ssrc(); |
157 } | 157 } |
158 | 158 |
159 // TODO(perkj): This is to support legacy unit test that only check one | 159 // TODO(perkj): This is to support legacy unit test that only check one |
160 // sending stream. | 160 // sending stream. |
161 const std::string rtcp_cname() { | 161 const std::string rtcp_cname() { |
162 if (send_streams_.empty()) | 162 if (send_streams_.empty()) |
163 return ""; | 163 return ""; |
164 return send_streams_[0].cname; | 164 return send_streams_[0].cname; |
165 } | 165 } |
166 | 166 |
167 bool ready_to_send() const { | 167 bool ready_to_send() const { |
168 return ready_to_send_; | 168 return ready_to_send_; |
169 } | 169 } |
170 | 170 |
171 protected: | 171 protected: |
172 bool MuteStream(uint32 ssrc, bool mute) { | 172 bool MuteStream(uint32_t ssrc, bool mute) { |
173 if (!HasSendStream(ssrc) && ssrc != 0) { | 173 if (!HasSendStream(ssrc) && ssrc != 0) { |
174 return false; | 174 return false; |
175 } | 175 } |
176 if (mute) { | 176 if (mute) { |
177 muted_streams_.insert(ssrc); | 177 muted_streams_.insert(ssrc); |
178 } else { | 178 } else { |
179 muted_streams_.erase(ssrc); | 179 muted_streams_.erase(ssrc); |
180 } | 180 } |
181 return true; | 181 return true; |
182 } | 182 } |
(...skipping 28 matching lines...) Expand all Loading... |
211 | 211 |
212 private: | 212 private: |
213 bool sending_; | 213 bool sending_; |
214 bool playout_; | 214 bool playout_; |
215 std::vector<RtpHeaderExtension> recv_extensions_; | 215 std::vector<RtpHeaderExtension> recv_extensions_; |
216 std::vector<RtpHeaderExtension> send_extensions_; | 216 std::vector<RtpHeaderExtension> send_extensions_; |
217 std::list<std::string> rtp_packets_; | 217 std::list<std::string> rtp_packets_; |
218 std::list<std::string> rtcp_packets_; | 218 std::list<std::string> rtcp_packets_; |
219 std::vector<StreamParams> send_streams_; | 219 std::vector<StreamParams> send_streams_; |
220 std::vector<StreamParams> receive_streams_; | 220 std::vector<StreamParams> receive_streams_; |
221 std::set<uint32> muted_streams_; | 221 std::set<uint32_t> muted_streams_; |
222 bool fail_set_send_codecs_; | 222 bool fail_set_send_codecs_; |
223 bool fail_set_recv_codecs_; | 223 bool fail_set_recv_codecs_; |
224 uint32 send_ssrc_; | 224 uint32_t send_ssrc_; |
225 std::string rtcp_cname_; | 225 std::string rtcp_cname_; |
226 bool ready_to_send_; | 226 bool ready_to_send_; |
227 }; | 227 }; |
228 | 228 |
229 class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> { | 229 class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> { |
230 public: | 230 public: |
231 struct DtmfInfo { | 231 struct DtmfInfo { |
232 DtmfInfo(uint32 ssrc, int event_code, int duration, int flags) | 232 DtmfInfo(uint32_t ssrc, int event_code, int duration, int flags) |
233 : ssrc(ssrc), event_code(event_code), duration(duration), flags(flags) { | 233 : ssrc(ssrc), |
234 } | 234 event_code(event_code), |
235 uint32 ssrc; | 235 duration(duration), |
| 236 flags(flags) {} |
| 237 uint32_t ssrc; |
236 int event_code; | 238 int event_code; |
237 int duration; | 239 int duration; |
238 int flags; | 240 int flags; |
239 }; | 241 }; |
240 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, | 242 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, |
241 const AudioOptions& options) | 243 const AudioOptions& options) |
242 : engine_(engine), | 244 : engine_(engine), |
243 time_since_last_typing_(-1) { | 245 time_since_last_typing_(-1) { |
244 output_scalings_[0] = OutputScaling(); // For default channel. | 246 output_scalings_[0] = OutputScaling(); // For default channel. |
245 SetOptions(options); | 247 SetOptions(options); |
(...skipping 18 matching lines...) Expand all Loading... |
264 return (SetRecvCodecs(params.codecs) && | 266 return (SetRecvCodecs(params.codecs) && |
265 SetRecvRtpHeaderExtensions(params.extensions)); | 267 SetRecvRtpHeaderExtensions(params.extensions)); |
266 } | 268 } |
267 virtual bool SetPlayout(bool playout) { | 269 virtual bool SetPlayout(bool playout) { |
268 set_playout(playout); | 270 set_playout(playout); |
269 return true; | 271 return true; |
270 } | 272 } |
271 virtual bool SetSend(SendFlags flag) { | 273 virtual bool SetSend(SendFlags flag) { |
272 return set_sending(flag != SEND_NOTHING); | 274 return set_sending(flag != SEND_NOTHING); |
273 } | 275 } |
274 virtual bool SetAudioSend(uint32 ssrc, bool enable, | 276 virtual bool SetAudioSend(uint32_t ssrc, |
| 277 bool enable, |
275 const AudioOptions* options, | 278 const AudioOptions* options, |
276 AudioRenderer* renderer) { | 279 AudioRenderer* renderer) { |
277 if (!SetLocalRenderer(ssrc, renderer)) { | 280 if (!SetLocalRenderer(ssrc, renderer)) { |
278 return false; | 281 return false; |
279 } | 282 } |
280 if (!RtpHelper<VoiceMediaChannel>::MuteStream(ssrc, !enable)) { | 283 if (!RtpHelper<VoiceMediaChannel>::MuteStream(ssrc, !enable)) { |
281 return false; | 284 return false; |
282 } | 285 } |
283 if (enable && options) { | 286 if (enable && options) { |
284 return SetOptions(*options); | 287 return SetOptions(*options); |
285 } | 288 } |
286 return true; | 289 return true; |
287 } | 290 } |
288 virtual bool AddRecvStream(const StreamParams& sp) { | 291 virtual bool AddRecvStream(const StreamParams& sp) { |
289 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp)) | 292 if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp)) |
290 return false; | 293 return false; |
291 output_scalings_[sp.first_ssrc()] = OutputScaling(); | 294 output_scalings_[sp.first_ssrc()] = OutputScaling(); |
292 return true; | 295 return true; |
293 } | 296 } |
294 virtual bool RemoveRecvStream(uint32 ssrc) { | 297 virtual bool RemoveRecvStream(uint32_t ssrc) { |
295 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc)) | 298 if (!RtpHelper<VoiceMediaChannel>::RemoveRecvStream(ssrc)) |
296 return false; | 299 return false; |
297 output_scalings_.erase(ssrc); | 300 output_scalings_.erase(ssrc); |
298 return true; | 301 return true; |
299 } | 302 } |
300 virtual bool SetRemoteRenderer(uint32 ssrc, AudioRenderer* renderer) { | 303 virtual bool SetRemoteRenderer(uint32_t ssrc, AudioRenderer* renderer) { |
301 std::map<uint32, AudioRenderer*>::iterator it = | 304 std::map<uint32_t, AudioRenderer*>::iterator it = |
302 remote_renderers_.find(ssrc); | 305 remote_renderers_.find(ssrc); |
303 if (renderer) { | 306 if (renderer) { |
304 if (it != remote_renderers_.end()) { | 307 if (it != remote_renderers_.end()) { |
305 ASSERT(it->second == renderer); | 308 ASSERT(it->second == renderer); |
306 } else { | 309 } else { |
307 remote_renderers_.insert(std::make_pair(ssrc, renderer)); | 310 remote_renderers_.insert(std::make_pair(ssrc, renderer)); |
308 renderer->AddChannel(0); | 311 renderer->AddChannel(0); |
309 } | 312 } |
310 } else { | 313 } else { |
311 if (it != remote_renderers_.end()) { | 314 if (it != remote_renderers_.end()) { |
(...skipping 17 matching lines...) Expand all Loading... |
329 virtual bool CanInsertDtmf() { | 332 virtual bool CanInsertDtmf() { |
330 for (std::vector<AudioCodec>::const_iterator it = send_codecs_.begin(); | 333 for (std::vector<AudioCodec>::const_iterator it = send_codecs_.begin(); |
331 it != send_codecs_.end(); ++it) { | 334 it != send_codecs_.end(); ++it) { |
332 // Find the DTMF telephone event "codec". | 335 // Find the DTMF telephone event "codec". |
333 if (_stricmp(it->name.c_str(), "telephone-event") == 0) { | 336 if (_stricmp(it->name.c_str(), "telephone-event") == 0) { |
334 return true; | 337 return true; |
335 } | 338 } |
336 } | 339 } |
337 return false; | 340 return false; |
338 } | 341 } |
339 virtual bool InsertDtmf(uint32 ssrc, int event_code, int duration, | 342 virtual bool InsertDtmf(uint32_t ssrc, |
| 343 int event_code, |
| 344 int duration, |
340 int flags) { | 345 int flags) { |
341 dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags)); | 346 dtmf_info_queue_.push_back(DtmfInfo(ssrc, event_code, duration, flags)); |
342 return true; | 347 return true; |
343 } | 348 } |
344 | 349 |
345 virtual bool SetOutputScaling(uint32 ssrc, double left, double right) { | 350 virtual bool SetOutputScaling(uint32_t ssrc, double left, double right) { |
346 if (0 == ssrc) { | 351 if (0 == ssrc) { |
347 std::map<uint32, OutputScaling>::iterator it; | 352 std::map<uint32_t, OutputScaling>::iterator it; |
348 for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) { | 353 for (it = output_scalings_.begin(); it != output_scalings_.end(); ++it) { |
349 it->second.left = left; | 354 it->second.left = left; |
350 it->second.right = right; | 355 it->second.right = right; |
351 } | 356 } |
352 return true; | 357 return true; |
353 } else if (output_scalings_.find(ssrc) != output_scalings_.end()) { | 358 } else if (output_scalings_.find(ssrc) != output_scalings_.end()) { |
354 output_scalings_[ssrc].left = left; | 359 output_scalings_[ssrc].left = left; |
355 output_scalings_[ssrc].right = right; | 360 output_scalings_[ssrc].right = right; |
356 return true; | 361 return true; |
357 } | 362 } |
358 return false; | 363 return false; |
359 } | 364 } |
360 bool GetOutputScaling(uint32 ssrc, double* left, double* right) { | 365 bool GetOutputScaling(uint32_t ssrc, double* left, double* right) { |
361 if (output_scalings_.find(ssrc) == output_scalings_.end()) | 366 if (output_scalings_.find(ssrc) == output_scalings_.end()) |
362 return false; | 367 return false; |
363 *left = output_scalings_[ssrc].left; | 368 *left = output_scalings_[ssrc].left; |
364 *right = output_scalings_[ssrc].right; | 369 *right = output_scalings_[ssrc].right; |
365 return true; | 370 return true; |
366 } | 371 } |
367 | 372 |
368 virtual bool GetStats(VoiceMediaInfo* info) { return false; } | 373 virtual bool GetStats(VoiceMediaInfo* info) { return false; } |
369 | 374 |
370 private: | 375 private: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 } | 418 } |
414 send_codecs_ = codecs; | 419 send_codecs_ = codecs; |
415 return true; | 420 return true; |
416 } | 421 } |
417 bool SetMaxSendBandwidth(int bps) { return true; } | 422 bool SetMaxSendBandwidth(int bps) { return true; } |
418 bool SetOptions(const AudioOptions& options) { | 423 bool SetOptions(const AudioOptions& options) { |
419 // Does a "merge" of current options and set options. | 424 // Does a "merge" of current options and set options. |
420 options_.SetAll(options); | 425 options_.SetAll(options); |
421 return true; | 426 return true; |
422 } | 427 } |
423 bool SetLocalRenderer(uint32 ssrc, AudioRenderer* renderer) { | 428 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer) { |
424 auto it = local_renderers_.find(ssrc); | 429 auto it = local_renderers_.find(ssrc); |
425 if (renderer) { | 430 if (renderer) { |
426 if (it != local_renderers_.end()) { | 431 if (it != local_renderers_.end()) { |
427 ASSERT(it->second->renderer() == renderer); | 432 ASSERT(it->second->renderer() == renderer); |
428 } else { | 433 } else { |
429 local_renderers_.insert(std::make_pair( | 434 local_renderers_.insert(std::make_pair( |
430 ssrc, new VoiceChannelAudioSink(renderer))); | 435 ssrc, new VoiceChannelAudioSink(renderer))); |
431 } | 436 } |
432 } else { | 437 } else { |
433 if (it != local_renderers_.end()) { | 438 if (it != local_renderers_.end()) { |
434 delete it->second; | 439 delete it->second; |
435 local_renderers_.erase(it); | 440 local_renderers_.erase(it); |
436 } | 441 } |
437 } | 442 } |
438 return true; | 443 return true; |
439 } | 444 } |
440 | 445 |
441 FakeVoiceEngine* engine_; | 446 FakeVoiceEngine* engine_; |
442 std::vector<AudioCodec> recv_codecs_; | 447 std::vector<AudioCodec> recv_codecs_; |
443 std::vector<AudioCodec> send_codecs_; | 448 std::vector<AudioCodec> send_codecs_; |
444 std::map<uint32, OutputScaling> output_scalings_; | 449 std::map<uint32_t, OutputScaling> output_scalings_; |
445 std::vector<DtmfInfo> dtmf_info_queue_; | 450 std::vector<DtmfInfo> dtmf_info_queue_; |
446 int time_since_last_typing_; | 451 int time_since_last_typing_; |
447 AudioOptions options_; | 452 AudioOptions options_; |
448 std::map<uint32, VoiceChannelAudioSink*> local_renderers_; | 453 std::map<uint32_t, VoiceChannelAudioSink*> local_renderers_; |
449 std::map<uint32, AudioRenderer*> remote_renderers_; | 454 std::map<uint32_t, AudioRenderer*> remote_renderers_; |
450 }; | 455 }; |
451 | 456 |
452 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo. | 457 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo. |
453 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, | 458 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, |
454 uint32 ssrc, int event_code, int duration, | 459 uint32_t ssrc, |
| 460 int event_code, |
| 461 int duration, |
455 int flags) { | 462 int flags) { |
456 return (info.duration == duration && info.event_code == event_code && | 463 return (info.duration == duration && info.event_code == event_code && |
457 info.flags == flags && info.ssrc == ssrc); | 464 info.flags == flags && info.ssrc == ssrc); |
458 } | 465 } |
459 | 466 |
460 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { | 467 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
461 public: | 468 public: |
462 explicit FakeVideoMediaChannel(FakeVideoEngine* engine, | 469 explicit FakeVideoMediaChannel(FakeVideoEngine* engine, |
463 const VideoOptions& options) | 470 const VideoOptions& options) |
464 : engine_(engine), | 471 : engine_(engine), |
465 sent_intra_frame_(false), | 472 sent_intra_frame_(false), |
466 requested_intra_frame_(false), | 473 requested_intra_frame_(false), |
467 max_bps_(-1) { | 474 max_bps_(-1) { |
468 SetOptions(options); | 475 SetOptions(options); |
469 } | 476 } |
470 | 477 |
471 ~FakeVideoMediaChannel(); | 478 ~FakeVideoMediaChannel(); |
472 | 479 |
473 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } | 480 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } |
474 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } | 481 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } |
475 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } | 482 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } |
476 bool rendering() const { return playout(); } | 483 bool rendering() const { return playout(); } |
477 const VideoOptions& options() const { return options_; } | 484 const VideoOptions& options() const { return options_; } |
478 const std::map<uint32, VideoRenderer*>& renderers() const { | 485 const std::map<uint32_t, VideoRenderer*>& renderers() const { |
479 return renderers_; | 486 return renderers_; |
480 } | 487 } |
481 int max_bps() const { return max_bps_; } | 488 int max_bps() const { return max_bps_; } |
482 bool GetSendStreamFormat(uint32 ssrc, VideoFormat* format) { | 489 bool GetSendStreamFormat(uint32_t ssrc, VideoFormat* format) { |
483 if (send_formats_.find(ssrc) == send_formats_.end()) { | 490 if (send_formats_.find(ssrc) == send_formats_.end()) { |
484 return false; | 491 return false; |
485 } | 492 } |
486 *format = send_formats_[ssrc]; | 493 *format = send_formats_[ssrc]; |
487 return true; | 494 return true; |
488 } | 495 } |
489 virtual bool SetSendStreamFormat(uint32 ssrc, const VideoFormat& format) { | 496 virtual bool SetSendStreamFormat(uint32_t ssrc, const VideoFormat& format) { |
490 if (send_formats_.find(ssrc) == send_formats_.end()) { | 497 if (send_formats_.find(ssrc) == send_formats_.end()) { |
491 return false; | 498 return false; |
492 } | 499 } |
493 send_formats_[ssrc] = format; | 500 send_formats_[ssrc] = format; |
494 return true; | 501 return true; |
495 } | 502 } |
496 virtual bool SetSendParameters(const VideoSendParameters& params) { | 503 virtual bool SetSendParameters(const VideoSendParameters& params) { |
497 return (SetSendCodecs(params.codecs) && | 504 return (SetSendCodecs(params.codecs) && |
498 SetSendRtpHeaderExtensions(params.extensions) && | 505 SetSendRtpHeaderExtensions(params.extensions) && |
499 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 506 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
500 SetOptions(params.options)); | 507 SetOptions(params.options)); |
501 } | 508 } |
502 | 509 |
503 virtual bool SetRecvParameters(const VideoRecvParameters& params) { | 510 virtual bool SetRecvParameters(const VideoRecvParameters& params) { |
504 return (SetRecvCodecs(params.codecs) && | 511 return (SetRecvCodecs(params.codecs) && |
505 SetRecvRtpHeaderExtensions(params.extensions)); | 512 SetRecvRtpHeaderExtensions(params.extensions)); |
506 } | 513 } |
507 virtual bool AddSendStream(const StreamParams& sp) { | 514 virtual bool AddSendStream(const StreamParams& sp) { |
508 if (!RtpHelper<VideoMediaChannel>::AddSendStream(sp)) { | 515 if (!RtpHelper<VideoMediaChannel>::AddSendStream(sp)) { |
509 return false; | 516 return false; |
510 } | 517 } |
511 SetSendStreamDefaultFormat(sp.first_ssrc()); | 518 SetSendStreamDefaultFormat(sp.first_ssrc()); |
512 return true; | 519 return true; |
513 } | 520 } |
514 virtual bool RemoveSendStream(uint32 ssrc) { | 521 virtual bool RemoveSendStream(uint32_t ssrc) { |
515 send_formats_.erase(ssrc); | 522 send_formats_.erase(ssrc); |
516 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); | 523 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); |
517 } | 524 } |
518 | 525 |
519 virtual bool GetSendCodec(VideoCodec* send_codec) { | 526 virtual bool GetSendCodec(VideoCodec* send_codec) { |
520 if (send_codecs_.empty()) { | 527 if (send_codecs_.empty()) { |
521 return false; | 528 return false; |
522 } | 529 } |
523 *send_codec = send_codecs_[0]; | 530 *send_codec = send_codecs_[0]; |
524 return true; | 531 return true; |
525 } | 532 } |
526 virtual bool SetRenderer(uint32 ssrc, VideoRenderer* r) { | 533 virtual bool SetRenderer(uint32_t ssrc, VideoRenderer* r) { |
527 if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) { | 534 if (ssrc != 0 && renderers_.find(ssrc) == renderers_.end()) { |
528 return false; | 535 return false; |
529 } | 536 } |
530 if (ssrc != 0) { | 537 if (ssrc != 0) { |
531 renderers_[ssrc] = r; | 538 renderers_[ssrc] = r; |
532 } | 539 } |
533 return true; | 540 return true; |
534 } | 541 } |
535 | 542 |
536 virtual bool SetSend(bool send) { return set_sending(send); } | 543 virtual bool SetSend(bool send) { return set_sending(send); } |
537 virtual bool SetVideoSend(uint32 ssrc, bool enable, | 544 virtual bool SetVideoSend(uint32_t ssrc, bool enable, |
538 const VideoOptions* options) { | 545 const VideoOptions* options) { |
539 if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, !enable)) { | 546 if (!RtpHelper<VideoMediaChannel>::MuteStream(ssrc, !enable)) { |
540 return false; | 547 return false; |
541 } | 548 } |
542 if (enable && options) { | 549 if (enable && options) { |
543 return SetOptions(*options); | 550 return SetOptions(*options); |
544 } | 551 } |
545 return true; | 552 return true; |
546 } | 553 } |
547 virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) { | 554 virtual bool SetCapturer(uint32_t ssrc, VideoCapturer* capturer) { |
548 capturers_[ssrc] = capturer; | 555 capturers_[ssrc] = capturer; |
549 return true; | 556 return true; |
550 } | 557 } |
551 bool HasCapturer(uint32 ssrc) const { | 558 bool HasCapturer(uint32_t ssrc) const { |
552 return capturers_.find(ssrc) != capturers_.end(); | 559 return capturers_.find(ssrc) != capturers_.end(); |
553 } | 560 } |
554 virtual bool AddRecvStream(const StreamParams& sp) { | 561 virtual bool AddRecvStream(const StreamParams& sp) { |
555 if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp)) | 562 if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp)) |
556 return false; | 563 return false; |
557 renderers_[sp.first_ssrc()] = NULL; | 564 renderers_[sp.first_ssrc()] = NULL; |
558 return true; | 565 return true; |
559 } | 566 } |
560 virtual bool RemoveRecvStream(uint32 ssrc) { | 567 virtual bool RemoveRecvStream(uint32_t ssrc) { |
561 if (!RtpHelper<VideoMediaChannel>::RemoveRecvStream(ssrc)) | 568 if (!RtpHelper<VideoMediaChannel>::RemoveRecvStream(ssrc)) |
562 return false; | 569 return false; |
563 renderers_.erase(ssrc); | 570 renderers_.erase(ssrc); |
564 return true; | 571 return true; |
565 } | 572 } |
566 | 573 |
567 virtual bool GetStats(VideoMediaInfo* info) { return false; } | 574 virtual bool GetStats(VideoMediaInfo* info) { return false; } |
568 virtual bool SendIntraFrame() { | 575 virtual bool SendIntraFrame() { |
569 sent_intra_frame_ = true; | 576 sent_intra_frame_ = true; |
570 return true; | 577 return true; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 bool SetOptions(const VideoOptions& options) { | 611 bool SetOptions(const VideoOptions& options) { |
605 options_ = options; | 612 options_ = options; |
606 return true; | 613 return true; |
607 } | 614 } |
608 bool SetMaxSendBandwidth(int bps) { | 615 bool SetMaxSendBandwidth(int bps) { |
609 max_bps_ = bps; | 616 max_bps_ = bps; |
610 return true; | 617 return true; |
611 } | 618 } |
612 | 619 |
613 // Be default, each send stream uses the first send codec format. | 620 // Be default, each send stream uses the first send codec format. |
614 void SetSendStreamDefaultFormat(uint32 ssrc) { | 621 void SetSendStreamDefaultFormat(uint32_t ssrc) { |
615 if (!send_codecs_.empty()) { | 622 if (!send_codecs_.empty()) { |
616 send_formats_[ssrc] = VideoFormat( | 623 send_formats_[ssrc] = VideoFormat( |
617 send_codecs_[0].width, send_codecs_[0].height, | 624 send_codecs_[0].width, send_codecs_[0].height, |
618 cricket::VideoFormat::FpsToInterval(send_codecs_[0].framerate), | 625 cricket::VideoFormat::FpsToInterval(send_codecs_[0].framerate), |
619 cricket::FOURCC_I420); | 626 cricket::FOURCC_I420); |
620 } | 627 } |
621 } | 628 } |
622 | 629 |
623 FakeVideoEngine* engine_; | 630 FakeVideoEngine* engine_; |
624 std::vector<VideoCodec> recv_codecs_; | 631 std::vector<VideoCodec> recv_codecs_; |
625 std::vector<VideoCodec> send_codecs_; | 632 std::vector<VideoCodec> send_codecs_; |
626 std::map<uint32, VideoRenderer*> renderers_; | 633 std::map<uint32_t, VideoRenderer*> renderers_; |
627 std::map<uint32, VideoFormat> send_formats_; | 634 std::map<uint32_t, VideoFormat> send_formats_; |
628 std::map<uint32, VideoCapturer*> capturers_; | 635 std::map<uint32_t, VideoCapturer*> capturers_; |
629 bool sent_intra_frame_; | 636 bool sent_intra_frame_; |
630 bool requested_intra_frame_; | 637 bool requested_intra_frame_; |
631 VideoOptions options_; | 638 VideoOptions options_; |
632 int max_bps_; | 639 int max_bps_; |
633 }; | 640 }; |
634 | 641 |
635 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { | 642 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { |
636 public: | 643 public: |
637 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) | 644 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) |
638 : send_blocked_(false), max_bps_(-1) {} | 645 : send_blocked_(false), max_bps_(-1) {} |
(...skipping 13 matching lines...) Expand all Loading... |
652 virtual bool SetSend(bool send) { return set_sending(send); } | 659 virtual bool SetSend(bool send) { return set_sending(send); } |
653 virtual bool SetReceive(bool receive) { | 660 virtual bool SetReceive(bool receive) { |
654 set_playout(receive); | 661 set_playout(receive); |
655 return true; | 662 return true; |
656 } | 663 } |
657 virtual bool AddRecvStream(const StreamParams& sp) { | 664 virtual bool AddRecvStream(const StreamParams& sp) { |
658 if (!RtpHelper<DataMediaChannel>::AddRecvStream(sp)) | 665 if (!RtpHelper<DataMediaChannel>::AddRecvStream(sp)) |
659 return false; | 666 return false; |
660 return true; | 667 return true; |
661 } | 668 } |
662 virtual bool RemoveRecvStream(uint32 ssrc) { | 669 virtual bool RemoveRecvStream(uint32_t ssrc) { |
663 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc)) | 670 if (!RtpHelper<DataMediaChannel>::RemoveRecvStream(ssrc)) |
664 return false; | 671 return false; |
665 return true; | 672 return true; |
666 } | 673 } |
667 | 674 |
668 virtual bool SendData(const SendDataParams& params, | 675 virtual bool SendData(const SendDataParams& params, |
669 const rtc::Buffer& payload, | 676 const rtc::Buffer& payload, |
670 SendDataResult* result) { | 677 SendDataResult* result) { |
671 if (send_blocked_) { | 678 if (send_blocked_) { |
672 *result = SDR_BLOCK; | 679 *result = SDR_BLOCK; |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 | 1010 |
1004 private: | 1011 private: |
1005 std::vector<FakeDataMediaChannel*> channels_; | 1012 std::vector<FakeDataMediaChannel*> channels_; |
1006 std::vector<DataCodec> data_codecs_; | 1013 std::vector<DataCodec> data_codecs_; |
1007 DataChannelType last_channel_type_; | 1014 DataChannelType last_channel_type_; |
1008 }; | 1015 }; |
1009 | 1016 |
1010 } // namespace cricket | 1017 } // namespace cricket |
1011 | 1018 |
1012 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 1019 #endif // TALK_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
OLD | NEW |