Chromium Code Reviews| 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 "remoting/host/video_frame_recorder.h" | 5 #include "remoting/host/video_frame_recorder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 DCHECK_GT(frame->stride(), 0); | 21 DCHECK_GT(frame->stride(), 0); |
| 22 return frame->stride() * frame->size().height(); | 22 return frame->stride() * frame->size().height(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 // VideoEncoder wrapper used to intercept frames passed to a real VideoEncoder. | 25 // VideoEncoder wrapper used to intercept frames passed to a real VideoEncoder. |
| 26 class VideoFrameRecorder::RecordingVideoEncoder : public VideoEncoder { | 26 class VideoFrameRecorder::RecordingVideoEncoder : public VideoEncoder { |
| 27 public: | 27 public: |
| 28 RecordingVideoEncoder(scoped_ptr<VideoEncoder> encoder, | 28 RecordingVideoEncoder(scoped_ptr<VideoEncoder> encoder, |
| 29 scoped_refptr<base::TaskRunner> recorder_task_runner, | 29 scoped_refptr<base::TaskRunner> recorder_task_runner, |
| 30 base::WeakPtr<VideoFrameRecorder> recorder) | 30 base::WeakPtr<VideoFrameRecorder> recorder) |
| 31 : encoder_(encoder.Pass()), | 31 : encoder_(encoder.Pass()), |
|
Peter Kasting
2014/08/22 06:38:29
Nit: Avoid defining complex functions inline excep
Wez
2014/08/25 23:23:11
Done.
| |
| 32 recorder_task_runner_(recorder_task_runner), | 32 recorder_task_runner_(recorder_task_runner), |
| 33 recorder_(recorder), | 33 recorder_(recorder), |
| 34 enable_recording_(false), | 34 enable_recording_(false), |
| 35 weak_factory_(this) { | 35 weak_factory_(this) { |
| 36 DCHECK(encoder_); | 36 DCHECK(encoder_); |
| 37 DCHECK(recorder_task_runner_); | 37 DCHECK(recorder_task_runner_); |
| 38 } | 38 } |
| 39 | 39 |
| 40 base::WeakPtr<RecordingVideoEncoder> AsWeakPtr() { | 40 base::WeakPtr<RecordingVideoEncoder> AsWeakPtr() { |
| 41 return weak_factory_.GetWeakPtr(); | 41 return weak_factory_.GetWeakPtr(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void SetEnableRecording(bool enable_recording) { | 44 void SetEnableRecording(bool enable_recording) { |
|
Peter Kasting
2014/08/22 06:38:29
Nit: This function could probably be left inlined,
Wez
2014/08/25 23:23:11
Done.
| |
| 45 DCHECK(!encoder_task_runner_ || | 45 DCHECK(!encoder_task_runner_ || |
| 46 encoder_task_runner_->BelongsToCurrentThread()); | 46 encoder_task_runner_->BelongsToCurrentThread()); |
| 47 enable_recording_ = enable_recording; | 47 enable_recording_ = enable_recording; |
| 48 } | 48 } |
| 49 | 49 |
| 50 // remoting::VideoEncoder interface. | 50 // remoting::VideoEncoder interface. |
| 51 virtual void SetLosslessEncode(bool want_lossless) OVERRIDE { | 51 virtual void SetLosslessEncode(bool want_lossless) OVERRIDE { |
| 52 encoder_->SetLosslessEncode(want_lossless); | 52 encoder_->SetLosslessEncode(want_lossless); |
| 53 } | 53 } |
| 54 virtual void SetLosslessColor(bool want_lossless) OVERRIDE { | 54 virtual void SetLosslessColor(bool want_lossless) OVERRIDE { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 if (content_bytes_ + frame_bytes > max_content_bytes_) { | 220 if (content_bytes_ + frame_bytes > max_content_bytes_) { |
| 221 return; | 221 return; |
| 222 } | 222 } |
| 223 | 223 |
| 224 // Store the frame and update the content byte count. | 224 // Store the frame and update the content byte count. |
| 225 recorded_frames_.push_back(frame.release()); | 225 recorded_frames_.push_back(frame.release()); |
| 226 content_bytes_ += frame_bytes; | 226 content_bytes_ += frame_bytes; |
| 227 } | 227 } |
| 228 | 228 |
| 229 } // namespace remoting | 229 } // namespace remoting |
| 230 | |
| OLD | NEW |