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

Unified Diff: media/mojo/services/mojo_audio_decoder_service.cc

Issue 1810293005: Implement MojoAudioDecoderService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spitzer-audio-client-init
Patch Set: Added log for NOTREACHED() 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/mojo/services/mojo_audio_decoder_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 85128453eb59614dcc748c086f97f05f0f1352d5..51fdef58f71149a6e9c2497386bc79f7344e6080 100644
--- a/media/mojo/services/mojo_audio_decoder_service.cc
+++ b/media/mojo/services/mojo_audio_decoder_service.cc
@@ -2,15 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "media/mojo/services/mojo_audio_decoder_service.h"
+#include "base/bind.h"
+#include "base/bind_helpers.h"
+#include "base/logging.h"
+#include "media/base/cdm_context.h"
+#include "media/mojo/common/media_type_converters.h"
+
namespace media {
MojoAudioDecoderService::MojoAudioDecoderService(
scoped_ptr<media::AudioDecoder> decoder,
mojo::InterfaceRequest<interfaces::AudioDecoder> request)
- : binding_(this, std::move(request)), decoder_(std::move(decoder)) {}
+ : binding_(this, std::move(request)),
+ decoder_(std::move(decoder)),
+ weak_factory_(this) {
+ weak_this_ = weak_factory_.GetWeakPtr();
+}
MojoAudioDecoderService::~MojoAudioDecoderService() {}
@@ -19,19 +28,87 @@ void MojoAudioDecoderService::Initialize(
interfaces::AudioDecoderConfigPtr config,
int32_t cdm_id,
const InitializeCallback& callback) {
- NOTIMPLEMENTED();
- callback.Run(false, false);
+ 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;
+ }
+
+ client_ = std::move(client);
+
+ // TODO(timav): Get CdmContext from cdm_id.
+ decoder_->Initialize(
+ config.To<media::AudioDecoderConfig>(),
+ nullptr, // no CdmContext
+ base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback),
+ base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_));
}
void MojoAudioDecoderService::Decode(interfaces::DecoderBufferPtr buffer,
const DecodeCallback& callback) {
- NOTIMPLEMENTED();
- callback.Run(DecodeStatus::DECODE_ERROR);
+ DVLOG(3) << __FUNCTION__;
+ decoder_->Decode(ReadDecoderBuffer(std::move(buffer)),
+ base::Bind(&MojoAudioDecoderService::OnDecodeStatus,
+ weak_this_, callback));
}
void MojoAudioDecoderService::Reset(const ResetCallback& callback) {
- NOTIMPLEMENTED();
+ DVLOG(1) << __FUNCTION__;
+ decoder_->Reset(
+ base::Bind(&MojoAudioDecoderService::OnResetDone, weak_this_, callback));
+}
+
+void MojoAudioDecoderService::OnInitialized(const InitializeCallback& callback,
+ bool success) {
+ DVLOG(1) << __FUNCTION__ << " success:" << success;
+ callback.Run(success, decoder_->NeedsBitstreamConversion());
+}
+
+static interfaces::AudioDecoder::DecodeStatus ConvertDecodeStatus(
+ media::AudioDecoder::Status status) {
+ switch (status) {
+ case media::AudioDecoder::kOk:
+ return interfaces::AudioDecoder::DecodeStatus::OK;
+ case media::AudioDecoder::kAborted:
+ return interfaces::AudioDecoder::DecodeStatus::ABORTED;
+ case media::AudioDecoder::kDecodeError:
+ return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
+ }
+ NOTREACHED();
+ return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
+}
+
+void MojoAudioDecoderService::OnDecodeStatus(
+ const DecodeCallback& callback,
+ media::AudioDecoder::Status status) {
+ DVLOG(3) << __FUNCTION__ << " status:" << status;
+ callback.Run(ConvertDecodeStatus(status));
+}
+
+void MojoAudioDecoderService::OnResetDone(const ResetCallback& callback) {
+ DVLOG(1) << __FUNCTION__;
callback.Run();
}
+void MojoAudioDecoderService::OnAudioBufferReady(
+ const scoped_refptr<AudioBuffer>& audio_buffer) {
+ DVLOG(1) << __FUNCTION__;
+ NOTIMPLEMENTED();
+}
+
+scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer(
+ interfaces::DecoderBufferPtr buffer) {
+ scoped_refptr<DecoderBuffer> media_buffer(
+ buffer.To<scoped_refptr<DecoderBuffer>>());
+
+ NOTIMPLEMENTED();
+ return media_buffer;
+}
+
} // namespace media
« 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