| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_BASE_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_BASE_AUDIO_DECODER_H_ |
| 6 #define MEDIA_BASE_AUDIO_DECODER_H_ | 6 #define MEDIA_BASE_AUDIO_DECODER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "media/base/audio_decoder_config.h" | 12 #include "media/base/audio_decoder_config.h" |
| 13 #include "media/base/cdm_context.h" | |
| 14 #include "media/base/channel_layout.h" | 13 #include "media/base/channel_layout.h" |
| 15 #include "media/base/decoder_buffer.h" | 14 #include "media/base/decoder_buffer.h" |
| 16 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 17 #include "media/base/pipeline_status.h" | 16 #include "media/base/pipeline_status.h" |
| 18 | 17 |
| 19 namespace media { | 18 namespace media { |
| 20 | 19 |
| 21 class AudioBuffer; | 20 class AudioBuffer; |
| 22 class DemuxerStream; | 21 class DemuxerStream; |
| 23 | 22 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 50 // Note: Since this is a destructor, |this| will be destroyed after this call. | 49 // Note: Since this is a destructor, |this| will be destroyed after this call. |
| 51 // Make sure the callbacks fired from this call doesn't post any task that | 50 // Make sure the callbacks fired from this call doesn't post any task that |
| 52 // depends on |this|. | 51 // depends on |this|. |
| 53 virtual ~AudioDecoder(); | 52 virtual ~AudioDecoder(); |
| 54 | 53 |
| 55 // Returns the name of the decoder for logging purpose. | 54 // Returns the name of the decoder for logging purpose. |
| 56 virtual std::string GetDisplayName() const = 0; | 55 virtual std::string GetDisplayName() const = 0; |
| 57 | 56 |
| 58 // Initializes an AudioDecoder with the given DemuxerStream, executing the | 57 // Initializes an AudioDecoder with the given DemuxerStream, executing the |
| 59 // callback upon completion. | 58 // callback upon completion. |
| 60 // | |
| 61 // |set_cdm_ready_cb| can be used to set/cancel a CdmReadyCB with which the | |
| 62 // decoder can be notified when a CDM is ready. The decoder can use the CDM to | |
| 63 // handle encrypted video stream. | |
| 64 // | |
| 65 // |init_cb| is used to return initialization status. | 59 // |init_cb| is used to return initialization status. |
| 66 // |output_cb| is called for decoded audio buffers (see Decode()). | 60 // |output_cb| is called for decoded audio buffers (see Decode()). |
| 67 virtual void Initialize(const AudioDecoderConfig& config, | 61 virtual void Initialize(const AudioDecoderConfig& config, |
| 68 const SetCdmReadyCB& set_cdm_ready_cb, | |
| 69 const InitCB& init_cb, | 62 const InitCB& init_cb, |
| 70 const OutputCB& output_cb) = 0; | 63 const OutputCB& output_cb) = 0; |
| 71 | 64 |
| 72 // Requests samples to be decoded. Only one decode may be in flight at any | 65 // Requests samples to be decoded. Only one decode may be in flight at any |
| 73 // given time. Once the buffer is decoded the decoder calls |decode_cb|. | 66 // given time. Once the buffer is decoded the decoder calls |decode_cb|. |
| 74 // |output_cb| specified in Initialize() is called for each decoded buffer, | 67 // |output_cb| specified in Initialize() is called for each decoded buffer, |
| 75 // before or after |decode_cb|. | 68 // before or after |decode_cb|. |
| 76 // | 69 // |
| 77 // Implementations guarantee that the callbacks will not be called from within | 70 // Implementations guarantee that the callbacks will not be called from within |
| 78 // this method. | 71 // this method. |
| 79 // | 72 // |
| 80 // If |buffer| is an EOS buffer then the decoder must be flushed, i.e. | 73 // If |buffer| is an EOS buffer then the decoder must be flushed, i.e. |
| 81 // |output_cb| must be called for each frame pending in the queue and | 74 // |output_cb| must be called for each frame pending in the queue and |
| 82 // |decode_cb| must be called after that. | 75 // |decode_cb| must be called after that. |
| 83 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 76 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 84 const DecodeCB& decode_cb) = 0; | 77 const DecodeCB& decode_cb) = 0; |
| 85 | 78 |
| 86 // Resets decoder state. All pending Decode() requests will be finished or | 79 // Resets decoder state. All pending Decode() requests will be finished or |
| 87 // aborted before |closure| is called. | 80 // aborted before |closure| is called. |
| 88 virtual void Reset(const base::Closure& closure) = 0; | 81 virtual void Reset(const base::Closure& closure) = 0; |
| 89 | 82 |
| 90 private: | 83 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); | 84 DISALLOW_COPY_AND_ASSIGN(AudioDecoder); |
| 92 }; | 85 }; |
| 93 | 86 |
| 94 } // namespace media | 87 } // namespace media |
| 95 | 88 |
| 96 #endif // MEDIA_BASE_AUDIO_DECODER_H_ | 89 #endif // MEDIA_BASE_AUDIO_DECODER_H_ |
| OLD | NEW |