OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Filters are connected in a strongly typed manner, with downstream filters | 5 // Filters are connected in a strongly typed manner, with downstream filters |
6 // always reading data from upstream filters. Upstream filters have no clue | 6 // always reading data from upstream filters. Upstream filters have no clue |
7 // who is actually reading from them, and return the results via callbacks. | 7 // who is actually reading from them, and return the results via callbacks. |
8 // | 8 // |
9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer | 9 // DemuxerStream(Video) <- VideoDecoder <- VideoRenderer |
10 // DataSource <- Demuxer < | 10 // DataSource <- Demuxer < |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 FilterHost* host() const { return host_; } | 102 FilterHost* host() const { return host_; } |
103 | 103 |
104 private: | 104 private: |
105 FilterHost* host_; | 105 FilterHost* host_; |
106 | 106 |
107 DISALLOW_COPY_AND_ASSIGN(Filter); | 107 DISALLOW_COPY_AND_ASSIGN(Filter); |
108 }; | 108 }; |
109 | 109 |
110 class MEDIA_EXPORT VideoDecoder : public Filter { | 110 class MEDIA_EXPORT VideoDecoder : public Filter { |
111 public: | 111 public: |
| 112 // Status codes for read operations on VideoDecoder. |
| 113 enum DecoderStatus { |
| 114 kOk, // Everything went as planned. |
| 115 kDecodeError, // Decoding error happened. |
| 116 kDecryptError // Decrypting error happened. |
| 117 }; |
| 118 |
112 // Initialize a VideoDecoder with the given DemuxerStream, executing the | 119 // Initialize a VideoDecoder with the given DemuxerStream, executing the |
113 // callback upon completion. | 120 // callback upon completion. |
114 // statistics_cb is used to update global pipeline statistics. | 121 // statistics_cb is used to update global pipeline statistics. |
115 virtual void Initialize(DemuxerStream* stream, | 122 virtual void Initialize(DemuxerStream* stream, |
116 const PipelineStatusCB& status_cb, | 123 const PipelineStatusCB& status_cb, |
117 const StatisticsCB& statistics_cb) = 0; | 124 const StatisticsCB& statistics_cb) = 0; |
118 | 125 |
119 // Request a frame to be decoded and returned via the provided callback. | 126 // Requests a frame to be decoded. The status of the decoder and decoded frame |
120 // Only one read may be in flight at any given time. | 127 // are returned via the provided callback. Only one read may be in flight at |
| 128 // any given time. |
121 // | 129 // |
122 // Implementations guarantee that the callback will not be called from within | 130 // Implementations guarantee that the callback will not be called from within |
123 // this method. | 131 // this method. |
124 // | 132 // |
125 // Non-NULL frames contain decoded video data or may indicate the end of | 133 // If the returned status is not kOk, some error has occurred in the video |
126 // the stream. NULL video frames indicate an aborted read. This can happen if | 134 // decoder. In this case, the returned frame should always be NULL. |
127 // the DemuxerStream gets flushed and doesn't have any more data to return. | 135 // |
128 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ReadCB; | 136 // Otherwise, the video decoder is in good shape. In this case, Non-NULL |
| 137 // frames contain decoded video data or may indicate the end of the stream. |
| 138 // NULL video frames indicate an aborted read. This can happen if the |
| 139 // DemuxerStream gets flushed and doesn't have any more data to return. |
| 140 typedef base::Callback<void(DecoderStatus, scoped_refptr<VideoFrame>)> ReadCB; |
129 virtual void Read(const ReadCB& read_cb) = 0; | 141 virtual void Read(const ReadCB& read_cb) = 0; |
130 | 142 |
131 // Returns the natural width and height of decoded video in pixels. | 143 // Returns the natural width and height of decoded video in pixels. |
132 // | 144 // |
133 // Clients should NOT rely on these values to remain constant. Instead, use | 145 // Clients should NOT rely on these values to remain constant. Instead, use |
134 // the width/height from decoded video frames themselves. | 146 // the width/height from decoded video frames themselves. |
135 // | 147 // |
136 // TODO(scherkus): why not rely on prerolling and decoding a single frame to | 148 // TODO(scherkus): why not rely on prerolling and decoding a single frame to |
137 // get dimensions? | 149 // get dimensions? |
138 virtual const gfx::Size& natural_size() = 0; | 150 virtual const gfx::Size& natural_size() = 0; |
(...skipping 12 matching lines...) Expand all Loading... |
151 virtual void PrepareForShutdownHack(); | 163 virtual void PrepareForShutdownHack(); |
152 | 164 |
153 protected: | 165 protected: |
154 VideoDecoder(); | 166 VideoDecoder(); |
155 virtual ~VideoDecoder(); | 167 virtual ~VideoDecoder(); |
156 | 168 |
157 private: | 169 private: |
158 // These functions will be removed later. Declare here to make sure they are | 170 // These functions will be removed later. Declare here to make sure they are |
159 // not called from VideoDecoder interface anymore. | 171 // not called from VideoDecoder interface anymore. |
160 // TODO(xhwang): Remove them when VideoDecoder is not a Filter any more. | 172 // TODO(xhwang): Remove them when VideoDecoder is not a Filter any more. |
161 // See bug: crbug.com/108340 | 173 // See bug: http://crbug.com/108340 |
162 virtual void Play(const base::Closure& callback) OVERRIDE; | 174 virtual void Play(const base::Closure& callback) OVERRIDE; |
163 virtual void Pause(const base::Closure& callback) OVERRIDE; | 175 virtual void Pause(const base::Closure& callback) OVERRIDE; |
164 virtual void Seek(base::TimeDelta time, | 176 virtual void Seek(base::TimeDelta time, |
165 const PipelineStatusCB& callback) OVERRIDE; | 177 const PipelineStatusCB& callback) OVERRIDE; |
| 178 virtual FilterHost* host() OVERRIDE; |
166 }; | 179 }; |
167 | 180 |
168 class MEDIA_EXPORT VideoRenderer : public Filter { | 181 class MEDIA_EXPORT VideoRenderer : public Filter { |
169 public: | 182 public: |
170 // Used to update the pipeline's clock time. The parameter is the time that | 183 // Used to update the pipeline's clock time. The parameter is the time that |
171 // the clock should not exceed. | 184 // the clock should not exceed. |
172 typedef base::Callback<void(base::TimeDelta)> TimeCB; | 185 typedef base::Callback<void(base::TimeDelta)> TimeCB; |
173 | 186 |
174 // Initialize a VideoRenderer with the given VideoDecoder, executing the | 187 // Initialize a VideoRenderer with the given VideoDecoder, executing the |
175 // callback upon completion. | 188 // callback upon completion. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 223 |
211 // Resumes playback after underflow occurs. | 224 // Resumes playback after underflow occurs. |
212 // |buffer_more_audio| is set to true if you want to increase the size of the | 225 // |buffer_more_audio| is set to true if you want to increase the size of the |
213 // decoded audio buffer. | 226 // decoded audio buffer. |
214 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; | 227 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; |
215 }; | 228 }; |
216 | 229 |
217 } // namespace media | 230 } // namespace media |
218 | 231 |
219 #endif // MEDIA_BASE_FILTERS_H_ | 232 #endif // MEDIA_BASE_FILTERS_H_ |
OLD | NEW |