summaryrefslogtreecommitdiffstats
path: root/webkit/glue/media/simple_data_source.cc
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 21:37:17 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-22 21:37:17 +0000
commit8e296bbd2d147c270d1839ab9dd93418532322e5 (patch)
tree250887882d757ad020aba85af7db935c4107a105 /webkit/glue/media/simple_data_source.cc
parent944a14b8d46e63e603850c6c8b0d0638dc492a14 (diff)
downloadchromium_src-8e296bbd2d147c270d1839ab9dd93418532322e5.zip
chromium_src-8e296bbd2d147c270d1839ab9dd93418532322e5.tar.gz
chromium_src-8e296bbd2d147c270d1839ab9dd93418532322e5.tar.bz2
Changes to provide asynchronous read in data source:
1. FFmpegGlue now taks a FFmpegProtocol instead of DataSource as input 2. FFmpegDemuxr implements FFmpegProtocol and does the blocking read and submit asynchronous read request to DataSource (with unit tests) 3. Changed SimpleDataSource to work with asynchronous read (with unit tests) 4. Reimplemented BufferedDataSource to work with asynchronous read (with unit tests) 5. Moved BufferedDataSource from chrome/renderer/media to webkit/glue/media (for faster build/debug and better coverage in automated testing) TEST=BufferedDataSourceTest.*, SimpleDataSourceTest.*, FFmpegDemuxerTest.* Review URL: http://codereview.chromium.org/149567 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media/simple_data_source.cc')
-rw-r--r--webkit/glue/media/simple_data_source.cc31
1 files changed, 13 insertions, 18 deletions
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index f426a14..27d286e 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -36,7 +36,6 @@ SimpleDataSource::SimpleDataSource(
: render_loop_(render_loop),
bridge_factory_(bridge_factory),
size_(-1),
- position_(0),
state_(UNINITIALIZED) {
DCHECK(render_loop);
}
@@ -81,24 +80,20 @@ const media::MediaFormat& SimpleDataSource::media_format() {
return media_format_;
}
-size_t SimpleDataSource::Read(uint8* data, size_t size) {
+void SimpleDataSource::Read(int64 position,
+ size_t size,
+ uint8* data,
+ ReadCallback* read_callback) {
DCHECK_GE(size_, 0);
- size_t copied = std::min(size, static_cast<size_t>(size_ - position_));
- memcpy(data, data_.c_str() + position_, copied);
- position_ += copied;
- return copied;
-}
-
-bool SimpleDataSource::GetPosition(int64* position_out) {
- *position_out = position_;
- return true;
-}
-
-bool SimpleDataSource::SetPosition(int64 position) {
- if (position < 0 || position > size_)
- return false;
- position_ = position;
- return true;
+ if (position >= size_) {
+ read_callback->RunWithParams(Tuple1<size_t>(0));
+ delete read_callback;
+ } else {
+ size_t copied = std::min(size, static_cast<size_t>(size_ - position));
+ memcpy(data, data_.c_str() + position, copied);
+ read_callback->RunWithParams(Tuple1<size_t>(copied));
+ delete read_callback;
+ }
}
bool SimpleDataSource::GetSize(int64* size_out) {