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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 | 174 |
| 175 return peerConnection.release(); | 175 return peerConnection.release(); |
| 176 } | 176 } |
| 177 | 177 |
| 178 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState) | 178 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState) |
| 179 : ActiveDOMObject(context) | 179 : ActiveDOMObject(context) |
| 180 , m_signalingState(SignalingStateStable) | 180 , m_signalingState(SignalingStateStable) |
| 181 , m_iceGatheringState(ICEGatheringStateNew) | 181 , m_iceGatheringState(ICEGatheringStateNew) |
| 182 , m_iceConnectionState(ICEConnectionStateNew) | 182 , m_iceConnectionState(ICEConnectionStateNew) |
| 183 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled Event) | 183 , m_dispatchScheduledEventRunner(this, &RTCPeerConnection::dispatchScheduled Event) |
| 184 , m_weakPtrFactory(this) | |
|
keishi
2014/06/17 08:16:42
nit: Wrap in #if ENABLE(OILPAN)
| |
| 184 , m_stopped(false) | 185 , m_stopped(false) |
| 186 , m_closed(false) | |
| 185 { | 187 { |
| 186 ScriptWrappable::init(this); | 188 ScriptWrappable::init(this); |
| 187 Document* document = toDocument(executionContext()); | 189 Document* document = toDocument(executionContext()); |
| 188 | 190 |
| 191 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the assert in the destructor. | |
| 192 | |
| 189 if (!document->frame()) { | 193 if (!document->frame()) { |
| 194 m_closed = true; | |
| 195 m_stopped = true; | |
| 190 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may not be created in detached documents."); | 196 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may not be created in detached documents."); |
| 191 return; | 197 return; |
| 192 } | 198 } |
| 193 | 199 |
| 194 m_peerHandler = adoptPtr(blink::Platform::current()->createRTCPeerConnection Handler(this)); | 200 m_peerHandler = adoptPtr(blink::Platform::current()->createRTCPeerConnection Handler(this)); |
| 195 if (!m_peerHandler) { | 201 if (!m_peerHandler) { |
| 202 m_closed = true; | |
| 203 m_stopped = true; | |
| 196 exceptionState.throwDOMException(NotSupportedError, "No PeerConnection h andler can be created, perhaps WebRTC is disabled?"); | 204 exceptionState.throwDOMException(NotSupportedError, "No PeerConnection h andler can be created, perhaps WebRTC is disabled?"); |
| 197 return; | 205 return; |
| 198 } | 206 } |
| 199 | 207 |
| 200 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get()); | 208 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa ndler(m_peerHandler.get()); |
| 201 | 209 |
| 202 if (!m_peerHandler->initialize(configuration, constraints)) { | 210 if (!m_peerHandler->initialize(configuration, constraints)) { |
| 211 m_closed = true; | |
| 212 m_stopped = true; | |
| 203 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection."); | 213 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ e native PeerConnection."); |
| 204 return; | 214 return; |
| 205 } | 215 } |
| 206 } | 216 } |
| 207 | 217 |
| 208 RTCPeerConnection::~RTCPeerConnection() | 218 RTCPeerConnection::~RTCPeerConnection() |
| 209 { | 219 { |
| 210 // This checks that stop() is called if necessary before the destructor. | 220 // This checks that close() or stop() is called before the destructor. |
| 211 // We are assuming that a wrapper is always created when RTCPeerConnection i s created | 221 // We are assuming that a wrapper is always created when RTCPeerConnection i s created. |
| 212 ASSERT(m_dataChannels.isEmpty()); | 222 ASSERT(m_closed || m_stopped); |
| 213 } | 223 } |
| 214 | 224 |
| 215 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState) | 225 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med iaConstraints, ExceptionState& exceptionState) |
| 216 { | 226 { |
| 217 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 227 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 218 return; | 228 return; |
| 219 | 229 |
| 220 ASSERT(successCallback); | 230 ASSERT(successCallback); |
| 221 | 231 |
| 222 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); | 232 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); |
| 223 if (exceptionState.hadException()) | 233 if (exceptionState.hadException()) |
| 224 return; | 234 return; |
| 225 | 235 |
| 226 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); | 236 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), this, successCallback, errorCallback); |
| 227 m_peerHandler->createOffer(request.release(), constraints); | 237 m_peerHandler->createOffer(request.release(), constraints); |
| 228 } | 238 } |
| 229 | 239 |
| 230 void RTCPeerConnection::createAnswer(PassOwnPtr<RTCSessionDescriptionCallback> s uccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& exceptionState) | 240 void RTCPeerConnection::createAnswer(PassOwnPtr<RTCSessionDescriptionCallback> s uccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& me diaConstraints, ExceptionState& exceptionState) |
| 231 { | 241 { |
| 232 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 242 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 233 return; | 243 return; |
| 234 | 244 |
| 235 ASSERT(successCallback); | 245 ASSERT(successCallback); |
| 236 | 246 |
| 237 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); | 247 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); |
| 238 if (exceptionState.hadException()) | 248 if (exceptionState.hadException()) |
| 239 return; | 249 return; |
| 240 | 250 |
| 241 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); | 251 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), this, successCallback, errorCallback); |
| 242 m_peerHandler->createAnswer(request.release(), constraints); | 252 m_peerHandler->createAnswer(request.release(), constraints); |
| 243 } | 253 } |
| 244 | 254 |
| 245 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) | 255 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) |
| 246 { | 256 { |
| 247 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 257 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 248 return; | 258 return; |
| 249 | 259 |
| 250 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; | 260 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; |
| 251 if (!sessionDescription) { | 261 if (!sessionDescription) { |
| 252 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 262 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
| 253 return; | 263 return; |
| 254 } | 264 } |
| 255 | 265 |
| 256 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); | 266 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), this, successCallback, errorCallback); |
| 257 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); | 267 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); |
| 258 } | 268 } |
| 259 | 269 |
| 260 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio n(ExceptionState& exceptionState) | 270 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio n(ExceptionState& exceptionState) |
| 261 { | 271 { |
| 262 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); | 272 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); |
| 263 if (webSessionDescription.isNull()) | 273 if (webSessionDescription.isNull()) |
| 264 return nullptr; | 274 return nullptr; |
| 265 | 275 |
| 266 return RTCSessionDescription::create(webSessionDescription); | 276 return RTCSessionDescription::create(webSessionDescription); |
| 267 } | 277 } |
| 268 | 278 |
| 269 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) | 279 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) |
| 270 { | 280 { |
| 271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 281 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 272 return; | 282 return; |
| 273 | 283 |
| 274 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; | 284 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; |
| 275 if (!sessionDescription) { | 285 if (!sessionDescription) { |
| 276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 286 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
| 277 return; | 287 return; |
| 278 } | 288 } |
| 279 | 289 |
| 280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); | 290 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), this, successCallback, errorCallback); |
| 281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); | 291 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); |
| 282 } | 292 } |
| 283 | 293 |
| 284 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState) | 294 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState) |
| 285 { | 295 { |
| 286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); | 296 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); |
| 287 if (webSessionDescription.isNull()) | 297 if (webSessionDescription.isNull()) |
| 288 return nullptr; | 298 return nullptr; |
| 289 | 299 |
| 290 return RTCSessionDescription::create(webSessionDescription); | 300 return RTCSessionDescription::create(webSessionDescription); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 338 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 329 return; | 339 return; |
| 330 | 340 |
| 331 if (!iceCandidate) { | 341 if (!iceCandidate) { |
| 332 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCIceCandidate")); | 342 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCIceCandidate")); |
| 333 return; | 343 return; |
| 334 } | 344 } |
| 335 ASSERT(successCallback); | 345 ASSERT(successCallback); |
| 336 ASSERT(errorCallback); | 346 ASSERT(errorCallback); |
| 337 | 347 |
| 338 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); | 348 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), this, successCallback, errorCallback); |
| 339 | 349 |
| 340 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand idate->webCandidate()); | 350 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand idate->webCandidate()); |
| 341 if (!implemented) | 351 if (!implemented) { |
| 342 exceptionState.throwDOMException(NotSupportedError, "This method is not yet implemented."); | 352 exceptionState.throwDOMException(NotSupportedError, "This method is not yet implemented."); |
| 353 } | |
| 343 } | 354 } |
| 344 | 355 |
| 345 String RTCPeerConnection::signalingState() const | 356 String RTCPeerConnection::signalingState() const |
| 346 { | 357 { |
| 347 switch (m_signalingState) { | 358 switch (m_signalingState) { |
| 348 case SignalingStateStable: | 359 case SignalingStateStable: |
| 349 return "stable"; | 360 return "stable"; |
| 350 case SignalingStateHaveLocalOffer: | 361 case SignalingStateHaveLocalOffer: |
| 351 return "have-local-offer"; | 362 return "have-local-offer"; |
| 352 case SignalingStateHaveRemoteOffer: | 363 case SignalingStateHaveRemoteOffer: |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) { | 478 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r emoteStreams.end(); ++iter) { |
| 468 if ((*iter)->id() == streamId) | 479 if ((*iter)->id() == streamId) |
| 469 return iter->get(); | 480 return iter->get(); |
| 470 } | 481 } |
| 471 | 482 |
| 472 return 0; | 483 return 0; |
| 473 } | 484 } |
| 474 | 485 |
| 475 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) | 486 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) |
| 476 { | 487 { |
| 477 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); | 488 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), this, successCallback, selector); |
| 478 // FIXME: Add passing selector as part of the statsRequest. | 489 // FIXME: Add passing selector as part of the statsRequest. |
| 479 m_peerHandler->getStats(statsRequest.release()); | 490 m_peerHandler->getStats(statsRequest.release()); |
| 480 } | 491 } |
| 481 | 492 |
| 482 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState) | 493 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState) |
| 483 { | 494 { |
| 484 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 495 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 485 return nullptr; | 496 return nullptr; |
| 486 | 497 |
| 487 blink::WebRTCDataChannelInit init; | 498 blink::WebRTCDataChannelInit init; |
| 488 options.get("ordered", init.ordered); | 499 options.get("ordered", init.ordered); |
| 489 options.get("negotiated", init.negotiated); | 500 options.get("negotiated", init.negotiated); |
| 490 | 501 |
| 491 unsigned short value = 0; | 502 unsigned short value = 0; |
| 492 if (options.get("id", value)) | 503 if (options.get("id", value)) |
| 493 init.id = value; | 504 init.id = value; |
| 494 if (options.get("maxRetransmits", value)) | 505 if (options.get("maxRetransmits", value)) |
| 495 init.maxRetransmits = value; | 506 init.maxRetransmits = value; |
| 496 if (options.get("maxRetransmitTime", value)) | 507 if (options.get("maxRetransmitTime", value)) |
| 497 init.maxRetransmitTime = value; | 508 init.maxRetransmitTime = value; |
| 498 | 509 |
| 499 String protocolString; | 510 String protocolString; |
| 500 options.get("protocol", protocolString); | 511 options.get("protocol", protocolString); |
| 501 init.protocol = protocolString; | 512 init.protocol = protocolString; |
| 502 | 513 |
| 503 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), m_peerHandler.get(), label, init, exceptionState); | 514 #if ENABLE(OILPAN) |
| 515 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), this, m_peerHandler.get(), label, init, exceptionState); | |
| 516 #else | |
| 517 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), m_weakPtrFactory.createWeakPtr(), m_peerHandler.get(), label, init, exceptionState); | |
| 518 #endif | |
| 504 if (exceptionState.hadException()) | 519 if (exceptionState.hadException()) |
| 505 return nullptr; | 520 return nullptr; |
| 506 m_dataChannels.append(channel); | 521 m_dataChannels.append(channel); |
| 507 return channel.release(); | 522 return channel.release(); |
| 508 } | 523 } |
| 509 | 524 |
| 510 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) | 525 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) |
| 511 { | 526 { |
| 512 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { | 527 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { |
| 513 if ((*iter)->getTrackById(trackId)) | 528 if ((*iter)->getTrackById(trackId)) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 538 return nullptr; | 553 return nullptr; |
| 539 return dtmfSender.release(); | 554 return dtmfSender.release(); |
| 540 } | 555 } |
| 541 | 556 |
| 542 void RTCPeerConnection::close(ExceptionState& exceptionState) | 557 void RTCPeerConnection::close(ExceptionState& exceptionState) |
| 543 { | 558 { |
| 544 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 559 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
| 545 return; | 560 return; |
| 546 | 561 |
| 547 m_peerHandler->stop(); | 562 m_peerHandler->stop(); |
| 563 m_closed = true; | |
| 548 | 564 |
| 549 changeIceConnectionState(ICEConnectionStateClosed); | 565 changeIceConnectionState(ICEConnectionStateClosed); |
| 550 changeIceGatheringState(ICEGatheringStateComplete); | 566 changeIceGatheringState(ICEGatheringStateComplete); |
| 551 changeSignalingState(SignalingStateClosed); | 567 changeSignalingState(SignalingStateClosed); |
| 552 } | 568 } |
| 553 | 569 |
| 554 void RTCPeerConnection::negotiationNeeded() | 570 void RTCPeerConnection::negotiationNeeded() |
| 555 { | 571 { |
| 572 ASSERT(!m_closed); | |
| 556 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); | 573 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); |
| 557 } | 574 } |
| 558 | 575 |
| 559 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) | 576 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) |
| 560 { | 577 { |
| 578 ASSERT(!m_closed); | |
| 561 ASSERT(executionContext()->isContextThread()); | 579 ASSERT(executionContext()->isContextThread()); |
| 562 if (webCandidate.isNull()) | 580 if (webCandidate.isNull()) |
| 563 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); | 581 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); |
| 564 else { | 582 else { |
| 565 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate); | 583 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate); |
| 566 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); | 584 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); |
| 567 } | 585 } |
| 568 } | 586 } |
| 569 | 587 |
| 570 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) | 588 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) |
| 571 { | 589 { |
| 590 ASSERT(!m_closed); | |
| 572 ASSERT(executionContext()->isContextThread()); | 591 ASSERT(executionContext()->isContextThread()); |
| 573 changeSignalingState(newState); | 592 changeSignalingState(newState); |
| 574 } | 593 } |
| 575 | 594 |
| 576 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) | 595 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) |
| 577 { | 596 { |
| 597 ASSERT(!m_closed); | |
| 578 ASSERT(executionContext()->isContextThread()); | 598 ASSERT(executionContext()->isContextThread()); |
| 579 changeIceGatheringState(newState); | 599 changeIceGatheringState(newState); |
| 580 } | 600 } |
| 581 | 601 |
| 582 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) | 602 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) |
| 583 { | 603 { |
| 604 ASSERT(!m_closed); | |
| 584 ASSERT(executionContext()->isContextThread()); | 605 ASSERT(executionContext()->isContextThread()); |
| 585 changeIceConnectionState(newState); | 606 changeIceConnectionState(newState); |
| 586 } | 607 } |
| 587 | 608 |
| 588 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) | 609 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) |
| 589 { | 610 { |
| 611 ASSERT(!m_closed); | |
| 590 ASSERT(executionContext()->isContextThread()); | 612 ASSERT(executionContext()->isContextThread()); |
| 591 | 613 |
| 592 if (m_signalingState == SignalingStateClosed) | 614 if (m_signalingState == SignalingStateClosed) |
| 593 return; | 615 return; |
| 594 | 616 |
| 595 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream); | 617 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream); |
| 596 m_remoteStreams.append(stream); | 618 m_remoteStreams.append(stream); |
| 597 | 619 |
| 598 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); | 620 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); |
| 599 } | 621 } |
| 600 | 622 |
| 601 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) | 623 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) |
| 602 { | 624 { |
| 625 ASSERT(!m_closed); | |
| 603 ASSERT(executionContext()->isContextThread()); | 626 ASSERT(executionContext()->isContextThread()); |
| 604 | 627 |
| 605 MediaStreamDescriptor* streamDescriptor = remoteStream; | 628 MediaStreamDescriptor* streamDescriptor = remoteStream; |
| 606 ASSERT(streamDescriptor->client()); | 629 ASSERT(streamDescriptor->client()); |
| 607 | 630 |
| 608 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client()); | 631 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client()); |
| 609 stream->streamEnded(); | 632 stream->streamEnded(); |
| 610 | 633 |
| 611 if (m_signalingState == SignalingStateClosed) | 634 if (m_signalingState == SignalingStateClosed) |
| 612 return; | 635 return; |
| 613 | 636 |
| 614 size_t pos = m_remoteStreams.find(stream); | 637 size_t pos = m_remoteStreams.find(stream); |
| 615 ASSERT(pos != kNotFound); | 638 ASSERT(pos != kNotFound); |
| 616 m_remoteStreams.remove(pos); | 639 m_remoteStreams.remove(pos); |
| 617 | 640 |
| 618 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); | 641 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); |
| 619 } | 642 } |
| 620 | 643 |
| 621 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) | 644 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) |
| 622 { | 645 { |
| 646 ASSERT(!m_closed); | |
| 623 ASSERT(executionContext()->isContextThread()); | 647 ASSERT(executionContext()->isContextThread()); |
| 624 | 648 |
| 625 if (m_signalingState == SignalingStateClosed) | 649 if (m_signalingState == SignalingStateClosed) |
| 626 return; | 650 return; |
| 627 | 651 |
| 628 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), adoptPtr(handler)); | 652 #if ENABLE(OILPAN) |
| 653 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), this, adoptPtr(handler)); | |
| 654 #else | |
| 655 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), m_weakPtrFactory.createWeakPtr(), adoptPtr(handler)); | |
| 656 #endif | |
| 629 m_dataChannels.append(channel); | 657 m_dataChannels.append(channel); |
| 630 | 658 |
| 631 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); | 659 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); |
| 632 } | 660 } |
| 633 | 661 |
| 634 void RTCPeerConnection::releasePeerConnectionHandler() | 662 void RTCPeerConnection::releasePeerConnectionHandler() |
| 635 { | 663 { |
| 636 stop(); | 664 stop(); |
| 637 } | 665 } |
| 638 | 666 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 void RTCPeerConnection::trace(Visitor* visitor) | 749 void RTCPeerConnection::trace(Visitor* visitor) |
| 722 { | 750 { |
| 723 visitor->trace(m_localStreams); | 751 visitor->trace(m_localStreams); |
| 724 visitor->trace(m_remoteStreams); | 752 visitor->trace(m_remoteStreams); |
| 725 visitor->trace(m_dataChannels); | 753 visitor->trace(m_dataChannels); |
| 726 visitor->trace(m_scheduledEvents); | 754 visitor->trace(m_scheduledEvents); |
| 727 EventTargetWithInlineData::trace(visitor); | 755 EventTargetWithInlineData::trace(visitor); |
| 728 } | 756 } |
| 729 | 757 |
| 730 } // namespace WebCore | 758 } // namespace WebCore |
| OLD | NEW |