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

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: 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 ebda8c00594cc948e3fb528e85b4c1ee2f05d1ff..37711bdcee08fdb52dc740ed1272192115972c9d 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,7 +100,8 @@ void DecoderStream<StreamType>::Read(const ReadCB& read_cb) {
return;
}
- ReadFromDemuxerStream();
+ if (!SendQueuedOutput())
+ ReadFromDemuxerStream();
}
template <DemuxerStream::Type StreamType>
@@ -185,6 +191,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 +331,7 @@ void DecoderStream<StreamType>::OnDecodeOutputReady(
return;
}
+ DCHECK(output);
SatisfyRead(OK, output);
}
@@ -336,6 +349,21 @@ void DecoderStream<StreamType>::ReadFromDemuxerStream() {
}
template <DemuxerStream::Type StreamType>
+bool DecoderStream<StreamType>::SendQueuedOutput() {
+ return false;
+}
+
+template <>
+bool DecoderStream<DemuxerStream::AUDIO>::SendQueuedOutput() {
xhwang 2014/02/27 19:52:28 The name "SendQueuedOutput" is a bit odd. How abou
+ AudioDecoder::Status status;
+ if (scoped_refptr<AudioBuffer> buffer = decoder_->GetAudioBuffer(&status)) {
+ OnDecodeOutputReady(0, status, buffer);
xhwang 2014/02/27 19:52:28 since the first parameter is always 0, how about c
+ return true;
+ }
+ return false;
+}
+
+template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnBufferReady(
DemuxerStream::Status status,
const scoped_refptr<DecoderBuffer>& buffer) {
@@ -387,12 +415,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,4 +518,5 @@ 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