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

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

Issue 395703002: Fold {Audio|Video}Decoder::Stop() into the dtor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 6 years, 5 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
« no previous file with comments | « media/base/mock_filters.h ('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 "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/media_export.h" 10 #include "media/base/media_export.h"
(...skipping 21 matching lines...) Expand all
32 // Callback for VideoDecoder to return a decoded frame whenever it becomes 32 // Callback for VideoDecoder to return a decoded frame whenever it becomes
33 // available. Only non-EOS frames should be returned via this callback. 33 // available. Only non-EOS frames should be returned via this callback.
34 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> OutputCB; 34 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> OutputCB;
35 35
36 // Callback type for Decode(). Called after the decoder has completed decoding 36 // Callback type for Decode(). Called after the decoder has completed decoding
37 // corresponding DecoderBuffer, indicating that it's ready to accept another 37 // corresponding DecoderBuffer, indicating that it's ready to accept another
38 // buffer to decode. 38 // buffer to decode.
39 typedef base::Callback<void(Status status)> DecodeCB; 39 typedef base::Callback<void(Status status)> DecodeCB;
40 40
41 VideoDecoder(); 41 VideoDecoder();
42
43 // Fires any pending callbacks, stops and destroys the decoder.
44 // Note: Since this is a destructor, |this| will be destroyed after this call.
45 // Make sure the callbacks fired from this call doesn't post any task that
46 // depends on |this|.
42 virtual ~VideoDecoder(); 47 virtual ~VideoDecoder();
43 48
44 // Initializes a VideoDecoder with the given |config|, executing the 49 // Initializes a VideoDecoder with the given |config|, executing the
45 // |status_cb| upon completion. |output_cb| is called for each output frame 50 // |status_cb| upon completion. |output_cb| is called for each output frame
46 // decoded by Decode(). 51 // decoded by Decode().
47 // 52 //
48 // Note: 53 // Note:
49 // 1) The VideoDecoder will be reinitialized if it was initialized before. 54 // 1) The VideoDecoder will be reinitialized if it was initialized before.
50 // Upon reinitialization, all internal buffered frames will be dropped. 55 // Upon reinitialization, all internal buffered frames will be dropped.
51 // 2) This method should not be called during pending decode, reset or stop. 56 // 2) This method should not be called during pending decode or reset.
52 // 3) No VideoDecoder calls except for Stop() should be made before 57 // 3) No VideoDecoder calls should be made before |status_cb| is executed.
53 // |status_cb| is executed.
54 virtual void Initialize(const VideoDecoderConfig& config, 58 virtual void Initialize(const VideoDecoderConfig& config,
55 bool low_delay, 59 bool low_delay,
56 const PipelineStatusCB& status_cb, 60 const PipelineStatusCB& status_cb,
57 const OutputCB& output_cb) = 0; 61 const OutputCB& output_cb) = 0;
58 62
59 // Requests a |buffer| to be decoded. The status of the decoder and decoded 63 // Requests a |buffer| to be decoded. The status of the decoder and decoded
60 // frame are returned via the provided callback. Some decoders may allow 64 // frame are returned via the provided callback. Some decoders may allow
61 // decoding multiple buffers in parallel. Callers should call 65 // decoding multiple buffers in parallel. Callers should call
62 // GetMaxDecodeRequests() to get number of buffers that may be decoded in 66 // GetMaxDecodeRequests() to get number of buffers that may be decoded in
63 // parallel. Decoder must call |decode_cb| in the same order in which Decode() 67 // parallel. Decoder must call |decode_cb| in the same order in which Decode()
(...skipping 12 matching lines...) Expand all
76 // |output_cb| must be called for each frame pending in the queue and 80 // |output_cb| must be called for each frame pending in the queue and
77 // |decode_cb| must be called after that. 81 // |decode_cb| must be called after that.
78 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 82 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
79 const DecodeCB& decode_cb) = 0; 83 const DecodeCB& decode_cb) = 0;
80 84
81 // Resets decoder state. All pending Decode() requests will be finished or 85 // Resets decoder state. All pending Decode() requests will be finished or
82 // aborted before |closure| is called. 86 // aborted before |closure| is called.
83 // Note: No VideoDecoder calls should be made before |closure| is executed. 87 // Note: No VideoDecoder calls should be made before |closure| is executed.
84 virtual void Reset(const base::Closure& closure) = 0; 88 virtual void Reset(const base::Closure& closure) = 0;
85 89
86 // Stops decoder, fires any pending callbacks and sets the decoder to an
87 // uninitialized state. A VideoDecoder cannot be re-initialized after it has
88 // been stopped.
89 // Note that if Initialize() is pending or has finished successfully, Stop()
90 // must be called before destructing the decoder.
91 virtual void Stop() = 0;
92
93 // Returns true if the decoder needs bitstream conversion before decoding. 90 // Returns true if the decoder needs bitstream conversion before decoding.
94 virtual bool NeedsBitstreamConversion() const; 91 virtual bool NeedsBitstreamConversion() const;
95 92
96 // Returns true if the decoder currently has the ability to decode and return 93 // Returns true if the decoder currently has the ability to decode and return
97 // a VideoFrame. Most implementations can allocate a new VideoFrame and hence 94 // a VideoFrame. Most implementations can allocate a new VideoFrame and hence
98 // this will always return true. Override and return false for decoders that 95 // this will always return true. Override and return false for decoders that
99 // use a fixed set of VideoFrames for decoding. 96 // use a fixed set of VideoFrames for decoding.
100 virtual bool CanReadWithoutStalling() const; 97 virtual bool CanReadWithoutStalling() const;
101 98
102 // Returns maximum number of parallel decode requests. 99 // Returns maximum number of parallel decode requests.
103 virtual int GetMaxDecodeRequests() const; 100 virtual int GetMaxDecodeRequests() const;
104 101
105 private: 102 private:
106 DISALLOW_COPY_AND_ASSIGN(VideoDecoder); 103 DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
107 }; 104 };
108 105
109 } // namespace media 106 } // namespace media
110 107
111 #endif // MEDIA_BASE_VIDEO_DECODER_H_ 108 #endif // MEDIA_BASE_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/base/mock_filters.h ('k') | media/filters/audio_decoder_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698