| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // there will be assertions at compile time if they do not match. | 55 // there will be assertions at compile time if they do not match. |
| 56 enum Preload { | 56 enum Preload { |
| 57 NONE, | 57 NONE, |
| 58 METADATA, | 58 METADATA, |
| 59 AUTO, | 59 AUTO, |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Used for completing asynchronous methods. | 62 // Used for completing asynchronous methods. |
| 63 typedef base::Callback<void(PipelineStatus)> FilterStatusCB; | 63 typedef base::Callback<void(PipelineStatus)> FilterStatusCB; |
| 64 | 64 |
| 65 // This function copies |*cb|, calls Reset() on |*cb|, and then calls Run() | 65 // These functions copy |*cb|, call Reset() on |*cb|, and then call Run() |
| 66 // on the copy. This is used in the common case where you need to clear | 66 // on the copy. This is used in the common case where you need to clear |
| 67 // a callback member variable before running the callback. | 67 // a callback member variable before running the callback. |
| 68 MEDIA_EXPORT void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status); | 68 MEDIA_EXPORT void ResetAndRunCB(FilterStatusCB* cb, PipelineStatus status); |
| 69 MEDIA_EXPORT void ResetAndRunCB(base::Closure* cb); | 69 MEDIA_EXPORT void ResetAndRunCB(base::Closure* cb); |
| 70 | 70 |
| 71 // Used for updating pipeline statistics. | 71 // Used for updating pipeline statistics. |
| 72 typedef base::Callback<void(const PipelineStatistics&)> StatisticsCallback; | 72 typedef base::Callback<void(const PipelineStatistics&)> StatisticsCallback; |
| 73 | 73 |
| 74 class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> { | 74 class MEDIA_EXPORT Filter : public base::RefCountedThreadSafe<Filter> { |
| 75 public: | 75 public: |
| 76 Filter(); | 76 Filter(); |
| 77 | 77 |
| 78 // Sets the private member |host_|. This is the first method called by | 78 // Sets the private member |host_|. This is the first method called by |
| 79 // the FilterHost after a filter is created. The host holds a strong | 79 // the FilterHost after a filter is created. The host holds a strong |
| 80 // reference to the filter. The reference held by the host is guaranteed | 80 // reference to the filter. The reference held by the host is guaranteed |
| 81 // to be released before the host object is destroyed by the pipeline. | 81 // to be released before the host object is destroyed by the pipeline. |
| 82 virtual void set_host(FilterHost* host); | 82 virtual void set_host(FilterHost* host); |
| 83 | 83 |
| 84 // Clear |host_| to signal abandonment. Must be called after set_host() and |
| 85 // before any state-changing method below. |
| 86 virtual void clear_host(); |
| 87 |
| 84 virtual FilterHost* host(); | 88 virtual FilterHost* host(); |
| 85 | 89 |
| 86 // The pipeline has resumed playback. Filters can continue requesting reads. | 90 // The pipeline has resumed playback. Filters can continue requesting reads. |
| 87 // Filters may implement this method if they need to respond to this call. | 91 // Filters may implement this method if they need to respond to this call. |
| 88 // TODO(boliu): Check that callback is not NULL in subclasses. | 92 // TODO(boliu): Check that callback is not NULL in subclasses. |
| 89 virtual void Play(const base::Closure& callback); | 93 virtual void Play(const base::Closure& callback); |
| 90 | 94 |
| 91 // The pipeline has paused playback. Filters should stop buffer exchange. | 95 // The pipeline has paused playback. Filters should stop buffer exchange. |
| 92 // Filters may implement this method if they need to respond to this call. | 96 // Filters may implement this method if they need to respond to this call. |
| 93 // TODO(boliu): Check that callback is not NULL in subclasses. | 97 // TODO(boliu): Check that callback is not NULL in subclasses. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // Notify the DataSource of the bitrate of the media. | 161 // Notify the DataSource of the bitrate of the media. |
| 158 // Values of |bitrate| <= 0 are invalid and should be ignored. | 162 // Values of |bitrate| <= 0 are invalid and should be ignored. |
| 159 virtual void SetBitrate(int bitrate) = 0; | 163 virtual void SetBitrate(int bitrate) = 0; |
| 160 }; | 164 }; |
| 161 | 165 |
| 162 class MEDIA_EXPORT VideoDecoder : public Filter { | 166 class MEDIA_EXPORT VideoDecoder : public Filter { |
| 163 public: | 167 public: |
| 164 // Initialize a VideoDecoder with the given DemuxerStream, executing the | 168 // Initialize a VideoDecoder with the given DemuxerStream, executing the |
| 165 // callback upon completion. | 169 // callback upon completion. |
| 166 // stats_callback is used to update global pipeline statistics. | 170 // stats_callback is used to update global pipeline statistics. |
| 167 // | 171 virtual void Initialize(DemuxerStream* stream, |
| 168 // TODO(scherkus): switch to PipelineStatus callback. | 172 const PipelineStatusCB& callback, |
| 169 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, | |
| 170 const StatisticsCallback& stats_callback) = 0; | 173 const StatisticsCallback& stats_callback) = 0; |
| 171 | 174 |
| 172 // Request a frame to be decoded and returned via the provided callback. | 175 // Request a frame to be decoded and returned via the provided callback. |
| 173 // Only one read may be in flight at any given time. | 176 // Only one read may be in flight at any given time. |
| 174 // | 177 // |
| 175 // Implementations guarantee that the callback will not be called from within | 178 // Implementations guarantee that the callback will not be called from within |
| 176 // this method. | 179 // this method. |
| 177 // | 180 // |
| 178 // Frames will be non-NULL yet may be end of stream frames. | 181 // Frames will be non-NULL yet may be end of stream frames. |
| 179 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ReadCB; | 182 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ReadCB; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 271 |
| 269 // Resumes playback after underflow occurs. | 272 // Resumes playback after underflow occurs. |
| 270 // |buffer_more_audio| is set to true if you want to increase the size of the | 273 // |buffer_more_audio| is set to true if you want to increase the size of the |
| 271 // decoded audio buffer. | 274 // decoded audio buffer. |
| 272 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; | 275 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; |
| 273 }; | 276 }; |
| 274 | 277 |
| 275 } // namespace media | 278 } // namespace media |
| 276 | 279 |
| 277 #endif // MEDIA_BASE_FILTERS_H_ | 280 #endif // MEDIA_BASE_FILTERS_H_ |
| OLD | NEW |