Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 #include <limits> | 26 #include <limits> |
| 27 #include <string> | 27 #include <string> |
| 28 | 28 |
| 29 #include "base/callback.h" | 29 #include "base/callback.h" |
| 30 #include "base/callback_old.h" | 30 #include "base/callback_old.h" |
| 31 #include "base/memory/ref_counted.h" | 31 #include "base/memory/ref_counted.h" |
| 32 #include "base/memory/scoped_ptr.h" | 32 #include "base/memory/scoped_ptr.h" |
| 33 #include "base/time.h" | 33 #include "base/time.h" |
| 34 #include "media/base/audio_decoder_config.h" | 34 #include "media/base/audio_decoder_config.h" |
| 35 #include "media/base/media_format.h" | 35 #include "media/base/media_format.h" |
| 36 #include "media/base/pipeline_status.h" | |
| 36 #include "media/base/video_frame.h" | 37 #include "media/base/video_frame.h" |
| 37 | 38 |
| 38 struct AVStream; | 39 struct AVStream; |
| 39 | 40 |
| 40 namespace media { | 41 namespace media { |
| 41 | 42 |
| 42 class Buffer; | 43 class Buffer; |
| 43 class Decoder; | 44 class Decoder; |
| 44 class DemuxerStream; | 45 class DemuxerStream; |
| 45 class Filter; | 46 class Filter; |
| 46 class FilterHost; | 47 class FilterHost; |
| 47 | 48 |
| 48 struct PipelineStatistics; | 49 struct PipelineStatistics; |
| 49 | 50 |
| 50 // Used to specify video preload states. They are "hints" to the browser about | 51 // Used to specify video preload states. They are "hints" to the browser about |
| 51 // how aggressively the browser should load and buffer data. | 52 // how aggressively the browser should load and buffer data. |
| 52 // Please see the HTML5 spec for the descriptions of these values: | 53 // Please see the HTML5 spec for the descriptions of these values: |
| 53 // http://www.w3.org/TR/html5/video.html#attr-media-preload | 54 // http://www.w3.org/TR/html5/video.html#attr-media-preload |
| 54 // | 55 // |
| 55 // Enum values must match the values in WebCore::MediaPlayer::Preload and | 56 // Enum values must match the values in WebCore::MediaPlayer::Preload and |
| 56 // there will be assertions at compile time if they do not match. | 57 // there will be assertions at compile time if they do not match. |
| 57 enum Preload { | 58 enum Preload { |
| 58 NONE, | 59 NONE, |
| 59 METADATA, | 60 METADATA, |
| 60 AUTO, | 61 AUTO, |
| 61 }; | 62 }; |
| 62 | 63 |
| 63 // Used for completing asynchronous methods. | 64 // Used for completing asynchronous methods. |
| 64 typedef Callback0::Type FilterCallback; | 65 typedef Callback0::Type FilterCallback; |
| 66 typedef base::Callback<void(PipelineStatus)> FilterStatusCB; | |
| 67 | |
| 68 // This function copies |cb|, calls Reset() on |cb|, and then calls Run() | |
| 69 // on the copy. This is used in the common case where you need to clear | |
| 70 // a callback member variable before running the callback. | |
| 71 void RunAndResetCB(FilterStatusCB* cb, PipelineStatus status); | |
|
Ami GONE FROM CHROMIUM
2011/05/12 22:49:26
In that case, s/RunAndResetCB/ResetAndRunCB/ ?
acolwell GONE FROM CHROMIUM
2011/05/13 00:49:10
Done.
| |
| 65 | 72 |
| 66 // Used for updating pipeline statistics. | 73 // Used for updating pipeline statistics. |
| 67 typedef Callback1<const PipelineStatistics&>::Type StatisticsCallback; | 74 typedef Callback1<const PipelineStatistics&>::Type StatisticsCallback; |
| 68 | 75 |
| 69 class Filter : public base::RefCountedThreadSafe<Filter> { | 76 class Filter : public base::RefCountedThreadSafe<Filter> { |
| 70 public: | 77 public: |
| 71 Filter(); | 78 Filter(); |
| 72 | 79 |
| 73 // Sets the private member |host_|. This is the first method called by | 80 // Sets the private member |host_|. This is the first method called by |
| 74 // the FilterHost after a filter is created. The host holds a strong | 81 // the FilterHost after a filter is created. The host holds a strong |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 97 // the client called Stop(). | 104 // the client called Stop(). |
| 98 // TODO(boliu): Check that callback is not NULL in subclasses. | 105 // TODO(boliu): Check that callback is not NULL in subclasses. |
| 99 virtual void Stop(FilterCallback* callback); | 106 virtual void Stop(FilterCallback* callback); |
| 100 | 107 |
| 101 // The pipeline playback rate has been changed. Filters may implement this | 108 // The pipeline playback rate has been changed. Filters may implement this |
| 102 // method if they need to respond to this call. | 109 // method if they need to respond to this call. |
| 103 virtual void SetPlaybackRate(float playback_rate); | 110 virtual void SetPlaybackRate(float playback_rate); |
| 104 | 111 |
| 105 // Carry out any actions required to seek to the given time, executing the | 112 // Carry out any actions required to seek to the given time, executing the |
| 106 // callback upon completion. | 113 // callback upon completion. |
| 107 virtual void Seek(base::TimeDelta time, FilterCallback* callback); | 114 virtual void Seek(base::TimeDelta time, const FilterStatusCB& callback); |
| 108 | 115 |
| 109 // This method is called from the pipeline when the audio renderer | 116 // This method is called from the pipeline when the audio renderer |
| 110 // is disabled. Filters can ignore the notification if they do not | 117 // is disabled. Filters can ignore the notification if they do not |
| 111 // need to react to this event. | 118 // need to react to this event. |
| 112 virtual void OnAudioRendererDisabled(); | 119 virtual void OnAudioRendererDisabled(); |
| 113 | 120 |
| 114 protected: | 121 protected: |
| 115 // Only allow scoped_refptr<> to delete filters. | 122 // Only allow scoped_refptr<> to delete filters. |
| 116 friend class base::RefCountedThreadSafe<Filter>; | 123 friend class base::RefCountedThreadSafe<Filter>; |
| 117 virtual ~Filter(); | 124 virtual ~Filter(); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 293 // buffer. | 300 // buffer. |
| 294 virtual bool HasEnded() = 0; | 301 virtual bool HasEnded() = 0; |
| 295 | 302 |
| 296 // Sets the output volume. | 303 // Sets the output volume. |
| 297 virtual void SetVolume(float volume) = 0; | 304 virtual void SetVolume(float volume) = 0; |
| 298 }; | 305 }; |
| 299 | 306 |
| 300 } // namespace media | 307 } // namespace media |
| 301 | 308 |
| 302 #endif // MEDIA_BASE_FILTERS_H_ | 309 #endif // MEDIA_BASE_FILTERS_H_ |
| OLD | NEW |