| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 FILTER_VIDEO_DECODER, | 51 FILTER_VIDEO_DECODER, |
| 52 FILTER_AUDIO_RENDERER, | 52 FILTER_AUDIO_RENDERER, |
| 53 FILTER_VIDEO_RENDERER | 53 FILTER_VIDEO_RENDERER |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 | 56 |
| 57 class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> { | 57 class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> { |
| 58 public: | 58 public: |
| 59 MediaFilter() : host_(NULL), message_loop_(NULL) {} | 59 MediaFilter() : host_(NULL), message_loop_(NULL) {} |
| 60 | 60 |
| 61 // Sets the protected member |host_|. This is the first method called by | 61 // Sets the private member |host_|. This is the first method called by |
| 62 // the FilterHost after a filter is created. The host holds a strong | 62 // the FilterHost after a filter is created. The host holds a strong |
| 63 // reference to the filter. The reference held by the host is guaranteed | 63 // reference to the filter. The reference held by the host is guaranteed |
| 64 // to be released before the host object is destroyed by the pipeline. | 64 // to be released before the host object is destroyed by the pipeline. |
| 65 virtual void SetFilterHost(FilterHost* host) { | 65 virtual void set_host(FilterHost* host) { |
| 66 DCHECK(host); | 66 DCHECK(host); |
| 67 DCHECK(!host_); | 67 DCHECK(!host_); |
| 68 host_ = host; | 68 host_ = host; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Sets the protected member |message_loop_|, which is used by filters for | 71 virtual FilterHost* host() { |
| 72 return host_; |
| 73 } |
| 74 |
| 75 // Sets the private member |message_loop_|, which is used by filters for |
| 72 // processing asynchronous tasks and maintaining synchronized access to | 76 // processing asynchronous tasks and maintaining synchronized access to |
| 73 // internal data members. The message loop should be running and exceed the | 77 // internal data members. The message loop should be running and exceed the |
| 74 // lifetime of the filter. | 78 // lifetime of the filter. |
| 75 virtual void SetMessageLoop(MessageLoop* message_loop) { | 79 virtual void set_message_loop(MessageLoop* message_loop) { |
| 76 DCHECK(message_loop); | 80 DCHECK(message_loop); |
| 77 DCHECK(!message_loop_); | 81 DCHECK(!message_loop_); |
| 78 message_loop_ = message_loop; | 82 message_loop_ = message_loop; |
| 79 } | 83 } |
| 80 | 84 |
| 85 virtual MessageLoop* message_loop() { |
| 86 return message_loop_; |
| 87 } |
| 88 |
| 81 // The pipeline is being stopped either as a result of an error or because | 89 // The pipeline is being stopped either as a result of an error or because |
| 82 // the client called Stop(). | 90 // the client called Stop(). |
| 83 virtual void Stop() = 0; | 91 virtual void Stop() = 0; |
| 84 | 92 |
| 85 // The pipeline playback rate has been changed. Filters may implement this | 93 // The pipeline playback rate has been changed. Filters may implement this |
| 86 // method if they need to respond to this call. | 94 // method if they need to respond to this call. |
| 87 virtual void SetPlaybackRate(float playback_rate) {} | 95 virtual void SetPlaybackRate(float playback_rate) {} |
| 88 | 96 |
| 89 // The pipeline is seeking to the specified time. Filters may implement | 97 // The pipeline is seeking to the specified time. Filters may implement |
| 90 // this method if they need to respond to this call. | 98 // this method if they need to respond to this call. |
| 91 virtual void Seek(base::TimeDelta time) {} | 99 virtual void Seek(base::TimeDelta time) {} |
| 92 | 100 |
| 93 protected: | 101 protected: |
| 94 // Only allow scoped_refptr<> to delete filters. | 102 // Only allow scoped_refptr<> to delete filters. |
| 95 friend class base::RefCountedThreadSafe<MediaFilter>; | 103 friend class base::RefCountedThreadSafe<MediaFilter>; |
| 96 virtual ~MediaFilter() {} | 104 virtual ~MediaFilter() {} |
| 97 | 105 |
| 98 // TODO(scherkus): make these private with public/protected accessors. | 106 private: |
| 99 FilterHost* host_; | 107 FilterHost* host_; |
| 100 MessageLoop* message_loop_; | 108 MessageLoop* message_loop_; |
| 101 | 109 |
| 102 private: | |
| 103 DISALLOW_COPY_AND_ASSIGN(MediaFilter); | 110 DISALLOW_COPY_AND_ASSIGN(MediaFilter); |
| 104 }; | 111 }; |
| 105 | 112 |
| 106 | 113 |
| 107 class DataSource : public MediaFilter { | 114 class DataSource : public MediaFilter { |
| 108 public: | 115 public: |
| 109 static const FilterType filter_type() { | 116 static const FilterType filter_type() { |
| 110 return FILTER_DATA_SOURCE; | 117 return FILTER_DATA_SOURCE; |
| 111 } | 118 } |
| 112 | 119 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 // Initializes this filter, returns true if successful, false otherwise. | 284 // Initializes this filter, returns true if successful, false otherwise. |
| 278 virtual bool Initialize(AudioDecoder* decoder) = 0; | 285 virtual bool Initialize(AudioDecoder* decoder) = 0; |
| 279 | 286 |
| 280 // Sets the output volume. | 287 // Sets the output volume. |
| 281 virtual void SetVolume(float volume) = 0; | 288 virtual void SetVolume(float volume) = 0; |
| 282 }; | 289 }; |
| 283 | 290 |
| 284 } // namespace media | 291 } // namespace media |
| 285 | 292 |
| 286 #endif // MEDIA_BASE_FILTERS_H_ | 293 #endif // MEDIA_BASE_FILTERS_H_ |
| OLD | NEW |