| OLD | NEW |
| 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-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 // Implementation of FilterHost. | 5 // Implementation of FilterHost. |
| 6 | 6 |
| 7 #ifndef MEDIA_BASE_FILTER_HOST_IMPL_H_ | 7 #ifndef MEDIA_BASE_FILTER_HOST_IMPL_H_ |
| 8 #define MEDIA_BASE_FILTER_HOST_IMPL_H_ | 8 #define MEDIA_BASE_FILTER_HOST_IMPL_H_ |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "media/base/filter_host.h" | 11 #include "media/base/filter_host.h" |
| 12 #include "media/base/pipeline_impl.h" | 12 #include "media/base/pipeline_impl.h" |
| 13 | 13 |
| 14 namespace media { | 14 namespace media { |
| 15 | 15 |
| 16 class FilterHostImpl : public FilterHost { | 16 class FilterHostImpl : public FilterHost { |
| 17 public: | 17 public: |
| 18 // FilterHost interface. | 18 // FilterHost interface. |
| 19 virtual void InitializationComplete(); | 19 virtual void InitializationComplete(); |
| 20 virtual void Error(PipelineError error); | 20 virtual void Error(PipelineError error); |
| 21 virtual base::TimeDelta GetTime() const; | 21 virtual base::TimeDelta GetTime() const; |
| 22 virtual void SetTime(base::TimeDelta time); | 22 virtual void SetTime(base::TimeDelta time); |
| 23 virtual void SetDuration(base::TimeDelta duration); | 23 virtual void SetDuration(base::TimeDelta duration); |
| 24 virtual void SetBufferedTime(base::TimeDelta buffered_time); | 24 virtual void SetBufferedTime(base::TimeDelta buffered_time); |
| 25 virtual void SetTotalBytes(int64 total_bytes); | 25 virtual void SetTotalBytes(int64 total_bytes); |
| 26 virtual void SetBufferedBytes(int64 buffered_bytes); | 26 virtual void SetBufferedBytes(int64 buffered_bytes); |
| 27 virtual void SetVideoSize(size_t width, size_t height); | 27 virtual void SetVideoSize(size_t width, size_t height); |
| 28 | 28 |
| 29 // These methods are public, but are intended for use by the | 29 // These methods are public, but are intended for use by the |
| 30 // PipelineThread class only. | 30 // PipelineInternal class only. |
| 31 | 31 |
| 32 // Creates a FilterHostImpl object and populates the |filter_type_| member | 32 // Creates a FilterHostImpl object and populates the |filter_type_| member |
| 33 // by calling the Filter class's static filter_type() method. This ensures | 33 // by calling the Filter class's static filter_type() method. This ensures |
| 34 // that the GetFilter method can safely cast the filter interface from the | 34 // that the GetFilter method can safely cast the filter interface from the |
| 35 // MediaFilter base class interface to the specific Filter interface. | 35 // MediaFilter base class interface to the specific Filter interface. |
| 36 template <class Filter> | 36 template <class Filter> |
| 37 FilterHostImpl(PipelineThread* pipeline_thread, Filter* filter) | 37 FilterHostImpl(PipelineInternal* pipeline_internal, Filter* filter) |
| 38 : pipeline_thread_(pipeline_thread), | 38 : pipeline_internal_(pipeline_internal), |
| 39 filter_type_(Filter::filter_type()), | 39 filter_type_(Filter::filter_type()), |
| 40 filter_(filter), | 40 filter_(filter), |
| 41 stopped_(false) { | 41 stopped_(false) { |
| 42 } | 42 } |
| 43 ~FilterHostImpl() {} | 43 ~FilterHostImpl() {} |
| 44 | 44 |
| 45 // If this FilterHost contains a filter of the specified Filter class, then | 45 // If this FilterHost contains a filter of the specified Filter class, then |
| 46 // this method returns a pointer to the interface, otherwise it returns NULL | 46 // this method returns a pointer to the interface, otherwise it returns NULL |
| 47 // in |*filter_out|. | 47 // in |*filter_out|. |
| 48 template <class Filter> | 48 template <class Filter> |
| 49 void GetFilter(scoped_refptr<Filter>* filter_out) const { | 49 void GetFilter(scoped_refptr<Filter>* filter_out) const { |
| 50 *filter_out = (Filter::filter_type() == filter_type_) ? | 50 *filter_out = (Filter::filter_type() == filter_type_) ? |
| 51 reinterpret_cast<Filter*>(media_filter()) : NULL; | 51 reinterpret_cast<Filter*>(media_filter()) : NULL; |
| 52 } | 52 } |
| 53 | 53 |
| 54 // Stops the filter. | 54 // Stops the filter. |
| 55 void Stop(); | 55 void Stop(); |
| 56 | 56 |
| 57 // Used by the PipelineThread to call Seek and SetRate methods on filters. | 57 // Used by the PipelineInternal to call Seek() and SetRate() methods on |
| 58 // filters. |
| 58 MediaFilter* media_filter() const { return filter_; } | 59 MediaFilter* media_filter() const { return filter_; } |
| 59 | 60 |
| 60 private: | 61 private: |
| 61 // Useful method for getting the pipeline. | 62 // Useful method for getting the pipeline. |
| 62 PipelineImpl* pipeline() const { return pipeline_thread_->pipeline(); } | 63 PipelineImpl* pipeline() const { return pipeline_internal_->pipeline(); } |
| 63 | 64 |
| 64 // PipelineThread that owns this FilterHostImpl. | 65 // PipelineInternal that owns this FilterHostImpl. |
| 65 PipelineThread* const pipeline_thread_; | 66 PipelineInternal* const pipeline_internal_; |
| 66 | 67 |
| 67 // The FilterType of the filter this host contains. | 68 // The FilterType of the filter this host contains. |
| 68 FilterType const filter_type_; | 69 FilterType const filter_type_; |
| 69 | 70 |
| 70 // A pointer to the filter's MediaFilter base interface. | 71 // A pointer to the filter's MediaFilter base interface. |
| 71 scoped_refptr<MediaFilter> filter_; | 72 scoped_refptr<MediaFilter> filter_; |
| 72 | 73 |
| 73 // Critical section used for scheduled time update callbacks. | 74 // Critical section used for scheduled time update callbacks. |
| 74 Lock time_update_lock_; | 75 Lock time_update_lock_; |
| 75 | 76 |
| 76 // Used to avoid calling Filter's Stop() method multiple times. | 77 // Used to avoid calling Filter's Stop() method multiple times. |
| 77 bool stopped_; | 78 bool stopped_; |
| 78 | 79 |
| 79 DISALLOW_COPY_AND_ASSIGN(FilterHostImpl); | 80 DISALLOW_COPY_AND_ASSIGN(FilterHostImpl); |
| 80 }; | 81 }; |
| 81 | 82 |
| 82 } // namespace media | 83 } // namespace media |
| 83 | 84 |
| 84 #endif // MEDIA_BASE_FILTER_HOST_IMPL_H_ | 85 #endif // MEDIA_BASE_FILTER_HOST_IMPL_H_ |
| OLD | NEW |