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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_stopped(false) | 184 , m_stopped(false) |
| 185 , m_closed(false) |
185 { | 186 { |
186 ScriptWrappable::init(this); | 187 ScriptWrappable::init(this); |
187 Document* document = toDocument(executionContext()); | 188 Document* document = toDocument(executionContext()); |
188 | 189 |
| 190 // If we fail, set |m_closed| and |m_stopped| to true, to avoid hitting the
assert in the destructor. |
| 191 |
189 if (!document->frame()) { | 192 if (!document->frame()) { |
| 193 m_closed = true; |
| 194 m_stopped = true; |
190 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may
not be created in detached documents."); | 195 exceptionState.throwDOMException(NotSupportedError, "PeerConnections may
not be created in detached documents."); |
191 return; | 196 return; |
192 } | 197 } |
193 | 198 |
194 m_peerHandler = adoptPtr(blink::Platform::current()->createRTCPeerConnection
Handler(this)); | 199 m_peerHandler = adoptPtr(blink::Platform::current()->createRTCPeerConnection
Handler(this)); |
195 if (!m_peerHandler) { | 200 if (!m_peerHandler) { |
| 201 m_closed = true; |
| 202 m_stopped = true; |
196 exceptionState.throwDOMException(NotSupportedError, "No PeerConnection h
andler can be created, perhaps WebRTC is disabled?"); | 203 exceptionState.throwDOMException(NotSupportedError, "No PeerConnection h
andler can be created, perhaps WebRTC is disabled?"); |
197 return; | 204 return; |
198 } | 205 } |
199 | 206 |
200 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa
ndler(m_peerHandler.get()); | 207 document->frame()->loader().client()->dispatchWillStartUsingPeerConnectionHa
ndler(m_peerHandler.get()); |
201 | 208 |
202 if (!m_peerHandler->initialize(configuration, constraints)) { | 209 if (!m_peerHandler->initialize(configuration, constraints)) { |
| 210 m_closed = true; |
| 211 m_stopped = true; |
203 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ
e native PeerConnection."); | 212 exceptionState.throwDOMException(NotSupportedError, "Failed to initializ
e native PeerConnection."); |
204 return; | 213 return; |
205 } | 214 } |
206 } | 215 } |
207 | 216 |
208 RTCPeerConnection::~RTCPeerConnection() | 217 RTCPeerConnection::~RTCPeerConnection() |
209 { | 218 { |
210 // This checks that stop() is called if necessary before the destructor. | 219 // 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 | 220 // We are assuming that a wrapper is always created when RTCPeerConnection i
s created. |
212 ASSERT(m_dataChannels.isEmpty()); | 221 ASSERT(m_closed || m_stopped); |
| 222 |
| 223 // FIXME: Oilpan: We can't call stop here since it touches m_dataChannels. |
| 224 // Another way to ensure that data channels are stopped at RTCPeerConnection |
| 225 // destruction is needed. |
| 226 stop(); |
213 } | 227 } |
214 | 228 |
215 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su
ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med
iaConstraints, ExceptionState& exceptionState) | 229 void RTCPeerConnection::createOffer(PassOwnPtr<RTCSessionDescriptionCallback> su
ccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& med
iaConstraints, ExceptionState& exceptionState) |
216 { | 230 { |
217 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 231 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
218 return; | 232 return; |
219 | 233 |
220 ASSERT(successCallback); | 234 ASSERT(successCallback); |
221 | 235 |
222 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC
onstraints, exceptionState); | 236 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC
onstraints, exceptionState); |
223 if (exceptionState.hadException()) | 237 if (exceptionState.hadException()) |
224 return; | 238 return; |
225 | 239 |
226 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI
mpl::create(executionContext(), successCallback, errorCallback); | 240 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI
mpl::create(executionContext(), this, successCallback, errorCallback); |
227 m_peerHandler->createOffer(request.release(), constraints); | 241 m_peerHandler->createOffer(request.release(), constraints); |
228 } | 242 } |
229 | 243 |
230 void RTCPeerConnection::createAnswer(PassOwnPtr<RTCSessionDescriptionCallback> s
uccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& me
diaConstraints, ExceptionState& exceptionState) | 244 void RTCPeerConnection::createAnswer(PassOwnPtr<RTCSessionDescriptionCallback> s
uccessCallback, PassOwnPtr<RTCErrorCallback> errorCallback, const Dictionary& me
diaConstraints, ExceptionState& exceptionState) |
231 { | 245 { |
232 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 246 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
233 return; | 247 return; |
234 | 248 |
235 ASSERT(successCallback); | 249 ASSERT(successCallback); |
236 | 250 |
237 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC
onstraints, exceptionState); | 251 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC
onstraints, exceptionState); |
238 if (exceptionState.hadException()) | 252 if (exceptionState.hadException()) |
239 return; | 253 return; |
240 | 254 |
241 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI
mpl::create(executionContext(), successCallback, errorCallback); | 255 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI
mpl::create(executionContext(), this, successCallback, errorCallback); |
242 m_peerHandler->createAnswer(request.release(), constraints); | 256 m_peerHandler->createAnswer(request.release(), constraints); |
243 } | 257 } |
244 | 258 |
245 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes
cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO
wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) | 259 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes
cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO
wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) |
246 { | 260 { |
247 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 261 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
248 return; | 262 return; |
249 | 263 |
250 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes
cription; | 264 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes
cription; |
251 if (!sessionDescription) { | 265 if (!sessionDescription) { |
252 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 266 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
253 return; | 267 return; |
254 } | 268 } |
255 | 269 |
256 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); | 270 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), this, successCallback, errorCallback); |
257 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we
bSessionDescription()); | 271 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we
bSessionDescription()); |
258 } | 272 } |
259 | 273 |
260 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio
n(ExceptionState& exceptionState) | 274 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio
n(ExceptionState& exceptionState) |
261 { | 275 { |
262 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local
Description(); | 276 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local
Description(); |
263 if (webSessionDescription.isNull()) | 277 if (webSessionDescription.isNull()) |
264 return nullptr; | 278 return nullptr; |
265 | 279 |
266 return RTCSessionDescription::create(webSessionDescription); | 280 return RTCSessionDescription::create(webSessionDescription); |
267 } | 281 } |
268 | 282 |
269 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe
scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass
OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) | 283 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe
scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass
OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) |
270 { | 284 { |
271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 285 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
272 return; | 286 return; |
273 | 287 |
274 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes
cription; | 288 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes
cription; |
275 if (!sessionDescription) { | 289 if (!sessionDescription) { |
276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 290 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
277 return; | 291 return; |
278 } | 292 } |
279 | 293 |
280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); | 294 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), this, successCallback, errorCallback); |
281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w
ebSessionDescription()); | 295 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w
ebSessionDescription()); |
282 } | 296 } |
283 | 297 |
284 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti
on(ExceptionState& exceptionState) | 298 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti
on(ExceptionState& exceptionState) |
285 { | 299 { |
286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot
eDescription(); | 300 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot
eDescription(); |
287 if (webSessionDescription.isNull()) | 301 if (webSessionDescription.isNull()) |
288 return nullptr; | 302 return nullptr; |
289 | 303 |
290 return RTCSessionDescription::create(webSessionDescription); | 304 return RTCSessionDescription::create(webSessionDescription); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 342 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
329 return; | 343 return; |
330 | 344 |
331 if (!iceCandidate) { | 345 if (!iceCandidate) { |
332 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); | 346 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a
rgumentNullOrIncorrectType(1, "RTCIceCandidate")); |
333 return; | 347 return; |
334 } | 348 } |
335 ASSERT(successCallback); | 349 ASSERT(successCallback); |
336 ASSERT(errorCallback); | 350 ASSERT(errorCallback); |
337 | 351 |
338 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), successCallback, errorCallback); | 352 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext
(), this, successCallback, errorCallback); |
339 | 353 |
340 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand
idate->webCandidate()); | 354 bool implemented = m_peerHandler->addICECandidate(request.release(), iceCand
idate->webCandidate()); |
341 if (!implemented) | 355 if (!implemented) { |
342 exceptionState.throwDOMException(NotSupportedError, "This method is not
yet implemented."); | 356 exceptionState.throwDOMException(NotSupportedError, "This method is not
yet implemented."); |
| 357 } |
343 } | 358 } |
344 | 359 |
345 String RTCPeerConnection::signalingState() const | 360 String RTCPeerConnection::signalingState() const |
346 { | 361 { |
347 switch (m_signalingState) { | 362 switch (m_signalingState) { |
348 case SignalingStateStable: | 363 case SignalingStateStable: |
349 return "stable"; | 364 return "stable"; |
350 case SignalingStateHaveLocalOffer: | 365 case SignalingStateHaveLocalOffer: |
351 return "have-local-offer"; | 366 return "have-local-offer"; |
352 case SignalingStateHaveRemoteOffer: | 367 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) { | 482 for (MediaStreamVector::iterator iter = m_remoteStreams.begin(); iter != m_r
emoteStreams.end(); ++iter) { |
468 if ((*iter)->id() == streamId) | 483 if ((*iter)->id() == streamId) |
469 return iter->get(); | 484 return iter->get(); |
470 } | 485 } |
471 | 486 |
472 return 0; | 487 return 0; |
473 } | 488 } |
474 | 489 |
475 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P
assRefPtr<MediaStreamTrack> selector) | 490 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P
assRefPtr<MediaStreamTrack> selector) |
476 { | 491 { |
477 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution
Context(), successCallback, selector); | 492 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution
Context(), this, successCallback, selector); |
478 // FIXME: Add passing selector as part of the statsRequest. | 493 // FIXME: Add passing selector as part of the statsRequest. |
479 m_peerHandler->getStats(statsRequest.release()); | 494 m_peerHandler->getStats(statsRequest.release()); |
480 } | 495 } |
481 | 496 |
482 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri
ng label, const Dictionary& options, ExceptionState& exceptionState) | 497 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri
ng label, const Dictionary& options, ExceptionState& exceptionState) |
483 { | 498 { |
484 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 499 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
485 return nullptr; | 500 return nullptr; |
486 | 501 |
487 blink::WebRTCDataChannelInit init; | 502 blink::WebRTCDataChannelInit init; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio
nContext(), adoptPtr(handler)); |
629 m_dataChannels.append(channel); | 653 m_dataChannels.append(channel); |
630 | 654 |
631 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne
l, false, false, channel.release())); | 655 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne
l, false, false, channel.release())); |
632 } | 656 } |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 void RTCPeerConnection::trace(Visitor* visitor) | 745 void RTCPeerConnection::trace(Visitor* visitor) |
722 { | 746 { |
723 visitor->trace(m_localStreams); | 747 visitor->trace(m_localStreams); |
724 visitor->trace(m_remoteStreams); | 748 visitor->trace(m_remoteStreams); |
725 visitor->trace(m_dataChannels); | 749 visitor->trace(m_dataChannels); |
726 visitor->trace(m_scheduledEvents); | 750 visitor->trace(m_scheduledEvents); |
727 EventTargetWithInlineData::trace(visitor); | 751 EventTargetWithInlineData::trace(visitor); |
728 } | 752 } |
729 | 753 |
730 } // namespace WebCore | 754 } // namespace WebCore |
OLD | NEW |