Delete almost all use of MediaConstraintsInterface in the PeerConnection API
Bug: webrtc:9239
Change-Id: I04f4370f624346bf72c7e4e090b57987b558213b
Reviewed-on: https://webrtc-review.googlesource.com/74420
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24396}
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 7271ece..28b3535 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -469,7 +469,6 @@
deps = [
":array_view",
":libjingle_peerconnection_api",
- ":libjingle_peerconnection_test_api",
":ortc_api",
"../rtc_base:checks",
"../rtc_base:rtc_base_approved",
diff --git a/api/mediaconstraintsinterface.cc b/api/mediaconstraintsinterface.cc
index fb4481f..c892606 100644
--- a/api/mediaconstraintsinterface.cc
+++ b/api/mediaconstraintsinterface.cc
@@ -260,4 +260,48 @@
}
}
+bool CopyConstraintsIntoOfferAnswerOptions(
+ const MediaConstraintsInterface* constraints,
+ PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options) {
+ if (!constraints) {
+ return true;
+ }
+
+ bool value = false;
+ size_t mandatory_constraints_satisfied = 0;
+
+ if (FindConstraint(constraints,
+ MediaConstraintsInterface::kOfferToReceiveAudio, &value,
+ &mandatory_constraints_satisfied)) {
+ offer_answer_options->offer_to_receive_audio =
+ value ? PeerConnectionInterface::RTCOfferAnswerOptions::
+ kOfferToReceiveMediaTrue
+ : 0;
+ }
+
+ if (FindConstraint(constraints,
+ MediaConstraintsInterface::kOfferToReceiveVideo, &value,
+ &mandatory_constraints_satisfied)) {
+ offer_answer_options->offer_to_receive_video =
+ value ? PeerConnectionInterface::RTCOfferAnswerOptions::
+ kOfferToReceiveMediaTrue
+ : 0;
+ }
+ if (FindConstraint(constraints,
+ MediaConstraintsInterface::kVoiceActivityDetection, &value,
+ &mandatory_constraints_satisfied)) {
+ offer_answer_options->voice_activity_detection = value;
+ }
+ if (FindConstraint(constraints, MediaConstraintsInterface::kUseRtpMux, &value,
+ &mandatory_constraints_satisfied)) {
+ offer_answer_options->use_rtp_mux = value;
+ }
+ if (FindConstraint(constraints, MediaConstraintsInterface::kIceRestart,
+ &value, &mandatory_constraints_satisfied)) {
+ offer_answer_options->ice_restart = value;
+ }
+
+ return mandatory_constraints_satisfied == constraints->GetMandatory().size();
+}
+
} // namespace webrtc
diff --git a/api/mediaconstraintsinterface.h b/api/mediaconstraintsinterface.h
index 54ab706..3c85dfb 100644
--- a/api/mediaconstraintsinterface.h
+++ b/api/mediaconstraintsinterface.h
@@ -13,9 +13,10 @@
// http://www.w3.org/TR/mediacapture-streams/#mediastreamconstraints and also
// used in WebRTC: http://dev.w3.org/2011/webrtc/editor/webrtc.html#constraints.
-// This interface is being deprecated in Chrome, and may be removed
-// from WebRTC too.
-// https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
+// Implementation of the w3c constraints spec is the responsibility of the
+// browser. Chrome no longer uses the constraints api declared here, and it will
+// be removed from WebRTC.
+// https://bugs.chromium.org/p/webrtc/issues/detail?id=9239
#ifndef API_MEDIACONSTRAINTSINTERFACE_H_
#define API_MEDIACONSTRAINTSINTERFACE_H_
@@ -144,6 +145,10 @@
const MediaConstraintsInterface* constraints,
cricket::AudioOptions* options);
+bool CopyConstraintsIntoOfferAnswerOptions(
+ const MediaConstraintsInterface* constraints,
+ PeerConnectionInterface::RTCOfferAnswerOptions* offer_answer_options);
+
} // namespace webrtc
#endif // API_MEDIACONSTRAINTSINTERFACE_H_
diff --git a/api/peerconnectionfactoryproxy.h b/api/peerconnectionfactoryproxy.h
index db52083..d885cc1 100644
--- a/api/peerconnectionfactoryproxy.h
+++ b/api/peerconnectionfactoryproxy.h
@@ -31,13 +31,6 @@
// removed.
using PeerConnectionFactoryInterface::CreateVideoSource;
PROXY_METHOD1(void, SetOptions, const Options&)
-PROXY_METHOD5(rtc::scoped_refptr<PeerConnectionInterface>,
- CreatePeerConnection,
- const PeerConnectionInterface::RTCConfiguration&,
- const MediaConstraintsInterface*,
- std::unique_ptr<cricket::PortAllocator>,
- std::unique_ptr<rtc::RTCCertificateGeneratorInterface>,
- PeerConnectionObserver*);
PROXY_METHOD4(rtc::scoped_refptr<PeerConnectionInterface>,
CreatePeerConnection,
const PeerConnectionInterface::RTCConfiguration&,
diff --git a/api/peerconnectioninterface.cc b/api/peerconnectioninterface.cc
index ddaeb36..05aa53f 100644
--- a/api/peerconnectioninterface.cc
+++ b/api/peerconnectioninterface.cc
@@ -247,12 +247,4 @@
return CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(capturer));
}
-rtc::scoped_refptr<VideoTrackSourceInterface>
-PeerConnectionFactoryInterface::CreateVideoSource(
- cricket::VideoCapturer* capturer,
- const MediaConstraintsInterface* constraints) {
- return CreateVideoSource(std::unique_ptr<cricket::VideoCapturer>(capturer),
- constraints);
-}
-
} // namespace webrtc
diff --git a/api/peerconnectioninterface.h b/api/peerconnectioninterface.h
index 593084e..84a0501 100644
--- a/api/peerconnectioninterface.h
+++ b/api/peerconnectioninterface.h
@@ -846,22 +846,12 @@
// Create a new offer.
// The CreateSessionDescriptionObserver callback will be called when done.
virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
- const MediaConstraintsInterface* constraints) {}
-
- // TODO(jiayl): remove the default impl and the old interface when chromium
- // code is updated.
- virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
- const RTCOfferAnswerOptions& options) {}
+ const RTCOfferAnswerOptions& options) = 0;
// Create an answer to an offer.
// The CreateSessionDescriptionObserver callback will be called when done.
virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
- const RTCOfferAnswerOptions& options) {}
- // Deprecated - use version above.
- // TODO(hta): Remove and remove default implementations when all callers
- // are updated.
- virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
- const MediaConstraintsInterface* constraints) {}
+ const RTCOfferAnswerOptions& options) = 0;
// Sets the local session description.
// The PeerConnection takes the ownership of |desc| even if it fails.
@@ -1293,10 +1283,6 @@
// TODO(deadbeef): Remove these once safe to do so.
virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
cricket::VideoCapturer* capturer);
- virtual rtc::scoped_refptr<VideoTrackSourceInterface> CreateVideoSource(
- cricket::VideoCapturer* capturer,
- const MediaConstraintsInterface* constraints);
-
// Creates a new local VideoTrack. The same |source| can be used in several
// tracks.
virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
diff --git a/api/peerconnectionproxy.h b/api/peerconnectionproxy.h
index 7fc5e17..6b66bcc 100644
--- a/api/peerconnectionproxy.h
+++ b/api/peerconnectionproxy.h
@@ -88,14 +88,6 @@
PROXY_METHOD2(void,
CreateOffer,
CreateSessionDescriptionObserver*,
- const MediaConstraintsInterface*)
-PROXY_METHOD2(void,
- CreateAnswer,
- CreateSessionDescriptionObserver*,
- const MediaConstraintsInterface*)
-PROXY_METHOD2(void,
- CreateOffer,
- CreateSessionDescriptionObserver*,
const RTCOfferAnswerOptions&)
PROXY_METHOD2(void,
CreateAnswer,