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 #include "mojo/public/cpp/bindings/binding.h" |
| 13 #include "mojo/public/cpp/system/data_pipe.h" |
13 | 14 |
14 namespace base { | 15 namespace base { |
15 class SingleThreadTaskRunner; | 16 class SingleThreadTaskRunner; |
16 } | 17 } |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 // An AudioDecoder that proxies to an interfaces::AudioDecoder. | 21 // An AudioDecoder that proxies to an interfaces::AudioDecoder. |
21 class MojoAudioDecoder : public AudioDecoder, | 22 class MojoAudioDecoder : public AudioDecoder, |
22 public interfaces::AudioDecoderClient { | 23 public interfaces::AudioDecoderClient { |
(...skipping 22 matching lines...) Expand all Loading... |
45 | 46 |
46 // Called when |remote_decoder_| finished initialization. | 47 // Called when |remote_decoder_| finished initialization. |
47 void OnInitialized(bool status, bool needs_bitstream_conversion); | 48 void OnInitialized(bool status, bool needs_bitstream_conversion); |
48 | 49 |
49 // Called when |remote_decoder_| accepted or rejected DecoderBuffer. | 50 // Called when |remote_decoder_| accepted or rejected DecoderBuffer. |
50 void OnDecodeStatus(interfaces::AudioDecoder::DecodeStatus decode_status); | 51 void OnDecodeStatus(interfaces::AudioDecoder::DecodeStatus decode_status); |
51 | 52 |
52 // called when |remote_decoder_| finished Reset() sequence. | 53 // called when |remote_decoder_| finished Reset() sequence. |
53 void OnResetDone(); | 54 void OnResetDone(); |
54 | 55 |
| 56 // A helper method that creates data pipe and sets the data connection to |
| 57 // the service. |
| 58 void CreateDataPipe(); |
| 59 |
| 60 // A helper method to serialize the data section of DecoderBuffer into pipe. |
| 61 interfaces::DecoderBufferPtr TransferDecoderBuffer( |
| 62 const scoped_refptr<DecoderBuffer>& media_buffer); |
| 63 |
55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
56 | 65 |
57 interfaces::AudioDecoderPtr remote_decoder_; | 66 interfaces::AudioDecoderPtr remote_decoder_; |
58 | 67 |
| 68 // DataPipe for serializing the data section of DecoderBuffer. |
| 69 mojo::ScopedDataPipeProducerHandle producer_handle_; |
| 70 |
59 // Binding for AudioDecoderClient, bound to the |task_runner_|. | 71 // Binding for AudioDecoderClient, bound to the |task_runner_|. |
60 mojo::Binding<AudioDecoderClient> binding_; | 72 mojo::Binding<AudioDecoderClient> binding_; |
61 | 73 |
62 // We call these callbacks to pass the information to the pipeline. | 74 // We call the following callbacks to pass the information to the pipeline. |
| 75 // |output_cb_| is permanent while other three are called only once, |
| 76 // |decode_cb_| and |reset_cb_| are replaced by every by Decode() and Reset(). |
63 InitCB init_cb_; | 77 InitCB init_cb_; |
| 78 OutputCB output_cb_; |
64 DecodeCB decode_cb_; | 79 DecodeCB decode_cb_; |
65 base::Closure reset_cb_; | 80 base::Closure reset_cb_; |
66 | 81 |
67 // Flag that is set if we got connection error. Never cleared. | 82 // Flag that is set if we got connection error. Never cleared. |
68 bool has_connection_error_; | 83 bool has_connection_error_; |
69 | 84 |
70 // Flag telling whether this decoder requires bitstream conversion. | 85 // Flag telling whether this decoder requires bitstream conversion. |
71 // Passed from |remote_decoder_| as a result of its initialization. | 86 // Passed from |remote_decoder_| as a result of its initialization. |
72 bool needs_bitstream_conversion_; | 87 bool needs_bitstream_conversion_; |
73 | 88 |
74 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoder); | 89 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoder); |
75 }; | 90 }; |
76 | 91 |
77 } // namespace media | 92 } // namespace media |
78 | 93 |
79 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ | 94 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ |
OLD | NEW |