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 #ifndef MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ |
6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "media/base/audio_decoder.h" | 10 #include "media/base/audio_decoder.h" |
11 #include "media/mojo/interfaces/audio_decoder.mojom.h" | 11 #include "media/mojo/interfaces/audio_decoder.mojom.h" |
12 #include "mojo/public/cpp/bindings/binding.h" | |
12 | 13 |
13 namespace base { | 14 namespace base { |
14 class SingleThreadTaskRunner; | 15 class SingleThreadTaskRunner; |
15 } | 16 } |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 | 19 |
19 // An AudioDecoder that proxies to an interfaces::AudioDecoder. | 20 // An AudioDecoder that proxies to an interfaces::AudioDecoder. |
20 class MojoAudioDecoder : public AudioDecoder { | 21 class MojoAudioDecoder : public AudioDecoder, |
22 public interfaces::AudioDecoderClient { | |
21 public: | 23 public: |
22 MojoAudioDecoder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 24 MojoAudioDecoder(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
23 interfaces::AudioDecoderPtr remote_decoder); | 25 interfaces::AudioDecoderPtr remote_decoder); |
24 ~MojoAudioDecoder() final; | 26 ~MojoAudioDecoder() final; |
25 | 27 |
26 // AudioDecoder implementation. | 28 // AudioDecoder implementation. |
27 std::string GetDisplayName() const final; | 29 std::string GetDisplayName() const final; |
28 void Initialize(const AudioDecoderConfig& config, | 30 void Initialize(const AudioDecoderConfig& config, |
29 CdmContext* cdm_context, | 31 CdmContext* cdm_context, |
30 const InitCB& init_cb, | 32 const InitCB& init_cb, |
31 const OutputCB& output_cb) final; | 33 const OutputCB& output_cb) final; |
32 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 34 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
33 const DecodeCB& decode_cb) final; | 35 const DecodeCB& decode_cb) final; |
34 void Reset(const base::Closure& closure) final; | 36 void Reset(const base::Closure& closure) final; |
35 bool NeedsBitstreamConversion() const final; | 37 bool NeedsBitstreamConversion() const final; |
36 | 38 |
39 // AudioDecoderClient implementation. | |
xhwang
2016/03/18 02:19:43
nit: drop one space
Tima Vaisburd
2016/03/18 19:05:49
Done.
| |
40 void OnBufferDecoded(interfaces::AudioBufferPtr buffer) final; | |
41 | |
37 private: | 42 private: |
43 // Callback for connection error on |remote_renderer_|. | |
xhwang
2016/03/18 02:19:43
s/renderer/decoder
Tima Vaisburd
2016/03/18 19:05:49
Done.
| |
44 void OnConnectionError(); | |
45 | |
46 // Called when |remote_decored_| finished initialization. | |
xhwang
2016/03/18 02:19:43
decoder
Tima Vaisburd
2016/03/18 19:05:49
Done.
| |
47 void OnInitialized(bool status, bool needs_bitstream_conversion); | |
48 | |
49 // Called when |remote_decoder_| accepted or rejected DecoderBuffer. | |
50 void OnDecodeStarted(interfaces::AudioDecoder::DecodeStatus decode_status); | |
xhwang
2016/03/18 02:19:43
Started is not accurate. It's possible that OnBuf
Tima Vaisburd
2016/03/18 19:05:49
Started is not accurate because the buffer can be
xhwang
2016/03/18 19:17:17
mojo_audio_decoder is generic, it should work with
Tima Vaisburd
2016/03/18 19:35:03
I see. Acknowledged.
| |
51 | |
52 // called when |remote_decoder_| finished Reset() sequence. | |
53 void OnResetDone(); | |
54 | |
55 // Data. | |
xhwang
2016/03/18 02:19:43
nit: seems not necessary..
Tima Vaisburd
2016/03/18 19:05:49
Removed.
| |
56 | |
38 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 57 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
58 | |
39 interfaces::AudioDecoderPtr remote_decoder_; | 59 interfaces::AudioDecoderPtr remote_decoder_; |
40 | 60 |
61 // Binding for AudioDecoderClient, bound to the |task_runner_|. | |
62 mojo::Binding<AudioDecoderClient> binding_; | |
63 | |
64 // We call these callbacks to pass the information to the pipeline. | |
65 InitCB init_cb_; | |
66 DecodeCB decode_cb_; | |
67 base::Closure reset_cb_; | |
68 | |
69 // Flag that is set if we got connection error. Never cleared. | |
70 bool has_connection_error_; | |
71 | |
72 // Flag telling Whether this decoder requires bitstream conversion. | |
73 // Passed from the |remote_decoder_| as a result of its initialization. | |
74 bool needs_bitstream_conversion_; | |
75 | |
41 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoder); | 76 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoder); |
42 }; | 77 }; |
43 | 78 |
44 } // namespace media | 79 } // namespace media |
45 | 80 |
46 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ | 81 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ |
OLD | NEW |