Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 : ssrc(ssrc), | 218 : ssrc(ssrc), |
| 219 event_code(event_code), | 219 event_code(event_code), |
| 220 duration(duration) {} | 220 duration(duration) {} |
| 221 uint32_t ssrc; | 221 uint32_t ssrc; |
| 222 int event_code; | 222 int event_code; |
| 223 int duration; | 223 int duration; |
| 224 }; | 224 }; |
| 225 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, | 225 explicit FakeVoiceMediaChannel(FakeVoiceEngine* engine, |
| 226 const AudioOptions& options) | 226 const AudioOptions& options) |
| 227 : engine_(engine), | 227 : engine_(engine), |
| 228 time_since_last_typing_(-1) { | 228 time_since_last_typing_(-1), |
| 229 max_bps_(-1), | |
| 230 rtp_parameters_(webrtc::RTCRtpParameters::CreateDefault()) { | |
|
pthatcher1
2016/03/12 01:21:03
It seems like building a one-encoding parameters s
Taylor Brandstetter
2016/03/12 01:57:06
To answer the question: If you call GetParameters
| |
| 229 output_scalings_[0] = 1.0; // For default channel. | 231 output_scalings_[0] = 1.0; // For default channel. |
| 230 SetOptions(options); | 232 SetOptions(options); |
| 231 } | 233 } |
| 232 ~FakeVoiceMediaChannel(); | 234 ~FakeVoiceMediaChannel(); |
| 233 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; } | 235 const std::vector<AudioCodec>& recv_codecs() const { return recv_codecs_; } |
| 234 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; } | 236 const std::vector<AudioCodec>& send_codecs() const { return send_codecs_; } |
| 235 const std::vector<AudioCodec>& codecs() const { return send_codecs(); } | 237 const std::vector<AudioCodec>& codecs() const { return send_codecs(); } |
| 236 const std::vector<DtmfInfo>& dtmf_info_queue() const { | 238 const std::vector<DtmfInfo>& dtmf_info_queue() const { |
| 237 return dtmf_info_queue_; | 239 return dtmf_info_queue_; |
| 238 } | 240 } |
| 239 const AudioOptions& options() const { return options_; } | 241 const AudioOptions& options() const { return options_; } |
| 240 | 242 int max_bps() const { return max_bps_; } |
| 241 virtual bool SetSendParameters(const AudioSendParameters& params) { | 243 virtual bool SetSendParameters(const AudioSendParameters& params) { |
| 242 return (SetSendCodecs(params.codecs) && | 244 return (SetSendCodecs(params.codecs) && |
| 243 SetSendRtpHeaderExtensions(params.extensions) && | 245 SetSendRtpHeaderExtensions(params.extensions) && |
| 244 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 246 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
| 245 SetOptions(params.options)); | 247 SetOptions(params.options)); |
| 246 } | 248 } |
| 247 | 249 |
| 248 virtual bool SetRecvParameters(const AudioRecvParameters& params) { | 250 virtual bool SetRecvParameters(const AudioRecvParameters& params) { |
| 249 return (SetRecvCodecs(params.codecs) && | 251 return (SetRecvCodecs(params.codecs) && |
| 250 SetRecvRtpHeaderExtensions(params.extensions)); | 252 SetRecvRtpHeaderExtensions(params.extensions)); |
| 251 } | 253 } |
| 254 | |
| 255 virtual webrtc::RTCRtpParameters GetRtpParameters(uint32_t ssrc) { | |
| 256 return rtp_parameters_; | |
| 257 } | |
| 258 virtual bool SetRtpParameters(uint32_t ssrc, | |
| 259 const webrtc::RTCRtpParameters& parameters) { | |
| 260 rtp_parameters_ = parameters; | |
|
Taylor Brandstetter
2016/03/12 01:57:06
I know this is just a stub class, but for consiste
skvlad
2016/03/15 21:18:18
Done.
| |
| 261 return true; | |
| 262 } | |
| 263 | |
| 252 virtual bool SetPlayout(bool playout) { | 264 virtual bool SetPlayout(bool playout) { |
| 253 set_playout(playout); | 265 set_playout(playout); |
| 254 return true; | 266 return true; |
| 255 } | 267 } |
| 256 virtual bool SetSend(SendFlags flag) { | 268 virtual bool SetSend(SendFlags flag) { |
| 257 return set_sending(flag != SEND_NOTHING); | 269 return set_sending(flag != SEND_NOTHING); |
| 258 } | 270 } |
| 259 virtual bool SetAudioSend(uint32_t ssrc, | 271 virtual bool SetAudioSend(uint32_t ssrc, |
| 260 bool enable, | 272 bool enable, |
| 261 const AudioOptions* options, | 273 const AudioOptions* options, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 return true; | 382 return true; |
| 371 } | 383 } |
| 372 bool SetSendCodecs(const std::vector<AudioCodec>& codecs) { | 384 bool SetSendCodecs(const std::vector<AudioCodec>& codecs) { |
| 373 if (fail_set_send_codecs()) { | 385 if (fail_set_send_codecs()) { |
| 374 // Fake the failure in SetSendCodecs. | 386 // Fake the failure in SetSendCodecs. |
| 375 return false; | 387 return false; |
| 376 } | 388 } |
| 377 send_codecs_ = codecs; | 389 send_codecs_ = codecs; |
| 378 return true; | 390 return true; |
| 379 } | 391 } |
| 380 bool SetMaxSendBandwidth(int bps) { return true; } | 392 bool SetMaxSendBandwidth(int bps) { |
| 393 max_bps_ = bps; | |
| 394 return true; | |
| 395 } | |
| 381 bool SetOptions(const AudioOptions& options) { | 396 bool SetOptions(const AudioOptions& options) { |
| 382 // Does a "merge" of current options and set options. | 397 // Does a "merge" of current options and set options. |
| 383 options_.SetAll(options); | 398 options_.SetAll(options); |
| 384 return true; | 399 return true; |
| 385 } | 400 } |
| 386 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer) { | 401 bool SetLocalRenderer(uint32_t ssrc, AudioRenderer* renderer) { |
| 387 auto it = local_renderers_.find(ssrc); | 402 auto it = local_renderers_.find(ssrc); |
| 388 if (renderer) { | 403 if (renderer) { |
| 389 if (it != local_renderers_.end()) { | 404 if (it != local_renderers_.end()) { |
| 390 ASSERT(it->second->renderer() == renderer); | 405 ASSERT(it->second->renderer() == renderer); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 403 | 418 |
| 404 FakeVoiceEngine* engine_; | 419 FakeVoiceEngine* engine_; |
| 405 std::vector<AudioCodec> recv_codecs_; | 420 std::vector<AudioCodec> recv_codecs_; |
| 406 std::vector<AudioCodec> send_codecs_; | 421 std::vector<AudioCodec> send_codecs_; |
| 407 std::map<uint32_t, double> output_scalings_; | 422 std::map<uint32_t, double> output_scalings_; |
| 408 std::vector<DtmfInfo> dtmf_info_queue_; | 423 std::vector<DtmfInfo> dtmf_info_queue_; |
| 409 int time_since_last_typing_; | 424 int time_since_last_typing_; |
| 410 AudioOptions options_; | 425 AudioOptions options_; |
| 411 std::map<uint32_t, VoiceChannelAudioSink*> local_renderers_; | 426 std::map<uint32_t, VoiceChannelAudioSink*> local_renderers_; |
| 412 std::unique_ptr<webrtc::AudioSinkInterface> sink_; | 427 std::unique_ptr<webrtc::AudioSinkInterface> sink_; |
| 428 int max_bps_; | |
| 429 webrtc::RTCRtpParameters rtp_parameters_; | |
| 413 }; | 430 }; |
| 414 | 431 |
| 415 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo. | 432 // A helper function to compare the FakeVoiceMediaChannel::DtmfInfo. |
| 416 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, | 433 inline bool CompareDtmfInfo(const FakeVoiceMediaChannel::DtmfInfo& info, |
| 417 uint32_t ssrc, | 434 uint32_t ssrc, |
| 418 int event_code, | 435 int event_code, |
| 419 int duration) { | 436 int duration) { |
| 420 return (info.duration == duration && info.event_code == event_code && | 437 return (info.duration == duration && info.event_code == event_code && |
| 421 info.ssrc == ssrc); | 438 info.ssrc == ssrc); |
| 422 } | 439 } |
| 423 | 440 |
| 424 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { | 441 class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
| 425 public: | 442 public: |
| 426 explicit FakeVideoMediaChannel(FakeVideoEngine* engine, | 443 explicit FakeVideoMediaChannel(FakeVideoEngine* engine, |
| 427 const VideoOptions& options) | 444 const VideoOptions& options) |
| 428 : engine_(engine), max_bps_(-1) { | 445 : engine_(engine), |
| 446 max_bps_(-1), | |
| 447 rtp_parameters_(webrtc::RTCRtpParameters::CreateDefault()) { | |
| 429 SetOptions(options); | 448 SetOptions(options); |
| 430 } | 449 } |
| 431 | 450 |
| 432 ~FakeVideoMediaChannel(); | 451 ~FakeVideoMediaChannel(); |
| 433 | 452 |
| 434 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } | 453 const std::vector<VideoCodec>& recv_codecs() const { return recv_codecs_; } |
| 435 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } | 454 const std::vector<VideoCodec>& send_codecs() const { return send_codecs_; } |
| 436 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } | 455 const std::vector<VideoCodec>& codecs() const { return send_codecs(); } |
| 437 bool rendering() const { return playout(); } | 456 bool rendering() const { return playout(); } |
| 438 const VideoOptions& options() const { return options_; } | 457 const VideoOptions& options() const { return options_; } |
| 439 const std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*>& sinks() | 458 const std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*>& sinks() |
| 440 const { | 459 const { |
| 441 return sinks_; | 460 return sinks_; |
| 442 } | 461 } |
| 443 int max_bps() const { return max_bps_; } | 462 int max_bps() const { return max_bps_; } |
| 444 virtual bool SetSendParameters(const VideoSendParameters& params) { | 463 virtual bool SetSendParameters(const VideoSendParameters& params) { |
| 445 return (SetSendCodecs(params.codecs) && | 464 return (SetSendCodecs(params.codecs) && |
| 446 SetSendRtpHeaderExtensions(params.extensions) && | 465 SetSendRtpHeaderExtensions(params.extensions) && |
| 447 SetMaxSendBandwidth(params.max_bandwidth_bps) && | 466 SetMaxSendBandwidth(params.max_bandwidth_bps) && |
| 448 SetOptions(params.options)); | 467 SetOptions(params.options)); |
| 449 } | 468 } |
| 450 | 469 |
| 470 virtual webrtc::RTCRtpParameters GetRtpParameters(uint32_t ssrc) { | |
| 471 return rtp_parameters_; | |
| 472 } | |
| 473 virtual bool SetRtpParameters(uint32_t ssrc, | |
| 474 const webrtc::RTCRtpParameters& parameters) { | |
| 475 rtp_parameters_ = parameters; | |
| 476 return true; | |
| 477 } | |
| 451 virtual bool SetRecvParameters(const VideoRecvParameters& params) { | 478 virtual bool SetRecvParameters(const VideoRecvParameters& params) { |
| 452 return (SetRecvCodecs(params.codecs) && | 479 return (SetRecvCodecs(params.codecs) && |
| 453 SetRecvRtpHeaderExtensions(params.extensions)); | 480 SetRecvRtpHeaderExtensions(params.extensions)); |
| 454 } | 481 } |
| 455 virtual bool AddSendStream(const StreamParams& sp) { | 482 virtual bool AddSendStream(const StreamParams& sp) { |
| 456 return RtpHelper<VideoMediaChannel>::AddSendStream(sp); | 483 return RtpHelper<VideoMediaChannel>::AddSendStream(sp); |
| 457 } | 484 } |
| 458 virtual bool RemoveSendStream(uint32_t ssrc) { | 485 virtual bool RemoveSendStream(uint32_t ssrc) { |
| 459 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); | 486 return RtpHelper<VideoMediaChannel>::RemoveSendStream(ssrc); |
| 460 } | 487 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 537 return true; | 564 return true; |
| 538 } | 565 } |
| 539 | 566 |
| 540 FakeVideoEngine* engine_; | 567 FakeVideoEngine* engine_; |
| 541 std::vector<VideoCodec> recv_codecs_; | 568 std::vector<VideoCodec> recv_codecs_; |
| 542 std::vector<VideoCodec> send_codecs_; | 569 std::vector<VideoCodec> send_codecs_; |
| 543 std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*> sinks_; | 570 std::map<uint32_t, rtc::VideoSinkInterface<VideoFrame>*> sinks_; |
| 544 std::map<uint32_t, VideoCapturer*> capturers_; | 571 std::map<uint32_t, VideoCapturer*> capturers_; |
| 545 VideoOptions options_; | 572 VideoOptions options_; |
| 546 int max_bps_; | 573 int max_bps_; |
| 574 webrtc::RTCRtpParameters rtp_parameters_; | |
| 547 }; | 575 }; |
| 548 | 576 |
| 549 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { | 577 class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { |
| 550 public: | 578 public: |
| 551 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) | 579 explicit FakeDataMediaChannel(void* unused, const DataOptions& options) |
| 552 : send_blocked_(false), max_bps_(-1) {} | 580 : send_blocked_(false), max_bps_(-1) {} |
| 553 ~FakeDataMediaChannel() {} | 581 ~FakeDataMediaChannel() {} |
| 554 const std::vector<DataCodec>& recv_codecs() const { return recv_codecs_; } | 582 const std::vector<DataCodec>& recv_codecs() const { return recv_codecs_; } |
| 555 const std::vector<DataCodec>& send_codecs() const { return send_codecs_; } | 583 const std::vector<DataCodec>& send_codecs() const { return send_codecs_; } |
| 556 const std::vector<DataCodec>& codecs() const { return send_codecs(); } | 584 const std::vector<DataCodec>& codecs() const { return send_codecs(); } |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 | 897 |
| 870 private: | 898 private: |
| 871 std::vector<FakeDataMediaChannel*> channels_; | 899 std::vector<FakeDataMediaChannel*> channels_; |
| 872 std::vector<DataCodec> data_codecs_; | 900 std::vector<DataCodec> data_codecs_; |
| 873 DataChannelType last_channel_type_; | 901 DataChannelType last_channel_type_; |
| 874 }; | 902 }; |
| 875 | 903 |
| 876 } // namespace cricket | 904 } // namespace cricket |
| 877 | 905 |
| 878 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ | 906 #endif // WEBRTC_MEDIA_BASE_FAKEMEDIAENGINE_H_ |
| OLD | NEW |