OLD | NEW |
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/clients/mojo_audio_decoder.h" | 5 #include "media/mojo/clients/mojo_audio_decoder.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/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
13 #include "base/threading/thread_task_runner_handle.h" | 13 #include "base/threading/thread_task_runner_handle.h" |
14 #include "media/base/audio_buffer.h" | 14 #include "media/base/audio_buffer.h" |
15 #include "media/base/cdm_context.h" | 15 #include "media/base/cdm_context.h" |
16 #include "media/base/demuxer_stream.h" | 16 #include "media/base/demuxer_stream.h" |
17 #include "media/mojo/common/media_type_converters.h" | 17 #include "media/mojo/common/media_type_converters.h" |
18 #include "media/mojo/common/mojo_decoder_buffer_converter.h" | 18 #include "media/mojo/common/mojo_decoder_buffer_converter.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 MojoAudioDecoder::MojoAudioDecoder( | 22 MojoAudioDecoder::MojoAudioDecoder( |
23 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 23 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
24 mojom::AudioDecoderPtr remote_decoder) | 24 mojom::AudioDecoderPtr remote_decoder) |
25 : task_runner_(task_runner), | 25 : task_runner_(task_runner), |
26 remote_decoder_info_(remote_decoder.PassInterface()), | 26 remote_decoder_info_(remote_decoder.PassInterface()), |
27 binding_(this), | 27 client_binding_(this), |
28 has_connection_error_(false), | 28 has_connection_error_(false), |
29 needs_bitstream_conversion_(false) { | 29 needs_bitstream_conversion_(false) { |
30 DVLOG(1) << __FUNCTION__; | 30 DVLOG(1) << __FUNCTION__; |
31 } | 31 } |
32 | 32 |
33 MojoAudioDecoder::~MojoAudioDecoder() { | 33 MojoAudioDecoder::~MojoAudioDecoder() { |
34 DVLOG(1) << __FUNCTION__; | 34 DVLOG(1) << __FUNCTION__; |
35 } | 35 } |
36 | 36 |
37 std::string MojoAudioDecoder::GetDisplayName() const { | 37 std::string MojoAudioDecoder::GetDisplayName() const { |
(...skipping 22 matching lines...) Expand all Loading... |
60 | 60 |
61 // Otherwise, set an error handler to catch the connection error. | 61 // Otherwise, set an error handler to catch the connection error. |
62 // Using base::Unretained(this) is safe because |this| owns |remote_decoder_|, | 62 // Using base::Unretained(this) is safe because |this| owns |remote_decoder_|, |
63 // and the error handler can't be invoked once |remote_decoder_| is destroyed. | 63 // and the error handler can't be invoked once |remote_decoder_| is destroyed. |
64 remote_decoder_.set_connection_error_handler( | 64 remote_decoder_.set_connection_error_handler( |
65 base::Bind(&MojoAudioDecoder::OnConnectionError, base::Unretained(this))); | 65 base::Bind(&MojoAudioDecoder::OnConnectionError, base::Unretained(this))); |
66 | 66 |
67 init_cb_ = init_cb; | 67 init_cb_ = init_cb; |
68 output_cb_ = output_cb; | 68 output_cb_ = output_cb; |
69 | 69 |
| 70 mojom::AudioDecoderClientAssociatedPtrInfo client_ptr_info; |
| 71 client_binding_.Bind(&client_ptr_info, remote_decoder_.associated_group()); |
| 72 |
70 // Using base::Unretained(this) is safe because |this| owns |remote_decoder_|, | 73 // Using base::Unretained(this) is safe because |this| owns |remote_decoder_|, |
71 // and the callback won't be dispatched if |remote_decoder_| is destroyed. | 74 // and the callback won't be dispatched if |remote_decoder_| is destroyed. |
72 remote_decoder_->Initialize( | 75 remote_decoder_->Initialize( |
73 binding_.CreateInterfacePtrAndBind(), | 76 std::move(client_ptr_info), mojom::AudioDecoderConfig::From(config), |
74 mojom::AudioDecoderConfig::From(config), cdm_id, | 77 cdm_id, |
75 base::Bind(&MojoAudioDecoder::OnInitialized, base::Unretained(this))); | 78 base::Bind(&MojoAudioDecoder::OnInitialized, base::Unretained(this))); |
76 } | 79 } |
77 | 80 |
78 void MojoAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& media_buffer, | 81 void MojoAudioDecoder::Decode(const scoped_refptr<DecoderBuffer>& media_buffer, |
79 const DecodeCB& decode_cb) { | 82 const DecodeCB& decode_cb) { |
80 DVLOG(3) << __FUNCTION__; | 83 DVLOG(3) << __FUNCTION__; |
81 DCHECK(task_runner_->BelongsToCurrentThread()); | 84 DCHECK(task_runner_->BelongsToCurrentThread()); |
82 | 85 |
83 if (has_connection_error_) { | 86 if (has_connection_error_) { |
84 task_runner_->PostTask(FROM_HERE, | 87 task_runner_->PostTask(FROM_HERE, |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 DCHECK(task_runner_->BelongsToCurrentThread()); | 188 DCHECK(task_runner_->BelongsToCurrentThread()); |
186 | 189 |
187 // For pending decodes OnDecodeStatus() should arrive before OnResetDone(). | 190 // For pending decodes OnDecodeStatus() should arrive before OnResetDone(). |
188 DCHECK(decode_cb_.is_null()); | 191 DCHECK(decode_cb_.is_null()); |
189 | 192 |
190 DCHECK(!reset_cb_.is_null()); | 193 DCHECK(!reset_cb_.is_null()); |
191 base::ResetAndReturn(&reset_cb_).Run(); | 194 base::ResetAndReturn(&reset_cb_).Run(); |
192 } | 195 } |
193 | 196 |
194 } // namespace media | 197 } // namespace media |
OLD | NEW |