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

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: add TODOs 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..40ce25453bb3a8f59c3850e6136d27b50217fdd5 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()));
}
@@ -319,6 +324,7 @@ void DecoderStream<StreamType>::OnDecodeOutputReady(
return;
}
+ DCHECK(output);
SatisfyRead(OK, output);
}
@@ -335,6 +341,25 @@ void DecoderStream<StreamType>::ReadFromDemuxerStream() {
weak_factory_.GetWeakPtr()));
}
+template <>
+void DecoderStream<DemuxerStream::AUDIO>::ReadFromDemuxerStream() {
+ DVLOG(2) << __FUNCTION__;
+ DCHECK_EQ(state_, STATE_NORMAL) << state_;
+ DCHECK(!read_cb_.is_null());
+ DCHECK(reset_cb_.is_null());
+ DCHECK(stop_cb_.is_null());
+ DCHECK(decoder_);
+
+ if (decoder_->HasQueuedData()) {
+ Decode(NULL);
DaleCurtis 2014/02/21 21:48:48 Won't this happen naturally as the decoder is drai
rileya (GONE FROM CHROMIUM) 2014/02/21 23:04:02 I just realized how unintuitive this looks now, ha
xhwang 2014/02/21 23:57:56 Some random ideas: 1, See comment above, if you h
rileya (GONE FROM CHROMIUM) 2014/02/24 21:04:11 1) Sounds good, done. 2) Yup, this was originally
rileya (GONE FROM CHROMIUM) 2014/02/24 21:07:50 s/VRD/GVD/ Not sure how I messed that up haha...
+ } else {
+ state_ = STATE_PENDING_DEMUXER_READ;
+ stream_->Read(
+ base::Bind(&DecoderStream<DemuxerStream::AUDIO>::OnBufferReady,
+ weak_factory_.GetWeakPtr()));
+ }
+}
+
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnBufferReady(
DemuxerStream::Status status,
@@ -387,12 +412,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 +515,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