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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 return nullptr; | 151 return nullptr; |
| 152 } | 152 } |
| 153 | 153 |
| 154 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential)); | 154 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential)); |
| 155 } | 155 } |
| 156 } | 156 } |
| 157 | 157 |
| 158 return rtcConfiguration.release(); | 158 return rtcConfiguration.release(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionContext* contex t, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, Excep tionState& exceptionState) | 161 PassRefPtrWillBeRawPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionCon text* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstr aints, ExceptionState& exceptionState) |
| 162 { | 162 { |
| 163 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); | 163 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); |
| 164 if (exceptionState.hadException()) | 164 if (exceptionState.hadException()) |
| 165 return nullptr; | 165 return nullptr; |
| 166 | 166 |
| 167 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); | 167 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); |
| 168 if (exceptionState.hadException()) | 168 if (exceptionState.hadException()) |
| 169 return nullptr; | 169 return nullptr; |
| 170 | 170 |
| 171 RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(co ntext, configuration.release(), constraints, exceptionState)); | 171 RefPtrWillBeRawPtr<RTCPeerConnection> peerConnection = adoptRefWillBeRefCoun tedGarbageCollected(new RTCPeerConnection(context, configuration.release(), cons traints, exceptionState)); |
| 172 peerConnection->suspendIfNeeded(); | 172 peerConnection->suspendIfNeeded(); |
| 173 if (exceptionState.hadException()) | 173 if (exceptionState.hadException()) |
| 174 return nullptr; | 174 return nullptr; |
| 175 | 175 |
| 176 return peerConnection.release(); | 176 return peerConnection.release(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState) | 179 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState) |
| 180 : ActiveDOMObject(context) | 180 : ActiveDOMObject(context) |
| 181 , m_signalingState(SignalingStateStable) | 181 , m_signalingState(SignalingStateStable) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 201 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get()); | 201 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get()); |
| 202 | 202 |
| 203 if (!m_peerHandler->initialize(configuration, constraints)) { | 203 if (!m_peerHandler->initialize(configuration, constraints)) { |
| 204 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection."); | 204 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection."); |
| 205 return; | 205 return; |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 RTCPeerConnection::~RTCPeerConnection() | 209 RTCPeerConnection::~RTCPeerConnection() |
| 210 { | 210 { |
| 211 stop(); | 211 stop(); |
|
sof
2014/04/07 14:22:16
Is this dtor call to stop() problematic?
haraken
2014/04/08 04:42:35
This is problematic because stop() touches m_dataC
keishi
2014/04/11 20:03:06
Done.
sof
2014/04/21 19:51:31
Sorry if I missed it, but how do you arrange for R
keishi
2014/05/08 04:15:43
I think this call was unnecessary. RTCPeerConnecti
| |
| 212 } | 212 } |
| 213 | 213 |
| 214 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState) | 214 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState) |
| 215 { | 215 { |
| 216 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 216 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 217 return; | 217 return; |
| 218 | 218 |
| 219 ASSERT(successCallback); | 219 ASSERT(successCallback); |
| 220 | 220 |
| 221 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); | 221 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 234 ASSERT(successCallback); | 234 ASSERT(successCallback); |
| 235 | 235 |
| 236 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); | 236 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); |
| 237 if (exceptionState.hadException()) | 237 if (exceptionState.hadException()) |
| 238 return; | 238 return; |
| 239 | 239 |
| 240 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); | 240 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); |
| 241 m_peerHandler->createAnswer(request.release(), constraints); | 241 m_peerHandler->createAnswer(request.release(), constraints); |
| 242 } | 242 } |
| 243 | 243 |
| 244 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCErr orCallback> errorCallback, ExceptionState& exceptionState) | 244 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) |
| 245 { | 245 { |
| 246 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 246 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 247 return; | 247 return; |
| 248 | 248 |
| 249 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; | 249 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; |
| 250 if (!sessionDescription) { | 250 if (!sessionDescription) { |
| 251 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 251 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
| 252 return; | 252 return; |
| 253 } | 253 } |
| 254 | 254 |
| 255 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); | 255 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); |
| 256 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); | 256 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); |
| 257 } | 257 } |
| 258 | 258 |
| 259 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& exceptionState) | 259 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio n(ExceptionState& exceptionState) |
| 260 { | 260 { |
| 261 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); | 261 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); |
| 262 if (webSessionDescription.isNull()) | 262 if (webSessionDescription.isNull()) |
| 263 return nullptr; | 263 return nullptr; |
| 264 | 264 |
| 265 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription); | 265 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = RTCSessionDes cription::create(webSessionDescription); |
|
sof
2014/04/07 14:22:16
Just return the result here also?
keishi
2014/04/11 20:03:06
Done.
| |
| 266 return sessionDescription.release(); | 266 return sessionDescription.release(); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCEr rorCallback> errorCallback, ExceptionState& exceptionState) | 269 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) |
| 270 { | 270 { |
| 271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 272 return; | 272 return; |
| 273 | 273 |
| 274 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; | 274 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; |
| 275 if (!sessionDescription) { | 275 if (!sessionDescription) { |
| 276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
| 277 return; | 277 return; |
| 278 } | 278 } |
| 279 | 279 |
| 280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); | 280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); |
| 281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); | 281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); |
| 282 } | 282 } |
| 283 | 283 |
| 284 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& exceptionState) | 284 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState) |
| 285 { | 285 { |
| 286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); | 286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); |
| 287 if (webSessionDescription.isNull()) | 287 if (webSessionDescription.isNull()) |
| 288 return nullptr; | 288 return nullptr; |
| 289 | 289 |
| 290 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription); | 290 RefPtrWillBeRawPtr<RTCSessionDescription> desc = RTCSessionDescription::crea te(webSessionDescription); |
|
sof
2014/04/07 14:22:16
It would look tidier just to return this straight.
keishi
2014/04/11 20:03:06
Done.
| |
| 291 return desc.release(); | 291 return desc.release(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) | 294 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) |
| 295 { | 295 { |
| 296 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 296 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 297 return; | 297 return; |
| 298 | 298 |
| 299 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); | 299 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); |
| 300 if (exceptionState.hadException()) | 300 if (exceptionState.hadException()) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 case ICEConnectionStateDisconnected: | 395 case ICEConnectionStateDisconnected: |
| 396 return "disconnected"; | 396 return "disconnected"; |
| 397 case ICEConnectionStateClosed: | 397 case ICEConnectionStateClosed: |
| 398 return "closed"; | 398 return "closed"; |
| 399 } | 399 } |
| 400 | 400 |
| 401 ASSERT_NOT_REACHED(); | 401 ASSERT_NOT_REACHED(); |
| 402 return String(); | 402 return String(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& exceptionState) | 405 void RTCPeerConnection::addStream(PassRefPtrWillBeRawPtr<MediaStream> prpStream, const Dictionary& mediaConstraints, ExceptionState& exceptionState) |
| 406 { | 406 { |
| 407 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 407 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 408 return; | 408 return; |
| 409 | 409 |
| 410 RefPtr<MediaStream> stream = prpStream; | 410 RefPtrWillBeRawPtr<MediaStream> stream = prpStream; |
| 411 if (!stream) { | 411 if (!stream) { |
| 412 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); | 412 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); |
| 413 return; | 413 return; |
| 414 } | 414 } |
| 415 | 415 |
| 416 if (m_localStreams.contains(stream)) | 416 if (m_localStreams.contains(stream)) |
| 417 return; | 417 return; |
| 418 | 418 |
| 419 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); | 419 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); |
| 420 if (exceptionState.hadException()) | 420 if (exceptionState.hadException()) |
| 421 return; | 421 return; |
| 422 | 422 |
| 423 m_localStreams.append(stream); | 423 m_localStreams.append(stream); |
| 424 | 424 |
| 425 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); | 425 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); |
| 426 if (!valid) | 426 if (!valid) |
| 427 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream."); | 427 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream."); |
| 428 } | 428 } |
| 429 | 429 |
| 430 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& exceptionState) | 430 void RTCPeerConnection::removeStream(PassRefPtrWillBeRawPtr<MediaStream> prpStre am, ExceptionState& exceptionState) |
| 431 { | 431 { |
| 432 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 432 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 433 return; | 433 return; |
| 434 | 434 |
| 435 if (!prpStream) { | 435 if (!prpStream) { |
| 436 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); | 436 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); |
| 437 return; | 437 return; |
| 438 } | 438 } |
| 439 | 439 |
| 440 RefPtr<MediaStream> stream = prpStream; | 440 RefPtrWillBeRawPtr<MediaStream> stream = prpStream; |
| 441 | 441 |
| 442 size_t pos = m_localStreams.find(stream); | 442 size_t pos = m_localStreams.find(stream); |
| 443 if (pos == kNotFound) | 443 if (pos == kNotFound) |
| 444 return; | 444 return; |
| 445 | 445 |
| 446 m_localStreams.remove(pos); | 446 m_localStreams.remove(pos); |
| 447 | 447 |
| 448 m_peerHandler->removeStream(stream->descriptor()); | 448 m_peerHandler->removeStream(stream->descriptor()); |
| 449 } | 449 } |
| 450 | 450 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 473 return 0; | 473 return 0; |
| 474 } | 474 } |
| 475 | 475 |
| 476 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) | 476 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) |
| 477 { | 477 { |
| 478 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); | 478 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); |
| 479 // FIXME: Add passing selector as part of the statsRequest. | 479 // FIXME: Add passing selector as part of the statsRequest. |
| 480 m_peerHandler->getStats(statsRequest.release()); | 480 m_peerHandler->getStats(statsRequest.release()); |
| 481 } | 481 } |
| 482 | 482 |
| 483 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& exceptionState) | 483 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState) |
| 484 { | 484 { |
| 485 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 485 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 486 return nullptr; | 486 return nullptr; |
| 487 | 487 |
| 488 blink::WebRTCDataChannelInit init; | 488 blink::WebRTCDataChannelInit init; |
| 489 options.get("ordered", init.ordered); | 489 options.get("ordered", init.ordered); |
| 490 options.get("negotiated", init.negotiated); | 490 options.get("negotiated", init.negotiated); |
| 491 | 491 |
| 492 unsigned short value = 0; | 492 unsigned short value = 0; |
| 493 if (options.get("id", value)) | 493 if (options.get("id", value)) |
| 494 init.id = value; | 494 init.id = value; |
| 495 if (options.get("maxRetransmits", value)) | 495 if (options.get("maxRetransmits", value)) |
| 496 init.maxRetransmits = value; | 496 init.maxRetransmits = value; |
| 497 if (options.get("maxRetransmitTime", value)) | 497 if (options.get("maxRetransmitTime", value)) |
| 498 init.maxRetransmitTime = value; | 498 init.maxRetransmitTime = value; |
| 499 | 499 |
| 500 String protocolString; | 500 String protocolString; |
| 501 options.get("protocol", protocolString); | 501 options.get("protocol", protocolString); |
| 502 init.protocol = protocolString; | 502 init.protocol = protocolString; |
| 503 | 503 |
| 504 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), m_peerHandler.get(), label, init, exceptionState); | 504 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), m_peerHandler.get(), label, init, exceptionState); |
| 505 if (exceptionState.hadException()) | 505 if (exceptionState.hadException()) |
| 506 return nullptr; | 506 return nullptr; |
| 507 m_dataChannels.append(channel); | 507 m_dataChannels.append(channel); |
| 508 return channel.release(); | 508 return channel.release(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) | 511 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) |
| 512 { | 512 { |
| 513 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { | 513 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { |
| 514 if ((*iter)->getTrackById(trackId)) | 514 if ((*iter)->getTrackById(trackId)) |
| 515 return true; | 515 return true; |
| 516 } | 516 } |
| 517 return false; | 517 return false; |
| 518 } | 518 } |
| 519 | 519 |
| 520 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& exceptionState) | 520 PassRefPtrWillBeRawPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRe fPtrWillBeRawPtr<MediaStreamTrack> prpTrack, ExceptionState& exceptionState) |
| 521 { | 521 { |
| 522 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 522 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 523 return nullptr; | 523 return nullptr; |
| 524 | 524 |
| 525 if (!prpTrack) { | 525 if (!prpTrack) { |
| 526 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(1, "MediaStreamTrack")); | 526 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(1, "MediaStreamTrack")); |
| 527 return nullptr; | 527 return nullptr; |
| 528 } | 528 } |
| 529 | 529 |
| 530 RefPtr<MediaStreamTrack> track = prpTrack; | 530 RefPtrWillBeRawPtr<MediaStreamTrack> track = prpTrack; |
| 531 | 531 |
| 532 if (!hasLocalStreamWithTrackId(track->id())) { | 532 if (!hasLocalStreamWithTrackId(track->id())) { |
| 533 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided."); | 533 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided."); |
| 534 return nullptr; | 534 return nullptr; |
| 535 } | 535 } |
| 536 | 536 |
| 537 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executionContext(), m_peerHandler.get(), track.release(), exceptionState); | 537 RefPtrWillBeRawPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executi onContext(), m_peerHandler.get(), track.release(), exceptionState); |
| 538 if (exceptionState.hadException()) | 538 if (exceptionState.hadException()) |
| 539 return nullptr; | 539 return nullptr; |
| 540 return dtmfSender.release(); | 540 return dtmfSender.release(); |
| 541 } | 541 } |
| 542 | 542 |
| 543 void RTCPeerConnection::close(ExceptionState& exceptionState) | 543 void RTCPeerConnection::close(ExceptionState& exceptionState) |
| 544 { | 544 { |
| 545 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 545 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 546 return; | 546 return; |
| 547 | 547 |
| 548 m_peerHandler->stop(); | 548 m_peerHandler->stop(); |
| 549 | 549 |
| 550 changeIceConnectionState(ICEConnectionStateClosed); | 550 changeIceConnectionState(ICEConnectionStateClosed); |
| 551 changeIceGatheringState(ICEGatheringStateComplete); | 551 changeIceGatheringState(ICEGatheringStateComplete); |
| 552 changeSignalingState(SignalingStateClosed); | 552 changeSignalingState(SignalingStateClosed); |
| 553 } | 553 } |
| 554 | 554 |
| 555 void RTCPeerConnection::negotiationNeeded() | 555 void RTCPeerConnection::negotiationNeeded() |
| 556 { | 556 { |
| 557 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); | 557 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); |
| 558 } | 558 } |
| 559 | 559 |
| 560 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) | 560 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) |
| 561 { | 561 { |
| 562 ASSERT(executionContext()->isContextThread()); | 562 ASSERT(executionContext()->isContextThread()); |
| 563 if (webCandidate.isNull()) | 563 if (webCandidate.isNull()) |
| 564 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); | 564 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); |
| 565 else { | 565 else { |
| 566 RefPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::create(webCandid ate); | 566 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate); |
| 567 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); | 567 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); |
| 568 } | 568 } |
| 569 } | 569 } |
| 570 | 570 |
| 571 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) | 571 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) |
| 572 { | 572 { |
| 573 ASSERT(executionContext()->isContextThread()); | 573 ASSERT(executionContext()->isContextThread()); |
| 574 changeSignalingState(newState); | 574 changeSignalingState(newState); |
| 575 } | 575 } |
| 576 | 576 |
| 577 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) | 577 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) |
| 578 { | 578 { |
| 579 ASSERT(executionContext()->isContextThread()); | 579 ASSERT(executionContext()->isContextThread()); |
| 580 changeIceGatheringState(newState); | 580 changeIceGatheringState(newState); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) | 583 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) |
| 584 { | 584 { |
| 585 ASSERT(executionContext()->isContextThread()); | 585 ASSERT(executionContext()->isContextThread()); |
| 586 changeIceConnectionState(newState); | 586 changeIceConnectionState(newState); |
| 587 } | 587 } |
| 588 | 588 |
| 589 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) | 589 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) |
| 590 { | 590 { |
| 591 ASSERT(executionContext()->isContextThread()); | 591 ASSERT(executionContext()->isContextThread()); |
| 592 | 592 |
| 593 if (m_signalingState == SignalingStateClosed) | 593 if (m_signalingState == SignalingStateClosed) |
| 594 return; | 594 return; |
| 595 | 595 |
| 596 RefPtr<MediaStream> stream = MediaStream::create(executionContext(), remoteS tream); | 596 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream); |
| 597 m_remoteStreams.append(stream); | 597 m_remoteStreams.append(stream); |
| 598 | 598 |
| 599 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); | 599 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); |
| 600 } | 600 } |
| 601 | 601 |
| 602 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) | 602 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) |
| 603 { | 603 { |
| 604 ASSERT(executionContext()->isContextThread()); | 604 ASSERT(executionContext()->isContextThread()); |
| 605 | 605 |
| 606 MediaStreamDescriptor* streamDescriptor = remoteStream; | 606 MediaStreamDescriptor* streamDescriptor = remoteStream; |
| 607 ASSERT(streamDescriptor->client()); | 607 ASSERT(streamDescriptor->client()); |
| 608 | 608 |
| 609 RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->cli ent()); | 609 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client()); |
| 610 stream->streamEnded(); | 610 stream->streamEnded(); |
| 611 | 611 |
| 612 if (m_signalingState == SignalingStateClosed) | 612 if (m_signalingState == SignalingStateClosed) |
| 613 return; | 613 return; |
| 614 | 614 |
| 615 size_t pos = m_remoteStreams.find(stream); | 615 size_t pos = m_remoteStreams.find(stream); |
| 616 ASSERT(pos != kNotFound); | 616 ASSERT(pos != kNotFound); |
| 617 m_remoteStreams.remove(pos); | 617 m_remoteStreams.remove(pos); |
| 618 | 618 |
| 619 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); | 619 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); |
| 620 } | 620 } |
| 621 | 621 |
| 622 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) | 622 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) |
| 623 { | 623 { |
| 624 ASSERT(executionContext()->isContextThread()); | 624 ASSERT(executionContext()->isContextThread()); |
| 625 | 625 |
| 626 if (m_signalingState == SignalingStateClosed) | 626 if (m_signalingState == SignalingStateClosed) |
| 627 return; | 627 return; |
| 628 | 628 |
| 629 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), adoptPtr(handler)); | 629 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), adoptPtr(handler)); |
| 630 m_dataChannels.append(channel); | 630 m_dataChannels.append(channel); |
| 631 | 631 |
| 632 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); | 632 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); |
| 633 } | 633 } |
| 634 | 634 |
| 635 const AtomicString& RTCPeerConnection::interfaceName() const | 635 const AtomicString& RTCPeerConnection::interfaceName() const |
| 636 { | 636 { |
| 637 return EventTargetNames::RTCPeerConnection; | 637 return EventTargetNames::RTCPeerConnection; |
| 638 } | 638 } |
| 639 | 639 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 654 | 654 |
| 655 void RTCPeerConnection::stop() | 655 void RTCPeerConnection::stop() |
| 656 { | 656 { |
| 657 if (m_stopped) | 657 if (m_stopped) |
| 658 return; | 658 return; |
| 659 | 659 |
| 660 m_stopped = true; | 660 m_stopped = true; |
| 661 m_iceConnectionState = ICEConnectionStateClosed; | 661 m_iceConnectionState = ICEConnectionStateClosed; |
| 662 m_signalingState = SignalingStateClosed; | 662 m_signalingState = SignalingStateClosed; |
| 663 | 663 |
| 664 Vector<RefPtr<RTCDataChannel> >::iterator i = m_dataChannels.begin(); | 664 WillBeHeapVector<RefPtrWillBeMember<RTCDataChannel> >::iterator i = m_dataCh annels.begin(); |
| 665 for (; i != m_dataChannels.end(); ++i) | 665 for (; i != m_dataChannels.end(); ++i) |
| 666 (*i)->stop(); | 666 (*i)->stop(); |
| 667 | 667 |
| 668 m_dispatchScheduledEventRunner.stop(); | 668 m_dispatchScheduledEventRunner.stop(); |
| 669 } | 669 } |
| 670 | 670 |
| 671 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) | 671 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) |
| 672 { | 672 { |
| 673 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) { | 673 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) { |
| 674 m_signalingState = signalingState; | 674 m_signalingState = signalingState; |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 704 WillBeHeapVector<RefPtrWillBeMember<Event> > events; | 704 WillBeHeapVector<RefPtrWillBeMember<Event> > events; |
| 705 events.swap(m_scheduledEvents); | 705 events.swap(m_scheduledEvents); |
| 706 | 706 |
| 707 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); | 707 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); |
| 708 for (; it != events.end(); ++it) | 708 for (; it != events.end(); ++it) |
| 709 dispatchEvent((*it).release()); | 709 dispatchEvent((*it).release()); |
| 710 | 710 |
| 711 events.clear(); | 711 events.clear(); |
| 712 } | 712 } |
| 713 | 713 |
| 714 void RTCPeerConnection::trace(Visitor* visitor) | |
| 715 { | |
| 716 visitor->trace(m_localStreams); | |
| 717 visitor->trace(m_remoteStreams); | |
| 718 visitor->trace(m_dataChannels); | |
| 719 visitor->trace(m_scheduledEvents); | |
| 720 } | |
| 721 | |
| 714 } // namespace WebCore | 722 } // namespace WebCore |
| OLD | NEW |