OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ | |
6 #define REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "base/single_thread_task_runner.h" | |
14 | |
15 namespace webrtc { | |
16 class DesktopFrame; | |
17 } | |
18 | |
19 namespace remoting { | |
20 | |
21 class VideoEncoder; | |
22 | |
23 // Records video frames passed to a VideoEncoder. | |
24 // Callers create VideoFrameRecorder instances and call WrapVideoEncoder() to | |
25 // wrap an underlying VideoEncoder, and return a replacement VideoEncoder | |
26 // 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.
| |
27 class VideoFrameRecorder { | |
28 public: | |
29 VideoFrameRecorder(); | |
30 virtual ~VideoFrameRecorder(); | |
31 | |
32 // Wraps the supplied VideoEncoder, returning a replacement VideoEncoder that | |
33 // 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.
| |
34 scoped_ptr<VideoEncoder> WrapVideoEncoder(scoped_ptr<VideoEncoder> encoder); | |
35 | |
36 // Enables/disables frame recording. Frame recording is initially disabled. | |
37 void SetEnableRecording(bool enable_recording); | |
38 | |
39 // Sets the maximum number of bytes of pixel data that may be recorded. | |
40 // When this maximum is reached older frames will be discard to make space | |
41 // for new ones. | |
42 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.
| |
43 | |
44 // Pops the next recorded frame in sequences, and returns it. | |
45 scoped_ptr<webrtc::DesktopFrame> NextFrame(); | |
46 | |
47 private: | |
48 class RecordingVideoEncoder; | |
49 friend class RecordingVideoEncoder; | |
50 | |
51 void SetEncoderTaskRunner(scoped_refptr<base::TaskRunner> task_runner); | |
52 void RecordFrame(scoped_ptr<webrtc::DesktopFrame> frame); | |
53 | |
54 // The recorded frames, in sequence. | |
55 std::list<webrtc::DesktopFrame*> recorded_frames_; | |
56 | |
57 // Size of the recorded frames' content, in bytes. | |
58 int64 content_bytes_; | |
59 | |
60 // Size that recorded frames' content must not exceed. | |
61 int64 max_content_bytes_; | |
62 | |
63 // True if recording is started, false otherwise. | |
64 bool enable_recording_; | |
65 | |
66 // Task runner on which the wrapper VideoEncoder is being run. | |
67 scoped_refptr<base::TaskRunner> encoder_task_runner_; | |
68 | |
69 // Weak reference to the wrapper VideoEncoder, to use to control it. | |
70 base::WeakPtr<RecordingVideoEncoder> recording_encoder_; | |
71 | |
72 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | |
73 base::WeakPtrFactory<VideoFrameRecorder> weak_factory_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(VideoFrameRecorder); | |
76 }; | |
77 | |
78 } // namespace remoting | |
79 | |
80 #endif // REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ | |
OLD | NEW |