| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/blink/video_frame_compositor.h" | 5 #include "media/blink/video_frame_compositor.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/time/default_tick_clock.h" | 10 #include "base/time/default_tick_clock.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 if (!auto_open_close_) { | 57 if (!auto_open_close_) { |
| 58 auto_open_close_.reset(new base::trace_event::AutoOpenCloseEvent( | 58 auto_open_close_.reset(new base::trace_event::AutoOpenCloseEvent( |
| 59 base::trace_event::AutoOpenCloseEvent::Type::ASYNC, "media,rail", | 59 base::trace_event::AutoOpenCloseEvent::Type::ASYNC, "media,rail", |
| 60 "VideoPlayback")); | 60 "VideoPlayback")); |
| 61 } | 61 } |
| 62 | 62 |
| 63 if (rendering_) { | 63 if (rendering_) { |
| 64 auto_open_close_->Begin(); | 64 auto_open_close_->Begin(); |
| 65 } else { | 65 } else { |
| 66 new_processed_frame_cb_.Reset(); |
| 66 auto_open_close_->End(); | 67 auto_open_close_->End(); |
| 67 } | 68 } |
| 68 | 69 |
| 69 if (rendering_) { | 70 if (rendering_) { |
| 70 // Always start playback in background rendering mode, if |client_| kicks | 71 // Always start playback in background rendering mode, if |client_| kicks |
| 71 // in right away it's okay. | 72 // in right away it's okay. |
| 72 BackgroundRender(); | 73 BackgroundRender(); |
| 73 } else if (background_rendering_enabled_) { | 74 } else if (background_rendering_enabled_) { |
| 74 background_rendering_timer_.Stop(); | 75 background_rendering_timer_.Stop(); |
| 75 } else { | 76 } else { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 void VideoFrameCompositor::Stop() { | 133 void VideoFrameCompositor::Stop() { |
| 133 // Called from the media thread, so release the callback under lock before | 134 // Called from the media thread, so release the callback under lock before |
| 134 // returning to avoid a pending UpdateCurrentFrame() call occurring before | 135 // returning to avoid a pending UpdateCurrentFrame() call occurring before |
| 135 // the PostTask is processed. | 136 // the PostTask is processed. |
| 136 base::AutoLock lock(callback_lock_); | 137 base::AutoLock lock(callback_lock_); |
| 137 DCHECK(callback_); | 138 DCHECK(callback_); |
| 138 callback_ = nullptr; | 139 callback_ = nullptr; |
| 139 compositor_task_runner_->PostTask( | 140 compositor_task_runner_->PostTask( |
| 140 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, | 141 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, |
| 141 base::Unretained(this), false)); | 142 base::Unretained(this), false)); |
| 142 new_processed_frame_cb_.Reset(); | |
| 143 } | 143 } |
| 144 | 144 |
| 145 void VideoFrameCompositor::PaintSingleFrame( | 145 void VideoFrameCompositor::PaintSingleFrame( |
| 146 const scoped_refptr<VideoFrame>& frame, | 146 const scoped_refptr<VideoFrame>& frame, |
| 147 bool repaint_duplicate_frame) { | 147 bool repaint_duplicate_frame) { |
| 148 if (!compositor_task_runner_->BelongsToCurrentThread()) { | 148 if (!compositor_task_runner_->BelongsToCurrentThread()) { |
| 149 compositor_task_runner_->PostTask( | 149 compositor_task_runner_->PostTask( |
| 150 FROM_HERE, | 150 FROM_HERE, |
| 151 base::Bind(&VideoFrameCompositor::PaintSingleFrame, | 151 base::Bind(&VideoFrameCompositor::PaintSingleFrame, |
| 152 base::Unretained(this), frame, repaint_duplicate_frame)); | 152 base::Unretained(this), frame, repaint_duplicate_frame)); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 last_interval_ = deadline_max - deadline_min; | 262 last_interval_ = deadline_max - deadline_min; |
| 263 | 263 |
| 264 // Restart the background rendering timer whether we're background rendering | 264 // Restart the background rendering timer whether we're background rendering |
| 265 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. | 265 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. |
| 266 if (background_rendering_enabled_) | 266 if (background_rendering_enabled_) |
| 267 background_rendering_timer_.Reset(); | 267 background_rendering_timer_.Reset(); |
| 268 return new_frame || had_new_background_frame; | 268 return new_frame || had_new_background_frame; |
| 269 } | 269 } |
| 270 | 270 |
| 271 } // namespace media | 271 } // namespace media |
| OLD | NEW |