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

Side by Side Diff: media/base/composite_filter.h

Issue 6171009: Remove MessageLoop methods from Filter interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied more CR suggestions & removed message_loop() methods where possible. Created 9 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 | « chrome/renderer/render_view.cc ('k') | media/base/composite_filter.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef MEDIA_BASE_COMPOSITE_FILTER_H_ 5 #ifndef MEDIA_BASE_COMPOSITE_FILTER_H_
6 #define MEDIA_BASE_COMPOSITE_FILTER_H_ 6 #define MEDIA_BASE_COMPOSITE_FILTER_H_
7 7
8 #include "base/threading/thread.h" 8 #include "base/task.h"
9 #include "media/base/filter_host.h" 9 #include "media/base/filter_host.h"
10 #include "media/base/filters.h" 10 #include "media/base/filters.h"
11 11
12 class MessageLoop;
13
12 namespace media { 14 namespace media {
13 15
14 class CompositeFilter : public Filter { 16 class CompositeFilter : public Filter {
15 public: 17 public:
16 typedef base::Thread* (*ThreadFactoryFunction)(const char* thread_name); 18 explicit CompositeFilter(MessageLoop* message_loop);
17
18 CompositeFilter(MessageLoop* message_loop);
19
20 // Constructor that allows the default thread creation strategy to be
21 // overridden.
22 CompositeFilter(MessageLoop* message_loop,
23 ThreadFactoryFunction thread_factory);
24 19
25 // Adds a filter to the composite. This is only allowed after set_host() 20 // Adds a filter to the composite. This is only allowed after set_host()
26 // is called and before the first state changing operation such as Play(), 21 // is called and before the first state changing operation such as Play(),
27 // Flush(), Stop(), or Seek(). True is returned if the filter was successfully 22 // Flush(), Stop(), or Seek(). True is returned if the filter was successfully
28 // added to the composite. False is returned if the filter couldn't be added 23 // added to the composite. False is returned if the filter couldn't be added
29 // because the composite is in the wrong state or the filter needed a thread 24 // because the composite is in the wrong state.
30 // and the composite was unable to create one.
31 bool AddFilter(scoped_refptr<Filter> filter); 25 bool AddFilter(scoped_refptr<Filter> filter);
32 26
33 // media::Filter methods. 27 // media::Filter methods.
34 virtual const char* major_mime_type() const; 28 virtual const char* major_mime_type() const;
35 virtual void set_host(FilterHost* host); 29 virtual void set_host(FilterHost* host);
36 virtual FilterHost* host(); 30 virtual FilterHost* host();
37 virtual bool requires_message_loop() const;
38 virtual const char* message_loop_name() const;
39 virtual void set_message_loop(MessageLoop* message_loop);
40 virtual MessageLoop* message_loop();
41 virtual void Play(FilterCallback* play_callback); 31 virtual void Play(FilterCallback* play_callback);
42 virtual void Pause(FilterCallback* pause_callback); 32 virtual void Pause(FilterCallback* pause_callback);
43 virtual void Flush(FilterCallback* flush_callback); 33 virtual void Flush(FilterCallback* flush_callback);
44 virtual void Stop(FilterCallback* stop_callback); 34 virtual void Stop(FilterCallback* stop_callback);
45 virtual void SetPlaybackRate(float playback_rate); 35 virtual void SetPlaybackRate(float playback_rate);
46 virtual void Seek(base::TimeDelta time, FilterCallback* seek_callback); 36 virtual void Seek(base::TimeDelta time, FilterCallback* seek_callback);
47 virtual void OnAudioRendererDisabled(); 37 virtual void OnAudioRendererDisabled();
48 38
49 protected: 39 protected:
50 virtual ~CompositeFilter(); 40 virtual ~CompositeFilter();
51 41
52 /// Default thread factory strategy.
53 static base::Thread* DefaultThreadFactory(const char* thread_name);
54
55 void SetError(PipelineError error); 42 void SetError(PipelineError error);
56 43
57 private: 44 private:
58 class FilterHostImpl; 45 class FilterHostImpl;
59 46
60 enum State { 47 enum State {
61 kInvalid, 48 kInvalid,
62 kCreated, 49 kCreated,
63 kPaused, 50 kPaused,
64 kPlayPending, 51 kPlayPending,
65 kStopWhilePlayPending, 52 kStopWhilePlayPending,
66 kPlaying, 53 kPlaying,
67 kPausePending, 54 kPausePending,
68 kStopWhilePausePending, 55 kStopWhilePausePending,
69 kFlushPending, 56 kFlushPending,
70 kStopWhileFlushPending, 57 kStopWhileFlushPending,
71 kSeekPending, 58 kSeekPending,
72 kStopWhileSeekPending, 59 kStopWhileSeekPending,
73 kStopPending, 60 kStopPending,
74 kStopped, 61 kStopped,
75 kError 62 kError
76 }; 63 };
77 64
78 // Initialization method called by constructors.
79 void Init(MessageLoop* message_loop, ThreadFactoryFunction thread_factory);
80
81 // Transition to a new state. 65 // Transition to a new state.
82 void ChangeState(State new_state); 66 void ChangeState(State new_state);
83 67
84 // Start calling filters in a sequence. 68 // Start calling filters in a sequence.
85 void StartSerialCallSequence(); 69 void StartSerialCallSequence();
86 70
87 // Call filters in parallel. 71 // Call filters in parallel.
88 void StartParallelCallSequence(); 72 void StartParallelCallSequence();
89 73
90 // Call the filter based on the current value of state_. 74 // Call the filter based on the current value of state_.
(...skipping 26 matching lines...) Expand all
117 101
118 // Helper function used by NewThreadSafeCallback() to make sure the 102 // Helper function used by NewThreadSafeCallback() to make sure the
119 // method gets called on the right thread. 103 // method gets called on the right thread.
120 static void OnCallback(MessageLoop* message_loop, 104 static void OnCallback(MessageLoop* message_loop,
121 CancelableTask* task); 105 CancelableTask* task);
122 106
123 // Helper function that indicates whether SetError() calls can be forwarded 107 // Helper function that indicates whether SetError() calls can be forwarded
124 // to the host of this filter. 108 // to the host of this filter.
125 bool CanForwardError(); 109 bool CanForwardError();
126 110
127 // Vector of threads owned by the composite and used by filters in |filters_|.
128 typedef std::vector<base::Thread*> FilterThreadVector;
129 FilterThreadVector filter_threads_;
130
131 // Vector of the filters added to the composite. 111 // Vector of the filters added to the composite.
132 typedef std::vector<scoped_refptr<Filter> > FilterVector; 112 typedef std::vector<scoped_refptr<Filter> > FilterVector;
133 FilterVector filters_; 113 FilterVector filters_;
134 114
135 // Factory function used to create filter threads.
136 ThreadFactoryFunction thread_factory_;
137
138 // Callback for the pending request. 115 // Callback for the pending request.
139 scoped_ptr<FilterCallback> callback_; 116 scoped_ptr<FilterCallback> callback_;
140 117
141 // Time parameter for the pending Seek() request. 118 // Time parameter for the pending Seek() request.
142 base::TimeDelta pending_seek_time_; 119 base::TimeDelta pending_seek_time_;
143 120
144 // Current state of this filter. 121 // Current state of this filter.
145 State state_; 122 State state_;
146 123
147 // The index of the filter currently processing a request. 124 // The index of the filter currently processing a request.
(...skipping 10 matching lines...) Expand all
158 PipelineError error_; 135 PipelineError error_;
159 136
160 scoped_ptr<ScopedRunnableMethodFactory<CompositeFilter> > runnable_factory_; 137 scoped_ptr<ScopedRunnableMethodFactory<CompositeFilter> > runnable_factory_;
161 138
162 DISALLOW_COPY_AND_ASSIGN(CompositeFilter); 139 DISALLOW_COPY_AND_ASSIGN(CompositeFilter);
163 }; 140 };
164 141
165 } // namespace media 142 } // namespace media
166 143
167 #endif // MEDIA_BASE_COMPOSITE_FILTER_H_ 144 #endif // MEDIA_BASE_COMPOSITE_FILTER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.cc ('k') | media/base/composite_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698