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

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

Issue 2624213006: media: Fix MojoAudioDecoder reinitialization (Closed)
Patch Set: Created 3 years, 11 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
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"
11 #include "media/base/content_decryption_module.h" 11 #include "media/base/content_decryption_module.h"
12 #include "media/mojo/common/media_type_converters.h" 12 #include "media/mojo/common/media_type_converters.h"
13 #include "media/mojo/common/mojo_decoder_buffer_converter.h" 13 #include "media/mojo/common/mojo_decoder_buffer_converter.h"
14 #include "media/mojo/services/mojo_cdm_service_context.h" 14 #include "media/mojo/services/mojo_cdm_service_context.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 MojoAudioDecoderService::MojoAudioDecoderService( 18 MojoAudioDecoderService::MojoAudioDecoderService(
19 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, 19 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context,
20 std::unique_ptr<media::AudioDecoder> decoder) 20 std::unique_ptr<media::AudioDecoder> decoder)
21 : mojo_cdm_service_context_(mojo_cdm_service_context), 21 : mojo_cdm_service_context_(mojo_cdm_service_context),
22 decoder_(std::move(decoder)), 22 decoder_(std::move(decoder)),
23 weak_factory_(this) { 23 weak_factory_(this) {
24 weak_this_ = weak_factory_.GetWeakPtr(); 24 weak_this_ = weak_factory_.GetWeakPtr();
25 } 25 }
26 26
27 MojoAudioDecoderService::~MojoAudioDecoderService() {} 27 MojoAudioDecoderService::~MojoAudioDecoderService() {}
28 28
29 void MojoAudioDecoderService::Construct(
30 mojom::AudioDecoderClientAssociatedPtrInfo client) {
31 DVLOG(1) << __func__;
32 client_.Bind(std::move(client));
33 }
34
29 void MojoAudioDecoderService::Initialize( 35 void MojoAudioDecoderService::Initialize(
30 mojom::AudioDecoderClientAssociatedPtrInfo client,
31 mojom::AudioDecoderConfigPtr config, 36 mojom::AudioDecoderConfigPtr config,
32 int32_t cdm_id, 37 int32_t cdm_id,
33 const InitializeCallback& callback) { 38 const InitializeCallback& callback) {
34 DVLOG(1) << __func__ << " " 39 DVLOG(1) << __func__ << " "
35 << config.To<media::AudioDecoderConfig>().AsHumanReadableString(); 40 << config.To<media::AudioDecoderConfig>().AsHumanReadableString();
36 41
37 // Get CdmContext from cdm_id if the stream is encrypted. 42 // Get CdmContext from cdm_id if the stream is encrypted.
38 CdmContext* cdm_context = nullptr; 43 CdmContext* cdm_context = nullptr;
39 scoped_refptr<ContentDecryptionModule> cdm; 44 scoped_refptr<ContentDecryptionModule> cdm;
40 if (config.To<media::AudioDecoderConfig>().is_encrypted()) { 45 if (config.To<media::AudioDecoderConfig>().is_encrypted()) {
(...skipping 11 matching lines...) Expand all
52 } 57 }
53 58
54 cdm_context = cdm->GetCdmContext(); 59 cdm_context = cdm->GetCdmContext();
55 if (!cdm_context) { 60 if (!cdm_context) {
56 DVLOG(1) << "CDM context not available for CDM id: " << cdm_id; 61 DVLOG(1) << "CDM context not available for CDM id: " << cdm_id;
57 callback.Run(false, false); 62 callback.Run(false, false);
58 return; 63 return;
59 } 64 }
60 } 65 }
61 66
62 client_.Bind(std::move(client));
63
64 decoder_->Initialize( 67 decoder_->Initialize(
65 config.To<media::AudioDecoderConfig>(), cdm_context, 68 config.To<media::AudioDecoderConfig>(), cdm_context,
66 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback, 69 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback,
67 cdm), 70 cdm),
68 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_)); 71 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_));
69 } 72 }
70 73
71 void MojoAudioDecoderService::SetDataSource( 74 void MojoAudioDecoderService::SetDataSource(
72 mojo::ScopedDataPipeConsumerHandle receive_pipe) { 75 mojo::ScopedDataPipeConsumerHandle receive_pipe) {
73 DVLOG(1) << __func__; 76 DVLOG(1) << __func__;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 138
136 void MojoAudioDecoderService::OnAudioBufferReady( 139 void MojoAudioDecoderService::OnAudioBufferReady(
137 const scoped_refptr<AudioBuffer>& audio_buffer) { 140 const scoped_refptr<AudioBuffer>& audio_buffer) {
138 DVLOG(1) << __func__; 141 DVLOG(1) << __func__;
139 142
140 // TODO(timav): Use DataPipe. 143 // TODO(timav): Use DataPipe.
141 client_->OnBufferDecoded(mojom::AudioBuffer::From(audio_buffer)); 144 client_->OnBufferDecoded(mojom::AudioBuffer::From(audio_buffer));
142 } 145 }
143 146
144 } // namespace media 147 } // namespace media
OLDNEW
« media/mojo/clients/mojo_audio_decoder.cc ('K') | « 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