OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/mojo/services/mojo_renderer_impl.h" | 5 #include "media/mojo/services/mojo_renderer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 // current thread so we can use it. The MojoRendererImpl object | 49 // current thread so we can use it. The MojoRendererImpl object |
50 // is constructed on another thread so we can't do it in the | 50 // is constructed on another thread so we can't do it in the |
51 // constructor and must pass a message pipe around since | 51 // constructor and must pass a message pipe around since |
52 // InterfacePtr's are tied to the message loop they were created on. | 52 // InterfacePtr's are tied to the message loop they were created on. |
53 remote_media_renderer_.Bind(remote_media_renderer_pipe_.Pass()); | 53 remote_media_renderer_.Bind(remote_media_renderer_pipe_.Pass()); |
54 DCHECK(remote_media_renderer_); | 54 DCHECK(remote_media_renderer_); |
55 remote_media_renderer_.set_client(this); | 55 remote_media_renderer_.set_client(this); |
56 | 56 |
57 demuxer_stream_provider_ = demuxer_stream_provider; | 57 demuxer_stream_provider_ = demuxer_stream_provider; |
58 // |init_cb| can be called on other thread. | 58 // |init_cb| can be called on other thread. |
59 init_cb_ = init_cb; | 59 init_cb_ = BindToCurrentLoop(init_cb); |
60 ended_cb_ = ended_cb; | 60 ended_cb_ = ended_cb; |
61 error_cb_ = error_cb; | 61 error_cb_ = error_cb; |
62 buffering_state_cb_ = buffering_state_cb; | 62 buffering_state_cb_ = buffering_state_cb; |
63 | 63 |
64 // Create audio and video mojo::DemuxerStream and bind its lifetime to the | 64 // Create audio and video mojo::DemuxerStream and bind its lifetime to the |
65 // pipe. | 65 // pipe. |
66 DemuxerStream* const audio = | 66 DemuxerStream* const audio = |
67 demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); | 67 demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); |
68 DemuxerStream* const video = | 68 DemuxerStream* const video = |
69 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); | 69 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); |
70 | 70 |
71 mojo::DemuxerStreamPtr audio_stream; | 71 mojo::DemuxerStreamPtr audio_stream; |
72 if (audio) { | 72 if (audio) { |
73 mojo::BindToProxy(new MojoDemuxerStreamImpl(audio), &audio_stream) | 73 mojo::BindToProxy(new MojoDemuxerStreamImpl(audio), &audio_stream) |
74 ->DidConnect(); | 74 ->DidConnect(); |
75 } | 75 } |
76 | 76 |
77 mojo::DemuxerStreamPtr video_stream; | 77 mojo::DemuxerStreamPtr video_stream; |
78 if (video) { | 78 if (video) { |
79 mojo::BindToProxy(new MojoDemuxerStreamImpl(video), &video_stream) | 79 mojo::BindToProxy(new MojoDemuxerStreamImpl(video), &video_stream) |
80 ->DidConnect(); | 80 ->DidConnect(); |
81 } | 81 } |
82 | 82 |
83 remote_media_renderer_->Initialize( | 83 remote_media_renderer_->Initialize( |
84 audio_stream.Pass(), | 84 audio_stream.Pass(), |
85 video_stream.Pass(), | 85 video_stream.Pass(), |
86 BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized, | 86 BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized, |
87 weak_factory_.GetWeakPtr()))); | 87 weak_factory_.GetWeakPtr()))); |
xhwang
2015/01/16 23:09:07
ditto: we have three posts here:
1, BindToCurrentL
DaleCurtis
2015/01/20 21:37:44
Done.
| |
88 } | 88 } |
89 | 89 |
90 void MojoRendererImpl::SetCdm(CdmContext* cdm_context, | 90 void MojoRendererImpl::SetCdm(CdmContext* cdm_context, |
91 const CdmAttachedCB& cdm_attached_cb) { | 91 const CdmAttachedCB& cdm_attached_cb) { |
92 DVLOG(1) << __FUNCTION__; | 92 DVLOG(1) << __FUNCTION__; |
93 DCHECK(task_runner_->BelongsToCurrentThread()); | 93 DCHECK(task_runner_->BelongsToCurrentThread()); |
94 NOTIMPLEMENTED(); | 94 NOTIMPLEMENTED(); |
95 cdm_attached_cb.Run(false); | 95 cdm_attached_cb.Run(false); |
96 } | 96 } |
97 | 97 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 | 190 |
191 void MojoRendererImpl::OnError() { | 191 void MojoRendererImpl::OnError() { |
192 DVLOG(1) << __FUNCTION__; | 192 DVLOG(1) << __FUNCTION__; |
193 | 193 |
194 if (!task_runner_->BelongsToCurrentThread()) { | 194 if (!task_runner_->BelongsToCurrentThread()) { |
195 task_runner_->PostTask( | 195 task_runner_->PostTask( |
196 FROM_HERE, | 196 FROM_HERE, |
197 base::Bind(&MojoRendererImpl::OnError, weak_factory_.GetWeakPtr())); | 197 base::Bind(&MojoRendererImpl::OnError, weak_factory_.GetWeakPtr())); |
198 return; | 198 return; |
199 } | 199 } |
200 | 200 |
DaleCurtis
2015/01/20 21:37:44
Hmm looks like this code should run init_cb_ on er
xhwang
2015/01/20 23:00:38
Looks like we are relying on OnInitialized() to fi
| |
201 // TODO(tim): Should we plumb error code from remote renderer? | 201 // TODO(tim): Should we plumb error code from remote renderer? |
202 // http://crbug.com/410451. | 202 // http://crbug.com/410451. |
203 if (init_cb_.is_null()) // We have initialized already. | 203 if (init_cb_.is_null()) // We have initialized already. |
204 error_cb_.Run(PIPELINE_ERROR_DECODE); | 204 error_cb_.Run(PIPELINE_ERROR_DECODE); |
205 else | 205 else |
206 error_cb_.Run(PIPELINE_ERROR_COULD_NOT_RENDER); | 206 error_cb_.Run(PIPELINE_ERROR_COULD_NOT_RENDER); |
207 } | 207 } |
208 | 208 |
209 void MojoRendererImpl::OnInitialized() { | 209 void MojoRendererImpl::OnInitialized() { |
210 DVLOG(1) << __FUNCTION__; | 210 DVLOG(1) << __FUNCTION__; |
211 DCHECK(task_runner_->BelongsToCurrentThread()); | 211 DCHECK(task_runner_->BelongsToCurrentThread()); |
212 DCHECK(!init_cb_.is_null()); | 212 DCHECK(!init_cb_.is_null()); |
213 | 213 |
214 base::ResetAndReturn(&init_cb_).Run(); | 214 base::ResetAndReturn(&init_cb_).Run(); |
215 } | 215 } |
216 | 216 |
217 } // namespace media | 217 } // namespace media |
OLD | NEW |