Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Side by Side Diff: media/mojo/services/mojo_audio_decoder_service.cc

Issue 2330273002: media: Use associated interface for mojo AudioDecoderClient (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/mojo/services/mojo_audio_decoder_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_audio_decoder_service.h" 5 #include "media/mojo/services/mojo_audio_decoder_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/cdm_context.h" 10 #include "media/base/cdm_context.h"
(...skipping 10 matching lines...) Expand all
21 mojo::InterfaceRequest<mojom::AudioDecoder> request) 21 mojo::InterfaceRequest<mojom::AudioDecoder> request)
22 : binding_(this, std::move(request)), 22 : binding_(this, std::move(request)),
23 mojo_cdm_service_context_(mojo_cdm_service_context), 23 mojo_cdm_service_context_(mojo_cdm_service_context),
24 decoder_(std::move(decoder)), 24 decoder_(std::move(decoder)),
25 weak_factory_(this) { 25 weak_factory_(this) {
26 weak_this_ = weak_factory_.GetWeakPtr(); 26 weak_this_ = weak_factory_.GetWeakPtr();
27 } 27 }
28 28
29 MojoAudioDecoderService::~MojoAudioDecoderService() {} 29 MojoAudioDecoderService::~MojoAudioDecoderService() {}
30 30
31 void MojoAudioDecoderService::Initialize(mojom::AudioDecoderClientPtr client, 31 void MojoAudioDecoderService::Initialize(
32 mojom::AudioDecoderConfigPtr config, 32 mojom::AudioDecoderClientAssociatedPtrInfo client,
33 int32_t cdm_id, 33 mojom::AudioDecoderConfigPtr config,
34 const InitializeCallback& callback) { 34 int32_t cdm_id,
35 const InitializeCallback& callback) {
35 DVLOG(1) << __FUNCTION__ << " " 36 DVLOG(1) << __FUNCTION__ << " "
36 << config.To<media::AudioDecoderConfig>().AsHumanReadableString(); 37 << config.To<media::AudioDecoderConfig>().AsHumanReadableString();
37 38
38 // Get CdmContext from cdm_id if the stream is encrypted. 39 // Get CdmContext from cdm_id if the stream is encrypted.
39 CdmContext* cdm_context = nullptr; 40 CdmContext* cdm_context = nullptr;
40 scoped_refptr<MediaKeys> cdm; 41 scoped_refptr<MediaKeys> cdm;
41 if (config.To<media::AudioDecoderConfig>().is_encrypted()) { 42 if (config.To<media::AudioDecoderConfig>().is_encrypted()) {
42 if (!mojo_cdm_service_context_) { 43 if (!mojo_cdm_service_context_) {
43 DVLOG(1) << "CDM service context not available."; 44 DVLOG(1) << "CDM service context not available.";
44 callback.Run(false, false); 45 callback.Run(false, false);
45 return; 46 return;
46 } 47 }
47 48
48 cdm = mojo_cdm_service_context_->GetCdm(cdm_id); 49 cdm = mojo_cdm_service_context_->GetCdm(cdm_id);
49 if (!cdm) { 50 if (!cdm) {
50 DVLOG(1) << "CDM not found for CDM id: " << cdm_id; 51 DVLOG(1) << "CDM not found for CDM id: " << cdm_id;
51 callback.Run(false, false); 52 callback.Run(false, false);
52 return; 53 return;
53 } 54 }
54 55
55 cdm_context = cdm->GetCdmContext(); 56 cdm_context = cdm->GetCdmContext();
56 if (!cdm_context) { 57 if (!cdm_context) {
57 DVLOG(1) << "CDM context not available for CDM id: " << cdm_id; 58 DVLOG(1) << "CDM context not available for CDM id: " << cdm_id;
58 callback.Run(false, false); 59 callback.Run(false, false);
59 return; 60 return;
60 } 61 }
61 } 62 }
62 63
63 client_ = std::move(client); 64 client_.Bind(std::move(client));
64 65
65 decoder_->Initialize( 66 decoder_->Initialize(
66 config.To<media::AudioDecoderConfig>(), cdm_context, 67 config.To<media::AudioDecoderConfig>(), cdm_context,
67 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback, 68 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback,
68 cdm), 69 cdm),
69 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_)); 70 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_));
70 } 71 }
71 72
72 void MojoAudioDecoderService::SetDataSource( 73 void MojoAudioDecoderService::SetDataSource(
73 mojo::ScopedDataPipeConsumerHandle receive_pipe) { 74 mojo::ScopedDataPipeConsumerHandle receive_pipe) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 127
127 void MojoAudioDecoderService::OnAudioBufferReady( 128 void MojoAudioDecoderService::OnAudioBufferReady(
128 const scoped_refptr<AudioBuffer>& audio_buffer) { 129 const scoped_refptr<AudioBuffer>& audio_buffer) {
129 DVLOG(1) << __FUNCTION__; 130 DVLOG(1) << __FUNCTION__;
130 131
131 // TODO(timav): Use DataPipe. 132 // TODO(timav): Use DataPipe.
132 client_->OnBufferDecoded(mojom::AudioBuffer::From(audio_buffer)); 133 client_->OnBufferDecoded(mojom::AudioBuffer::From(audio_buffer));
133 } 134 }
134 135
135 } // namespace media 136 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_audio_decoder_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698