Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(971)

Side by Side Diff: Source/modules/mediastream/RTCPeerConnection.cpp

Issue 173363002: Move mediastream module to oilpan transition types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added Finalized Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "public/platform/WebRTCDataChannelHandler.h" 62 #include "public/platform/WebRTCDataChannelHandler.h"
63 #include "public/platform/WebRTCDataChannelInit.h" 63 #include "public/platform/WebRTCDataChannelInit.h"
64 #include "public/platform/WebRTCICECandidate.h" 64 #include "public/platform/WebRTCICECandidate.h"
65 #include "public/platform/WebRTCSessionDescription.h" 65 #include "public/platform/WebRTCSessionDescription.h"
66 #include "public/platform/WebRTCSessionDescriptionRequest.h" 66 #include "public/platform/WebRTCSessionDescriptionRequest.h"
67 #include "public/platform/WebRTCStatsRequest.h" 67 #include "public/platform/WebRTCStatsRequest.h"
68 #include "public/platform/WebRTCVoidRequest.h" 68 #include "public/platform/WebRTCVoidRequest.h"
69 69
70 namespace WebCore { 70 namespace WebCore {
71 71
72 DEFINE_GC_INFO(RTCPeerConnection);
73
72 namespace { 74 namespace {
73 75
74 static bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingSta te state, ExceptionState& exceptionState) 76 static bool throwExceptionIfSignalingStateClosed(RTCPeerConnection::SignalingSta te state, ExceptionState& exceptionState)
75 { 77 {
76 if (state == RTCPeerConnection::SignalingStateClosed) { 78 if (state == RTCPeerConnection::SignalingStateClosed) {
77 exceptionState.throwDOMException(InvalidStateError, "The RTCPeerConnecti on's signalingState is 'closed'."); 79 exceptionState.throwDOMException(InvalidStateError, "The RTCPeerConnecti on's signalingState is 'closed'.");
78 return true; 80 return true;
79 } 81 }
80 82
81 return false; 83 return false;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 return 0; 152 return 0;
151 } 153 }
152 154
153 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential)); 155 rtcConfiguration->appendServer(RTCIceServer::create(url, username, c redential));
154 } 156 }
155 } 157 }
156 158
157 return rtcConfiguration.release(); 159 return rtcConfiguration.release();
158 } 160 }
159 161
160 PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionContext* contex t, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, Excep tionState& exceptionState) 162 PassRefPtrWillBeRawPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionCon text* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstr aints, ExceptionState& exceptionState)
161 { 163 {
162 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); 164 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState);
163 if (exceptionState.hadException()) 165 if (exceptionState.hadException())
164 return 0; 166 return 0;
165 167
166 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 168 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
167 if (exceptionState.hadException()) 169 if (exceptionState.hadException())
168 return 0; 170 return 0;
169 171
170 RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(co ntext, configuration.release(), constraints, exceptionState)); 172 RefPtrWillBeRawPtr<RTCPeerConnection> peerConnection = adoptRefCountedWillBe RefCountedGarbageCollected(new RTCPeerConnection(context, configuration.release( ), constraints, exceptionState));
171 peerConnection->suspendIfNeeded(); 173 peerConnection->suspendIfNeeded();
172 if (exceptionState.hadException()) 174 if (exceptionState.hadException())
173 return 0; 175 return 0;
174 176
175 return peerConnection.release(); 177 return peerConnection.release();
176 } 178 }
177 179
178 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState) 180 RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, PassRefPtr<RTCCo nfiguration> configuration, blink::WebMediaConstraints constraints, ExceptionSta te& exceptionState)
179 : ActiveDOMObject(context) 181 : ActiveDOMObject(context)
180 , m_signalingState(SignalingStateStable) 182 , m_signalingState(SignalingStateStable)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 241 }
240 242
241 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 243 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
242 if (exceptionState.hadException()) 244 if (exceptionState.hadException())
243 return; 245 return;
244 246
245 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback); 247 RefPtr<RTCSessionDescriptionRequest> request = RTCSessionDescriptionRequestI mpl::create(executionContext(), successCallback, errorCallback);
246 m_peerHandler->createAnswer(request.release(), constraints); 248 m_peerHandler->createAnswer(request.release(), constraints);
247 } 249 }
248 250
249 void RTCPeerConnection::setLocalDescription(PassRefPtr<RTCSessionDescription> pr pSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCErr orCallback> errorCallback, ExceptionState& exceptionState) 251 void RTCPeerConnection::setLocalDescription(PassRefPtrWillBeRawPtr<RTCSessionDes cription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassO wnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState)
250 { 252 {
251 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 253 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
252 return; 254 return;
253 255
254 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 256 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription;
255 if (!sessionDescription) { 257 if (!sessionDescription) {
256 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("session description", "RTCSessionDescription")); 258 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("session description", "RTCSessionDescription"));
257 return; 259 return;
258 } 260 }
259 261
260 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); 262 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback);
261 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription()); 263 m_peerHandler->setLocalDescription(request.release(), sessionDescription->we bSessionDescription());
262 } 264 }
263 265
264 PassRefPtr<RTCSessionDescription> RTCPeerConnection::localDescription(ExceptionS tate& exceptionState) 266 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::localDescriptio n(ExceptionState& exceptionState)
265 { 267 {
266 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description(); 268 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->local Description();
267 if (webSessionDescription.isNull()) 269 if (webSessionDescription.isNull())
268 return 0; 270 return 0;
269 271
270 RefPtr<RTCSessionDescription> sessionDescription = RTCSessionDescription::cr eate(webSessionDescription); 272 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = RTCSessionDes cription::create(webSessionDescription);
271 return sessionDescription.release(); 273 return sessionDescription.release();
272 } 274 }
273 275
274 void RTCPeerConnection::setRemoteDescription(PassRefPtr<RTCSessionDescription> p rpSessionDescription, PassOwnPtr<VoidCallback> successCallback, PassOwnPtr<RTCEr rorCallback> errorCallback, ExceptionState& exceptionState) 276 void RTCPeerConnection::setRemoteDescription(PassRefPtrWillBeRawPtr<RTCSessionDe scription> prpSessionDescription, PassOwnPtr<VoidCallback> successCallback, Pass OwnPtr<RTCErrorCallback> errorCallback, ExceptionState& exceptionState)
275 { 277 {
276 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 278 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
277 return; 279 return;
278 280
279 RefPtr<RTCSessionDescription> sessionDescription = prpSessionDescription; 281 RefPtrWillBeRawPtr<RTCSessionDescription> sessionDescription = prpSessionDes cription;
280 if (!sessionDescription) { 282 if (!sessionDescription) {
281 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("session description", "RTCSessionDescription")); 283 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("session description", "RTCSessionDescription"));
282 return; 284 return;
283 } 285 }
284 286
285 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback); 287 RefPtr<RTCVoidRequest> request = RTCVoidRequestImpl::create(executionContext (), successCallback, errorCallback);
286 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription()); 288 m_peerHandler->setRemoteDescription(request.release(), sessionDescription->w ebSessionDescription());
287 } 289 }
288 290
289 PassRefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription(Exception State& exceptionState) 291 PassRefPtrWillBeRawPtr<RTCSessionDescription> RTCPeerConnection::remoteDescripti on(ExceptionState& exceptionState)
290 { 292 {
291 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription(); 293 blink::WebRTCSessionDescription webSessionDescription = m_peerHandler->remot eDescription();
292 if (webSessionDescription.isNull()) 294 if (webSessionDescription.isNull())
293 return 0; 295 return 0;
294 296
295 RefPtr<RTCSessionDescription> desc = RTCSessionDescription::create(webSessio nDescription); 297 RefPtrWillBeRawPtr<RTCSessionDescription> desc = RTCSessionDescription::crea te(webSessionDescription);
296 return desc.release(); 298 return desc.release();
297 } 299 }
298 300
299 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState) 301 void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dict ionary& mediaConstraints, ExceptionState& exceptionState)
300 { 302 {
301 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 303 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
302 return; 304 return;
303 305
304 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState); 306 RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration , exceptionState);
305 if (exceptionState.hadException()) 307 if (exceptionState.hadException())
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 case ICEConnectionStateDisconnected: 408 case ICEConnectionStateDisconnected:
407 return "disconnected"; 409 return "disconnected";
408 case ICEConnectionStateClosed: 410 case ICEConnectionStateClosed:
409 return "closed"; 411 return "closed";
410 } 412 }
411 413
412 ASSERT_NOT_REACHED(); 414 ASSERT_NOT_REACHED();
413 return String(); 415 return String();
414 } 416 }
415 417
416 void RTCPeerConnection::addStream(PassRefPtr<MediaStream> prpStream, const Dicti onary& mediaConstraints, ExceptionState& exceptionState) 418 void RTCPeerConnection::addStream(PassRefPtrWillBeRawPtr<MediaStream> prpStream, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
417 { 419 {
418 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 420 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
419 return; 421 return;
420 422
421 RefPtr<MediaStream> stream = prpStream; 423 RefPtrWillBeRawPtr<MediaStream> stream = prpStream;
422 if (!stream) { 424 if (!stream) {
423 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("stream", "MediaStream")); 425 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("stream", "MediaStream"));
424 return; 426 return;
425 } 427 }
426 428
427 if (m_localStreams.contains(stream)) 429 if (m_localStreams.contains(stream))
428 return; 430 return;
429 431
430 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState); 432 blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaC onstraints, exceptionState);
431 if (exceptionState.hadException()) 433 if (exceptionState.hadException())
432 return; 434 return;
433 435
434 m_localStreams.append(stream); 436 m_localStreams.append(stream);
435 437
436 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); 438 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints);
437 if (!valid) 439 if (!valid)
438 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream."); 440 exceptionState.throwDOMException(SyntaxError, "Unable to add the provide d stream.");
439 } 441 }
440 442
441 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio nState& exceptionState) 443 void RTCPeerConnection::removeStream(PassRefPtrWillBeRawPtr<MediaStream> prpStre am, ExceptionState& exceptionState)
442 { 444 {
443 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 445 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
444 return; 446 return;
445 447
446 if (!prpStream) { 448 if (!prpStream) {
447 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("stream", "MediaStream")); 449 exceptionState.throwDOMException(TypeMismatchError, ExceptionMessages::a rgumentNullOrIncorrectType("stream", "MediaStream"));
448 return; 450 return;
449 } 451 }
450 452
451 RefPtr<MediaStream> stream = prpStream; 453 RefPtrWillBeRawPtr<MediaStream> stream = prpStream;
452 454
453 size_t pos = m_localStreams.find(stream); 455 size_t pos = m_localStreams.find(stream);
454 if (pos == kNotFound) 456 if (pos == kNotFound)
455 return; 457 return;
456 458
457 m_localStreams.remove(pos); 459 m_localStreams.remove(pos);
458 460
459 m_peerHandler->removeStream(stream->descriptor()); 461 m_peerHandler->removeStream(stream->descriptor());
460 } 462 }
461 463
(...skipping 22 matching lines...) Expand all
484 return 0; 486 return 0;
485 } 487 }
486 488
487 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector) 489 void RTCPeerConnection::getStats(PassOwnPtr<RTCStatsCallback> successCallback, P assRefPtr<MediaStreamTrack> selector)
488 { 490 {
489 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector); 491 RefPtr<RTCStatsRequest> statsRequest = RTCStatsRequestImpl::create(execution Context(), successCallback, selector);
490 // FIXME: Add passing selector as part of the statsRequest. 492 // FIXME: Add passing selector as part of the statsRequest.
491 m_peerHandler->getStats(statsRequest.release()); 493 m_peerHandler->getStats(statsRequest.release());
492 } 494 }
493 495
494 PassRefPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(String label, co nst Dictionary& options, ExceptionState& exceptionState) 496 PassRefPtrWillBeRawPtr<RTCDataChannel> RTCPeerConnection::createDataChannel(Stri ng label, const Dictionary& options, ExceptionState& exceptionState)
495 { 497 {
496 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 498 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
497 return 0; 499 return 0;
498 500
499 blink::WebRTCDataChannelInit init; 501 blink::WebRTCDataChannelInit init;
500 options.get("ordered", init.ordered); 502 options.get("ordered", init.ordered);
501 options.get("negotiated", init.negotiated); 503 options.get("negotiated", init.negotiated);
502 504
503 unsigned short value = 0; 505 unsigned short value = 0;
504 if (options.get("id", value)) 506 if (options.get("id", value))
505 init.id = value; 507 init.id = value;
506 if (options.get("maxRetransmits", value)) 508 if (options.get("maxRetransmits", value))
507 init.maxRetransmits = value; 509 init.maxRetransmits = value;
508 if (options.get("maxRetransmitTime", value)) 510 if (options.get("maxRetransmitTime", value))
509 init.maxRetransmitTime = value; 511 init.maxRetransmitTime = value;
510 512
511 String protocolString; 513 String protocolString;
512 options.get("protocol", protocolString); 514 options.get("protocol", protocolString);
513 init.protocol = protocolString; 515 init.protocol = protocolString;
514 516
515 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), m_peerHandler.get(), label, init, exceptionState); 517 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), m_peerHandler.get(), label, init, exceptionState);
516 if (exceptionState.hadException()) 518 if (exceptionState.hadException())
517 return 0; 519 return 0;
518 m_dataChannels.append(channel); 520 m_dataChannels.append(channel);
519 return channel.release(); 521 return channel.release();
520 } 522 }
521 523
522 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId) 524 bool RTCPeerConnection::hasLocalStreamWithTrackId(const String& trackId)
523 { 525 {
524 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) { 526 for (MediaStreamVector::iterator iter = m_localStreams.begin(); iter != m_lo calStreams.end(); ++iter) {
525 if ((*iter)->getTrackById(trackId)) 527 if ((*iter)->getTrackById(trackId))
526 return true; 528 return true;
527 } 529 }
528 return false; 530 return false;
529 } 531 }
530 532
531 PassRefPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRefPtr<MediaSt reamTrack> prpTrack, ExceptionState& exceptionState) 533 PassRefPtrWillBeRawPtr<RTCDTMFSender> RTCPeerConnection::createDTMFSender(PassRe fPtrWillBeRawPtr<MediaStreamTrack> prpTrack, ExceptionState& exceptionState)
532 { 534 {
533 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 535 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
534 return 0; 536 return 0;
535 537
536 if (!prpTrack) { 538 if (!prpTrack) {
537 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type("track", "MediaStreamTrack")); 539 exceptionState.throwTypeError(ExceptionMessages::argumentNullOrIncorrect Type("track", "MediaStreamTrack"));
538 return 0; 540 return 0;
539 } 541 }
540 542
541 RefPtr<MediaStreamTrack> track = prpTrack; 543 RefPtrWillBeRawPtr<MediaStreamTrack> track = prpTrack;
542 544
543 if (!hasLocalStreamWithTrackId(track->id())) { 545 if (!hasLocalStreamWithTrackId(track->id())) {
544 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided."); 546 exceptionState.throwDOMException(SyntaxError, "No local stream is availa ble for the track provided.");
545 return 0; 547 return 0;
546 } 548 }
547 549
548 RefPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executionContext(), m_peerHandler.get(), track.release(), exceptionState); 550 RefPtrWillBeRawPtr<RTCDTMFSender> dtmfSender = RTCDTMFSender::create(executi onContext(), m_peerHandler.get(), track.release(), exceptionState);
549 if (exceptionState.hadException()) 551 if (exceptionState.hadException())
550 return 0; 552 return 0;
551 return dtmfSender.release(); 553 return dtmfSender.release();
552 } 554 }
553 555
554 void RTCPeerConnection::close(ExceptionState& exceptionState) 556 void RTCPeerConnection::close(ExceptionState& exceptionState)
555 { 557 {
556 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState)) 558 if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
557 return; 559 return;
558 560
559 m_peerHandler->stop(); 561 m_peerHandler->stop();
560 562
561 changeIceConnectionState(ICEConnectionStateClosed); 563 changeIceConnectionState(ICEConnectionStateClosed);
562 changeIceGatheringState(ICEGatheringStateComplete); 564 changeIceGatheringState(ICEGatheringStateComplete);
563 changeSignalingState(SignalingStateClosed); 565 changeSignalingState(SignalingStateClosed);
564 } 566 }
565 567
566 void RTCPeerConnection::negotiationNeeded() 568 void RTCPeerConnection::negotiationNeeded()
567 { 569 {
568 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded)); 570 scheduleDispatchEvent(Event::create(EventTypeNames::negotiationneeded));
569 } 571 }
570 572
571 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate) 573 void RTCPeerConnection::didGenerateICECandidate(const blink::WebRTCICECandidate& webCandidate)
572 { 574 {
573 ASSERT(executionContext()->isContextThread()); 575 ASSERT(executionContext()->isContextThread());
574 if (webCandidate.isNull()) 576 if (webCandidate.isNull())
575 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, 0)); 577 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, 0));
576 else { 578 else {
577 RefPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::create(webCandid ate); 579 RefPtrWillBeRawPtr<RTCIceCandidate> iceCandidate = RTCIceCandidate::crea te(webCandidate);
578 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release())); 580 scheduleDispatchEvent(RTCIceCandidateEvent::create(false, false, iceCand idate.release()));
579 } 581 }
580 } 582 }
581 583
582 void RTCPeerConnection::didChangeSignalingState(SignalingState newState) 584 void RTCPeerConnection::didChangeSignalingState(SignalingState newState)
583 { 585 {
584 ASSERT(executionContext()->isContextThread()); 586 ASSERT(executionContext()->isContextThread());
585 changeSignalingState(newState); 587 changeSignalingState(newState);
586 } 588 }
587 589
588 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState) 590 void RTCPeerConnection::didChangeICEGatheringState(ICEGatheringState newState)
589 { 591 {
590 ASSERT(executionContext()->isContextThread()); 592 ASSERT(executionContext()->isContextThread());
591 changeIceGatheringState(newState); 593 changeIceGatheringState(newState);
592 } 594 }
593 595
594 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState) 596 void RTCPeerConnection::didChangeICEConnectionState(ICEConnectionState newState)
595 { 597 {
596 ASSERT(executionContext()->isContextThread()); 598 ASSERT(executionContext()->isContextThread());
597 changeIceConnectionState(newState); 599 changeIceConnectionState(newState);
598 } 600 }
599 601
600 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream) 602 void RTCPeerConnection::didAddRemoteStream(const blink::WebMediaStream& remoteSt ream)
601 { 603 {
602 ASSERT(executionContext()->isContextThread()); 604 ASSERT(executionContext()->isContextThread());
603 605
604 if (m_signalingState == SignalingStateClosed) 606 if (m_signalingState == SignalingStateClosed)
605 return; 607 return;
606 608
607 RefPtr<MediaStream> stream = MediaStream::create(executionContext(), remoteS tream); 609 RefPtrWillBeRawPtr<MediaStream> stream = MediaStream::create(executionContex t(), remoteStream);
608 m_remoteStreams.append(stream); 610 m_remoteStreams.append(stream);
609 611
610 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release())); 612 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::addstream, fa lse, false, stream.release()));
611 } 613 }
612 614
613 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream) 615 void RTCPeerConnection::didRemoveRemoteStream(const blink::WebMediaStream& remot eStream)
614 { 616 {
615 ASSERT(executionContext()->isContextThread()); 617 ASSERT(executionContext()->isContextThread());
616 618
617 MediaStreamDescriptor* streamDescriptor = remoteStream; 619 MediaStreamDescriptor* streamDescriptor = remoteStream;
618 ASSERT(streamDescriptor->client()); 620 ASSERT(streamDescriptor->client());
619 621
620 RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->cli ent()); 622 RefPtrWillBeRawPtr<MediaStream> stream = static_cast<MediaStream*>(streamDes criptor->client());
621 stream->streamEnded(); 623 stream->streamEnded();
622 624
623 if (m_signalingState == SignalingStateClosed) 625 if (m_signalingState == SignalingStateClosed)
624 return; 626 return;
625 627
626 size_t pos = m_remoteStreams.find(stream); 628 size_t pos = m_remoteStreams.find(stream);
627 ASSERT(pos != kNotFound); 629 ASSERT(pos != kNotFound);
628 m_remoteStreams.remove(pos); 630 m_remoteStreams.remove(pos);
629 631
630 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release())); 632 scheduleDispatchEvent(MediaStreamEvent::create(EventTypeNames::removestream, false, false, stream.release()));
631 } 633 }
632 634
633 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler) 635 void RTCPeerConnection::didAddRemoteDataChannel(blink::WebRTCDataChannelHandler* handler)
634 { 636 {
635 ASSERT(executionContext()->isContextThread()); 637 ASSERT(executionContext()->isContextThread());
636 638
637 if (m_signalingState == SignalingStateClosed) 639 if (m_signalingState == SignalingStateClosed)
638 return; 640 return;
639 641
640 RefPtr<RTCDataChannel> channel = RTCDataChannel::create(executionContext(), adoptPtr(handler)); 642 RefPtrWillBeRawPtr<RTCDataChannel> channel = RTCDataChannel::create(executio nContext(), adoptPtr(handler));
641 m_dataChannels.append(channel); 643 m_dataChannels.append(channel);
642 644
643 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release())); 645 scheduleDispatchEvent(RTCDataChannelEvent::create(EventTypeNames::datachanne l, false, false, channel.release()));
644 } 646 }
645 647
646 const AtomicString& RTCPeerConnection::interfaceName() const 648 const AtomicString& RTCPeerConnection::interfaceName() const
647 { 649 {
648 return EventTargetNames::RTCPeerConnection; 650 return EventTargetNames::RTCPeerConnection;
649 } 651 }
650 652
(...skipping 14 matching lines...) Expand all
665 667
666 void RTCPeerConnection::stop() 668 void RTCPeerConnection::stop()
667 { 669 {
668 if (m_stopped) 670 if (m_stopped)
669 return; 671 return;
670 672
671 m_stopped = true; 673 m_stopped = true;
672 m_iceConnectionState = ICEConnectionStateClosed; 674 m_iceConnectionState = ICEConnectionStateClosed;
673 m_signalingState = SignalingStateClosed; 675 m_signalingState = SignalingStateClosed;
674 676
675 Vector<RefPtr<RTCDataChannel> >::iterator i = m_dataChannels.begin(); 677 WillBeHeapVector<RefPtrWillBeMember<RTCDataChannel> >::iterator i = m_dataCh annels.begin();
676 for (; i != m_dataChannels.end(); ++i) 678 for (; i != m_dataChannels.end(); ++i)
677 (*i)->stop(); 679 (*i)->stop();
678 680
679 m_dispatchScheduledEventRunner.stop(); 681 m_dispatchScheduledEventRunner.stop();
680 } 682 }
681 683
682 void RTCPeerConnection::changeSignalingState(SignalingState signalingState) 684 void RTCPeerConnection::changeSignalingState(SignalingState signalingState)
683 { 685 {
684 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) { 686 if (m_signalingState != SignalingStateClosed && m_signalingState != signalin gState) {
685 m_signalingState = signalingState; 687 m_signalingState = signalingState;
(...skipping 29 matching lines...) Expand all
715 Vector<RefPtr<Event> > events; 717 Vector<RefPtr<Event> > events;
716 events.swap(m_scheduledEvents); 718 events.swap(m_scheduledEvents);
717 719
718 Vector<RefPtr<Event> >::iterator it = events.begin(); 720 Vector<RefPtr<Event> >::iterator it = events.begin();
719 for (; it != events.end(); ++it) 721 for (; it != events.end(); ++it)
720 dispatchEvent((*it).release()); 722 dispatchEvent((*it).release());
721 723
722 events.clear(); 724 events.clear();
723 } 725 }
724 726
727 void RTCPeerConnection::trace(Visitor* visitor)
728 {
729 visitor->trace(m_dataChannels);
730 }
731
725 } // namespace WebCore 732 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698