Index: remoting/host/video_frame_recorder.h |
diff --git a/remoting/host/video_frame_recorder.h b/remoting/host/video_frame_recorder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..61f7be78c268cecd5df3f435a3ff4a96eae04591 |
--- /dev/null |
+++ b/remoting/host/video_frame_recorder.h |
@@ -0,0 +1,80 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ |
+#define REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ |
+ |
+#include <list> |
+ |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/single_thread_task_runner.h" |
+ |
+namespace webrtc { |
+class DesktopFrame; |
+} |
+ |
+namespace remoting { |
+ |
+class VideoEncoder; |
+ |
+// Records video frames passed to a VideoEncoder. |
+// Callers create VideoFrameRecorder instances and call WrapVideoEncoder() to |
+// wrap an underlying VideoEncoder, and return a replacement VideoEncoder |
+// instance that can be passed to the frame capture engine in its place. |
Sergey Ulanov
2014/06/20 22:32:13
Threading semantics is not very clear. It looks li
Wez
2014/06/24 01:02:15
Done.
|
+class VideoFrameRecorder { |
+ public: |
+ VideoFrameRecorder(); |
+ virtual ~VideoFrameRecorder(); |
+ |
+ // Wraps the supplied VideoEncoder, returning a replacement VideoEncoder that |
+ // will route frames to the recorder, as well as passing them for encoding. |
Sergey Ulanov
2014/06/20 22:32:13
Looks like this function is not allowed to be call
Wez
2014/06/24 01:02:15
Done.
|
+ scoped_ptr<VideoEncoder> WrapVideoEncoder(scoped_ptr<VideoEncoder> encoder); |
+ |
+ // Enables/disables frame recording. Frame recording is initially disabled. |
+ void SetEnableRecording(bool enable_recording); |
+ |
+ // Sets the maximum number of bytes of pixel data that may be recorded. |
+ // When this maximum is reached older frames will be discard to make space |
+ // for new ones. |
+ void SetMaxContentBytes(int64 max_content_bytes); |
Sergey Ulanov
2014/06/20 22:32:13
nit: not sure if it's documented anywhere, but it'
Wez
2014/06/24 01:02:15
Done.
|
+ |
+ // Pops the next recorded frame in sequences, and returns it. |
+ scoped_ptr<webrtc::DesktopFrame> NextFrame(); |
+ |
+ private: |
+ class RecordingVideoEncoder; |
+ friend class RecordingVideoEncoder; |
+ |
+ void SetEncoderTaskRunner(scoped_refptr<base::TaskRunner> task_runner); |
+ void RecordFrame(scoped_ptr<webrtc::DesktopFrame> frame); |
+ |
+ // The recorded frames, in sequence. |
+ std::list<webrtc::DesktopFrame*> recorded_frames_; |
+ |
+ // Size of the recorded frames' content, in bytes. |
+ int64 content_bytes_; |
+ |
+ // Size that recorded frames' content must not exceed. |
+ int64 max_content_bytes_; |
+ |
+ // True if recording is started, false otherwise. |
+ bool enable_recording_; |
+ |
+ // Task runner on which the wrapper VideoEncoder is being run. |
+ scoped_refptr<base::TaskRunner> encoder_task_runner_; |
+ |
+ // Weak reference to the wrapper VideoEncoder, to use to control it. |
+ base::WeakPtr<RecordingVideoEncoder> recording_encoder_; |
+ |
+ scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
+ base::WeakPtrFactory<VideoFrameRecorder> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(VideoFrameRecorder); |
+}; |
+ |
+} // namespace remoting |
+ |
+#endif // REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ |