| 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 "JSRTCStatsReport.h" |
| 26 | |
| 27 | #include "JSDOMAttribute.h" |
| 28 | #include "JSDOMBinding.h" |
| 29 | #include "JSDOMConstructorNotConstructable.h" |
| 30 | #include "JSDOMConvertAny.h" |
| 31 | #include "JSDOMConvertBoolean.h" |
| 32 | #include "JSDOMConvertNumbers.h" |
| 33 | #include "JSDOMConvertStrings.h" |
| 34 | #include "JSDOMExceptionHandling.h" |
| 35 | #include "JSDOMGlobalObject.h" |
| 36 | #include "JSDOMMapLike.h" |
| 37 | #include "JSDOMOperation.h" |
| 38 | #include "JSDOMWrapperCache.h" |
| 39 | #include "ScriptExecutionContext.h" |
| 40 | #include <JavaScriptCore/BuiltinNames.h> |
| 41 | #include <JavaScriptCore/FunctionPrototype.h> |
| 42 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
| 43 | #include <JavaScriptCore/JSCInlines.h> |
| 44 | #include <JavaScriptCore/JSString.h> |
| 45 | #include <JavaScriptCore/ObjectConstructor.h> |
| 46 | #include <wtf/GetPtr.h> |
| 47 | #include <wtf/PointerPreparations.h> |
| 48 | #include <wtf/URL.h> |
| 49 | |
| 50 | |
| 51 | namespace WebCore { |
| 52 | using namespace JSC; |
| 53 | |
| 54 | String convertEnumerationToString(RTCStatsReport::Type enumerationValue) |
| 55 | { |
| 56 | static const NeverDestroyed<String> values[] = { |
| 57 | MAKE_STATIC_STRING_IMPL("codec" ), |
| 58 | MAKE_STATIC_STRING_IMPL("inbound-rtp" ), |
| 59 | MAKE_STATIC_STRING_IMPL("outbound-rtp" ), |
| 60 | MAKE_STATIC_STRING_IMPL("peer-connection" ), |
| 61 | MAKE_STATIC_STRING_IMPL("data-channel" ), |
| 62 | MAKE_STATIC_STRING_IMPL("track" ), |
| 63 | MAKE_STATIC_STRING_IMPL("transport" ), |
| 64 | MAKE_STATIC_STRING_IMPL("candidate-pair" ), |
| 65 | MAKE_STATIC_STRING_IMPL("local-candidate" ), |
| 66 | MAKE_STATIC_STRING_IMPL("remote-candidate" ), |
| 67 | MAKE_STATIC_STRING_IMPL("certificate" ), |
| 68 | }; |
| 69 | static_assert(static_cast<size_t>(RTCStatsReport::Type::Codec) == 0, "RTCStatsReport::Type::Codec is not 0 as expected" ); |
| 70 | static_assert(static_cast<size_t>(RTCStatsReport::Type::InboundRtp) == 1, "RTCStatsReport::Type::InboundRtp is not 1 as expected" ); |
| 71 | static_assert(static_cast<size_t>(RTCStatsReport::Type::OutboundRtp) == 2, "RTCStatsReport::Type::OutboundRtp is not 2 as expected" ); |
| 72 | static_assert(static_cast<size_t>(RTCStatsReport::Type::PeerConnection) == 3, "RTCStatsReport::Type::PeerConnection is not 3 as expected" ); |
| 73 | static_assert(static_cast<size_t>(RTCStatsReport::Type::DataChannel) == 4, "RTCStatsReport::Type::DataChannel is not 4 as expected" ); |
| 74 | static_assert(static_cast<size_t>(RTCStatsReport::Type::Track) == 5, "RTCStatsReport::Type::Track is not 5 as expected" ); |
| 75 | static_assert(static_cast<size_t>(RTCStatsReport::Type::Transport) == 6, "RTCStatsReport::Type::Transport is not 6 as expected" ); |
| 76 | static_assert(static_cast<size_t>(RTCStatsReport::Type::CandidatePair) == 7, "RTCStatsReport::Type::CandidatePair is not 7 as expected" ); |
| 77 | static_assert(static_cast<size_t>(RTCStatsReport::Type::LocalCandidate) == 8, "RTCStatsReport::Type::LocalCandidate is not 8 as expected" ); |
| 78 | static_assert(static_cast<size_t>(RTCStatsReport::Type::RemoteCandidate) == 9, "RTCStatsReport::Type::RemoteCandidate is not 9 as expected" ); |
| 79 | static_assert(static_cast<size_t>(RTCStatsReport::Type::Certificate) == 10, "RTCStatsReport::Type::Certificate is not 10 as expected" ); |
| 80 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 81 | return values[static_cast<size_t>(enumerationValue)]; |
| 82 | } |
| 83 | |
| 84 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCStatsReport::Type enumerationValue) |
| 85 | { |
| 86 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 87 | } |
| 88 | |
| 89 | template<> Optional<RTCStatsReport::Type> parseEnumeration<RTCStatsReport::Type>(ExecState& state, JSValue value) |
| 90 | { |
| 91 | auto stringValue = value.toWTFString(&state); |
| 92 | if (stringValue == "codec" ) |
| 93 | return RTCStatsReport::Type::Codec; |
| 94 | if (stringValue == "inbound-rtp" ) |
| 95 | return RTCStatsReport::Type::InboundRtp; |
| 96 | if (stringValue == "outbound-rtp" ) |
| 97 | return RTCStatsReport::Type::OutboundRtp; |
| 98 | if (stringValue == "peer-connection" ) |
| 99 | return RTCStatsReport::Type::PeerConnection; |
| 100 | if (stringValue == "data-channel" ) |
| 101 | return RTCStatsReport::Type::DataChannel; |
| 102 | if (stringValue == "track" ) |
| 103 | return RTCStatsReport::Type::Track; |
| 104 | if (stringValue == "transport" ) |
| 105 | return RTCStatsReport::Type::Transport; |
| 106 | if (stringValue == "candidate-pair" ) |
| 107 | return RTCStatsReport::Type::CandidatePair; |
| 108 | if (stringValue == "local-candidate" ) |
| 109 | return RTCStatsReport::Type::LocalCandidate; |
| 110 | if (stringValue == "remote-candidate" ) |
| 111 | return RTCStatsReport::Type::RemoteCandidate; |
| 112 | if (stringValue == "certificate" ) |
| 113 | return RTCStatsReport::Type::Certificate; |
| 114 | return WTF::nullopt; |
| 115 | } |
| 116 | |
| 117 | template<> const char* expectedEnumerationValues<RTCStatsReport::Type>() |
| 118 | { |
| 119 | return "\"codec\", \"inbound-rtp\", \"outbound-rtp\", \"peer-connection\", \"data-channel\", \"track\", \"transport\", \"candidate-pair\", \"local-candidate\", \"remote-candidate\", \"certificate\"" ; |
| 120 | } |
| 121 | |
| 122 | String convertEnumerationToString(RTCStatsReport::IceCandidatePairState enumerationValue) |
| 123 | { |
| 124 | static const NeverDestroyed<String> values[] = { |
| 125 | MAKE_STATIC_STRING_IMPL("frozen" ), |
| 126 | MAKE_STATIC_STRING_IMPL("waiting" ), |
| 127 | MAKE_STATIC_STRING_IMPL("inprogress" ), |
| 128 | MAKE_STATIC_STRING_IMPL("failed" ), |
| 129 | MAKE_STATIC_STRING_IMPL("succeeded" ), |
| 130 | MAKE_STATIC_STRING_IMPL("cancelled" ), |
| 131 | }; |
| 132 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidatePairState::Frozen) == 0, "RTCStatsReport::IceCandidatePairState::Frozen is not 0 as expected" ); |
| 133 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidatePairState::Waiting) == 1, "RTCStatsReport::IceCandidatePairState::Waiting is not 1 as expected" ); |
| 134 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidatePairState::Inprogress) == 2, "RTCStatsReport::IceCandidatePairState::Inprogress is not 2 as expected" ); |
| 135 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidatePairState::Failed) == 3, "RTCStatsReport::IceCandidatePairState::Failed is not 3 as expected" ); |
| 136 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidatePairState::Succeeded) == 4, "RTCStatsReport::IceCandidatePairState::Succeeded is not 4 as expected" ); |
| 137 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidatePairState::Cancelled) == 5, "RTCStatsReport::IceCandidatePairState::Cancelled is not 5 as expected" ); |
| 138 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 139 | return values[static_cast<size_t>(enumerationValue)]; |
| 140 | } |
| 141 | |
| 142 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCStatsReport::IceCandidatePairState enumerationValue) |
| 143 | { |
| 144 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 145 | } |
| 146 | |
| 147 | template<> Optional<RTCStatsReport::IceCandidatePairState> parseEnumeration<RTCStatsReport::IceCandidatePairState>(ExecState& state, JSValue value) |
| 148 | { |
| 149 | auto stringValue = value.toWTFString(&state); |
| 150 | if (stringValue == "frozen" ) |
| 151 | return RTCStatsReport::IceCandidatePairState::Frozen; |
| 152 | if (stringValue == "waiting" ) |
| 153 | return RTCStatsReport::IceCandidatePairState::Waiting; |
| 154 | if (stringValue == "inprogress" ) |
| 155 | return RTCStatsReport::IceCandidatePairState::Inprogress; |
| 156 | if (stringValue == "failed" ) |
| 157 | return RTCStatsReport::IceCandidatePairState::Failed; |
| 158 | if (stringValue == "succeeded" ) |
| 159 | return RTCStatsReport::IceCandidatePairState::Succeeded; |
| 160 | if (stringValue == "cancelled" ) |
| 161 | return RTCStatsReport::IceCandidatePairState::Cancelled; |
| 162 | return WTF::nullopt; |
| 163 | } |
| 164 | |
| 165 | template<> const char* expectedEnumerationValues<RTCStatsReport::IceCandidatePairState>() |
| 166 | { |
| 167 | return "\"frozen\", \"waiting\", \"inprogress\", \"failed\", \"succeeded\", \"cancelled\"" ; |
| 168 | } |
| 169 | |
| 170 | String convertEnumerationToString(RTCStatsReport::IceCandidateType enumerationValue) |
| 171 | { |
| 172 | static const NeverDestroyed<String> values[] = { |
| 173 | MAKE_STATIC_STRING_IMPL("host" ), |
| 174 | MAKE_STATIC_STRING_IMPL("srflx" ), |
| 175 | MAKE_STATIC_STRING_IMPL("prflx" ), |
| 176 | MAKE_STATIC_STRING_IMPL("relay" ), |
| 177 | }; |
| 178 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidateType::Host) == 0, "RTCStatsReport::IceCandidateType::Host is not 0 as expected" ); |
| 179 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidateType::Srflx) == 1, "RTCStatsReport::IceCandidateType::Srflx is not 1 as expected" ); |
| 180 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidateType::Prflx) == 2, "RTCStatsReport::IceCandidateType::Prflx is not 2 as expected" ); |
| 181 | static_assert(static_cast<size_t>(RTCStatsReport::IceCandidateType::Relay) == 3, "RTCStatsReport::IceCandidateType::Relay is not 3 as expected" ); |
| 182 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 183 | return values[static_cast<size_t>(enumerationValue)]; |
| 184 | } |
| 185 | |
| 186 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCStatsReport::IceCandidateType enumerationValue) |
| 187 | { |
| 188 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 189 | } |
| 190 | |
| 191 | template<> Optional<RTCStatsReport::IceCandidateType> parseEnumeration<RTCStatsReport::IceCandidateType>(ExecState& state, JSValue value) |
| 192 | { |
| 193 | auto stringValue = value.toWTFString(&state); |
| 194 | if (stringValue == "host" ) |
| 195 | return RTCStatsReport::IceCandidateType::Host; |
| 196 | if (stringValue == "srflx" ) |
| 197 | return RTCStatsReport::IceCandidateType::Srflx; |
| 198 | if (stringValue == "prflx" ) |
| 199 | return RTCStatsReport::IceCandidateType::Prflx; |
| 200 | if (stringValue == "relay" ) |
| 201 | return RTCStatsReport::IceCandidateType::Relay; |
| 202 | return WTF::nullopt; |
| 203 | } |
| 204 | |
| 205 | template<> const char* expectedEnumerationValues<RTCStatsReport::IceCandidateType>() |
| 206 | { |
| 207 | return "\"host\", \"srflx\", \"prflx\", \"relay\"" ; |
| 208 | } |
| 209 | |
| 210 | String convertEnumerationToString(RTCStatsReport::CodecType enumerationValue) |
| 211 | { |
| 212 | static const NeverDestroyed<String> values[] = { |
| 213 | MAKE_STATIC_STRING_IMPL("encode" ), |
| 214 | MAKE_STATIC_STRING_IMPL("decode" ), |
| 215 | }; |
| 216 | static_assert(static_cast<size_t>(RTCStatsReport::CodecType::Encode) == 0, "RTCStatsReport::CodecType::Encode is not 0 as expected" ); |
| 217 | static_assert(static_cast<size_t>(RTCStatsReport::CodecType::Decode) == 1, "RTCStatsReport::CodecType::Decode is not 1 as expected" ); |
| 218 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 219 | return values[static_cast<size_t>(enumerationValue)]; |
| 220 | } |
| 221 | |
| 222 | template<> JSString* convertEnumerationToJS(ExecState& state, RTCStatsReport::CodecType enumerationValue) |
| 223 | { |
| 224 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 225 | } |
| 226 | |
| 227 | template<> Optional<RTCStatsReport::CodecType> parseEnumeration<RTCStatsReport::CodecType>(ExecState& state, JSValue value) |
| 228 | { |
| 229 | auto stringValue = value.toWTFString(&state); |
| 230 | if (stringValue == "encode" ) |
| 231 | return RTCStatsReport::CodecType::Encode; |
| 232 | if (stringValue == "decode" ) |
| 233 | return RTCStatsReport::CodecType::Decode; |
| 234 | return WTF::nullopt; |
| 235 | } |
| 236 | |
| 237 | template<> const char* expectedEnumerationValues<RTCStatsReport::CodecType>() |
| 238 | { |
| 239 | return "\"encode\", \"decode\"" ; |
| 240 | } |
| 241 | |
| 242 | template<> RTCStatsReport::Stats convertDictionary<RTCStatsReport::Stats>(ExecState& state, JSValue value) |
| 243 | { |
| 244 | VM& vm = state.vm(); |
| 245 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 246 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 247 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 248 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 249 | throwTypeError(&state, throwScope); |
| 250 | return { }; |
| 251 | } |
| 252 | RTCStatsReport::Stats result; |
| 253 | JSValue idValue; |
| 254 | if (isNullOrUndefined) |
| 255 | idValue = jsUndefined(); |
| 256 | else { |
| 257 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 258 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 259 | } |
| 260 | if (!idValue.isUndefined()) { |
| 261 | result.id = convert<IDLDOMString>(state, idValue); |
| 262 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 263 | } |
| 264 | JSValue timestampValue; |
| 265 | if (isNullOrUndefined) |
| 266 | timestampValue = jsUndefined(); |
| 267 | else { |
| 268 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 269 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 270 | } |
| 271 | if (!timestampValue.isUndefined()) { |
| 272 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 273 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 274 | } |
| 275 | JSValue typeValue; |
| 276 | if (isNullOrUndefined) |
| 277 | typeValue = jsUndefined(); |
| 278 | else { |
| 279 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 280 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 281 | } |
| 282 | if (!typeValue.isUndefined()) { |
| 283 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 284 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 285 | } |
| 286 | return result; |
| 287 | } |
| 288 | |
| 289 | template<> RTCStatsReport::RTCRTPStreamStats convertDictionary<RTCStatsReport::RTCRTPStreamStats>(ExecState& state, JSValue value) |
| 290 | { |
| 291 | VM& vm = state.vm(); |
| 292 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 293 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 294 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 295 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 296 | throwTypeError(&state, throwScope); |
| 297 | return { }; |
| 298 | } |
| 299 | RTCStatsReport::RTCRTPStreamStats result; |
| 300 | JSValue idValue; |
| 301 | if (isNullOrUndefined) |
| 302 | idValue = jsUndefined(); |
| 303 | else { |
| 304 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 305 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 306 | } |
| 307 | if (!idValue.isUndefined()) { |
| 308 | result.id = convert<IDLDOMString>(state, idValue); |
| 309 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 310 | } |
| 311 | JSValue timestampValue; |
| 312 | if (isNullOrUndefined) |
| 313 | timestampValue = jsUndefined(); |
| 314 | else { |
| 315 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 316 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 317 | } |
| 318 | if (!timestampValue.isUndefined()) { |
| 319 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 320 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 321 | } |
| 322 | JSValue typeValue; |
| 323 | if (isNullOrUndefined) |
| 324 | typeValue = jsUndefined(); |
| 325 | else { |
| 326 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 327 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 328 | } |
| 329 | if (!typeValue.isUndefined()) { |
| 330 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 331 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 332 | } |
| 333 | JSValue associateStatsIdValue; |
| 334 | if (isNullOrUndefined) |
| 335 | associateStatsIdValue = jsUndefined(); |
| 336 | else { |
| 337 | associateStatsIdValue = object->get(&state, Identifier::fromString(&state, "associateStatsId" )); |
| 338 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 339 | } |
| 340 | if (!associateStatsIdValue.isUndefined()) { |
| 341 | result.associateStatsId = convert<IDLDOMString>(state, associateStatsIdValue); |
| 342 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 343 | } |
| 344 | JSValue codecIdValue; |
| 345 | if (isNullOrUndefined) |
| 346 | codecIdValue = jsUndefined(); |
| 347 | else { |
| 348 | codecIdValue = object->get(&state, Identifier::fromString(&state, "codecId" )); |
| 349 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 350 | } |
| 351 | if (!codecIdValue.isUndefined()) { |
| 352 | result.codecId = convert<IDLDOMString>(state, codecIdValue); |
| 353 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 354 | } |
| 355 | JSValue firCountValue; |
| 356 | if (isNullOrUndefined) |
| 357 | firCountValue = jsUndefined(); |
| 358 | else { |
| 359 | firCountValue = object->get(&state, Identifier::fromString(&state, "firCount" )); |
| 360 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 361 | } |
| 362 | if (!firCountValue.isUndefined()) { |
| 363 | result.firCount = convert<IDLUnsignedLong>(state, firCountValue); |
| 364 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 365 | } |
| 366 | JSValue isRemoteValue; |
| 367 | if (isNullOrUndefined) |
| 368 | isRemoteValue = jsUndefined(); |
| 369 | else { |
| 370 | isRemoteValue = object->get(&state, Identifier::fromString(&state, "isRemote" )); |
| 371 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 372 | } |
| 373 | if (!isRemoteValue.isUndefined()) { |
| 374 | result.isRemote = convert<IDLBoolean>(state, isRemoteValue); |
| 375 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 376 | } else |
| 377 | result.isRemote = false; |
| 378 | JSValue mediaTypeValue; |
| 379 | if (isNullOrUndefined) |
| 380 | mediaTypeValue = jsUndefined(); |
| 381 | else { |
| 382 | mediaTypeValue = object->get(&state, Identifier::fromString(&state, "mediaType" )); |
| 383 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 384 | } |
| 385 | if (!mediaTypeValue.isUndefined()) { |
| 386 | result.mediaType = convert<IDLDOMString>(state, mediaTypeValue); |
| 387 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 388 | } |
| 389 | JSValue nackCountValue; |
| 390 | if (isNullOrUndefined) |
| 391 | nackCountValue = jsUndefined(); |
| 392 | else { |
| 393 | nackCountValue = object->get(&state, Identifier::fromString(&state, "nackCount" )); |
| 394 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 395 | } |
| 396 | if (!nackCountValue.isUndefined()) { |
| 397 | result.nackCount = convert<IDLUnsignedLong>(state, nackCountValue); |
| 398 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 399 | } |
| 400 | JSValue pliCountValue; |
| 401 | if (isNullOrUndefined) |
| 402 | pliCountValue = jsUndefined(); |
| 403 | else { |
| 404 | pliCountValue = object->get(&state, Identifier::fromString(&state, "pliCount" )); |
| 405 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 406 | } |
| 407 | if (!pliCountValue.isUndefined()) { |
| 408 | result.pliCount = convert<IDLUnsignedLong>(state, pliCountValue); |
| 409 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 410 | } |
| 411 | JSValue qpSumValue; |
| 412 | if (isNullOrUndefined) |
| 413 | qpSumValue = jsUndefined(); |
| 414 | else { |
| 415 | qpSumValue = object->get(&state, Identifier::fromString(&state, "qpSum" )); |
| 416 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 417 | } |
| 418 | if (!qpSumValue.isUndefined()) { |
| 419 | result.qpSum = convert<IDLUnsignedLongLong>(state, qpSumValue); |
| 420 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 421 | } |
| 422 | JSValue sliCountValue; |
| 423 | if (isNullOrUndefined) |
| 424 | sliCountValue = jsUndefined(); |
| 425 | else { |
| 426 | sliCountValue = object->get(&state, Identifier::fromString(&state, "sliCount" )); |
| 427 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 428 | } |
| 429 | if (!sliCountValue.isUndefined()) { |
| 430 | result.sliCount = convert<IDLUnsignedLong>(state, sliCountValue); |
| 431 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 432 | } |
| 433 | JSValue ssrcValue; |
| 434 | if (isNullOrUndefined) |
| 435 | ssrcValue = jsUndefined(); |
| 436 | else { |
| 437 | ssrcValue = object->get(&state, Identifier::fromString(&state, "ssrc" )); |
| 438 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 439 | } |
| 440 | if (!ssrcValue.isUndefined()) { |
| 441 | result.ssrc = convert<IDLUnsignedLong>(state, ssrcValue); |
| 442 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 443 | } |
| 444 | JSValue trackIdValue; |
| 445 | if (isNullOrUndefined) |
| 446 | trackIdValue = jsUndefined(); |
| 447 | else { |
| 448 | trackIdValue = object->get(&state, Identifier::fromString(&state, "trackId" )); |
| 449 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 450 | } |
| 451 | if (!trackIdValue.isUndefined()) { |
| 452 | result.trackId = convert<IDLDOMString>(state, trackIdValue); |
| 453 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 454 | } |
| 455 | JSValue transportIdValue; |
| 456 | if (isNullOrUndefined) |
| 457 | transportIdValue = jsUndefined(); |
| 458 | else { |
| 459 | transportIdValue = object->get(&state, Identifier::fromString(&state, "transportId" )); |
| 460 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 461 | } |
| 462 | if (!transportIdValue.isUndefined()) { |
| 463 | result.transportId = convert<IDLDOMString>(state, transportIdValue); |
| 464 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 465 | } |
| 466 | return result; |
| 467 | } |
| 468 | |
| 469 | template<> RTCStatsReport::InboundRTPStreamStats convertDictionary<RTCStatsReport::InboundRTPStreamStats>(ExecState& state, JSValue value) |
| 470 | { |
| 471 | VM& vm = state.vm(); |
| 472 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 473 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 474 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 475 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 476 | throwTypeError(&state, throwScope); |
| 477 | return { }; |
| 478 | } |
| 479 | RTCStatsReport::InboundRTPStreamStats result; |
| 480 | JSValue idValue; |
| 481 | if (isNullOrUndefined) |
| 482 | idValue = jsUndefined(); |
| 483 | else { |
| 484 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 485 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 486 | } |
| 487 | if (!idValue.isUndefined()) { |
| 488 | result.id = convert<IDLDOMString>(state, idValue); |
| 489 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 490 | } |
| 491 | JSValue timestampValue; |
| 492 | if (isNullOrUndefined) |
| 493 | timestampValue = jsUndefined(); |
| 494 | else { |
| 495 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 496 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 497 | } |
| 498 | if (!timestampValue.isUndefined()) { |
| 499 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 500 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 501 | } |
| 502 | JSValue typeValue; |
| 503 | if (isNullOrUndefined) |
| 504 | typeValue = jsUndefined(); |
| 505 | else { |
| 506 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 507 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 508 | } |
| 509 | if (!typeValue.isUndefined()) { |
| 510 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 511 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 512 | } |
| 513 | JSValue associateStatsIdValue; |
| 514 | if (isNullOrUndefined) |
| 515 | associateStatsIdValue = jsUndefined(); |
| 516 | else { |
| 517 | associateStatsIdValue = object->get(&state, Identifier::fromString(&state, "associateStatsId" )); |
| 518 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 519 | } |
| 520 | if (!associateStatsIdValue.isUndefined()) { |
| 521 | result.associateStatsId = convert<IDLDOMString>(state, associateStatsIdValue); |
| 522 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 523 | } |
| 524 | JSValue codecIdValue; |
| 525 | if (isNullOrUndefined) |
| 526 | codecIdValue = jsUndefined(); |
| 527 | else { |
| 528 | codecIdValue = object->get(&state, Identifier::fromString(&state, "codecId" )); |
| 529 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 530 | } |
| 531 | if (!codecIdValue.isUndefined()) { |
| 532 | result.codecId = convert<IDLDOMString>(state, codecIdValue); |
| 533 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 534 | } |
| 535 | JSValue firCountValue; |
| 536 | if (isNullOrUndefined) |
| 537 | firCountValue = jsUndefined(); |
| 538 | else { |
| 539 | firCountValue = object->get(&state, Identifier::fromString(&state, "firCount" )); |
| 540 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 541 | } |
| 542 | if (!firCountValue.isUndefined()) { |
| 543 | result.firCount = convert<IDLUnsignedLong>(state, firCountValue); |
| 544 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 545 | } |
| 546 | JSValue isRemoteValue; |
| 547 | if (isNullOrUndefined) |
| 548 | isRemoteValue = jsUndefined(); |
| 549 | else { |
| 550 | isRemoteValue = object->get(&state, Identifier::fromString(&state, "isRemote" )); |
| 551 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 552 | } |
| 553 | if (!isRemoteValue.isUndefined()) { |
| 554 | result.isRemote = convert<IDLBoolean>(state, isRemoteValue); |
| 555 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 556 | } else |
| 557 | result.isRemote = false; |
| 558 | JSValue mediaTypeValue; |
| 559 | if (isNullOrUndefined) |
| 560 | mediaTypeValue = jsUndefined(); |
| 561 | else { |
| 562 | mediaTypeValue = object->get(&state, Identifier::fromString(&state, "mediaType" )); |
| 563 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 564 | } |
| 565 | if (!mediaTypeValue.isUndefined()) { |
| 566 | result.mediaType = convert<IDLDOMString>(state, mediaTypeValue); |
| 567 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 568 | } |
| 569 | JSValue nackCountValue; |
| 570 | if (isNullOrUndefined) |
| 571 | nackCountValue = jsUndefined(); |
| 572 | else { |
| 573 | nackCountValue = object->get(&state, Identifier::fromString(&state, "nackCount" )); |
| 574 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 575 | } |
| 576 | if (!nackCountValue.isUndefined()) { |
| 577 | result.nackCount = convert<IDLUnsignedLong>(state, nackCountValue); |
| 578 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 579 | } |
| 580 | JSValue pliCountValue; |
| 581 | if (isNullOrUndefined) |
| 582 | pliCountValue = jsUndefined(); |
| 583 | else { |
| 584 | pliCountValue = object->get(&state, Identifier::fromString(&state, "pliCount" )); |
| 585 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 586 | } |
| 587 | if (!pliCountValue.isUndefined()) { |
| 588 | result.pliCount = convert<IDLUnsignedLong>(state, pliCountValue); |
| 589 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 590 | } |
| 591 | JSValue qpSumValue; |
| 592 | if (isNullOrUndefined) |
| 593 | qpSumValue = jsUndefined(); |
| 594 | else { |
| 595 | qpSumValue = object->get(&state, Identifier::fromString(&state, "qpSum" )); |
| 596 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 597 | } |
| 598 | if (!qpSumValue.isUndefined()) { |
| 599 | result.qpSum = convert<IDLUnsignedLongLong>(state, qpSumValue); |
| 600 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 601 | } |
| 602 | JSValue sliCountValue; |
| 603 | if (isNullOrUndefined) |
| 604 | sliCountValue = jsUndefined(); |
| 605 | else { |
| 606 | sliCountValue = object->get(&state, Identifier::fromString(&state, "sliCount" )); |
| 607 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 608 | } |
| 609 | if (!sliCountValue.isUndefined()) { |
| 610 | result.sliCount = convert<IDLUnsignedLong>(state, sliCountValue); |
| 611 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 612 | } |
| 613 | JSValue ssrcValue; |
| 614 | if (isNullOrUndefined) |
| 615 | ssrcValue = jsUndefined(); |
| 616 | else { |
| 617 | ssrcValue = object->get(&state, Identifier::fromString(&state, "ssrc" )); |
| 618 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 619 | } |
| 620 | if (!ssrcValue.isUndefined()) { |
| 621 | result.ssrc = convert<IDLUnsignedLong>(state, ssrcValue); |
| 622 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 623 | } |
| 624 | JSValue trackIdValue; |
| 625 | if (isNullOrUndefined) |
| 626 | trackIdValue = jsUndefined(); |
| 627 | else { |
| 628 | trackIdValue = object->get(&state, Identifier::fromString(&state, "trackId" )); |
| 629 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 630 | } |
| 631 | if (!trackIdValue.isUndefined()) { |
| 632 | result.trackId = convert<IDLDOMString>(state, trackIdValue); |
| 633 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 634 | } |
| 635 | JSValue transportIdValue; |
| 636 | if (isNullOrUndefined) |
| 637 | transportIdValue = jsUndefined(); |
| 638 | else { |
| 639 | transportIdValue = object->get(&state, Identifier::fromString(&state, "transportId" )); |
| 640 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 641 | } |
| 642 | if (!transportIdValue.isUndefined()) { |
| 643 | result.transportId = convert<IDLDOMString>(state, transportIdValue); |
| 644 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 645 | } |
| 646 | JSValue burstDiscardCountValue; |
| 647 | if (isNullOrUndefined) |
| 648 | burstDiscardCountValue = jsUndefined(); |
| 649 | else { |
| 650 | burstDiscardCountValue = object->get(&state, Identifier::fromString(&state, "burstDiscardCount" )); |
| 651 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 652 | } |
| 653 | if (!burstDiscardCountValue.isUndefined()) { |
| 654 | result.burstDiscardCount = convert<IDLUnsignedLong>(state, burstDiscardCountValue); |
| 655 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 656 | } |
| 657 | JSValue burstDiscardRateValue; |
| 658 | if (isNullOrUndefined) |
| 659 | burstDiscardRateValue = jsUndefined(); |
| 660 | else { |
| 661 | burstDiscardRateValue = object->get(&state, Identifier::fromString(&state, "burstDiscardRate" )); |
| 662 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 663 | } |
| 664 | if (!burstDiscardRateValue.isUndefined()) { |
| 665 | result.burstDiscardRate = convert<IDLDouble>(state, burstDiscardRateValue); |
| 666 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 667 | } |
| 668 | JSValue burstLossCountValue; |
| 669 | if (isNullOrUndefined) |
| 670 | burstLossCountValue = jsUndefined(); |
| 671 | else { |
| 672 | burstLossCountValue = object->get(&state, Identifier::fromString(&state, "burstLossCount" )); |
| 673 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 674 | } |
| 675 | if (!burstLossCountValue.isUndefined()) { |
| 676 | result.burstLossCount = convert<IDLUnsignedLong>(state, burstLossCountValue); |
| 677 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 678 | } |
| 679 | JSValue burstLossRateValue; |
| 680 | if (isNullOrUndefined) |
| 681 | burstLossRateValue = jsUndefined(); |
| 682 | else { |
| 683 | burstLossRateValue = object->get(&state, Identifier::fromString(&state, "burstLossRate" )); |
| 684 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 685 | } |
| 686 | if (!burstLossRateValue.isUndefined()) { |
| 687 | result.burstLossRate = convert<IDLDouble>(state, burstLossRateValue); |
| 688 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 689 | } |
| 690 | JSValue burstPacketsDiscardedValue; |
| 691 | if (isNullOrUndefined) |
| 692 | burstPacketsDiscardedValue = jsUndefined(); |
| 693 | else { |
| 694 | burstPacketsDiscardedValue = object->get(&state, Identifier::fromString(&state, "burstPacketsDiscarded" )); |
| 695 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 696 | } |
| 697 | if (!burstPacketsDiscardedValue.isUndefined()) { |
| 698 | result.burstPacketsDiscarded = convert<IDLUnsignedLong>(state, burstPacketsDiscardedValue); |
| 699 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 700 | } |
| 701 | JSValue burstPacketsLostValue; |
| 702 | if (isNullOrUndefined) |
| 703 | burstPacketsLostValue = jsUndefined(); |
| 704 | else { |
| 705 | burstPacketsLostValue = object->get(&state, Identifier::fromString(&state, "burstPacketsLost" )); |
| 706 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 707 | } |
| 708 | if (!burstPacketsLostValue.isUndefined()) { |
| 709 | result.burstPacketsLost = convert<IDLUnsignedLong>(state, burstPacketsLostValue); |
| 710 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 711 | } |
| 712 | JSValue bytesReceivedValue; |
| 713 | if (isNullOrUndefined) |
| 714 | bytesReceivedValue = jsUndefined(); |
| 715 | else { |
| 716 | bytesReceivedValue = object->get(&state, Identifier::fromString(&state, "bytesReceived" )); |
| 717 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 718 | } |
| 719 | if (!bytesReceivedValue.isUndefined()) { |
| 720 | result.bytesReceived = convert<IDLUnsignedLongLong>(state, bytesReceivedValue); |
| 721 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 722 | } |
| 723 | JSValue fractionLostValue; |
| 724 | if (isNullOrUndefined) |
| 725 | fractionLostValue = jsUndefined(); |
| 726 | else { |
| 727 | fractionLostValue = object->get(&state, Identifier::fromString(&state, "fractionLost" )); |
| 728 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 729 | } |
| 730 | if (!fractionLostValue.isUndefined()) { |
| 731 | result.fractionLost = convert<IDLDouble>(state, fractionLostValue); |
| 732 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 733 | } |
| 734 | JSValue framesDecodedValue; |
| 735 | if (isNullOrUndefined) |
| 736 | framesDecodedValue = jsUndefined(); |
| 737 | else { |
| 738 | framesDecodedValue = object->get(&state, Identifier::fromString(&state, "framesDecoded" )); |
| 739 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 740 | } |
| 741 | if (!framesDecodedValue.isUndefined()) { |
| 742 | result.framesDecoded = convert<IDLUnsignedLong>(state, framesDecodedValue); |
| 743 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 744 | } |
| 745 | JSValue gapDiscardRateValue; |
| 746 | if (isNullOrUndefined) |
| 747 | gapDiscardRateValue = jsUndefined(); |
| 748 | else { |
| 749 | gapDiscardRateValue = object->get(&state, Identifier::fromString(&state, "gapDiscardRate" )); |
| 750 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 751 | } |
| 752 | if (!gapDiscardRateValue.isUndefined()) { |
| 753 | result.gapDiscardRate = convert<IDLDouble>(state, gapDiscardRateValue); |
| 754 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 755 | } |
| 756 | JSValue gapLossRateValue; |
| 757 | if (isNullOrUndefined) |
| 758 | gapLossRateValue = jsUndefined(); |
| 759 | else { |
| 760 | gapLossRateValue = object->get(&state, Identifier::fromString(&state, "gapLossRate" )); |
| 761 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 762 | } |
| 763 | if (!gapLossRateValue.isUndefined()) { |
| 764 | result.gapLossRate = convert<IDLDouble>(state, gapLossRateValue); |
| 765 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 766 | } |
| 767 | JSValue jitterValue; |
| 768 | if (isNullOrUndefined) |
| 769 | jitterValue = jsUndefined(); |
| 770 | else { |
| 771 | jitterValue = object->get(&state, Identifier::fromString(&state, "jitter" )); |
| 772 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 773 | } |
| 774 | if (!jitterValue.isUndefined()) { |
| 775 | result.jitter = convert<IDLDouble>(state, jitterValue); |
| 776 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 777 | } |
| 778 | JSValue packetsDiscardedValue; |
| 779 | if (isNullOrUndefined) |
| 780 | packetsDiscardedValue = jsUndefined(); |
| 781 | else { |
| 782 | packetsDiscardedValue = object->get(&state, Identifier::fromString(&state, "packetsDiscarded" )); |
| 783 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 784 | } |
| 785 | if (!packetsDiscardedValue.isUndefined()) { |
| 786 | result.packetsDiscarded = convert<IDLUnsignedLong>(state, packetsDiscardedValue); |
| 787 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 788 | } |
| 789 | JSValue packetsLostValue; |
| 790 | if (isNullOrUndefined) |
| 791 | packetsLostValue = jsUndefined(); |
| 792 | else { |
| 793 | packetsLostValue = object->get(&state, Identifier::fromString(&state, "packetsLost" )); |
| 794 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 795 | } |
| 796 | if (!packetsLostValue.isUndefined()) { |
| 797 | result.packetsLost = convert<IDLUnsignedLong>(state, packetsLostValue); |
| 798 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 799 | } |
| 800 | JSValue packetsReceivedValue; |
| 801 | if (isNullOrUndefined) |
| 802 | packetsReceivedValue = jsUndefined(); |
| 803 | else { |
| 804 | packetsReceivedValue = object->get(&state, Identifier::fromString(&state, "packetsReceived" )); |
| 805 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 806 | } |
| 807 | if (!packetsReceivedValue.isUndefined()) { |
| 808 | result.packetsReceived = convert<IDLUnsignedLong>(state, packetsReceivedValue); |
| 809 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 810 | } |
| 811 | JSValue packetsRepairedValue; |
| 812 | if (isNullOrUndefined) |
| 813 | packetsRepairedValue = jsUndefined(); |
| 814 | else { |
| 815 | packetsRepairedValue = object->get(&state, Identifier::fromString(&state, "packetsRepaired" )); |
| 816 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 817 | } |
| 818 | if (!packetsRepairedValue.isUndefined()) { |
| 819 | result.packetsRepaired = convert<IDLUnsignedLong>(state, packetsRepairedValue); |
| 820 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 821 | } |
| 822 | return result; |
| 823 | } |
| 824 | |
| 825 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::InboundRTPStreamStats& dictionary) |
| 826 | { |
| 827 | auto& vm = state.vm(); |
| 828 | |
| 829 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 830 | |
| 831 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 832 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 833 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 834 | } |
| 835 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 836 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 837 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 838 | } |
| 839 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 840 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 841 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 842 | } |
| 843 | if (!IDLDOMString::isNullValue(dictionary.associateStatsId)) { |
| 844 | auto associateStatsIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.associateStatsId)); |
| 845 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "associateStatsId" ), associateStatsIdValue); |
| 846 | } |
| 847 | if (!IDLDOMString::isNullValue(dictionary.codecId)) { |
| 848 | auto codecIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.codecId)); |
| 849 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "codecId" ), codecIdValue); |
| 850 | } |
| 851 | if (!IDLUnsignedLong::isNullValue(dictionary.firCount)) { |
| 852 | auto firCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.firCount)); |
| 853 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "firCount" ), firCountValue); |
| 854 | } |
| 855 | auto isRemoteValue = toJS<IDLBoolean>(dictionary.isRemote); |
| 856 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "isRemote" ), isRemoteValue); |
| 857 | if (!IDLDOMString::isNullValue(dictionary.mediaType)) { |
| 858 | auto mediaTypeValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.mediaType)); |
| 859 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "mediaType" ), mediaTypeValue); |
| 860 | } |
| 861 | if (!IDLUnsignedLong::isNullValue(dictionary.nackCount)) { |
| 862 | auto nackCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.nackCount)); |
| 863 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "nackCount" ), nackCountValue); |
| 864 | } |
| 865 | if (!IDLUnsignedLong::isNullValue(dictionary.pliCount)) { |
| 866 | auto pliCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.pliCount)); |
| 867 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "pliCount" ), pliCountValue); |
| 868 | } |
| 869 | if (!IDLUnsignedLongLong::isNullValue(dictionary.qpSum)) { |
| 870 | auto qpSumValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.qpSum)); |
| 871 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "qpSum" ), qpSumValue); |
| 872 | } |
| 873 | if (!IDLUnsignedLong::isNullValue(dictionary.sliCount)) { |
| 874 | auto sliCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.sliCount)); |
| 875 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "sliCount" ), sliCountValue); |
| 876 | } |
| 877 | if (!IDLUnsignedLong::isNullValue(dictionary.ssrc)) { |
| 878 | auto ssrcValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.ssrc)); |
| 879 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "ssrc" ), ssrcValue); |
| 880 | } |
| 881 | if (!IDLDOMString::isNullValue(dictionary.trackId)) { |
| 882 | auto trackIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.trackId)); |
| 883 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "trackId" ), trackIdValue); |
| 884 | } |
| 885 | if (!IDLDOMString::isNullValue(dictionary.transportId)) { |
| 886 | auto transportIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.transportId)); |
| 887 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "transportId" ), transportIdValue); |
| 888 | } |
| 889 | if (!IDLUnsignedLong::isNullValue(dictionary.burstDiscardCount)) { |
| 890 | auto burstDiscardCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.burstDiscardCount)); |
| 891 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "burstDiscardCount" ), burstDiscardCountValue); |
| 892 | } |
| 893 | if (!IDLDouble::isNullValue(dictionary.burstDiscardRate)) { |
| 894 | auto burstDiscardRateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.burstDiscardRate)); |
| 895 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "burstDiscardRate" ), burstDiscardRateValue); |
| 896 | } |
| 897 | if (!IDLUnsignedLong::isNullValue(dictionary.burstLossCount)) { |
| 898 | auto burstLossCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.burstLossCount)); |
| 899 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "burstLossCount" ), burstLossCountValue); |
| 900 | } |
| 901 | if (!IDLDouble::isNullValue(dictionary.burstLossRate)) { |
| 902 | auto burstLossRateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.burstLossRate)); |
| 903 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "burstLossRate" ), burstLossRateValue); |
| 904 | } |
| 905 | if (!IDLUnsignedLong::isNullValue(dictionary.burstPacketsDiscarded)) { |
| 906 | auto burstPacketsDiscardedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.burstPacketsDiscarded)); |
| 907 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "burstPacketsDiscarded" ), burstPacketsDiscardedValue); |
| 908 | } |
| 909 | if (!IDLUnsignedLong::isNullValue(dictionary.burstPacketsLost)) { |
| 910 | auto burstPacketsLostValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.burstPacketsLost)); |
| 911 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "burstPacketsLost" ), burstPacketsLostValue); |
| 912 | } |
| 913 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesReceived)) { |
| 914 | auto bytesReceivedValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesReceived)); |
| 915 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesReceived" ), bytesReceivedValue); |
| 916 | } |
| 917 | if (!IDLDouble::isNullValue(dictionary.fractionLost)) { |
| 918 | auto fractionLostValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.fractionLost)); |
| 919 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "fractionLost" ), fractionLostValue); |
| 920 | } |
| 921 | if (!IDLUnsignedLong::isNullValue(dictionary.framesDecoded)) { |
| 922 | auto framesDecodedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.framesDecoded)); |
| 923 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesDecoded" ), framesDecodedValue); |
| 924 | } |
| 925 | if (!IDLDouble::isNullValue(dictionary.gapDiscardRate)) { |
| 926 | auto gapDiscardRateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.gapDiscardRate)); |
| 927 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "gapDiscardRate" ), gapDiscardRateValue); |
| 928 | } |
| 929 | if (!IDLDouble::isNullValue(dictionary.gapLossRate)) { |
| 930 | auto gapLossRateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.gapLossRate)); |
| 931 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "gapLossRate" ), gapLossRateValue); |
| 932 | } |
| 933 | if (!IDLDouble::isNullValue(dictionary.jitter)) { |
| 934 | auto jitterValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.jitter)); |
| 935 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "jitter" ), jitterValue); |
| 936 | } |
| 937 | if (!IDLUnsignedLong::isNullValue(dictionary.packetsDiscarded)) { |
| 938 | auto packetsDiscardedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.packetsDiscarded)); |
| 939 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "packetsDiscarded" ), packetsDiscardedValue); |
| 940 | } |
| 941 | if (!IDLUnsignedLong::isNullValue(dictionary.packetsLost)) { |
| 942 | auto packetsLostValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.packetsLost)); |
| 943 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "packetsLost" ), packetsLostValue); |
| 944 | } |
| 945 | if (!IDLUnsignedLong::isNullValue(dictionary.packetsReceived)) { |
| 946 | auto packetsReceivedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.packetsReceived)); |
| 947 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "packetsReceived" ), packetsReceivedValue); |
| 948 | } |
| 949 | if (!IDLUnsignedLong::isNullValue(dictionary.packetsRepaired)) { |
| 950 | auto packetsRepairedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.packetsRepaired)); |
| 951 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "packetsRepaired" ), packetsRepairedValue); |
| 952 | } |
| 953 | return result; |
| 954 | } |
| 955 | |
| 956 | template<> RTCStatsReport::OutboundRTPStreamStats convertDictionary<RTCStatsReport::OutboundRTPStreamStats>(ExecState& state, JSValue value) |
| 957 | { |
| 958 | VM& vm = state.vm(); |
| 959 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 960 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 961 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 962 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 963 | throwTypeError(&state, throwScope); |
| 964 | return { }; |
| 965 | } |
| 966 | RTCStatsReport::OutboundRTPStreamStats result; |
| 967 | JSValue idValue; |
| 968 | if (isNullOrUndefined) |
| 969 | idValue = jsUndefined(); |
| 970 | else { |
| 971 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 972 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 973 | } |
| 974 | if (!idValue.isUndefined()) { |
| 975 | result.id = convert<IDLDOMString>(state, idValue); |
| 976 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 977 | } |
| 978 | JSValue timestampValue; |
| 979 | if (isNullOrUndefined) |
| 980 | timestampValue = jsUndefined(); |
| 981 | else { |
| 982 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 983 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 984 | } |
| 985 | if (!timestampValue.isUndefined()) { |
| 986 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 987 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 988 | } |
| 989 | JSValue typeValue; |
| 990 | if (isNullOrUndefined) |
| 991 | typeValue = jsUndefined(); |
| 992 | else { |
| 993 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 994 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 995 | } |
| 996 | if (!typeValue.isUndefined()) { |
| 997 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 998 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 999 | } |
| 1000 | JSValue associateStatsIdValue; |
| 1001 | if (isNullOrUndefined) |
| 1002 | associateStatsIdValue = jsUndefined(); |
| 1003 | else { |
| 1004 | associateStatsIdValue = object->get(&state, Identifier::fromString(&state, "associateStatsId" )); |
| 1005 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1006 | } |
| 1007 | if (!associateStatsIdValue.isUndefined()) { |
| 1008 | result.associateStatsId = convert<IDLDOMString>(state, associateStatsIdValue); |
| 1009 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1010 | } |
| 1011 | JSValue codecIdValue; |
| 1012 | if (isNullOrUndefined) |
| 1013 | codecIdValue = jsUndefined(); |
| 1014 | else { |
| 1015 | codecIdValue = object->get(&state, Identifier::fromString(&state, "codecId" )); |
| 1016 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1017 | } |
| 1018 | if (!codecIdValue.isUndefined()) { |
| 1019 | result.codecId = convert<IDLDOMString>(state, codecIdValue); |
| 1020 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1021 | } |
| 1022 | JSValue firCountValue; |
| 1023 | if (isNullOrUndefined) |
| 1024 | firCountValue = jsUndefined(); |
| 1025 | else { |
| 1026 | firCountValue = object->get(&state, Identifier::fromString(&state, "firCount" )); |
| 1027 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1028 | } |
| 1029 | if (!firCountValue.isUndefined()) { |
| 1030 | result.firCount = convert<IDLUnsignedLong>(state, firCountValue); |
| 1031 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1032 | } |
| 1033 | JSValue isRemoteValue; |
| 1034 | if (isNullOrUndefined) |
| 1035 | isRemoteValue = jsUndefined(); |
| 1036 | else { |
| 1037 | isRemoteValue = object->get(&state, Identifier::fromString(&state, "isRemote" )); |
| 1038 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1039 | } |
| 1040 | if (!isRemoteValue.isUndefined()) { |
| 1041 | result.isRemote = convert<IDLBoolean>(state, isRemoteValue); |
| 1042 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1043 | } else |
| 1044 | result.isRemote = false; |
| 1045 | JSValue mediaTypeValue; |
| 1046 | if (isNullOrUndefined) |
| 1047 | mediaTypeValue = jsUndefined(); |
| 1048 | else { |
| 1049 | mediaTypeValue = object->get(&state, Identifier::fromString(&state, "mediaType" )); |
| 1050 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1051 | } |
| 1052 | if (!mediaTypeValue.isUndefined()) { |
| 1053 | result.mediaType = convert<IDLDOMString>(state, mediaTypeValue); |
| 1054 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1055 | } |
| 1056 | JSValue nackCountValue; |
| 1057 | if (isNullOrUndefined) |
| 1058 | nackCountValue = jsUndefined(); |
| 1059 | else { |
| 1060 | nackCountValue = object->get(&state, Identifier::fromString(&state, "nackCount" )); |
| 1061 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1062 | } |
| 1063 | if (!nackCountValue.isUndefined()) { |
| 1064 | result.nackCount = convert<IDLUnsignedLong>(state, nackCountValue); |
| 1065 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1066 | } |
| 1067 | JSValue pliCountValue; |
| 1068 | if (isNullOrUndefined) |
| 1069 | pliCountValue = jsUndefined(); |
| 1070 | else { |
| 1071 | pliCountValue = object->get(&state, Identifier::fromString(&state, "pliCount" )); |
| 1072 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1073 | } |
| 1074 | if (!pliCountValue.isUndefined()) { |
| 1075 | result.pliCount = convert<IDLUnsignedLong>(state, pliCountValue); |
| 1076 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1077 | } |
| 1078 | JSValue qpSumValue; |
| 1079 | if (isNullOrUndefined) |
| 1080 | qpSumValue = jsUndefined(); |
| 1081 | else { |
| 1082 | qpSumValue = object->get(&state, Identifier::fromString(&state, "qpSum" )); |
| 1083 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1084 | } |
| 1085 | if (!qpSumValue.isUndefined()) { |
| 1086 | result.qpSum = convert<IDLUnsignedLongLong>(state, qpSumValue); |
| 1087 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1088 | } |
| 1089 | JSValue sliCountValue; |
| 1090 | if (isNullOrUndefined) |
| 1091 | sliCountValue = jsUndefined(); |
| 1092 | else { |
| 1093 | sliCountValue = object->get(&state, Identifier::fromString(&state, "sliCount" )); |
| 1094 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1095 | } |
| 1096 | if (!sliCountValue.isUndefined()) { |
| 1097 | result.sliCount = convert<IDLUnsignedLong>(state, sliCountValue); |
| 1098 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1099 | } |
| 1100 | JSValue ssrcValue; |
| 1101 | if (isNullOrUndefined) |
| 1102 | ssrcValue = jsUndefined(); |
| 1103 | else { |
| 1104 | ssrcValue = object->get(&state, Identifier::fromString(&state, "ssrc" )); |
| 1105 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1106 | } |
| 1107 | if (!ssrcValue.isUndefined()) { |
| 1108 | result.ssrc = convert<IDLUnsignedLong>(state, ssrcValue); |
| 1109 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1110 | } |
| 1111 | JSValue trackIdValue; |
| 1112 | if (isNullOrUndefined) |
| 1113 | trackIdValue = jsUndefined(); |
| 1114 | else { |
| 1115 | trackIdValue = object->get(&state, Identifier::fromString(&state, "trackId" )); |
| 1116 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1117 | } |
| 1118 | if (!trackIdValue.isUndefined()) { |
| 1119 | result.trackId = convert<IDLDOMString>(state, trackIdValue); |
| 1120 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1121 | } |
| 1122 | JSValue transportIdValue; |
| 1123 | if (isNullOrUndefined) |
| 1124 | transportIdValue = jsUndefined(); |
| 1125 | else { |
| 1126 | transportIdValue = object->get(&state, Identifier::fromString(&state, "transportId" )); |
| 1127 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1128 | } |
| 1129 | if (!transportIdValue.isUndefined()) { |
| 1130 | result.transportId = convert<IDLDOMString>(state, transportIdValue); |
| 1131 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1132 | } |
| 1133 | JSValue bytesSentValue; |
| 1134 | if (isNullOrUndefined) |
| 1135 | bytesSentValue = jsUndefined(); |
| 1136 | else { |
| 1137 | bytesSentValue = object->get(&state, Identifier::fromString(&state, "bytesSent" )); |
| 1138 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1139 | } |
| 1140 | if (!bytesSentValue.isUndefined()) { |
| 1141 | result.bytesSent = convert<IDLUnsignedLongLong>(state, bytesSentValue); |
| 1142 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1143 | } |
| 1144 | JSValue framesEncodedValue; |
| 1145 | if (isNullOrUndefined) |
| 1146 | framesEncodedValue = jsUndefined(); |
| 1147 | else { |
| 1148 | framesEncodedValue = object->get(&state, Identifier::fromString(&state, "framesEncoded" )); |
| 1149 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1150 | } |
| 1151 | if (!framesEncodedValue.isUndefined()) { |
| 1152 | result.framesEncoded = convert<IDLUnsignedLong>(state, framesEncodedValue); |
| 1153 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1154 | } |
| 1155 | JSValue packetsSentValue; |
| 1156 | if (isNullOrUndefined) |
| 1157 | packetsSentValue = jsUndefined(); |
| 1158 | else { |
| 1159 | packetsSentValue = object->get(&state, Identifier::fromString(&state, "packetsSent" )); |
| 1160 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1161 | } |
| 1162 | if (!packetsSentValue.isUndefined()) { |
| 1163 | result.packetsSent = convert<IDLUnsignedLong>(state, packetsSentValue); |
| 1164 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1165 | } |
| 1166 | JSValue targetBitrateValue; |
| 1167 | if (isNullOrUndefined) |
| 1168 | targetBitrateValue = jsUndefined(); |
| 1169 | else { |
| 1170 | targetBitrateValue = object->get(&state, Identifier::fromString(&state, "targetBitrate" )); |
| 1171 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1172 | } |
| 1173 | if (!targetBitrateValue.isUndefined()) { |
| 1174 | result.targetBitrate = convert<IDLDouble>(state, targetBitrateValue); |
| 1175 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1176 | } |
| 1177 | return result; |
| 1178 | } |
| 1179 | |
| 1180 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::OutboundRTPStreamStats& dictionary) |
| 1181 | { |
| 1182 | auto& vm = state.vm(); |
| 1183 | |
| 1184 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 1185 | |
| 1186 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 1187 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 1188 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 1189 | } |
| 1190 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 1191 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 1192 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 1193 | } |
| 1194 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 1195 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 1196 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 1197 | } |
| 1198 | if (!IDLDOMString::isNullValue(dictionary.associateStatsId)) { |
| 1199 | auto associateStatsIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.associateStatsId)); |
| 1200 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "associateStatsId" ), associateStatsIdValue); |
| 1201 | } |
| 1202 | if (!IDLDOMString::isNullValue(dictionary.codecId)) { |
| 1203 | auto codecIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.codecId)); |
| 1204 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "codecId" ), codecIdValue); |
| 1205 | } |
| 1206 | if (!IDLUnsignedLong::isNullValue(dictionary.firCount)) { |
| 1207 | auto firCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.firCount)); |
| 1208 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "firCount" ), firCountValue); |
| 1209 | } |
| 1210 | auto isRemoteValue = toJS<IDLBoolean>(dictionary.isRemote); |
| 1211 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "isRemote" ), isRemoteValue); |
| 1212 | if (!IDLDOMString::isNullValue(dictionary.mediaType)) { |
| 1213 | auto mediaTypeValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.mediaType)); |
| 1214 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "mediaType" ), mediaTypeValue); |
| 1215 | } |
| 1216 | if (!IDLUnsignedLong::isNullValue(dictionary.nackCount)) { |
| 1217 | auto nackCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.nackCount)); |
| 1218 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "nackCount" ), nackCountValue); |
| 1219 | } |
| 1220 | if (!IDLUnsignedLong::isNullValue(dictionary.pliCount)) { |
| 1221 | auto pliCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.pliCount)); |
| 1222 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "pliCount" ), pliCountValue); |
| 1223 | } |
| 1224 | if (!IDLUnsignedLongLong::isNullValue(dictionary.qpSum)) { |
| 1225 | auto qpSumValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.qpSum)); |
| 1226 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "qpSum" ), qpSumValue); |
| 1227 | } |
| 1228 | if (!IDLUnsignedLong::isNullValue(dictionary.sliCount)) { |
| 1229 | auto sliCountValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.sliCount)); |
| 1230 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "sliCount" ), sliCountValue); |
| 1231 | } |
| 1232 | if (!IDLUnsignedLong::isNullValue(dictionary.ssrc)) { |
| 1233 | auto ssrcValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.ssrc)); |
| 1234 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "ssrc" ), ssrcValue); |
| 1235 | } |
| 1236 | if (!IDLDOMString::isNullValue(dictionary.trackId)) { |
| 1237 | auto trackIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.trackId)); |
| 1238 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "trackId" ), trackIdValue); |
| 1239 | } |
| 1240 | if (!IDLDOMString::isNullValue(dictionary.transportId)) { |
| 1241 | auto transportIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.transportId)); |
| 1242 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "transportId" ), transportIdValue); |
| 1243 | } |
| 1244 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesSent)) { |
| 1245 | auto bytesSentValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesSent)); |
| 1246 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesSent" ), bytesSentValue); |
| 1247 | } |
| 1248 | if (!IDLUnsignedLong::isNullValue(dictionary.framesEncoded)) { |
| 1249 | auto framesEncodedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.framesEncoded)); |
| 1250 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesEncoded" ), framesEncodedValue); |
| 1251 | } |
| 1252 | if (!IDLUnsignedLong::isNullValue(dictionary.packetsSent)) { |
| 1253 | auto packetsSentValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.packetsSent)); |
| 1254 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "packetsSent" ), packetsSentValue); |
| 1255 | } |
| 1256 | if (!IDLDouble::isNullValue(dictionary.targetBitrate)) { |
| 1257 | auto targetBitrateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.targetBitrate)); |
| 1258 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "targetBitrate" ), targetBitrateValue); |
| 1259 | } |
| 1260 | return result; |
| 1261 | } |
| 1262 | |
| 1263 | template<> RTCStatsReport::MediaStreamTrackStats convertDictionary<RTCStatsReport::MediaStreamTrackStats>(ExecState& state, JSValue value) |
| 1264 | { |
| 1265 | VM& vm = state.vm(); |
| 1266 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 1267 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 1268 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 1269 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 1270 | throwTypeError(&state, throwScope); |
| 1271 | return { }; |
| 1272 | } |
| 1273 | RTCStatsReport::MediaStreamTrackStats result; |
| 1274 | JSValue idValue; |
| 1275 | if (isNullOrUndefined) |
| 1276 | idValue = jsUndefined(); |
| 1277 | else { |
| 1278 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 1279 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1280 | } |
| 1281 | if (!idValue.isUndefined()) { |
| 1282 | result.id = convert<IDLDOMString>(state, idValue); |
| 1283 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1284 | } |
| 1285 | JSValue timestampValue; |
| 1286 | if (isNullOrUndefined) |
| 1287 | timestampValue = jsUndefined(); |
| 1288 | else { |
| 1289 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 1290 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1291 | } |
| 1292 | if (!timestampValue.isUndefined()) { |
| 1293 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 1294 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1295 | } |
| 1296 | JSValue typeValue; |
| 1297 | if (isNullOrUndefined) |
| 1298 | typeValue = jsUndefined(); |
| 1299 | else { |
| 1300 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 1301 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1302 | } |
| 1303 | if (!typeValue.isUndefined()) { |
| 1304 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 1305 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1306 | } |
| 1307 | JSValue audioLevelValue; |
| 1308 | if (isNullOrUndefined) |
| 1309 | audioLevelValue = jsUndefined(); |
| 1310 | else { |
| 1311 | audioLevelValue = object->get(&state, Identifier::fromString(&state, "audioLevel" )); |
| 1312 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1313 | } |
| 1314 | if (!audioLevelValue.isUndefined()) { |
| 1315 | result.audioLevel = convert<IDLDouble>(state, audioLevelValue); |
| 1316 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1317 | } |
| 1318 | JSValue detachedValue; |
| 1319 | if (isNullOrUndefined) |
| 1320 | detachedValue = jsUndefined(); |
| 1321 | else { |
| 1322 | detachedValue = object->get(&state, Identifier::fromString(&state, "detached" )); |
| 1323 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1324 | } |
| 1325 | if (!detachedValue.isUndefined()) { |
| 1326 | result.detached = convert<IDLBoolean>(state, detachedValue); |
| 1327 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1328 | } |
| 1329 | JSValue echoReturnLossValue; |
| 1330 | if (isNullOrUndefined) |
| 1331 | echoReturnLossValue = jsUndefined(); |
| 1332 | else { |
| 1333 | echoReturnLossValue = object->get(&state, Identifier::fromString(&state, "echoReturnLoss" )); |
| 1334 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1335 | } |
| 1336 | if (!echoReturnLossValue.isUndefined()) { |
| 1337 | result.echoReturnLoss = convert<IDLDouble>(state, echoReturnLossValue); |
| 1338 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1339 | } |
| 1340 | JSValue echoReturnLossEnhancementValue; |
| 1341 | if (isNullOrUndefined) |
| 1342 | echoReturnLossEnhancementValue = jsUndefined(); |
| 1343 | else { |
| 1344 | echoReturnLossEnhancementValue = object->get(&state, Identifier::fromString(&state, "echoReturnLossEnhancement" )); |
| 1345 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1346 | } |
| 1347 | if (!echoReturnLossEnhancementValue.isUndefined()) { |
| 1348 | result.echoReturnLossEnhancement = convert<IDLDouble>(state, echoReturnLossEnhancementValue); |
| 1349 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1350 | } |
| 1351 | JSValue endedValue; |
| 1352 | if (isNullOrUndefined) |
| 1353 | endedValue = jsUndefined(); |
| 1354 | else { |
| 1355 | endedValue = object->get(&state, Identifier::fromString(&state, "ended" )); |
| 1356 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1357 | } |
| 1358 | if (!endedValue.isUndefined()) { |
| 1359 | result.ended = convert<IDLBoolean>(state, endedValue); |
| 1360 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1361 | } |
| 1362 | JSValue frameHeightValue; |
| 1363 | if (isNullOrUndefined) |
| 1364 | frameHeightValue = jsUndefined(); |
| 1365 | else { |
| 1366 | frameHeightValue = object->get(&state, Identifier::fromString(&state, "frameHeight" )); |
| 1367 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1368 | } |
| 1369 | if (!frameHeightValue.isUndefined()) { |
| 1370 | result.frameHeight = convert<IDLUnsignedLong>(state, frameHeightValue); |
| 1371 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1372 | } |
| 1373 | JSValue frameWidthValue; |
| 1374 | if (isNullOrUndefined) |
| 1375 | frameWidthValue = jsUndefined(); |
| 1376 | else { |
| 1377 | frameWidthValue = object->get(&state, Identifier::fromString(&state, "frameWidth" )); |
| 1378 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1379 | } |
| 1380 | if (!frameWidthValue.isUndefined()) { |
| 1381 | result.frameWidth = convert<IDLUnsignedLong>(state, frameWidthValue); |
| 1382 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1383 | } |
| 1384 | JSValue framesCorruptedValue; |
| 1385 | if (isNullOrUndefined) |
| 1386 | framesCorruptedValue = jsUndefined(); |
| 1387 | else { |
| 1388 | framesCorruptedValue = object->get(&state, Identifier::fromString(&state, "framesCorrupted" )); |
| 1389 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1390 | } |
| 1391 | if (!framesCorruptedValue.isUndefined()) { |
| 1392 | result.framesCorrupted = convert<IDLUnsignedLong>(state, framesCorruptedValue); |
| 1393 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1394 | } |
| 1395 | JSValue framesDecodedValue; |
| 1396 | if (isNullOrUndefined) |
| 1397 | framesDecodedValue = jsUndefined(); |
| 1398 | else { |
| 1399 | framesDecodedValue = object->get(&state, Identifier::fromString(&state, "framesDecoded" )); |
| 1400 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1401 | } |
| 1402 | if (!framesDecodedValue.isUndefined()) { |
| 1403 | result.framesDecoded = convert<IDLUnsignedLong>(state, framesDecodedValue); |
| 1404 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1405 | } |
| 1406 | JSValue framesDroppedValue; |
| 1407 | if (isNullOrUndefined) |
| 1408 | framesDroppedValue = jsUndefined(); |
| 1409 | else { |
| 1410 | framesDroppedValue = object->get(&state, Identifier::fromString(&state, "framesDropped" )); |
| 1411 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1412 | } |
| 1413 | if (!framesDroppedValue.isUndefined()) { |
| 1414 | result.framesDropped = convert<IDLUnsignedLong>(state, framesDroppedValue); |
| 1415 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1416 | } |
| 1417 | JSValue framesPerSecondValue; |
| 1418 | if (isNullOrUndefined) |
| 1419 | framesPerSecondValue = jsUndefined(); |
| 1420 | else { |
| 1421 | framesPerSecondValue = object->get(&state, Identifier::fromString(&state, "framesPerSecond" )); |
| 1422 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1423 | } |
| 1424 | if (!framesPerSecondValue.isUndefined()) { |
| 1425 | result.framesPerSecond = convert<IDLDouble>(state, framesPerSecondValue); |
| 1426 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1427 | } |
| 1428 | JSValue framesReceivedValue; |
| 1429 | if (isNullOrUndefined) |
| 1430 | framesReceivedValue = jsUndefined(); |
| 1431 | else { |
| 1432 | framesReceivedValue = object->get(&state, Identifier::fromString(&state, "framesReceived" )); |
| 1433 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1434 | } |
| 1435 | if (!framesReceivedValue.isUndefined()) { |
| 1436 | result.framesReceived = convert<IDLUnsignedLong>(state, framesReceivedValue); |
| 1437 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1438 | } |
| 1439 | JSValue framesSentValue; |
| 1440 | if (isNullOrUndefined) |
| 1441 | framesSentValue = jsUndefined(); |
| 1442 | else { |
| 1443 | framesSentValue = object->get(&state, Identifier::fromString(&state, "framesSent" )); |
| 1444 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1445 | } |
| 1446 | if (!framesSentValue.isUndefined()) { |
| 1447 | result.framesSent = convert<IDLUnsignedLong>(state, framesSentValue); |
| 1448 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1449 | } |
| 1450 | JSValue fullFramesLostValue; |
| 1451 | if (isNullOrUndefined) |
| 1452 | fullFramesLostValue = jsUndefined(); |
| 1453 | else { |
| 1454 | fullFramesLostValue = object->get(&state, Identifier::fromString(&state, "fullFramesLost" )); |
| 1455 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1456 | } |
| 1457 | if (!fullFramesLostValue.isUndefined()) { |
| 1458 | result.fullFramesLost = convert<IDLUnsignedLong>(state, fullFramesLostValue); |
| 1459 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1460 | } |
| 1461 | JSValue partialFramesLostValue; |
| 1462 | if (isNullOrUndefined) |
| 1463 | partialFramesLostValue = jsUndefined(); |
| 1464 | else { |
| 1465 | partialFramesLostValue = object->get(&state, Identifier::fromString(&state, "partialFramesLost" )); |
| 1466 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1467 | } |
| 1468 | if (!partialFramesLostValue.isUndefined()) { |
| 1469 | result.partialFramesLost = convert<IDLUnsignedLong>(state, partialFramesLostValue); |
| 1470 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1471 | } |
| 1472 | JSValue remoteSourceValue; |
| 1473 | if (isNullOrUndefined) |
| 1474 | remoteSourceValue = jsUndefined(); |
| 1475 | else { |
| 1476 | remoteSourceValue = object->get(&state, Identifier::fromString(&state, "remoteSource" )); |
| 1477 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1478 | } |
| 1479 | if (!remoteSourceValue.isUndefined()) { |
| 1480 | result.remoteSource = convert<IDLBoolean>(state, remoteSourceValue); |
| 1481 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1482 | } |
| 1483 | JSValue trackIdentifierValue; |
| 1484 | if (isNullOrUndefined) |
| 1485 | trackIdentifierValue = jsUndefined(); |
| 1486 | else { |
| 1487 | trackIdentifierValue = object->get(&state, Identifier::fromString(&state, "trackIdentifier" )); |
| 1488 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1489 | } |
| 1490 | if (!trackIdentifierValue.isUndefined()) { |
| 1491 | result.trackIdentifier = convert<IDLDOMString>(state, trackIdentifierValue); |
| 1492 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1493 | } |
| 1494 | return result; |
| 1495 | } |
| 1496 | |
| 1497 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::MediaStreamTrackStats& dictionary) |
| 1498 | { |
| 1499 | auto& vm = state.vm(); |
| 1500 | |
| 1501 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 1502 | |
| 1503 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 1504 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 1505 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 1506 | } |
| 1507 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 1508 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 1509 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 1510 | } |
| 1511 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 1512 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 1513 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 1514 | } |
| 1515 | if (!IDLDouble::isNullValue(dictionary.audioLevel)) { |
| 1516 | auto audioLevelValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.audioLevel)); |
| 1517 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "audioLevel" ), audioLevelValue); |
| 1518 | } |
| 1519 | if (!IDLBoolean::isNullValue(dictionary.detached)) { |
| 1520 | auto detachedValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.detached)); |
| 1521 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "detached" ), detachedValue); |
| 1522 | } |
| 1523 | if (!IDLDouble::isNullValue(dictionary.echoReturnLoss)) { |
| 1524 | auto echoReturnLossValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.echoReturnLoss)); |
| 1525 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "echoReturnLoss" ), echoReturnLossValue); |
| 1526 | } |
| 1527 | if (!IDLDouble::isNullValue(dictionary.echoReturnLossEnhancement)) { |
| 1528 | auto echoReturnLossEnhancementValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.echoReturnLossEnhancement)); |
| 1529 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "echoReturnLossEnhancement" ), echoReturnLossEnhancementValue); |
| 1530 | } |
| 1531 | if (!IDLBoolean::isNullValue(dictionary.ended)) { |
| 1532 | auto endedValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.ended)); |
| 1533 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "ended" ), endedValue); |
| 1534 | } |
| 1535 | if (!IDLUnsignedLong::isNullValue(dictionary.frameHeight)) { |
| 1536 | auto frameHeightValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.frameHeight)); |
| 1537 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "frameHeight" ), frameHeightValue); |
| 1538 | } |
| 1539 | if (!IDLUnsignedLong::isNullValue(dictionary.frameWidth)) { |
| 1540 | auto frameWidthValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.frameWidth)); |
| 1541 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "frameWidth" ), frameWidthValue); |
| 1542 | } |
| 1543 | if (!IDLUnsignedLong::isNullValue(dictionary.framesCorrupted)) { |
| 1544 | auto framesCorruptedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.framesCorrupted)); |
| 1545 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesCorrupted" ), framesCorruptedValue); |
| 1546 | } |
| 1547 | if (!IDLUnsignedLong::isNullValue(dictionary.framesDecoded)) { |
| 1548 | auto framesDecodedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.framesDecoded)); |
| 1549 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesDecoded" ), framesDecodedValue); |
| 1550 | } |
| 1551 | if (!IDLUnsignedLong::isNullValue(dictionary.framesDropped)) { |
| 1552 | auto framesDroppedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.framesDropped)); |
| 1553 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesDropped" ), framesDroppedValue); |
| 1554 | } |
| 1555 | if (!IDLDouble::isNullValue(dictionary.framesPerSecond)) { |
| 1556 | auto framesPerSecondValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.framesPerSecond)); |
| 1557 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesPerSecond" ), framesPerSecondValue); |
| 1558 | } |
| 1559 | if (!IDLUnsignedLong::isNullValue(dictionary.framesReceived)) { |
| 1560 | auto framesReceivedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.framesReceived)); |
| 1561 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesReceived" ), framesReceivedValue); |
| 1562 | } |
| 1563 | if (!IDLUnsignedLong::isNullValue(dictionary.framesSent)) { |
| 1564 | auto framesSentValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.framesSent)); |
| 1565 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "framesSent" ), framesSentValue); |
| 1566 | } |
| 1567 | if (!IDLUnsignedLong::isNullValue(dictionary.fullFramesLost)) { |
| 1568 | auto fullFramesLostValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.fullFramesLost)); |
| 1569 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "fullFramesLost" ), fullFramesLostValue); |
| 1570 | } |
| 1571 | if (!IDLUnsignedLong::isNullValue(dictionary.partialFramesLost)) { |
| 1572 | auto partialFramesLostValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.partialFramesLost)); |
| 1573 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "partialFramesLost" ), partialFramesLostValue); |
| 1574 | } |
| 1575 | if (!IDLBoolean::isNullValue(dictionary.remoteSource)) { |
| 1576 | auto remoteSourceValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.remoteSource)); |
| 1577 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "remoteSource" ), remoteSourceValue); |
| 1578 | } |
| 1579 | if (!IDLDOMString::isNullValue(dictionary.trackIdentifier)) { |
| 1580 | auto trackIdentifierValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.trackIdentifier)); |
| 1581 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "trackIdentifier" ), trackIdentifierValue); |
| 1582 | } |
| 1583 | return result; |
| 1584 | } |
| 1585 | |
| 1586 | template<> RTCStatsReport::DataChannelStats convertDictionary<RTCStatsReport::DataChannelStats>(ExecState& state, JSValue value) |
| 1587 | { |
| 1588 | VM& vm = state.vm(); |
| 1589 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 1590 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 1591 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 1592 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 1593 | throwTypeError(&state, throwScope); |
| 1594 | return { }; |
| 1595 | } |
| 1596 | RTCStatsReport::DataChannelStats result; |
| 1597 | JSValue idValue; |
| 1598 | if (isNullOrUndefined) |
| 1599 | idValue = jsUndefined(); |
| 1600 | else { |
| 1601 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 1602 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1603 | } |
| 1604 | if (!idValue.isUndefined()) { |
| 1605 | result.id = convert<IDLDOMString>(state, idValue); |
| 1606 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1607 | } |
| 1608 | JSValue timestampValue; |
| 1609 | if (isNullOrUndefined) |
| 1610 | timestampValue = jsUndefined(); |
| 1611 | else { |
| 1612 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 1613 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1614 | } |
| 1615 | if (!timestampValue.isUndefined()) { |
| 1616 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 1617 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1618 | } |
| 1619 | JSValue typeValue; |
| 1620 | if (isNullOrUndefined) |
| 1621 | typeValue = jsUndefined(); |
| 1622 | else { |
| 1623 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 1624 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1625 | } |
| 1626 | if (!typeValue.isUndefined()) { |
| 1627 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 1628 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1629 | } |
| 1630 | JSValue bytesReceivedValue; |
| 1631 | if (isNullOrUndefined) |
| 1632 | bytesReceivedValue = jsUndefined(); |
| 1633 | else { |
| 1634 | bytesReceivedValue = object->get(&state, Identifier::fromString(&state, "bytesReceived" )); |
| 1635 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1636 | } |
| 1637 | if (!bytesReceivedValue.isUndefined()) { |
| 1638 | result.bytesReceived = convert<IDLUnsignedLongLong>(state, bytesReceivedValue); |
| 1639 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1640 | } |
| 1641 | JSValue bytesSentValue; |
| 1642 | if (isNullOrUndefined) |
| 1643 | bytesSentValue = jsUndefined(); |
| 1644 | else { |
| 1645 | bytesSentValue = object->get(&state, Identifier::fromString(&state, "bytesSent" )); |
| 1646 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1647 | } |
| 1648 | if (!bytesSentValue.isUndefined()) { |
| 1649 | result.bytesSent = convert<IDLUnsignedLongLong>(state, bytesSentValue); |
| 1650 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1651 | } |
| 1652 | JSValue datachannelidValue; |
| 1653 | if (isNullOrUndefined) |
| 1654 | datachannelidValue = jsUndefined(); |
| 1655 | else { |
| 1656 | datachannelidValue = object->get(&state, Identifier::fromString(&state, "datachannelid" )); |
| 1657 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1658 | } |
| 1659 | if (!datachannelidValue.isUndefined()) { |
| 1660 | result.datachannelid = convert<IDLLong>(state, datachannelidValue); |
| 1661 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1662 | } |
| 1663 | JSValue labelValue; |
| 1664 | if (isNullOrUndefined) |
| 1665 | labelValue = jsUndefined(); |
| 1666 | else { |
| 1667 | labelValue = object->get(&state, Identifier::fromString(&state, "label" )); |
| 1668 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1669 | } |
| 1670 | if (!labelValue.isUndefined()) { |
| 1671 | result.label = convert<IDLDOMString>(state, labelValue); |
| 1672 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1673 | } |
| 1674 | JSValue messagesReceivedValue; |
| 1675 | if (isNullOrUndefined) |
| 1676 | messagesReceivedValue = jsUndefined(); |
| 1677 | else { |
| 1678 | messagesReceivedValue = object->get(&state, Identifier::fromString(&state, "messagesReceived" )); |
| 1679 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1680 | } |
| 1681 | if (!messagesReceivedValue.isUndefined()) { |
| 1682 | result.messagesReceived = convert<IDLUnsignedLong>(state, messagesReceivedValue); |
| 1683 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1684 | } |
| 1685 | JSValue messagesSentValue; |
| 1686 | if (isNullOrUndefined) |
| 1687 | messagesSentValue = jsUndefined(); |
| 1688 | else { |
| 1689 | messagesSentValue = object->get(&state, Identifier::fromString(&state, "messagesSent" )); |
| 1690 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1691 | } |
| 1692 | if (!messagesSentValue.isUndefined()) { |
| 1693 | result.messagesSent = convert<IDLUnsignedLong>(state, messagesSentValue); |
| 1694 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1695 | } |
| 1696 | JSValue protocolValue; |
| 1697 | if (isNullOrUndefined) |
| 1698 | protocolValue = jsUndefined(); |
| 1699 | else { |
| 1700 | protocolValue = object->get(&state, Identifier::fromString(&state, "protocol" )); |
| 1701 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1702 | } |
| 1703 | if (!protocolValue.isUndefined()) { |
| 1704 | result.protocol = convert<IDLDOMString>(state, protocolValue); |
| 1705 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1706 | } |
| 1707 | JSValue stateValue; |
| 1708 | if (isNullOrUndefined) |
| 1709 | stateValue = jsUndefined(); |
| 1710 | else { |
| 1711 | stateValue = object->get(&state, Identifier::fromString(&state, "state" )); |
| 1712 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1713 | } |
| 1714 | if (!stateValue.isUndefined()) { |
| 1715 | result.state = convert<IDLDOMString>(state, stateValue); |
| 1716 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1717 | } |
| 1718 | return result; |
| 1719 | } |
| 1720 | |
| 1721 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::DataChannelStats& dictionary) |
| 1722 | { |
| 1723 | auto& vm = state.vm(); |
| 1724 | |
| 1725 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 1726 | |
| 1727 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 1728 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 1729 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 1730 | } |
| 1731 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 1732 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 1733 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 1734 | } |
| 1735 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 1736 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 1737 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 1738 | } |
| 1739 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesReceived)) { |
| 1740 | auto bytesReceivedValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesReceived)); |
| 1741 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesReceived" ), bytesReceivedValue); |
| 1742 | } |
| 1743 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesSent)) { |
| 1744 | auto bytesSentValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesSent)); |
| 1745 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesSent" ), bytesSentValue); |
| 1746 | } |
| 1747 | if (!IDLLong::isNullValue(dictionary.datachannelid)) { |
| 1748 | auto datachannelidValue = toJS<IDLLong>(IDLLong::extractValueFromNullable(dictionary.datachannelid)); |
| 1749 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "datachannelid" ), datachannelidValue); |
| 1750 | } |
| 1751 | if (!IDLDOMString::isNullValue(dictionary.label)) { |
| 1752 | auto labelValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.label)); |
| 1753 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "label" ), labelValue); |
| 1754 | } |
| 1755 | if (!IDLUnsignedLong::isNullValue(dictionary.messagesReceived)) { |
| 1756 | auto messagesReceivedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.messagesReceived)); |
| 1757 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "messagesReceived" ), messagesReceivedValue); |
| 1758 | } |
| 1759 | if (!IDLUnsignedLong::isNullValue(dictionary.messagesSent)) { |
| 1760 | auto messagesSentValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.messagesSent)); |
| 1761 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "messagesSent" ), messagesSentValue); |
| 1762 | } |
| 1763 | if (!IDLDOMString::isNullValue(dictionary.protocol)) { |
| 1764 | auto protocolValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.protocol)); |
| 1765 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "protocol" ), protocolValue); |
| 1766 | } |
| 1767 | if (!IDLDOMString::isNullValue(dictionary.state)) { |
| 1768 | auto stateValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.state)); |
| 1769 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "state" ), stateValue); |
| 1770 | } |
| 1771 | return result; |
| 1772 | } |
| 1773 | |
| 1774 | template<> RTCStatsReport::IceCandidatePairStats convertDictionary<RTCStatsReport::IceCandidatePairStats>(ExecState& state, JSValue value) |
| 1775 | { |
| 1776 | VM& vm = state.vm(); |
| 1777 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 1778 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 1779 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 1780 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 1781 | throwTypeError(&state, throwScope); |
| 1782 | return { }; |
| 1783 | } |
| 1784 | RTCStatsReport::IceCandidatePairStats result; |
| 1785 | JSValue idValue; |
| 1786 | if (isNullOrUndefined) |
| 1787 | idValue = jsUndefined(); |
| 1788 | else { |
| 1789 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 1790 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1791 | } |
| 1792 | if (!idValue.isUndefined()) { |
| 1793 | result.id = convert<IDLDOMString>(state, idValue); |
| 1794 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1795 | } |
| 1796 | JSValue timestampValue; |
| 1797 | if (isNullOrUndefined) |
| 1798 | timestampValue = jsUndefined(); |
| 1799 | else { |
| 1800 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 1801 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1802 | } |
| 1803 | if (!timestampValue.isUndefined()) { |
| 1804 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 1805 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1806 | } |
| 1807 | JSValue typeValue; |
| 1808 | if (isNullOrUndefined) |
| 1809 | typeValue = jsUndefined(); |
| 1810 | else { |
| 1811 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 1812 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1813 | } |
| 1814 | if (!typeValue.isUndefined()) { |
| 1815 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 1816 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1817 | } |
| 1818 | JSValue availableIncomingBitrateValue; |
| 1819 | if (isNullOrUndefined) |
| 1820 | availableIncomingBitrateValue = jsUndefined(); |
| 1821 | else { |
| 1822 | availableIncomingBitrateValue = object->get(&state, Identifier::fromString(&state, "availableIncomingBitrate" )); |
| 1823 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1824 | } |
| 1825 | if (!availableIncomingBitrateValue.isUndefined()) { |
| 1826 | result.availableIncomingBitrate = convert<IDLDouble>(state, availableIncomingBitrateValue); |
| 1827 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1828 | } |
| 1829 | JSValue availableOutgoingBitrateValue; |
| 1830 | if (isNullOrUndefined) |
| 1831 | availableOutgoingBitrateValue = jsUndefined(); |
| 1832 | else { |
| 1833 | availableOutgoingBitrateValue = object->get(&state, Identifier::fromString(&state, "availableOutgoingBitrate" )); |
| 1834 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1835 | } |
| 1836 | if (!availableOutgoingBitrateValue.isUndefined()) { |
| 1837 | result.availableOutgoingBitrate = convert<IDLDouble>(state, availableOutgoingBitrateValue); |
| 1838 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1839 | } |
| 1840 | JSValue bytesReceivedValue; |
| 1841 | if (isNullOrUndefined) |
| 1842 | bytesReceivedValue = jsUndefined(); |
| 1843 | else { |
| 1844 | bytesReceivedValue = object->get(&state, Identifier::fromString(&state, "bytesReceived" )); |
| 1845 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1846 | } |
| 1847 | if (!bytesReceivedValue.isUndefined()) { |
| 1848 | result.bytesReceived = convert<IDLUnsignedLongLong>(state, bytesReceivedValue); |
| 1849 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1850 | } |
| 1851 | JSValue bytesSentValue; |
| 1852 | if (isNullOrUndefined) |
| 1853 | bytesSentValue = jsUndefined(); |
| 1854 | else { |
| 1855 | bytesSentValue = object->get(&state, Identifier::fromString(&state, "bytesSent" )); |
| 1856 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1857 | } |
| 1858 | if (!bytesSentValue.isUndefined()) { |
| 1859 | result.bytesSent = convert<IDLUnsignedLongLong>(state, bytesSentValue); |
| 1860 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1861 | } |
| 1862 | JSValue currentRoundTripTimeValue; |
| 1863 | if (isNullOrUndefined) |
| 1864 | currentRoundTripTimeValue = jsUndefined(); |
| 1865 | else { |
| 1866 | currentRoundTripTimeValue = object->get(&state, Identifier::fromString(&state, "currentRoundTripTime" )); |
| 1867 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1868 | } |
| 1869 | if (!currentRoundTripTimeValue.isUndefined()) { |
| 1870 | result.currentRoundTripTime = convert<IDLDouble>(state, currentRoundTripTimeValue); |
| 1871 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1872 | } |
| 1873 | JSValue localCandidateIdValue; |
| 1874 | if (isNullOrUndefined) |
| 1875 | localCandidateIdValue = jsUndefined(); |
| 1876 | else { |
| 1877 | localCandidateIdValue = object->get(&state, Identifier::fromString(&state, "localCandidateId" )); |
| 1878 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1879 | } |
| 1880 | if (!localCandidateIdValue.isUndefined()) { |
| 1881 | result.localCandidateId = convert<IDLDOMString>(state, localCandidateIdValue); |
| 1882 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1883 | } |
| 1884 | JSValue nominatedValue; |
| 1885 | if (isNullOrUndefined) |
| 1886 | nominatedValue = jsUndefined(); |
| 1887 | else { |
| 1888 | nominatedValue = object->get(&state, Identifier::fromString(&state, "nominated" )); |
| 1889 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1890 | } |
| 1891 | if (!nominatedValue.isUndefined()) { |
| 1892 | result.nominated = convert<IDLBoolean>(state, nominatedValue); |
| 1893 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1894 | } |
| 1895 | JSValue priorityValue; |
| 1896 | if (isNullOrUndefined) |
| 1897 | priorityValue = jsUndefined(); |
| 1898 | else { |
| 1899 | priorityValue = object->get(&state, Identifier::fromString(&state, "priority" )); |
| 1900 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1901 | } |
| 1902 | if (!priorityValue.isUndefined()) { |
| 1903 | result.priority = convert<IDLUnsignedLongLong>(state, priorityValue); |
| 1904 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1905 | } |
| 1906 | JSValue readableValue; |
| 1907 | if (isNullOrUndefined) |
| 1908 | readableValue = jsUndefined(); |
| 1909 | else { |
| 1910 | readableValue = object->get(&state, Identifier::fromString(&state, "readable" )); |
| 1911 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1912 | } |
| 1913 | if (!readableValue.isUndefined()) { |
| 1914 | result.readable = convert<IDLBoolean>(state, readableValue); |
| 1915 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1916 | } |
| 1917 | JSValue remoteCandidateIdValue; |
| 1918 | if (isNullOrUndefined) |
| 1919 | remoteCandidateIdValue = jsUndefined(); |
| 1920 | else { |
| 1921 | remoteCandidateIdValue = object->get(&state, Identifier::fromString(&state, "remoteCandidateId" )); |
| 1922 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1923 | } |
| 1924 | if (!remoteCandidateIdValue.isUndefined()) { |
| 1925 | result.remoteCandidateId = convert<IDLDOMString>(state, remoteCandidateIdValue); |
| 1926 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1927 | } |
| 1928 | JSValue requestsReceivedValue; |
| 1929 | if (isNullOrUndefined) |
| 1930 | requestsReceivedValue = jsUndefined(); |
| 1931 | else { |
| 1932 | requestsReceivedValue = object->get(&state, Identifier::fromString(&state, "requestsReceived" )); |
| 1933 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1934 | } |
| 1935 | if (!requestsReceivedValue.isUndefined()) { |
| 1936 | result.requestsReceived = convert<IDLUnsignedLongLong>(state, requestsReceivedValue); |
| 1937 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1938 | } |
| 1939 | JSValue requestsSentValue; |
| 1940 | if (isNullOrUndefined) |
| 1941 | requestsSentValue = jsUndefined(); |
| 1942 | else { |
| 1943 | requestsSentValue = object->get(&state, Identifier::fromString(&state, "requestsSent" )); |
| 1944 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1945 | } |
| 1946 | if (!requestsSentValue.isUndefined()) { |
| 1947 | result.requestsSent = convert<IDLUnsignedLongLong>(state, requestsSentValue); |
| 1948 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1949 | } |
| 1950 | JSValue responsesReceivedValue; |
| 1951 | if (isNullOrUndefined) |
| 1952 | responsesReceivedValue = jsUndefined(); |
| 1953 | else { |
| 1954 | responsesReceivedValue = object->get(&state, Identifier::fromString(&state, "responsesReceived" )); |
| 1955 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1956 | } |
| 1957 | if (!responsesReceivedValue.isUndefined()) { |
| 1958 | result.responsesReceived = convert<IDLUnsignedLongLong>(state, responsesReceivedValue); |
| 1959 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1960 | } |
| 1961 | JSValue responsesSentValue; |
| 1962 | if (isNullOrUndefined) |
| 1963 | responsesSentValue = jsUndefined(); |
| 1964 | else { |
| 1965 | responsesSentValue = object->get(&state, Identifier::fromString(&state, "responsesSent" )); |
| 1966 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1967 | } |
| 1968 | if (!responsesSentValue.isUndefined()) { |
| 1969 | result.responsesSent = convert<IDLUnsignedLongLong>(state, responsesSentValue); |
| 1970 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1971 | } |
| 1972 | JSValue stateValue; |
| 1973 | if (isNullOrUndefined) |
| 1974 | stateValue = jsUndefined(); |
| 1975 | else { |
| 1976 | stateValue = object->get(&state, Identifier::fromString(&state, "state" )); |
| 1977 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1978 | } |
| 1979 | if (!stateValue.isUndefined()) { |
| 1980 | result.state = convert<IDLEnumeration<RTCStatsReport::IceCandidatePairState>>(state, stateValue); |
| 1981 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1982 | } |
| 1983 | JSValue totalRoundTripTimeValue; |
| 1984 | if (isNullOrUndefined) |
| 1985 | totalRoundTripTimeValue = jsUndefined(); |
| 1986 | else { |
| 1987 | totalRoundTripTimeValue = object->get(&state, Identifier::fromString(&state, "totalRoundTripTime" )); |
| 1988 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1989 | } |
| 1990 | if (!totalRoundTripTimeValue.isUndefined()) { |
| 1991 | result.totalRoundTripTime = convert<IDLDouble>(state, totalRoundTripTimeValue); |
| 1992 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 1993 | } |
| 1994 | JSValue transportIdValue; |
| 1995 | if (isNullOrUndefined) |
| 1996 | transportIdValue = jsUndefined(); |
| 1997 | else { |
| 1998 | transportIdValue = object->get(&state, Identifier::fromString(&state, "transportId" )); |
| 1999 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2000 | } |
| 2001 | if (!transportIdValue.isUndefined()) { |
| 2002 | result.transportId = convert<IDLDOMString>(state, transportIdValue); |
| 2003 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2004 | } |
| 2005 | JSValue writableValue; |
| 2006 | if (isNullOrUndefined) |
| 2007 | writableValue = jsUndefined(); |
| 2008 | else { |
| 2009 | writableValue = object->get(&state, Identifier::fromString(&state, "writable" )); |
| 2010 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2011 | } |
| 2012 | if (!writableValue.isUndefined()) { |
| 2013 | result.writable = convert<IDLBoolean>(state, writableValue); |
| 2014 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2015 | } |
| 2016 | return result; |
| 2017 | } |
| 2018 | |
| 2019 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::IceCandidatePairStats& dictionary) |
| 2020 | { |
| 2021 | auto& vm = state.vm(); |
| 2022 | |
| 2023 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 2024 | |
| 2025 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 2026 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 2027 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 2028 | } |
| 2029 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 2030 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 2031 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 2032 | } |
| 2033 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 2034 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 2035 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 2036 | } |
| 2037 | if (!IDLDouble::isNullValue(dictionary.availableIncomingBitrate)) { |
| 2038 | auto availableIncomingBitrateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.availableIncomingBitrate)); |
| 2039 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "availableIncomingBitrate" ), availableIncomingBitrateValue); |
| 2040 | } |
| 2041 | if (!IDLDouble::isNullValue(dictionary.availableOutgoingBitrate)) { |
| 2042 | auto availableOutgoingBitrateValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.availableOutgoingBitrate)); |
| 2043 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "availableOutgoingBitrate" ), availableOutgoingBitrateValue); |
| 2044 | } |
| 2045 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesReceived)) { |
| 2046 | auto bytesReceivedValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesReceived)); |
| 2047 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesReceived" ), bytesReceivedValue); |
| 2048 | } |
| 2049 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesSent)) { |
| 2050 | auto bytesSentValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesSent)); |
| 2051 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesSent" ), bytesSentValue); |
| 2052 | } |
| 2053 | if (!IDLDouble::isNullValue(dictionary.currentRoundTripTime)) { |
| 2054 | auto currentRoundTripTimeValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.currentRoundTripTime)); |
| 2055 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "currentRoundTripTime" ), currentRoundTripTimeValue); |
| 2056 | } |
| 2057 | if (!IDLDOMString::isNullValue(dictionary.localCandidateId)) { |
| 2058 | auto localCandidateIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.localCandidateId)); |
| 2059 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "localCandidateId" ), localCandidateIdValue); |
| 2060 | } |
| 2061 | if (!IDLBoolean::isNullValue(dictionary.nominated)) { |
| 2062 | auto nominatedValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.nominated)); |
| 2063 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "nominated" ), nominatedValue); |
| 2064 | } |
| 2065 | if (!IDLUnsignedLongLong::isNullValue(dictionary.priority)) { |
| 2066 | auto priorityValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.priority)); |
| 2067 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "priority" ), priorityValue); |
| 2068 | } |
| 2069 | if (!IDLBoolean::isNullValue(dictionary.readable)) { |
| 2070 | auto readableValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.readable)); |
| 2071 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "readable" ), readableValue); |
| 2072 | } |
| 2073 | if (!IDLDOMString::isNullValue(dictionary.remoteCandidateId)) { |
| 2074 | auto remoteCandidateIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.remoteCandidateId)); |
| 2075 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "remoteCandidateId" ), remoteCandidateIdValue); |
| 2076 | } |
| 2077 | if (!IDLUnsignedLongLong::isNullValue(dictionary.requestsReceived)) { |
| 2078 | auto requestsReceivedValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.requestsReceived)); |
| 2079 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "requestsReceived" ), requestsReceivedValue); |
| 2080 | } |
| 2081 | if (!IDLUnsignedLongLong::isNullValue(dictionary.requestsSent)) { |
| 2082 | auto requestsSentValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.requestsSent)); |
| 2083 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "requestsSent" ), requestsSentValue); |
| 2084 | } |
| 2085 | if (!IDLUnsignedLongLong::isNullValue(dictionary.responsesReceived)) { |
| 2086 | auto responsesReceivedValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.responsesReceived)); |
| 2087 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "responsesReceived" ), responsesReceivedValue); |
| 2088 | } |
| 2089 | if (!IDLUnsignedLongLong::isNullValue(dictionary.responsesSent)) { |
| 2090 | auto responsesSentValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.responsesSent)); |
| 2091 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "responsesSent" ), responsesSentValue); |
| 2092 | } |
| 2093 | if (!IDLEnumeration<RTCStatsReport::IceCandidatePairState>::isNullValue(dictionary.state)) { |
| 2094 | auto stateValue = toJS<IDLEnumeration<RTCStatsReport::IceCandidatePairState>>(state, IDLEnumeration<RTCStatsReport::IceCandidatePairState>::extractValueFromNullable(dictionary.state)); |
| 2095 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "state" ), stateValue); |
| 2096 | } |
| 2097 | if (!IDLDouble::isNullValue(dictionary.totalRoundTripTime)) { |
| 2098 | auto totalRoundTripTimeValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.totalRoundTripTime)); |
| 2099 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "totalRoundTripTime" ), totalRoundTripTimeValue); |
| 2100 | } |
| 2101 | if (!IDLDOMString::isNullValue(dictionary.transportId)) { |
| 2102 | auto transportIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.transportId)); |
| 2103 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "transportId" ), transportIdValue); |
| 2104 | } |
| 2105 | if (!IDLBoolean::isNullValue(dictionary.writable)) { |
| 2106 | auto writableValue = toJS<IDLBoolean>(IDLBoolean::extractValueFromNullable(dictionary.writable)); |
| 2107 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "writable" ), writableValue); |
| 2108 | } |
| 2109 | return result; |
| 2110 | } |
| 2111 | |
| 2112 | template<> RTCStatsReport::IceCandidateStats convertDictionary<RTCStatsReport::IceCandidateStats>(ExecState& state, JSValue value) |
| 2113 | { |
| 2114 | VM& vm = state.vm(); |
| 2115 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 2116 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 2117 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 2118 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 2119 | throwTypeError(&state, throwScope); |
| 2120 | return { }; |
| 2121 | } |
| 2122 | RTCStatsReport::IceCandidateStats result; |
| 2123 | JSValue idValue; |
| 2124 | if (isNullOrUndefined) |
| 2125 | idValue = jsUndefined(); |
| 2126 | else { |
| 2127 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 2128 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2129 | } |
| 2130 | if (!idValue.isUndefined()) { |
| 2131 | result.id = convert<IDLDOMString>(state, idValue); |
| 2132 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2133 | } |
| 2134 | JSValue timestampValue; |
| 2135 | if (isNullOrUndefined) |
| 2136 | timestampValue = jsUndefined(); |
| 2137 | else { |
| 2138 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 2139 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2140 | } |
| 2141 | if (!timestampValue.isUndefined()) { |
| 2142 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 2143 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2144 | } |
| 2145 | JSValue typeValue; |
| 2146 | if (isNullOrUndefined) |
| 2147 | typeValue = jsUndefined(); |
| 2148 | else { |
| 2149 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 2150 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2151 | } |
| 2152 | if (!typeValue.isUndefined()) { |
| 2153 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 2154 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2155 | } |
| 2156 | JSValue addressValue; |
| 2157 | if (isNullOrUndefined) |
| 2158 | addressValue = jsUndefined(); |
| 2159 | else { |
| 2160 | addressValue = object->get(&state, Identifier::fromString(&state, "address" )); |
| 2161 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2162 | } |
| 2163 | if (!addressValue.isUndefined()) { |
| 2164 | result.address = convert<IDLDOMString>(state, addressValue); |
| 2165 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2166 | } |
| 2167 | JSValue candidateTypeValue; |
| 2168 | if (isNullOrUndefined) |
| 2169 | candidateTypeValue = jsUndefined(); |
| 2170 | else { |
| 2171 | candidateTypeValue = object->get(&state, Identifier::fromString(&state, "candidateType" )); |
| 2172 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2173 | } |
| 2174 | if (!candidateTypeValue.isUndefined()) { |
| 2175 | result.candidateType = convert<IDLEnumeration<RTCStatsReport::IceCandidateType>>(state, candidateTypeValue); |
| 2176 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2177 | } |
| 2178 | JSValue deletedValue; |
| 2179 | if (isNullOrUndefined) |
| 2180 | deletedValue = jsUndefined(); |
| 2181 | else { |
| 2182 | deletedValue = object->get(&state, Identifier::fromString(&state, "deleted" )); |
| 2183 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2184 | } |
| 2185 | if (!deletedValue.isUndefined()) { |
| 2186 | result.deleted = convert<IDLBoolean>(state, deletedValue); |
| 2187 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2188 | } else |
| 2189 | result.deleted = false; |
| 2190 | JSValue portValue; |
| 2191 | if (isNullOrUndefined) |
| 2192 | portValue = jsUndefined(); |
| 2193 | else { |
| 2194 | portValue = object->get(&state, Identifier::fromString(&state, "port" )); |
| 2195 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2196 | } |
| 2197 | if (!portValue.isUndefined()) { |
| 2198 | result.port = convert<IDLLong>(state, portValue); |
| 2199 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2200 | } |
| 2201 | JSValue priorityValue; |
| 2202 | if (isNullOrUndefined) |
| 2203 | priorityValue = jsUndefined(); |
| 2204 | else { |
| 2205 | priorityValue = object->get(&state, Identifier::fromString(&state, "priority" )); |
| 2206 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2207 | } |
| 2208 | if (!priorityValue.isUndefined()) { |
| 2209 | result.priority = convert<IDLLong>(state, priorityValue); |
| 2210 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2211 | } |
| 2212 | JSValue protocolValue; |
| 2213 | if (isNullOrUndefined) |
| 2214 | protocolValue = jsUndefined(); |
| 2215 | else { |
| 2216 | protocolValue = object->get(&state, Identifier::fromString(&state, "protocol" )); |
| 2217 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2218 | } |
| 2219 | if (!protocolValue.isUndefined()) { |
| 2220 | result.protocol = convert<IDLDOMString>(state, protocolValue); |
| 2221 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2222 | } |
| 2223 | JSValue transportIdValue; |
| 2224 | if (isNullOrUndefined) |
| 2225 | transportIdValue = jsUndefined(); |
| 2226 | else { |
| 2227 | transportIdValue = object->get(&state, Identifier::fromString(&state, "transportId" )); |
| 2228 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2229 | } |
| 2230 | if (!transportIdValue.isUndefined()) { |
| 2231 | result.transportId = convert<IDLDOMString>(state, transportIdValue); |
| 2232 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2233 | } |
| 2234 | JSValue urlValue; |
| 2235 | if (isNullOrUndefined) |
| 2236 | urlValue = jsUndefined(); |
| 2237 | else { |
| 2238 | urlValue = object->get(&state, Identifier::fromString(&state, "url" )); |
| 2239 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2240 | } |
| 2241 | if (!urlValue.isUndefined()) { |
| 2242 | result.url = convert<IDLDOMString>(state, urlValue); |
| 2243 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2244 | } |
| 2245 | return result; |
| 2246 | } |
| 2247 | |
| 2248 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::IceCandidateStats& dictionary) |
| 2249 | { |
| 2250 | auto& vm = state.vm(); |
| 2251 | |
| 2252 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 2253 | |
| 2254 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 2255 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 2256 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 2257 | } |
| 2258 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 2259 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 2260 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 2261 | } |
| 2262 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 2263 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 2264 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 2265 | } |
| 2266 | if (!IDLDOMString::isNullValue(dictionary.address)) { |
| 2267 | auto addressValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.address)); |
| 2268 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "address" ), addressValue); |
| 2269 | } |
| 2270 | if (!IDLEnumeration<RTCStatsReport::IceCandidateType>::isNullValue(dictionary.candidateType)) { |
| 2271 | auto candidateTypeValue = toJS<IDLEnumeration<RTCStatsReport::IceCandidateType>>(state, IDLEnumeration<RTCStatsReport::IceCandidateType>::extractValueFromNullable(dictionary.candidateType)); |
| 2272 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "candidateType" ), candidateTypeValue); |
| 2273 | } |
| 2274 | auto deletedValue = toJS<IDLBoolean>(dictionary.deleted); |
| 2275 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "deleted" ), deletedValue); |
| 2276 | if (!IDLLong::isNullValue(dictionary.port)) { |
| 2277 | auto portValue = toJS<IDLLong>(IDLLong::extractValueFromNullable(dictionary.port)); |
| 2278 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "port" ), portValue); |
| 2279 | } |
| 2280 | if (!IDLLong::isNullValue(dictionary.priority)) { |
| 2281 | auto priorityValue = toJS<IDLLong>(IDLLong::extractValueFromNullable(dictionary.priority)); |
| 2282 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "priority" ), priorityValue); |
| 2283 | } |
| 2284 | if (!IDLDOMString::isNullValue(dictionary.protocol)) { |
| 2285 | auto protocolValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.protocol)); |
| 2286 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "protocol" ), protocolValue); |
| 2287 | } |
| 2288 | if (!IDLDOMString::isNullValue(dictionary.transportId)) { |
| 2289 | auto transportIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.transportId)); |
| 2290 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "transportId" ), transportIdValue); |
| 2291 | } |
| 2292 | if (!IDLDOMString::isNullValue(dictionary.url)) { |
| 2293 | auto urlValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.url)); |
| 2294 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "url" ), urlValue); |
| 2295 | } |
| 2296 | return result; |
| 2297 | } |
| 2298 | |
| 2299 | template<> RTCStatsReport::CertificateStats convertDictionary<RTCStatsReport::CertificateStats>(ExecState& state, JSValue value) |
| 2300 | { |
| 2301 | VM& vm = state.vm(); |
| 2302 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 2303 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 2304 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 2305 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 2306 | throwTypeError(&state, throwScope); |
| 2307 | return { }; |
| 2308 | } |
| 2309 | RTCStatsReport::CertificateStats result; |
| 2310 | JSValue idValue; |
| 2311 | if (isNullOrUndefined) |
| 2312 | idValue = jsUndefined(); |
| 2313 | else { |
| 2314 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 2315 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2316 | } |
| 2317 | if (!idValue.isUndefined()) { |
| 2318 | result.id = convert<IDLDOMString>(state, idValue); |
| 2319 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2320 | } |
| 2321 | JSValue timestampValue; |
| 2322 | if (isNullOrUndefined) |
| 2323 | timestampValue = jsUndefined(); |
| 2324 | else { |
| 2325 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 2326 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2327 | } |
| 2328 | if (!timestampValue.isUndefined()) { |
| 2329 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 2330 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2331 | } |
| 2332 | JSValue typeValue; |
| 2333 | if (isNullOrUndefined) |
| 2334 | typeValue = jsUndefined(); |
| 2335 | else { |
| 2336 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 2337 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2338 | } |
| 2339 | if (!typeValue.isUndefined()) { |
| 2340 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 2341 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2342 | } |
| 2343 | JSValue base64CertificateValue; |
| 2344 | if (isNullOrUndefined) |
| 2345 | base64CertificateValue = jsUndefined(); |
| 2346 | else { |
| 2347 | base64CertificateValue = object->get(&state, Identifier::fromString(&state, "base64Certificate" )); |
| 2348 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2349 | } |
| 2350 | if (!base64CertificateValue.isUndefined()) { |
| 2351 | result.base64Certificate = convert<IDLDOMString>(state, base64CertificateValue); |
| 2352 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2353 | } |
| 2354 | JSValue fingerprintValue; |
| 2355 | if (isNullOrUndefined) |
| 2356 | fingerprintValue = jsUndefined(); |
| 2357 | else { |
| 2358 | fingerprintValue = object->get(&state, Identifier::fromString(&state, "fingerprint" )); |
| 2359 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2360 | } |
| 2361 | if (!fingerprintValue.isUndefined()) { |
| 2362 | result.fingerprint = convert<IDLDOMString>(state, fingerprintValue); |
| 2363 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2364 | } |
| 2365 | JSValue fingerprintAlgorithmValue; |
| 2366 | if (isNullOrUndefined) |
| 2367 | fingerprintAlgorithmValue = jsUndefined(); |
| 2368 | else { |
| 2369 | fingerprintAlgorithmValue = object->get(&state, Identifier::fromString(&state, "fingerprintAlgorithm" )); |
| 2370 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2371 | } |
| 2372 | if (!fingerprintAlgorithmValue.isUndefined()) { |
| 2373 | result.fingerprintAlgorithm = convert<IDLDOMString>(state, fingerprintAlgorithmValue); |
| 2374 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2375 | } |
| 2376 | JSValue issuerCertificateIdValue; |
| 2377 | if (isNullOrUndefined) |
| 2378 | issuerCertificateIdValue = jsUndefined(); |
| 2379 | else { |
| 2380 | issuerCertificateIdValue = object->get(&state, Identifier::fromString(&state, "issuerCertificateId" )); |
| 2381 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2382 | } |
| 2383 | if (!issuerCertificateIdValue.isUndefined()) { |
| 2384 | result.issuerCertificateId = convert<IDLDOMString>(state, issuerCertificateIdValue); |
| 2385 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2386 | } |
| 2387 | return result; |
| 2388 | } |
| 2389 | |
| 2390 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::CertificateStats& dictionary) |
| 2391 | { |
| 2392 | auto& vm = state.vm(); |
| 2393 | |
| 2394 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 2395 | |
| 2396 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 2397 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 2398 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 2399 | } |
| 2400 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 2401 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 2402 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 2403 | } |
| 2404 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 2405 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 2406 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 2407 | } |
| 2408 | if (!IDLDOMString::isNullValue(dictionary.base64Certificate)) { |
| 2409 | auto base64CertificateValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.base64Certificate)); |
| 2410 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "base64Certificate" ), base64CertificateValue); |
| 2411 | } |
| 2412 | if (!IDLDOMString::isNullValue(dictionary.fingerprint)) { |
| 2413 | auto fingerprintValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.fingerprint)); |
| 2414 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "fingerprint" ), fingerprintValue); |
| 2415 | } |
| 2416 | if (!IDLDOMString::isNullValue(dictionary.fingerprintAlgorithm)) { |
| 2417 | auto fingerprintAlgorithmValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.fingerprintAlgorithm)); |
| 2418 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "fingerprintAlgorithm" ), fingerprintAlgorithmValue); |
| 2419 | } |
| 2420 | if (!IDLDOMString::isNullValue(dictionary.issuerCertificateId)) { |
| 2421 | auto issuerCertificateIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.issuerCertificateId)); |
| 2422 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "issuerCertificateId" ), issuerCertificateIdValue); |
| 2423 | } |
| 2424 | return result; |
| 2425 | } |
| 2426 | |
| 2427 | template<> RTCStatsReport::CodecStats convertDictionary<RTCStatsReport::CodecStats>(ExecState& state, JSValue value) |
| 2428 | { |
| 2429 | VM& vm = state.vm(); |
| 2430 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 2431 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 2432 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 2433 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 2434 | throwTypeError(&state, throwScope); |
| 2435 | return { }; |
| 2436 | } |
| 2437 | RTCStatsReport::CodecStats result; |
| 2438 | JSValue idValue; |
| 2439 | if (isNullOrUndefined) |
| 2440 | idValue = jsUndefined(); |
| 2441 | else { |
| 2442 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 2443 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2444 | } |
| 2445 | if (!idValue.isUndefined()) { |
| 2446 | result.id = convert<IDLDOMString>(state, idValue); |
| 2447 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2448 | } |
| 2449 | JSValue timestampValue; |
| 2450 | if (isNullOrUndefined) |
| 2451 | timestampValue = jsUndefined(); |
| 2452 | else { |
| 2453 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 2454 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2455 | } |
| 2456 | if (!timestampValue.isUndefined()) { |
| 2457 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 2458 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2459 | } |
| 2460 | JSValue typeValue; |
| 2461 | if (isNullOrUndefined) |
| 2462 | typeValue = jsUndefined(); |
| 2463 | else { |
| 2464 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 2465 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2466 | } |
| 2467 | if (!typeValue.isUndefined()) { |
| 2468 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 2469 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2470 | } |
| 2471 | JSValue channelsValue; |
| 2472 | if (isNullOrUndefined) |
| 2473 | channelsValue = jsUndefined(); |
| 2474 | else { |
| 2475 | channelsValue = object->get(&state, Identifier::fromString(&state, "channels" )); |
| 2476 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2477 | } |
| 2478 | if (!channelsValue.isUndefined()) { |
| 2479 | result.channels = convert<IDLUnsignedLong>(state, channelsValue); |
| 2480 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2481 | } |
| 2482 | JSValue clockRateValue; |
| 2483 | if (isNullOrUndefined) |
| 2484 | clockRateValue = jsUndefined(); |
| 2485 | else { |
| 2486 | clockRateValue = object->get(&state, Identifier::fromString(&state, "clockRate" )); |
| 2487 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2488 | } |
| 2489 | if (!clockRateValue.isUndefined()) { |
| 2490 | result.clockRate = convert<IDLUnsignedLong>(state, clockRateValue); |
| 2491 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2492 | } |
| 2493 | JSValue codecTypeValue; |
| 2494 | if (isNullOrUndefined) |
| 2495 | codecTypeValue = jsUndefined(); |
| 2496 | else { |
| 2497 | codecTypeValue = object->get(&state, Identifier::fromString(&state, "codecType" )); |
| 2498 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2499 | } |
| 2500 | if (!codecTypeValue.isUndefined()) { |
| 2501 | result.codecType = convert<IDLEnumeration<RTCStatsReport::CodecType>>(state, codecTypeValue); |
| 2502 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2503 | } |
| 2504 | JSValue implementationValue; |
| 2505 | if (isNullOrUndefined) |
| 2506 | implementationValue = jsUndefined(); |
| 2507 | else { |
| 2508 | implementationValue = object->get(&state, Identifier::fromString(&state, "implementation" )); |
| 2509 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2510 | } |
| 2511 | if (!implementationValue.isUndefined()) { |
| 2512 | result.implementation = convert<IDLDOMString>(state, implementationValue); |
| 2513 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2514 | } |
| 2515 | JSValue mimeTypeValue; |
| 2516 | if (isNullOrUndefined) |
| 2517 | mimeTypeValue = jsUndefined(); |
| 2518 | else { |
| 2519 | mimeTypeValue = object->get(&state, Identifier::fromString(&state, "mimeType" )); |
| 2520 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2521 | } |
| 2522 | if (!mimeTypeValue.isUndefined()) { |
| 2523 | result.mimeType = convert<IDLDOMString>(state, mimeTypeValue); |
| 2524 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2525 | } |
| 2526 | JSValue payloadTypeValue; |
| 2527 | if (isNullOrUndefined) |
| 2528 | payloadTypeValue = jsUndefined(); |
| 2529 | else { |
| 2530 | payloadTypeValue = object->get(&state, Identifier::fromString(&state, "payloadType" )); |
| 2531 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2532 | } |
| 2533 | if (!payloadTypeValue.isUndefined()) { |
| 2534 | result.payloadType = convert<IDLUnsignedLong>(state, payloadTypeValue); |
| 2535 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2536 | } |
| 2537 | JSValue sdpFmtpLineValue; |
| 2538 | if (isNullOrUndefined) |
| 2539 | sdpFmtpLineValue = jsUndefined(); |
| 2540 | else { |
| 2541 | sdpFmtpLineValue = object->get(&state, Identifier::fromString(&state, "sdpFmtpLine" )); |
| 2542 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2543 | } |
| 2544 | if (!sdpFmtpLineValue.isUndefined()) { |
| 2545 | result.sdpFmtpLine = convert<IDLDOMString>(state, sdpFmtpLineValue); |
| 2546 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2547 | } |
| 2548 | JSValue transportIdValue; |
| 2549 | if (isNullOrUndefined) |
| 2550 | transportIdValue = jsUndefined(); |
| 2551 | else { |
| 2552 | transportIdValue = object->get(&state, Identifier::fromString(&state, "transportId" )); |
| 2553 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2554 | } |
| 2555 | if (!transportIdValue.isUndefined()) { |
| 2556 | result.transportId = convert<IDLDOMString>(state, transportIdValue); |
| 2557 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2558 | } |
| 2559 | return result; |
| 2560 | } |
| 2561 | |
| 2562 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::CodecStats& dictionary) |
| 2563 | { |
| 2564 | auto& vm = state.vm(); |
| 2565 | |
| 2566 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 2567 | |
| 2568 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 2569 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 2570 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 2571 | } |
| 2572 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 2573 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 2574 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 2575 | } |
| 2576 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 2577 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 2578 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 2579 | } |
| 2580 | if (!IDLUnsignedLong::isNullValue(dictionary.channels)) { |
| 2581 | auto channelsValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.channels)); |
| 2582 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "channels" ), channelsValue); |
| 2583 | } |
| 2584 | if (!IDLUnsignedLong::isNullValue(dictionary.clockRate)) { |
| 2585 | auto clockRateValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.clockRate)); |
| 2586 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "clockRate" ), clockRateValue); |
| 2587 | } |
| 2588 | if (!IDLEnumeration<RTCStatsReport::CodecType>::isNullValue(dictionary.codecType)) { |
| 2589 | auto codecTypeValue = toJS<IDLEnumeration<RTCStatsReport::CodecType>>(state, IDLEnumeration<RTCStatsReport::CodecType>::extractValueFromNullable(dictionary.codecType)); |
| 2590 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "codecType" ), codecTypeValue); |
| 2591 | } |
| 2592 | if (!IDLDOMString::isNullValue(dictionary.implementation)) { |
| 2593 | auto implementationValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.implementation)); |
| 2594 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "implementation" ), implementationValue); |
| 2595 | } |
| 2596 | if (!IDLDOMString::isNullValue(dictionary.mimeType)) { |
| 2597 | auto mimeTypeValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.mimeType)); |
| 2598 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "mimeType" ), mimeTypeValue); |
| 2599 | } |
| 2600 | if (!IDLUnsignedLong::isNullValue(dictionary.payloadType)) { |
| 2601 | auto payloadTypeValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.payloadType)); |
| 2602 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "payloadType" ), payloadTypeValue); |
| 2603 | } |
| 2604 | if (!IDLDOMString::isNullValue(dictionary.sdpFmtpLine)) { |
| 2605 | auto sdpFmtpLineValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.sdpFmtpLine)); |
| 2606 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "sdpFmtpLine" ), sdpFmtpLineValue); |
| 2607 | } |
| 2608 | if (!IDLDOMString::isNullValue(dictionary.transportId)) { |
| 2609 | auto transportIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.transportId)); |
| 2610 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "transportId" ), transportIdValue); |
| 2611 | } |
| 2612 | return result; |
| 2613 | } |
| 2614 | |
| 2615 | template<> RTCStatsReport::TransportStats convertDictionary<RTCStatsReport::TransportStats>(ExecState& state, JSValue value) |
| 2616 | { |
| 2617 | VM& vm = state.vm(); |
| 2618 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 2619 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 2620 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 2621 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 2622 | throwTypeError(&state, throwScope); |
| 2623 | return { }; |
| 2624 | } |
| 2625 | RTCStatsReport::TransportStats result; |
| 2626 | JSValue idValue; |
| 2627 | if (isNullOrUndefined) |
| 2628 | idValue = jsUndefined(); |
| 2629 | else { |
| 2630 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 2631 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2632 | } |
| 2633 | if (!idValue.isUndefined()) { |
| 2634 | result.id = convert<IDLDOMString>(state, idValue); |
| 2635 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2636 | } |
| 2637 | JSValue timestampValue; |
| 2638 | if (isNullOrUndefined) |
| 2639 | timestampValue = jsUndefined(); |
| 2640 | else { |
| 2641 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 2642 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2643 | } |
| 2644 | if (!timestampValue.isUndefined()) { |
| 2645 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 2646 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2647 | } |
| 2648 | JSValue typeValue; |
| 2649 | if (isNullOrUndefined) |
| 2650 | typeValue = jsUndefined(); |
| 2651 | else { |
| 2652 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 2653 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2654 | } |
| 2655 | if (!typeValue.isUndefined()) { |
| 2656 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 2657 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2658 | } |
| 2659 | JSValue bytesReceivedValue; |
| 2660 | if (isNullOrUndefined) |
| 2661 | bytesReceivedValue = jsUndefined(); |
| 2662 | else { |
| 2663 | bytesReceivedValue = object->get(&state, Identifier::fromString(&state, "bytesReceived" )); |
| 2664 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2665 | } |
| 2666 | if (!bytesReceivedValue.isUndefined()) { |
| 2667 | result.bytesReceived = convert<IDLUnsignedLongLong>(state, bytesReceivedValue); |
| 2668 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2669 | } |
| 2670 | JSValue bytesSentValue; |
| 2671 | if (isNullOrUndefined) |
| 2672 | bytesSentValue = jsUndefined(); |
| 2673 | else { |
| 2674 | bytesSentValue = object->get(&state, Identifier::fromString(&state, "bytesSent" )); |
| 2675 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2676 | } |
| 2677 | if (!bytesSentValue.isUndefined()) { |
| 2678 | result.bytesSent = convert<IDLUnsignedLongLong>(state, bytesSentValue); |
| 2679 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2680 | } |
| 2681 | JSValue localCertificateIdValue; |
| 2682 | if (isNullOrUndefined) |
| 2683 | localCertificateIdValue = jsUndefined(); |
| 2684 | else { |
| 2685 | localCertificateIdValue = object->get(&state, Identifier::fromString(&state, "localCertificateId" )); |
| 2686 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2687 | } |
| 2688 | if (!localCertificateIdValue.isUndefined()) { |
| 2689 | result.localCertificateId = convert<IDLDOMString>(state, localCertificateIdValue); |
| 2690 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2691 | } |
| 2692 | JSValue remoteCertificateIdValue; |
| 2693 | if (isNullOrUndefined) |
| 2694 | remoteCertificateIdValue = jsUndefined(); |
| 2695 | else { |
| 2696 | remoteCertificateIdValue = object->get(&state, Identifier::fromString(&state, "remoteCertificateId" )); |
| 2697 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2698 | } |
| 2699 | if (!remoteCertificateIdValue.isUndefined()) { |
| 2700 | result.remoteCertificateId = convert<IDLDOMString>(state, remoteCertificateIdValue); |
| 2701 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2702 | } |
| 2703 | JSValue rtcpTransportStatsIdValue; |
| 2704 | if (isNullOrUndefined) |
| 2705 | rtcpTransportStatsIdValue = jsUndefined(); |
| 2706 | else { |
| 2707 | rtcpTransportStatsIdValue = object->get(&state, Identifier::fromString(&state, "rtcpTransportStatsId" )); |
| 2708 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2709 | } |
| 2710 | if (!rtcpTransportStatsIdValue.isUndefined()) { |
| 2711 | result.rtcpTransportStatsId = convert<IDLDOMString>(state, rtcpTransportStatsIdValue); |
| 2712 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2713 | } |
| 2714 | JSValue selectedCandidatePairIdValue; |
| 2715 | if (isNullOrUndefined) |
| 2716 | selectedCandidatePairIdValue = jsUndefined(); |
| 2717 | else { |
| 2718 | selectedCandidatePairIdValue = object->get(&state, Identifier::fromString(&state, "selectedCandidatePairId" )); |
| 2719 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2720 | } |
| 2721 | if (!selectedCandidatePairIdValue.isUndefined()) { |
| 2722 | result.selectedCandidatePairId = convert<IDLDOMString>(state, selectedCandidatePairIdValue); |
| 2723 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2724 | } |
| 2725 | return result; |
| 2726 | } |
| 2727 | |
| 2728 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::TransportStats& dictionary) |
| 2729 | { |
| 2730 | auto& vm = state.vm(); |
| 2731 | |
| 2732 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 2733 | |
| 2734 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 2735 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 2736 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 2737 | } |
| 2738 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 2739 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 2740 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 2741 | } |
| 2742 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 2743 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 2744 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 2745 | } |
| 2746 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesReceived)) { |
| 2747 | auto bytesReceivedValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesReceived)); |
| 2748 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesReceived" ), bytesReceivedValue); |
| 2749 | } |
| 2750 | if (!IDLUnsignedLongLong::isNullValue(dictionary.bytesSent)) { |
| 2751 | auto bytesSentValue = toJS<IDLUnsignedLongLong>(IDLUnsignedLongLong::extractValueFromNullable(dictionary.bytesSent)); |
| 2752 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "bytesSent" ), bytesSentValue); |
| 2753 | } |
| 2754 | if (!IDLDOMString::isNullValue(dictionary.localCertificateId)) { |
| 2755 | auto localCertificateIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.localCertificateId)); |
| 2756 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "localCertificateId" ), localCertificateIdValue); |
| 2757 | } |
| 2758 | if (!IDLDOMString::isNullValue(dictionary.remoteCertificateId)) { |
| 2759 | auto remoteCertificateIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.remoteCertificateId)); |
| 2760 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "remoteCertificateId" ), remoteCertificateIdValue); |
| 2761 | } |
| 2762 | if (!IDLDOMString::isNullValue(dictionary.rtcpTransportStatsId)) { |
| 2763 | auto rtcpTransportStatsIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.rtcpTransportStatsId)); |
| 2764 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "rtcpTransportStatsId" ), rtcpTransportStatsIdValue); |
| 2765 | } |
| 2766 | if (!IDLDOMString::isNullValue(dictionary.selectedCandidatePairId)) { |
| 2767 | auto selectedCandidatePairIdValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.selectedCandidatePairId)); |
| 2768 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "selectedCandidatePairId" ), selectedCandidatePairIdValue); |
| 2769 | } |
| 2770 | return result; |
| 2771 | } |
| 2772 | |
| 2773 | template<> RTCStatsReport::PeerConnectionStats convertDictionary<RTCStatsReport::PeerConnectionStats>(ExecState& state, JSValue value) |
| 2774 | { |
| 2775 | VM& vm = state.vm(); |
| 2776 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 2777 | bool isNullOrUndefined = value.isUndefinedOrNull(); |
| 2778 | auto* object = isNullOrUndefined ? nullptr : value.getObject(); |
| 2779 | if (UNLIKELY(!isNullOrUndefined && !object)) { |
| 2780 | throwTypeError(&state, throwScope); |
| 2781 | return { }; |
| 2782 | } |
| 2783 | RTCStatsReport::PeerConnectionStats result; |
| 2784 | JSValue idValue; |
| 2785 | if (isNullOrUndefined) |
| 2786 | idValue = jsUndefined(); |
| 2787 | else { |
| 2788 | idValue = object->get(&state, Identifier::fromString(&state, "id" )); |
| 2789 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2790 | } |
| 2791 | if (!idValue.isUndefined()) { |
| 2792 | result.id = convert<IDLDOMString>(state, idValue); |
| 2793 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2794 | } |
| 2795 | JSValue timestampValue; |
| 2796 | if (isNullOrUndefined) |
| 2797 | timestampValue = jsUndefined(); |
| 2798 | else { |
| 2799 | timestampValue = object->get(&state, Identifier::fromString(&state, "timestamp" )); |
| 2800 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2801 | } |
| 2802 | if (!timestampValue.isUndefined()) { |
| 2803 | result.timestamp = convert<IDLDouble>(state, timestampValue); |
| 2804 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2805 | } |
| 2806 | JSValue typeValue; |
| 2807 | if (isNullOrUndefined) |
| 2808 | typeValue = jsUndefined(); |
| 2809 | else { |
| 2810 | typeValue = object->get(&state, Identifier::fromString(&state, "type" )); |
| 2811 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2812 | } |
| 2813 | if (!typeValue.isUndefined()) { |
| 2814 | result.type = convert<IDLEnumeration<RTCStatsReport::Type>>(state, typeValue); |
| 2815 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2816 | } |
| 2817 | JSValue dataChannelsClosedValue; |
| 2818 | if (isNullOrUndefined) |
| 2819 | dataChannelsClosedValue = jsUndefined(); |
| 2820 | else { |
| 2821 | dataChannelsClosedValue = object->get(&state, Identifier::fromString(&state, "dataChannelsClosed" )); |
| 2822 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2823 | } |
| 2824 | if (!dataChannelsClosedValue.isUndefined()) { |
| 2825 | result.dataChannelsClosed = convert<IDLUnsignedLong>(state, dataChannelsClosedValue); |
| 2826 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2827 | } |
| 2828 | JSValue dataChannelsOpenedValue; |
| 2829 | if (isNullOrUndefined) |
| 2830 | dataChannelsOpenedValue = jsUndefined(); |
| 2831 | else { |
| 2832 | dataChannelsOpenedValue = object->get(&state, Identifier::fromString(&state, "dataChannelsOpened" )); |
| 2833 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2834 | } |
| 2835 | if (!dataChannelsOpenedValue.isUndefined()) { |
| 2836 | result.dataChannelsOpened = convert<IDLUnsignedLong>(state, dataChannelsOpenedValue); |
| 2837 | RETURN_IF_EXCEPTION(throwScope, { }); |
| 2838 | } |
| 2839 | return result; |
| 2840 | } |
| 2841 | |
| 2842 | JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const RTCStatsReport::PeerConnectionStats& dictionary) |
| 2843 | { |
| 2844 | auto& vm = state.vm(); |
| 2845 | |
| 2846 | auto result = constructEmptyObject(&state, globalObject.objectPrototype()); |
| 2847 | |
| 2848 | if (!IDLDOMString::isNullValue(dictionary.id)) { |
| 2849 | auto idValue = toJS<IDLDOMString>(state, IDLDOMString::extractValueFromNullable(dictionary.id)); |
| 2850 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "id" ), idValue); |
| 2851 | } |
| 2852 | if (!IDLDouble::isNullValue(dictionary.timestamp)) { |
| 2853 | auto timestampValue = toJS<IDLDouble>(IDLDouble::extractValueFromNullable(dictionary.timestamp)); |
| 2854 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "timestamp" ), timestampValue); |
| 2855 | } |
| 2856 | if (!IDLEnumeration<RTCStatsReport::Type>::isNullValue(dictionary.type)) { |
| 2857 | auto typeValue = toJS<IDLEnumeration<RTCStatsReport::Type>>(state, IDLEnumeration<RTCStatsReport::Type>::extractValueFromNullable(dictionary.type)); |
| 2858 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "type" ), typeValue); |
| 2859 | } |
| 2860 | if (!IDLUnsignedLong::isNullValue(dictionary.dataChannelsClosed)) { |
| 2861 | auto dataChannelsClosedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.dataChannelsClosed)); |
| 2862 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "dataChannelsClosed" ), dataChannelsClosedValue); |
| 2863 | } |
| 2864 | if (!IDLUnsignedLong::isNullValue(dictionary.dataChannelsOpened)) { |
| 2865 | auto dataChannelsOpenedValue = toJS<IDLUnsignedLong>(IDLUnsignedLong::extractValueFromNullable(dictionary.dataChannelsOpened)); |
| 2866 | result->putDirect(vm, JSC::Identifier::fromString(&vm, "dataChannelsOpened" ), dataChannelsOpenedValue); |
| 2867 | } |
| 2868 | return result; |
| 2869 | } |
| 2870 | |
| 2871 | // Functions |
| 2872 | |
| 2873 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionGet(JSC::ExecState*); |
| 2874 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionHas(JSC::ExecState*); |
| 2875 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionEntries(JSC::ExecState*); |
| 2876 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionKeys(JSC::ExecState*); |
| 2877 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionValues(JSC::ExecState*); |
| 2878 | JSC::EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionForEach(JSC::ExecState*); |
| 2879 | |
| 2880 | // Attributes |
| 2881 | |
| 2882 | JSC::EncodedJSValue jsRTCStatsReportConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 2883 | bool setJSRTCStatsReportConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
| 2884 | JSC::EncodedJSValue jsRTCStatsReportSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
| 2885 | |
| 2886 | class JSRTCStatsReportPrototype : public JSC::JSNonFinalObject { |
| 2887 | public: |
| 2888 | using Base = JSC::JSNonFinalObject; |
| 2889 | static JSRTCStatsReportPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
| 2890 | { |
| 2891 | JSRTCStatsReportPrototype* ptr = new (NotNull, JSC::allocateCell<JSRTCStatsReportPrototype>(vm.heap)) JSRTCStatsReportPrototype(vm, globalObject, structure); |
| 2892 | ptr->finishCreation(vm); |
| 2893 | return ptr; |
| 2894 | } |
| 2895 | |
| 2896 | DECLARE_INFO; |
| 2897 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
| 2898 | { |
| 2899 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
| 2900 | } |
| 2901 | |
| 2902 | private: |
| 2903 | JSRTCStatsReportPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
| 2904 | : JSC::JSNonFinalObject(vm, structure) |
| 2905 | { |
| 2906 | } |
| 2907 | |
| 2908 | void finishCreation(JSC::VM&); |
| 2909 | }; |
| 2910 | |
| 2911 | using JSRTCStatsReportConstructor = JSDOMConstructorNotConstructable<JSRTCStatsReport>; |
| 2912 | |
| 2913 | template<> JSValue JSRTCStatsReportConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
| 2914 | { |
| 2915 | UNUSED_PARAM(vm); |
| 2916 | return globalObject.functionPrototype(); |
| 2917 | } |
| 2918 | |
| 2919 | template<> void JSRTCStatsReportConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
| 2920 | { |
| 2921 | putDirect(vm, vm.propertyNames->prototype, JSRTCStatsReport::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 2922 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("RTCStatsReport"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 2923 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
| 2924 | } |
| 2925 | |
| 2926 | template<> const ClassInfo JSRTCStatsReportConstructor::s_info = { "RTCStatsReport" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCStatsReportConstructor) }; |
| 2927 | |
| 2928 | /* Hash table for prototype */ |
| 2929 | |
| 2930 | static const HashTableValue JSRTCStatsReportPrototypeTableValues[] = |
| 2931 | { |
| 2932 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCStatsReportConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSRTCStatsReportConstructor) } }, |
| 2933 | { "size" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsRTCStatsReportSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
| 2934 | { "get" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCStatsReportPrototypeFunctionGet), (intptr_t) (1) } }, |
| 2935 | { "has" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCStatsReportPrototypeFunctionHas), (intptr_t) (1) } }, |
| 2936 | { "entries" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCStatsReportPrototypeFunctionEntries), (intptr_t) (0) } }, |
| 2937 | { "keys" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCStatsReportPrototypeFunctionKeys), (intptr_t) (0) } }, |
| 2938 | { "values" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCStatsReportPrototypeFunctionValues), (intptr_t) (0) } }, |
| 2939 | { "forEach" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsRTCStatsReportPrototypeFunctionForEach), (intptr_t) (1) } }, |
| 2940 | }; |
| 2941 | |
| 2942 | const ClassInfo JSRTCStatsReportPrototype::s_info = { "RTCStatsReportPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCStatsReportPrototype) }; |
| 2943 | |
| 2944 | void JSRTCStatsReportPrototype::finishCreation(VM& vm) |
| 2945 | { |
| 2946 | Base::finishCreation(vm); |
| 2947 | reifyStaticProperties(vm, JSRTCStatsReport::info(), JSRTCStatsReportPrototypeTableValues, *this); |
| 2948 | putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
| 2949 | } |
| 2950 | |
| 2951 | const ClassInfo JSRTCStatsReport::s_info = { "RTCStatsReport" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSRTCStatsReport) }; |
| 2952 | |
| 2953 | JSRTCStatsReport::JSRTCStatsReport(Structure* structure, JSDOMGlobalObject& globalObject, Ref<RTCStatsReport>&& impl) |
| 2954 | : JSDOMWrapper<RTCStatsReport>(structure, globalObject, WTFMove(impl)) |
| 2955 | { |
| 2956 | } |
| 2957 | |
| 2958 | void JSRTCStatsReport::finishCreation(VM& vm) |
| 2959 | { |
| 2960 | Base::finishCreation(vm); |
| 2961 | ASSERT(inherits(vm, info())); |
| 2962 | |
| 2963 | synchronizeBackingMap(*globalObject()->globalExec(), *globalObject(), *this); |
| 2964 | } |
| 2965 | |
| 2966 | JSObject* JSRTCStatsReport::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 2967 | { |
| 2968 | return JSRTCStatsReportPrototype::create(vm, &globalObject, JSRTCStatsReportPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
| 2969 | } |
| 2970 | |
| 2971 | JSObject* JSRTCStatsReport::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
| 2972 | { |
| 2973 | return getDOMPrototype<JSRTCStatsReport>(vm, globalObject); |
| 2974 | } |
| 2975 | |
| 2976 | JSValue JSRTCStatsReport::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
| 2977 | { |
| 2978 | return getDOMConstructor<JSRTCStatsReportConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
| 2979 | } |
| 2980 | |
| 2981 | void JSRTCStatsReport::destroy(JSC::JSCell* cell) |
| 2982 | { |
| 2983 | JSRTCStatsReport* thisObject = static_cast<JSRTCStatsReport*>(cell); |
| 2984 | thisObject->JSRTCStatsReport::~JSRTCStatsReport(); |
| 2985 | } |
| 2986 | |
| 2987 | template<> inline JSRTCStatsReport* IDLAttribute<JSRTCStatsReport>::cast(ExecState& state, EncodedJSValue thisValue) |
| 2988 | { |
| 2989 | return jsDynamicCast<JSRTCStatsReport*>(state.vm(), JSValue::decode(thisValue)); |
| 2990 | } |
| 2991 | |
| 2992 | template<> inline JSRTCStatsReport* IDLOperation<JSRTCStatsReport>::cast(ExecState& state) |
| 2993 | { |
| 2994 | return jsDynamicCast<JSRTCStatsReport*>(state.vm(), state.thisValue()); |
| 2995 | } |
| 2996 | |
| 2997 | EncodedJSValue jsRTCStatsReportConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 2998 | { |
| 2999 | VM& vm = state->vm(); |
| 3000 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 3001 | auto* prototype = jsDynamicCast<JSRTCStatsReportPrototype*>(vm, JSValue::decode(thisValue)); |
| 3002 | if (UNLIKELY(!prototype)) |
| 3003 | return throwVMTypeError(state, throwScope); |
| 3004 | return JSValue::encode(JSRTCStatsReport::getConstructor(state->vm(), prototype->globalObject())); |
| 3005 | } |
| 3006 | |
| 3007 | bool setJSRTCStatsReportConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
| 3008 | { |
| 3009 | VM& vm = state->vm(); |
| 3010 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
| 3011 | auto* prototype = jsDynamicCast<JSRTCStatsReportPrototype*>(vm, JSValue::decode(thisValue)); |
| 3012 | if (UNLIKELY(!prototype)) { |
| 3013 | throwVMTypeError(state, throwScope); |
| 3014 | return false; |
| 3015 | } |
| 3016 | // Shadowing a built-in constructor |
| 3017 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
| 3018 | } |
| 3019 | |
| 3020 | static inline JSValue jsRTCStatsReportSizeGetter(ExecState& state, JSRTCStatsReport& thisObject, ThrowScope& throwScope) |
| 3021 | { |
| 3022 | UNUSED_PARAM(throwScope); |
| 3023 | UNUSED_PARAM(state); |
| 3024 | JSValue result = toJS<IDLAny>(state, throwScope, forwardSizeToMapLike(state, thisObject)); |
| 3025 | return result; |
| 3026 | } |
| 3027 | |
| 3028 | EncodedJSValue jsRTCStatsReportSize(ExecState* state, EncodedJSValue thisValue, PropertyName) |
| 3029 | { |
| 3030 | return IDLAttribute<JSRTCStatsReport>::get<jsRTCStatsReportSizeGetter>(*state, thisValue, "size" ); |
| 3031 | } |
| 3032 | |
| 3033 | static inline JSC::EncodedJSValue jsRTCStatsReportPrototypeFunctionGetBody(JSC::ExecState* state, typename IDLOperation<JSRTCStatsReport>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 3034 | { |
| 3035 | UNUSED_PARAM(state); |
| 3036 | UNUSED_PARAM(throwScope); |
| 3037 | if (UNLIKELY(state->argumentCount() < 1)) |
| 3038 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 3039 | auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 3040 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 3041 | return JSValue::encode(toJS<IDLAny>(forwardGetToMapLike(*state, *castedThis, WTFMove(key)))); |
| 3042 | } |
| 3043 | |
| 3044 | EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionGet(ExecState* state) |
| 3045 | { |
| 3046 | return IDLOperation<JSRTCStatsReport>::call<jsRTCStatsReportPrototypeFunctionGetBody>(*state, "get" ); |
| 3047 | } |
| 3048 | |
| 3049 | static inline JSC::EncodedJSValue jsRTCStatsReportPrototypeFunctionHasBody(JSC::ExecState* state, typename IDLOperation<JSRTCStatsReport>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 3050 | { |
| 3051 | UNUSED_PARAM(state); |
| 3052 | UNUSED_PARAM(throwScope); |
| 3053 | if (UNLIKELY(state->argumentCount() < 1)) |
| 3054 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 3055 | auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
| 3056 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 3057 | return JSValue::encode(toJS<IDLAny>(forwardHasToMapLike(*state, *castedThis, WTFMove(key)))); |
| 3058 | } |
| 3059 | |
| 3060 | EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionHas(ExecState* state) |
| 3061 | { |
| 3062 | return IDLOperation<JSRTCStatsReport>::call<jsRTCStatsReportPrototypeFunctionHasBody>(*state, "has" ); |
| 3063 | } |
| 3064 | |
| 3065 | static inline JSC::EncodedJSValue jsRTCStatsReportPrototypeFunctionEntriesBody(JSC::ExecState* state, typename IDLOperation<JSRTCStatsReport>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 3066 | { |
| 3067 | UNUSED_PARAM(state); |
| 3068 | UNUSED_PARAM(throwScope); |
| 3069 | return JSValue::encode(toJS<IDLAny>(forwardEntriesToMapLike(*state, *castedThis))); |
| 3070 | } |
| 3071 | |
| 3072 | EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionEntries(ExecState* state) |
| 3073 | { |
| 3074 | return IDLOperation<JSRTCStatsReport>::call<jsRTCStatsReportPrototypeFunctionEntriesBody>(*state, "entries" ); |
| 3075 | } |
| 3076 | |
| 3077 | static inline JSC::EncodedJSValue jsRTCStatsReportPrototypeFunctionKeysBody(JSC::ExecState* state, typename IDLOperation<JSRTCStatsReport>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 3078 | { |
| 3079 | UNUSED_PARAM(state); |
| 3080 | UNUSED_PARAM(throwScope); |
| 3081 | return JSValue::encode(toJS<IDLAny>(forwardKeysToMapLike(*state, *castedThis))); |
| 3082 | } |
| 3083 | |
| 3084 | EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionKeys(ExecState* state) |
| 3085 | { |
| 3086 | return IDLOperation<JSRTCStatsReport>::call<jsRTCStatsReportPrototypeFunctionKeysBody>(*state, "keys" ); |
| 3087 | } |
| 3088 | |
| 3089 | static inline JSC::EncodedJSValue jsRTCStatsReportPrototypeFunctionValuesBody(JSC::ExecState* state, typename IDLOperation<JSRTCStatsReport>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 3090 | { |
| 3091 | UNUSED_PARAM(state); |
| 3092 | UNUSED_PARAM(throwScope); |
| 3093 | return JSValue::encode(toJS<IDLAny>(forwardValuesToMapLike(*state, *castedThis))); |
| 3094 | } |
| 3095 | |
| 3096 | EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionValues(ExecState* state) |
| 3097 | { |
| 3098 | return IDLOperation<JSRTCStatsReport>::call<jsRTCStatsReportPrototypeFunctionValuesBody>(*state, "values" ); |
| 3099 | } |
| 3100 | |
| 3101 | static inline JSC::EncodedJSValue jsRTCStatsReportPrototypeFunctionForEachBody(JSC::ExecState* state, typename IDLOperation<JSRTCStatsReport>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
| 3102 | { |
| 3103 | UNUSED_PARAM(state); |
| 3104 | UNUSED_PARAM(throwScope); |
| 3105 | if (UNLIKELY(state->argumentCount() < 1)) |
| 3106 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
| 3107 | auto callback = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
| 3108 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
| 3109 | return JSValue::encode(toJS<IDLAny>(forwardForEachToMapLike(*state, *castedThis, WTFMove(callback)))); |
| 3110 | } |
| 3111 | |
| 3112 | EncodedJSValue JSC_HOST_CALL jsRTCStatsReportPrototypeFunctionForEach(ExecState* state) |
| 3113 | { |
| 3114 | return IDLOperation<JSRTCStatsReport>::call<jsRTCStatsReportPrototypeFunctionForEachBody>(*state, "forEach" ); |
| 3115 | } |
| 3116 | |
| 3117 | void JSRTCStatsReport::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
| 3118 | { |
| 3119 | auto* thisObject = jsCast<JSRTCStatsReport*>(cell); |
| 3120 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
| 3121 | if (thisObject->scriptExecutionContext()) |
| 3122 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
| 3123 | Base::heapSnapshot(cell, builder); |
| 3124 | } |
| 3125 | |
| 3126 | bool JSRTCStatsReportOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
| 3127 | { |
| 3128 | UNUSED_PARAM(handle); |
| 3129 | UNUSED_PARAM(visitor); |
| 3130 | UNUSED_PARAM(reason); |
| 3131 | return false; |
| 3132 | } |
| 3133 | |
| 3134 | void JSRTCStatsReportOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
| 3135 | { |
| 3136 | auto* jsRTCStatsReport = static_cast<JSRTCStatsReport*>(handle.slot()->asCell()); |
| 3137 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
| 3138 | uncacheWrapper(world, &jsRTCStatsReport->wrapped(), jsRTCStatsReport); |
| 3139 | } |
| 3140 | |
| 3141 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<RTCStatsReport>&& impl) |
| 3142 | { |
| 3143 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
| 3144 | // attribute. You should remove that attribute. If the class has subclasses |
| 3145 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
| 3146 | // attribute to RTCStatsReport. |
| 3147 | static_assert(!std::is_polymorphic<RTCStatsReport>::value, "RTCStatsReport is polymorphic but the IDL claims it is not" ); |
| 3148 | return createWrapper<RTCStatsReport>(globalObject, WTFMove(impl)); |
| 3149 | } |
| 3150 | |
| 3151 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RTCStatsReport& impl) |
| 3152 | { |
| 3153 | return wrap(state, globalObject, impl); |
| 3154 | } |
| 3155 | |
| 3156 | RTCStatsReport* JSRTCStatsReport::toWrapped(JSC::VM& vm, JSC::JSValue value) |
| 3157 | { |
| 3158 | if (auto* wrapper = jsDynamicCast<JSRTCStatsReport*>(vm, value)) |
| 3159 | return &wrapper->wrapped(); |
| 3160 | return nullptr; |
| 3161 | } |
| 3162 | |
| 3163 | } |
| 3164 | |
| 3165 | #endif // ENABLE(WEB_RTC) |
| 3166 | |