Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "media/remoting/remote_renderer_impl.h" | 5 #include "media/remoting/remote_renderer_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 VideoRendererSink* video_renderer_sink) | 29 VideoRendererSink* video_renderer_sink) |
| 30 : state_(STATE_UNINITIALIZED), | 30 : state_(STATE_UNINITIALIZED), |
| 31 main_task_runner_(base::ThreadTaskRunnerHandle::Get()), | 31 main_task_runner_(base::ThreadTaskRunnerHandle::Get()), |
| 32 media_task_runner_(std::move(media_task_runner)), | 32 media_task_runner_(std::move(media_task_runner)), |
| 33 demuxer_stream_provider_(nullptr), | 33 demuxer_stream_provider_(nullptr), |
| 34 client_(nullptr), | 34 client_(nullptr), |
| 35 remoting_renderer_controller_(remoting_renderer_controller), | 35 remoting_renderer_controller_(remoting_renderer_controller), |
| 36 rpc_broker_(remoting_renderer_controller_->GetRpcBroker()), | 36 rpc_broker_(remoting_renderer_controller_->GetRpcBroker()), |
| 37 rpc_handle_(remoting::RpcBroker::GetUniqueHandle()), | 37 rpc_handle_(remoting::RpcBroker::GetUniqueHandle()), |
| 38 remote_renderer_handle_(remoting::kInvalidHandle), | 38 remote_renderer_handle_(remoting::kInvalidHandle), |
| 39 interstitial_ui_(video_renderer_sink, | 39 remoting_interstitial_ui_(video_renderer_sink), |
| 40 remoting_renderer_controller->pipeline_metadata()), | |
| 41 weak_factory_(this) { | 40 weak_factory_(this) { |
| 42 VLOG(2) << __FUNCTION__; | 41 VLOG(2) << __FUNCTION__; |
| 43 // The constructor is running on the main thread. | 42 // The constructor is running on the main thread. |
| 44 DCHECK(remoting_renderer_controller); | 43 DCHECK(remoting_renderer_controller_); |
| 45 | 44 remoting_renderer_controller_->SetShowInterstitialCallback( |
| 46 UpdateInterstitial(); | 45 base::Bind(&RemotingInterstitialUI::ShowInterstitialOnSink, |
|
miu
2016/12/13 22:39:09
As discussed face-to-face, consider:
base::Bind(&
xjz
2016/12/14 00:29:50
Done. Use static function instead, as this doesn't
| |
| 46 remoting_interstitial_ui_.GetWeakPtr())); | |
| 47 | 47 |
| 48 const remoting::RpcBroker::ReceiveMessageCallback receive_callback = | 48 const remoting::RpcBroker::ReceiveMessageCallback receive_callback = |
| 49 base::Bind(&RemoteRendererImpl::OnMessageReceivedOnMainThread, | 49 base::Bind(&RemoteRendererImpl::OnMessageReceivedOnMainThread, |
| 50 media_task_runner_, weak_factory_.GetWeakPtr()); | 50 media_task_runner_, weak_factory_.GetWeakPtr()); |
| 51 rpc_broker_->RegisterMessageReceiverCallback(rpc_handle_, receive_callback); | 51 rpc_broker_->RegisterMessageReceiverCallback(rpc_handle_, receive_callback); |
| 52 } | 52 } |
| 53 | 53 |
| 54 RemoteRendererImpl::~RemoteRendererImpl() { | 54 RemoteRendererImpl::~RemoteRendererImpl() { |
| 55 VLOG(2) << __FUNCTION__; | 55 VLOG(2) << __FUNCTION__; |
| 56 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 56 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 } | 548 } |
| 549 | 549 |
| 550 void RemoteRendererImpl::OnFatalError(PipelineStatus error) { | 550 void RemoteRendererImpl::OnFatalError(PipelineStatus error) { |
| 551 DCHECK(media_task_runner_->BelongsToCurrentThread()); | 551 DCHECK(media_task_runner_->BelongsToCurrentThread()); |
| 552 DCHECK_NE(PIPELINE_OK, error) << "PIPELINE_OK isn't an error!"; | 552 DCHECK_NE(PIPELINE_OK, error) << "PIPELINE_OK isn't an error!"; |
| 553 | 553 |
| 554 // An error has already been delivered. | 554 // An error has already been delivered. |
| 555 if (state_ == STATE_ERROR) | 555 if (state_ == STATE_ERROR) |
| 556 return; | 556 return; |
| 557 | 557 |
| 558 main_task_runner_->PostTask( | |
| 559 FROM_HERE, base::Bind(&RemoteRendererImpl::UpdateInterstitial, | |
| 560 weak_factory_.GetWeakPtr())); | |
| 561 | |
| 562 const State old_state = state_; | 558 const State old_state = state_; |
| 563 state_ = STATE_ERROR; | 559 state_ = STATE_ERROR; |
| 564 | 560 |
| 565 if (!init_workflow_done_callback_.is_null()) { | 561 if (!init_workflow_done_callback_.is_null()) { |
| 566 DCHECK(old_state == STATE_CREATE_PIPE || old_state == STATE_ACQUIRING || | 562 DCHECK(old_state == STATE_CREATE_PIPE || old_state == STATE_ACQUIRING || |
| 567 old_state == STATE_INITIALIZING); | 563 old_state == STATE_INITIALIZING); |
| 568 base::ResetAndReturn(&init_workflow_done_callback_).Run(error); | 564 base::ResetAndReturn(&init_workflow_done_callback_).Run(error); |
| 569 return; | 565 return; |
| 570 } | 566 } |
| 571 | 567 |
| 572 if (!flush_cb_.is_null()) | 568 if (!flush_cb_.is_null()) |
| 573 base::ResetAndReturn(&flush_cb_).Run(); | 569 base::ResetAndReturn(&flush_cb_).Run(); |
| 574 | 570 |
| 575 // After OnError() returns, the pipeline may destroy |this|. | 571 // After OnError() returns, the pipeline may destroy |this|. |
| 576 client_->OnError(error); | 572 client_->OnError(error); |
| 577 } | 573 } |
| 578 | 574 |
| 579 void RemoteRendererImpl::UpdateInterstitial() { | |
| 580 DCHECK(main_task_runner_->BelongsToCurrentThread()); | |
| 581 | |
| 582 interstitial_ui_.ShowInterstitial( | |
| 583 remoting_renderer_controller_->remoting_source()->state() == | |
| 584 RemotingSessionState::SESSION_STARTED); | |
| 585 } | |
| 586 | |
| 587 } // namespace media | 575 } // namespace media |
| OLD | NEW |