Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Unified Diff: media/base/filter_host_impl.h

Issue 18546: Implementation of Pipeline and FilterHost interfaces. This is a large change... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/filter_host.h ('k') | media/base/filter_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/filter_host_impl.h
===================================================================
--- media/base/filter_host_impl.h (revision 8731)
+++ media/base/filter_host_impl.h (working copy)
@@ -9,30 +9,81 @@
#include "base/task.h"
#include "media/base/filter_host.h"
+#include "media/base/pipeline_impl.h"
namespace media {
class FilterHostImpl : public FilterHost {
public:
- FilterHostImpl();
-
// FilterHost interface.
virtual const PipelineStatus* GetPipelineStatus() const;
- virtual void SetTimeUpdateCallback(Callback1<int64>::Type* callback);
- virtual void InitializationComplete();
+ virtual void SetTimeUpdateCallback(Callback1<base::TimeDelta>::Type* cb);
+ virtual void InitializationComplete();
virtual void PostTask(Task* task);
virtual void Error(PipelineError error);
- virtual void SetTime(int64 time);
- virtual void SetDuration(int64 duration);
- virtual void SetBufferedTime(int64 buffered_time);
+ virtual void SetTime(base::TimeDelta time);
+ virtual void SetDuration(base::TimeDelta duration);
+ virtual void SetBufferedTime(base::TimeDelta buffered_time);
virtual void SetTotalBytes(int64 total_bytes);
virtual void SetBufferedBytes(int64 buffered_bytes);
virtual void SetVideoSize(size_t width, size_t height);
- protected:
- virtual ~FilterHostImpl() {}
+ // These methods are public, but are intended for use by the
+ // PipelineThread class only.
+ // Creates a FilterHostImpl object and populates the filter_type_ member
+ // by calling the Filter class's static filter_type() method. This ensures
+ // that the GetFilter method can safely cast the filter interface from the
+ // MediaFilter base class interface to the specific Filter interface.
+ template <class Filter>
+ FilterHostImpl(PipelineThread* pipeline_thread, Filter* filter)
+ : pipeline_thread_(pipeline_thread),
+ filter_type_(Filter::filter_type()),
+ filter_(filter),
+ stopped_(false) {
+ }
+ ~FilterHostImpl() {}
+
+ // If this FilterHost contains a filter of the specifed Filter class, then
+ // this method returns a pointer to the interface, otherwise it returns NULL.
+ template <class Filter>
+ Filter* GetFilter() const {
+ Filter* filter = NULL;
+ if (Filter::filter_type() == filter_type_) {
+ filter = reinterpret_cast<Filter*>(media_filter());
+ }
+ return filter;
+ }
+
+ // Call the filter if it has registered a time update callback if the filter
+ // has registered one though the FilterHost::SetTimeUpdateCallback method.
+ void RunTimeUpdateCallback(base::TimeDelta time);
+
+ // Stops the filter.
+ void Stop();
+
+ // Used by the PipelineThread to call Seek and SetRate methods on filters.
+ MediaFilter* media_filter() const { return filter_; }
+
private:
+ PipelineImpl* pipeline() const { return pipeline_thread_->pipeline(); }
+
+ // PipelineThread that owns this FilterHostImpl.
+ PipelineThread* const pipeline_thread_;
+
+ // The FilterType of the filter this host contains.
+ FilterType const filter_type_;
+
+ // A pointer to the filter's MediaFilter base interface.
+ scoped_refptr<MediaFilter> filter_;
+
+ // An optional callback that will be called when the time is updated.
+ scoped_ptr<Callback1<base::TimeDelta>::Type> time_update_callback_;
+
+ // Used to avoid calling Filter's Stop method multiplie times. It is also
+ // used to prevent a filter that has been stopped from calling PostTask.
+ bool stopped_;
+
DISALLOW_COPY_AND_ASSIGN(FilterHostImpl);
};
« no previous file with comments | « media/base/filter_host.h ('k') | media/base/filter_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698