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

Unified Diff: media/base/filters.h

Issue 155469: Splitting media filter's Initialize() into Create() + callback and Seek() + callback. (Closed)
Patch Set: Fixed valgrind errors Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/filter_host_impl.cc ('k') | media/base/mock_filters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/filters.h
diff --git a/media/base/filters.h b/media/base/filters.h
index b892961aaf5473729857d5f1544de22b000af730..84df0966534fe5d83796d6780d0c4c89d38e14e6 100644
--- a/media/base/filters.h
+++ b/media/base/filters.h
@@ -53,6 +53,8 @@ enum FilterType {
FILTER_VIDEO_RENDERER
};
+// Used for completing asynchronous methods.
+typedef Callback0::Type FilterCallback;
class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> {
public:
@@ -94,9 +96,14 @@ class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> {
// method if they need to respond to this call.
virtual void SetPlaybackRate(float playback_rate) {}
- // The pipeline is seeking to the specified time. Filters may implement
- // this method if they need to respond to this call.
- virtual void Seek(base::TimeDelta time) {}
+ // Carry out any actions required to seek to the given time, executing the
+ // callback upon completion.
+ virtual void Seek(base::TimeDelta time, FilterCallback* callback) {
+ scoped_ptr<FilterCallback> seek_callback(callback);
+ if (seek_callback.get()) {
+ seek_callback->Run();
+ }
+ }
protected:
// Only allow scoped_refptr<> to delete filters.
@@ -128,8 +135,9 @@ class DataSource : public MediaFilter {
static const size_t kReadError = static_cast<size_t>(-1);
- // Initializes this filter, returns true if successful, false otherwise.
- virtual bool Initialize(const std::string& url) = 0;
+ // Initialize a DataSource for the given URL, executing the callback upon
+ // completion.
+ virtual void Initialize(const std::string& url, FilterCallback* callback) = 0;
// Returns the MediaFormat for this filter.
virtual const MediaFormat& media_format() = 0;
@@ -166,8 +174,10 @@ class Demuxer : public MediaFilter {
mime_type == mime_type::kApplicationOctetStream);
}
- // Initializes this filter, returns true if successful, false otherwise.
- virtual bool Initialize(DataSource* data_source) = 0;
+ // Initialize a Demuxer with the given DataSource, executing the callback upon
+ // completion.
+ virtual void Initialize(DataSource* data_source,
+ FilterCallback* callback) = 0;
// Returns the number of streams available
virtual size_t GetNumberOfStreams() = 0;
@@ -223,8 +233,9 @@ class VideoDecoder : public MediaFilter {
return mime_type::kMajorTypeVideo;
}
- // Initializes this filter, returns true if successful, false otherwise.
- virtual bool Initialize(DemuxerStream* demuxer_stream) = 0;
+ // Initialize a VideoDecoder with the given DemuxerStream, executing the
+ // callback upon completion.
+ virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0;
// Returns the MediaFormat for this filter.
virtual const MediaFormat& media_format() = 0;
@@ -246,8 +257,9 @@ class AudioDecoder : public MediaFilter {
return mime_type::kMajorTypeAudio;
}
- // Initializes this filter, returns true if successful, false otherwise.
- virtual bool Initialize(DemuxerStream* demuxer_stream) = 0;
+ // Initialize a AudioDecoder with the given DemuxerStream, executing the
+ // callback upon completion.
+ virtual void Initialize(DemuxerStream* stream, FilterCallback* callback) = 0;
// Returns the MediaFormat for this filter.
virtual const MediaFormat& media_format() = 0;
@@ -269,8 +281,9 @@ class VideoRenderer : public MediaFilter {
return mime_type::kMajorTypeVideo;
}
- // Initializes this filter, returns true if successful, false otherwise.
- virtual bool Initialize(VideoDecoder* decoder) = 0;
+ // Initialize a VideoRenderer with the given VideoDecoder, executing the
+ // callback upon completion.
+ virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback) = 0;
};
@@ -284,8 +297,9 @@ class AudioRenderer : public MediaFilter {
return mime_type::kMajorTypeAudio;
}
- // Initializes this filter, returns true if successful, false otherwise.
- virtual bool Initialize(AudioDecoder* decoder) = 0;
+ // Initialize a AudioRenderer with the given AudioDecoder, executing the
+ // callback upon completion.
+ virtual void Initialize(AudioDecoder* decoder, FilterCallback* callback) = 0;
// Sets the output volume.
virtual void SetVolume(float volume) = 0;
« no previous file with comments | « media/base/filter_host_impl.cc ('k') | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698