Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1621)

Unified Diff: webrtc/modules/desktop_capture/screen_capture_frame_queue.h

Issue 1902323002: Modify ScreenCaptureFrameQueue into a template (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix build break in Chromium Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/desktop_capture/screen_capture_frame_queue.h
diff --git a/webrtc/modules/desktop_capture/screen_capture_frame_queue.h b/webrtc/modules/desktop_capture/screen_capture_frame_queue.h
index 21af0f320fc277952c4515b547d9ab98492a2a15..97f3b810e9d64d467e164ce16b53946289c3dcf8 100644
--- a/webrtc/modules/desktop_capture/screen_capture_frame_queue.h
+++ b/webrtc/modules/desktop_capture/screen_capture_frame_queue.h
@@ -13,12 +13,12 @@
#include <memory>
-#include "webrtc/modules/desktop_capture/shared_desktop_frame.h"
-#include "webrtc/typedefs.h"
+#include "webrtc/base/constructormagic.h"
+// TODO(zijiehe): These headers are not used in this file, but to avoid build
+// break in remoting/host. We should add headers in each individual files.
+#include "webrtc/modules/desktop_capture/desktop_frame.h" // Remove
+#include "webrtc/modules/desktop_capture/shared_desktop_frame.h" // Remove
-namespace webrtc {
-class DesktopFrame;
-} // namespace webrtc
namespace webrtc {
@@ -35,28 +35,38 @@ namespace webrtc {
// Frame consumer is expected to never hold more than kQueueLength frames
// created by this function and it should release the earliest one before trying
// to capture a new frame (i.e. before MoveToNextFrame() is called).
+template <typename FrameType>
class ScreenCaptureFrameQueue {
public:
- ScreenCaptureFrameQueue();
- ~ScreenCaptureFrameQueue();
+ ScreenCaptureFrameQueue() : current_(0) {}
+ ~ScreenCaptureFrameQueue() = default;
// Moves to the next frame in the queue, moving the 'current' frame to become
// the 'previous' one.
- void MoveToNextFrame();
+ void MoveToNextFrame() {
+ current_ = (current_ + 1) % kQueueLength;
+ }
// Replaces the current frame with a new one allocated by the caller. The
// existing frame (if any) is destroyed. Takes ownership of |frame|.
- void ReplaceCurrentFrame(DesktopFrame* frame);
+ void ReplaceCurrentFrame(FrameType* frame) {
+ frames_[current_].reset(frame);
+ }
// Marks all frames obsolete and resets the previous frame pointer. No
// frames are freed though as the caller can still access them.
- void Reset();
+ void Reset() {
+ for (int i = 0; i < kQueueLength; i++) {
+ frames_[i].reset();
+ }
+ current_ = 0;
+ }
- SharedDesktopFrame* current_frame() const {
+ FrameType* current_frame() const {
return frames_[current_].get();
}
- SharedDesktopFrame* previous_frame() const {
+ FrameType* previous_frame() const {
return frames_[(current_ + kQueueLength - 1) % kQueueLength].get();
}
@@ -65,7 +75,7 @@ class ScreenCaptureFrameQueue {
int current_;
static const int kQueueLength = 2;
- std::unique_ptr<SharedDesktopFrame> frames_[kQueueLength];
+ std::unique_ptr<FrameType> frames_[kQueueLength];
RTC_DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameQueue);
};
« no previous file with comments | « webrtc/modules/desktop_capture/desktop_capture.gypi ('k') | webrtc/modules/desktop_capture/screen_capture_frame_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698