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

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

Issue 1824763002: Get CdmContext in MojoAudioDecoderService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spitzer-audio-serialize
Patch Set: Created 4 years, 9 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/media_keys.h"
11 #include "media/mojo/common/media_type_converters.h" 12 #include "media/mojo/common/media_type_converters.h"
13 #include "media/mojo/services/mojo_cdm_service_context.h"
12 14
13 namespace media { 15 namespace media {
14 16
15 MojoAudioDecoderService::MojoAudioDecoderService( 17 MojoAudioDecoderService::MojoAudioDecoderService(
18 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context,
16 scoped_ptr<media::AudioDecoder> decoder, 19 scoped_ptr<media::AudioDecoder> decoder,
17 mojo::InterfaceRequest<interfaces::AudioDecoder> request) 20 mojo::InterfaceRequest<interfaces::AudioDecoder> request)
18 : binding_(this, std::move(request)), 21 : binding_(this, std::move(request)),
22 mojo_cdm_service_context_(mojo_cdm_service_context),
19 decoder_(std::move(decoder)), 23 decoder_(std::move(decoder)),
20 weak_factory_(this) { 24 weak_factory_(this) {
21 weak_this_ = weak_factory_.GetWeakPtr(); 25 weak_this_ = weak_factory_.GetWeakPtr();
22 } 26 }
23 27
24 MojoAudioDecoderService::~MojoAudioDecoderService() {} 28 MojoAudioDecoderService::~MojoAudioDecoderService() {}
25 29
26 void MojoAudioDecoderService::Initialize( 30 void MojoAudioDecoderService::Initialize(
27 interfaces::AudioDecoderClientPtr client, 31 interfaces::AudioDecoderClientPtr client,
28 interfaces::AudioDecoderConfigPtr config, 32 interfaces::AudioDecoderConfigPtr config,
29 int32_t cdm_id, 33 int32_t cdm_id,
30 const InitializeCallback& callback) { 34 const InitializeCallback& callback) {
31 DVLOG(1) << __FUNCTION__ << " " 35 DVLOG(1) << __FUNCTION__ << " "
32 << config.To<media::AudioDecoderConfig>().AsHumanReadableString(); 36 << config.To<media::AudioDecoderConfig>().AsHumanReadableString();
33 37
34 // Encrypted streams are not supported for now. 38 // Get CdmContext from cdm_id if the stream is encrypted.
35 if (config.To<media::AudioDecoderConfig>().is_encrypted() && 39 CdmContext* cdm_context = nullptr;
36 cdm_id == CdmContext::kInvalidCdmId) { 40 if (config.To<media::AudioDecoderConfig>().is_encrypted()) {
37 // The client should prevent this situation. 41 if (!mojo_cdm_service_context_) {
38 NOTREACHED() << "Encrypted streams are not supported"; 42 DVLOG(1) << "CDM service context not available.";
39 callback.Run(false, false); 43 callback.Run(false, false);
40 return; 44 return;
45 }
46
47 scoped_refptr<MediaKeys> cdm = mojo_cdm_service_context_->GetCdm(cdm_id);
Tima Vaisburd 2016/03/21 20:40:57 [Q] Will this call succeed? Do we have cdm_id alre
xhwang 2016/03/21 20:50:49 This will work. But the check in line 55 will fail
xhwang 2016/03/21 20:55:58 When initialization is successful, you should hold
Tima Vaisburd 2016/03/21 21:53:01 Done, see my question though.
48 if (!cdm) {
49 DVLOG(1) << "CDM not found for CDM id: " << cdm_id;
50 callback.Run(false, false);
51 return;
52 }
53
54 cdm_context = cdm->GetCdmContext();
55 if (!cdm_context) {
56 DVLOG(1) << "CDM context not available for CDM id: " << cdm_id;
57 callback.Run(false, false);
58 return;
59 }
41 } 60 }
42 61
43 client_ = std::move(client); 62 client_ = std::move(client);
44 63
45 // TODO(timav): Get CdmContext from cdm_id.
46 decoder_->Initialize( 64 decoder_->Initialize(
47 config.To<media::AudioDecoderConfig>(), 65 config.To<media::AudioDecoderConfig>(), cdm_context,
48 nullptr, // no CdmContext
49 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback), 66 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback),
50 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_)); 67 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_));
51 } 68 }
52 69
53 void MojoAudioDecoderService::SetDataSource( 70 void MojoAudioDecoderService::SetDataSource(
54 mojo::ScopedDataPipeConsumerHandle receive_pipe) { 71 mojo::ScopedDataPipeConsumerHandle receive_pipe) {
55 DVLOG(1) << __FUNCTION__; 72 DVLOG(1) << __FUNCTION__;
56 consumer_handle_ = std::move(receive_pipe); 73 consumer_handle_ = std::move(receive_pipe);
57 } 74 }
58 75
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 uint32_t bytes_read = bytes_to_read; 148 uint32_t bytes_read = bytes_to_read;
132 CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(), 149 CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(),
133 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE), 150 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE),
134 MOJO_RESULT_OK); 151 MOJO_RESULT_OK);
135 CHECK_EQ(bytes_to_read, bytes_read); 152 CHECK_EQ(bytes_to_read, bytes_read);
136 153
137 return media_buffer; 154 return media_buffer;
138 } 155 }
139 156
140 } // namespace media 157 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_audio_decoder_service.h ('k') | media/mojo/services/service_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698