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 ASSERT(m_stopped); |
tkent
2014/04/24 04:21:49
This change is not obvious. Please explain it in
| |
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 return RTCSessionDescription::create(webSessionDescription); |
266 return sessionDescription.release(); | |
267 } | 266 } |
268 | 267 |
269 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCEr rorCallback> errorCallback, ExceptionState& exceptionState) | 268 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState) |
270 { | 269 { |
271 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 270 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
272 return; | 271 return; |
273 | 272 |
274 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; | 273 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription; |
275 if (!sessionDescription) { | 274 if (!sessionDescription) { |
276 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); | 275 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "RTCSessionDescription")); |
277 return; | 276 return; |
278 } | 277 } |
279 | 278 |
280 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); | 279 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); |
281 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); | 280 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); |
282 } | 281 } |
283 | 282 |
284 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& exceptionState) | 283 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState) |
285 { | 284 { |
286 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); | 285 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); |
287 if (webSessionDescription.isNull()) | 286 if (webSessionDescription.isNull()) |
288 return nullptr; | 287 return nullptr; |
289 | 288 |
290 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription); | 289 return RTCSessionDescription::create(webSessionDescription); |
291 return desc.release(); | |
292 } | 290 } |
293 | 291 |
294 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) | 292 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) |
295 { | 293 { |
296 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 294 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
297 return; | 295 return; |
298 | 296 |
299 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); | 297 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); |
300 if (exceptionState.hadException()) | 298 if (exceptionState.hadException()) |
301 return; | 299 return; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
395 case ICEConnectionStateDisconnected: | 393 case ICEConnectionStateDisconnected: |
396 return "disconnected"; | 394 return "disconnected"; |
397 case ICEConnectionStateClosed: | 395 case ICEConnectionStateClosed: |
398 return "closed"; | 396 return "closed"; |
399 } | 397 } |
400 | 398 |
401 ASSERT_NOT_REACHED(); | 399 ASSERT_NOT_REACHED(); |
402 return String(); | 400 return String(); |
403 } | 401 } |
404 | 402 |
405 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& exceptionState) | 403 void RTCPeerConnection::addStream(PassRefPtrWillBeRawPtr<MediaStream> prpStream, const Dictionary& mediaConstraints, ExceptionState& exceptionState) |
406 { | 404 { |
407 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 405 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
408 return; | 406 return; |
409 | 407 |
410 RefPtr<MediaStream> stream = prpStream; | 408 RefPtrWillBeRawPtr<MediaStream> stream = prpStream; |
411 if (!stream) { | 409 if (!stream) { |
412 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); | 410 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); |
413 return; | 411 return; |
414 } | 412 } |
415 | 413 |
416 if (m_localStreams.contains(stream)) | 414 if (m_localStreams.contains(stream)) |
417 return; | 415 return; |
418 | 416 |
419 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); | 417 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); |
420 if (exceptionState.hadException()) | 418 if (exceptionState.hadException()) |
421 return; | 419 return; |
422 | 420 |
423 m_localStreams.append(stream); | 421 m_localStreams.append(stream); |
424 | 422 |
425 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); | 423 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); |
426 if (!valid) | 424 if (!valid) |
427 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream."); | 425 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream."); |
428 } | 426 } |
429 | 427 |
430 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& exceptionState) | 428 void RTCPeerConnection::removeStream(PassRefPtrWillBeRawPtr<MediaStream> prpStre am, ExceptionState& exceptionState) |
431 { | 429 { |
432 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 430 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
433 return; | 431 return; |
434 | 432 |
435 if (!prpStream) { | 433 if (!prpStream) { |
436 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); | 434 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType(1, "MediaStream")); |
437 return; | 435 return; |
438 } | 436 } |
439 | 437 |
440 RefPtr<MediaStream> stream = prpStream; | 438 RefPtrWillBeRawPtr<MediaStream> stream = prpStream; |
441 | 439 |
442 size_t pos = m_localStreams.find(stream); | 440 size_t pos = m_localStreams.find(stream); |
443 if (pos == kNotFound) | 441 if (pos == kNotFound) |
444 return; | 442 return; |
445 | 443 |
446 m_localStreams.remove(pos); | 444 m_localStreams.remove(pos); |
447 | 445 |
448 m_peerHandler->removeStream(stream->descriptor()); | 446 m_peerHandler->removeStream(stream->descriptor()); |
449 } | 447 } |
450 | 448 |
(...skipping 22 matching lines...) Expand all Loading... | |
473 return 0; | 471 return 0; |
474 } | 472 } |
475 | 473 |
476 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) | 474 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) |
477 { | 475 { |
478 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); | 476 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); |
479 // FIXME: Add passing selector as part of the statsRequest. | 477 // FIXME: Add passing selector as part of the statsRequest. |
480 m_peerHandler->getStats(statsRequest.release()); | 478 m_peerHandler->getStats(statsRequest.release()); |
481 } | 479 } |
482 | 480 |
483 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& exceptionState) | 481 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState) |
484 { | 482 { |
485 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 483 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
486 return nullptr; | 484 return nullptr; |
487 | 485 |
488 blink::WebRTCDataChannelInit init; | 486 blink::WebRTCDataChannelInit init; |
489 options.get("ordered", init.ordered); | 487 options.get("ordered", init.ordered); |
490 options.get("negotiated", init.negotiated); | 488 options.get("negotiated", init.negotiated); |
491 | 489 |
492 unsigned short value = 0; | 490 unsigned short value = 0; |
493 if (options.get("id", value)) | 491 if (options.get("id", value)) |
494 init.id = value; | 492 init.id = value; |
495 if (options.get("maxRetransmits", value)) | 493 if (options.get("maxRetransmits", value)) |
496 init.maxRetransmits = value; | 494 init.maxRetransmits = value; |
497 if (options.get("maxRetransmitTime", value)) | 495 if (options.get("maxRetransmitTime", value)) |
498 init.maxRetransmitTime = value; | 496 init.maxRetransmitTime = value; |
499 | 497 |
500 String protocolString; | 498 String protocolString; |
501 options.get("protocol", protocolString); | 499 options.get("protocol", protocolString); |
502 init.protocol = protocolString; | 500 init.protocol = protocolString; |
503 | 501 |
504 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), m_peerHandler.get(), label, init, exceptionState); | 502 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), m_peerHandler.get(), label, init, exceptionState); |
505 if (exceptionState.hadException()) | 503 if (exceptionState.hadException()) |
506 return nullptr; | 504 return nullptr; |
507 m_dataChannels.append(channel); | 505 m_dataChannels.append(channel); |
508 return channel.release(); | 506 return channel.release(); |
509 } | 507 } |
510 | 508 |
511 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) | 509 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) |
512 { | 510 { |
513 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { | 511 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { |
514 if ((*iter)->getTrackById(trackId)) | 512 if ((*iter)->getTrackById(trackId)) |
515 return true; | 513 return true; |
516 } | 514 } |
517 return false; | 515 return false; |
518 } | 516 } |
519 | 517 |
520 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& exceptionState) | 518 PassRefPtrWillBeRawPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRe fPtrWillBeRawPtr<MediaStreamTrack> prpTrack, ExceptionState& exceptionState) |
521 { | 519 { |
522 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 520 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
523 return nullptr; | 521 return nullptr; |
524 | 522 |
525 if (!prpTrack) { | 523 if (!prpTrack) { |
526 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(1, "MediaStreamTrack")); | 524 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type(1, "MediaStreamTrack")); |
527 return nullptr; | 525 return nullptr; |
528 } | 526 } |
529 | 527 |
530 RefPtr<MediaStreamTrack> track = prpTrack; | 528 RefPtrWillBeRawPtr<MediaStreamTrack> track = prpTrack; |
531 | 529 |
532 if (!hasLocalStreamWithTrackId(track->id())) { | 530 if (!hasLocalStreamWithTrackId(track->id())) { |
533 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided."); | 531 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided."); |
534 return nullptr; | 532 return nullptr; |
535 } | 533 } |
536 | 534 |
537 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executionContext(), m_peerHandler.get(), track.release(), exceptionState); | 535 RefPtrWillBeRawPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executi onContext(), m_peerHandler.get(), track.release(), exceptionState); |
538 if (exceptionState.hadException()) | 536 if (exceptionState.hadException()) |
539 return nullptr; | 537 return nullptr; |
540 return dtmfSender.release(); | 538 return dtmfSender.release(); |
541 } | 539 } |
542 | 540 |
543 void RTCPeerConnection::close(ExceptionState& exceptionState) | 541 void RTCPeerConnection::close(ExceptionState& exceptionState) |
544 { | 542 { |
545 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) | 543 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) |
546 return; | 544 return; |
547 | 545 |
548 m_peerHandler->stop(); | 546 m_peerHandler->stop(); |
549 | 547 |
550 changeIceConnectionState(ICEConnectionStateClosed); | 548 changeIceConnectionState(ICEConnectionStateClosed); |
551 changeIceGatheringState(ICEGatheringStateComplete); | 549 changeIceGatheringState(ICEGatheringStateComplete); |
552 changeSignalingState(SignalingStateClosed); | 550 changeSignalingState(SignalingStateClosed); |
553 } | 551 } |
554 | 552 |
555 void RTCPeerConnection::negotiationNeeded() | 553 void RTCPeerConnection::negotiationNeeded() |
556 { | 554 { |
557 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); | 555 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); |
558 } | 556 } |
559 | 557 |
560 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) | 558 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) |
561 { | 559 { |
562 ASSERT(executionContext()->isContextThread()); | 560 ASSERT(executionContext()->isContextThread()); |
563 if (webCandidate.isNull()) | 561 if (webCandidate.isNull()) |
564 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); | 562 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, nullptr )); |
565 else { | 563 else { |
566 RefPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::create(webCandid ate); | 564 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate); |
567 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); | 565 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); |
568 } | 566 } |
569 } | 567 } |
570 | 568 |
571 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) | 569 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) |
572 { | 570 { |
573 ASSERT(executionContext()->isContextThread()); | 571 ASSERT(executionContext()->isContextThread()); |
574 changeSignalingState(newState); | 572 changeSignalingState(newState); |
575 } | 573 } |
576 | 574 |
577 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) | 575 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) |
578 { | 576 { |
579 ASSERT(executionContext()->isContextThread()); | 577 ASSERT(executionContext()->isContextThread()); |
580 changeIceGatheringState(newState); | 578 changeIceGatheringState(newState); |
581 } | 579 } |
582 | 580 |
583 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) | 581 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) |
584 { | 582 { |
585 ASSERT(executionContext()->isContextThread()); | 583 ASSERT(executionContext()->isContextThread()); |
586 changeIceConnectionState(newState); | 584 changeIceConnectionState(newState); |
587 } | 585 } |
588 | 586 |
589 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) | 587 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) |
590 { | 588 { |
591 ASSERT(executionContext()->isContextThread()); | 589 ASSERT(executionContext()->isContextThread()); |
592 | 590 |
593 if (m_signalingState == SignalingStateClosed) | 591 if (m_signalingState == SignalingStateClosed) |
594 return; | 592 return; |
595 | 593 |
596 RefPtr<MediaStream> stream = MediaStream::create(executionContext(), remoteS tream); | 594 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream); |
597 m_remoteStreams.append(stream); | 595 m_remoteStreams.append(stream); |
598 | 596 |
599 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); | 597 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); |
600 } | 598 } |
601 | 599 |
602 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) | 600 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) |
603 { | 601 { |
604 ASSERT(executionContext()->isContextThread()); | 602 ASSERT(executionContext()->isContextThread()); |
605 | 603 |
606 MediaStreamDescriptor* streamDescriptor = remoteStream; | 604 MediaStreamDescriptor* streamDescriptor = remoteStream; |
607 ASSERT(streamDescriptor->client()); | 605 ASSERT(streamDescriptor->client()); |
608 | 606 |
609 RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->cli ent()); | 607 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client()); |
610 stream->streamEnded(); | 608 stream->streamEnded(); |
611 | 609 |
612 if (m_signalingState == SignalingStateClosed) | 610 if (m_signalingState == SignalingStateClosed) |
613 return; | 611 return; |
614 | 612 |
615 size_t pos = m_remoteStreams.find(stream); | 613 size_t pos = m_remoteStreams.find(stream); |
616 ASSERT(pos != kNotFound); | 614 ASSERT(pos != kNotFound); |
617 m_remoteStreams.remove(pos); | 615 m_remoteStreams.remove(pos); |
618 | 616 |
619 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); | 617 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); |
620 } | 618 } |
621 | 619 |
622 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) | 620 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) |
623 { | 621 { |
624 ASSERT(executionContext()->isContextThread()); | 622 ASSERT(executionContext()->isContextThread()); |
625 | 623 |
626 if (m_signalingState == SignalingStateClosed) | 624 if (m_signalingState == SignalingStateClosed) |
627 return; | 625 return; |
628 | 626 |
629 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), adoptPtr(handler)); | 627 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), adoptPtr(handler)); |
630 m_dataChannels.append(channel); | 628 m_dataChannels.append(channel); |
631 | 629 |
632 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); | 630 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); |
633 } | 631 } |
634 | 632 |
635 const AtomicString& RTCPeerConnection::interfaceName() const | 633 const AtomicString& RTCPeerConnection::interfaceName() const |
636 { | 634 { |
637 return EventTargetNames::RTCPeerConnection; | 635 return EventTargetNames::RTCPeerConnection; |
638 } | 636 } |
639 | 637 |
(...skipping 14 matching lines...) Expand all Loading... | |
654 | 652 |
655 void RTCPeerConnection::stop() | 653 void RTCPeerConnection::stop() |
656 { | 654 { |
657 if (m_stopped) | 655 if (m_stopped) |
658 return; | 656 return; |
659 | 657 |
660 m_stopped = true; | 658 m_stopped = true; |
661 m_iceConnectionState = ICEConnectionStateClosed; | 659 m_iceConnectionState = ICEConnectionStateClosed; |
662 m_signalingState = SignalingStateClosed; | 660 m_signalingState = SignalingStateClosed; |
663 | 661 |
664 Vector<RefPtr<RTCDataChannel> >::iterator i = m_dataChannels.begin(); | 662 WillBeHeapVector<RefPtrWillBeMember<RTCDataChannel> >::iterator i = m_dataCh annels.begin(); |
665 for (; i != m_dataChannels.end(); ++i) | 663 for (; i != m_dataChannels.end(); ++i) |
666 (*i)->stop(); | 664 (*i)->stop(); |
667 | 665 |
668 m_dispatchScheduledEventRunner.stop(); | 666 m_dispatchScheduledEventRunner.stop(); |
669 } | 667 } |
670 | 668 |
671 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) | 669 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) |
672 { | 670 { |
673 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) { | 671 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) { |
674 m_signalingState = signalingState; | 672 m_signalingState = signalingState; |
(...skipping 29 matching lines...) Expand all Loading... | |
704 WillBeHeapVector<RefPtrWillBeMember<Event> > events; | 702 WillBeHeapVector<RefPtrWillBeMember<Event> > events; |
705 events.swap(m_scheduledEvents); | 703 events.swap(m_scheduledEvents); |
706 | 704 |
707 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); | 705 WillBeHeapVector<RefPtrWillBeMember<Event> >::iterator it = events.begin(); |
708 for (; it != events.end(); ++it) | 706 for (; it != events.end(); ++it) |
709 dispatchEvent((*it).release()); | 707 dispatchEvent((*it).release()); |
710 | 708 |
711 events.clear(); | 709 events.clear(); |
712 } | 710 } |
713 | 711 |
712 void RTCPeerConnection::trace(Visitor* visitor) | |
713 { | |
714 visitor->trace(m_localStreams); | |
715 visitor->trace(m_remoteStreams); | |
716 visitor->trace(m_dataChannels); | |
717 visitor->trace(m_scheduledEvents); | |
718 } | |
719 | |
714 } // namespace WebCore | 720 } // namespace WebCore |
OLD | NEW |