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

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

Issue 10796074: Move VideoRenderer out of Filter heirarchy. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: GetMediaTime Created 8 years, 5 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/clock.h ('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
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_COMPOSITE_FILTER_H_
6 #define MEDIA_BASE_COMPOSITE_FILTER_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/memory/weak_ptr.h"
12 #include "media/base/filter_host.h"
13 #include "media/base/filters.h"
14
15 namespace base {
16 class MessageLoopProxy;
17 }
18
19 namespace media {
20
21 class MEDIA_EXPORT CompositeFilter : public Filter {
22 public:
23 explicit CompositeFilter(
24 const scoped_refptr<base::MessageLoopProxy>& message_loop);
25
26 // Adds a filter to the composite. This is only allowed after SetHost()
27 // is called and before the first state changing operation such as Play(),
28 // Flush(), Stop(), or Seek(). CHECK-fails if preconditions are not met.
29 void AddFilter(scoped_refptr<Filter> filter);
30
31 // media::Filter methods.
32 virtual void SetHost(FilterHost* host) OVERRIDE;
33 virtual void Play(const base::Closure& play_cb) OVERRIDE;
34 virtual void Pause(const base::Closure& pause_cb) OVERRIDE;
35 virtual void Flush(const base::Closure& flush_cb) OVERRIDE;
36 virtual void Stop(const base::Closure& stop_cb) OVERRIDE;
37 virtual void SetPlaybackRate(float playback_rate) OVERRIDE;
38 virtual void Seek(
39 base::TimeDelta time, const PipelineStatusCB& seek_cb) OVERRIDE;
40
41 protected:
42 virtual ~CompositeFilter();
43
44 void SetError(PipelineStatus error);
45
46 private:
47 class FilterHostImpl;
48
49 enum State {
50 kInvalid,
51 kCreated,
52 kPaused,
53 kPlayPending,
54 kStopWhilePlayPending,
55 kPlaying,
56 kPausePending,
57 kStopWhilePausePending,
58 kFlushPending,
59 kStopWhileFlushPending,
60 kSeekPending,
61 kStopWhileSeekPending,
62 kStopPending,
63 kStopped,
64 kError
65 };
66
67 // Transition to a new state.
68 void ChangeState(State new_state);
69
70 // Start calling filters in a sequence.
71 void StartSerialCallSequence();
72
73 // Call filters in parallel.
74 void StartParallelCallSequence();
75
76 // Call the filter based on the current value of state_.
77 void CallFilter(scoped_refptr<Filter>& filter, const base::Closure& callback);
78
79 // Calls |callback_| and then clears the reference.
80 void DispatchPendingCallback(PipelineStatus status);
81
82 // Gets the state to transition to given |state|.
83 State GetNextState(State state) const;
84
85 // Filter callback for a serial sequence.
86 void SerialCallback();
87
88 // Filter callback for a parallel sequence.
89 void ParallelCallback();
90
91 // Called when a parallel or serial call sequence completes.
92 void OnCallSequenceDone();
93
94 // Helper function for sending an error to the FilterHost.
95 void SendErrorToHost(PipelineStatus error);
96
97 // Creates a callback that can be called from any thread, but is guaranteed
98 // to call the specified method on the thread associated with this filter.
99 base::Closure NewThreadSafeCallback(void (CompositeFilter::*method)());
100
101 // Helper function that indicates whether SetError() calls can be forwarded
102 // to the host of this filter.
103 bool CanForwardError();
104
105 // Checks to see if a Play(), Pause(), Flush(), Stop(), or Seek() operation is
106 // pending.
107 bool IsOperationPending() const;
108
109 // Called by operations that take a PipelineStatusCB instead of a Closure.
110 // TODO: Remove when Closures are replaced by PipelineStatusCB.
111 void OnStatusCB(const base::Closure& callback, PipelineStatus status);
112
113 // Convenience method for accessing the FilterHost object.
114 FilterHost* host();
115
116 // Vector of the filters added to the composite.
117 typedef std::vector<scoped_refptr<Filter> > FilterVector;
118 FilterVector filters_;
119
120 // Callback for the pending request.
121 // TODO: Remove callback_ when Closures are replaced by PipelineStatusCB.
122 base::Closure callback_;
123 PipelineStatusCB status_cb_;
124
125 // Time parameter for the pending Seek() request.
126 base::TimeDelta pending_seek_time_;
127
128 // Current state of this filter.
129 State state_;
130
131 // The index of the filter currently processing a request.
132 unsigned int sequence_index_;
133
134 // Message loop passed into the constructor.
135 scoped_refptr<base::MessageLoopProxy> message_loop_;
136
137 // FilterHost implementation passed to Filters owned by this
138 // object.
139 scoped_ptr<FilterHostImpl> host_impl_;
140
141 // PIPELINE_OK, or last error passed to SetError().
142 PipelineStatus status_;
143
144 base::WeakPtrFactory<CompositeFilter> weak_ptr_factory_;
145
146 DISALLOW_COPY_AND_ASSIGN(CompositeFilter);
147 };
148
149 } // namespace media
150
151 #endif // MEDIA_BASE_COMPOSITE_FILTER_H_
OLDNEW
« no previous file with comments | « media/base/clock.h ('k') | media/base/composite_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698