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

Unified Diff: media/filters/decoder_stream.cc

Issue 141243003: Add AudioBufferStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decoderstream_rebased
Patch Set: address comments Created 6 years, 10 months 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
Index: media/filters/decoder_stream.cc
diff --git a/media/filters/decoder_stream.cc b/media/filters/decoder_stream.cc
index 5c02547a2309e2b163ac242da56b7638b160c8d1..291af439a62428950005291de1ad3f495966af92 100644
--- a/media/filters/decoder_stream.cc
+++ b/media/filters/decoder_stream.cc
@@ -10,6 +10,7 @@
#include "base/location.h"
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
+#include "media/base/audio_decoder.h"
#include "media/base/bind_to_current_loop.h"
#include "media/base/decoder_buffer.h"
#include "media/base/demuxer_stream.h"
@@ -28,6 +29,11 @@ const char* GetTraceString<DemuxerStream::VIDEO>() {
return "DecoderStream<VIDEO>::Decode";
}
+template <>
+const char* GetTraceString<DemuxerStream::AUDIO>() {
+ return "DecoderStream<AUDIO>::Decode";
+}
+
template <DemuxerStream::Type StreamType>
DecoderStream<StreamType>::DecoderStream(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
@@ -65,7 +71,6 @@ void DecoderStream<StreamType>::Initialize(DemuxerStream* stream,
// TODO(xhwang): DecoderSelector only needs a config to select a decoder.
decoder_selector_->SelectDecoder(
stream,
- StatisticsCB(),
base::Bind(&DecoderStream<StreamType>::OnDecoderSelected,
weak_factory_.GetWeakPtr()));
}
@@ -95,6 +100,12 @@ void DecoderStream<StreamType>::Read(const ReadCB& read_cb) {
return;
}
+ // If the decoder has queued output ready to go we don't need a demuxer read.
+ if (scoped_refptr<Output> output = decoder_->GetDecodeOutput()) {
xhwang 2014/03/05 00:40:46 This is neat, but I am not sure whether it's more
rileya (GONE FROM CHROMIUM) 2014/03/05 08:08:28 Done.
+ SatisfyRead(OK, output);
xhwang 2014/03/05 00:40:46 Can we add a unit test to cover this logic?
rileya (GONE FROM CHROMIUM) 2014/03/05 08:08:28 Sounds good, will do.
rileya (GONE FROM CHROMIUM) 2014/03/06 22:11:56 Done. There's currently no tests for DecoderStream
+ return;
+ }
+
ReadFromDemuxerStream();
}
@@ -185,6 +196,12 @@ bool DecoderStream<StreamType>::CanReadWithoutStalling() const {
return decoder_->CanReadWithoutStalling();
}
+template <>
+bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ return true;
+}
+
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnDecoderSelected(
scoped_ptr<Decoder> selected_decoder,
@@ -319,6 +336,7 @@ void DecoderStream<StreamType>::OnDecodeOutputReady(
return;
}
+ DCHECK(output);
SatisfyRead(OK, output);
}
@@ -387,12 +405,10 @@ void DecoderStream<StreamType>::ReinitializeDecoder() {
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK_EQ(state_, STATE_FLUSHING_DECODER) << state_;
- // TODO(rileya): Specialize this for audio, or, better yet, change
- // DemuxerStream config getters to be templated.
- DCHECK(stream_->video_decoder_config().IsValidConfig());
+ DCHECK(StreamTraits::GetDecoderConfig(*stream_).IsValidConfig());
state_ = STATE_REINITIALIZING_DECODER;
decoder_->Initialize(
- stream_->video_decoder_config(),
+ StreamTraits::GetDecoderConfig(*stream_),
base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized,
weak_factory_.GetWeakPtr()));
}
@@ -492,5 +508,6 @@ void DecoderStream<StreamType>::OnDecoderStopped() {
}
template class DecoderStream<DemuxerStream::VIDEO>;
+template class DecoderStream<DemuxerStream::AUDIO>;
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698