| 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/optional.h" | 10 #include "base/optional.h" |
| 11 #include "media/base/audio_renderer_sink.h" | 11 #include "media/base/audio_renderer_sink.h" |
| 12 #include "media/base/media_keys.h" | 12 #include "media/base/content_decryption_module.h" |
| 13 #include "media/base/media_url_demuxer.h" | 13 #include "media/base/media_url_demuxer.h" |
| 14 #include "media/base/renderer.h" | 14 #include "media/base/renderer.h" |
| 15 #include "media/base/video_renderer_sink.h" | 15 #include "media/base/video_renderer_sink.h" |
| 16 #include "media/mojo/services/demuxer_stream_provider_shim.h" | 16 #include "media/mojo/services/demuxer_stream_provider_shim.h" |
| 17 #include "media/mojo/services/mojo_cdm_service_context.h" | 17 #include "media/mojo/services/mojo_cdm_service_context.h" |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 void MojoRendererService::SetCdm(int32_t cdm_id, | 136 void MojoRendererService::SetCdm(int32_t cdm_id, |
| 137 const SetCdmCallback& callback) { | 137 const SetCdmCallback& callback) { |
| 138 if (!mojo_cdm_service_context_) { | 138 if (!mojo_cdm_service_context_) { |
| 139 DVLOG(1) << "CDM service context not available."; | 139 DVLOG(1) << "CDM service context not available."; |
| 140 callback.Run(false); | 140 callback.Run(false); |
| 141 return; | 141 return; |
| 142 } | 142 } |
| 143 | 143 |
| 144 scoped_refptr<MediaKeys> cdm = mojo_cdm_service_context_->GetCdm(cdm_id); | 144 scoped_refptr<ContentDecryptionModule> cdm = |
| 145 mojo_cdm_service_context_->GetCdm(cdm_id); |
| 145 if (!cdm) { | 146 if (!cdm) { |
| 146 DVLOG(1) << "CDM not found: " << cdm_id; | 147 DVLOG(1) << "CDM not found: " << cdm_id; |
| 147 callback.Run(false); | 148 callback.Run(false); |
| 148 return; | 149 return; |
| 149 } | 150 } |
| 150 | 151 |
| 151 CdmContext* cdm_context = cdm->GetCdmContext(); | 152 CdmContext* cdm_context = cdm->GetCdmContext(); |
| 152 if (!cdm_context) { | 153 if (!cdm_context) { |
| 153 DVLOG(1) << "CDM context not available: " << cdm_id; | 154 DVLOG(1) << "CDM context not available: " << cdm_id; |
| 154 callback.Run(false); | 155 callback.Run(false); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 } | 258 } |
| 258 | 259 |
| 259 void MojoRendererService::OnFlushCompleted(const FlushCallback& callback) { | 260 void MojoRendererService::OnFlushCompleted(const FlushCallback& callback) { |
| 260 DVLOG(1) << __func__; | 261 DVLOG(1) << __func__; |
| 261 DCHECK_EQ(state_, STATE_FLUSHING); | 262 DCHECK_EQ(state_, STATE_FLUSHING); |
| 262 state_ = STATE_PLAYING; | 263 state_ = STATE_PLAYING; |
| 263 callback.Run(); | 264 callback.Run(); |
| 264 } | 265 } |
| 265 | 266 |
| 266 void MojoRendererService::OnCdmAttached( | 267 void MojoRendererService::OnCdmAttached( |
| 267 scoped_refptr<MediaKeys> cdm, | 268 scoped_refptr<ContentDecryptionModule> cdm, |
| 268 const base::Callback<void(bool)>& callback, | 269 const base::Callback<void(bool)>& callback, |
| 269 bool success) { | 270 bool success) { |
| 270 DVLOG(1) << __func__ << "(" << success << ")"; | 271 DVLOG(1) << __func__ << "(" << success << ")"; |
| 271 | 272 |
| 272 if (success) | 273 if (success) |
| 273 cdm_ = cdm; | 274 cdm_ = cdm; |
| 274 | 275 |
| 275 callback.Run(success); | 276 callback.Run(success); |
| 276 } | 277 } |
| 277 | 278 |
| 278 void MojoRendererService::InitiateScopedSurfaceRequest( | 279 void MojoRendererService::InitiateScopedSurfaceRequest( |
| 279 const InitiateScopedSurfaceRequestCallback& callback) { | 280 const InitiateScopedSurfaceRequestCallback& callback) { |
| 280 if (initiate_surface_request_cb_.is_null()) { | 281 if (initiate_surface_request_cb_.is_null()) { |
| 281 // |renderer_| is likely not of type MediaPlayerRenderer. | 282 // |renderer_| is likely not of type MediaPlayerRenderer. |
| 282 // This is an unexpected call, and the connection should be closed. | 283 // This is an unexpected call, and the connection should be closed. |
| 283 mojo::ReportBadMessage("Unexpected call to InitiateScopedSurfaceRequest."); | 284 mojo::ReportBadMessage("Unexpected call to InitiateScopedSurfaceRequest."); |
| 284 | 285 |
| 285 // This may cause |this| to be destructed. | 286 // This may cause |this| to be destructed. |
| 286 DCHECK(!bad_message_cb_.is_null()); | 287 DCHECK(!bad_message_cb_.is_null()); |
| 287 bad_message_cb_.Run(); | 288 bad_message_cb_.Run(); |
| 288 | 289 |
| 289 return; | 290 return; |
| 290 } | 291 } |
| 291 | 292 |
| 292 callback.Run(initiate_surface_request_cb_.Run()); | 293 callback.Run(initiate_surface_request_cb_.Run()); |
| 293 } | 294 } |
| 294 | 295 |
| 295 } // namespace media | 296 } // namespace media |
| OLD | NEW |