summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/base/filters.h19
-rw-r--r--media/base/mock_media_filters.h20
-rw-r--r--media/base/pipeline_impl.cc4
-rw-r--r--media/filters/audio_renderer_base.cc6
-rw-r--r--media/filters/decoder_base.h6
-rw-r--r--media/filters/ffmpeg_audio_decoder.cc4
-rw-r--r--media/filters/ffmpeg_demuxer.cc20
-rw-r--r--media/filters/ffmpeg_demuxer_unittest.cc4
-rw-r--r--media/filters/ffmpeg_video_decoder.cc2
-rw-r--r--media/filters/ffmpeg_video_decoder_unittest.cc4
-rw-r--r--media/filters/file_data_source.cc8
-rw-r--r--media/filters/video_renderer_base.cc8
12 files changed, 52 insertions, 53 deletions
diff --git a/media/base/filters.h b/media/base/filters.h
index 9fd1b2e..bc94d39 100644
--- a/media/base/filters.h
+++ b/media/base/filters.h
@@ -58,34 +58,26 @@ class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> {
public:
MediaFilter() : host_(NULL), message_loop_(NULL) {}
- // Sets the private member |host_|. This is the first method called by
+ // Sets the protected member |host_|. This is the first method called by
// the FilterHost after a filter is created. The host holds a strong
// reference to the filter. The reference held by the host is guaranteed
// to be released before the host object is destroyed by the pipeline.
- virtual void set_host(FilterHost* host) {
+ virtual void SetFilterHost(FilterHost* host) {
DCHECK(host);
DCHECK(!host_);
host_ = host;
}
- virtual FilterHost* host() {
- return host_;
- }
-
- // Sets the private member |message_loop_|, which is used by filters for
+ // Sets the protected member |message_loop_|, which is used by filters for
// processing asynchronous tasks and maintaining synchronized access to
// internal data members. The message loop should be running and exceed the
// lifetime of the filter.
- virtual void set_message_loop(MessageLoop* message_loop) {
+ virtual void SetMessageLoop(MessageLoop* message_loop) {
DCHECK(message_loop);
DCHECK(!message_loop_);
message_loop_ = message_loop;
}
- virtual MessageLoop* message_loop() {
- return message_loop_;
- }
-
// The pipeline is being stopped either as a result of an error or because
// the client called Stop().
virtual void Stop() = 0;
@@ -103,10 +95,11 @@ class MediaFilter : public base::RefCountedThreadSafe<MediaFilter> {
friend class base::RefCountedThreadSafe<MediaFilter>;
virtual ~MediaFilter() {}
- private:
+ // TODO(scherkus): make these private with public/protected accessors.
FilterHost* host_;
MessageLoop* message_loop_;
+ private:
DISALLOW_COPY_AND_ASSIGN(MediaFilter);
};
diff --git a/media/base/mock_media_filters.h b/media/base/mock_media_filters.h
index 698815f..b8749d9 100644
--- a/media/base/mock_media_filters.h
+++ b/media/base/mock_media_filters.h
@@ -105,15 +105,15 @@ class MockDataSource : public DataSource {
media_format_.SetAsString(MediaFormat::kMimeType,
mime_type::kApplicationOctetStream);
media_format_.SetAsString(MediaFormat::kURL, url);
- host()->SetTotalBytes(config_->media_total_bytes);
+ host_->SetTotalBytes(config_->media_total_bytes);
switch (config_->data_source_behavior) {
case MOCK_DATA_SOURCE_NORMAL_INIT:
- host()->InitializationComplete();
+ host_->InitializationComplete();
return true;
case MOCK_DATA_SOURCE_NEVER_INIT:
return true;
case MOCK_DATA_SOURCE_URL_ERROR_IN_INIT:
- host()->Error(PIPELINE_ERROR_URL_NOT_FOUND);
+ host_->Error(PIPELINE_ERROR_URL_NOT_FOUND);
return false;
case MOCK_DATA_SOURCE_INIT_RETURN_FALSE:
return false;
@@ -234,7 +234,7 @@ class MockDemuxer : public Demuxer {
// Implementation of Demuxer.
virtual bool Initialize(DataSource* data_source) {
- host()->InitializationComplete();
+ host_->InitializationComplete();
return true;
}
@@ -299,7 +299,7 @@ class MockAudioDecoder : public AudioDecoder {
// Implementation of AudioDecoder.
virtual bool Initialize(DemuxerStream* stream) {
- host()->InitializationComplete();
+ host_->InitializationComplete();
return true;
}
@@ -338,7 +338,7 @@ class MockAudioRenderer : public AudioRenderer {
// Implementation of AudioRenderer.
virtual bool Initialize(AudioDecoder* decoder) {
- host()->InitializationComplete();
+ host_->InitializationComplete();
return true;
}
@@ -404,7 +404,7 @@ class MockVideoDecoder : public VideoDecoder {
// Implementation of VideoDecoder.
virtual bool Initialize(DemuxerStream* stream) {
- host()->InitializationComplete();
+ host_->InitializationComplete();
return true;
}
@@ -436,7 +436,7 @@ class MockVideoDecoder : public VideoDecoder {
config_->frame_duration,
&frame);
if (!frame) {
- host()->Error(PIPELINE_ERROR_OUT_OF_MEMORY);
+ host_->Error(PIPELINE_ERROR_OUT_OF_MEMORY);
ADD_FAILURE();
} else {
mock_frame_time_ += config_->frame_duration;
@@ -475,8 +475,8 @@ class MockVideoRenderer : public VideoRenderer {
// Implementation of VideoRenderer.
virtual bool Initialize(VideoDecoder* decoder) {
- host()->SetVideoSize(config_->video_width, config_->video_height);
- host()->InitializationComplete();
+ host_->SetVideoSize(config_->video_width, config_->video_height);
+ host_->InitializationComplete();
return true;
}
diff --git a/media/base/pipeline_impl.cc b/media/base/pipeline_impl.cc
index 56a71a6..e9edc4f 100644
--- a/media/base/pipeline_impl.cc
+++ b/media/base/pipeline_impl.cc
@@ -604,7 +604,7 @@ void PipelineThread::CreateFilter(FilterFactory* filter_factory,
NOTREACHED() << "Could not start filter thread";
Error(PIPELINE_ERROR_INITIALIZATION_FAILED);
} else {
- filter->set_message_loop(thread->message_loop());
+ filter->SetMessageLoop(thread->message_loop());
filter_threads_.push_back(thread.release());
}
}
@@ -612,7 +612,7 @@ void PipelineThread::CreateFilter(FilterFactory* filter_factory,
// Creating a thread could have failed, verify we're still OK.
if (IsPipelineOk()) {
filter_hosts_.push_back(host.get());
- filter->set_host(host.release());
+ filter->SetFilterHost(host.release());
if (!filter->Initialize(source)) {
Error(PIPELINE_ERROR_INITIALIZATION_FAILED);
}
diff --git a/media/filters/audio_renderer_base.cc b/media/filters/audio_renderer_base.cc
index ba52fe0..43f79ca 100644
--- a/media/filters/audio_renderer_base.cc
+++ b/media/filters/audio_renderer_base.cc
@@ -89,10 +89,10 @@ void AudioRendererBase::OnReadComplete(Buffer* buffer_in) {
if (queue_.empty()) {
// If we say we have initialized but buffer queue is empty, raise an
// error.
- host()->Error(PIPELINE_ERROR_NO_DATA);
+ host_->Error(PIPELINE_ERROR_NO_DATA);
} else {
initialized_ = true;
- host()->InitializationComplete();
+ host_->InitializationComplete();
}
}
}
@@ -210,7 +210,7 @@ size_t AudioRendererBase::FillBuffer(uint8* dest,
// finer time update events.
if (playback_delay < last_fill_buffer_time)
last_fill_buffer_time -= playback_delay;
- host()->SetTime(last_fill_buffer_time);
+ host_->SetTime(last_fill_buffer_time);
}
return dest_written;
diff --git a/media/filters/decoder_base.h b/media/filters/decoder_base.h
index c448447..b36a9b8 100644
--- a/media/filters/decoder_base.h
+++ b/media/filters/decoder_base.h
@@ -116,6 +116,12 @@ class DecoderBase : public Decoder {
MediaFormat media_format_;
private:
+ // GCC doesn't let us access superclass member variables directly, so use
+ // a helper to get around the situation.
+ //
+ // TODO(scherkus): another reason to add protected accessors to MediaFilter.
+ FilterHost* host() const { return Decoder::host_; }
+ MessageLoop* message_loop() const { return Decoder::message_loop_; }
bool IsStopped() { return state_ == STOPPED; }
void StopTask() {
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index 5d9e3c1..12e7be8 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -67,7 +67,7 @@ bool FFmpegAudioDecoder::OnInitialize(DemuxerStream* demuxer_stream) {
// Prepare the output buffer.
output_buffer_.reset(static_cast<uint8*>(av_malloc(kOutputBufferSize)));
if (!output_buffer_.get()) {
- host()->Error(PIPELINE_ERROR_OUT_OF_MEMORY);
+ host_->Error(PIPELINE_ERROR_OUT_OF_MEMORY);
return false;
}
return true;
@@ -101,7 +101,7 @@ void FFmpegAudioDecoder::OnDecode(Buffer* input) {
if (result < 0 ||
output_buffer_size < 0 ||
static_cast<size_t>(output_buffer_size) > kOutputBufferSize) {
- host()->Error(PIPELINE_ERROR_DECODE);
+ host_->Error(PIPELINE_ERROR_DECODE);
return;
}
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index c12e0ad..00a2fbd 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -156,7 +156,7 @@ const MediaFormat& FFmpegDemuxerStream::media_format() {
void FFmpegDemuxerStream::Read(Callback1<Buffer*>::Type* read_callback) {
DCHECK(read_callback);
- demuxer_->message_loop()->PostTask(FROM_HERE,
+ demuxer_->message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &FFmpegDemuxerStream::ReadTask, read_callback));
}
@@ -252,13 +252,13 @@ FFmpegDemuxer::~FFmpegDemuxer() {
}
void FFmpegDemuxer::PostDemuxTask() {
- message_loop()->PostTask(FROM_HERE,
+ message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &FFmpegDemuxer::DemuxTask));
}
void FFmpegDemuxer::Stop() {
// Post a task to notify the streams to stop as well.
- message_loop()->PostTask(FROM_HERE,
+ message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &FFmpegDemuxer::StopTask));
}
@@ -267,12 +267,12 @@ void FFmpegDemuxer::Seek(base::TimeDelta time) {
// operation is completed and filters behind the demuxer is good to issue
// more reads, but we are posting a task here, which makes the seek operation
// asynchronous, should change how seek works to make it fully asynchronous.
- message_loop()->PostTask(FROM_HERE,
+ message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &FFmpegDemuxer::SeekTask, time));
}
bool FFmpegDemuxer::Initialize(DataSource* data_source) {
- message_loop()->PostTask(FROM_HERE,
+ message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(this, &FFmpegDemuxer::InititalizeTask, data_source));
return true;
}
@@ -313,7 +313,7 @@ void FFmpegDemuxer::InititalizeTask(DataSource* data_source) {
FFmpegGlue::get()->RemoveDataSource(data_source);
if (result < 0) {
- host()->Error(DEMUXER_ERROR_COULD_NOT_OPEN);
+ host_->Error(DEMUXER_ERROR_COULD_NOT_OPEN);
return;
}
@@ -327,7 +327,7 @@ void FFmpegDemuxer::InititalizeTask(DataSource* data_source) {
// Fully initialize AVFormatContext by parsing the stream a little.
result = av_find_stream_info(format_context_);
if (result < 0) {
- host()->Error(DEMUXER_ERROR_COULD_NOT_PARSE);
+ host_->Error(DEMUXER_ERROR_COULD_NOT_PARSE);
return;
}
}
@@ -349,13 +349,13 @@ void FFmpegDemuxer::InititalizeTask(DataSource* data_source) {
}
}
if (streams_.empty()) {
- host()->Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS);
+ host_->Error(DEMUXER_ERROR_NO_SUPPORTED_STREAMS);
return;
}
// Good to go: set the duration and notify we're done initializing.
- host()->SetDuration(max_duration);
- host()->InitializationComplete();
+ host_->SetDuration(max_duration);
+ host_->InitializationComplete();
}
void FFmpegDemuxer::SeekTask(base::TimeDelta time) {
diff --git a/media/filters/ffmpeg_demuxer_unittest.cc b/media/filters/ffmpeg_demuxer_unittest.cc
index a8e3498..dc21c49 100644
--- a/media/filters/ffmpeg_demuxer_unittest.cc
+++ b/media/filters/ffmpeg_demuxer_unittest.cc
@@ -67,8 +67,8 @@ class FFmpegDemuxerTest : public testing::Test {
DCHECK(demuxer_);
// Inject a filter host and message loop and prepare a data source.
- demuxer_->set_filter_host(&host_);
- demuxer_->set_message_loop(&message_loop_);
+ demuxer_->SetFilterHost(&host_);
+ demuxer_->SetMessageLoop(&message_loop_);
data_source_ = new StrictMock<MockDataSource>();
// Initialize FFmpeg fixtures.
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index c396c00..6423db4 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -337,7 +337,7 @@ VideoSurface::Format FFmpegVideoDecoder::GetSurfaceFormat(
}
void FFmpegVideoDecoder::SignalPipelineError() {
- host()->Error(PIPELINE_ERROR_DECODE);
+ host_->Error(PIPELINE_ERROR_DECODE);
state_ = kDecodeFinished;
}
diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc
index 23e73c9..fca238e 100644
--- a/media/filters/ffmpeg_video_decoder_unittest.cc
+++ b/media/filters/ffmpeg_video_decoder_unittest.cc
@@ -79,8 +79,8 @@ class FFmpegVideoDecoderTest : public testing::Test {
DCHECK(decoder_);
// Inject a filter host and message loop and prepare a demuxer stream.
- decoder_->set_filter_host(&host_);
- decoder_->set_message_loop(&message_loop_);
+ decoder_->SetFilterHost(&host_);
+ decoder_->SetMessageLoop(&message_loop_);
demuxer_ = new StrictMock<MockFFmpegDemuxerStream>();
// Manually set the thread id for tests that don't initialize the decoder.
diff --git a/media/filters/file_data_source.cc b/media/filters/file_data_source.cc
index 2e13a59..bdab8fb 100644
--- a/media/filters/file_data_source.cc
+++ b/media/filters/file_data_source.cc
@@ -32,15 +32,15 @@ bool FileDataSource::Initialize(const std::string& url) {
}
if (!file_) {
file_size_ = 0;
- host()->Error(PIPELINE_ERROR_URL_NOT_FOUND);
+ host_->Error(PIPELINE_ERROR_URL_NOT_FOUND);
return false;
}
media_format_.SetAsString(MediaFormat::kMimeType,
mime_type::kApplicationOctetStream);
media_format_.SetAsString(MediaFormat::kURL, url);
- host()->SetTotalBytes(file_size_);
- host()->SetBufferedBytes(file_size_);
- host()->InitializationComplete();
+ host_->SetTotalBytes(file_size_);
+ host_->SetBufferedBytes(file_size_);
+ host_->InitializationComplete();
return true;
}
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index 7eace6f..094c92a 100644
--- a/media/filters/video_renderer_base.cc
+++ b/media/filters/video_renderer_base.cc
@@ -104,7 +104,7 @@ bool VideoRendererBase::Initialize(VideoDecoder* decoder) {
int height = 0;
if (!ParseMediaFormat(decoder->media_format(), &width, &height))
return false;
- host()->SetVideoSize(width, height);
+ host_->SetVideoSize(width, height);
// Initialize the subclass.
// TODO(scherkus): do we trust subclasses not to do something silly while
@@ -188,7 +188,7 @@ void VideoRendererBase::ThreadMain() {
OnFrameAvailable();
// Determine the current and next presentation timestamps.
- base::TimeDelta now = host()->GetTime();
+ base::TimeDelta now = host_->GetTime();
base::TimeDelta this_pts = current_frame_->GetTimestamp();
base::TimeDelta next_pts;
if (next_frame) {
@@ -248,11 +248,11 @@ void VideoRendererBase::OnReadComplete(VideoFrame* frame) {
if (frames_.empty()) {
// We should have initialized but there's no decoded frames in the queue.
// Raise an error.
- host()->Error(PIPELINE_ERROR_NO_DATA);
+ host_->Error(PIPELINE_ERROR_NO_DATA);
} else {
state_ = INITIALIZED;
current_frame_ = frames_.front();
- host()->InitializationComplete();
+ host_->InitializationComplete();
}
}
}