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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 465044: Refactor FFmpegVideoDecoder to try and generalize code common to all video decoders. (Closed)
Patch Set: Fix SCOPED_TRACE since VS faults on %zd. Created 11 years 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/filters/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_audio_decoder.cc
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index 8a7991a89fc115faf04f0ffee9dc57465804c316..884cde93f3ce4e1751b6033e03b16e2599b9078c 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -4,6 +4,7 @@
#include "media/filters/ffmpeg_audio_decoder.h"
+#include "media/base/callback.h"
#include "media/base/data_buffer.h"
#include "media/base/limits.h"
#include "media/filters/ffmpeg_common.h"
@@ -29,11 +30,16 @@ bool FFmpegAudioDecoder::IsMediaFormatSupported(const MediaFormat& format) {
mime_type::kFFmpegAudio == mime_type;
}
-bool FFmpegAudioDecoder::OnInitialize(DemuxerStream* demuxer_stream) {
+void FFmpegAudioDecoder::DoInitialize(DemuxerStream* demuxer_stream,
+ bool* success,
+ Task* done_cb) {
+ AutoTaskRunner done_runner(done_cb);
+ *success = false;
+
// Get the AVStream by querying for the provider interface.
AVStreamProvider* av_stream_provider;
if (!demuxer_stream->QueryInterface(&av_stream_provider)) {
- return false;
+ return;
}
AVStream* av_stream = av_stream_provider->GetAVStream();
@@ -48,15 +54,17 @@ bool FFmpegAudioDecoder::OnInitialize(DemuxerStream* demuxer_stream) {
bps == 0 ||
static_cast<size_t>(bps) > Limits::kMaxBPS ||
codec_context_->sample_rate == 0 ||
- static_cast<size_t>(codec_context_->sample_rate) > Limits::kMaxSampleRate)
- return false;
+ (static_cast<size_t>(codec_context_->sample_rate) >
+ Limits::kMaxSampleRate)) {
+ return;
+ }
// Serialize calls to avcodec_open().
AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
{
AutoLock auto_lock(FFmpegLock::get()->lock());
if (!codec || avcodec_open(codec_context_, codec) < 0) {
- return false;
+ return;
}
}
@@ -78,20 +86,21 @@ bool FFmpegAudioDecoder::OnInitialize(DemuxerStream* demuxer_stream) {
output_buffer_.reset(static_cast<uint8*>(av_malloc(kOutputBufferSize)));
if (!output_buffer_.get()) {
host()->SetError(PIPELINE_ERROR_OUT_OF_MEMORY);
- return false;
+ return;
}
- return true;
+ *success = true;
}
-void FFmpegAudioDecoder::OnSeek(base::TimeDelta time) {
+void FFmpegAudioDecoder::DoSeek(base::TimeDelta time, Task* done_cb) {
avcodec_flush_buffers(codec_context_);
estimated_next_timestamp_ = StreamSample::kInvalidTimestamp;
+ done_cb->Run();
+ delete done_cb;
}
-void FFmpegAudioDecoder::OnStop() {
-}
+void FFmpegAudioDecoder::DoDecode(Buffer* input, Task* done_cb) {
+ AutoTaskRunner done_runner(done_cb);
-void FFmpegAudioDecoder::OnDecode(Buffer* input) {
// Due to FFmpeg API changes we no longer have const read-only pointers.
AVPacket packet;
av_init_packet(&packet);
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | media/filters/ffmpeg_demuxer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698