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

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

Issue 1143223007: media: Reland "Simplify {Audio|Video}Decoder initialization callback." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « media/base/test_helpers.cc ('k') | media/cast/sender/h264_vt_encoder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
13 #include "media/base/pipeline_status.h" 13 #include "media/base/pipeline_status.h"
14 #include "ui/gfx/geometry/size.h" 14 #include "ui/gfx/geometry/size.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 class DecoderBuffer; 18 class DecoderBuffer;
19 class VideoDecoderConfig; 19 class VideoDecoderConfig;
20 class VideoFrame; 20 class VideoFrame;
21 21
22 class MEDIA_EXPORT VideoDecoder { 22 class MEDIA_EXPORT VideoDecoder {
23 public: 23 public:
24 // Status codes for decode operations on VideoDecoder. 24 // Status codes for decode operations on VideoDecoder.
25 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums 25 // TODO(rileya): Now that both AudioDecoder and VideoDecoder Status enums
26 // match, break them into a decoder_status.h. 26 // match, break them into a decoder_status.h.
27 enum Status { 27 enum Status {
28 kOk, // Everything went as planned. 28 kOk, // Everything went as planned.
29 kAborted, // Decode was aborted as a result of Reset() being called. 29 kAborted, // Decode was aborted as a result of Reset() being called.
30 kDecodeError // Decoding error happened. 30 kDecodeError // Decoding error happened.
31 }; 31 };
32 32
33 // Callback for VideoDecoder initialization.
34 typedef base::Callback<void(bool success)> InitCB;
35
33 // Callback for VideoDecoder to return a decoded frame whenever it becomes 36 // Callback for VideoDecoder to return a decoded frame whenever it becomes
34 // available. Only non-EOS frames should be returned via this callback. 37 // available. Only non-EOS frames should be returned via this callback.
35 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> OutputCB; 38 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> OutputCB;
36 39
37 // Callback type for Decode(). Called after the decoder has completed decoding 40 // Callback type for Decode(). Called after the decoder has completed decoding
38 // corresponding DecoderBuffer, indicating that it's ready to accept another 41 // corresponding DecoderBuffer, indicating that it's ready to accept another
39 // buffer to decode. 42 // buffer to decode.
40 typedef base::Callback<void(Status status)> DecodeCB; 43 typedef base::Callback<void(Status status)> DecodeCB;
41 44
42 VideoDecoder(); 45 VideoDecoder();
43 46
44 // Fires any pending callbacks, stops and destroys the decoder. 47 // Fires any pending callbacks, stops and destroys the decoder.
45 // Note: Since this is a destructor, |this| will be destroyed after this call. 48 // Note: Since this is a destructor, |this| will be destroyed after this call.
46 // Make sure the callbacks fired from this call doesn't post any task that 49 // Make sure the callbacks fired from this call doesn't post any task that
47 // depends on |this|. 50 // depends on |this|.
48 virtual ~VideoDecoder(); 51 virtual ~VideoDecoder();
49 52
50 // Returns the name of the decoder for logging purpose. 53 // Returns the name of the decoder for logging purpose.
51 virtual std::string GetDisplayName() const = 0; 54 virtual std::string GetDisplayName() const = 0;
52 55
53 // Initializes a VideoDecoder with the given |config|, executing the 56 // Initializes a VideoDecoder with the given |config|, executing the
54 // |status_cb| upon completion. |output_cb| is called for each output frame 57 // |init_cb| upon completion. |output_cb| is called for each output frame
55 // decoded by Decode(). 58 // decoded by Decode().
56 // 59 //
57 // If |low_delay| is true then the decoder is not allowed to queue frames, 60 // If |low_delay| is true then the decoder is not allowed to queue frames,
58 // except for out-of-order frames, i.e. if the next frame can be returned it 61 // except for out-of-order frames, i.e. if the next frame can be returned it
59 // must be returned without waiting for Decode() to be called again. 62 // must be returned without waiting for Decode() to be called again.
60 // Initialization should fail if |low_delay| is true and the decoder cannot 63 // Initialization should fail if |low_delay| is true and the decoder cannot
61 // satisfy the requirements above. 64 // satisfy the requirements above.
62 // 65 //
63 // Note: 66 // Note:
64 // 1) The VideoDecoder will be reinitialized if it was initialized before. 67 // 1) The VideoDecoder will be reinitialized if it was initialized before.
65 // Upon reinitialization, all internal buffered frames will be dropped. 68 // Upon reinitialization, all internal buffered frames will be dropped.
66 // 2) This method should not be called during pending decode or reset. 69 // 2) This method should not be called during pending decode or reset.
67 // 3) No VideoDecoder calls should be made before |status_cb| is executed. 70 // 3) No VideoDecoder calls should be made before |init_cb| is executed.
68 virtual void Initialize(const VideoDecoderConfig& config, 71 virtual void Initialize(const VideoDecoderConfig& config,
69 bool low_delay, 72 bool low_delay,
70 const PipelineStatusCB& status_cb, 73 const InitCB& init_cb,
71 const OutputCB& output_cb) = 0; 74 const OutputCB& output_cb) = 0;
72 75
73 // Requests a |buffer| to be decoded. The status of the decoder and decoded 76 // Requests a |buffer| to be decoded. The status of the decoder and decoded
74 // frame are returned via the provided callback. Some decoders may allow 77 // frame are returned via the provided callback. Some decoders may allow
75 // decoding multiple buffers in parallel. Callers should call 78 // decoding multiple buffers in parallel. Callers should call
76 // GetMaxDecodeRequests() to get number of buffers that may be decoded in 79 // GetMaxDecodeRequests() to get number of buffers that may be decoded in
77 // parallel. Decoder must call |decode_cb| in the same order in which Decode() 80 // parallel. Decoder must call |decode_cb| in the same order in which Decode()
78 // is called. 81 // is called.
79 // 82 //
80 // Implementations guarantee that the callback will not be called from within 83 // Implementations guarantee that the callback will not be called from within
(...skipping 30 matching lines...) Expand all
111 // Returns maximum number of parallel decode requests. 114 // Returns maximum number of parallel decode requests.
112 virtual int GetMaxDecodeRequests() const; 115 virtual int GetMaxDecodeRequests() const;
113 116
114 private: 117 private:
115 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); 118 DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
116 }; 119 };
117 120
118 } // namespace media 121 } // namespace media
119 122
120 #endif // MEDIA_BASE_VIDEO_DECODER_H_ 123 #endif // MEDIA_BASE_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/test_helpers.cc ('k') | media/cast/sender/h264_vt_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698