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

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

Issue 14348007: Reland: Remove reference counting from media::VideoDecoder and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 8 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_unittest.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> 8 #include <list>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_vector.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "media/base/decryptor.h" 16 #include "media/base/decryptor.h"
16 #include "media/base/demuxer_stream.h" 17 #include "media/base/demuxer_stream.h"
17 #include "media/base/media_export.h" 18 #include "media/base/media_export.h"
18 #include "media/base/pipeline_status.h" 19 #include "media/base/pipeline_status.h"
19 #include "media/base/video_decoder.h" 20 #include "media/base/video_decoder.h"
21 #include "media/filters/video_decoder_selector.h"
20 22
21 namespace base { 23 namespace base {
22 class MessageLoopProxy; 24 class MessageLoopProxy;
23 } 25 }
24 26
25 namespace media { 27 namespace media {
26 28
27 class DecryptingDemuxerStream; 29 class DecryptingDemuxerStream;
28 class VideoDecoderSelector; 30 class VideoDecoderSelector;
29 31
30 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded 32 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded
31 // VideoFrames to its client (e.g. VideoRendererBase). 33 // VideoFrames to its client (e.g. VideoRendererBase).
32 class MEDIA_EXPORT VideoFrameStream : public DemuxerStream { 34 class MEDIA_EXPORT VideoFrameStream : public DemuxerStream {
33 public: 35 public:
34 typedef std::list<scoped_refptr<VideoDecoder> > VideoDecoderList;
35
36 // Indicates completion of VideoFrameStream initialization. 36 // Indicates completion of VideoFrameStream initialization.
37 typedef base::Callback<void(bool success, bool has_alpha)> InitCB; 37 typedef base::Callback<void(bool success, bool has_alpha)> InitCB;
38 38
39 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop, 39 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop,
40 ScopedVector<VideoDecoder> decoders,
40 const SetDecryptorReadyCB& set_decryptor_ready_cb); 41 const SetDecryptorReadyCB& set_decryptor_ready_cb);
41 42
42 // Initializes the VideoFrameStream and returns the initialization result 43 // Initializes the VideoFrameStream and returns the initialization result
43 // through |init_cb|. Note that |init_cb| is always called asynchronously. 44 // through |init_cb|. Note that |init_cb| is always called asynchronously.
44 void Initialize(const scoped_refptr<DemuxerStream>& stream, 45 void Initialize(const scoped_refptr<DemuxerStream>& stream,
45 const VideoDecoderList& decoders,
46 const StatisticsCB& statistics_cb, 46 const StatisticsCB& statistics_cb,
47 const InitCB& init_cb); 47 const InitCB& init_cb);
48 48
49 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that 49 // 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 50 // |read_cb| is always called asynchronously. This method should only be
51 // called after initialization has succeeded and must not be called during 51 // called after initialization has succeeded and must not be called during
52 // any pending Reset() and/or Stop(). 52 // any pending Reset() and/or Stop().
53 void ReadFrame(const VideoDecoder::ReadCB& read_cb); 53 void ReadFrame(const VideoDecoder::ReadCB& read_cb);
54 54
55 // Resets the decoder, flushes all decoded frames and/or internal buffers, 55 // Resets the decoder, flushes all decoded frames and/or internal buffers,
(...skipping 24 matching lines...) Expand all
80 protected: 80 protected:
81 virtual ~VideoFrameStream(); 81 virtual ~VideoFrameStream();
82 82
83 private: 83 private:
84 enum State { 84 enum State {
85 UNINITIALIZED, 85 UNINITIALIZED,
86 NORMAL, 86 NORMAL,
87 STOPPED 87 STOPPED
88 }; 88 };
89 89
90 // Called when |decoder_selector_| selected the |selected_decoder|. 90 // Called when |decoder_selector| selected the |selected_decoder|.
91 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream 91 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream
92 // is created to help decrypt the encrypted stream. 92 // is created to help decrypt the encrypted stream.
93 // Note: |decoder_selector| is passed here to keep the VideoDecoderSelector
94 // alive until OnDecoderSelected() finishes.
95 void OnDecoderSelected( 93 void OnDecoderSelected(
96 scoped_ptr<VideoDecoderSelector> decoder_selector, 94 scoped_ptr<VideoDecoderSelector> decoder_selector,
97 const scoped_refptr<VideoDecoder>& selected_decoder, 95 scoped_ptr<VideoDecoder> selected_decoder,
98 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream); 96 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream);
99 97
100 // Callback for VideoDecoder::Read(). 98 // Callback for VideoDecoder::Read().
101 void OnFrameRead(const VideoDecoder::Status status, 99 void OnFrameRead(const VideoDecoder::Status status,
102 const scoped_refptr<VideoFrame>& frame); 100 const scoped_refptr<VideoFrame>& frame);
103 101
104 void ResetDecoder(); 102 void ResetDecoder();
105 void OnDecoderReset(); 103 void OnDecoderReset();
106 104
107 void StopDecoder(); 105 void StopDecoder();
108 void OnDecoderStopped(); 106 void OnDecoderStopped();
109 107
110 scoped_refptr<base::MessageLoopProxy> message_loop_; 108 scoped_refptr<base::MessageLoopProxy> message_loop_;
111 base::WeakPtrFactory<VideoFrameStream> weak_factory_; 109 base::WeakPtrFactory<VideoFrameStream> weak_factory_;
112 base::WeakPtr<VideoFrameStream> weak_this_; 110 base::WeakPtr<VideoFrameStream> weak_this_;
113 111
114 State state_; 112 State state_;
115 113
116 InitCB init_cb_; 114 InitCB init_cb_;
117 VideoDecoder::ReadCB read_cb_; 115 VideoDecoder::ReadCB read_cb_;
118 base::Closure reset_cb_; 116 base::Closure reset_cb_;
119 base::Closure stop_cb_; 117 base::Closure stop_cb_;
120 118
119 // TODO(scherkus): Replace these with a VideoDecoderSelector instance after
120 // DemuxerStream is no longer refcounted.
121 ScopedVector<VideoDecoder> decoders_;
121 SetDecryptorReadyCB set_decryptor_ready_cb_; 122 SetDecryptorReadyCB set_decryptor_ready_cb_;
122 123
123 scoped_refptr<DemuxerStream> stream_; 124 scoped_refptr<DemuxerStream> stream_;
124 125
125 // These two will be set by VideoDecoderSelector::SelectVideoDecoder(). 126 // These two will be set by VideoDecoderSelector::SelectVideoDecoder().
126 scoped_refptr<VideoDecoder> decoder_; 127 scoped_ptr<VideoDecoder> decoder_;
127 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; 128 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_;
128 129
129 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream); 130 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream);
130 }; 131 };
131 132
132 } // namespace media 133 } // namespace media
133 134
134 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ 135 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_
OLDNEW
« no previous file with comments | « media/filters/video_decoder_selector_unittest.cc ('k') | media/filters/video_frame_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698