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/pipeline_status.h" | 10 #include "media/base/pipeline_status.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 public: | 21 public: |
22 // Status codes for read operations on VideoDecoder. | 22 // Status codes for read operations on VideoDecoder. |
23 enum Status { | 23 enum Status { |
24 kOk, // Everything went as planned. | 24 kOk, // Everything went as planned. |
25 kDecodeError, // Decoding error happened. | 25 kDecodeError, // Decoding error happened. |
26 kDecryptError // Decrypting error happened. | 26 kDecryptError // Decrypting error happened. |
27 }; | 27 }; |
28 | 28 |
29 // Initializes a VideoDecoder with the given DemuxerStream, executing the | 29 // Initializes a VideoDecoder with the given DemuxerStream, executing the |
30 // |status_cb| upon completion. | 30 // |status_cb| upon completion. |
31 // |statistics_cb| is used to update global pipeline statistics. | 31 // |statistics_cb| is used to update the global pipeline statistics. |
| 32 // Note: No VideoDecoder calls should be made before |status_cb| is executed. |
32 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 33 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
33 const PipelineStatusCB& status_cb, | 34 const PipelineStatusCB& status_cb, |
34 const StatisticsCB& statistics_cb) = 0; | 35 const StatisticsCB& statistics_cb) = 0; |
35 | 36 |
36 // Requests a frame to be decoded. The status of the decoder and decoded frame | 37 // Requests a frame to be decoded. The status of the decoder and decoded frame |
37 // are returned via the provided callback. Only one read may be in flight at | 38 // are returned via the provided callback. Only one read may be in flight at |
38 // any given time. | 39 // any given time. |
39 // | 40 // |
40 // Implementations guarantee that the callback will not be called from within | 41 // Implementations guarantee that the callback will not be called from within |
41 // this method. | 42 // this method. |
42 // | 43 // |
43 // If the returned status is not kOk, some error has occurred in the video | 44 // If the returned status is not kOk, some error has occurred in the video |
44 // decoder. In this case, the returned frame should always be NULL. | 45 // decoder. In this case, the returned frame should always be NULL. |
45 // | 46 // |
46 // Otherwise, the video decoder is in good shape. In this case, Non-NULL | 47 // Otherwise, the video decoder is in good shape. In this case, Non-NULL |
47 // frames contain decoded video data or may indicate the end of the stream. | 48 // frames contain decoded video data or may indicate the end of the stream. |
48 // NULL video frames indicate an aborted read. This can happen if the | 49 // NULL video frames indicate an aborted read. This can happen if the |
49 // DemuxerStream gets flushed and doesn't have any more data to return. | 50 // DemuxerStream gets flushed and doesn't have any more data to return. |
50 typedef base::Callback<void(Status, const scoped_refptr<VideoFrame>&)> ReadCB; | 51 typedef base::Callback<void(Status, const scoped_refptr<VideoFrame>&)> ReadCB; |
51 virtual void Read(const ReadCB& read_cb) = 0; | 52 virtual void Read(const ReadCB& read_cb) = 0; |
52 | 53 |
53 // Resets decoder state, fulfilling all pending ReadCB and dropping extra | 54 // Resets decoder state, fulfilling all pending ReadCB and dropping extra |
54 // queued decoded data. After this call, the decoder is back to an initialized | 55 // queued decoded data. After this call, the decoder is back to an initialized |
55 // clean state. | 56 // clean state. |
| 57 // Note: No VideoDecoder calls should be made before |closure| is executed. |
56 virtual void Reset(const base::Closure& closure) = 0; | 58 virtual void Reset(const base::Closure& closure) = 0; |
57 | 59 |
58 // Stops decoder, fires any pending callbacks and sets the decoder to an | 60 // Stops decoder, fires any pending callbacks and sets the decoder to an |
59 // uninitialized state. A VideoDecoder cannot be re-initialized after it has | 61 // uninitialized state. A VideoDecoder cannot be re-initialized after it has |
60 // been stopped. | 62 // been stopped. |
61 // Note that if Initialize() has been called, Stop() must be called and | 63 // Note that if Initialize() has been called, Stop() must be called and |
62 // complete before deleting the decoder. | 64 // complete before deleting the decoder. |
63 virtual void Stop(const base::Closure& closure) = 0; | 65 virtual void Stop(const base::Closure& closure) = 0; |
64 | 66 |
65 // Returns true if the output format has an alpha channel. Most formats do not | 67 // Returns true if the output format has an alpha channel. Most formats do not |
66 // have alpha so the default is false. Override and return true for decoders | 68 // have alpha so the default is false. Override and return true for decoders |
67 // that return formats with an alpha channel. | 69 // that return formats with an alpha channel. |
68 virtual bool HasAlpha() const; | 70 virtual bool HasAlpha() const; |
69 | 71 |
70 protected: | 72 protected: |
71 friend class base::RefCountedThreadSafe<VideoDecoder>; | 73 friend class base::RefCountedThreadSafe<VideoDecoder>; |
72 virtual ~VideoDecoder(); | 74 virtual ~VideoDecoder(); |
73 VideoDecoder(); | 75 VideoDecoder(); |
74 | 76 |
75 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); | 77 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); |
76 }; | 78 }; |
77 | 79 |
78 } // namespace media | 80 } // namespace media |
79 | 81 |
80 #endif // MEDIA_BASE_VIDEO_DECODER_H_ | 82 #endif // MEDIA_BASE_VIDEO_DECODER_H_ |
OLD | NEW |