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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 DCHECK(task_runner_->BelongsToCurrentThread()); | 46 DCHECK(task_runner_->BelongsToCurrentThread()); |
47 DCHECK(demuxer_stream_provider); | 47 DCHECK(demuxer_stream_provider); |
48 | 48 |
49 demuxer_stream_provider_ = demuxer_stream_provider; | 49 demuxer_stream_provider_ = demuxer_stream_provider; |
50 // |init_cb| can be called on other thread. | 50 // |init_cb| can be called on other thread. |
51 init_cb_ = init_cb; | 51 init_cb_ = init_cb; |
52 ended_cb_ = ended_cb; | 52 ended_cb_ = ended_cb; |
53 error_cb_ = error_cb; | 53 error_cb_ = error_cb; |
54 buffering_state_cb_ = buffering_state_cb; | 54 buffering_state_cb_ = buffering_state_cb; |
55 | 55 |
56 // Create a mojo::DemuxerStream and bind its lifetime to the pipe. | 56 // Create audio and video mojo::DemuxerStream and bind its lifetime to the |
57 mojo::DemuxerStreamPtr demuxer_stream; | 57 // pipe. |
58 mojo::BindToProxy( | 58 DemuxerStream* const audio = |
59 new MojoDemuxerStreamImpl( | 59 demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); |
60 demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO)), | 60 DemuxerStream* const video = |
61 &demuxer_stream); | 61 demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); |
| 62 |
| 63 mojo::DemuxerStreamPtr audio_stream; |
| 64 if (audio) |
| 65 mojo::BindToProxy(new MojoDemuxerStreamImpl(audio), &audio_stream); |
| 66 |
| 67 mojo::DemuxerStreamPtr video_stream; |
| 68 if (video) |
| 69 mojo::BindToProxy(new MojoDemuxerStreamImpl(video), &video_stream); |
| 70 |
62 remote_audio_renderer_->Initialize( | 71 remote_audio_renderer_->Initialize( |
63 demuxer_stream.Pass(), | 72 audio_stream.Pass(), |
| 73 video_stream.Pass(), |
64 BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized, | 74 BindToCurrentLoop(base::Bind(&MojoRendererImpl::OnInitialized, |
65 weak_factory_.GetWeakPtr()))); | 75 weak_factory_.GetWeakPtr()))); |
66 } | 76 } |
67 | 77 |
68 void MojoRendererImpl::Flush(const base::Closure& flush_cb) { | 78 void MojoRendererImpl::Flush(const base::Closure& flush_cb) { |
69 DVLOG(2) << __FUNCTION__; | 79 DVLOG(2) << __FUNCTION__; |
70 DCHECK(task_runner_->BelongsToCurrentThread()); | 80 DCHECK(task_runner_->BelongsToCurrentThread()); |
71 remote_audio_renderer_->Flush(flush_cb); | 81 remote_audio_renderer_->Flush(flush_cb); |
72 } | 82 } |
73 | 83 |
(...skipping 24 matching lines...) Expand all Loading... |
98 base::TimeDelta MojoRendererImpl::GetMediaTime() { | 108 base::TimeDelta MojoRendererImpl::GetMediaTime() { |
99 base::AutoLock auto_lock(lock_); | 109 base::AutoLock auto_lock(lock_); |
100 DVLOG(3) << __FUNCTION__ << ": " << time_.InMilliseconds() << " ms"; | 110 DVLOG(3) << __FUNCTION__ << ": " << time_.InMilliseconds() << " ms"; |
101 return time_; | 111 return time_; |
102 } | 112 } |
103 | 113 |
104 bool MojoRendererImpl::HasAudio() { | 114 bool MojoRendererImpl::HasAudio() { |
105 DVLOG(1) << __FUNCTION__; | 115 DVLOG(1) << __FUNCTION__; |
106 DCHECK(task_runner_->BelongsToCurrentThread()); | 116 DCHECK(task_runner_->BelongsToCurrentThread()); |
107 DCHECK(remote_audio_renderer_.get()); // We always bind the renderer. | 117 DCHECK(remote_audio_renderer_.get()); // We always bind the renderer. |
108 return true; | 118 return !!demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO); |
109 } | 119 } |
110 | 120 |
111 bool MojoRendererImpl::HasVideo() { | 121 bool MojoRendererImpl::HasVideo() { |
112 DVLOG(1) << __FUNCTION__; | 122 DVLOG(1) << __FUNCTION__; |
113 DCHECK(task_runner_->BelongsToCurrentThread()); | 123 DCHECK(task_runner_->BelongsToCurrentThread()); |
114 return false; | 124 return !!demuxer_stream_provider_->GetStream(DemuxerStream::VIDEO); |
115 } | 125 } |
116 | 126 |
117 void MojoRendererImpl::SetCdm(MediaKeys* cdm) { | 127 void MojoRendererImpl::SetCdm(MediaKeys* cdm) { |
118 DVLOG(1) << __FUNCTION__; | 128 DVLOG(1) << __FUNCTION__; |
119 DCHECK(task_runner_->BelongsToCurrentThread()); | 129 DCHECK(task_runner_->BelongsToCurrentThread()); |
120 NOTIMPLEMENTED(); | 130 NOTIMPLEMENTED(); |
121 } | 131 } |
122 | 132 |
123 void MojoRendererImpl::OnTimeUpdate(int64_t time_usec, int64_t max_time_usec) { | 133 void MojoRendererImpl::OnTimeUpdate(int64_t time_usec, int64_t max_time_usec) { |
124 DVLOG(3) << __FUNCTION__ << ": " << time_usec << ", " << max_time_usec; | 134 DVLOG(3) << __FUNCTION__ << ": " << time_usec << ", " << max_time_usec; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 194 |
185 void MojoRendererImpl::OnInitialized() { | 195 void MojoRendererImpl::OnInitialized() { |
186 DVLOG(1) << __FUNCTION__; | 196 DVLOG(1) << __FUNCTION__; |
187 DCHECK(task_runner_->BelongsToCurrentThread()); | 197 DCHECK(task_runner_->BelongsToCurrentThread()); |
188 DCHECK(!init_cb_.is_null()); | 198 DCHECK(!init_cb_.is_null()); |
189 | 199 |
190 base::ResetAndReturn(&init_cb_).Run(); | 200 base::ResetAndReturn(&init_cb_).Run(); |
191 } | 201 } |
192 | 202 |
193 } // namespace media | 203 } // namespace media |
OLD | NEW |