| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 certificates.size()); | 339 certificates.size()); |
| 340 for (size_t i = 0; i < certificates.size(); ++i) { | 340 for (size_t i = 0; i < certificates.size(); ++i) { |
| 341 certificatesCopy[i] = certificates[i]->certificateShallowCopy(); | 341 certificatesCopy[i] = certificates[i]->certificateShallowCopy(); |
| 342 } | 342 } |
| 343 webConfiguration.certificates = std::move(certificatesCopy); | 343 webConfiguration.certificates = std::move(certificatesCopy); |
| 344 } | 344 } |
| 345 | 345 |
| 346 return webConfiguration; | 346 return webConfiguration; |
| 347 } | 347 } |
| 348 | 348 |
| 349 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options) { | 349 RTCOfferOptionsPlatform* parseOfferOptions(const Dictionary& options, |
| 350 ExceptionState& exceptionState) { |
| 350 if (options.isUndefinedOrNull()) | 351 if (options.isUndefinedOrNull()) |
| 351 return 0; | 352 return nullptr; |
| 352 | 353 |
| 353 Vector<String> propertyNames; | 354 const Vector<String>& propertyNames = |
| 354 options.getPropertyNames(propertyNames); | 355 options.getPropertyNames(exceptionState); |
| 356 if (exceptionState.hadException()) |
| 357 return nullptr; |
| 355 | 358 |
| 356 // Treat |options| as MediaConstraints if it is empty or has "optional" or | 359 // Treat |options| as MediaConstraints if it is empty or has "optional" or |
| 357 // "mandatory" properties for compatibility. | 360 // "mandatory" properties for compatibility. |
| 358 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and | 361 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and |
| 359 // client code is ready. | 362 // client code is ready. |
| 360 if (propertyNames.isEmpty() || propertyNames.contains("optional") || | 363 if (propertyNames.isEmpty() || propertyNames.contains("optional") || |
| 361 propertyNames.contains("mandatory")) | 364 propertyNames.contains("mandatory")) |
| 362 return 0; | 365 return nullptr; |
| 363 | 366 |
| 364 int32_t offerToReceiveVideo = -1; | 367 int32_t offerToReceiveVideo = -1; |
| 365 int32_t offerToReceiveAudio = -1; | 368 int32_t offerToReceiveAudio = -1; |
| 366 bool voiceActivityDetection = true; | 369 bool voiceActivityDetection = true; |
| 367 bool iceRestart = false; | 370 bool iceRestart = false; |
| 368 | 371 |
| 369 if (DictionaryHelper::get(options, "offerToReceiveVideo", | 372 if (DictionaryHelper::get(options, "offerToReceiveVideo", |
| 370 offerToReceiveVideo) && | 373 offerToReceiveVideo) && |
| 371 offerToReceiveVideo < 0) | 374 offerToReceiveVideo < 0) |
| 372 offerToReceiveVideo = 0; | 375 offerToReceiveVideo = 0; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 context, UseCounter::RTCPeerConnectionCreateOfferOptionsOfferToReceive); | 569 context, UseCounter::RTCPeerConnectionCreateOfferOptionsOfferToReceive); |
| 567 } | 570 } |
| 568 m_peerHandler->createOffer(request, convertToWebRTCOfferOptions(options)); | 571 m_peerHandler->createOffer(request, convertToWebRTCOfferOptions(options)); |
| 569 return promise; | 572 return promise; |
| 570 } | 573 } |
| 571 | 574 |
| 572 ScriptPromise RTCPeerConnection::createOffer( | 575 ScriptPromise RTCPeerConnection::createOffer( |
| 573 ScriptState* scriptState, | 576 ScriptState* scriptState, |
| 574 RTCSessionDescriptionCallback* successCallback, | 577 RTCSessionDescriptionCallback* successCallback, |
| 575 RTCPeerConnectionErrorCallback* errorCallback, | 578 RTCPeerConnectionErrorCallback* errorCallback, |
| 576 const Dictionary& rtcOfferOptions) { | 579 const Dictionary& rtcOfferOptions, |
| 580 ExceptionState& exceptionState) { |
| 577 DCHECK(successCallback); | 581 DCHECK(successCallback); |
| 578 DCHECK(errorCallback); | 582 DCHECK(errorCallback); |
| 579 ExecutionContext* context = scriptState->getExecutionContext(); | 583 ExecutionContext* context = scriptState->getExecutionContext(); |
| 580 UseCounter::count( | 584 UseCounter::count( |
| 581 context, UseCounter::RTCPeerConnectionCreateOfferLegacyFailureCallback); | 585 context, UseCounter::RTCPeerConnectionCreateOfferLegacyFailureCallback); |
| 582 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) | 586 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback)) |
| 583 return ScriptPromise::castUndefined(scriptState); | 587 return ScriptPromise::castUndefined(scriptState); |
| 584 | 588 |
| 585 RTCOfferOptionsPlatform* offerOptions = parseOfferOptions(rtcOfferOptions); | 589 RTCOfferOptionsPlatform* offerOptions = |
| 590 parseOfferOptions(rtcOfferOptions, exceptionState); |
| 591 if (exceptionState.hadException()) |
| 592 return ScriptPromise(); |
| 586 RTCSessionDescriptionRequest* request = | 593 RTCSessionDescriptionRequest* request = |
| 587 RTCSessionDescriptionRequestImpl::create(getExecutionContext(), this, | 594 RTCSessionDescriptionRequestImpl::create(getExecutionContext(), this, |
| 588 successCallback, errorCallback); | 595 successCallback, errorCallback); |
| 589 | 596 |
| 590 if (offerOptions) { | 597 if (offerOptions) { |
| 591 if (offerOptions->offerToReceiveAudio() != -1 || | 598 if (offerOptions->offerToReceiveAudio() != -1 || |
| 592 offerOptions->offerToReceiveVideo() != -1) | 599 offerOptions->offerToReceiveVideo() != -1) |
| 593 UseCounter::count( | 600 UseCounter::count( |
| 594 context, UseCounter::RTCPeerConnectionCreateOfferLegacyOfferOptions); | 601 context, UseCounter::RTCPeerConnectionCreateOfferLegacyOfferOptions); |
| 595 else | 602 else |
| (...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 DEFINE_TRACE(RTCPeerConnection) { | 1491 DEFINE_TRACE(RTCPeerConnection) { |
| 1485 visitor->trace(m_localStreams); | 1492 visitor->trace(m_localStreams); |
| 1486 visitor->trace(m_remoteStreams); | 1493 visitor->trace(m_remoteStreams); |
| 1487 visitor->trace(m_dispatchScheduledEventRunner); | 1494 visitor->trace(m_dispatchScheduledEventRunner); |
| 1488 visitor->trace(m_scheduledEvents); | 1495 visitor->trace(m_scheduledEvents); |
| 1489 EventTargetWithInlineData::trace(visitor); | 1496 EventTargetWithInlineData::trace(visitor); |
| 1490 ActiveDOMObject::trace(visitor); | 1497 ActiveDOMObject::trace(visitor); |
| 1491 } | 1498 } |
| 1492 | 1499 |
| 1493 } // namespace blink | 1500 } // namespace blink |
| OLD | NEW |