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

Side by Side 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: Addressed comments 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
« 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"
6
7 #include "base/bind.h"
8 #include "base/bind_helpers.h"
5 #include "base/logging.h" 9 #include "base/logging.h"
6 #include "media/mojo/services/mojo_audio_decoder_service.h" 10 #include "media/base/cdm_context.h"
11 #include "media/mojo/common/media_type_converters.h"
7 12
8 namespace media { 13 namespace media {
9 14
10 MojoAudioDecoderService::MojoAudioDecoderService( 15 MojoAudioDecoderService::MojoAudioDecoderService(
11 scoped_ptr<media::AudioDecoder> decoder, 16 scoped_ptr<media::AudioDecoder> decoder,
12 mojo::InterfaceRequest<interfaces::AudioDecoder> request) 17 mojo::InterfaceRequest<interfaces::AudioDecoder> request)
13 : binding_(this, std::move(request)), decoder_(std::move(decoder)) {} 18 : binding_(this, std::move(request)),
19 decoder_(std::move(decoder)),
20 weak_factory_(this) {
21 weak_this_ = weak_factory_.GetWeakPtr();
22 }
14 23
15 MojoAudioDecoderService::~MojoAudioDecoderService() {} 24 MojoAudioDecoderService::~MojoAudioDecoderService() {}
16 25
17 void MojoAudioDecoderService::Initialize( 26 void MojoAudioDecoderService::Initialize(
18 interfaces::AudioDecoderClientPtr client, 27 interfaces::AudioDecoderClientPtr client,
19 interfaces::AudioDecoderConfigPtr config, 28 interfaces::AudioDecoderConfigPtr config,
20 int32_t cdm_id, 29 int32_t cdm_id,
21 const InitializeCallback& callback) { 30 const InitializeCallback& callback) {
22 NOTIMPLEMENTED(); 31 DVLOG(1) << __FUNCTION__ << " "
23 callback.Run(false, false); 32 << config.To<media::AudioDecoderConfig>().AsHumanReadableString();
33
34 // Encrypted streams are not supported for now.
35 if (config.To<media::AudioDecoderConfig>().is_encrypted() &&
36 cdm_id == CdmContext::kInvalidCdmId) {
37 NOTREACHED(); // The client should prevent this situation.
xhwang 2016/03/19 03:45:53 nit: You can still use a error message for better
Tima Vaisburd 2016/03/19 04:10:34 Done.
38 callback.Run(false, false);
39 return;
40 }
41
42 client_ = std::move(client);
43
44 // TODO(timav): Get CdmContext from cdm_id.
45 decoder_->Initialize(
46 config.To<media::AudioDecoderConfig>(),
47 nullptr, // no CdmContext
48 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback),
49 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_));
24 } 50 }
25 51
26 void MojoAudioDecoderService::Decode(interfaces::DecoderBufferPtr buffer, 52 void MojoAudioDecoderService::Decode(interfaces::DecoderBufferPtr buffer,
27 const DecodeCallback& callback) { 53 const DecodeCallback& callback) {
28 NOTIMPLEMENTED(); 54 DVLOG(3) << __FUNCTION__;
29 callback.Run(DecodeStatus::DECODE_ERROR); 55 decoder_->Decode(ReadDecoderBuffer(std::move(buffer)),
56 base::Bind(&MojoAudioDecoderService::OnDecodeStatus,
57 weak_this_, callback));
30 } 58 }
31 59
32 void MojoAudioDecoderService::Reset(const ResetCallback& callback) { 60 void MojoAudioDecoderService::Reset(const ResetCallback& callback) {
33 NOTIMPLEMENTED(); 61 DVLOG(1) << __FUNCTION__;
62 decoder_->Reset(
63 base::Bind(&MojoAudioDecoderService::OnResetDone, weak_this_, callback));
64 }
65
66 void MojoAudioDecoderService::OnInitialized(const InitializeCallback& callback,
67 bool success) {
68 DVLOG(1) << __FUNCTION__ << " success:" << success;
69 callback.Run(success, decoder_->NeedsBitstreamConversion());
70 }
71
72 static interfaces::AudioDecoder::DecodeStatus ConvertDecodeStatus(
73 media::AudioDecoder::Status status) {
74 switch (status) {
75 case media::AudioDecoder::kOk:
76 return interfaces::AudioDecoder::DecodeStatus::OK;
77 case media::AudioDecoder::kAborted:
78 return interfaces::AudioDecoder::DecodeStatus::ABORTED;
79 case media::AudioDecoder::kDecodeError:
80 return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
81 }
82 NOTREACHED();
83 return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
84 }
85
86 void MojoAudioDecoderService::OnDecodeStatus(
87 const DecodeCallback& callback,
88 media::AudioDecoder::Status status) {
89 DVLOG(3) << __FUNCTION__ << " status:" << status;
90 callback.Run(ConvertDecodeStatus(status));
91 }
92
93 void MojoAudioDecoderService::OnResetDone(const ResetCallback& callback) {
94 DVLOG(1) << __FUNCTION__;
34 callback.Run(); 95 callback.Run();
35 } 96 }
36 97
98 void MojoAudioDecoderService::OnAudioBufferReady(
99 const scoped_refptr<AudioBuffer>& audio_buffer) {
100 DVLOG(1) << __FUNCTION__;
101 NOTIMPLEMENTED();
102 }
103
104 scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer(
105 interfaces::DecoderBufferPtr buffer) {
106 scoped_refptr<DecoderBuffer> media_buffer(
107 buffer.To<scoped_refptr<DecoderBuffer>>());
108
109 NOTIMPLEMENTED();
110 return media_buffer;
111 }
112
37 } // namespace media 113 } // 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