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

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: resolve ddorwin's comments and have a question about force posting task! Created 8 years, 2 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 // 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 // Reset 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 // Stop decoder and set it to an uninitialized state. Note that a VideoDecoder 60 // Stops decoder and sets it to an uninitialized state. Note that a
59 // should/could not be re-initialized after it has been stopped. 61 // VideoDecoder cannot be re-initialized after it has been stopped.
62 // Note: No VideoDecoder calls should be made before |closure| is executed.
60 virtual void Stop(const base::Closure& closure) = 0; 63 virtual void Stop(const base::Closure& closure) = 0;
61 64
62 // Returns true if the output format has an alpha channel. Most formats do not 65 // 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 66 // have alpha so the default is false. Override and return true for decoders
64 // that return formats with an alpha channel. 67 // that return formats with an alpha channel.
65 virtual bool HasAlpha() const; 68 virtual bool HasAlpha() const;
66 69
67 protected: 70 protected:
68 friend class base::RefCountedThreadSafe<VideoDecoder>; 71 friend class base::RefCountedThreadSafe<VideoDecoder>;
69 virtual ~VideoDecoder(); 72 virtual ~VideoDecoder();
70 VideoDecoder(); 73 VideoDecoder();
71 74
72 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); 75 DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
73 }; 76 };
74 77
75 } // namespace media 78 } // namespace media
76 79
77 #endif // MEDIA_BASE_VIDEO_DECODER_H_ 80 #endif // MEDIA_BASE_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698