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

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

Issue 1417673002: MediaStream Recorder: implement pause() and resume() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 | « content/renderer/media/video_track_recorder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/video_track_recorder.cc
diff --git a/content/renderer/media/video_track_recorder.cc b/content/renderer/media/video_track_recorder.cc
index a2755bddeb224fcbc0e1dc7cfb3a7a1c340ef79a..a33d44dee935bc53e452c9e91b4a1bc2f958d8a2 100644
--- a/content/renderer/media/video_track_recorder.cc
+++ b/content/renderer/media/video_track_recorder.cc
@@ -80,6 +80,8 @@ class VideoTrackRecorder::VpxEncoder final
void StartFrameEncode(const scoped_refptr<VideoFrame>& frame,
base::TimeTicks capture_timestamp);
+ void set_paused(bool paused) { paused_ = paused; }
+
private:
friend class base::RefCountedThreadSafe<VpxEncoder>;
~VpxEncoder();
@@ -96,6 +98,9 @@ class VideoTrackRecorder::VpxEncoder final
base::TimeDelta CalculateFrameDuration(
const scoped_refptr<VideoFrame>& frame);
+ // While |paused_|, frames are not encoded.
+ bool paused_;
+
// Force usage of VP9 for encoding, instead of VP8 which is the default.
const bool use_vp9_;
@@ -136,7 +141,8 @@ void VideoTrackRecorder::VpxEncoder::ShutdownEncoder(
VideoTrackRecorder::VpxEncoder::VpxEncoder(
bool use_vp9,
const OnEncodedVideoCB& on_encoded_video_callback)
- : use_vp9_(use_vp9),
+ : paused_(false),
+ use_vp9_(use_vp9),
main_task_runner_(base::MessageLoop::current()->task_runner()),
on_encoded_video_callback_(on_encoded_video_callback),
encoding_thread_(new base::Thread("EncodingThread")) {
@@ -162,7 +168,8 @@ void VideoTrackRecorder::VpxEncoder::StartFrameEncode(
if (!origin_task_runner_.get())
origin_task_runner_ = base::MessageLoop::current()->task_runner();
DCHECK(origin_task_runner_->BelongsToCurrentThread());
-
+ if (paused_)
+ return;
emircan 2015/10/20 22:00:27 Move to l.167?
encoding_thread_->task_runner()->PostTask(
FROM_HERE, base::Bind(&VpxEncoder::EncodeOnEncodingThread,
this, frame, capture_timestamp));
@@ -358,6 +365,18 @@ VideoTrackRecorder::~VideoTrackRecorder() {
track_.reset();
}
+void VideoTrackRecorder::Pause() {
+ DCHECK(main_render_thread_checker_.CalledOnValidThread());
+ DCHECK(encoder_);
+ encoder_->set_paused(true);
+}
+
+void VideoTrackRecorder::Resume() {
+ DCHECK(main_render_thread_checker_.CalledOnValidThread());
+ DCHECK(encoder_);
+ encoder_->set_paused(false);
+}
+
void VideoTrackRecorder::OnVideoFrameForTesting(
const scoped_refptr<media::VideoFrame>& frame,
base::TimeTicks timestamp) {
« no previous file with comments | « content/renderer/media/video_track_recorder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698