Chromium Code Reviews| Index: talk/media/base/fakemediaengine.h |
| diff --git a/talk/media/base/fakemediaengine.h b/talk/media/base/fakemediaengine.h |
| index 2c579e29375ed4d8e6c2fb91c37c1ec3bf517a98..ff56608744449856f9d567de6c824d6e5769b626 100644 |
| --- a/talk/media/base/fakemediaengine.h |
| +++ b/talk/media/base/fakemediaengine.h |
| @@ -103,16 +103,6 @@ template <class Base> class RtpHelper : public Base { |
| } |
| bool CheckNoRtp() { return rtp_packets_.empty(); } |
| bool CheckNoRtcp() { return rtcp_packets_.empty(); } |
| - virtual bool SetRecvRtpHeaderExtensions( |
| - const std::vector<RtpHeaderExtension>& extensions) { |
| - recv_extensions_ = extensions; |
| - return true; |
| - } |
| - virtual bool SetSendRtpHeaderExtensions( |
| - const std::vector<RtpHeaderExtension>& extensions) { |
| - send_extensions_ = extensions; |
| - return true; |
| - } |
| void set_fail_set_send_codecs(bool fail) { fail_set_send_codecs_ = fail; } |
| void set_fail_set_recv_codecs(bool fail) { fail_set_recv_codecs_ = fail; } |
| virtual bool AddSendStream(const StreamParams& sp) { |
| @@ -137,15 +127,6 @@ template <class Base> class RtpHelper : public Base { |
| virtual bool RemoveRecvStream(uint32 ssrc) { |
| return RemoveStreamBySsrc(&receive_streams_, ssrc); |
| } |
| - virtual bool MuteStream(uint32 ssrc, bool on) { |
| - if (!HasSendStream(ssrc) && ssrc != 0) |
| - return false; |
| - if (on) |
| - muted_streams_.insert(ssrc); |
| - else |
| - muted_streams_.erase(ssrc); |
| - return true; |
| - } |
| bool IsStreamMuted(uint32 ssrc) const { |
| bool ret = muted_streams_.find(ssrc) != muted_streams_.end(); |
| // If |ssrc = 0| check if the first send stream is muted. |
| @@ -188,11 +169,32 @@ template <class Base> class RtpHelper : public Base { |
| } |
| protected: |
| + bool MuteStream(uint32 ssrc, bool mute) { |
| + if (!HasSendStream(ssrc) && ssrc != 0) { |
| + return false; |
| + } |
| + if (mute) { |
| + muted_streams_.insert(ssrc); |
| + } else { |
| + muted_streams_.erase(ssrc); |
| + } |
| + return true; |
| + } |
| bool set_sending(bool send) { |
| sending_ = send; |
| return true; |
| } |
| void set_playout(bool playout) { playout_ = playout; } |
| + bool SetRecvRtpHeaderExtensions( |
| + const std::vector<RtpHeaderExtension>& extensions) { |
| + recv_extensions_ = extensions; |
| + return true; |
| + } |
| + bool SetSendRtpHeaderExtensions( |
| + const std::vector<RtpHeaderExtension>& extensions) { |
| + send_extensions_ = extensions; |
| + return true; |
| + } |
| virtual void OnPacketReceived(rtc::Buffer* packet, |
| const rtc::PacketTime& packet_time) { |
| rtp_packets_.push_back(std::string(packet->data<char>(), packet->size())); |
| @@ -257,21 +259,16 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> { |
| bool ringback_tone_play() const { return ringback_tone_play_; } |
| bool ringback_tone_loop() const { return ringback_tone_loop_; } |
| - virtual bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) { |
| - if (fail_set_recv_codecs()) { |
| - // Fake the failure in SetRecvCodecs. |
| - return false; |
| - } |
| - recv_codecs_ = codecs; |
| - return true; |
| + virtual bool SetSendParameters(const AudioSendParameters& params) { |
| + return (SetSendCodecs(params.codecs) && |
| + SetSendRtpHeaderExtensions(params.extensions) && |
| + SetMaxSendBandwidth(params.max_bandwidth_bps) && |
| + SetOptions(params.options)); |
| } |
| - virtual bool SetSendCodecs(const std::vector<AudioCodec>& codecs) { |
| - if (fail_set_send_codecs()) { |
| - // Fake the failure in SetSendCodecs. |
| - return false; |
| - } |
| - send_codecs_ = codecs; |
| - return true; |
| + |
| + virtual bool SetRecvParameters(const AudioRecvParameters& params) { |
| + return (SetRecvCodecs(params.codecs) && |
| + SetRecvRtpHeaderExtensions(params.extensions)); |
| } |
| virtual bool SetPlayout(bool playout) { |
| set_playout(playout); |
| @@ -283,7 +280,14 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> { |
| } |
| return set_sending(flag != SEND_NOTHING); |
| } |
| - virtual bool SetMaxSendBandwidth(int bps) { return true; } |
| + virtual bool MuteStream(uint32 ssrc, bool mute, const AudioOptions* options) { |
| + bool result = RtpHelper<VoiceMediaChannel>::MuteStream(ssrc, mute); |
| + if (result && !mute && options) { |
| + return SetOptions(*options); |
| + } else { |
| + return result; |
| + } |
| + } |
| virtual bool AddRecvStream(const StreamParams& sp) { |
| if (!RtpHelper<VoiceMediaChannel>::AddRecvStream(sp)) |
| return false; |
| @@ -405,11 +409,6 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> { |
| VoiceMediaChannel::SignalMediaError(ssrc, error); |
| } |
| - virtual bool SetOptions(const AudioOptions& options) { |
| - // Does a "merge" of current options and set options. |
| - options_.SetAll(options); |
| - return true; |
| - } |
| virtual bool GetOptions(AudioOptions* options) const { |
| *options = options_; |
| return true; |
| @@ -446,6 +445,28 @@ class FakeVoiceMediaChannel : public RtpHelper<VoiceMediaChannel> { |
| AudioRenderer* renderer_; |
| }; |
| + bool SetRecvCodecs(const std::vector<AudioCodec>& codecs) { |
| + if (fail_set_recv_codecs()) { |
| + // Fake the failure in SetRecvCodecs. |
| + return false; |
| + } |
| + recv_codecs_ = codecs; |
| + return true; |
| + } |
| + bool SetSendCodecs(const std::vector<AudioCodec>& codecs) { |
| + if (fail_set_send_codecs()) { |
| + // Fake the failure in SetSendCodecs. |
| + return false; |
| + } |
| + send_codecs_ = codecs; |
| + return true; |
| + } |
| + bool SetMaxSendBandwidth(int bps) { return true; } |
| + bool SetOptions(const AudioOptions& options) { |
| + // Does a "merge" of current options and set options. |
| + options_.SetAll(options); |
| + return true; |
| + } |
| FakeVoiceEngine* engine_; |
| std::vector<AudioCodec> recv_codecs_; |
| @@ -503,7 +524,17 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
| send_formats_[ssrc] = format; |
| return true; |
| } |
| + virtual bool SetSendParameters(const VideoSendParameters& params) { |
| + return (SetSendCodecs(params.codecs) && |
| + SetSendRtpHeaderExtensions(params.extensions) && |
| + SetMaxSendBandwidth(params.max_bandwidth_bps) && |
| + SetOptions(params.options)); |
| + } |
| + virtual bool SetRecvParameters(const VideoRecvParameters& params) { |
| + return (SetRecvCodecs(params.codecs) && |
| + SetRecvRtpHeaderExtensions(params.extensions)); |
| + } |
| virtual bool AddSendStream(const StreamParams& sp) { |
| if (!RtpHelper<VideoMediaChannel>::AddSendStream(sp)) { |
| return false; |
| @@ -517,27 +548,6 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
| } |
| void DetachVoiceChannel() override {} |
| - virtual bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) { |
| - if (fail_set_recv_codecs()) { |
| - // Fake the failure in SetRecvCodecs. |
| - return false; |
| - } |
| - recv_codecs_ = codecs; |
| - return true; |
| - } |
| - virtual bool SetSendCodecs(const std::vector<VideoCodec>& codecs) { |
| - if (fail_set_send_codecs()) { |
| - // Fake the failure in SetSendCodecs. |
| - return false; |
| - } |
| - send_codecs_ = codecs; |
| - |
| - for (std::vector<StreamParams>::const_iterator it = send_streams().begin(); |
| - it != send_streams().end(); ++it) { |
| - SetSendStreamDefaultFormat(it->first_ssrc()); |
| - } |
| - return true; |
| - } |
| virtual bool GetSendCodec(VideoCodec* send_codec) { |
| if (send_codecs_.empty()) { |
| return false; |
| @@ -560,6 +570,14 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
| } |
| virtual bool SetSend(bool send) { return set_sending(send); } |
| + virtual bool MuteStream(uint32 ssrc, bool mute, const VideoOptions* options) { |
| + bool result = RtpHelper<VideoMediaChannel>::MuteStream(ssrc, mute); |
| + if (result && !mute && options) { |
| + return SetOptions(*options); |
| + } else { |
| + return result; |
| + } |
| + } |
| virtual bool SetCapturer(uint32 ssrc, VideoCapturer* capturer) { |
| capturers_[ssrc] = capturer; |
| return true; |
| @@ -567,10 +585,6 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
| bool HasCapturer(uint32 ssrc) const { |
| return capturers_.find(ssrc) != capturers_.end(); |
| } |
| - virtual bool SetMaxSendBandwidth(int bps) { |
| - max_bps_ = bps; |
| - return true; |
| - } |
| virtual bool AddRecvStream(const StreamParams& sp) { |
| if (!RtpHelper<VideoMediaChannel>::AddRecvStream(sp)) |
| return false; |
| @@ -593,10 +607,6 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
| requested_intra_frame_ = true; |
| return true; |
| } |
| - virtual bool SetOptions(const VideoOptions& options) { |
| - options_ = options; |
| - return true; |
| - } |
| virtual bool GetOptions(VideoOptions* options) const { |
| *options = options_; |
| return true; |
| @@ -608,6 +618,36 @@ class FakeVideoMediaChannel : public RtpHelper<VideoMediaChannel> { |
| bool requested_intra_frame() const { return requested_intra_frame_; } |
| private: |
| + bool SetRecvCodecs(const std::vector<VideoCodec>& codecs) { |
| + if (fail_set_recv_codecs()) { |
| + // Fake the failure in SetRecvCodecs. |
| + return false; |
| + } |
| + recv_codecs_ = codecs; |
| + return true; |
| + } |
| + bool SetSendCodecs(const std::vector<VideoCodec>& codecs) { |
| + if (fail_set_send_codecs()) { |
| + // Fake the failure in SetSendCodecs. |
| + return false; |
| + } |
| + send_codecs_ = codecs; |
| + |
| + for (std::vector<StreamParams>::const_iterator it = send_streams().begin(); |
| + it != send_streams().end(); ++it) { |
| + SetSendStreamDefaultFormat(it->first_ssrc()); |
| + } |
| + return true; |
| + } |
| + bool SetOptions(const VideoOptions& options) { |
| + options_ = options; |
| + return true; |
| + } |
| + bool SetMaxSendBandwidth(int bps) { |
| + max_bps_ = bps; |
| + return true; |
| + } |
| + |
| // Be default, each send stream uses the first send codec format. |
| void SetSendStreamDefaultFormat(uint32 ssrc) { |
| if (!send_codecs_.empty()) { |
| @@ -640,31 +680,18 @@ class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { |
| const std::vector<DataCodec>& codecs() const { return send_codecs(); } |
| int max_bps() const { return max_bps_; } |
| - virtual bool SetRecvCodecs(const std::vector<DataCodec>& codecs) { |
| - if (fail_set_recv_codecs()) { |
| - // Fake the failure in SetRecvCodecs. |
| - return false; |
| - } |
| - recv_codecs_ = codecs; |
| - return true; |
| + virtual bool SetSendParameters(const DataSendParameters& params) { |
| + return (SetSendCodecs(params.codecs) && |
| + SetMaxSendBandwidth(params.max_bandwidth_bps)); |
| } |
| - virtual bool SetSendCodecs(const std::vector<DataCodec>& codecs) { |
| - if (fail_set_send_codecs()) { |
| - // Fake the failure in SetSendCodecs. |
| - return false; |
| - } |
| - send_codecs_ = codecs; |
| - return true; |
| + virtual bool SetRecvParameters(const DataRecvParameters& params) { |
| + return SetRecvCodecs(params.codecs); |
| } |
| virtual bool SetSend(bool send) { return set_sending(send); } |
| virtual bool SetReceive(bool receive) { |
| set_playout(receive); |
| return true; |
| } |
| - virtual bool SetMaxSendBandwidth(int bps) { |
| - max_bps_ = bps; |
| - return true; |
| - } |
| virtual bool AddRecvStream(const StreamParams& sp) { |
| if (!RtpHelper<DataMediaChannel>::AddRecvStream(sp)) |
| return false; |
| @@ -695,6 +722,27 @@ class FakeDataMediaChannel : public RtpHelper<DataMediaChannel> { |
| void set_send_blocked(bool blocked) { send_blocked_ = blocked; } |
| private: |
| + bool SetRecvCodecs(const std::vector<DataCodec>& codecs) { |
| + if (fail_set_recv_codecs()) { |
| + // Fake the failure in SetRecvCodecs. |
| + return false; |
| + } |
| + recv_codecs_ = codecs; |
| + return true; |
| + } |
| + bool SetSendCodecs(const std::vector<DataCodec>& codecs) { |
| + if (fail_set_send_codecs()) { |
| + // Fake the failure in SetSendCodecs. |
| + return false; |
| + } |
| + send_codecs_ = codecs; |
| + return true; |
| + } |
| + bool SetMaxSendBandwidth(int bps) { |
| + max_bps_ = bps; |
| + return true; |
| + } |
| + |
| std::vector<DataCodec> recv_codecs_; |
| std::vector<DataCodec> send_codecs_; |
| SendDataParams last_sent_data_params_; |
| @@ -769,7 +817,8 @@ class FakeVoiceEngine : public FakeBaseEngine { |
| } |
| FakeVoiceMediaChannel* ch = new FakeVoiceMediaChannel(this); |
| - ch->SetOptions(options); |
| + // TODO(solenberg): !!!!!! SetParameters with only options? |
| + // ch->SetOptions(options); |
|
pthatcher1
2015/09/04 23:21:16
The options don't matter until the other parameter
the sun
2015/09/11 15:03:03
Done.
|
| channels_.push_back(ch); |
| return ch; |
| } |
| @@ -887,7 +936,8 @@ class FakeVideoEngine : public FakeBaseEngine { |
| } |
| FakeVideoMediaChannel* ch = new FakeVideoMediaChannel(this); |
| - ch->SetOptions(options); |
| + // TODO(solenberg): !!!!! SetParameters with only options? |
| + // ch->SetOptions(options); |
| channels_.push_back(ch); |
| return ch; |
| } |