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

Unified Diff: remoting/host/video_frame_recorder.cc

Issue 372943002: Add video frame recording capability to Chromoting hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Correct comment Created 6 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: remoting/host/video_frame_recorder.cc
diff --git a/remoting/host/video_frame_recorder.cc b/remoting/host/video_frame_recorder.cc
index cccfe7cd90b5d90e3d41c2b1fdaa8bb8b18dd635..38213b3bcba9ae3693d2ec81329c65452f083da7 100644
--- a/remoting/host/video_frame_recorder.cc
+++ b/remoting/host/video_frame_recorder.cc
@@ -107,12 +107,12 @@ VideoFrameRecorder::VideoFrameRecorder()
}
VideoFrameRecorder::~VideoFrameRecorder() {
- SetEnableRecording(false);
- STLDeleteElements(&recorded_frames_);
+ DetachVideoEncoderWrapper();
}
scoped_ptr<VideoEncoder> VideoFrameRecorder::WrapVideoEncoder(
scoped_ptr<VideoEncoder> encoder) {
+ DCHECK(!encoder_task_runner_);
DCHECK(!caller_task_runner_);
caller_task_runner_ = base::ThreadTaskRunnerHandle::Get();
@@ -125,6 +125,28 @@ scoped_ptr<VideoEncoder> VideoFrameRecorder::WrapVideoEncoder(
return recording_encoder.PassAs<VideoEncoder>();
}
+void VideoFrameRecorder::DetachVideoEncoderWrapper() {
+ DCHECK(!caller_task_runner_ || caller_task_runner_->BelongsToCurrentThread());
+
+ // Immediately detach the wrapper from this recorder.
+ weak_factory_.InvalidateWeakPtrs();
+
+ // Clean up any pending recorded frames.
+ STLDeleteElements(&recorded_frames_);
+ content_bytes_ = 0;
+
+ // Tell the wrapper to stop recording and posting frames to us.
+ if (encoder_task_runner_) {
+ encoder_task_runner_->PostTask(FROM_HERE,
+ base::Bind(&RecordingVideoEncoder::SetEnableRecording,
+ recording_encoder_, false));
+ }
+
+ // Detach this recorder from the calling and encode threads.
+ caller_task_runner_ = NULL;
+ encoder_task_runner_ = NULL;
+}
+
void VideoFrameRecorder::SetEnableRecording(bool enable_recording) {
DCHECK(!caller_task_runner_ || caller_task_runner_->BelongsToCurrentThread());

Powered by Google App Engine
This is Rietveld 408576698