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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
266 RTCPeerConnection::~RTCPeerConnection() | 266 RTCPeerConnection::~RTCPeerConnection() |
267 { | 267 { |
268 // This checks that close() or stop() is called before the destructor. | 268 // This checks that close() or stop() is called before the destructor. |
269 // We are assuming that a wrapper is always created when RTCPeerConnection i
s created. | 269 // We are assuming that a wrapper is always created when RTCPeerConnection i
s created. |
270 ASSERT(m_closed || m_stopped); | 270 ASSERT(m_closed || m_stopped); |
271 } | 271 } |
272 | 272 |
273 void RTCPeerConnection::createOffer(PassOwnPtrWillBeRawPtr<RTCSessionDescription
Callback> successCallback, PassOwnPtrWillBeRawPtr<RTCErrorCallback> errorCallbac
k, const Dictionary& rtcOfferOptions, ExceptionState& exceptionState) | 273 void RTCPeerConnection::createOffer(RTCSessionDescriptionCallback* successCallba
ck, RTCErrorCallback* errorCallback, const Dictionary& rtcOfferOptions, Exceptio
nState& exceptionState) |
274 { | 274 { |
275 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 275 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
276 return; | 276 return; |
277 | 277 |
278 ASSERT(successCallback); | 278 ASSERT(successCallback); |
279 | 279 |
280 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); | 280 RTCOfferOptions* offerOptions = parseOfferOptions(rtcOfferOptions, exception
State); |
281 if (exceptionState.hadException()) | 281 if (exceptionState.hadException()) |
282 return; | 282 return; |
283 | 283 |
284 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 284 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); |
285 | 285 |
286 if (offerOptions) { | 286 if (offerOptions) { |
287 m_peerHandler->createOffer(request, offerOptions); | 287 m_peerHandler->createOffer(request, offerOptions); |
288 } else { | 288 } else { |
289 WebMediaConstraints constraints = MediaConstraintsImpl::create(rtcOfferO
ptions, exceptionState); | 289 WebMediaConstraints constraints = MediaConstraintsImpl::create(rtcOfferO
ptions, exceptionState); |
290 if (exceptionState.hadException()) | 290 if (exceptionState.hadException()) |
291 return; | 291 return; |
292 | 292 |
293 m_peerHandler->createOffer(request, constraints); | 293 m_peerHandler->createOffer(request, constraints); |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 void RTCPeerConnection::createAnswer(PassOwnPtrWillBeRawPtr<RTCSessionDescriptio
nCallback> successCallback, PassOwnPtrWillBeRawPtr<RTCErrorCallback> errorCallba
ck, const Dictionary& mediaConstraints, ExceptionState& exceptionState) | 297 void RTCPeerConnection::createAnswer(RTCSessionDescriptionCallback* successCallb
ack, RTCErrorCallback* errorCallback, const Dictionary& mediaConstraints, Except
ionState& exceptionState) |
298 { | 298 { |
299 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 299 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
300 return; | 300 return; |
301 | 301 |
302 ASSERT(successCallback); | 302 ASSERT(successCallback); |
303 | 303 |
304 WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstrai
nts, exceptionState); | 304 WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstrai
nts, exceptionState); |
305 if (exceptionState.hadException()) | 305 if (exceptionState.hadException()) |
306 return; | 306 return; |
307 | 307 |
308 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); | 308 RTCSessionDescriptionRequest* request = RTCSessionDescriptionRequestImpl::cr
eate(executionContext(), this, successCallback, errorCallback); |
309 m_peerHandler->createAnswer(request, constraints); | 309 m_peerHandler->createAnswer(request, constraints); |
310 } | 310 } |
311 | 311 |
312 void RTCPeerConnection::setLocalDescription(RTCSessionDescription* sessionDescri
ption, PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRaw
Ptr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) | 312 void RTCPeerConnection::setLocalDescription(RTCSessionDescription* sessionDescri
ption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exception
State& exceptionState) |
313 { | 313 { |
314 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 314 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
315 return; | 315 return; |
316 | 316 |
317 if (!sessionDescription) { | 317 if (!sessionDescription) { |
318 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 318 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
319 return; | 319 return; |
320 } | 320 } |
321 | 321 |
322 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 322 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); |
323 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); | 323 m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDe
scription()); |
324 } | 324 } |
325 | 325 |
326 RTCSessionDescription* RTCPeerConnection::localDescription(ExceptionState& excep
tionState) | 326 RTCSessionDescription* RTCPeerConnection::localDescription(ExceptionState& excep
tionState) |
327 { | 327 { |
328 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); | 328 WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescrip
tion(); |
329 if (webSessionDescription.isNull()) | 329 if (webSessionDescription.isNull()) |
330 return nullptr; | 330 return nullptr; |
331 | 331 |
332 return RTCSessionDescription::create(webSessionDescription); | 332 return RTCSessionDescription::create(webSessionDescription); |
333 } | 333 } |
334 | 334 |
335 void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr
iption, PassOwnPtrWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRa
wPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) | 335 void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr
iption, VoidCallback* successCallback, RTCErrorCallback* errorCallback, Exceptio
nState& exceptionState) |
336 { | 336 { |
337 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 337 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
338 return; | 338 return; |
339 | 339 |
340 if (!sessionDescription) { | 340 if (!sessionDescription) { |
341 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 341 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
342 return; | 342 return; |
343 } | 343 } |
344 | 344 |
345 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); | 345 RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), thi
s, successCallback, errorCallback); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (!iceCandidate) { | 381 if (!iceCandidate) { |
382 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); | 382 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); |
383 return; | 383 return; |
384 } | 384 } |
385 | 385 |
386 bool valid = m_peerHandler->addICECandidate(iceCandidate->webCandidate()); | 386 bool valid = m_peerHandler->addICECandidate(iceCandidate->webCandidate()); |
387 if (!valid) | 387 if (!valid) |
388 exceptionState.throwDOMException(SyntaxError, "The ICE candidate could n
ot be added."); | 388 exceptionState.throwDOMException(SyntaxError, "The ICE candidate could n
ot be added."); |
389 } | 389 } |
390 | 390 |
391 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, PassOwnPt
rWillBeRawPtr<VoidCallback> successCallback, PassOwnPtrWillBeRawPtr<RTCErrorCall
back> errorCallback, ExceptionState& exceptionState) | 391 void RTCPeerConnection::addIceCandidate(RTCIceCandidate* iceCandidate, VoidCallb
ack* successCallback, RTCErrorCallback* errorCallback, ExceptionState& exception
State) |
392 { | 392 { |
393 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 393 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
394 return; | 394 return; |
395 | 395 |
396 if (!iceCandidate) { | 396 if (!iceCandidate) { |
397 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); | 397 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); |
398 return; | 398 return; |
399 } | 399 } |
400 ASSERT(successCallback); | 400 ASSERT(successCallback); |
401 ASSERT(errorCallback); | 401 ASSERT(errorCallback); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } | 528 } |
529 | 529 |
530 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r
emoteStreams.end(); ++iter) { | 530 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r
emoteStreams.end(); ++iter) { |
531 if ((*iter)->id() == streamId) | 531 if ((*iter)->id() == streamId) |
532 return iter->get(); | 532 return iter->get(); |
533 } | 533 } |
534 | 534 |
535 return 0; | 535 return 0; |
536 } | 536 } |
537 | 537 |
538 void RTCPeerConnection::getStats(PassOwnPtrWillBeRawPtr<RTCStatsCallback> succes
sCallback, MediaStreamTrack* selector) | 538 void RTCPeerConnection::getStats(RTCStatsCallback* successCallback, MediaStreamT
rack* selector) |
539 { | 539 { |
540 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(executionContext
(), this, successCallback, selector); | 540 RTCStatsRequest* statsRequest = RTCStatsRequestImpl::create(executionContext
(), this, successCallback, selector); |
541 // FIXME: Add passing selector as part of the statsRequest. | 541 // FIXME: Add passing selector as part of the statsRequest. |
542 m_peerHandler->getStats(statsRequest); | 542 m_peerHandler->getStats(statsRequest); |
543 } | 543 } |
544 | 544 |
545 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) | 545 RTCDataChannel* RTCPeerConnection::createDataChannel(String label, const Diction
ary& options, ExceptionState& exceptionState) |
546 { | 546 { |
547 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 547 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
548 return nullptr; | 548 return nullptr; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 visitor->trace(m_localStreams); | 805 visitor->trace(m_localStreams); |
806 visitor->trace(m_remoteStreams); | 806 visitor->trace(m_remoteStreams); |
807 visitor->trace(m_dataChannels); | 807 visitor->trace(m_dataChannels); |
808 #if ENABLE(OILPAN) | 808 #if ENABLE(OILPAN) |
809 visitor->trace(m_scheduledEvents); | 809 visitor->trace(m_scheduledEvents); |
810 #endif | 810 #endif |
811 EventTargetWithInlineData::trace(visitor); | 811 EventTargetWithInlineData::trace(visitor); |
812 } | 812 } |
813 | 813 |
814 } // namespace blink | 814 } // namespace blink |
OLD | NEW |