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 // These functions copy |*cb|, call Reset() on |*cb|, and then call Run() | 65 // This function copies |*cb|, calls Reset() on |*cb|, and then calls 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 | |
88 virtual FilterHost* host(); | 84 virtual FilterHost* host(); |
89 | 85 |
90 // The pipeline has resumed playback. Filters can continue requesting reads. | 86 // The pipeline has resumed playback. Filters can continue requesting reads. |
91 // Filters may implement this method if they need to respond to this call. | 87 // Filters may implement this method if they need to respond to this call. |
92 // TODO(boliu): Check that callback is not NULL in subclasses. | 88 // TODO(boliu): Check that callback is not NULL in subclasses. |
93 virtual void Play(const base::Closure& callback); | 89 virtual void Play(const base::Closure& callback); |
94 | 90 |
95 // The pipeline has paused playback. Filters should stop buffer exchange. | 91 // The pipeline has paused playback. Filters should stop buffer exchange. |
96 // Filters may implement this method if they need to respond to this call. | 92 // Filters may implement this method if they need to respond to this call. |
97 // TODO(boliu): Check that callback is not NULL in subclasses. | 93 // TODO(boliu): Check that callback is not NULL in subclasses. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Notify the DataSource of the bitrate of the media. | 157 // Notify the DataSource of the bitrate of the media. |
162 // Values of |bitrate| <= 0 are invalid and should be ignored. | 158 // Values of |bitrate| <= 0 are invalid and should be ignored. |
163 virtual void SetBitrate(int bitrate) = 0; | 159 virtual void SetBitrate(int bitrate) = 0; |
164 }; | 160 }; |
165 | 161 |
166 class MEDIA_EXPORT VideoDecoder : public Filter { | 162 class MEDIA_EXPORT VideoDecoder : public Filter { |
167 public: | 163 public: |
168 // Initialize a VideoDecoder with the given DemuxerStream, executing the | 164 // Initialize a VideoDecoder with the given DemuxerStream, executing the |
169 // callback upon completion. | 165 // callback upon completion. |
170 // stats_callback is used to update global pipeline statistics. | 166 // stats_callback is used to update global pipeline statistics. |
171 virtual void Initialize(DemuxerStream* stream, | 167 // |
172 const PipelineStatusCB& callback, | 168 // TODO(scherkus): switch to PipelineStatus callback. |
| 169 virtual void Initialize(DemuxerStream* stream, const base::Closure& callback, |
173 const StatisticsCallback& stats_callback) = 0; | 170 const StatisticsCallback& stats_callback) = 0; |
174 | 171 |
175 // Request a frame to be decoded and returned via the provided callback. | 172 // Request a frame to be decoded and returned via the provided callback. |
176 // Only one read may be in flight at any given time. | 173 // Only one read may be in flight at any given time. |
177 // | 174 // |
178 // Implementations guarantee that the callback will not be called from within | 175 // Implementations guarantee that the callback will not be called from within |
179 // this method. | 176 // this method. |
180 // | 177 // |
181 // Frames will be non-NULL yet may be end of stream frames. | 178 // Frames will be non-NULL yet may be end of stream frames. |
182 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ReadCB; | 179 typedef base::Callback<void(scoped_refptr<VideoFrame>)> ReadCB; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 268 |
272 // Resumes playback after underflow occurs. | 269 // Resumes playback after underflow occurs. |
273 // |buffer_more_audio| is set to true if you want to increase the size of the | 270 // |buffer_more_audio| is set to true if you want to increase the size of the |
274 // decoded audio buffer. | 271 // decoded audio buffer. |
275 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; | 272 virtual void ResumeAfterUnderflow(bool buffer_more_audio) = 0; |
276 }; | 273 }; |
277 | 274 |
278 } // namespace media | 275 } // namespace media |
279 | 276 |
280 #endif // MEDIA_BASE_FILTERS_H_ | 277 #endif // MEDIA_BASE_FILTERS_H_ |
OLD | NEW |