Chromium Code Reviews| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 return 0; | 352 return 0; |
| 353 } | 353 } |
| 354 | 354 |
| 355 rtcConfiguration->appendCertificate(certificate->certificateShallowC opy()); | 355 rtcConfiguration->appendCertificate(certificate->certificateShallowC opy()); |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 | 358 |
| 359 return rtcConfiguration; | 359 return rtcConfiguration; |
| 360 } | 360 } |
| 361 | 361 |
| 362 RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, ExceptionState& exceptionState) | 362 RTCOfferOptions* RTCPeerConnection::parseOfferOptions(const Dictionary& options, RTCErrorCallback* errorCallback, bool& hadError) |
| 363 { | 363 { |
| 364 hadError = false; | |
| 364 if (options.isUndefinedOrNull()) | 365 if (options.isUndefinedOrNull()) |
| 365 return 0; | 366 return 0; |
| 366 | 367 |
| 367 Vector<String> propertyNames; | 368 Vector<String> propertyNames; |
| 368 options.getPropertyNames(propertyNames); | 369 options.getPropertyNames(propertyNames); |
| 369 | 370 |
| 370 // Treat |options| as MediaConstraints if it is empty or has "optional" or " mandatory" properties for compatibility. | 371 // Treat |options| as MediaConstraints if it is empty or has "optional" or " mandatory" properties for compatibility. |
| 371 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and c lient code is ready. | 372 // TODO(jiayl): remove constraints when RTCOfferOptions reaches Stable and c lient code is ready. |
| 372 if (propertyNames.isEmpty() || propertyNames.contains("optional") || propert yNames.contains("mandatory")) | 373 if (propertyNames.isEmpty() || propertyNames.contains("optional") || propert yNames.contains("mandatory")) |
| 373 return 0; | 374 return 0; |
| 374 | 375 |
| 375 int32_t offerToReceiveVideo = -1; | 376 int32_t offerToReceiveVideo = -1; |
| 376 int32_t offerToReceiveAudio = -1; | 377 int32_t offerToReceiveAudio = -1; |
| 377 bool voiceActivityDetection = true; | 378 bool voiceActivityDetection = true; |
| 378 bool iceRestart = false; | 379 bool iceRestart = false; |
| 379 | 380 |
| 380 if (DictionaryHelper::get(options, "offerToReceiveVideo", offerToReceiveVide o) && offerToReceiveVideo < 0) { | 381 if (DictionaryHelper::get(options, "offerToReceiveVideo", offerToReceiveVide o) && offerToReceiveVideo < 0) { |
| 381 exceptionState.throwTypeError("Invalid offerToReceiveVideo"); | 382 asyncCallErrorCallback(errorCallback, "Invalid offerToReceiveVideo"); |
|
philipj_slow
2016/02/22 10:03:41
Before this would throw a TypeError, and if I'm re
Guido Urdaneta
2016/02/22 11:37:50
Yes. The spec uses RTCPeerConnectionErrorCallback,
| |
| 383 hadError = true; | |
| 382 return 0; | 384 return 0; |
| 383 } | 385 } |
| 384 | 386 |
| 385 if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudi o) && offerToReceiveAudio < 0) { | 387 if (DictionaryHelper::get(options, "offerToReceiveAudio", offerToReceiveAudi o) && offerToReceiveAudio < 0) { |
| 386 exceptionState.throwTypeError("Invalid offerToReceiveAudio"); | 388 asyncCallErrorCallback(errorCallback, "Invalid offerToReceiveAudio"); |
| 389 hadError = true; | |
| 387 return 0; | 390 return 0; |
| 388 } | 391 } |
| 389 | 392 |
| 390 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect ion); | 393 DictionaryHelper::get(options, "voiceActivityDetection", voiceActivityDetect ion); |
| 391 DictionaryHelper::get(options, "iceRestart", iceRestart); | 394 DictionaryHelper::get(options, "iceRestart", iceRestart); |
| 392 | 395 |
| 393 RTCOfferOptions* rtcOfferOptions = RTCOfferOptions::create(offerToReceiveVid eo, offerToReceiveAudio, voiceActivityDetection, iceRestart); | 396 RTCOfferOptions* rtcOfferOptions = RTCOfferOptions::create(offerToReceiveVid eo, offerToReceiveAudio, voiceActivityDetection, iceRestart); |
| 394 return rtcOfferOptions; | 397 return rtcOfferOptions; |
| 395 } | 398 } |
| 396 | 399 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 458 } | 461 } |
| 459 } | 462 } |
| 460 | 463 |
| 461 RTCPeerConnection::~RTCPeerConnection() | 464 RTCPeerConnection::~RTCPeerConnection() |
| 462 { | 465 { |
| 463 // This checks that close() or stop() is called before the destructor. | 466 // This checks that close() or stop() is called before the destructor. |
| 464 // We are assuming that a wrapper is always created when RTCPeerConnection i s created. | 467 // We are assuming that a wrapper is always created when RTCPeerConnection i s created. |
| 465 ASSERT(m_closed || m_stopped); | 468 ASSERT(m_closed || m_stopped); |
| 466 } | 469 } |
| 467 | 470 |
| 468 void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip tionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionary & rtcOfferOptions, ExceptionState& exceptionState) | 471 void RTCPeerConnection::createOffer(ExecutionContext* context, RTCSessionDescrip tionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionary & rtcOfferOptions) |
| 469 { | 472 { |
| 470 if (errorCallback) | 473 ASSERT(successCallback); |
| 471 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegac yFailureCallback); | 474 ASSERT(errorCallback); |
|
philipj_slow
2016/02/22 10:03:41
The nullability of errorCallback didn't change wit
Guido Urdaneta
2016/02/22 11:37:50
Correct. There was a previous CL making the error
philipj_slow
2016/02/23 09:13:54
Sounds fine to do here, just checking.
| |
| 472 else | 475 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferLegacyFai lureCallback); |
| 473 Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCrea teOfferLegacyNoFailureCallback); | 476 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) ) |
| 474 | |
| 475 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | |
| 476 return; | 477 return; |
| 477 | 478 |
| 478 ASSERT(successCallback); | 479 bool hadOfferOptionsError = false; |
| 479 | 480 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, errorCall back, hadOfferOptionsError); |
| 480 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception State); | 481 if (hadOfferOptionsError) |
| 481 if (exceptionState.hadException()) | |
| 482 return; | 482 return; |
| 483 | 483 |
| 484 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback); | 484 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback); |
| 485 | 485 |
| 486 if (offerOptions) { | 486 if (offerOptions) { |
| 487 if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToRe ceiveVideo() != -1) | 487 if (offerOptions->offerToReceiveAudio() != -1 || offerOptions->offerToRe ceiveVideo() != -1) |
| 488 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyOfferOptions); | 488 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyOfferOptions); |
| 489 else if (errorCallback) | 489 else |
| 490 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyCompliant); | 490 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyCompliant); |
| 491 | 491 |
| 492 m_peerHandler->createOffer(request, offerOptions); | 492 m_peerHandler->createOffer(request, offerOptions); |
| 493 } else { | 493 } else { |
| 494 MediaErrorState mediaErrorState; | 494 MediaErrorState mediaErrorState; |
| 495 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, rtcOfferOptions, mediaErrorState); | 495 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, rtcOfferOptions, mediaErrorState); |
| 496 if (mediaErrorState.hadException()) { | 496 if (mediaErrorState.hadException()) { |
| 497 mediaErrorState.raiseException(exceptionState); | 497 String errorMsg = mediaErrorState.getErrorMessage(); |
| 498 asyncCallErrorCallback(errorCallback, errorMsg); | |
| 498 return; | 499 return; |
| 499 } | 500 } |
| 500 | 501 |
| 501 if (!constraints.isEmpty()) | 502 if (!constraints.isEmpty()) |
| 502 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyConstraints); | 503 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyConstraints); |
| 503 else if (errorCallback) | 504 else |
| 504 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyCompliant); | 505 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateOfferL egacyCompliant); |
| 505 | 506 |
| 506 m_peerHandler->createOffer(request, constraints); | 507 m_peerHandler->createOffer(request, constraints); |
| 507 } | 508 } |
| 508 } | 509 } |
| 509 | 510 |
| 510 void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescri ptionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionar y& mediaConstraints, ExceptionState& exceptionState) | 511 void RTCPeerConnection::createAnswer(ExecutionContext* context, RTCSessionDescri ptionCallback* successCallback, RTCErrorCallback* errorCallback, const Dictionar y& mediaConstraints) |
| 511 { | 512 { |
| 512 if (errorCallback) | 513 ASSERT(successCallback); |
| 513 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega cyFailureCallback); | 514 ASSERT(errorCallback); |
| 514 else | 515 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLegacyFa ilureCallback); |
| 515 Deprecation::countDeprecation(context, UseCounter::RTCPeerConnectionCrea teAnswerLegacyNoFailureCallback); | |
| 516 | |
| 517 if (mediaConstraints.isObject()) | 516 if (mediaConstraints.isObject()) |
| 518 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega cyConstraints); | 517 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega cyConstraints); |
| 519 else if (errorCallback) | 518 else |
| 520 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega cyCompliant); | 519 UseCounter::count(context, UseCounter::RTCPeerConnectionCreateAnswerLega cyCompliant); |
| 521 | 520 |
| 522 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 521 if (callErrorCallbackIfSignalingStateClosed(m_signalingState, errorCallback) ) |
| 523 return; | 522 return; |
| 524 | 523 |
| 525 ASSERT(successCallback); | |
| 526 | |
| 527 MediaErrorState mediaErrorState; | 524 MediaErrorState mediaErrorState; |
| 528 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi aConstraints, mediaErrorState); | 525 WebMediaConstraints constraints = MediaConstraintsImpl::create(context, medi aConstraints, mediaErrorState); |
| 529 if (mediaErrorState.hadException()) { | 526 if (mediaErrorState.hadException()) { |
| 530 mediaErrorState.raiseException(exceptionState); | 527 String errorMsg = mediaErrorState.getErrorMessage(); |
| 528 asyncCallErrorCallback(errorCallback, errorMsg); | |
| 531 return; | 529 return; |
| 532 } | 530 } |
| 533 | 531 |
| 534 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback); | 532 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr eate(executionContext(), this, successCallback, errorCallback); |
| 535 m_peerHandler->createAnswer(request, constraints); | 533 m_peerHandler->createAnswer(request, constraints); |
| 536 } | 534 } |
| 537 | 535 |
| 538 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c onst RTCSessionDescriptionInit& sessionDescriptionInit) | 536 ScriptPromise RTCPeerConnection::setLocalDescription(ScriptState* scriptState, c onst RTCSessionDescriptionInit& sessionDescriptionInit) |
| 539 { | 537 { |
| 540 if (m_signalingState == SignalingStateClosed) | 538 if (m_signalingState == SignalingStateClosed) |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1160 { | 1158 { |
| 1161 visitor->trace(m_localStreams); | 1159 visitor->trace(m_localStreams); |
| 1162 visitor->trace(m_remoteStreams); | 1160 visitor->trace(m_remoteStreams); |
| 1163 visitor->trace(m_dispatchScheduledEventRunner); | 1161 visitor->trace(m_dispatchScheduledEventRunner); |
| 1164 visitor->trace(m_scheduledEvents); | 1162 visitor->trace(m_scheduledEvents); |
| 1165 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); | 1163 RefCountedGarbageCollectedEventTargetWithInlineData<RTCPeerConnection>::trac e(visitor); |
| 1166 ActiveDOMObject::trace(visitor); | 1164 ActiveDOMObject::trace(visitor); |
| 1167 } | 1165 } |
| 1168 | 1166 |
| 1169 } // namespace blink | 1167 } // namespace blink |
| OLD | NEW |