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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/filter_host.h ('k') | media/base/filter_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 13
13 namespace media { 14 namespace media {
14 15
15 class FilterHostImpl : public FilterHost { 16 class FilterHostImpl : public FilterHost {
16 public: 17 public:
17 FilterHostImpl();
18
19 // FilterHost interface. 18 // FilterHost interface.
20 virtual const PipelineStatus* GetPipelineStatus() const; 19 virtual const PipelineStatus* GetPipelineStatus() const;
21 virtual void SetTimeUpdateCallback(Callback1<int64>::Type* callback); 20 virtual void SetTimeUpdateCallback(Callback1<base::TimeDelta>::Type* cb);
22 virtual void InitializationComplete(); 21 virtual void InitializationComplete();
23 virtual void PostTask(Task* task); 22 virtual void PostTask(Task* task);
24 virtual void Error(PipelineError error); 23 virtual void Error(PipelineError error);
25 virtual void SetTime(int64 time); 24 virtual void SetTime(base::TimeDelta time);
26 virtual void SetDuration(int64 duration); 25 virtual void SetDuration(base::TimeDelta duration);
27 virtual void SetBufferedTime(int64 buffered_time); 26 virtual void SetBufferedTime(base::TimeDelta buffered_time);
28 virtual void SetTotalBytes(int64 total_bytes); 27 virtual void SetTotalBytes(int64 total_bytes);
29 virtual void SetBufferedBytes(int64 buffered_bytes); 28 virtual void SetBufferedBytes(int64 buffered_bytes);
30 virtual void SetVideoSize(size_t width, size_t height); 29 virtual void SetVideoSize(size_t width, size_t height);
31 30
32 protected: 31 // These methods are public, but are intended for use by the
33 virtual ~FilterHostImpl() {} 32 // PipelineThread class only.
33
34 // Creates a FilterHostImpl object and populates the filter_type_ member
35 // by calling the Filter class's static filter_type() method. This ensures
36 // that the GetFilter method can safely cast the filter interface from the
37 // MediaFilter base class interface to the specific Filter interface.
38 template <class Filter>
39 FilterHostImpl(PipelineThread* pipeline_thread, Filter* filter)
40 : pipeline_thread_(pipeline_thread),
41 filter_type_(Filter::filter_type()),
42 filter_(filter),
43 stopped_(false) {
44 }
45 ~FilterHostImpl() {}
46
47 // If this FilterHost contains a filter of the specifed Filter class, then
48 // this method returns a pointer to the interface, otherwise it returns NULL.
49 template <class Filter>
50 Filter* GetFilter() const {
51 Filter* filter = NULL;
52 if (Filter::filter_type() == filter_type_) {
53 filter = reinterpret_cast<Filter*>(media_filter());
54 }
55 return filter;
56 }
57
58 // Call the filter if it has registered a time update callback if the filter
59 // has registered one though the FilterHost::SetTimeUpdateCallback method.
60 void RunTimeUpdateCallback(base::TimeDelta time);
61
62 // Stops the filter.
63 void Stop();
64
65 // Used by the PipelineThread to call Seek and SetRate methods on filters.
66 MediaFilter* media_filter() const { return filter_; }
34 67
35 private: 68 private:
69 PipelineImpl* pipeline() const { return pipeline_thread_->pipeline(); }
70
71 // PipelineThread that owns this FilterHostImpl.
72 PipelineThread* const pipeline_thread_;
73
74 // The FilterType of the filter this host contains.
75 FilterType const filter_type_;
76
77 // A pointer to the filter's MediaFilter base interface.
78 scoped_refptr<MediaFilter> filter_;
79
80 // An optional callback that will be called when the time is updated.
81 scoped_ptr<Callback1<base::TimeDelta>::Type> time_update_callback_;
82
83 // Used to avoid calling Filter's Stop method multiplie times. It is also
84 // used to prevent a filter that has been stopped from calling PostTask.
85 bool stopped_;
86
36 DISALLOW_COPY_AND_ASSIGN(FilterHostImpl); 87 DISALLOW_COPY_AND_ASSIGN(FilterHostImpl);
37 }; 88 };
38 89
39 } // namespace media 90 } // namespace media
40 91
41 #endif // MEDIA_BASE_FILTER_HOST_IMPL_H_ 92 #endif // MEDIA_BASE_FILTER_HOST_IMPL_H_
OLDNEW
« 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