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

Side by Side Diff: media/filters/video_frame_stream.h

Issue 20136002: Reland r212023 "Rename VideoDecoder::ReadCB to VideoDecoder::DecodeCB." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix content_browsertests failure. Created 7 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/filters/gpu_video_decoder.cc ('k') | media/filters/video_frame_stream.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_FILTERS_VIDEO_FRAME_STREAM_H_ 5 #ifndef MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
6 #define MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ 6 #define MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 15 matching lines...) Expand all
26 class DecryptingDemuxerStream; 26 class DecryptingDemuxerStream;
27 class VideoDecoderSelector; 27 class VideoDecoderSelector;
28 28
29 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded 29 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded
30 // VideoFrames to its client (e.g. VideoRendererBase). 30 // VideoFrames to its client (e.g. VideoRendererBase).
31 class MEDIA_EXPORT VideoFrameStream { 31 class MEDIA_EXPORT VideoFrameStream {
32 public: 32 public:
33 // Indicates completion of VideoFrameStream initialization. 33 // Indicates completion of VideoFrameStream initialization.
34 typedef base::Callback<void(bool success, bool has_alpha)> InitCB; 34 typedef base::Callback<void(bool success, bool has_alpha)> InitCB;
35 35
36 enum Status {
37 OK, // Everything went as planned.
38 ABORTED, // Read aborted due to Reset() during pending read.
39 DEMUXER_READ_ABORTED, // Demuxer returned aborted read.
40 DECODE_ERROR, // Decoder returned decode error.
41 DECRYPT_ERROR // Decoder returned decrypt error.
42 };
43
44 // Indicates completion of a VideoFrameStream read.
45 typedef base::Callback<void(Status, const scoped_refptr<VideoFrame>&)> ReadCB;
46
36 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop, 47 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop,
37 ScopedVector<VideoDecoder> decoders, 48 ScopedVector<VideoDecoder> decoders,
38 const SetDecryptorReadyCB& set_decryptor_ready_cb); 49 const SetDecryptorReadyCB& set_decryptor_ready_cb);
39 virtual ~VideoFrameStream(); 50 virtual ~VideoFrameStream();
40 51
41 // Initializes the VideoFrameStream and returns the initialization result 52 // Initializes the VideoFrameStream and returns the initialization result
42 // through |init_cb|. Note that |init_cb| is always called asynchronously. 53 // through |init_cb|. Note that |init_cb| is always called asynchronously.
43 void Initialize(DemuxerStream* stream, 54 void Initialize(DemuxerStream* stream,
44 const StatisticsCB& statistics_cb, 55 const StatisticsCB& statistics_cb,
45 const InitCB& init_cb); 56 const InitCB& init_cb);
46 57
47 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that 58 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that
48 // |read_cb| is always called asynchronously. This method should only be 59 // |read_cb| is always called asynchronously. This method should only be
49 // called after initialization has succeeded and must not be called during 60 // called after initialization has succeeded and must not be called during
50 // any pending Reset() and/or Stop(). 61 // any pending Reset() and/or Stop().
51 void Read(const VideoDecoder::ReadCB& read_cb); 62 void Read(const ReadCB& read_cb);
52 63
53 // Resets the decoder, flushes all decoded frames and/or internal buffers, 64 // Resets the decoder, flushes all decoded frames and/or internal buffers,
54 // fires any existing pending read callback and calls |closure| on completion. 65 // fires any existing pending read callback and calls |closure| on completion.
55 // Note that |closure| is always called asynchronously. This method should 66 // Note that |closure| is always called asynchronously. This method should
56 // only be called after initialization has succeeded and must not be called 67 // only be called after initialization has succeeded and must not be called
57 // during any pending Reset() and/or Stop(). 68 // during any pending Reset() and/or Stop().
58 void Reset(const base::Closure& closure); 69 void Reset(const base::Closure& closure);
59 70
60 // Stops the decoder, fires any existing pending read callback or reset 71 // Stops the decoder, fires any existing pending read callback or reset
61 // callback and calls |closure| on completion. Note that |closure| is always 72 // callback and calls |closure| on completion. Note that |closure| is always
(...skipping 19 matching lines...) Expand all
81 }; 92 };
82 93
83 // Called when |decoder_selector| selected the |selected_decoder|. 94 // Called when |decoder_selector| selected the |selected_decoder|.
84 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream 95 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream
85 // is created to help decrypt the encrypted stream. 96 // is created to help decrypt the encrypted stream.
86 void OnDecoderSelected( 97 void OnDecoderSelected(
87 scoped_ptr<VideoDecoder> selected_decoder, 98 scoped_ptr<VideoDecoder> selected_decoder,
88 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); 99 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream);
89 100
90 // Satisfy pending |read_cb_| with |status| and |frame|. 101 // Satisfy pending |read_cb_| with |status| and |frame|.
91 void SatisfyRead(VideoDecoder::Status status, 102 void SatisfyRead(Status status, const scoped_refptr<VideoFrame>& frame);
92 const scoped_refptr<VideoFrame>& frame);
93 103
94 // Abort pending |read_cb_|. 104 // Abort pending |read_cb_|.
95 void AbortRead(); 105 void AbortRead();
96 106
97 // Decodes |buffer| and returns the result via OnFrameReady(). 107 // Decodes |buffer| and returns the result via OnFrameReady().
98 void Decode(const scoped_refptr<DecoderBuffer>& buffer); 108 void Decode(const scoped_refptr<DecoderBuffer>& buffer);
99 109
100 // Flushes the decoder with an EOS buffer to retrieve internally buffered 110 // Flushes the decoder with an EOS buffer to retrieve internally buffered
101 // video frames. 111 // video frames.
102 void FlushDecoder(); 112 void FlushDecoder();
(...skipping 23 matching lines...) Expand all
126 136
127 scoped_refptr<base::MessageLoopProxy> message_loop_; 137 scoped_refptr<base::MessageLoopProxy> message_loop_;
128 base::WeakPtrFactory<VideoFrameStream> weak_factory_; 138 base::WeakPtrFactory<VideoFrameStream> weak_factory_;
129 base::WeakPtr<VideoFrameStream> weak_this_; 139 base::WeakPtr<VideoFrameStream> weak_this_;
130 140
131 State state_; 141 State state_;
132 142
133 StatisticsCB statistics_cb_; 143 StatisticsCB statistics_cb_;
134 InitCB init_cb_; 144 InitCB init_cb_;
135 145
136 VideoDecoder::ReadCB read_cb_; 146 ReadCB read_cb_;
137 base::Closure reset_cb_; 147 base::Closure reset_cb_;
138 base::Closure stop_cb_; 148 base::Closure stop_cb_;
139 149
140 DemuxerStream* stream_; 150 DemuxerStream* stream_;
141 151
142 scoped_ptr<VideoDecoderSelector> decoder_selector_; 152 scoped_ptr<VideoDecoderSelector> decoder_selector_;
143 153
144 // These two will be set by VideoDecoderSelector::SelectVideoDecoder(). 154 // These two will be set by VideoDecoderSelector::SelectVideoDecoder().
145 scoped_ptr<VideoDecoder> decoder_; 155 scoped_ptr<VideoDecoder> decoder_;
146 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; 156 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
147 157
148 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream); 158 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream);
149 }; 159 };
150 160
151 } // namespace media 161 } // namespace media
152 162
153 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ 163 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
OLDNEW
« no previous file with comments | « media/filters/gpu_video_decoder.cc ('k') | media/filters/video_frame_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698