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

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

Issue 16274005: Separate DemuxerStream and VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win64 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/video_decoder_selector.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 <list>
9
10 #include "base/basictypes.h" 8 #include "base/basictypes.h"
11 #include "base/callback.h" 9 #include "base/callback.h"
12 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
15 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
16 #include "media/base/decryptor.h" 14 #include "media/base/decryptor.h"
17 #include "media/base/demuxer_stream.h" 15 #include "media/base/demuxer_stream.h"
18 #include "media/base/media_export.h" 16 #include "media/base/media_export.h"
19 #include "media/base/pipeline_status.h" 17 #include "media/base/pipeline_status.h"
20 #include "media/base/video_decoder.h" 18 #include "media/base/video_decoder.h"
21 19
22 namespace base { 20 namespace base {
23 class MessageLoopProxy; 21 class MessageLoopProxy;
24 } 22 }
25 23
26 namespace media { 24 namespace media {
27 25
28 class DecryptingDemuxerStream; 26 class DecryptingDemuxerStream;
29 class VideoDecoderSelector; 27 class VideoDecoderSelector;
30 28
31 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded 29 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded
32 // VideoFrames to its client (e.g. VideoRendererBase). 30 // VideoFrames to its client (e.g. VideoRendererBase).
33 class MEDIA_EXPORT VideoFrameStream : public DemuxerStream { 31 class MEDIA_EXPORT VideoFrameStream {
34 public: 32 public:
35 // Indicates completion of VideoFrameStream initialization. 33 // Indicates completion of VideoFrameStream initialization.
36 typedef base::Callback<void(bool success, bool has_alpha)> InitCB; 34 typedef base::Callback<void(bool success, bool has_alpha)> InitCB;
37 35
38 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop, 36 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop,
39 ScopedVector<VideoDecoder> decoders, 37 ScopedVector<VideoDecoder> decoders,
40 const SetDecryptorReadyCB& set_decryptor_ready_cb); 38 const SetDecryptorReadyCB& set_decryptor_ready_cb);
41 virtual ~VideoFrameStream(); 39 virtual ~VideoFrameStream();
42 40
43 // Initializes the VideoFrameStream and returns the initialization result 41 // Initializes the VideoFrameStream and returns the initialization result
44 // through |init_cb|. Note that |init_cb| is always called asynchronously. 42 // through |init_cb|. Note that |init_cb| is always called asynchronously.
45 void Initialize(DemuxerStream* stream, 43 void Initialize(DemuxerStream* stream,
46 const StatisticsCB& statistics_cb, 44 const StatisticsCB& statistics_cb,
47 const InitCB& init_cb); 45 const InitCB& init_cb);
48 46
49 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that 47 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that
50 // |read_cb| is always called asynchronously. This method should only be 48 // |read_cb| is always called asynchronously. This method should only be
51 // called after initialization has succeeded and must not be called during 49 // called after initialization has succeeded and must not be called during
52 // any pending Reset() and/or Stop(). 50 // any pending Reset() and/or Stop().
51 // TODO(xhwang): Rename this back to Read().
53 void ReadFrame(const VideoDecoder::ReadCB& read_cb); 52 void ReadFrame(const VideoDecoder::ReadCB& read_cb);
54 53
55 // Resets the decoder, flushes all decoded frames and/or internal buffers, 54 // Resets the decoder, flushes all decoded frames and/or internal buffers,
56 // fires any existing pending read callback and calls |closure| on completion. 55 // fires any existing pending read callback and calls |closure| on completion.
57 // Note that |closure| is always called asynchronously. This method should 56 // Note that |closure| is always called asynchronously. This method should
58 // only be called after initialization has succeeded and must not be called 57 // only be called after initialization has succeeded and must not be called
59 // during any pending Reset() and/or Stop(). 58 // during any pending Reset() and/or Stop().
60 void Reset(const base::Closure& closure); 59 void Reset(const base::Closure& closure);
61 60
62 // Stops the decoder, fires any existing pending read callback or reset 61 // Stops the decoder, fires any existing pending read callback or reset
63 // callback and calls |closure| on completion. Note that |closure| is always 62 // callback and calls |closure| on completion. Note that |closure| is always
64 // called asynchronously. The VideoFrameStream cannot be used anymore after 63 // called asynchronously. The VideoFrameStream cannot be used anymore after
65 // it is stopped. This method can be called at any time but not during another 64 // it is stopped. This method can be called at any time but not during another
66 // pending Stop(). 65 // pending Stop().
67 void Stop(const base::Closure& closure); 66 void Stop(const base::Closure& closure);
68 67
69 // Returns true if the decoder currently has the ability to decode and return 68 // Returns true if the decoder currently has the ability to decode and return
70 // a VideoFrame. 69 // a VideoFrame.
71 bool CanReadWithoutStalling() const; 70 bool CanReadWithoutStalling() const;
72 71
73 // DemuxerStream implementation.
74 virtual void Read(const ReadCB& read_cb) OVERRIDE;
75 virtual AudioDecoderConfig audio_decoder_config() OVERRIDE;
76 virtual VideoDecoderConfig video_decoder_config() OVERRIDE;
77 virtual Type type() OVERRIDE;
78 virtual void EnableBitstreamConverter() OVERRIDE;
79
80 private: 72 private:
81 enum State { 73 enum State {
82 STATE_UNINITIALIZED, 74 STATE_UNINITIALIZED,
83 STATE_INITIALIZING, 75 STATE_INITIALIZING,
84 STATE_NORMAL, 76 STATE_NORMAL, // Includes idle, pending decoder decode/reset/stop.
85 STATE_FLUSHING_DECODER, 77 STATE_FLUSHING_DECODER,
78 STATE_PENDING_DEMUXER_READ,
86 STATE_REINITIALIZING_DECODER, 79 STATE_REINITIALIZING_DECODER,
87 STATE_STOPPED, 80 STATE_STOPPED,
88 STATE_ERROR 81 STATE_ERROR
89 }; 82 };
90 83
91 // Called when |decoder_selector| selected the |selected_decoder|. 84 // Called when |decoder_selector| selected the |selected_decoder|.
92 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream 85 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream
93 // is created to help decrypt the encrypted stream. 86 // is created to help decrypt the encrypted stream.
94 void OnDecoderSelected( 87 void OnDecoderSelected(
95 scoped_ptr<VideoDecoder> selected_decoder, 88 scoped_ptr<VideoDecoder> selected_decoder,
96 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); 89 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream);
97 90
98 // Callback for VideoDecoder::Read(). 91 // Satisfy pending |read_cb_| with |status| and |frame|.
92 void SatisfyRead(VideoDecoder::Status status,
93 const scoped_refptr<VideoFrame>& frame);
94
95 // Abort pending |read_cb_|.
96 void AbortRead();
97
98 // Decodes |buffer| and returns the result via OnFrameReady().
99 void Decode(const scoped_refptr<DecoderBuffer>& buffer);
100
101 // Flushes the decoder with an EOS buffer to retrieve internally buffered
102 // video frames.
103 void FlushDecoder();
104
105 // Callback for VideoDecoder::Decode().
99 void OnFrameReady(const VideoDecoder::Status status, 106 void OnFrameReady(const VideoDecoder::Status status,
100 const scoped_refptr<VideoFrame>& frame); 107 const scoped_refptr<VideoFrame>& frame);
101 108
109 // Reads a buffer from |stream_| and returns the result via OnBufferReady().
110 void ReadFromDemuxerStream();
111
102 // Callback for DemuxerStream::Read(). 112 // Callback for DemuxerStream::Read().
103 void OnBufferReady(const DemuxerStream::ReadCB& demuxer_read_cb, 113 void OnBufferReady(DemuxerStream::Status status,
104 DemuxerStream::Status status,
105 const scoped_refptr<DecoderBuffer>& buffer); 114 const scoped_refptr<DecoderBuffer>& buffer);
106 115
107 void ReinitializeDecoder(); 116 void ReinitializeDecoder();
108 117
109 // Callback for VideoDecoder reinitialization. 118 // Callback for VideoDecoder reinitialization.
110 void OnDecoderReinitialized(PipelineStatus status); 119 void OnDecoderReinitialized(PipelineStatus status);
111 120
112 void ResetDecoder(); 121 void ResetDecoder();
113 void OnDecoderReset(); 122 void OnDecoderReset();
114 123
(...skipping 20 matching lines...) Expand all
135 // These two will be set by VideoDecoderSelector::SelectVideoDecoder(). 144 // These two will be set by VideoDecoderSelector::SelectVideoDecoder().
136 scoped_ptr<VideoDecoder> decoder_; 145 scoped_ptr<VideoDecoder> decoder_;
137 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; 146 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
138 147
139 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream); 148 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream);
140 }; 149 };
141 150
142 } // namespace media 151 } // namespace media
143 152
144 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ 153 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
OLDNEW
« no previous file with comments | « media/filters/video_decoder_selector.cc ('k') | media/filters/video_frame_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698