| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(WEB_RTC) |
| 24 | |
| 25 | #include "JSRTCRtpSendParameters.h" |
| 26 | |
| 27 | #include "JSDOMConvertEnumeration.h" |
| 28 | #include "JSDOMConvertSequences.h" |
| 29 | #include "JSDOMConvertStrings.h" |
| 30 | #include "JSDOMGlobalObject.h" |
| 31 | #include "JSRTCDegradationPreference.h" |
| 32 | #include "JSRTCRtpCodecParameters.h" |
| 33 | #include "JSRTCRtpEncodingParameters.h" |
| 34 | #include "JSRTCRtpHeaderExtensionParameters.h" |
| 35 | #include <JavaScriptCore/JSArray.h> |
| 36 | #include <JavaScriptCore/JSCInlines.h> |
| 37 | #include <JavaScriptCore/ObjectConstructor.h> |
| 38 | |
| 39 | |
| 40 | namespace WebCore { |
| 41 | using namespace JSC; |
| 42 | |
| 43 | #if ENABLE(WEB_RTC) |
| 44 | |
| 45 | template<> RTCRtpSendParameters convertDictionary<RTCRtpSendParameters>(ExecState& state, JSValue value) |
| 46 | { |
| 47 | VM& vm = state.vm(); |
| 48 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 49 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 50 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 51 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 52 | throwTypeError(&state, throwScope); |
| 53 | return { }; |
| 54 | } |
| 55 | RTCRtpSendParameters result; |
| 56 | JSValue codecsValue; |
| 57 | if (isNullOrUndefined) |
| 58 | codecsValue = jsUndefined(); |
| 59 | else { |
| 60 | codecsValue = object->get(&state, Identifier::fromString(&state, "codecs" )); |
| 61 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 62 | } |
| 63 | if (!codecsValue.isUndefined()) { |
| 64 | result.codecs = convert<IDLSequence<IDLDictionary<RTCRtpCodecParameters>>>(state, codecsValue); |
| 65 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 66 | } |
| 67 | JSValue ; |
| 68 | if (isNullOrUndefined) |
| 69 | headerExtensionsValue = jsUndefined(); |
| 70 | else { |
| 71 | headerExtensionsValue = object->get(&state, Identifier::fromString(&state, "headerExtensions" )); |
| 72 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 73 | } |
| 74 | if (!headerExtensionsValue.isUndefined()) { |
| 75 | result.headerExtensions = convert<IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>>(state, headerExtensionsValue); |
| 76 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 77 | } |
| 78 | JSValue degradationPreferenceValue; |
| 79 | if (isNullOrUndefined) |
| 80 | degradationPreferenceValue = jsUndefined(); |
| 81 | else { |
| 82 | degradationPreferenceValue = object->get(&state, Identifier::fromString(&state, "degradationPreference" )); |
| 83 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 84 | } |
| 85 | if (!degradationPreferenceValue.isUndefined()) { |
| 86 | result.degradationPreference = convert<IDLEnumeration<RTCDegradationPreference>>(state, degradationPreferenceValue); |
| 87 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 88 | } else |
| 89 | result.degradationPreference = RTCDegradationPreference::Balanced; |
| 90 | JSValue encodingsValue; |
| 91 | if (isNullOrUndefined) |
| 92 | encodingsValue = jsUndefined(); |
| 93 | else { |
| 94 | encodingsValue = object->get(&state, Identifier::fromString(&state, "encodings" )); |
| 95 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 96 | } |
| 97 | if (!encodingsValue.isUndefined()) { |
| 98 | result.encodings = convert<IDLSequence<IDLDictionary<RTCRtpEncodingParameters>>>(state, encodingsValue); |
| 99 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 100 | } else { |
| 101 | throwRequiredMemberTypeError(state, throwScope, "encodings" , "RTCRtpSendParameters" , "sequence" ); |
| 102 | return { }; |
| 103 | } |
| 104 | JSValue transactionIdValue; |
| 105 | if (isNullOrUndefined) |
| 106 | transactionIdValue = jsUndefined(); |
| 107 | else { |
| 108 | transactionIdValue = object->get(&state, Identifier::fromString(&state, "transactionId" )); |
| 109 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 110 | } |
| 111 | if (!transactionIdValue.isUndefined()) { |
| 112 | result.transactionId = convert<IDLDOMString>(state, transactionIdValue); |
| 113 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 114 | } else { |
| 115 | throwRequiredMemberTypeError(state, throwScope, "transactionId" , "RTCRtpSendParameters" , "DOMString" ); |
| 116 | return { }; |
| 117 | } |
| 118 | return result; |
| 119 | } |
| 120 | |
| 121 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCRtpSendParameters& dictionary) |
| 122 | { |
| 123 | auto& vm = state.vm(); |
| 124 | |
| 125 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 126 | |
| 127 | if (!IDLSequence<IDLDictionary<RTCRtpCodecParameters>>::isNullValue(dictionary.codecs)) { |
| 128 | auto codecsValue = toJS<IDLSequence<IDLDictionary<RTCRtpCodecParameters>>>(state, globalObject, IDLSequence<IDLDictionary<RTCRtpCodecParameters>>::extractValueFromNullable(dictionary.codecs)); |
| 129 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "codecs" ), codecsValue); |
| 130 | } |
| 131 | if (!IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>::isNullValue(dictionary.headerExtensions)) { |
| 132 | auto = toJS<IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>>(state, globalObject, IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>::extractValueFromNullable(dictionary.headerExtensions)); |
| 133 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "headerExtensions" ), headerExtensionsValue); |
| 134 | } |
| 135 | auto degradationPreferenceValue = toJS<IDLEnumeration<RTCDegradationPreference>>(state, dictionary.degradationPreference); |
| 136 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "degradationPreference" ), degradationPreferenceValue); |
| 137 | auto encodingsValue = toJS<IDLSequence<IDLDictionary<RTCRtpEncodingParameters>>>(state, globalObject, dictionary.encodings); |
| 138 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "encodings" ), encodingsValue); |
| 139 | auto transactionIdValue = toJS<IDLDOMString>(state, dictionary.transactionId); |
| 140 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "transactionId" ), transactionIdValue); |
| 141 | return result; |
| 142 | } |
| 143 | |
| 144 | #endif |
| 145 | |
| 146 | } // namespace WebCore |
| 147 | |
| 148 | #endif // ENABLE(WEB_RTC) |
| 149 | |