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

Unified Diff: media/base/android/media_codec_video_decoder.cc

Issue 1254293003: MediaCodecPlayer implementation (stage 4 - preroll) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-browserseek
Patch Set: Save the first post-preroll audio buffer and replay it when preroll is done Created 5 years, 5 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/base/android/media_codec_video_decoder.cc
diff --git a/media/base/android/media_codec_video_decoder.cc b/media/base/android/media_codec_video_decoder.cc
index 2eccc402b628a1061a19508938708cc5109d1341..7954430b52482a8c8bb2657abad1bb76a5b05712 100644
--- a/media/base/android/media_codec_video_decoder.cc
+++ b/media/base/android/media_codec_video_decoder.cc
@@ -20,6 +20,7 @@ MediaCodecVideoDecoder::MediaCodecVideoDecoder(
const scoped_refptr<base::SingleThreadTaskRunner>& media_task_runner,
const base::Closure& request_data_cb,
const base::Closure& starvation_cb,
+ const base::Closure& preroll_done_cb,
const base::Closure& stop_done_cb,
const base::Closure& error_cb,
const SetTimeCallback& update_current_time_cb,
@@ -28,6 +29,7 @@ MediaCodecVideoDecoder::MediaCodecVideoDecoder(
: MediaCodecDecoder(media_task_runner,
request_data_cb,
starvation_cb,
+ preroll_done_cb,
stop_done_cb,
error_cb,
"VideoDecoder"),
@@ -72,6 +74,14 @@ void MediaCodecVideoDecoder::ReleaseDecoderResources() {
MediaCodecDecoder::ReleaseDecoderResources();
surface_ = gfx::ScopedJavaSurface();
+}
+
+void MediaCodecVideoDecoder::ReleaseMediaCodec() {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+
+ DVLOG(1) << class_name() << "::" << __FUNCTION__;
+
+ MediaCodecDecoder::ReleaseMediaCodec();
delayed_buffers_.clear();
}
@@ -159,13 +169,18 @@ MediaCodecDecoder::ConfigStatus MediaCodecVideoDecoder::ConfigureInternal() {
return kConfigOk;
}
-void MediaCodecVideoDecoder::SynchronizePTSWithTime(
- base::TimeDelta current_time) {
+void MediaCodecVideoDecoder::AssociateCurrentTimeWithPTS(base::TimeDelta pts) {
DCHECK(media_task_runner_->BelongsToCurrentThread());
start_time_ticks_ = base::TimeTicks::Now();
- start_pts_ = current_time;
- last_seen_pts_ = current_time;
+ start_pts_ = pts;
+ last_seen_pts_ = pts;
+}
+
+void MediaCodecVideoDecoder::DissociatePTSFromTime() {
+ DCHECK(media_task_runner_->BelongsToCurrentThread());
+
+ start_pts_ = last_seen_pts_ = kNoTimestamp();
}
void MediaCodecVideoDecoder::OnOutputFormatChanged() {
@@ -185,7 +200,7 @@ void MediaCodecVideoDecoder::OnOutputFormatChanged() {
void MediaCodecVideoDecoder::Render(int buffer_index,
size_t size,
- bool render_output,
+ RenderMode render_mode,
base::TimeDelta pts,
bool eos_encountered) {
DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread());
@@ -206,7 +221,12 @@ void MediaCodecVideoDecoder::Render(int buffer_index,
last_seen_pts_ = pts;
}
- if (!render_output) {
+ // For video we simplify the preroll operation and render the first frame
+ // after preroll during the preroll phase, i.e. without waiting for audio
+ // stream to finish prerolling.
+ const bool render_output = (render_mode != kRenderSkip);
+
+ if (!render_output || start_pts_ == kNoTimestamp()) {
ReleaseOutputBuffer(buffer_index, pts, size, false, eos_encountered);
return;
}
@@ -236,13 +256,11 @@ int MediaCodecVideoDecoder::NumDelayedRenderTasks() const {
return delayed_buffers_.size();
}
-void MediaCodecVideoDecoder::ClearDelayedBuffers(bool release) {
+void MediaCodecVideoDecoder::ReleaseDelayedBuffers() {
// Media thread
// Called when there is no decoder thread
- if (release) {
- for (int index : delayed_buffers_)
- media_codec_bridge_->ReleaseOutputBuffer(index, false);
- }
+ for (int index : delayed_buffers_)
+ media_codec_bridge_->ReleaseOutputBuffer(index, false);
delayed_buffers_.clear();
}
« media/base/android/media_codec_decoder.cc ('K') | « media/base/android/media_codec_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698