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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "media/base/demuxer_stream_provider.h" | 10 #include "media/base/demuxer_stream_provider.h" |
11 #include "media/mojo/services/mojo_demuxer_stream_impl.h" | 11 #include "media/mojo/services/mojo_demuxer_stream_impl.h" |
12 #include "mojo/public/cpp/application/connect.h" | 12 #include "mojo/public/cpp/application/connect.h" |
13 #include "mojo/public/cpp/bindings/interface_impl.h" | 13 #include "mojo/public/cpp/bindings/interface_impl.h" |
14 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 14 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
15 | 15 |
16 namespace media { | 16 namespace media { |
17 | 17 |
18 MojoRendererImpl::MojoRendererImpl( | 18 MojoRendererImpl::MojoRendererImpl( |
19 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 19 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
20 DemuxerStreamProvider* demuxer_stream_provider, | |
21 mojo::ServiceProvider* audio_renderer_provider) | 20 mojo::ServiceProvider* audio_renderer_provider) |
22 : task_runner_(task_runner), | 21 : task_runner_(task_runner), |
23 demuxer_stream_provider_(demuxer_stream_provider), | |
24 weak_factory_(this) { | 22 weak_factory_(this) { |
25 // For now we only support audio and there must be a provider. | 23 // For now we only support audio and there must be a provider. |
26 DCHECK(audio_renderer_provider); | 24 DCHECK(audio_renderer_provider); |
27 mojo::ConnectToService(audio_renderer_provider, &remote_audio_renderer_); | 25 mojo::ConnectToService(audio_renderer_provider, &remote_audio_renderer_); |
28 remote_audio_renderer_.set_client(this); | 26 remote_audio_renderer_.set_client(this); |
29 } | 27 } |
30 | 28 |
31 MojoRendererImpl::~MojoRendererImpl() { | 29 MojoRendererImpl::~MojoRendererImpl() { |
32 DCHECK(task_runner_->BelongsToCurrentThread()); | 30 DCHECK(task_runner_->BelongsToCurrentThread()); |
33 // Connection to |remote_audio_renderer_| will error-out here. | 31 // Connection to |remote_audio_renderer_| will error-out here. |
34 } | 32 } |
35 | 33 |
36 void MojoRendererImpl::Initialize(const base::Closure& init_cb, | 34 void MojoRendererImpl::Initialize( |
37 const StatisticsCB& statistics_cb, | 35 DemuxerStreamProvider* demuxer_stream_provider, |
38 const base::Closure& ended_cb, | 36 const base::Closure& init_cb, |
39 const PipelineStatusCB& error_cb, | 37 const StatisticsCB& statistics_cb, |
40 const BufferingStateCB& buffering_state_cb) { | 38 const base::Closure& ended_cb, |
| 39 const PipelineStatusCB& error_cb, |
| 40 const BufferingStateCB& buffering_state_cb) { |
41 DCHECK(task_runner_->BelongsToCurrentThread()); | 41 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 42 DCHECK(demuxer_stream_provider); |
| 43 |
| 44 demuxer_stream_provider_ = demuxer_stream_provider; |
42 init_cb_ = init_cb; | 45 init_cb_ = init_cb; |
43 ended_cb_ = ended_cb; | 46 ended_cb_ = ended_cb; |
44 error_cb_ = error_cb; | 47 error_cb_ = error_cb; |
45 buffering_state_cb_ = buffering_state_cb; | 48 buffering_state_cb_ = buffering_state_cb; |
46 | 49 |
47 // Create a mojo::DemuxerStream and bind its lifetime to the pipe. | 50 // Create a mojo::DemuxerStream and bind its lifetime to the pipe. |
48 mojo::DemuxerStreamPtr demuxer_stream; | 51 mojo::DemuxerStreamPtr demuxer_stream; |
49 mojo::BindToProxy( | 52 mojo::BindToProxy( |
50 new MojoDemuxerStreamImpl( | 53 new MojoDemuxerStreamImpl( |
51 demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO)), | 54 demuxer_stream_provider_->GetStream(DemuxerStream::AUDIO)), |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 else | 121 else |
119 error_cb_.Run(PIPELINE_ERROR_COULD_NOT_RENDER); | 122 error_cb_.Run(PIPELINE_ERROR_COULD_NOT_RENDER); |
120 } | 123 } |
121 | 124 |
122 void MojoRendererImpl::OnInitialized() { | 125 void MojoRendererImpl::OnInitialized() { |
123 DCHECK(!init_cb_.is_null()); | 126 DCHECK(!init_cb_.is_null()); |
124 base::ResetAndReturn(&init_cb_).Run(); | 127 base::ResetAndReturn(&init_cb_).Run(); |
125 } | 128 } |
126 | 129 |
127 } // namespace media | 130 } // namespace media |
OLD | NEW |