Chromium Code Reviews| Index: talk/media/base/mediachannel.h |
| diff --git a/talk/media/base/mediachannel.h b/talk/media/base/mediachannel.h |
| index 3b27b92dd96d613764f44386e4b9d3dcd07e6297..1c8aa4cab763b3b450d7fa59b045b82b345e986d 100644 |
| --- a/talk/media/base/mediachannel.h |
| +++ b/talk/media/base/mediachannel.h |
| @@ -94,6 +94,12 @@ static std::string VectorToString(const std::vector<T>& vals) { |
| return ost.str(); |
| } |
| +struct MediaChannelOptions { |
|
pbos-webrtc
2016/02/01 14:44:38
Can we call this Config? this may be fuzzy, but th
nisse-webrtc
2016/02/02 11:32:50
Makes sense, but not changing it now, we need to d
|
| + // Set DSCP value for packet sent from media channel. This flag |
|
pbos-webrtc
2016/02/01 14:44:38
packets, also 80 chars per line.
|
| + // comes from the PeerConnection constraint 'googDscp'. |
| + bool enable_dscp = false; |
| +}; |
| + |
| // Options that can be applied to a VoiceMediaChannel or a VoiceMediaEngine. |
| // Used to be flags, but that makes it hard to selectively apply options. |
| // We are moving all of the setting of options to structs like this, |
| @@ -124,7 +130,6 @@ struct AudioOptions { |
| SetFrom(&tx_agc_limiter, change.tx_agc_limiter); |
| SetFrom(&recording_sample_rate, change.recording_sample_rate); |
| SetFrom(&playout_sample_rate, change.playout_sample_rate); |
| - SetFrom(&dscp, change.dscp); |
| SetFrom(&combined_audio_video_bwe, change.combined_audio_video_bwe); |
| } |
| @@ -151,7 +156,6 @@ struct AudioOptions { |
| tx_agc_limiter == o.tx_agc_limiter && |
| recording_sample_rate == o.recording_sample_rate && |
| playout_sample_rate == o.playout_sample_rate && |
| - dscp == o.dscp && |
| combined_audio_video_bwe == o.combined_audio_video_bwe; |
| } |
| @@ -182,7 +186,6 @@ struct AudioOptions { |
| ost << ToStringIfSet("tx_agc_limiter", tx_agc_limiter); |
| ost << ToStringIfSet("recording_sample_rate", recording_sample_rate); |
| ost << ToStringIfSet("playout_sample_rate", playout_sample_rate); |
| - ost << ToStringIfSet("dscp", dscp); |
| ost << ToStringIfSet("combined_audio_video_bwe", combined_audio_video_bwe); |
| ost << "}"; |
| return ost.str(); |
| @@ -219,8 +222,6 @@ struct AudioOptions { |
| rtc::Optional<bool> tx_agc_limiter; |
| rtc::Optional<uint32_t> recording_sample_rate; |
| rtc::Optional<uint32_t> playout_sample_rate; |
| - // Set DSCP value for packet sent from audio channel. |
| - rtc::Optional<bool> dscp; |
| // Enable combined audio+bandwidth BWE. |
| rtc::Optional<bool> combined_audio_video_bwe; |
| @@ -242,7 +243,6 @@ struct VideoOptions { |
| SetFrom(&video_noise_reduction, change.video_noise_reduction); |
| SetFrom(&cpu_overuse_detection, change.cpu_overuse_detection); |
| SetFrom(&conference_mode, change.conference_mode); |
| - SetFrom(&dscp, change.dscp); |
| SetFrom(&suspend_below_min_bitrate, change.suspend_below_min_bitrate); |
| SetFrom(&screencast_min_bitrate_kbps, change.screencast_min_bitrate_kbps); |
| SetFrom(&disable_prerenderer_smoothing, |
| @@ -253,7 +253,6 @@ struct VideoOptions { |
| return video_noise_reduction == o.video_noise_reduction && |
| cpu_overuse_detection == o.cpu_overuse_detection && |
| conference_mode == o.conference_mode && |
| - dscp == o.dscp && |
| suspend_below_min_bitrate == o.suspend_below_min_bitrate && |
| screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps && |
| disable_prerenderer_smoothing == o.disable_prerenderer_smoothing; |
| @@ -265,7 +264,6 @@ struct VideoOptions { |
| ost << ToStringIfSet("noise reduction", video_noise_reduction); |
| ost << ToStringIfSet("cpu overuse detection", cpu_overuse_detection); |
| ost << ToStringIfSet("conference mode", conference_mode); |
| - ost << ToStringIfSet("dscp", dscp); |
| ost << ToStringIfSet("suspend below min bitrate", |
| suspend_below_min_bitrate); |
| ost << ToStringIfSet("screencast min bitrate kbps", |
| @@ -290,12 +288,6 @@ struct VideoOptions { |
| // WebRtcVideoChannel2::WebRtcVideoSendStream::CreateVideoEncoderConfig. |
| // The special screencast behaviour is disabled by default. |
| rtc::Optional<bool> conference_mode; |
| - // Set DSCP value for packet sent from video channel. This flag |
| - // comes from the PeerConnection constraint 'googDscp' and, |
| - // WebRtcVideoChannel2::SetOptions checks it before calling |
| - // MediaChannel::SetDscp. If enabled, rtc::DSCP_AF41 is used. If |
| - // disabled, which is the default, rtc::DSCP_DEFAULT is used. |
| - rtc::Optional<bool> dscp; |
| // Enable WebRTC suspension of video. No video frames will be sent |
| // when the bitrate is below the configured minimum bitrate. This |
| // flag comes from the PeerConnection constraint |
| @@ -384,15 +376,20 @@ class MediaChannel : public sigslot::has_slots<> { |
| virtual ~NetworkInterface() {} |
| }; |
| - MediaChannel() : network_interface_(NULL) {} |
| + MediaChannel(const MediaChannelOptions& options) |
| + : options_(options), network_interface_(NULL) {} |
| + MediaChannel() : options_(), network_interface_(NULL) {} |
|
pbos-webrtc
2016/02/01 14:44:38
Can you remove the default constructor?
nisse-webrtc
2016/02/02 11:32:50
I need either a default constructor here, or a def
|
| virtual ~MediaChannel() {} |
| // Sets the abstract interface class for sending RTP/RTCP data. |
| virtual void SetInterface(NetworkInterface *iface) { |
| rtc::CritScope cs(&network_interface_crit_); |
| network_interface_ = iface; |
| + SetDscp(options_.enable_dscp ? MediaTypeDscpValue() : rtc::DSCP_DEFAULT); |
| + } |
| + virtual rtc::DiffServCodePoint MediaTypeDscpValue() const { |
| + return rtc::DSCP_DEFAULT; |
| } |
| - |
| // Called when a RTP packet is received. |
| virtual void OnPacketReceived(rtc::Buffer* packet, |
| const rtc::PacketTime& packet_time) = 0; |
| @@ -440,7 +437,7 @@ class MediaChannel : public sigslot::has_slots<> { |
| return network_interface_->SetOption(type, opt, option); |
| } |
| - protected: |
| + private: |
| // This method sets DSCP |value| on both RTP and RTCP channels. |
| int SetDscp(rtc::DiffServCodePoint value) { |
| int ret; |
| @@ -455,7 +452,6 @@ class MediaChannel : public sigslot::has_slots<> { |
| return ret; |
| } |
| - private: |
| bool DoSendPacket(rtc::Buffer* packet, |
| bool rtcp, |
| const rtc::PacketOptions& options) { |
| @@ -467,6 +463,7 @@ class MediaChannel : public sigslot::has_slots<> { |
| : network_interface_->SendRtcp(packet, options); |
| } |
| + const MediaChannelOptions options_; |
| // |network_interface_| can be accessed from the worker_thread and |
| // from any MediaEngine threads. This critical section is to protect accessing |
| // of network_interface_ object. |
| @@ -919,7 +916,10 @@ class VoiceMediaChannel : public MediaChannel { |
| ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| }; |
| + VoiceMediaChannel(const MediaChannelOptions& options) |
| + : MediaChannel(options) {} |
| VoiceMediaChannel() {} |
| + |
| virtual ~VoiceMediaChannel() {} |
| virtual bool SetSendParameters(const AudioSendParameters& params) = 0; |
| virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; |
| @@ -982,7 +982,9 @@ class VideoMediaChannel : public MediaChannel { |
| ERROR_PLAY_SRTP_REPLAY, // Packet replay detected. |
| }; |
| - VideoMediaChannel() : renderer_(NULL) {} |
| + VideoMediaChannel(const MediaChannelOptions& options) |
| + : MediaChannel(options), renderer_(NULL) {} |
| + VideoMediaChannel() : MediaChannel(), renderer_(NULL) {} |
| virtual ~VideoMediaChannel() {} |
| virtual bool SetSendParameters(const VideoSendParameters& params) = 0; |