summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorralphl@chromium.org <ralphl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 23:53:50 +0000
committerralphl@chromium.org <ralphl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-04 23:53:50 +0000
commit90f6e2e8b787268630fcecddd7542e1bfb587ab3 (patch)
tree57799e04f1c96f90fc6a83a2ce03d66399d62bda /chrome
parent57f60991a561d3b3a53cf00ce2878f6b1d4bf223 (diff)
downloadchromium_src-90f6e2e8b787268630fcecddd7542e1bfb587ab3.zip
chromium_src-90f6e2e8b787268630fcecddd7542e1bfb587ab3.tar.gz
chromium_src-90f6e2e8b787268630fcecddd7542e1bfb587ab3.tar.bz2
Changed several references from "char" to "uint8" which is the appropriate definition for byte data buffers.
This change is small, but modifies the data source interface Read() method, and the VideoSurface data structure. Mocks and tests all have very small changes. There are some changes in the mock_media_filters.h file that go beyond the scope of just changing char to uint8. These changes are required for future tests, and simply fill in parts of mocks that previously were NOTIMPLEMENTED(). The MockVideoFrame was modified to allow other tests to create a video frame directly without using the MockFilterConfiguration data structure. Also, it is now possible to construct a mock pipeline that has no audio. The currently checked-in pipeline will NOT work if you don't have audio. In a 2nd changelist, I will submit a new Pipeline_Impl and unit test that DOES support video without audio. Review URL: http://codereview.chromium.org/40059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10940 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/renderer/media/data_source_impl.cc28
-rw-r--r--chrome/renderer/media/data_source_impl.h4
2 files changed, 17 insertions, 15 deletions
diff --git a/chrome/renderer/media/data_source_impl.cc b/chrome/renderer/media/data_source_impl.cc
index 3b8af52..5e97a80 100644
--- a/chrome/renderer/media/data_source_impl.cc
+++ b/chrome/renderer/media/data_source_impl.cc
@@ -45,7 +45,7 @@ void DataSourceImpl::Stop() {
// Post a close file stream task to IO message loop, it will signal the read
// event.
io_loop_->PostTask(
- FROM_HERE,NewRunnableMethod(this, &DataSourceImpl::OnCloseFileStream));
+ FROM_HERE, NewRunnableMethod(this, &DataSourceImpl::OnCloseFileStream));
// Wait for close to finish for FileStream.
close_event_.Wait();
@@ -61,14 +61,14 @@ bool DataSourceImpl::Initialize(const std::string& url) {
// We should get a call back at OnReceivedResponse().
media_format_.SetAsString(media::MediaFormat::kMimeType,
media::mime_type::kApplicationOctetStream);
- media_format_.SetAsString(media::MediaFormat::kURL, url);
+ media_format_.SetAsString(media::MediaFormat::kURL, url);
return true;
}
-size_t DataSourceImpl::Read(char* data, size_t size) {
+size_t DataSourceImpl::Read(uint8* data, size_t size) {
DCHECK(stream_.get());
// Wait until we have downloaded the requested bytes.
- while(!stopped_) {
+ while (!stopped_) {
{
AutoLock auto_lock(lock_);
if (position_ + size <= downloaded_bytes_)
@@ -99,7 +99,7 @@ bool DataSourceImpl::GetPosition(int64* position_out) {
bool DataSourceImpl::SetPosition(int64 position) {
DCHECK(stream_.get());
- while(!stopped_) {
+ while (!stopped_) {
{
AutoLock auto_lock(lock_);
if (position < downloaded_bytes_)
@@ -142,17 +142,19 @@ void DataSourceImpl::OnCreateFileStream(base::PlatformFile file) {
host_->InitializationComplete();
}
-void DataSourceImpl::OnReadFileStream(char* data, size_t size) {
+void DataSourceImpl::OnReadFileStream(uint8* data, size_t size) {
if (!stopped_ && stream_.get()) {
+ // net::FileStream::Read wants a char*, not uint8*.
+ char* c_data = reinterpret_cast<char*>(data);
+ COMPILE_ASSERT(sizeof(*c_data) == sizeof(*data), data_not_sizeof_char);
+
// This method IO operation is asynchronous, it is expected to return
// ERROR_IO_PENDING, when the operation is done, OnDidFileStreamRead() will
- // be called.
- int rv = stream_->Read(data, size, &read_callback_);
-
- // Since the file handle is asynchronous, return value other than
- // ERROR_IO_PENDING is an error.
- if (rv != net::ERR_IO_PENDING) {
- // TODO(hclam): using something like PipelineError::PIPELINE_READ_ERROR.
+ // be called. Since the file handle is asynchronous, return value other
+ // than ERROR_IO_PENDING is an error.
+ if (stream_->Read(c_data, size, &read_callback_) != net::ERR_IO_PENDING) {
+ // TODO(hclam): change to PipelineError::PIPELINE_ERROR_READ once ralphl
+ // gets the new pipeline CL checked in.
host_->Error(media::PIPELINE_ERROR_NETWORK);
}
}
diff --git a/chrome/renderer/media/data_source_impl.h b/chrome/renderer/media/data_source_impl.h
index e62bcd9..95e8090 100644
--- a/chrome/renderer/media/data_source_impl.h
+++ b/chrome/renderer/media/data_source_impl.h
@@ -102,7 +102,7 @@ class DataSourceImpl : public media::DataSource {
// Methods called from demuxer thread ---------------------------------------
// media::DataSource implementation.
- virtual size_t Read(char* data, size_t size);
+ virtual size_t Read(uint8* data, size_t size);
virtual bool GetPosition(int64* position_out);
virtual bool SetPosition(int64 position);
virtual bool GetSize(int64* size_out);
@@ -120,7 +120,7 @@ class DataSourceImpl : public media::DataSource {
// Methods called from IO thread --------------------------------------------
// Handlers for file reading.
void OnCreateFileStream(base::PlatformFile file);
- void OnReadFileStream(char* data, size_t size);
+ void OnReadFileStream(uint8* data, size_t size);
void OnCloseFileStream();
void OnSeekFileStream(net::Whence whence, int64 position);
void OnDidFileStreamRead(int size);