| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/media_stream_impl.h" | 5 #include "content/renderer/media/media_stream_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 << "Stopping stream " << it->first; | 377 << "Stopping stream " << it->first; |
| 378 media_stream_dispatcher_->StopStream(it->first); | 378 media_stream_dispatcher_->StopStream(it->first); |
| 379 local_media_streams_.erase(it); | 379 local_media_streams_.erase(it); |
| 380 it = local_media_streams_.begin(); | 380 it = local_media_streams_.begin(); |
| 381 } else { | 381 } else { |
| 382 ++it; | 382 ++it; |
| 383 } | 383 } |
| 384 } | 384 } |
| 385 } | 385 } |
| 386 | 386 |
| 387 void MediaStreamImpl::OnSocketDispatcherDestroyed() { | |
| 388 CleanupPeerConnectionFactory(); | |
| 389 } | |
| 390 | |
| 391 void MediaStreamImpl::InitializeWorkerThread(talk_base::Thread** thread, | 387 void MediaStreamImpl::InitializeWorkerThread(talk_base::Thread** thread, |
| 392 base::WaitableEvent* event) { | 388 base::WaitableEvent* event) { |
| 393 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 389 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 394 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); | 390 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
| 395 *thread = jingle_glue::JingleThreadWrapper::current(); | 391 *thread = jingle_glue::JingleThreadWrapper::current(); |
| 396 event->Signal(); | 392 event->Signal(); |
| 397 } | 393 } |
| 398 | 394 |
| 399 void MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread( | 395 void MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread( |
| 400 base::WaitableEvent* event) { | 396 base::WaitableEvent* event) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 DCHECK(worker_thread_); | 431 DCHECK(worker_thread_); |
| 436 } | 432 } |
| 437 | 433 |
| 438 if (!network_manager_) { | 434 if (!network_manager_) { |
| 439 base::WaitableEvent event(true, false); | 435 base::WaitableEvent event(true, false); |
| 440 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 436 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| 441 &MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread, | 437 &MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread, |
| 442 base::Unretained(this), | 438 base::Unretained(this), |
| 443 &event)); | 439 &event)); |
| 444 event.Wait(); | 440 event.Wait(); |
| 445 p2p_socket_dispatcher_->AddDestructionObserver(this); | |
| 446 } | 441 } |
| 447 | 442 |
| 448 if (!socket_factory_.get()) { | 443 if (!socket_factory_.get()) { |
| 449 socket_factory_.reset( | 444 socket_factory_.reset( |
| 450 new content::IpcPacketSocketFactory(p2p_socket_dispatcher_)); | 445 new content::IpcPacketSocketFactory(p2p_socket_dispatcher_)); |
| 451 } | 446 } |
| 452 | 447 |
| 453 if (!dependency_factory_->PeerConnectionFactoryCreated()) { | 448 if (!dependency_factory_->PeerConnectionFactoryCreated()) { |
| 454 if (!dependency_factory_->CreatePeerConnectionFactory( | 449 if (!dependency_factory_->CreatePeerConnectionFactory( |
| 455 worker_thread_, | 450 worker_thread_, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 475 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 470 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| 476 &MediaStreamImpl::DeleteIpcNetworkManager, | 471 &MediaStreamImpl::DeleteIpcNetworkManager, |
| 477 base::Unretained(this))); | 472 base::Unretained(this))); |
| 478 // Stopping the thread will wait until all tasks have been | 473 // Stopping the thread will wait until all tasks have been |
| 479 // processed before returning. We wait for the above task to finish before | 474 // processed before returning. We wait for the above task to finish before |
| 480 // letting the the function continue to avoid any potential race issues. | 475 // letting the the function continue to avoid any potential race issues. |
| 481 chrome_worker_thread_.Stop(); | 476 chrome_worker_thread_.Stop(); |
| 482 } else { | 477 } else { |
| 483 NOTREACHED() << "Worker thread not running."; | 478 NOTREACHED() << "Worker thread not running."; |
| 484 } | 479 } |
| 485 p2p_socket_dispatcher_->RemoveDestructionObserver(this); | |
| 486 } | 480 } |
| 487 } | 481 } |
| 488 | 482 |
| 489 scoped_refptr<media::VideoDecoder> MediaStreamImpl::CreateLocalVideoDecoder( | 483 scoped_refptr<media::VideoDecoder> MediaStreamImpl::CreateLocalVideoDecoder( |
| 490 webrtc::MediaStreamInterface* stream, | 484 webrtc::MediaStreamInterface* stream, |
| 491 media::MessageLoopFactory* message_loop_factory) { | 485 media::MessageLoopFactory* message_loop_factory) { |
| 492 if (!stream->video_tracks() || stream->video_tracks()->count() == 0) | 486 if (!stream->video_tracks() || stream->video_tracks()->count() == 0) |
| 493 return NULL; | 487 return NULL; |
| 494 | 488 |
| 495 int video_session_id = | 489 int video_session_id = |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 MediaStreamExtraData::MediaStreamExtraData( | 591 MediaStreamExtraData::MediaStreamExtraData( |
| 598 webrtc::MediaStreamInterface* remote_stream) | 592 webrtc::MediaStreamInterface* remote_stream) |
| 599 : remote_stream_(remote_stream) { | 593 : remote_stream_(remote_stream) { |
| 600 } | 594 } |
| 601 MediaStreamExtraData::MediaStreamExtraData( | 595 MediaStreamExtraData::MediaStreamExtraData( |
| 602 webrtc::LocalMediaStreamInterface* local_stream) | 596 webrtc::LocalMediaStreamInterface* local_stream) |
| 603 : local_stream_(local_stream) { | 597 : local_stream_(local_stream) { |
| 604 } | 598 } |
| 605 MediaStreamExtraData::~MediaStreamExtraData() { | 599 MediaStreamExtraData::~MediaStreamExtraData() { |
| 606 } | 600 } |
| OLD | NEW |