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 #ifndef REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ | 5 #ifndef REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ |
| 6 #define REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ | 6 #define REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
|
Peter Kasting
2014/08/22 06:38:30
Nit: Prefer C++ headers to C ones (<cstdint>)
Wez
2014/08/25 23:23:12
Done.
Wez
2014/08/26 19:22:25
Hmmm, stdint.h -> cstdint seems to break Mac Chrom
Peter Kasting
2014/08/26 20:58:14
Huh! Apparently cstdint is formally C++11, and I
Wez
2014/08/28 00:13:20
Done.
| |
| 9 #include <list> | 9 #include <list> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 15 | 15 |
| 16 namespace webrtc { | 16 namespace webrtc { |
| 17 class DesktopFrame; | 17 class DesktopFrame; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 | 21 |
| 22 class VideoEncoder; | 22 class VideoEncoder; |
| 23 | 23 |
| 24 // Allows sequences of DesktopFrames passed to a VideoEncoder to be recorded. | 24 // Allows sequences of DesktopFrames passed to a VideoEncoder to be recorded. |
| 25 // | 25 // |
| 26 // VideoFrameRecorder is designed to support applications which use a dedicated | 26 // VideoFrameRecorder is designed to support applications which use a dedicated |
| 27 // thread for video encoding, but need to manage that process from a "main" | 27 // thread for video encoding, but need to manage that process from a "main" |
| 28 // or "control" thread. | 28 // or "control" thread. |
| 29 // | 29 // |
| 30 // On the control thread: | 30 // On the control thread: |
| 31 // 1. Create the VideoFrameRecorder on the controlling thread. | 31 // 1. Create the VideoFrameRecorder on the controlling thread. |
|
Peter Kasting
2014/08/22 06:38:30
Nit: "on the controlling thread" unnecessary (you'
Wez
2014/08/25 23:23:11
Done.
| |
| 32 // 2. Specify the amount of memory that may be used for recording. | 32 // 2. Specify the amount of memory that may be used for recording. |
| 33 // 3. Call WrapVideoEncoder(), passing the actual VideoEncoder that will be | 33 // 3. Call WrapVideoEncoder(), passing the actual VideoEncoder that will be |
| 34 // used to encode frames. | 34 // used to encode frames. |
| 35 // 4. Hand the returned wrapper VideoEncoder of to the video encoding thread, | 35 // 4. Hand the returned wrapper VideoEncoder of to the video encoding thread, |
|
Peter Kasting
2014/08/22 06:38:30
Nit: of -> off ("Hand off the..." might be even be
Wez
2014/08/25 23:23:11
Done.
| |
| 36 // to call in place of the actual VideoEncoder. | 36 // to call in place of the actual VideoEncoder. |
| 37 // 5. Start/stop frame recording as necessary. | 37 // 5. Start/stop frame recording as necessary. |
| 38 // 6. Use NextFrame() to read each recorded frame in sequence. | 38 // 6. Use NextFrame() to read each recorded frame in sequence. |
| 39 // | 39 // |
| 40 // The wrapper VideoEncoder is designed to be handed off to the video encoding | 40 // The wrapper VideoEncoder is designed to be handed off to the video encoding |
| 41 // thread, and used and torn down there. | 41 // thread, and used and torn down there. |
| 42 // | 42 // |
| 43 // The VideoFrameRecorder and VideoEncoder may be torn down in any order; frame | 43 // The VideoFrameRecorder and VideoEncoder may be torn down in any order; frame |
| 44 // recording will stop as soon as either is destroyed. | 44 // recording will stop as soon as either is destroyed. |
| 45 | 45 |
| 46 class VideoFrameRecorder { | 46 class VideoFrameRecorder { |
| 47 public: | 47 public: |
| 48 VideoFrameRecorder(); | 48 VideoFrameRecorder(); |
| 49 virtual ~VideoFrameRecorder(); | 49 virtual ~VideoFrameRecorder(); |
| 50 | 50 |
| 51 // Wraps the supplied VideoEncoder, returning a replacement VideoEncoder that | 51 // Wraps the supplied VideoEncoder, returning a replacement VideoEncoder that |
| 52 // will route frames to the recorder, as well as passing them for encoding. | 52 // will route frames to the recorder, as well as passing them for encoding. |
| 53 // The caller must delete the previous recording VideoEncoder, or call | 53 // The caller must delete the previous recording VideoEncoder, or call |
|
Peter Kasting
2014/08/22 06:38:30
Nit: Perhaps this second sentence would be clearer
Wez
2014/08/25 23:23:12
Acknowledged; I've gone with another rewording tha
| |
| 54 // DetachVideoEncoderWrapper() before calling WrapVideoEncoder() to create | 54 // DetachVideoEncoderWrapper() before calling WrapVideoEncoder() to create |
| 55 // a new wrapper. | 55 // a new wrapper. |
| 56 scoped_ptr<VideoEncoder> WrapVideoEncoder(scoped_ptr<VideoEncoder> encoder); | 56 scoped_ptr<VideoEncoder> WrapVideoEncoder(scoped_ptr<VideoEncoder> encoder); |
| 57 | 57 |
| 58 // Detaches the existing VideoEncoder wrapper, stopping it from recording. | 58 // Detaches the existing VideoEncoder wrapper, stopping it from recording. |
|
Peter Kasting
2014/08/22 06:38:30
What about the lifetime of the wrapper? Will it e
Wez
2014/08/25 23:23:12
Done.
| |
| 59 void DetachVideoEncoderWrapper(); | 59 void DetachVideoEncoderWrapper(); |
| 60 | 60 |
| 61 // Enables/disables frame recording. Frame recording is initially disabled. | 61 // Enables/disables frame recording. Frame recording is initially disabled. |
| 62 void SetEnableRecording(bool enable_recording); | 62 void SetEnableRecording(bool enable_recording); |
| 63 | 63 |
| 64 // Sets the maximum number of bytes of pixel data that may be recorded. | 64 // Sets the maximum number of bytes of pixel data that may be recorded. |
| 65 // When this maximum is reached older frames will be discard to make space | 65 // When this maximum is reached older frames will be discard to make space |
|
Peter Kasting
2014/08/22 06:38:30
Nit: discarded
Wez
2014/08/25 23:23:11
Done.
| |
| 66 // for new ones. | 66 // for new ones. |
| 67 void SetMaxContentBytes(int64_t max_content_bytes); | 67 void SetMaxContentBytes(int64_t max_content_bytes); |
| 68 | 68 |
| 69 // Pops the next recorded frame in the sequence, and returns it. | 69 // Pops the next recorded frame in the sequence, and returns it. |
| 70 scoped_ptr<webrtc::DesktopFrame> NextFrame(); | 70 scoped_ptr<webrtc::DesktopFrame> NextFrame(); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 class RecordingVideoEncoder; | 73 class RecordingVideoEncoder; |
| 74 friend class RecordingVideoEncoder; | 74 friend class RecordingVideoEncoder; |
| 75 | 75 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 96 | 96 |
| 97 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | 97 scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; |
| 98 base::WeakPtrFactory<VideoFrameRecorder> weak_factory_; | 98 base::WeakPtrFactory<VideoFrameRecorder> weak_factory_; |
| 99 | 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(VideoFrameRecorder); | 100 DISALLOW_COPY_AND_ASSIGN(VideoFrameRecorder); |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace remoting | 103 } // namespace remoting |
| 104 | 104 |
| 105 #endif // REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ | 105 #endif // REMOTING_HOST_VIDEO_FRAME_RECORDER_H_ |
| 106 | |
| OLD | NEW |