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

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

Issue 12818004: Introduce VideoFrameStream, the video frame provider in media pipeline. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Prettier name for test. Created 7 years, 9 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 | « no previous file | 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
6 #define MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
7
8 #include <list>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14 #include "media/base/decryptor.h"
15 #include "media/base/media_export.h"
16 #include "media/base/pipeline_status.h"
17 #include "media/base/video_decoder.h"
18
19 namespace base {
20 class MessageLoopProxy;
21 }
22
23 namespace media {
24
25 class DecryptingDemuxerStream;
26 class DemuxerStream;
27 class VideoDecoderSelector;
28
29 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded
30 // VideoFrames to its client (e.g. VideoRendererBase).
31 class MEDIA_EXPORT VideoFrameStream {
32 public:
33 typedef std::list<scoped_refptr<VideoDecoder> > VideoDecoderList;
34
35 // Indicates completion of VideoFrameStream initialization.
36 typedef base::Callback<void(bool success, bool has_alpha)> InitCB;
37
38 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop,
39 const SetDecryptorReadyCB& set_decryptor_ready_cb);
40
41 ~VideoFrameStream();
42
43 // Initializes the VideoFrameStream and returns the initialization result
44 // through |init_cb|. Note that |init_cb| is always called asynchronously.
45 void Initialize(const scoped_refptr<DemuxerStream>& stream,
46 const VideoDecoderList& decoders,
47 const StatisticsCB& statistics_cb,
48 const InitCB& init_cb);
49
50 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that
51 // |read_cb| is always called asynchronously. This method should only be
52 // called after initialization has succeeded and must not be called during
53 // any pending Reset() and/or Stop().
54 void ReadFrame(const VideoDecoder::ReadCB& read_cb);
55
56 // Resets the decoder, flushes all decoded frames and/or internal buffers,
57 // fires any existing pending read callback and calls |closure| on completion.
58 // Note that |closure| is always called asynchronously. This method should
59 // only be called after initialization has succeeded and must not be called
60 // during any pending Reset() and/or Stop().
61 void Reset(const base::Closure& closure);
62
63 // Stops the decoder, fires any existing pending read callback or reset
64 // callback and calls |closure| on completion. Note that |closure| is always
65 // called asynchronously. The VideoFrameStream cannot be used anymore after
66 // it is stopped. This method can be called at any time but not during another
67 // pending Stop().
68 void Stop(const base::Closure& closure);
69
70 // Returns true if the decoder currently has the ability to decode and return
71 // a VideoFrame.
72 bool HasOutputFrameAvailable() const;
73
74 private:
75 enum State {
76 UNINITIALIZED,
77 NORMAL,
78 STOPPED
79 };
80
81 // Called when |decoder_selector_| selected the |selected_decoder|.
82 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream
83 // is created to help decrypt the encrypted stream.
84 // Note: |decoder_selector| is passed here to keep the VideoDecoderSelector
85 // alive until OnDecoderSelected() finishes.
86 void OnDecoderSelected(
87 scoped_ptr<VideoDecoderSelector> decoder_selector,
88 const scoped_refptr<VideoDecoder>& selected_decoder,
89 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream);
90
91 // Callback for VideoDecoder::Read().
92 void OnFrameRead(const VideoDecoder::Status status,
93 const scoped_refptr<VideoFrame>& frame);
94
95 void ResetDecoder();
96 void OnDecoderReset();
97
98 void StopDecoder();
99 void OnDecoderStopped();
100
101 scoped_refptr<base::MessageLoopProxy> message_loop_;
102 base::WeakPtrFactory<VideoFrameStream> weak_factory_;
103 base::WeakPtr<VideoFrameStream> weak_this_;
104
105 State state_;
106
107 InitCB init_cb_;
108 VideoDecoder::ReadCB read_cb_;
109 base::Closure reset_cb_;
110 base::Closure stop_cb_;
111
112 SetDecryptorReadyCB set_decryptor_ready_cb_;
113
114 // These two will be set by VideoDecoderSelector::SelectVideoDecoder().
115 scoped_refptr<VideoDecoder> decoder_;
116 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
117
118 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream);
119 };
120
121 } // namespace media
122
123 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | media/filters/video_frame_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698