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_service.h" | 5 #include "media/mojo/services/mojo_renderer_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "base/optional.h" | 11 #include "base/optional.h" |
12 #include "media/base/audio_renderer_sink.h" | 12 #include "media/base/audio_renderer_sink.h" |
13 #include "media/base/content_decryption_module.h" | 13 #include "media/base/content_decryption_module.h" |
14 #include "media/base/media_url_demuxer.h" | 14 #include "media/base/media_url_demuxer.h" |
15 #include "media/base/renderer.h" | 15 #include "media/base/renderer.h" |
16 #include "media/base/video_renderer_sink.h" | 16 #include "media/base/video_renderer_sink.h" |
17 #include "media/mojo/services/demuxer_stream_provider_shim.h" | 17 #include "media/mojo/services/media_resource_shim.h" |
18 #include "media/mojo/services/mojo_cdm_service_context.h" | 18 #include "media/mojo/services/mojo_cdm_service_context.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 void CloseBindingOnBadMessage(mojo::StrongBindingPtr<mojom::Renderer> binding) { | 24 void CloseBindingOnBadMessage(mojo::StrongBindingPtr<mojom::Renderer> binding) { |
25 LOG(ERROR) << __func__; | 25 LOG(ERROR) << __func__; |
26 DCHECK(binding); | 26 DCHECK(binding); |
27 binding->Close(); | 27 binding->Close(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 const base::Optional<GURL>& first_party_for_cookies, | 82 const base::Optional<GURL>& first_party_for_cookies, |
83 const InitializeCallback& callback) { | 83 const InitializeCallback& callback) { |
84 DVLOG(1) << __func__; | 84 DVLOG(1) << __func__; |
85 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 85 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
86 | 86 |
87 client_.Bind(std::move(client)); | 87 client_.Bind(std::move(client)); |
88 state_ = STATE_INITIALIZING; | 88 state_ = STATE_INITIALIZING; |
89 | 89 |
90 if (media_url == base::nullopt) { | 90 if (media_url == base::nullopt) { |
91 DCHECK(streams.has_value()); | 91 DCHECK(streams.has_value()); |
92 stream_provider_.reset(new DemuxerStreamProviderShim( | 92 media_resource_.reset(new MediaResourceShim( |
93 std::move(*streams), | 93 std::move(*streams), |
94 base::Bind(&MojoRendererService::OnStreamReady, weak_this_, callback))); | 94 base::Bind(&MojoRendererService::OnStreamReady, weak_this_, callback))); |
95 return; | 95 return; |
96 } | 96 } |
97 | 97 |
98 DCHECK(!media_url.value().is_empty()); | 98 DCHECK(!media_url.value().is_empty()); |
99 DCHECK(first_party_for_cookies); | 99 DCHECK(first_party_for_cookies); |
100 stream_provider_.reset(new MediaUrlDemuxer(nullptr, media_url.value(), | 100 media_resource_.reset(new MediaUrlDemuxer(nullptr, media_url.value(), |
101 first_party_for_cookies.value())); | 101 first_party_for_cookies.value())); |
102 renderer_->Initialize( | 102 renderer_->Initialize( |
103 stream_provider_.get(), this, | 103 media_resource_.get(), this, |
104 base::Bind(&MojoRendererService::OnRendererInitializeDone, weak_this_, | 104 base::Bind(&MojoRendererService::OnRendererInitializeDone, weak_this_, |
105 callback)); | 105 callback)); |
106 } | 106 } |
107 | 107 |
108 void MojoRendererService::Flush(const FlushCallback& callback) { | 108 void MojoRendererService::Flush(const FlushCallback& callback) { |
109 DVLOG(2) << __func__; | 109 DVLOG(2) << __func__; |
110 DCHECK_EQ(state_, STATE_PLAYING); | 110 DCHECK_EQ(state_, STATE_PLAYING); |
111 | 111 |
112 state_ = STATE_FLUSHING; | 112 state_ = STATE_FLUSHING; |
113 CancelPeriodicMediaTimeUpdates(); | 113 CancelPeriodicMediaTimeUpdates(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 void MojoRendererService::OnVideoOpacityChange(bool opaque) { | 198 void MojoRendererService::OnVideoOpacityChange(bool opaque) { |
199 DVLOG(2) << __func__ << "(" << opaque << ")"; | 199 DVLOG(2) << __func__ << "(" << opaque << ")"; |
200 client_->OnVideoOpacityChange(opaque); | 200 client_->OnVideoOpacityChange(opaque); |
201 } | 201 } |
202 | 202 |
203 void MojoRendererService::OnStreamReady( | 203 void MojoRendererService::OnStreamReady( |
204 const base::Callback<void(bool)>& callback) { | 204 const base::Callback<void(bool)>& callback) { |
205 DCHECK_EQ(state_, STATE_INITIALIZING); | 205 DCHECK_EQ(state_, STATE_INITIALIZING); |
206 | 206 |
207 renderer_->Initialize( | 207 renderer_->Initialize( |
208 stream_provider_.get(), this, | 208 media_resource_.get(), this, |
209 base::Bind(&MojoRendererService::OnRendererInitializeDone, weak_this_, | 209 base::Bind(&MojoRendererService::OnRendererInitializeDone, weak_this_, |
210 callback)); | 210 callback)); |
211 } | 211 } |
212 | 212 |
213 void MojoRendererService::OnRendererInitializeDone( | 213 void MojoRendererService::OnRendererInitializeDone( |
214 const base::Callback<void(bool)>& callback, | 214 const base::Callback<void(bool)>& callback, |
215 PipelineStatus status) { | 215 PipelineStatus status) { |
216 DVLOG(1) << __func__; | 216 DVLOG(1) << __func__; |
217 DCHECK_EQ(state_, STATE_INITIALIZING); | 217 DCHECK_EQ(state_, STATE_INITIALIZING); |
218 | 218 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 DCHECK(!bad_message_cb_.is_null()); | 286 DCHECK(!bad_message_cb_.is_null()); |
287 bad_message_cb_.Run(); | 287 bad_message_cb_.Run(); |
288 | 288 |
289 return; | 289 return; |
290 } | 290 } |
291 | 291 |
292 callback.Run(initiate_surface_request_cb_.Run()); | 292 callback.Run(initiate_surface_request_cb_.Run()); |
293 } | 293 } |
294 | 294 |
295 } // namespace media | 295 } // namespace media |
OLD | NEW |