summaryrefslogtreecommitdiffstats
path: root/media/base
diff options
context:
space:
mode:
authorralphl@chromium.org <ralphl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 19:51:00 +0000
committerralphl@chromium.org <ralphl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 19:51:00 +0000
commit44d568ec954287a29ff14ae3f2217b7ec534e49f (patch)
treed068c196197eb82303b938aa3d1b35f480d2a466 /media/base
parent000b6ee0af3d7b362f812352cc2adcdbf4a2c51f (diff)
downloadchromium_src-44d568ec954287a29ff14ae3f2217b7ec534e49f.zip
chromium_src-44d568ec954287a29ff14ae3f2217b7ec534e49f.tar.gz
chromium_src-44d568ec954287a29ff14ae3f2217b7ec534e49f.tar.bz2
Decoders now use standard callback mechanism for Reads. Removed Assignable<> template.
Also includes an update that should provide more accurate timing from the audio renderer. Review URL: http://codereview.chromium.org/55031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12796 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r--media/base/buffers.h54
-rw-r--r--media/base/filters.h12
-rw-r--r--media/base/mock_media_filters.h15
3 files changed, 12 insertions, 69 deletions
diff --git a/media/base/buffers.h b/media/base/buffers.h
index 901a8a2..d600289 100644
--- a/media/base/buffers.h
+++ b/media/base/buffers.h
@@ -177,60 +177,6 @@ class VideoFrame : public StreamSample {
virtual void Unlock() = 0;
};
-
-// An interface for receiving the results of an asynchronous read. Downstream
-// filters typically implement this interface or use AssignableBuffer and
-// provide it to upstream filters as a read request. When the upstream filter
-// has completed the read, they call SetBuffer/OnAssignment to notify the
-// downstream filter.
-//
-// TODO(scherkus): rethink the Assignable interface -- it's a bit kludgy.
-template <class BufferType>
-class Assignable
- : public base::RefCountedThreadSafe< Assignable<BufferType> > {
- public:
- // Assigns a buffer to the owner.
- virtual void SetBuffer(BufferType* buffer) = 0;
-
- // Notifies the owner that an assignment has been completed.
- virtual void OnAssignment() = 0;
-
- // TODO(scherkus): figure out a solution to friending a template.
- // See http://www.comeaucomputing.com/techtalk/templates/#friendclassT for
- // an explanation.
- // protected:
- // friend class base::RefCountedThreadSafe< Assignable<class T> >;
- virtual ~Assignable() {}
-};
-
-
-// Template for easily creating Assignable buffers. Pass in the pointer of the
-// object to receive the OnAssignment callback.
-template <class OwnerType, class BufferType>
-class AssignableBuffer : public Assignable<BufferType> {
- public:
- explicit AssignableBuffer(OwnerType* owner)
- : owner_(owner),
- buffer_(NULL) {
- DCHECK(owner_);
- }
-
- // AssignableBuffer<BufferType> implementation.
- virtual void SetBuffer(BufferType* buffer) {
- buffer_ = buffer;
- }
-
- virtual void OnAssignment() {
- owner_->OnAssignment(buffer_.get());
- }
-
- private:
- OwnerType* owner_;
- scoped_refptr<BufferType> buffer_;
-
- DISALLOW_COPY_AND_ASSIGN(AssignableBuffer);
-};
-
} // namespace media
#endif // MEDIA_BASE_BUFFERS_H_
diff --git a/media/base/filters.h b/media/base/filters.h
index e36d81a..6d2b17e 100644
--- a/media/base/filters.h
+++ b/media/base/filters.h
@@ -4,8 +4,7 @@
// Filters are connected in a strongly typed manner, with downstream filters
// always reading data from upstream filters. Upstream filters have no clue
-// who is actually reading from them, and return the results via OnAssignment
-// using the AssignableInterface<SomeBufferType> interface:
+// who is actually reading from them, and return the results via callbacks.
//
// DemuxerStream(Video) <- VideoDecoder <- VideoRenderer
// DataSource <- Demuxer <
@@ -35,7 +34,6 @@
namespace media {
-template <class TBuffer> class Assignable;
class Buffer;
class Decoder;
class DemuxerStream;
@@ -202,8 +200,8 @@ class VideoDecoder : public MediaFilter {
// Returns the MediaFormat for this filter.
virtual const MediaFormat& media_format() = 0;
- // Schedules a read and takes ownership of the given buffer.
- virtual void Read(Assignable<VideoFrame>* video_frame) = 0;
+ // Schedules a read. Decoder takes ownership of the callback.
+ virtual void Read(Callback1<VideoFrame*>::Type* read_callback) = 0;
};
@@ -223,8 +221,8 @@ class AudioDecoder : public MediaFilter {
// Returns the MediaFormat for this filter.
virtual const MediaFormat& media_format() = 0;
- // Schedules a read and takes ownership of the given buffer.
- virtual void Read(Assignable<Buffer>* buffer) = 0;
+ // Schedules a read. Decoder takes ownership of the callback.
+ virtual void Read(Callback1<Buffer*>::Type* read_callbasck) = 0;
};
diff --git a/media/base/mock_media_filters.h b/media/base/mock_media_filters.h
index 1f7af93..fef7938 100644
--- a/media/base/mock_media_filters.h
+++ b/media/base/mock_media_filters.h
@@ -321,7 +321,7 @@ class MockAudioDecoder : public AudioDecoder {
return media_format_;
}
- virtual void Read(Assignable<Buffer>* buffer) {
+ virtual void Read(Callback1<Buffer*>::Type* callback) {
// TODO(ralphl): implement mock read.
NOTREACHED();
}
@@ -429,15 +429,16 @@ class MockVideoDecoder : public VideoDecoder {
return media_format_;
}
- virtual void Read(Assignable<VideoFrame>* buffer) {
- buffer->AddRef();
- host_->PostTask(NewRunnableMethod(this, &MockVideoDecoder::DoRead, buffer));
+ virtual void Read(Callback1<VideoFrame*>::Type* callback) {
+ host_->PostTask(NewRunnableMethod(
+ this, &MockVideoDecoder::DoRead, callback));
}
private:
virtual ~MockVideoDecoder() {}
- void DoRead(Assignable<VideoFrame>* buffer) {
+ void DoRead(Callback1<VideoFrame*>::Type* callback) {
+ scoped_ptr<Callback1<VideoFrame*>::Type> scoped_callback(callback);
if (mock_frame_time_ < config_->media_duration) {
// TODO(ralphl): Mock video decoder only works with YV12. Implement other
// formats as needed.
@@ -459,11 +460,9 @@ class MockVideoDecoder : public VideoDecoder {
}
InitializeYV12Frame(frame, (mock_frame_time_.InSecondsF() /
config_->media_duration.InSecondsF()));
- buffer->SetBuffer(frame);
- buffer->OnAssignment();
+ callback->Run(frame);
}
}
- buffer->Release();
}
MediaFormat media_format_;