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 "JSRTCRtpCodecParameters.h" |
26 | |
27 | #include "JSDOMConvertNumbers.h" |
28 | #include "JSDOMConvertStrings.h" |
29 | #include "JSDOMGlobalObject.h" |
30 | #include <JavaScriptCore/JSCInlines.h> |
31 | #include <JavaScriptCore/ObjectConstructor.h> |
32 | |
33 | |
34 | namespace WebCore { |
35 | using namespace JSC; |
36 | |
37 | #if ENABLE(WEB_RTC) |
38 | |
39 | template<> RTCRtpCodecParameters convertDictionary<RTCRtpCodecParameters>(ExecState& state, JSValue value) |
40 | { |
41 | VM& vm = state.vm(); |
42 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
43 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
44 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
45 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
46 | throwTypeError(&state, throwScope); |
47 | return { }; |
48 | } |
49 | RTCRtpCodecParameters result; |
50 | JSValue channelsValue; |
51 | if (isNullOrUndefined) |
52 | channelsValue = jsUndefined(); |
53 | else { |
54 | channelsValue = object->get(&state, Identifier::fromString(&state, "channels" )); |
55 | RETURN_IF_EXCEPTION(throwScope, { }); |
56 | } |
57 | if (!channelsValue.isUndefined()) { |
58 | result.channels = convert<IDLUnsignedShort>(state, channelsValue); |
59 | RETURN_IF_EXCEPTION(throwScope, { }); |
60 | } else |
61 | result.channels = 1; |
62 | JSValue clockRateValue; |
63 | if (isNullOrUndefined) |
64 | clockRateValue = jsUndefined(); |
65 | else { |
66 | clockRateValue = object->get(&state, Identifier::fromString(&state, "clockRate" )); |
67 | RETURN_IF_EXCEPTION(throwScope, { }); |
68 | } |
69 | if (!clockRateValue.isUndefined()) { |
70 | result.clockRate = convert<IDLUnsignedLong>(state, clockRateValue); |
71 | RETURN_IF_EXCEPTION(throwScope, { }); |
72 | } |
73 | JSValue mimeTypeValue; |
74 | if (isNullOrUndefined) |
75 | mimeTypeValue = jsUndefined(); |
76 | else { |
77 | mimeTypeValue = object->get(&state, Identifier::fromString(&state, "mimeType" )); |
78 | RETURN_IF_EXCEPTION(throwScope, { }); |
79 | } |
80 | if (!mimeTypeValue.isUndefined()) { |
81 | result.mimeType = convert<IDLDOMString>(state, mimeTypeValue); |
82 | RETURN_IF_EXCEPTION(throwScope, { }); |
83 | } |
84 | JSValue payloadTypeValue; |
85 | if (isNullOrUndefined) |
86 | payloadTypeValue = jsUndefined(); |
87 | else { |
88 | payloadTypeValue = object->get(&state, Identifier::fromString(&state, "payloadType" )); |
89 | RETURN_IF_EXCEPTION(throwScope, { }); |
90 | } |
91 | if (!payloadTypeValue.isUndefined()) { |
92 | result.payloadType = convert<IDLUnsignedShort>(state, payloadTypeValue); |
93 | RETURN_IF_EXCEPTION(throwScope, { }); |
94 | } |
95 | JSValue sdpFmtpLineValue; |
96 | if (isNullOrUndefined) |
97 | sdpFmtpLineValue = jsUndefined(); |
98 | else { |
99 | sdpFmtpLineValue = object->get(&state, Identifier::fromString(&state, "sdpFmtpLine" )); |
100 | RETURN_IF_EXCEPTION(throwScope, { }); |
101 | } |
102 | if (!sdpFmtpLineValue.isUndefined()) { |
103 | result.sdpFmtpLine = convert<IDLDOMString>(state, sdpFmtpLineValue); |
104 | RETURN_IF_EXCEPTION(throwScope, { }); |
105 | } |
106 | return result; |
107 | } |
108 | |
109 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCRtpCodecParameters& dictionary) |
110 | { |
111 | auto& vm = state.vm(); |
112 | |
113 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
114 | |
115 | auto channelsValue = toJS<IDLUnsignedShort>(dictionary.channels); |
116 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "channels" ), channelsValue); |
117 | if (!IDLUnsignedLong::isNullValue(dictionary.clockRate)) { |
118 | auto clockRateValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.clockRate)); |
119 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "clockRate" ), clockRateValue); |
120 | } |
121 | if (!IDLDOMString::isNullValue(dictionary.mimeType)) { |
122 | auto mimeTypeValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.mimeType)); |
123 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "mimeType" ), mimeTypeValue); |
124 | } |
125 | if (!IDLUnsignedShort::isNullValue(dictionary.payloadType)) { |
126 | auto payloadTypeValue = toJS<IDLUnsignedShort>(IDLUnsignedShort::extractValueFromNullable(dictionary.payloadType)); |
127 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "payloadType" ), payloadTypeValue); |
128 | } |
129 | if (!IDLDOMString::isNullValue(dictionary.sdpFmtpLine)) { |
130 | auto sdpFmtpLineValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.sdpFmtpLine)); |
131 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "sdpFmtpLine" ), sdpFmtpLineValue); |
132 | } |
133 | return result; |
134 | } |
135 | |
136 | #endif |
137 | |
138 | } // namespace WebCore |
139 | |
140 | #endif // ENABLE(WEB_RTC) |
141 | |