Chromium Code Reviews| 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/bindings/interface_ptr_info.h" | |
| 13 #include "mojo/public/cpp/system/data_pipe.h" | 14 #include "mojo/public/cpp/system/data_pipe.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 | 21 |
| 21 // An AudioDecoder that proxies to an interfaces::AudioDecoder. | 22 // An AudioDecoder that proxies to an interfaces::AudioDecoder. |
| 22 class MojoAudioDecoder : public AudioDecoder, | 23 class MojoAudioDecoder : public AudioDecoder, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 // A helper method that creates data pipe and sets the data connection to | 57 // A helper method that creates data pipe and sets the data connection to |
| 57 // the service. | 58 // the service. |
| 58 void CreateDataPipe(); | 59 void CreateDataPipe(); |
| 59 | 60 |
| 60 // A helper method to serialize the data section of DecoderBuffer into pipe. | 61 // A helper method to serialize the data section of DecoderBuffer into pipe. |
| 61 interfaces::DecoderBufferPtr TransferDecoderBuffer( | 62 interfaces::DecoderBufferPtr TransferDecoderBuffer( |
| 62 const scoped_refptr<DecoderBuffer>& media_buffer); | 63 const scoped_refptr<DecoderBuffer>& media_buffer); |
| 63 | 64 |
| 64 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 65 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 65 | 66 |
| 67 // This class is constructed on one thread and used exclusively on another | |
| 68 // thread. This member is used to safely pass the AudioDecoderPtr from one | |
| 69 // thread to another. It is set in the constructor and is consumed in | |
| 70 // Initialize(). | |
| 71 mojo::InterfacePtrInfo<interfaces::AudioDecoder> remote_decoder_info_; | |
|
yzshen1
2016/03/22 19:15:04
optional: you could use interfaces::AudioDecoderPt
xhwang
2016/03/22 19:45:26
Done.
| |
| 72 | |
| 66 interfaces::AudioDecoderPtr remote_decoder_; | 73 interfaces::AudioDecoderPtr remote_decoder_; |
| 67 | 74 |
| 68 // DataPipe for serializing the data section of DecoderBuffer. | 75 // DataPipe for serializing the data section of DecoderBuffer. |
| 69 mojo::ScopedDataPipeProducerHandle producer_handle_; | 76 mojo::ScopedDataPipeProducerHandle producer_handle_; |
| 70 | 77 |
| 71 // Binding for AudioDecoderClient, bound to the |task_runner_|. | 78 // Binding for AudioDecoderClient, bound to the |task_runner_|. |
| 72 mojo::Binding<AudioDecoderClient> binding_; | 79 mojo::Binding<AudioDecoderClient> binding_; |
| 73 | 80 |
| 74 // We call the following callbacks to pass the information to the pipeline. | 81 // We call the following callbacks to pass the information to the pipeline. |
| 75 // |output_cb_| is permanent while other three are called only once, | 82 // |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(). | 83 // |decode_cb_| and |reset_cb_| are replaced by every by Decode() and Reset(). |
| 77 InitCB init_cb_; | 84 InitCB init_cb_; |
| 78 OutputCB output_cb_; | 85 OutputCB output_cb_; |
| 79 DecodeCB decode_cb_; | 86 DecodeCB decode_cb_; |
| 80 base::Closure reset_cb_; | 87 base::Closure reset_cb_; |
| 81 | 88 |
| 82 // Flag that is set if we got connection error. Never cleared. | 89 // Flag that is set if we got connection error. Never cleared. |
| 83 bool has_connection_error_; | 90 bool has_connection_error_; |
| 84 | 91 |
| 85 // Flag telling whether this decoder requires bitstream conversion. | 92 // Flag telling whether this decoder requires bitstream conversion. |
| 86 // Passed from |remote_decoder_| as a result of its initialization. | 93 // Passed from |remote_decoder_| as a result of its initialization. |
| 87 bool needs_bitstream_conversion_; | 94 bool needs_bitstream_conversion_; |
| 88 | 95 |
| 89 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoder); | 96 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoder); |
| 90 }; | 97 }; |
| 91 | 98 |
| 92 } // namespace media | 99 } // namespace media |
| 93 | 100 |
| 94 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ | 101 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_H_ |
| OLD | NEW |