| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 371 |
| 372 if (m_localStreams.contains(stream)) | 372 if (m_localStreams.contains(stream)) |
| 373 return; | 373 return; |
| 374 | 374 |
| 375 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); | 375 RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaCon
straints, ec); |
| 376 if (ec) | 376 if (ec) |
| 377 return; | 377 return; |
| 378 | 378 |
| 379 m_localStreams.append(stream); | 379 m_localStreams.append(stream); |
| 380 | 380 |
| 381 bool valid = m_peerHandler->addStream(stream->webStream(), constraints); | 381 bool valid = m_peerHandler->addStream(stream->descriptor(), constraints); |
| 382 if (!valid) | 382 if (!valid) |
| 383 ec = SYNTAX_ERR; | 383 ec = SYNTAX_ERR; |
| 384 } | 384 } |
| 385 | 385 |
| 386 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio
nCode& ec) | 386 void RTCPeerConnection::removeStream(PassRefPtr<MediaStream> prpStream, Exceptio
nCode& ec) |
| 387 { | 387 { |
| 388 if (m_signalingState == SignalingStateClosed) { | 388 if (m_signalingState == SignalingStateClosed) { |
| 389 ec = INVALID_STATE_ERR; | 389 ec = INVALID_STATE_ERR; |
| 390 return; | 390 return; |
| 391 } | 391 } |
| 392 | 392 |
| 393 if (!prpStream) { | 393 if (!prpStream) { |
| 394 ec = TYPE_MISMATCH_ERR; | 394 ec = TYPE_MISMATCH_ERR; |
| 395 return; | 395 return; |
| 396 } | 396 } |
| 397 | 397 |
| 398 RefPtr<MediaStream> stream = prpStream; | 398 RefPtr<MediaStream> stream = prpStream; |
| 399 | 399 |
| 400 size_t pos = m_localStreams.find(stream); | 400 size_t pos = m_localStreams.find(stream); |
| 401 if (pos == notFound) | 401 if (pos == notFound) |
| 402 return; | 402 return; |
| 403 | 403 |
| 404 m_localStreams.remove(pos); | 404 m_localStreams.remove(pos); |
| 405 | 405 |
| 406 m_peerHandler->removeStream(stream->webStream()); | 406 m_peerHandler->removeStream(stream->descriptor()); |
| 407 } | 407 } |
| 408 | 408 |
| 409 MediaStreamVector RTCPeerConnection::getLocalStreams() const | 409 MediaStreamVector RTCPeerConnection::getLocalStreams() const |
| 410 { | 410 { |
| 411 return m_localStreams; | 411 return m_localStreams; |
| 412 } | 412 } |
| 413 | 413 |
| 414 MediaStreamVector RTCPeerConnection::getRemoteStreams() const | 414 MediaStreamVector RTCPeerConnection::getRemoteStreams() const |
| 415 { | 415 { |
| 416 return m_remoteStreams; | 416 return m_remoteStreams; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 ASSERT(scriptExecutionContext()->isContextThread()); | 543 ASSERT(scriptExecutionContext()->isContextThread()); |
| 544 changeIceGatheringState(newState); | 544 changeIceGatheringState(newState); |
| 545 } | 545 } |
| 546 | 546 |
| 547 void RTCPeerConnection::didChangeIceConnectionState(IceConnectionState newState) | 547 void RTCPeerConnection::didChangeIceConnectionState(IceConnectionState newState) |
| 548 { | 548 { |
| 549 ASSERT(scriptExecutionContext()->isContextThread()); | 549 ASSERT(scriptExecutionContext()->isContextThread()); |
| 550 changeIceConnectionState(newState); | 550 changeIceConnectionState(newState); |
| 551 } | 551 } |
| 552 | 552 |
| 553 void RTCPeerConnection::didAddRemoteStream(WebKit::WebMediaStream webStream) | 553 void RTCPeerConnection::didAddRemoteStream(PassRefPtr<MediaStreamDescriptor> str
eamDescriptor) |
| 554 { | 554 { |
| 555 ASSERT(scriptExecutionContext()->isContextThread()); | 555 ASSERT(scriptExecutionContext()->isContextThread()); |
| 556 | 556 |
| 557 if (m_signalingState == SignalingStateClosed) | 557 if (m_signalingState == SignalingStateClosed) |
| 558 return; | 558 return; |
| 559 | 559 |
| 560 RefPtr<MediaStream> stream = MediaStream::create(scriptExecutionContext(), w
ebStream); | 560 RefPtr<MediaStream> stream = MediaStream::create(scriptExecutionContext(), s
treamDescriptor); |
| 561 m_remoteStreams.append(stream); | 561 m_remoteStreams.append(stream); |
| 562 | 562 |
| 563 scheduleDispatchEvent(MediaStreamEvent::create(eventNames().addstreamEvent,
false, false, stream.release())); | 563 scheduleDispatchEvent(MediaStreamEvent::create(eventNames().addstreamEvent,
false, false, stream.release())); |
| 564 } | 564 } |
| 565 | 565 |
| 566 void RTCPeerConnection::didRemoveRemoteStream(WebKit::WebMediaStream webStream) | 566 void RTCPeerConnection::didRemoveRemoteStream(MediaStreamDescriptor* streamDescr
iptor) |
| 567 { | 567 { |
| 568 ASSERT(scriptExecutionContext()->isContextThread()); | 568 ASSERT(scriptExecutionContext()->isContextThread()); |
| 569 ASSERT(streamDescriptor->client()); |
| 569 | 570 |
| 570 RefPtr<MediaStream> stream = static_cast<MediaStream*>(webStream.client()); | 571 RefPtr<MediaStream> stream = static_cast<MediaStream*>(streamDescriptor->cli
ent()); |
| 571 webStream.streamEnded(); | 572 stream->streamEnded(); |
| 572 | 573 |
| 573 if (m_signalingState == SignalingStateClosed) | 574 if (m_signalingState == SignalingStateClosed) |
| 574 return; | 575 return; |
| 575 | 576 |
| 576 size_t pos = m_remoteStreams.find(stream); | 577 size_t pos = m_remoteStreams.find(stream); |
| 577 ASSERT(pos != notFound); | 578 ASSERT(pos != notFound); |
| 578 m_remoteStreams.remove(pos); | 579 m_remoteStreams.remove(pos); |
| 579 | 580 |
| 580 scheduleDispatchEvent(MediaStreamEvent::create(eventNames().removestreamEven
t, false, false, stream.release())); | 581 scheduleDispatchEvent(MediaStreamEvent::create(eventNames().removestreamEven
t, false, false, stream.release())); |
| 581 } | 582 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 events.swap(m_scheduledEvents); | 666 events.swap(m_scheduledEvents); |
| 666 | 667 |
| 667 Vector<RefPtr<Event> >::iterator it = events.begin(); | 668 Vector<RefPtr<Event> >::iterator it = events.begin(); |
| 668 for (; it != events.end(); ++it) | 669 for (; it != events.end(); ++it) |
| 669 dispatchEvent((*it).release()); | 670 dispatchEvent((*it).release()); |
| 670 | 671 |
| 671 events.clear(); | 672 events.clear(); |
| 672 } | 673 } |
| 673 | 674 |
| 674 } // namespace WebCore | 675 } // namespace WebCore |
| OLD | NEW |