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_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_BASE_VIDEO_DECODER_H_ |
6 #define MEDIA_BASE_VIDEO_DECODER_H_ | 6 #define MEDIA_BASE_VIDEO_DECODER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "media/base/media_export.h" | 10 #include "media/base/media_export.h" |
11 #include "media/base/pipeline_status.h" | 11 #include "media/base/pipeline_status.h" |
12 #include "ui/gfx/size.h" | 12 #include "ui/gfx/size.h" |
13 | 13 |
14 namespace media { | 14 namespace media { |
15 | 15 |
16 class DecoderBuffer; | 16 class DecoderBuffer; |
17 class VideoDecoderConfig; | 17 class VideoDecoderConfig; |
18 class VideoFrame; | 18 class VideoFrame; |
19 | 19 |
20 class MEDIA_EXPORT VideoDecoder { | 20 class MEDIA_EXPORT VideoDecoder { |
21 public: | 21 public: |
22 // Status codes for decode operations on VideoDecoder. | 22 // Status codes for decode operations on VideoDecoder. |
| 23 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums |
| 24 // match, break them into a decoder_status.h. |
23 enum Status { | 25 enum Status { |
24 kOk, // Everything went as planned. | 26 kOk, // Everything went as planned. |
25 kAborted, // Decode was aborted as a result of Reset() being called. | 27 kAborted, // Decode was aborted as a result of Reset() being called. |
26 kNotEnoughData, // Not enough data to produce a video frame. | 28 kNotEnoughData, // Not enough data to produce a video frame. |
27 kDecodeError, // Decoding error happened. | 29 kDecodeError, // Decoding error happened. |
28 kDecryptError // Decrypting error happened. | 30 kDecryptError // Decrypting error happened. |
29 }; | 31 }; |
30 | 32 |
31 VideoDecoder(); | 33 VideoDecoder(); |
32 virtual ~VideoDecoder(); | 34 virtual ~VideoDecoder(); |
(...skipping 19 matching lines...) Expand all Loading... |
52 // | 54 // |
53 // If the returned status is kOk: | 55 // If the returned status is kOk: |
54 // - Non-EOS (end of stream) frame contains decoded video data. | 56 // - Non-EOS (end of stream) frame contains decoded video data. |
55 // - EOS frame indicates the end of the stream. | 57 // - EOS frame indicates the end of the stream. |
56 // Otherwise the returned frame must be NULL. | 58 // Otherwise the returned frame must be NULL. |
57 typedef base::Callback<void(Status, | 59 typedef base::Callback<void(Status, |
58 const scoped_refptr<VideoFrame>&)> DecodeCB; | 60 const scoped_refptr<VideoFrame>&)> DecodeCB; |
59 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 61 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
60 const DecodeCB& decode_cb) = 0; | 62 const DecodeCB& decode_cb) = 0; |
61 | 63 |
| 64 // Some VideoDecoders may queue up multiple VideoFrames from a single |
| 65 // DecoderBuffer, if we have any such queued frames this will return the next |
| 66 // one. Otherwise we return a NULL VideoFrame. |
| 67 virtual scoped_refptr<VideoFrame> GetDecodeOutput(); |
| 68 |
62 // Resets decoder state, fulfilling all pending DecodeCB and dropping extra | 69 // Resets decoder state, fulfilling all pending DecodeCB and dropping extra |
63 // queued decoded data. After this call, the decoder is back to an initialized | 70 // queued decoded data. After this call, the decoder is back to an initialized |
64 // clean state. | 71 // clean state. |
65 // Note: No VideoDecoder calls should be made before |closure| is executed. | 72 // Note: No VideoDecoder calls should be made before |closure| is executed. |
66 virtual void Reset(const base::Closure& closure) = 0; | 73 virtual void Reset(const base::Closure& closure) = 0; |
67 | 74 |
68 // Stops decoder, fires any pending callbacks and sets the decoder to an | 75 // Stops decoder, fires any pending callbacks and sets the decoder to an |
69 // uninitialized state. A VideoDecoder cannot be re-initialized after it has | 76 // uninitialized state. A VideoDecoder cannot be re-initialized after it has |
70 // been stopped. | 77 // been stopped. |
71 // Note that if Initialize() has been called, Stop() must be called and | 78 // Note that if Initialize() has been called, Stop() must be called and |
(...skipping 14 matching lines...) Expand all Loading... |
86 // use a fixed set of VideoFrames for decoding. | 93 // use a fixed set of VideoFrames for decoding. |
87 virtual bool CanReadWithoutStalling() const; | 94 virtual bool CanReadWithoutStalling() const; |
88 | 95 |
89 private: | 96 private: |
90 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 97 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
91 }; | 98 }; |
92 | 99 |
93 } // namespace media | 100 } // namespace media |
94 | 101 |
95 #endif // MEDIA_BASE_VIDEO_DECODER_H_ | 102 #endif // MEDIA_BASE_VIDEO_DECODER_H_ |
OLD | NEW |