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