Changed defaults for CreateAnswer in non-constraint mode
This CL also adds control flag in webrtcsession_unittests
that says whether to prefer constraints APIs or non-constraints APIs, and uses it in the test that was needed
to uncover the bug.
BUG=webrtc:4906
Review URL: https://codereview.webrtc.org/1775033002
Cr-Commit-Position: refs/heads/master@{#11947}
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index 700714a..e4ab40e 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -417,6 +417,7 @@
bool ExtractMediaSessionOptions(
const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
+ bool is_offer,
cricket::MediaSessionOptions* session_options) {
typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions;
if (!IsValidOfferToReceiveMedia(rtc_options.offer_to_receive_audio) ||
@@ -424,11 +425,20 @@
return false;
}
+ // If constraints don't prevent us, we always accept video.
if (rtc_options.offer_to_receive_audio != RTCOfferAnswerOptions::kUndefined) {
session_options->recv_audio = (rtc_options.offer_to_receive_audio > 0);
+ } else {
+ session_options->recv_audio = true;
}
+ // For offers, we only offer video if we have it or it's forced by options.
+ // For answers, we will always accept video (if offered).
if (rtc_options.offer_to_receive_video != RTCOfferAnswerOptions::kUndefined) {
session_options->recv_video = (rtc_options.offer_to_receive_video > 0);
+ } else if (is_offer) {
+ session_options->recv_video = false;
+ } else {
+ session_options->recv_video = true;
}
session_options->vad_enabled = rtc_options.voice_activity_detection;
@@ -1497,7 +1507,7 @@
cricket::TransportOptions();
}
}
- if (!ExtractMediaSessionOptions(rtc_options, session_options)) {
+ if (!ExtractMediaSessionOptions(rtc_options, true, session_options)) {
return false;
}
@@ -1568,7 +1578,7 @@
cricket::MediaSessionOptions* session_options) {
session_options->recv_audio = false;
session_options->recv_video = false;
- if (!ExtractMediaSessionOptions(options, session_options)) {
+ if (!ExtractMediaSessionOptions(options, false, session_options)) {
return false;
}
FinishOptionsForAnswer(session_options);