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

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

Issue 1146913008: Revert of media: 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/filters/audio_decoder_selector_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
36 // Callback for VideoDecoder to return a decoded frame whenever it becomes 33 // Callback for VideoDecoder to return a decoded frame whenever it becomes
37 // available. Only non-EOS frames should be returned via this callback. 34 // available. Only non-EOS frames should be returned via this callback.
38 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> OutputCB; 35 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> OutputCB;
39 36
40 // Callback type for Decode(). Called after the decoder has completed decoding 37 // Callback type for Decode(). Called after the decoder has completed decoding
41 // corresponding DecoderBuffer, indicating that it's ready to accept another 38 // corresponding DecoderBuffer, indicating that it's ready to accept another
42 // buffer to decode. 39 // buffer to decode.
43 typedef base::Callback<void(Status status)> DecodeCB; 40 typedef base::Callback<void(Status status)> DecodeCB;
44 41
45 VideoDecoder(); 42 VideoDecoder();
46 43
47 // Fires any pending callbacks, stops and destroys the decoder. 44 // Fires any pending callbacks, stops and destroys the decoder.
48 // Note: Since this is a destructor, |this| will be destroyed after this call. 45 // Note: Since this is a destructor, |this| will be destroyed after this call.
49 // Make sure the callbacks fired from this call doesn't post any task that 46 // Make sure the callbacks fired from this call doesn't post any task that
50 // depends on |this|. 47 // depends on |this|.
51 virtual ~VideoDecoder(); 48 virtual ~VideoDecoder();
52 49
53 // Returns the name of the decoder for logging purpose. 50 // Returns the name of the decoder for logging purpose.
54 virtual std::string GetDisplayName() const = 0; 51 virtual std::string GetDisplayName() const = 0;
55 52
56 // Initializes a VideoDecoder with the given |config|, executing the 53 // Initializes a VideoDecoder with the given |config|, executing the
57 // |init_cb| upon completion. |output_cb| is called for each output frame 54 // |status_cb| upon completion. |output_cb| is called for each output frame
58 // decoded by Decode(). 55 // decoded by Decode().
59 // 56 //
60 // If |low_delay| is true then the decoder is not allowed to queue frames, 57 // If |low_delay| is true then the decoder is not allowed to queue frames,
61 // except for out-of-order frames, i.e. if the next frame can be returned it 58 // except for out-of-order frames, i.e. if the next frame can be returned it
62 // must be returned without waiting for Decode() to be called again. 59 // must be returned without waiting for Decode() to be called again.
63 // Initialization should fail if |low_delay| is true and the decoder cannot 60 // Initialization should fail if |low_delay| is true and the decoder cannot
64 // satisfy the requirements above. 61 // satisfy the requirements above.
65 // 62 //
66 // Note: 63 // Note:
67 // 1) The VideoDecoder will be reinitialized if it was initialized before. 64 // 1) The VideoDecoder will be reinitialized if it was initialized before.
68 // Upon reinitialization, all internal buffered frames will be dropped. 65 // Upon reinitialization, all internal buffered frames will be dropped.
69 // 2) This method should not be called during pending decode or reset. 66 // 2) This method should not be called during pending decode or reset.
70 // 3) No VideoDecoder calls should be made before |init_cb| is executed. 67 // 3) No VideoDecoder calls should be made before |status_cb| is executed.
71 virtual void Initialize(const VideoDecoderConfig& config, 68 virtual void Initialize(const VideoDecoderConfig& config,
72 bool low_delay, 69 bool low_delay,
73 const InitCB& init_cb, 70 const PipelineStatusCB& status_cb,
74 const OutputCB& output_cb) = 0; 71 const OutputCB& output_cb) = 0;
75 72
76 // Requests a |buffer| to be decoded. The status of the decoder and decoded 73 // Requests a |buffer| to be decoded. The status of the decoder and decoded
77 // frame are returned via the provided callback. Some decoders may allow 74 // frame are returned via the provided callback. Some decoders may allow
78 // decoding multiple buffers in parallel. Callers should call 75 // decoding multiple buffers in parallel. Callers should call
79 // GetMaxDecodeRequests() to get number of buffers that may be decoded in 76 // GetMaxDecodeRequests() to get number of buffers that may be decoded in
80 // parallel. Decoder must call |decode_cb| in the same order in which Decode() 77 // parallel. Decoder must call |decode_cb| in the same order in which Decode()
81 // is called. 78 // is called.
82 // 79 //
83 // Implementations guarantee that the callback will not be called from within 80 // Implementations guarantee that the callback will not be called from within
(...skipping 30 matching lines...) Expand all
114 // Returns maximum number of parallel decode requests. 111 // Returns maximum number of parallel decode requests.
115 virtual int GetMaxDecodeRequests() const; 112 virtual int GetMaxDecodeRequests() const;
116 113
117 private: 114 private:
118 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); 115 DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
119 }; 116 };
120 117
121 } // namespace media 118 } // namespace media
122 119
123 #endif // MEDIA_BASE_VIDEO_DECODER_H_ 120 #endif // MEDIA_BASE_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/test_helpers.cc ('k') | media/filters/audio_decoder_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698