+PassRefPtr<RTCOfferOptions> RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState)
+{
+ if (options.isUndefinedOrNull())
+ return nullptr;
+
+ Vector<String> propertyNames;
+ options.getOwnPropertyNames(propertyNames);
+
+ // Treat |options| as MediaConstraints if it is empty or has "optional" or "mandatory" properties for compatibility.
+ // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and client code is ready.
+ if (propertyNames.isEmpty() || propertyNames.contains("optional") || propertyNames.contains("mandatory"))
+ return nullptr;
+
+ int32_t offerToReceiveVideo = -1;
+ int32_t offerToReceiveAudio = -1;
+ bool voiceActivityDetection = true;
+ bool iceRestart = false;
+
+ if (DictionaryHelper::get(options, "offerToReceiveVideo", offerToReceiveVideo) && offerToReceiveVideo < 0) {
+ exceptionState.throwTypeError("Invalid offerToReceiveVideo");
+ return nullptr;
+ }
+
+ if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudio) && offerToReceiveAudio < 0) {
+ exceptionState.throwTypeError("Invalid offerToReceiveAudio");
+ return nullptr;
+ }
+
+ DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetection);
+ DictionaryHelper::get(options, "iceRestart", iceRestart);
+
+ RefPtr<RTCOfferOptions> rtcOfferOptions = RTCOfferOptions::create(offerToReceiveVideo, offerToReceiveAudio, voiceActivityDetection, iceRestart);
+ return rtcOfferOptions.release();
+}
+
+RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState& exceptionState)