Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: media/base/video_decoder.h

Issue 10969028: Add video decoding methods in Decryptor and add DecryptingVideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "media/base/media_export.h" 11 #include "media/base/media_export.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 DemuxerStream; 16 class DemuxerStream;
17 class VideoFrame; 17 class VideoFrame;
18 18
19 class MEDIA_EXPORT VideoDecoder 19 class MEDIA_EXPORT VideoDecoder
20 : public base::RefCountedThreadSafe<VideoDecoder> { 20 : public base::RefCountedThreadSafe<VideoDecoder> {
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 // Initialize a VideoDecoder with the given DemuxerStream, executing the 29 // Initializes a VideoDecoder with the given DemuxerStream, executing the
30 // callback 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 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, 32 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
33 const PipelineStatusCB& status_cb, 33 const PipelineStatusCB& status_cb,
34 const StatisticsCB& statistics_cb) = 0; 34 const StatisticsCB& statistics_cb) = 0;
35 35
36 // Requests a frame to be decoded. The status of the decoder and decoded frame 36 // 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 37 // are returned via the provided callback. Only one read may be in flight at
38 // any given time. 38 // any given time.
39 // 39 //
40 // Implementations guarantee that the callback will not be called from within 40 // Implementations guarantee that the callback will not be called from within
41 // this method. 41 // this method.
42 // 42 //
43 // If the returned status is not kOk, some error has occurred in the video 43 // 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. 44 // decoder. In this case, the returned frame should always be NULL.
45 // 45 //
46 // Otherwise, the video decoder is in good shape. In this case, Non-NULL 46 // 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. 47 // 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 48 // 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. 49 // DemuxerStream gets flushed and doesn't have any more data to return.
50 typedef base::Callback<void(Status, const scoped_refptr<VideoFrame>&)> ReadCB; 50 typedef base::Callback<void(Status, const scoped_refptr<VideoFrame>&)> ReadCB;
51 virtual void Read(const ReadCB& read_cb) = 0; 51 virtual void Read(const ReadCB& read_cb) = 0;
52 52
53 // Reset decoder state, fulfilling all pending ReadCB and dropping extra 53 // Resets decoder state, fulfilling all pending ReadCB and dropping extra
54 // queued decoded data. After this call, the decoder is back to an initialized 54 // queued decoded data. After this call, the decoder is back to an initialized
55 // clean state. 55 // clean state.
56 virtual void Reset(const base::Closure& closure) = 0; 56 virtual void Reset(const base::Closure& closure) = 0;
57 57
58 // Stop decoder and set it to an uninitialized state. Note that a VideoDecoder 58 // Stops decoder and sets it to an uninitialized state. Note that a
59 // should/could not be re-initialized after it has been stopped. 59 // VideoDecoder cannot be re-initialized after it has been stopped.
60 virtual void Stop(const base::Closure& closure) = 0; 60 virtual void Stop(const base::Closure& closure) = 0;
61 61
62 // Returns true if the output format has an alpha channel. Most formats do not 62 // Returns true if the output format has an alpha channel. Most formats do not
63 // have alpha so the default is false. Override and return true for decoders 63 // have alpha so the default is false. Override and return true for decoders
64 // that return formats with an alpha channel. 64 // that return formats with an alpha channel.
65 virtual bool HasAlpha() const; 65 virtual bool HasAlpha() const;
66 66
67 protected: 67 protected:
68 friend class base::RefCountedThreadSafe<VideoDecoder>; 68 friend class base::RefCountedThreadSafe<VideoDecoder>;
69 virtual ~VideoDecoder(); 69 virtual ~VideoDecoder();
70 VideoDecoder(); 70 VideoDecoder();
71 71
72 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); 72 DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
73 }; 73 };
74 74
75 } // namespace media 75 } // namespace media
76 76
77 #endif // MEDIA_BASE_VIDEO_DECODER_H_ 77 #endif // MEDIA_BASE_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698