diff --git a/api/BUILD.gn b/api/BUILD.gn index 95891dface..e9eba77357 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -103,6 +103,7 @@ rtc_static_library("libjingle_peerconnection_api") { # file, really. All these should arguably go away in time. "..:typedefs", "..:webrtc_common", + "../media:rtc_media_config", "../modules/audio_processing:audio_processing_statistics", "../rtc_base:checks", "../rtc_base:deprecation", diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h index 3cbf26386d..7087de6a9f 100644 --- a/api/peerconnectioninterface.h +++ b/api/peerconnectioninterface.h @@ -95,7 +95,7 @@ #include "api/umametrics.h" #include "call/callfactoryinterface.h" #include "logging/rtc_event_log/rtc_event_log_factory_interface.h" -#include "media/base/mediachannel.h" +#include "media/base/mediaconfig.h" #include "media/base/videocapturer.h" #include "p2p/base/portallocator.h" #include "rtc_base/network.h" @@ -446,6 +446,9 @@ class PeerConnectionInterface : public rtc::RefCountInterface { // standard priority order. bool prioritize_most_likely_ice_candidate_pairs = false; + // Implementation defined settings. A public member only for the benefit of + // the implementation. Applications must not access it directly, and should + // instead use provided accessor methods, e.g., set_cpu_adaptation. struct cricket::MediaConfig media_config; // If set to true, only one preferred TURN allocation will be used per diff --git a/media/BUILD.gn b/media/BUILD.gn index dfadbae2f0..b856bb5085 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -55,6 +55,13 @@ rtc_source_set("rtc_h264_profile_id") { ] } +rtc_source_set("rtc_media_config") { + visibility = [ "*" ] + sources = [ + "base/mediaconfig.h", + ] +} + rtc_static_library("rtc_media_base") { visibility = [ "*" ] defines = [] @@ -106,6 +113,7 @@ rtc_static_library("rtc_media_base") { deps += [ ":rtc_h264_profile_id", + ":rtc_media_config", "..:webrtc_common", "../api:libjingle_peerconnection_api", "../api:optional", diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h index 3bcb5964bc..32ab479546 100644 --- a/media/base/mediachannel.h +++ b/media/base/mediachannel.h @@ -28,6 +28,7 @@ #include "api/videosourceinterface.h" #include "call/video_config.h" #include "media/base/codec.h" +#include "media/base/mediaconfig.h" #include "media/base/mediaconstants.h" #include "media/base/streamparams.h" #include "modules/audio_processing/include/audio_processing_statistics.h" @@ -88,71 +89,6 @@ static std::string VectorToString(const std::vector& vals) { return ost.str(); } -// Construction-time settings, 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. - struct Video { - // Enable WebRTC CPU Overuse Detection. This flag comes from the - // PeerConnection constraint 'googCpuOveruseDetection'. - bool enable_cpu_adaptation = true; - - // 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 - // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel copies it - // to VideoSendStream::Config::suspend_below_min_bitrate. - bool suspend_below_min_bitrate = false; - - // 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'. - // WebRtcVideoChannel::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 enable_prerenderer_smoothing = true; - - // Enables periodic bandwidth probing in application-limited region. - bool periodic_alr_bandwidth_probing = false; - - // Enables the new method to estimate the cpu load from encoding, used for - // cpu adaptation. This flag is intended to be controlled primarily by a - // Chrome origin-trial. - // TODO(bugs.webrtc.org/8504): If all goes well, the flag will be removed - // together with the old method of estimation. - bool experiment_cpu_load_estimator = false; - } video; - - bool operator==(const MediaConfig& o) const { - return enable_dscp == o.enable_dscp && - video.enable_cpu_adaptation == - o.video.enable_cpu_adaptation && - video.suspend_below_min_bitrate == - o.video.suspend_below_min_bitrate && - video.enable_prerenderer_smoothing == - o.video.enable_prerenderer_smoothing && - video.periodic_alr_bandwidth_probing == - o.video.periodic_alr_bandwidth_probing && - video.experiment_cpu_load_estimator == - o.video.experiment_cpu_load_estimator; - } - - bool operator!=(const MediaConfig& o) const { return !(*this == o); } -}; - // Options that can be applied to a VideoMediaChannel or a VideoMediaEngine. // 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, diff --git a/media/base/mediaconfig.h b/media/base/mediaconfig.h new file mode 100644 index 0000000000..5e8487155b --- /dev/null +++ b/media/base/mediaconfig.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#ifndef MEDIA_BASE_MEDIACONFIG_H_ +#define MEDIA_BASE_MEDIACONFIG_H_ + +namespace cricket { + +// Construction-time settings, 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. + struct Video { + // Enable WebRTC CPU Overuse Detection. This flag comes from the + // PeerConnection constraint 'googCpuOveruseDetection'. + bool enable_cpu_adaptation = true; + + // 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 + // 'googSuspendBelowMinBitrate', and WebRtcVideoChannel copies it + // to VideoSendStream::Config::suspend_below_min_bitrate. + bool suspend_below_min_bitrate = false; + + // 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'. + // WebRtcVideoChannel::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 enable_prerenderer_smoothing = true; + + // Enables periodic bandwidth probing in application-limited region. + bool periodic_alr_bandwidth_probing = false; + + // Enables the new method to estimate the cpu load from encoding, used for + // cpu adaptation. This flag is intended to be controlled primarily by a + // Chrome origin-trial. + // TODO(bugs.webrtc.org/8504): If all goes well, the flag will be removed + // together with the old method of estimation. + bool experiment_cpu_load_estimator = false; + } video; + + bool operator==(const MediaConfig& o) const { + return enable_dscp == o.enable_dscp && + video.enable_cpu_adaptation == + o.video.enable_cpu_adaptation && + video.suspend_below_min_bitrate == + o.video.suspend_below_min_bitrate && + video.enable_prerenderer_smoothing == + o.video.enable_prerenderer_smoothing && + video.periodic_alr_bandwidth_probing == + o.video.periodic_alr_bandwidth_probing && + video.experiment_cpu_load_estimator == + o.video.experiment_cpu_load_estimator; + } + + bool operator!=(const MediaConfig& o) const { return !(*this == o); } +}; + +} // namespace cricket + +#endif // MEDIA_BASE_MEDIACONFIG_H_ diff --git a/pc/rtpsender.h b/pc/rtpsender.h index 119d91f11a..1fd7b37344 100644 --- a/pc/rtpsender.h +++ b/pc/rtpsender.h @@ -23,9 +23,8 @@ #include "api/rtpsenderinterface.h" #include "rtc_base/basictypes.h" #include "rtc_base/criticalsection.h" -// Adding 'nogncheck' to disable the gn include headers check to support modular -// WebRTC build targets. -#include "media/base/audiosource.h" // nogncheck +#include "media/base/audiosource.h" +#include "media/base/mediachannel.h" #include "pc/dtmfsender.h" #include "pc/statscollector.h"