| 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());
|
|
|
|
|