Chromium Code Reviews| Index: webrtc/media/base/mediachannel.h |
| diff --git a/webrtc/media/base/mediachannel.h b/webrtc/media/base/mediachannel.h |
| index 30d4a45ff21debbf7caa4ba80b17873046193bf4..bcc69c1e822c0a85badea571e7138ed6eabee22c 100644 |
| --- a/webrtc/media/base/mediachannel.h |
| +++ b/webrtc/media/base/mediachannel.h |
| @@ -95,6 +95,40 @@ static std::string VectorToString(const std::vector<T>& vals) { |
| return ost.str(); |
| } |
| +// Construction-time settings, passed to |
| +// MediaControllerInterface::Create, and passed on when creating |
| +// MediaChannels. |
| +struct MediaConfig { |
| + // Set DSCP value on packets. This flag comes from the |
| + // PeerConnection constraint 'googDscp'. |
| + bool enable_dscp = false; |
| + |
| + // Video-specific config |
| + |
| + // Enable WebRTC CPU Overuse Detection. This flag comes from the |
|
perkj_webrtc
2016/02/09 15:35:37
We normally descibe the purpose. Not the exact cal
nisse-webrtc
2016/02/10 08:53:00
I understand this comment is going to get less acc
|
| + // PeerConnection constraint 'googCpuOveruseDetection' and is |
| + // checked in WebRtcVideoChannel2::OnLoadUpdate, where it's passed |
| + // to VideoCapturer::video_adapter()->OnCpuResolutionRequest. |
| + bool enable_cpu_overuse_detection = true; |
| + |
| + // Set to true if the renderer has an algorithm of frame selection. |
| + // If the value is true, then WebRTC will hand over a frame as soon as |
| + // possible without delay, and rendering smoothness is completely the duty |
| + // of the renderer; |
| + // If the value is false, then WebRTC is responsible to delay frame release |
| + // in order to increase rendering smoothness. |
| + // |
| + // This flag comes from PeerConnection's RtcConfiguration, but is |
|
perkj_webrtc
2016/02/09 15:35:37
dito
|
| + // currently only set by the command line flag |
| + // 'disable-rtc-smoothness-algorithm'. |
| + // WebRtcVideoChannel2::AddRecvStream copies it to the created |
| + // WebRtcVideoReceiveStream, where it is returned by the |
| + // SmoothsRenderedFrames method. This method is used by the |
| + // VideoReceiveStream, where the value is passed on to the |
| + // IncomingVideoStream constructor. |
| + bool disable_prerenderer_smoothing = 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, |
| @@ -125,7 +159,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); |
| } |
| @@ -152,7 +185,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; |
| } |
| @@ -183,7 +215,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(); |
| @@ -220,9 +251,10 @@ 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. |
| + // TODO(pthatcher): This flag is set from the |
| + // "googCombinedAudioVideoBwe", but not used anywhere. So delete it, |
| + // and check if any other AudioOptions members are unused. |
| rtc::Optional<bool> combined_audio_video_bwe; |
| private: |
| @@ -241,32 +273,23 @@ struct AudioOptions { |
| struct VideoOptions { |
| void SetAll(const VideoOptions& change) { |
| 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, |
| - change.disable_prerenderer_smoothing); |
| } |
| bool operator==(const VideoOptions& o) const { |
| 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; |
| + screencast_min_bitrate_kbps == o.screencast_min_bitrate_kbps; |
| } |
| std::string ToString() const { |
| std::ostringstream ost; |
| ost << "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", |
| @@ -279,11 +302,6 @@ struct VideoOptions { |
| // constraint 'googNoiseReduction', and WebRtcVideoEngine2 passes it |
| // on to the codec options. Disabled by default. |
| rtc::Optional<bool> video_noise_reduction; |
| - // Enable WebRTC Cpu Overuse Detection. This flag comes from the |
| - // PeerConnection constraint 'googCpuOveruseDetection' and is |
| - // checked in WebRtcVideoChannel2::OnLoadUpdate, where it's passed |
| - // to VideoCapturer::video_adapter()->OnCpuResolutionRequest. |
| - rtc::Optional<bool> cpu_overuse_detection; |
| // Use conference mode? This flag comes from the remote |
| // description's SDP line 'a=x-google-flag:conference', copied over |
| // by VideoChannel::SetRemoteContent_w, and ultimately used by |
| @@ -291,12 +309,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 |
| @@ -307,22 +319,6 @@ struct VideoOptions { |
| // the PeerConnection constraint 'googScreencastMinBitrate'. It is |
| // copied to the encoder config by WebRtcVideoChannel2. |
| rtc::Optional<int> screencast_min_bitrate_kbps; |
| - // Set to true if the renderer has an algorithm of frame selection. |
| - // If the value is true, then WebRTC will hand over a frame as soon as |
| - // possible without delay, and rendering smoothness is completely the duty |
| - // of the renderer; |
| - // If the value is false, then WebRTC is responsible to delay frame release |
| - // in order to increase rendering smoothness. |
| - // |
| - // This flag comes from PeerConnection's RtcConfiguration, but is |
| - // currently only set by the command line flag |
| - // 'disable-rtc-smoothness-algorithm'. |
| - // WebRtcVideoChannel2::AddRecvStream copies it to the created |
| - // WebRtcVideoReceiveStream, where it is returned by the |
| - // SmoothsRenderedFrames method. This method is used by the |
| - // VideoReceiveStream, where the value is passed on to the |
| - // IncomingVideoStream constructor. |
| - rtc::Optional<bool> disable_prerenderer_smoothing; |
| private: |
| template <typename T> |
| @@ -385,15 +381,22 @@ class MediaChannel : public sigslot::has_slots<> { |
| virtual ~NetworkInterface() {} |
| }; |
| - MediaChannel() : network_interface_(NULL) {} |
| + MediaChannel(const MediaConfig& config) |
| + : network_interface_(NULL) { |
| + enable_dscp_ = config.enable_dscp; |
| + } |
| + MediaChannel() : enable_dscp_(false), network_interface_(NULL) {} |
| 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(enable_dscp_ ? PreferredDscp() : rtc::DSCP_DEFAULT); |
| + } |
| + virtual rtc::DiffServCodePoint PreferredDscp() const { |
| + return rtc::DSCP_DEFAULT; |
| } |
| - |
| // Called when a RTP packet is received. |
| virtual void OnPacketReceived(rtc::Buffer* packet, |
| const rtc::PacketTime& packet_time) = 0; |
| @@ -441,7 +444,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; |
| @@ -468,6 +471,7 @@ class MediaChannel : public sigslot::has_slots<> { |
| : network_interface_->SendRtcp(packet, options); |
| } |
| + bool enable_dscp_; |
| // |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. |
| @@ -921,6 +925,7 @@ class VoiceMediaChannel : public MediaChannel { |
| }; |
| VoiceMediaChannel() {} |
| + VoiceMediaChannel(const MediaConfig& config) : MediaChannel(config) {} |
| virtual ~VoiceMediaChannel() {} |
| virtual bool SetSendParameters(const AudioSendParameters& params) = 0; |
| virtual bool SetRecvParameters(const AudioRecvParameters& params) = 0; |
| @@ -984,6 +989,7 @@ class VideoMediaChannel : public MediaChannel { |
| }; |
| VideoMediaChannel() {} |
| + VideoMediaChannel(const MediaConfig& config) : MediaChannel(config) {} |
| virtual ~VideoMediaChannel() {} |
| virtual bool SetSendParameters(const VideoSendParameters& params) = 0; |