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 "chromecast/renderer/media/media_pipeline_proxy.h" | 5 #include "chromecast/renderer/media/media_pipeline_proxy.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/logging.h" | 10 #include "base/logging.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 // This class is not thread safe and should run on the same thread | 22 // This class is not thread safe and should run on the same thread |
23 // as the media channel proxy. | 23 // as the media channel proxy. |
24 class MediaPipelineProxyInternal { | 24 class MediaPipelineProxyInternal { |
25 public: | 25 public: |
26 static void Release(scoped_ptr<MediaPipelineProxyInternal> proxy); | 26 static void Release(scoped_ptr<MediaPipelineProxyInternal> proxy); |
27 | 27 |
28 explicit MediaPipelineProxyInternal( | 28 explicit MediaPipelineProxyInternal( |
29 scoped_refptr<MediaChannelProxy> media_channel_proxy); | 29 scoped_refptr<MediaChannelProxy> media_channel_proxy); |
30 virtual ~MediaPipelineProxyInternal(); | 30 virtual ~MediaPipelineProxyInternal(); |
31 | 31 |
32 void SetClient(const MediaPipelineClient& client); | 32 void SetClient(const RendererMediaPipelineClient& client); |
33 void SetCdm(int render_frame_id, int cdm_id); | 33 void SetCdm(int render_frame_id, int cdm_id); |
34 void StartPlayingFrom(const base::TimeDelta& time); | 34 void StartPlayingFrom(const base::TimeDelta& time); |
35 void Flush(const ::media::PipelineStatusCB& status_cb); | 35 void Flush(const ::media::PipelineStatusCB& status_cb); |
36 void Stop(); | 36 void Stop(); |
37 void SetPlaybackRate(double playback_rate); | 37 void SetPlaybackRate(double playback_rate); |
38 | 38 |
39 private: | 39 private: |
40 void Shutdown(); | 40 void Shutdown(); |
41 | 41 |
42 // Callbacks for CmaMessageFilterHost::MediaDelegate. | 42 // Callbacks for CmaMessageFilterHost::MediaDelegate. |
43 void OnStateChanged(::media::PipelineStatus status); | 43 void OnStateChanged(::media::PipelineStatus status); |
44 | 44 |
45 base::ThreadChecker thread_checker_; | 45 base::ThreadChecker thread_checker_; |
46 | 46 |
47 scoped_refptr<MediaChannelProxy> media_channel_proxy_; | 47 scoped_refptr<MediaChannelProxy> media_channel_proxy_; |
48 | 48 |
49 MediaPipelineClient client_; | 49 RendererMediaPipelineClient client_; |
50 | 50 |
51 // Store the callback for a pending state transition. | 51 // Store the callback for a pending state transition. |
52 ::media::PipelineStatusCB status_cb_; | 52 ::media::PipelineStatusCB status_cb_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(MediaPipelineProxyInternal); | 54 DISALLOW_COPY_AND_ASSIGN(MediaPipelineProxyInternal); |
55 }; | 55 }; |
56 | 56 |
57 // static | 57 // static |
58 void MediaPipelineProxyInternal::Release( | 58 void MediaPipelineProxyInternal::Release( |
59 scoped_ptr<MediaPipelineProxyInternal> proxy) { | 59 scoped_ptr<MediaPipelineProxyInternal> proxy) { |
(...skipping 14 matching lines...) Expand all Loading... |
74 | 74 |
75 void MediaPipelineProxyInternal::Shutdown() { | 75 void MediaPipelineProxyInternal::Shutdown() { |
76 DCHECK(thread_checker_.CalledOnValidThread()); | 76 DCHECK(thread_checker_.CalledOnValidThread()); |
77 | 77 |
78 // Remove any callback on VideoPipelineProxyInternal. | 78 // Remove any callback on VideoPipelineProxyInternal. |
79 media_channel_proxy_->SetMediaDelegate( | 79 media_channel_proxy_->SetMediaDelegate( |
80 CmaMessageFilterProxy::MediaDelegate()); | 80 CmaMessageFilterProxy::MediaDelegate()); |
81 } | 81 } |
82 | 82 |
83 void MediaPipelineProxyInternal::SetClient( | 83 void MediaPipelineProxyInternal::SetClient( |
84 const MediaPipelineClient& client) { | 84 const RendererMediaPipelineClient& client) { |
85 DCHECK(thread_checker_.CalledOnValidThread()); | 85 DCHECK(thread_checker_.CalledOnValidThread()); |
86 DCHECK(!client.error_cb.is_null()); | 86 DCHECK(!client.error_cb.is_null()); |
87 DCHECK(!client.buffering_state_cb.is_null()); | 87 DCHECK(!client.buffering_state_cb.is_null()); |
88 client_ = client; | 88 client_ = client; |
89 | 89 |
90 CmaMessageFilterProxy::MediaDelegate delegate; | 90 CmaMessageFilterProxy::MediaDelegate delegate; |
91 delegate.state_changed_cb = | 91 delegate.state_changed_cb = |
92 base::Bind(&MediaPipelineProxyInternal::OnStateChanged, | 92 base::Bind(&MediaPipelineProxyInternal::OnStateChanged, |
93 base::Unretained(this)); | 93 base::Unretained(this)); |
94 delegate.client = client; | 94 delegate.client = client; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 MediaPipelineProxy::~MediaPipelineProxy() { | 180 MediaPipelineProxy::~MediaPipelineProxy() { |
181 io_task_runner_->PostTask( | 181 io_task_runner_->PostTask( |
182 FROM_HERE, | 182 FROM_HERE, |
183 base::Bind(&MediaPipelineProxyInternal::Release, base::Passed(&proxy_))); | 183 base::Bind(&MediaPipelineProxyInternal::Release, base::Passed(&proxy_))); |
184 io_task_runner_->PostTask( | 184 io_task_runner_->PostTask( |
185 FROM_HERE, base::Bind(&MediaChannelProxy::Close, media_channel_proxy_)); | 185 FROM_HERE, base::Bind(&MediaChannelProxy::Close, media_channel_proxy_)); |
186 } | 186 } |
187 | 187 |
188 void MediaPipelineProxy::SetClient( | 188 void MediaPipelineProxy::SetClient(const RendererMediaPipelineClient& client) { |
189 const MediaPipelineClient& client) { | |
190 DCHECK(thread_checker_.CalledOnValidThread()); | 189 DCHECK(thread_checker_.CalledOnValidThread()); |
191 FORWARD_ON_IO_THREAD(SetClient, client); | 190 FORWARD_ON_IO_THREAD(SetClient, client); |
192 } | 191 } |
193 | 192 |
194 void MediaPipelineProxy::SetCdm(int cdm_id) { | 193 void MediaPipelineProxy::SetCdm(int cdm_id) { |
195 DCHECK(thread_checker_.CalledOnValidThread()); | 194 DCHECK(thread_checker_.CalledOnValidThread()); |
196 FORWARD_ON_IO_THREAD(SetCdm, render_frame_id_, cdm_id); | 195 FORWARD_ON_IO_THREAD(SetCdm, render_frame_id_, cdm_id); |
197 } | 196 } |
198 | 197 |
199 AudioPipeline* MediaPipelineProxy::GetAudioPipeline() const { | 198 AudioPipeline* MediaPipelineProxy::GetAudioPipeline() const { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 FORWARD_ON_IO_THREAD(Stop); | 274 FORWARD_ON_IO_THREAD(Stop); |
276 } | 275 } |
277 | 276 |
278 void MediaPipelineProxy::SetPlaybackRate(double playback_rate) { | 277 void MediaPipelineProxy::SetPlaybackRate(double playback_rate) { |
279 DCHECK(thread_checker_.CalledOnValidThread()); | 278 DCHECK(thread_checker_.CalledOnValidThread()); |
280 FORWARD_ON_IO_THREAD(SetPlaybackRate, playback_rate); | 279 FORWARD_ON_IO_THREAD(SetPlaybackRate, playback_rate); |
281 } | 280 } |
282 | 281 |
283 } // namespace cma | 282 } // namespace cma |
284 } // namespace chromecast | 283 } // namespace chromecast |
OLD | NEW |