Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: webrtc/api/peerconnection.cc

Issue 1775033002: Changed defaults for CreateAnswer in non-constraint mode (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: First landable version of patch Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 422 }
423 return nullptr; 423 return nullptr;
424 } 424 }
425 425
426 rtc::Thread* signaling_thread_; 426 rtc::Thread* signaling_thread_;
427 rtc::Thread* worker_thread_; 427 rtc::Thread* worker_thread_;
428 }; 428 };
429 429
430 bool ExtractMediaSessionOptions( 430 bool ExtractMediaSessionOptions(
431 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, 431 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
432 bool is_offer,
432 cricket::MediaSessionOptions* session_options) { 433 cricket::MediaSessionOptions* session_options) {
433 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; 434 typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions;
434 if (!IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_audio) || 435 if (!IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_audio) ||
435 !IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_video)) { 436 !IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_video)) {
436 return false; 437 return false;
437 } 438 }
438 439
440 // If constraints don't prevent us, we always accept video.
439 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) { 441 if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) {
440 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0); 442 session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0);
443 } else {
444 session_options->recv_audio = true;
441 } 445 }
446 // For offers, we only offer video if we have it or it's forced by options.
447 // For answers, we will always accept video (if offered).
442 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) { 448 if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) {
443 session_options->recv_video = (rtc_options.offer_to_receive_video > 0); 449 session_options->recv_video = (rtc_options.offer_to_receive_video > 0);
450 } else if (is_offer) {
451 session_options->recv_video = false;
452 } else {
453 session_options->recv_video = true;
444 } 454 }
445 455
446 session_options->vad_enabled = rtc_options.voice_activity_detection; 456 session_options->vad_enabled = rtc_options.voice_activity_detection;
447 session_options->bundle_enabled = rtc_options.use_rtp_mux; 457 session_options->bundle_enabled = rtc_options.use_rtp_mux;
448 for (auto& kv : session_options->transport_options) { 458 for (auto& kv : session_options->transport_options) {
449 kv.second.ice_restart = rtc_options.ice_restart; 459 kv.second.ice_restart = rtc_options.ice_restart;
450 } 460 }
451 461
452 return true; 462 return true;
453 } 463 }
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 cricket::MediaSessionOptions* session_options) { 1511 cricket::MediaSessionOptions* session_options) {
1502 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of 1512 // TODO(deadbeef): Once we have transceivers, enumerate them here instead of
1503 // ContentInfos. 1513 // ContentInfos.
1504 if (session_->local_description()) { 1514 if (session_->local_description()) {
1505 for (const cricket::ContentInfo& content : 1515 for (const cricket::ContentInfo& content :
1506 session_->local_description()->description()->contents()) { 1516 session_->local_description()->description()->contents()) {
1507 session_options->transport_options[content.name] = 1517 session_options->transport_options[content.name] =
1508 cricket::TransportOptions(); 1518 cricket::TransportOptions();
1509 } 1519 }
1510 } 1520 }
1511 if (!ExtractMediaSessionOptions(rtc_options, session_options)) { 1521 if (!ExtractMediaSessionOptions(rtc_options, true, session_options)) {
1512 return false; 1522 return false;
1513 } 1523 }
1514 1524
1515 AddSendStreams(session_options, senders_, rtp_data_channels_); 1525 AddSendStreams(session_options, senders_, rtp_data_channels_);
1516 // Offer to receive audio/video if the constraint is not set and there are 1526 // Offer to receive audio/video if the constraint is not set and there are
1517 // send streams, or we're currently receiving. 1527 // send streams, or we're currently receiving.
1518 if (rtc_options.offer_to_receive_audio == RTCOfferAnswerOptions::kUndefined) { 1528 if (rtc_options.offer_to_receive_audio == RTCOfferAnswerOptions::kUndefined) {
1519 session_options->recv_audio = 1529 session_options->recv_audio =
1520 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO) || 1530 session_options->HasSendMediaStream(cricket::MEDIA_TYPE_AUDIO) ||
1521 !remote_audio_tracks_.empty(); 1531 !remote_audio_tracks_.empty();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1572 } 1582 }
1573 FinishOptionsForAnswer(session_options); 1583 FinishOptionsForAnswer(session_options);
1574 return true; 1584 return true;
1575 } 1585 }
1576 1586
1577 bool PeerConnection::GetOptionsForAnswer( 1587 bool PeerConnection::GetOptionsForAnswer(
1578 const RTCOfferAnswerOptions& options, 1588 const RTCOfferAnswerOptions& options,
1579 cricket::MediaSessionOptions* session_options) { 1589 cricket::MediaSessionOptions* session_options) {
1580 session_options->recv_audio = false; 1590 session_options->recv_audio = false;
1581 session_options->recv_video = false; 1591 session_options->recv_video = false;
1582 if (!ExtractMediaSessionOptions(options, session_options)) { 1592 if (!ExtractMediaSessionOptions(options, false, session_options)) {
1583 return false; 1593 return false;
1584 } 1594 }
1585 FinishOptionsForAnswer(session_options); 1595 FinishOptionsForAnswer(session_options);
1586 return true; 1596 return true;
1587 } 1597 }
1588 1598
1589 void PeerConnection::RemoveTracks(cricket::MediaType media_type) { 1599 void PeerConnection::RemoveTracks(cricket::MediaType media_type) {
1590 UpdateLocalTracks(std::vector<cricket::StreamParams>(), media_type); 1600 UpdateLocalTracks(std::vector<cricket::StreamParams>(), media_type);
1591 UpdateRemoteStreamsList(std::vector<cricket::StreamParams>(), false, 1601 UpdateRemoteStreamsList(std::vector<cricket::StreamParams>(), false,
1592 media_type, nullptr); 1602 media_type, nullptr);
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const { 2122 DataChannel* PeerConnection::FindDataChannelBySid(int sid) const {
2113 for (const auto& channel : sctp_data_channels_) { 2123 for (const auto& channel : sctp_data_channels_) {
2114 if (channel->id() == sid) { 2124 if (channel->id() == sid) {
2115 return channel; 2125 return channel;
2116 } 2126 }
2117 } 2127 }
2118 return nullptr; 2128 return nullptr;
2119 } 2129 }
2120 2130
2121 } // namespace webrtc 2131 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698