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

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

Issue 1977173002: Rename media::interfaces to media::mojom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: android + chromeos files Created 4 years, 7 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') | media/mojo/services/mojo_cdm.h » ('j') | 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" 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/base/media_keys.h"
12 #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" 13 #include "media/mojo/services/mojo_cdm_service_context.h"
14 14
15 namespace media { 15 namespace media {
16 16
17 static interfaces::AudioDecoder::DecodeStatus ConvertDecodeStatus( 17 static mojom::AudioDecoder::DecodeStatus ConvertDecodeStatus(
18 media::DecodeStatus status) { 18 media::DecodeStatus status) {
19 switch (status) { 19 switch (status) {
20 case media::DecodeStatus::OK: 20 case media::DecodeStatus::OK:
21 return interfaces::AudioDecoder::DecodeStatus::OK; 21 return mojom::AudioDecoder::DecodeStatus::OK;
22 case media::DecodeStatus::ABORTED: 22 case media::DecodeStatus::ABORTED:
23 return interfaces::AudioDecoder::DecodeStatus::ABORTED; 23 return mojom::AudioDecoder::DecodeStatus::ABORTED;
24 case media::DecodeStatus::DECODE_ERROR: 24 case media::DecodeStatus::DECODE_ERROR:
25 return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR; 25 return mojom::AudioDecoder::DecodeStatus::DECODE_ERROR;
26 } 26 }
27 NOTREACHED(); 27 NOTREACHED();
28 return interfaces::AudioDecoder::DecodeStatus::DECODE_ERROR; 28 return mojom::AudioDecoder::DecodeStatus::DECODE_ERROR;
29 } 29 }
30 30
31 MojoAudioDecoderService::MojoAudioDecoderService( 31 MojoAudioDecoderService::MojoAudioDecoderService(
32 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, 32 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context,
33 std::unique_ptr<media::AudioDecoder> decoder, 33 std::unique_ptr<media::AudioDecoder> decoder,
34 mojo::InterfaceRequest<interfaces::AudioDecoder> request) 34 mojo::InterfaceRequest<mojom::AudioDecoder> request)
35 : binding_(this, std::move(request)), 35 : binding_(this, std::move(request)),
36 mojo_cdm_service_context_(mojo_cdm_service_context), 36 mojo_cdm_service_context_(mojo_cdm_service_context),
37 decoder_(std::move(decoder)), 37 decoder_(std::move(decoder)),
38 weak_factory_(this) { 38 weak_factory_(this) {
39 weak_this_ = weak_factory_.GetWeakPtr(); 39 weak_this_ = weak_factory_.GetWeakPtr();
40 } 40 }
41 41
42 MojoAudioDecoderService::~MojoAudioDecoderService() {} 42 MojoAudioDecoderService::~MojoAudioDecoderService() {}
43 43
44 void MojoAudioDecoderService::Initialize( 44 void MojoAudioDecoderService::Initialize(mojom::AudioDecoderClientPtr client,
45 interfaces::AudioDecoderClientPtr client, 45 mojom::AudioDecoderConfigPtr config,
46 interfaces::AudioDecoderConfigPtr config, 46 int32_t cdm_id,
47 int32_t cdm_id, 47 const InitializeCallback& callback) {
48 const InitializeCallback& callback) {
49 DVLOG(1) << __FUNCTION__ << " " 48 DVLOG(1) << __FUNCTION__ << " "
50 << config.To<media::AudioDecoderConfig>().AsHumanReadableString(); 49 << config.To<media::AudioDecoderConfig>().AsHumanReadableString();
51 50
52 // Get CdmContext from cdm_id if the stream is encrypted. 51 // Get CdmContext from cdm_id if the stream is encrypted.
53 CdmContext* cdm_context = nullptr; 52 CdmContext* cdm_context = nullptr;
54 scoped_refptr<MediaKeys> cdm; 53 scoped_refptr<MediaKeys> cdm;
55 if (config.To<media::AudioDecoderConfig>().is_encrypted()) { 54 if (config.To<media::AudioDecoderConfig>().is_encrypted()) {
56 if (!mojo_cdm_service_context_) { 55 if (!mojo_cdm_service_context_) {
57 DVLOG(1) << "CDM service context not available."; 56 DVLOG(1) << "CDM service context not available.";
58 callback.Run(false, false); 57 callback.Run(false, false);
(...skipping 23 matching lines...) Expand all
82 cdm), 81 cdm),
83 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_)); 82 base::Bind(&MojoAudioDecoderService::OnAudioBufferReady, weak_this_));
84 } 83 }
85 84
86 void MojoAudioDecoderService::SetDataSource( 85 void MojoAudioDecoderService::SetDataSource(
87 mojo::ScopedDataPipeConsumerHandle receive_pipe) { 86 mojo::ScopedDataPipeConsumerHandle receive_pipe) {
88 DVLOG(1) << __FUNCTION__; 87 DVLOG(1) << __FUNCTION__;
89 consumer_handle_ = std::move(receive_pipe); 88 consumer_handle_ = std::move(receive_pipe);
90 } 89 }
91 90
92 void MojoAudioDecoderService::Decode(interfaces::DecoderBufferPtr buffer, 91 void MojoAudioDecoderService::Decode(mojom::DecoderBufferPtr buffer,
93 const DecodeCallback& callback) { 92 const DecodeCallback& callback) {
94 DVLOG(3) << __FUNCTION__; 93 DVLOG(3) << __FUNCTION__;
95 94
96 scoped_refptr<DecoderBuffer> media_buffer = 95 scoped_refptr<DecoderBuffer> media_buffer =
97 ReadDecoderBuffer(std::move(buffer)); 96 ReadDecoderBuffer(std::move(buffer));
98 if (!media_buffer) { 97 if (!media_buffer) {
99 callback.Run(ConvertDecodeStatus(media::DecodeStatus::DECODE_ERROR)); 98 callback.Run(ConvertDecodeStatus(media::DecodeStatus::DECODE_ERROR));
100 return; 99 return;
101 } 100 }
102 101
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void MojoAudioDecoderService::OnResetDone(const ResetCallback& callback) { 133 void MojoAudioDecoderService::OnResetDone(const ResetCallback& callback) {
135 DVLOG(1) << __FUNCTION__; 134 DVLOG(1) << __FUNCTION__;
136 callback.Run(); 135 callback.Run();
137 } 136 }
138 137
139 void MojoAudioDecoderService::OnAudioBufferReady( 138 void MojoAudioDecoderService::OnAudioBufferReady(
140 const scoped_refptr<AudioBuffer>& audio_buffer) { 139 const scoped_refptr<AudioBuffer>& audio_buffer) {
141 DVLOG(1) << __FUNCTION__; 140 DVLOG(1) << __FUNCTION__;
142 141
143 // TODO(timav): Use DataPipe. 142 // TODO(timav): Use DataPipe.
144 client_->OnBufferDecoded(interfaces::AudioBuffer::From(audio_buffer)); 143 client_->OnBufferDecoded(mojom::AudioBuffer::From(audio_buffer));
145 } 144 }
146 145
147 scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer( 146 scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer(
148 interfaces::DecoderBufferPtr buffer) { 147 mojom::DecoderBufferPtr buffer) {
149 scoped_refptr<DecoderBuffer> media_buffer( 148 scoped_refptr<DecoderBuffer> media_buffer(
150 buffer.To<scoped_refptr<DecoderBuffer>>()); 149 buffer.To<scoped_refptr<DecoderBuffer>>());
151 150
152 if (media_buffer->end_of_stream()) 151 if (media_buffer->end_of_stream())
153 return media_buffer; 152 return media_buffer;
154 153
155 // Wait for the data to become available in the DataPipe. 154 // Wait for the data to become available in the DataPipe.
156 MojoHandleSignalsState state; 155 MojoHandleSignalsState state;
157 CHECK_EQ(MOJO_RESULT_OK, 156 CHECK_EQ(MOJO_RESULT_OK,
158 MojoWait(consumer_handle_.get().value(), MOJO_HANDLE_SIGNAL_READABLE, 157 MojoWait(consumer_handle_.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
(...skipping 14 matching lines...) Expand all
173 uint32_t bytes_read = bytes_to_read; 172 uint32_t bytes_read = bytes_to_read;
174 CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(), 173 CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(),
175 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE), 174 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE),
176 MOJO_RESULT_OK); 175 MOJO_RESULT_OK);
177 CHECK_EQ(bytes_to_read, bytes_read); 176 CHECK_EQ(bytes_to_read, bytes_read);
178 177
179 return media_buffer; 178 return media_buffer;
180 } 179 }
181 180
182 } // namespace media 181 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_audio_decoder_service.h ('k') | media/mojo/services/mojo_cdm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698