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 "JSRTCRtpParameters.h"
26
27#include "JSDOMConvertSequences.h"
28#include "JSDOMGlobalObject.h"
29#include "JSRTCRtpCodecParameters.h"
30#include "JSRTCRtpHeaderExtensionParameters.h"
31#include <JavaScriptCore/JSArray.h>
32#include <JavaScriptCore/JSCInlines.h>
33#include <JavaScriptCore/ObjectConstructor.h>
34
35
36namespace WebCore {
37using namespace JSC;
38
39#if ENABLE(WEB_RTC)
40
41template<> RTCRtpParameters convertDictionary<RTCRtpParameters>(ExecState& state, JSValue value)
42{
43 VM& vm = state.vm();
44 auto throwScope = DECLARE_THROW_SCOPE(vm);
45 bool isNullOrUndefined = value.isUndefinedOrNull();
46 auto* object = isNullOrUndefined ? nullptr : value.getObject();
47 if (UNLIKELY(!isNullOrUndefined && !object)) {
48 throwTypeError(&state, throwScope);
49 return { };
50 }
51 RTCRtpParameters result;
52 JSValue codecsValue;
53 if (isNullOrUndefined)
54 codecsValue = jsUndefined();
55 else {
56 codecsValue = object->get(&state, Identifier::fromString(&state, "codecs"));
57 RETURN_IF_EXCEPTION(throwScope, { });
58 }
59 if (!codecsValue.isUndefined()) {
60 result.codecs = convert<IDLSequence<IDLDictionary<RTCRtpCodecParameters>>>(state, codecsValue);
61 RETURN_IF_EXCEPTION(throwScope, { });
62 }
63 JSValue headerExtensionsValue;
64 if (isNullOrUndefined)
65 headerExtensionsValue = jsUndefined();
66 else {
67 headerExtensionsValue = object->get(&state, Identifier::fromString(&state, "headerExtensions"));
68 RETURN_IF_EXCEPTION(throwScope, { });
69 }
70 if (!headerExtensionsValue.isUndefined()) {
71 result.headerExtensions = convert<IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>>(state, headerExtensionsValue);
72 RETURN_IF_EXCEPTION(throwScope, { });
73 }
74 return result;
75}
76
77JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCRtpParameters& dictionary)
78{
79 auto& vm = state.vm();
80
81 auto result = constructEmptyObject(&state, globalObject.objectPrototype());
82
83 if (!IDLSequence<IDLDictionary<RTCRtpCodecParameters>>::isNullValue(dictionary.codecs)) {
84 auto codecsValue = toJS<IDLSequence<IDLDictionary<RTCRtpCodecParameters>>>(state, globalObject, IDLSequence<IDLDictionary<RTCRtpCodecParameters>>::extractValueFromNullable(dictionary.codecs));
85 result->putDirect(vm, JSC::Identifier::fromString(&vm, "codecs"), codecsValue);
86 }
87 if (!IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>::isNullValue(dictionary.headerExtensions)) {
88 auto headerExtensionsValue = toJS<IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>>(state, globalObject, IDLSequence<IDLDictionary<RTCRtpHeaderExtensionParameters>>::extractValueFromNullable(dictionary.headerExtensions));
89 result->putDirect(vm, JSC::Identifier::fromString(&vm, "headerExtensions"), headerExtensionsValue);
90 }
91 return result;
92}
93
94#endif
95
96} // namespace WebCore
97
98#endif // ENABLE(WEB_RTC)
99