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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/filters/video_frame_stream.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_frame_stream.h
diff --git a/media/filters/video_frame_stream.h b/media/filters/video_frame_stream.h
new file mode 100644
index 0000000000000000000000000000000000000000..1fe2a077b977b191042c2438e6927a4bbad74e71
--- /dev/null
+++ b/media/filters/video_frame_stream.h
@@ -0,0 +1,123 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
+#define MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
+
+#include <list>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "media/base/decryptor.h"
+#include "media/base/media_export.h"
+#include "media/base/pipeline_status.h"
+#include "media/base/video_decoder.h"
+
+namespace base {
+class MessageLoopProxy;
+}
+
+namespace media {
+
+class DecryptingDemuxerStream;
+class DemuxerStream;
+class VideoDecoderSelector;
+
+// Wraps a DemuxerStream and a list of VideoDecoders and provides decoded
+// VideoFrames to its client (e.g. VideoRendererBase).
+class MEDIA_EXPORT VideoFrameStream {
+ public:
+ typedef std::list<scoped_refptr<VideoDecoder> > VideoDecoderList;
+
+ // Indicates completion of VideoFrameStream initialization.
+ typedef base::Callback<void(bool success, bool has_alpha)> InitCB;
+
+ VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop,
+ const SetDecryptorReadyCB& set_decryptor_ready_cb);
+
+ ~VideoFrameStream();
+
+ // Initializes the VideoFrameStream and returns the initialization result
+ // through |init_cb|. Note that |init_cb| is always called asynchronously.
+ void Initialize(const scoped_refptr<DemuxerStream>& stream,
+ const VideoDecoderList& decoders,
+ const StatisticsCB& statistics_cb,
+ const InitCB& init_cb);
+
+ // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that
+ // |read_cb| is always called asynchronously. This method should only be
+ // called after initialization has succeeded and must not be called during
+ // any pending Reset() and/or Stop().
+ void ReadFrame(const VideoDecoder::ReadCB& read_cb);
+
+ // Resets the decoder, flushes all decoded frames and/or internal buffers,
+ // fires any existing pending read callback and calls |closure| on completion.
+ // Note that |closure| is always called asynchronously. This method should
+ // only be called after initialization has succeeded and must not be called
+ // during any pending Reset() and/or Stop().
+ void Reset(const base::Closure& closure);
+
+ // Stops the decoder, fires any existing pending read callback or reset
+ // callback and calls |closure| on completion. Note that |closure| is always
+ // called asynchronously. The VideoFrameStream cannot be used anymore after
+ // it is stopped. This method can be called at any time but not during another
+ // pending Stop().
+ void Stop(const base::Closure& closure);
+
+ // Returns true if the decoder currently has the ability to decode and return
+ // a VideoFrame.
+ bool HasOutputFrameAvailable() const;
+
+ private:
+ enum State {
+ UNINITIALIZED,
+ NORMAL,
+ STOPPED
+ };
+
+ // Called when |decoder_selector_| selected the |selected_decoder|.
+ // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream
+ // is created to help decrypt the encrypted stream.
+ // Note: |decoder_selector| is passed here to keep the VideoDecoderSelector
+ // alive until OnDecoderSelected() finishes.
+ void OnDecoderSelected(
+ scoped_ptr<VideoDecoderSelector> decoder_selector,
+ const scoped_refptr<VideoDecoder>& selected_decoder,
+ const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream);
+
+ // Callback for VideoDecoder::Read().
+ void OnFrameRead(const VideoDecoder::Status status,
+ const scoped_refptr<VideoFrame>& frame);
+
+ void ResetDecoder();
+ void OnDecoderReset();
+
+ void StopDecoder();
+ void OnDecoderStopped();
+
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
+ base::WeakPtrFactory<VideoFrameStream> weak_factory_;
+ base::WeakPtr<VideoFrameStream> weak_this_;
+
+ State state_;
+
+ InitCB init_cb_;
+ VideoDecoder::ReadCB read_cb_;
+ base::Closure reset_cb_;
+ base::Closure stop_cb_;
+
+ SetDecryptorReadyCB set_decryptor_ready_cb_;
+
+ // These two will be set by VideoDecoderSelector::SelectVideoDecoder().
+ scoped_refptr<VideoDecoder> decoder_;
+ scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoFrameStream);
+};
+
+} // namespace media
+
+#endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
« 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