Index: media/mojo/services/mojo_audio_decoder_service.cc |
diff --git a/media/mojo/services/mojo_audio_decoder_service.cc b/media/mojo/services/mojo_audio_decoder_service.cc |
index dbe72d17125d6f94638e2e6c285b246a2ff60720..4845dd6ee63408926502e783cf7a8a6588390c5a 100644 |
--- a/media/mojo/services/mojo_audio_decoder_service.cc |
+++ b/media/mojo/services/mojo_audio_decoder_service.cc |
@@ -8,14 +8,18 @@ |
#include "base/bind_helpers.h" |
#include "base/logging.h" |
#include "media/base/cdm_context.h" |
+#include "media/base/media_keys.h" |
#include "media/mojo/common/media_type_converters.h" |
+#include "media/mojo/services/mojo_cdm_service_context.h" |
namespace media { |
MojoAudioDecoderService::MojoAudioDecoderService( |
+ base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, |
scoped_ptr<media::AudioDecoder> decoder, |
mojo::InterfaceRequest<interfaces::AudioDecoder> request) |
: binding_(this, std::move(request)), |
+ mojo_cdm_service_context_(mojo_cdm_service_context), |
decoder_(std::move(decoder)), |
weak_factory_(this) { |
weak_this_ = weak_factory_.GetWeakPtr(); |
@@ -31,21 +35,34 @@ void MojoAudioDecoderService::Initialize( |
DVLOG(1) << __FUNCTION__ << " " |
<< config.To<media::AudioDecoderConfig>().AsHumanReadableString(); |
- // Encrypted streams are not supported for now. |
- if (config.To<media::AudioDecoderConfig>().is_encrypted() && |
- cdm_id == CdmContext::kInvalidCdmId) { |
- // The client should prevent this situation. |
- NOTREACHED() << "Encrypted streams are not supported"; |
- callback.Run(false, false); |
- return; |
+ // Get CdmContext from cdm_id if the stream is encrypted. |
+ CdmContext* cdm_context = nullptr; |
+ if (config.To<media::AudioDecoderConfig>().is_encrypted()) { |
+ if (!mojo_cdm_service_context_) { |
+ DVLOG(1) << "CDM service context not available."; |
+ callback.Run(false, false); |
+ return; |
+ } |
+ |
+ 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.
|
+ if (!cdm) { |
+ DVLOG(1) << "CDM not found for CDM id: " << cdm_id; |
+ callback.Run(false, false); |
+ return; |
+ } |
+ |
+ cdm_context = cdm->GetCdmContext(); |
+ if (!cdm_context) { |
+ DVLOG(1) << "CDM context not available for CDM id: " << cdm_id; |
+ callback.Run(false, false); |
+ return; |
+ } |
} |
client_ = std::move(client); |
- // TODO(timav): Get CdmContext from cdm_id. |
decoder_->Initialize( |
- config.To<media::AudioDecoderConfig>(), |
- nullptr, // no CdmContext |
+ config.To<media::AudioDecoderConfig>(), cdm_context, |
base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback), |
base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_)); |
} |