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

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: 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 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 // The client should prevent this situation.
38 NOTREACHED() << "Encrypted streams are not supported";
39 callback.Run(false, false);
40 return;
41 }
42
43 client_ = std::move(client);
44
45 // TODO(timav): Get CdmContext from cdm_id.
46 decoder_->Initialize(
47 config.To<media::AudioDecoderConfig>(),
48 nullptr, // no CdmContext
49 base::Bind(&MojoAudioDecoderService::OnInitialized, weak_this_, callback),
50 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_));
24 } 51 }
25 52
26 void MojoAudioDecoderService::Decode(interfaces::DecoderBufferPtr buffer, 53 void MojoAudioDecoderService::Decode(interfaces::DecoderBufferPtr buffer,
27 const DecodeCallback& callback) { 54 const DecodeCallback& callback) {
28 NOTIMPLEMENTED(); 55 DVLOG(3) << __FUNCTION__;
29 callback.Run(DecodeStatus::DECODE_ERROR); 56 decoder_->Decode(ReadDecoderBuffer(std::move(buffer)),
57 base::Bind(&MojoAudioDecoderService::OnDecodeStatus,
58 weak_this_, callback));
30 } 59 }
31 60
32 void MojoAudioDecoderService::Reset(const ResetCallback& callback) { 61 void MojoAudioDecoderService::Reset(const ResetCallback& callback) {
33 NOTIMPLEMENTED(); 62 DVLOG(1) << __FUNCTION__;
63 decoder_->Reset(
64 base::Bind(&MojoAudioDecoderService::OnResetDone, weak_this_, callback));
65 }
66
67 void MojoAudioDecoderService::OnInitialized(const InitializeCallback& callback,
68 bool success) {
69 DVLOG(1) << __FUNCTION__ << " success:" << success;
70 callback.Run(success, decoder_->NeedsBitstreamConversion());
71 }
72
73 static interfaces::AudioDecoder::DecodeStatus ConvertDecodeStatus(
74 media::AudioDecoder::Status status) {
75 switch (status) {
76 case media::AudioDecoder::kOk:
77 return interfaces::AudioDecoder::DecodeStatus::OK;
78 case media::AudioDecoder::kAborted:
79 return interfaces::AudioDecoder::DecodeStatus::ABORTED;
80 case media::AudioDecoder::kDecodeError:
81 return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
82 }
83 NOTREACHED();
84 return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR;
85 }
86
87 void MojoAudioDecoderService::OnDecodeStatus(
88 const DecodeCallback& callback,
89 media::AudioDecoder::Status status) {
90 DVLOG(3) << __FUNCTION__ << " status:" << status;
91 callback.Run(ConvertDecodeStatus(status));
92 }
93
94 void MojoAudioDecoderService::OnResetDone(const ResetCallback& callback) {
95 DVLOG(1) << __FUNCTION__;
34 callback.Run(); 96 callback.Run();
35 } 97 }
36 98
99 void MojoAudioDecoderService::OnAudioBufferReady(
100 const scoped_refptr<AudioBuffer>& audio_buffer) {
101 DVLOG(1) << __FUNCTION__;
102 NOTIMPLEMENTED();
103 }
104
105 scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer(
106 interfaces::DecoderBufferPtr buffer) {
107 scoped_refptr<DecoderBuffer> media_buffer(
108 buffer.To<scoped_refptr<DecoderBuffer>>());
109
110 NOTIMPLEMENTED();
111 return media_buffer;
112 }
113
37 } // namespace media 114 } // 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