Embed a cricket::MediaConfig in RTCConfiguration.
This eliminates some instances rtc:Optional and makes the code simpler. No changes in defaults or other behaviour are intended. BUG=webrtc:4906 Review URL: https://codereview.webrtc.org/1818033002 Cr-Commit-Position: refs/heads/master@{#12326}
This commit is contained in:
parent
9c4fadc199
commit
c36b31b78e
@ -179,29 +179,23 @@ void CopyConstraintsIntoRtcConfiguration(
|
||||
return;
|
||||
}
|
||||
|
||||
bool value;
|
||||
bool enable_ipv6;
|
||||
if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6,
|
||||
&value, nullptr)) {
|
||||
if (!value) {
|
||||
configuration->disable_ipv6 = true;
|
||||
}
|
||||
}
|
||||
ConstraintToOptionalBool(constraints, MediaConstraintsInterface::kEnableDscp,
|
||||
&configuration->enable_dscp);
|
||||
ConstraintToOptionalBool(constraints,
|
||||
MediaConstraintsInterface::kCpuOveruseDetection,
|
||||
&configuration->cpu_overuse_detection);
|
||||
if (FindConstraint(constraints,
|
||||
MediaConstraintsInterface::kEnableRtpDataChannels, &value,
|
||||
NULL) &&
|
||||
value) {
|
||||
configuration->enable_rtp_data_channel = true;
|
||||
&enable_ipv6, nullptr)) {
|
||||
configuration->disable_ipv6 = !enable_ipv6;
|
||||
}
|
||||
FindConstraint(constraints, MediaConstraintsInterface::kEnableDscp,
|
||||
&configuration->media_config.enable_dscp, nullptr);
|
||||
FindConstraint(
|
||||
constraints, MediaConstraintsInterface::kCpuOveruseDetection,
|
||||
&configuration->media_config.video.enable_cpu_overuse_detection, nullptr);
|
||||
FindConstraint(constraints, MediaConstraintsInterface::kEnableRtpDataChannels,
|
||||
&configuration->enable_rtp_data_channel, nullptr);
|
||||
// Find Suspend Below Min Bitrate constraint.
|
||||
ConstraintToOptionalBool(
|
||||
constraints,
|
||||
MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate,
|
||||
&configuration->suspend_below_min_bitrate);
|
||||
FindConstraint(constraints,
|
||||
MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate,
|
||||
&configuration->media_config.video.suspend_below_min_bitrate,
|
||||
nullptr);
|
||||
ConstraintToOptionalInt(constraints,
|
||||
MediaConstraintsInterface::kScreencastMinBitrate,
|
||||
&configuration->screencast_min_bitrate);
|
||||
|
||||
@ -17,11 +17,24 @@ namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
// Checks all settings touched by CopyConstraintsIntoRtcConfiguration,
|
||||
// plus audio_jitter_buffer_max_packets.
|
||||
bool Matches(const PeerConnectionInterface::RTCConfiguration& a,
|
||||
const PeerConnectionInterface::RTCConfiguration& b) {
|
||||
return a.audio_jitter_buffer_max_packets ==
|
||||
return a.disable_ipv6 == b.disable_ipv6 &&
|
||||
a.audio_jitter_buffer_max_packets ==
|
||||
b.audio_jitter_buffer_max_packets &&
|
||||
a.disable_prerenderer_smoothing == b.disable_prerenderer_smoothing;
|
||||
a.enable_rtp_data_channel == b.enable_rtp_data_channel &&
|
||||
a.screencast_min_bitrate == b.screencast_min_bitrate &&
|
||||
a.combined_audio_video_bwe == b.combined_audio_video_bwe &&
|
||||
a.enable_dtls_srtp == b.enable_dtls_srtp &&
|
||||
a.media_config.enable_dscp == b.media_config.enable_dscp &&
|
||||
a.media_config.video.enable_cpu_overuse_detection ==
|
||||
b.media_config.video.enable_cpu_overuse_detection &&
|
||||
a.media_config.video.disable_prerenderer_smoothing ==
|
||||
b.media_config.video.disable_prerenderer_smoothing &&
|
||||
a.media_config.video.suspend_below_min_bitrate ==
|
||||
b.media_config.video.suspend_below_min_bitrate;
|
||||
}
|
||||
|
||||
TEST(MediaConstraintsInterface, CopyConstraintsIntoRtcConfiguration) {
|
||||
|
||||
@ -525,7 +525,6 @@ PeerConnection::~PeerConnection() {
|
||||
}
|
||||
|
||||
bool PeerConnection::Initialize(
|
||||
const cricket::MediaConfig& media_config,
|
||||
const PeerConnectionInterface::RTCConfiguration& configuration,
|
||||
rtc::scoped_ptr<cricket::PortAllocator> allocator,
|
||||
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
|
||||
@ -569,7 +568,8 @@ bool PeerConnection::Initialize(
|
||||
// No step delay is used while allocating ports.
|
||||
port_allocator_->set_step_delay(cricket::kMinimumStepDelay);
|
||||
|
||||
media_controller_.reset(factory_->CreateMediaController(media_config));
|
||||
media_controller_.reset(
|
||||
factory_->CreateMediaController(configuration.media_config));
|
||||
|
||||
session_.reset(
|
||||
new WebRtcSession(media_controller_.get(), factory_->signaling_thread(),
|
||||
|
||||
@ -68,7 +68,6 @@ class PeerConnection : public PeerConnectionInterface,
|
||||
explicit PeerConnection(PeerConnectionFactory* factory);
|
||||
|
||||
bool Initialize(
|
||||
const cricket::MediaConfig& media_config,
|
||||
const PeerConnectionInterface::RTCConfiguration& configuration,
|
||||
rtc::scoped_ptr<cricket::PortAllocator> allocator,
|
||||
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
|
||||
|
||||
@ -286,24 +286,8 @@ PeerConnectionFactory::CreatePeerConnection(
|
||||
|
||||
rtc::scoped_refptr<PeerConnection> pc(
|
||||
new rtc::RefCountedObject<PeerConnection>(this));
|
||||
// We rely on default values when constraints aren't found.
|
||||
cricket::MediaConfig media_config;
|
||||
|
||||
media_config.video.disable_prerenderer_smoothing =
|
||||
configuration.disable_prerenderer_smoothing;
|
||||
if (configuration.enable_dscp) {
|
||||
media_config.enable_dscp = *(configuration.enable_dscp);
|
||||
}
|
||||
if (configuration.cpu_overuse_detection) {
|
||||
media_config.video.enable_cpu_overuse_detection =
|
||||
*(configuration.cpu_overuse_detection);
|
||||
}
|
||||
if (configuration.suspend_below_min_bitrate) {
|
||||
media_config.video.suspend_below_min_bitrate =
|
||||
*(configuration.suspend_below_min_bitrate);
|
||||
}
|
||||
|
||||
if (!pc->Initialize(media_config, configuration, std::move(allocator),
|
||||
if (!pc->Initialize(configuration, std::move(allocator),
|
||||
std::move(dtls_identity_store), observer)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -70,6 +70,7 @@
|
||||
#include "webrtc/base/rtccertificate.h"
|
||||
#include "webrtc/base/socketaddress.h"
|
||||
#include "webrtc/base/sslstreamadapter.h"
|
||||
#include "webrtc/media/base/mediachannel.h"
|
||||
#include "webrtc/p2p/base/portallocator.h"
|
||||
|
||||
namespace rtc {
|
||||
@ -222,6 +223,11 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
|
||||
};
|
||||
|
||||
// TODO(hbos): Change into class with private data and public getters.
|
||||
// TODO(nisse): In particular, accessing fields directly from an
|
||||
// application is brittle, since the organization mirrors the
|
||||
// organization of the implementation, which isn't stable. So we
|
||||
// need getters and setters at least for fields which applications
|
||||
// are interested in.
|
||||
struct RTCConfiguration {
|
||||
// This struct is subject to reorganization, both for naming
|
||||
// consistency, and to group settings to match where they are used
|
||||
@ -229,28 +235,33 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
|
||||
// methods for all settings which are of interest to applications,
|
||||
// Chrome in particular.
|
||||
|
||||
bool dscp() { return enable_dscp.value_or(false); }
|
||||
void set_dscp(bool enable) { enable_dscp = rtc::Optional<bool>(enable); }
|
||||
bool dscp() { return media_config.enable_dscp; }
|
||||
void set_dscp(bool enable) { media_config.enable_dscp = enable; }
|
||||
|
||||
// TODO(nisse): The corresponding flag in MediaConfig and
|
||||
// elsewhere should be renamed enable_cpu_adaptation.
|
||||
bool cpu_adaptation() { return cpu_overuse_detection.value_or(true); }
|
||||
bool cpu_adaptation() {
|
||||
return media_config.video.enable_cpu_overuse_detection;
|
||||
}
|
||||
void set_cpu_adaptation(bool enable) {
|
||||
cpu_overuse_detection = rtc::Optional<bool>(enable);
|
||||
media_config.video.enable_cpu_overuse_detection = enable;
|
||||
}
|
||||
|
||||
// TODO(nisse): Currently no getter method, since it collides with
|
||||
// the flag itself. Add when the flag is moved to MediaConfig.
|
||||
bool suspend_below_min_bitrate() {
|
||||
return media_config.video.suspend_below_min_bitrate;
|
||||
}
|
||||
void set_suspend_below_min_bitrate(bool enable) {
|
||||
suspend_below_min_bitrate = rtc::Optional<bool>(enable);
|
||||
media_config.video.suspend_below_min_bitrate = enable;
|
||||
}
|
||||
|
||||
// TODO(nisse): The negation in the corresponding MediaConfig
|
||||
// attribute is inconsistent, and it should be renamed at some
|
||||
// point.
|
||||
bool prerenderer_smoothing() { return !disable_prerenderer_smoothing; }
|
||||
bool prerenderer_smoothing() {
|
||||
return !media_config.video.disable_prerenderer_smoothing;
|
||||
}
|
||||
void set_prerenderer_smoothing(bool enable) {
|
||||
disable_prerenderer_smoothing = !enable;
|
||||
media_config.video.disable_prerenderer_smoothing = !enable;
|
||||
}
|
||||
|
||||
static const int kUndefined = -1;
|
||||
@ -271,16 +282,13 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
|
||||
int ice_backup_candidate_pair_ping_interval; // ms
|
||||
ContinualGatheringPolicy continual_gathering_policy;
|
||||
std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates;
|
||||
bool disable_prerenderer_smoothing;
|
||||
bool prioritize_most_likely_ice_candidate_pairs;
|
||||
struct cricket::MediaConfig media_config;
|
||||
// Flags corresponding to values set by constraint flags.
|
||||
// rtc::Optional flags can be "missing", in which case the webrtc
|
||||
// default applies.
|
||||
bool disable_ipv6;
|
||||
rtc::Optional<bool> enable_dscp;
|
||||
bool enable_rtp_data_channel;
|
||||
rtc::Optional<bool> cpu_overuse_detection;
|
||||
rtc::Optional<bool> suspend_below_min_bitrate;
|
||||
rtc::Optional<int> screencast_min_bitrate;
|
||||
rtc::Optional<bool> combined_audio_video_bwe;
|
||||
rtc::Optional<bool> enable_dtls_srtp;
|
||||
@ -294,7 +302,6 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
|
||||
ice_connection_receiving_timeout(kUndefined),
|
||||
ice_backup_candidate_pair_ping_interval(kUndefined),
|
||||
continual_gathering_policy(GATHER_ONCE),
|
||||
disable_prerenderer_smoothing(false),
|
||||
prioritize_most_likely_ice_candidate_pairs(false),
|
||||
disable_ipv6(false),
|
||||
enable_rtp_data_channel(false) {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user