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

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

Issue 6969026: Convert Filter::Seek() to use new callback system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for CR comments Created 9 years, 7 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/task.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"
(...skipping 14 matching lines...) Expand all
25 bool AddFilter(scoped_refptr<Filter> filter); 25 bool AddFilter(scoped_refptr<Filter> filter);
26 26
27 // media::Filter methods. 27 // media::Filter methods.
28 virtual void set_host(FilterHost* host); 28 virtual void set_host(FilterHost* host);
29 virtual FilterHost* host(); 29 virtual FilterHost* host();
30 virtual void Play(FilterCallback* play_callback); 30 virtual void Play(FilterCallback* play_callback);
31 virtual void Pause(FilterCallback* pause_callback); 31 virtual void Pause(FilterCallback* pause_callback);
32 virtual void Flush(FilterCallback* flush_callback); 32 virtual void Flush(FilterCallback* flush_callback);
33 virtual void Stop(FilterCallback* stop_callback); 33 virtual void Stop(FilterCallback* stop_callback);
34 virtual void SetPlaybackRate(float playback_rate); 34 virtual void SetPlaybackRate(float playback_rate);
35 virtual void Seek(base::TimeDelta time, FilterCallback* seek_callback); 35 virtual void Seek(base::TimeDelta time, const FilterStatusCB& seek_cb);
36 virtual void OnAudioRendererDisabled(); 36 virtual void OnAudioRendererDisabled();
37 37
38 protected: 38 protected:
39 virtual ~CompositeFilter(); 39 virtual ~CompositeFilter();
40 40
41 void SetError(PipelineStatus error); 41 void SetError(PipelineStatus error);
42 42
43 private: 43 private:
44 class FilterHostImpl; 44 class FilterHostImpl;
45 45
(...skipping 21 matching lines...) Expand all
67 // Start calling filters in a sequence. 67 // Start calling filters in a sequence.
68 void StartSerialCallSequence(); 68 void StartSerialCallSequence();
69 69
70 // Call filters in parallel. 70 // Call filters in parallel.
71 void StartParallelCallSequence(); 71 void StartParallelCallSequence();
72 72
73 // Call the filter based on the current value of state_. 73 // Call the filter based on the current value of state_.
74 void CallFilter(scoped_refptr<Filter>& filter, FilterCallback* callback); 74 void CallFilter(scoped_refptr<Filter>& filter, FilterCallback* callback);
75 75
76 // Calls |callback_| and then clears the reference. 76 // Calls |callback_| and then clears the reference.
77 void DispatchPendingCallback(); 77 void DispatchPendingCallback(PipelineStatus status);
78 78
79 // Gets the state to transition to given |state|. 79 // Gets the state to transition to given |state|.
80 State GetNextState(State state) const; 80 State GetNextState(State state) const;
81 81
82 // Filter callback for a serial sequence. 82 // Filter callback for a serial sequence.
83 void SerialCallback(); 83 void SerialCallback();
84 84
85 // Filter callback for a parallel sequence. 85 // Filter callback for a parallel sequence.
86 void ParallelCallback(); 86 void ParallelCallback();
87 87
88 // Called when a parallel or serial call sequence completes. 88 // Called when a parallel or serial call sequence completes.
89 void OnCallSequenceDone(); 89 void OnCallSequenceDone();
90 90
91 // Helper function for sending an error to the FilterHost. 91 // Helper function for sending an error to the FilterHost.
92 void SendErrorToHost(PipelineStatus error); 92 void SendErrorToHost(PipelineStatus error);
93 93
94 // Helper function for handling errors during call sequences.
95 void HandleError(PipelineStatus error);
96
97 // Creates a callback that can be called from any thread, but is guaranteed 94 // 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. 95 // to call the specified method on the thread associated with this filter.
99 FilterCallback* NewThreadSafeCallback(void (CompositeFilter::*method)()); 96 FilterCallback* NewThreadSafeCallback(void (CompositeFilter::*method)());
100 97
101 // Helper function used by NewThreadSafeCallback() to make sure the 98 // Helper function used by NewThreadSafeCallback() to make sure the
102 // method gets called on the right thread. 99 // method gets called on the right thread.
103 static void OnCallback(MessageLoop* message_loop, 100 static void OnCallback(MessageLoop* message_loop,
104 CancelableTask* task); 101 CancelableTask* task);
105 102
106 // Helper function that indicates whether SetError() calls can be forwarded 103 // Helper function that indicates whether SetError() calls can be forwarded
107 // to the host of this filter. 104 // to the host of this filter.
108 bool CanForwardError(); 105 bool CanForwardError();
109 106
107 // Checks to see if a Play(), Pause(), Flush(), Stop(), or Seek() operation is
108 // pending.
109 bool IsOperationPending() const;
110
111 // Called by operations that take a FilterStatusCB instead of a
112 // FilterCallback.
113 // TODO: Remove when FilterCallback goes away.
114 void OnStatusCB(FilterCallback* callback, PipelineStatus status);
115
110 // Vector of the filters added to the composite. 116 // Vector of the filters added to the composite.
111 typedef std::vector<scoped_refptr<Filter> > FilterVector; 117 typedef std::vector<scoped_refptr<Filter> > FilterVector;
112 FilterVector filters_; 118 FilterVector filters_;
113 119
114 // Callback for the pending request. 120 // Callback for the pending request.
121 // TODO: Remove callback_ when FilterCallback is removed.
115 scoped_ptr<FilterCallback> callback_; 122 scoped_ptr<FilterCallback> callback_;
123 FilterStatusCB status_cb_;
116 124
117 // Time parameter for the pending Seek() request. 125 // Time parameter for the pending Seek() request.
118 base::TimeDelta pending_seek_time_; 126 base::TimeDelta pending_seek_time_;
119 127
120 // Current state of this filter. 128 // Current state of this filter.
121 State state_; 129 State state_;
122 130
123 // The index of the filter currently processing a request. 131 // The index of the filter currently processing a request.
124 unsigned int sequence_index_; 132 unsigned int sequence_index_;
125 133
126 // Message loop passed into the constructor. 134 // Message loop passed into the constructor.
127 MessageLoop* message_loop_; 135 MessageLoop* message_loop_;
128 136
129 // FilterHost implementation passed to Filters owned by this 137 // FilterHost implementation passed to Filters owned by this
130 // object. 138 // object.
131 scoped_ptr<FilterHostImpl> host_impl_; 139 scoped_ptr<FilterHostImpl> host_impl_;
132 140
133 // PIPELINE_OK, or last error passed to SetError(). 141 // PIPELINE_OK, or last error passed to SetError().
134 PipelineStatus status_; 142 PipelineStatus status_;
135 143
136 scoped_ptr<ScopedRunnableMethodFactory<CompositeFilter> > runnable_factory_; 144 scoped_ptr<ScopedRunnableMethodFactory<CompositeFilter> > runnable_factory_;
137 145
138 DISALLOW_COPY_AND_ASSIGN(CompositeFilter); 146 DISALLOW_COPY_AND_ASSIGN(CompositeFilter);
139 }; 147 };
140 148
141 } // namespace media 149 } // namespace media
142 150
143 #endif // MEDIA_BASE_COMPOSITE_FILTER_H_ 151 #endif // MEDIA_BASE_COMPOSITE_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698