| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 << "Stopping stream " << it->first; | 356 << "Stopping stream " << it->first; |
| 357 media_stream_dispatcher_->StopStream(it->first); | 357 media_stream_dispatcher_->StopStream(it->first); |
| 358 local_media_streams_.erase(it); | 358 local_media_streams_.erase(it); |
| 359 it = local_media_streams_.begin(); | 359 it = local_media_streams_.begin(); |
| 360 } else { | 360 } else { |
| 361 ++it; | 361 ++it; |
| 362 } | 362 } |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 | 365 |
| 366 void MediaStreamImpl::OnSocketDispatcherDestroyed() { | |
| 367 CleanupPeerConnectionFactory(); | |
| 368 } | |
| 369 | |
| 370 void MediaStreamImpl::InitializeWorkerThread(talk_base::Thread** thread, | 366 void MediaStreamImpl::InitializeWorkerThread(talk_base::Thread** thread, |
| 371 base::WaitableEvent* event) { | 367 base::WaitableEvent* event) { |
| 372 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 368 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 373 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); | 369 jingle_glue::JingleThreadWrapper::current()->set_send_allowed(true); |
| 374 *thread = jingle_glue::JingleThreadWrapper::current(); | 370 *thread = jingle_glue::JingleThreadWrapper::current(); |
| 375 event->Signal(); | 371 event->Signal(); |
| 376 } | 372 } |
| 377 | 373 |
| 378 void MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread( | 374 void MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread( |
| 379 base::WaitableEvent* event) { | 375 base::WaitableEvent* event) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 DCHECK(worker_thread_); | 410 DCHECK(worker_thread_); |
| 415 } | 411 } |
| 416 | 412 |
| 417 if (!network_manager_) { | 413 if (!network_manager_) { |
| 418 base::WaitableEvent event(true, false); | 414 base::WaitableEvent event(true, false); |
| 419 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 415 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| 420 &MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread, | 416 &MediaStreamImpl::CreateIpcNetworkManagerOnWorkerThread, |
| 421 base::Unretained(this), | 417 base::Unretained(this), |
| 422 &event)); | 418 &event)); |
| 423 event.Wait(); | 419 event.Wait(); |
| 424 p2p_socket_dispatcher_->AddDestructionObserver(this); | |
| 425 } | 420 } |
| 426 | 421 |
| 427 if (!socket_factory_.get()) { | 422 if (!socket_factory_.get()) { |
| 428 socket_factory_.reset( | 423 socket_factory_.reset( |
| 429 new content::IpcPacketSocketFactory(p2p_socket_dispatcher_)); | 424 new content::IpcPacketSocketFactory(p2p_socket_dispatcher_)); |
| 430 } | 425 } |
| 431 | 426 |
| 432 if (!dependency_factory_->PeerConnectionFactoryCreated()) { | 427 if (!dependency_factory_->PeerConnectionFactoryCreated()) { |
| 433 if (!dependency_factory_->CreatePeerConnectionFactory( | 428 if (!dependency_factory_->CreatePeerConnectionFactory( |
| 434 worker_thread_, | 429 worker_thread_, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 454 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( | 449 chrome_worker_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| 455 &MediaStreamImpl::DeleteIpcNetworkManager, | 450 &MediaStreamImpl::DeleteIpcNetworkManager, |
| 456 base::Unretained(this))); | 451 base::Unretained(this))); |
| 457 // Stopping the thread will wait until all tasks have been | 452 // Stopping the thread will wait until all tasks have been |
| 458 // processed before returning. We wait for the above task to finish before | 453 // processed before returning. We wait for the above task to finish before |
| 459 // letting the the function continue to avoid any potential race issues. | 454 // letting the the function continue to avoid any potential race issues. |
| 460 chrome_worker_thread_.Stop(); | 455 chrome_worker_thread_.Stop(); |
| 461 } else { | 456 } else { |
| 462 NOTREACHED() << "Worker thread not running."; | 457 NOTREACHED() << "Worker thread not running."; |
| 463 } | 458 } |
| 464 p2p_socket_dispatcher_->RemoveDestructionObserver(this); | |
| 465 } | 459 } |
| 466 } | 460 } |
| 467 | 461 |
| 468 scoped_refptr<media::VideoDecoder> MediaStreamImpl::CreateLocalVideoDecoder( | 462 scoped_refptr<media::VideoDecoder> MediaStreamImpl::CreateLocalVideoDecoder( |
| 469 webrtc::MediaStreamInterface* stream, | 463 webrtc::MediaStreamInterface* stream, |
| 470 media::MessageLoopFactory* message_loop_factory) { | 464 media::MessageLoopFactory* message_loop_factory) { |
| 471 if (!stream->video_tracks() || stream->video_tracks()->count() == 0) | 465 if (!stream->video_tracks() || stream->video_tracks()->count() == 0) |
| 472 return NULL; | 466 return NULL; |
| 473 | 467 |
| 474 int video_session_id = | 468 int video_session_id = |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 MediaStreamExtraData::MediaStreamExtraData( | 551 MediaStreamExtraData::MediaStreamExtraData( |
| 558 webrtc::MediaStreamInterface* remote_stream) | 552 webrtc::MediaStreamInterface* remote_stream) |
| 559 : remote_stream_(remote_stream) { | 553 : remote_stream_(remote_stream) { |
| 560 } | 554 } |
| 561 MediaStreamExtraData::MediaStreamExtraData( | 555 MediaStreamExtraData::MediaStreamExtraData( |
| 562 webrtc::LocalMediaStreamInterface* local_stream) | 556 webrtc::LocalMediaStreamInterface* local_stream) |
| 563 : local_stream_(local_stream) { | 557 : local_stream_(local_stream) { |
| 564 } | 558 } |
| 565 MediaStreamExtraData::~MediaStreamExtraData() { | 559 MediaStreamExtraData::~MediaStreamExtraData() { |
| 566 } | 560 } |
| OLD | NEW |