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

Unified Diff: content/renderer/media/webmediaplayer_ms_compositor.cc

Issue 1772353003: Bug Fix: Remote Video Hang For Apprtc Loopback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Blank line remove Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webmediaplayer_ms_compositor.cc
diff --git a/content/renderer/media/webmediaplayer_ms_compositor.cc b/content/renderer/media/webmediaplayer_ms_compositor.cc
index 7bd992de607e8b0921affac52f3cc1a0716db05c..ac8208459900845cb9cb270629c3c6f19e2dba09 100644
--- a/content/renderer/media/webmediaplayer_ms_compositor.cc
+++ b/content/renderer/media/webmediaplayer_ms_compositor.cc
@@ -185,6 +185,7 @@ void WebMediaPlayerMSCompositor::EnqueueFrame(
base::AutoLock auto_lock(current_frame_lock_);
++total_frame_count_;
+ // With algorithm off, just let |current_frame_| hold the incoming |frame|.
if (!rendering_frame_buffer_) {
SetCurrentFrame(frame);
return;
@@ -200,6 +201,9 @@ void WebMediaPlayerMSCompositor::EnqueueFrame(
return;
}
+ // If we detect a bad frame without |render_time|, we switch off algorithm,
+ // because without |render_time|, algorithm cannot work.
+ // In general, this should not happen.
base::TimeTicks render_time;
if (!frame->metadata()->GetTimeTicks(
media::VideoFrameMetadata::REFERENCE_TIME, &render_time)) {
@@ -211,20 +215,25 @@ void WebMediaPlayerMSCompositor::EnqueueFrame(
return;
}
- timestamps_to_clock_times_[frame->timestamp()] = render_time;
-
- rendering_frame_buffer_->EnqueueFrame(frame);
-
+ // The code below handles the case where UpdateCurrentFrame() callbacks stop.
+ // These callbacks can stop when the tab is hidden or the page area containing
+ // the video frame is scrolled out of view.
+ // Since some hardware decoders only have a limited number of output frames,
+ // we must aggressively release frames in this case.
const base::TimeTicks now = base::TimeTicks::Now();
- if (now <= last_deadline_max_)
- return;
-
- // This shows vsyncs stops rendering frames. A probable cause is that the
- // tab is not in the front. But we still have to let old frames go.
- const base::TimeTicks deadline_max =
- std::max(now, last_deadline_max_ + last_render_length_);
+ if (now > last_deadline_max_) {
+ // Note: the frame in |rendering_frame_buffer_| with lowest index is the
+ // same as |current_frame_|. Function SetCurrentFrame() handles whether
+ // to increase |dropped_frame_count_| for that frame, so here we should
+ // increase |dropped_frame_count_| by the count of all other frames.
+ dropped_frame_count_ += rendering_frame_buffer_->frames_queued() - 1;
+ rendering_frame_buffer_->Reset();
+ timestamps_to_clock_times_.clear();
+ SetCurrentFrame(frame);
+ }
- Render(deadline_max - last_render_length_, deadline_max);
+ timestamps_to_clock_times_[frame->timestamp()] = render_time;
+ rendering_frame_buffer_->EnqueueFrame(frame);
}
bool WebMediaPlayerMSCompositor::UpdateCurrentFrame(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698