Chromium Code Reviews| Index: webrtc/api/peerconnection.cc |
| diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc |
| index eacbeaedc3c8bd2262169362276572d95772ce73..2190cdf4d53af790933870ab118daaf18d7839af 100644 |
| --- a/webrtc/api/peerconnection.cc |
| +++ b/webrtc/api/peerconnection.cc |
| @@ -454,6 +454,13 @@ bool ConvertRtcOptionsForOffer( |
| return true; |
| } |
| +bool ConvertRtcOptionsForAnswer( |
| + const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| + cricket::MediaSessionOptions* session_options) { |
| + // TODO(hta): Figure out if there's a difference |
| + return ConvertRtcOptionsForOffer(rtc_options, session_options); |
| +} |
| + |
| bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, |
| cricket::MediaSessionOptions* session_options) { |
| bool value = false; |
| @@ -570,7 +577,6 @@ PeerConnection::~PeerConnection() { |
| bool PeerConnection::Initialize( |
| const PeerConnectionInterface::RTCConfiguration& configuration, |
| - const MediaConstraintsInterface* constraints, |
| rtc::scoped_ptr<cricket::PortAllocator> allocator, |
| rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| PeerConnectionObserver* observer) { |
| @@ -595,13 +601,9 @@ bool PeerConnection::Initialize( |
| int portallocator_flags = port_allocator_->flags(); |
| portallocator_flags |= cricket::PORTALLOCATOR_ENABLE_SHARED_SOCKET | |
| cricket::PORTALLOCATOR_ENABLE_IPV6; |
| - bool value; |
| // If IPv6 flag was specified, we'll not override it by experiment. |
| - if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6, |
| - &value, nullptr)) { |
| - if (!value) { |
| - portallocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6); |
| - } |
| + if (configuration.disable_ipv6) { |
| + portallocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6); |
| } else if (webrtc::field_trial::FindFullName("WebRTC-IPv6Default") == |
| "Disabled") { |
| portallocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6); |
| @@ -623,11 +625,14 @@ bool PeerConnection::Initialize( |
| configuration.disable_prerenderer_smoothing; |
| // Find DSCP constraint. |
| - FindConstraint(constraints, MediaConstraintsInterface::kEnableDscp, |
| - &media_config.enable_dscp, NULL); |
| + if (configuration.override_dscp) { |
| + media_config.enable_dscp = configuration.enable_dscp; |
| + } |
| // Find constraints for cpu overuse detection. |
| - FindConstraint(constraints, MediaConstraintsInterface::kCpuOveruseDetection, |
| - &media_config.enable_cpu_overuse_detection, NULL); |
| + if (configuration.override_cpu_overuse_detection) { |
| + media_config.enable_cpu_overuse_detection = |
| + configuration.enable_cpu_overuse_detection; |
| + } |
| media_controller_.reset(factory_->CreateMediaController(media_config)); |
| @@ -640,8 +645,8 @@ bool PeerConnection::Initialize( |
| stats_.reset(new StatsCollector(this)); |
| // Initialize the WebRtcSession. It creates transport channels etc. |
| - if (!session_->Initialize(factory_->options(), constraints, |
| - std::move(dtls_identity_store), configuration)) { |
| + if (!session_->Initialize(factory_->options(), std::move(dtls_identity_store), |
| + configuration)) { |
| return false; |
| } |
| @@ -1005,7 +1010,26 @@ void PeerConnection::CreateAnswer( |
| return; |
| } |
| - session_->CreateAnswer(observer, constraints, session_options); |
| + session_->CreateAnswer(observer, session_options); |
| +} |
| + |
| +void PeerConnection::CreateAnswer(CreateSessionDescriptionObserver* observer, |
| + const RTCOfferAnswerOptions& options) { |
| + TRACE_EVENT0("webrtc", "PeerConnection::CreateAnswer"); |
| + if (!VERIFY(observer != nullptr)) { |
| + LOG(LS_ERROR) << "CreateAnswer - observer is NULL."; |
| + return; |
| + } |
| + |
| + cricket::MediaSessionOptions session_options; |
| + if (!GetOptionsForAnswer(options, &session_options)) { |
| + std::string error = "CreateAnswer called with invalid options."; |
| + LOG(LS_ERROR) << error; |
| + PostCreateSessionDescriptionFailure(observer, error); |
| + return; |
| + } |
| + |
| + session_->CreateAnswer(observer, session_options); |
| } |
| void PeerConnection::SetLocalDescription( |
| @@ -1552,6 +1576,30 @@ bool PeerConnection::GetOptionsForAnswer( |
| return true; |
| } |
| +bool PeerConnection::GetOptionsForAnswer( |
| + const RTCOfferAnswerOptions& options, |
| + cricket::MediaSessionOptions* session_options) { |
| + session_options->recv_audio = false; |
| + session_options->recv_video = false; |
| + if (!ConvertRtcOptionsForAnswer(options, session_options)) { |
|
perkj_webrtc
2016/02/23 11:40:18
This is code duplication. Please create a helper m
hta-webrtc
2016/02/23 14:30:34
Done. We can inline it again when there's only one
|
| + return false; |
| + } |
| + |
| + AddSendStreams(session_options, senders_, rtp_data_channels_); |
| + session_options->bundle_enabled = |
| + session_options->bundle_enabled && |
| + (session_options->has_audio() || session_options->has_video() || |
| + session_options->has_data()); |
| + |
| + // RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams |
| + // are not signaled in the SDP so does not go through that path and must be |
| + // handled here. |
| + if (session_->data_channel_type() == cricket::DCT_SCTP) { |
| + session_options->data_channel_type = cricket::DCT_SCTP; |
| + } |
| + return true; |
| +} |
| + |
| void PeerConnection::RemoveTracks(cricket::MediaType media_type) { |
| UpdateLocalTracks(std::vector<cricket::StreamParams>(), media_type); |
| UpdateRemoteStreamsList(std::vector<cricket::StreamParams>(), false, |
| @@ -2084,4 +2132,61 @@ DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { |
| return nullptr; |
| } |
| +void CopyConstraintsIntoRtcConfiguration( |
|
perkj_webrtc
2016/02/23 11:40:18
Please move this to the factory where it is used i
hta-webrtc
2016/02/23 14:30:34
The other user is webrtcsession_unittest, which do
|
| + const MediaConstraintsInterface* constraints, |
| + PeerConnectionInterface::RTCConfiguration* configuration) { |
| + // Copy info from constraints into configuration, if present. |
| + if (!constraints) { |
| + return; |
| + } |
| + |
| + bool value; |
| + if (FindConstraint(constraints, MediaConstraintsInterface::kEnableIPv6, |
| + &value, nullptr)) { |
| + if (!value) { |
| + configuration->disable_ipv6 = true; |
| + } |
| + } |
| + // Find DSCP constraint. |
| + if (FindConstraint(constraints, MediaConstraintsInterface::kEnableDscp, |
| + &configuration->enable_dscp, NULL)) { |
| + configuration->override_dscp = true; |
| + } |
| + // Find constraints for cpu overuse detection. |
| + if (FindConstraint(constraints, |
| + MediaConstraintsInterface::kCpuOveruseDetection, |
| + &configuration->enable_cpu_overuse_detection, NULL)) { |
| + configuration->override_cpu_overuse_detection = true; |
| + } |
| + if (FindConstraint(constraints, |
| + MediaConstraintsInterface::kEnableRtpDataChannels, &value, |
| + NULL) && |
| + value) { |
| + configuration->enable_rtp_data_channel = true; |
| + } |
| + // Find Suspend Below Min Bitrate constraint. |
| + if (FindConstraint( |
| + constraints, |
| + MediaConstraintsInterface::kEnableVideoSuspendBelowMinBitrate, |
| + &configuration->suspend_below_min_bitrate, NULL)) { |
| + configuration->override_suspend_below_min_bitrate = true; |
| + } |
| + if (FindConstraint(constraints, |
| + MediaConstraintsInterface::kScreencastMinBitrate, |
| + &configuration->screencast_min_bitrate, NULL)) { |
| + configuration->override_screencast_min_bitrate = true; |
| + } |
| + if (FindConstraint(constraints, |
| + MediaConstraintsInterface::kCombinedAudioVideoBwe, &value, |
| + NULL)) { |
| + configuration->override_combined_audio_video_bwe = true; |
| + configuration->combined_audio_video_bwe = value; |
| + } |
| + if (FindConstraint(constraints, MediaConstraintsInterface::kEnableDtlsSrtp, |
| + &value, NULL)) { |
| + configuration->override_enable_dtls_srtp = true; |
| + configuration->enable_dtls_srtp = value; |
| + } |
| +} |
| + |
| } // namespace webrtc |