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

Side by Side Diff: media/video/capture/screen/screen_capture_frame_queue.h

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_ 5 #ifndef MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_
6 #define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_ 6 #define MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "media/video/capture/screen/shared_desktop_frame.h"
11
12 namespace webrtc {
13 class DesktopFrame;
14 } // namespace webrtc
10 15
11 namespace media { 16 namespace media {
12 17
13 class ScreenCaptureFrame;
14
15 // Represents a queue of reusable video frames. Provides access to the 'current' 18 // Represents a queue of reusable video frames. Provides access to the 'current'
16 // frame - the frame that the caller is working with at the moment, and to 19 // frame - the frame that the caller is working with at the moment, and to the
17 // the 'previous' frame - the predecessor of the current frame swapped by 20 // 'previous' frame - the predecessor of the current frame swapped by
18 // DoneWithCurrentFrame() call, if any. 21 // MoveToNextFrame() call, if any.
19 // 22 //
20 // The caller is expected to (re)allocate frames if current_frame_needs_update() 23 // The caller is expected to (re)allocate frames if current_frame() returns
21 // is set. The caller can mark all frames in the queue for reallocation (when, 24 // NULL. The caller can mark all frames in the queue for reallocation (when,
22 // say, frame dimensions change). The queue records which frames need updating 25 // say, frame dimensions change). The queue records which frames need updating
23 // which the caller can query. 26 // which the caller can query.
27 //
28 // Frame consumer is expected to never hold more than kQueueLength frames
29 // created by this function and it should release the earliest one before trying
30 // to capture a new frame (i.e. before MoveToNextFrame() is called).
24 class ScreenCaptureFrameQueue { 31 class ScreenCaptureFrameQueue {
25 public: 32 public:
26 ScreenCaptureFrameQueue(); 33 ScreenCaptureFrameQueue();
27 ~ScreenCaptureFrameQueue(); 34 ~ScreenCaptureFrameQueue();
28 35
29 // Moves to the next frame in the queue, moving the 'current' frame to become 36 // Moves to the next frame in the queue, moving the 'current' frame to become
30 // the 'previous' one. 37 // the 'previous' one.
31 void DoneWithCurrentFrame(); 38 void MoveToNextFrame();
32 39
33 // Replaces the current frame with a new one allocated by the caller. 40 // Replaces the current frame with a new one allocated by the caller.
34 // The existing frame (if any) is destroyed. 41 // The existing frame (if any) is destroyed.
35 void ReplaceCurrentFrame(scoped_ptr<ScreenCaptureFrame> frame); 42 void ReplaceCurrentFrame(scoped_ptr<webrtc::DesktopFrame> frame);
36 43
37 // Marks all frames obsolete and resets the previous frame pointer. No 44 // Marks all frames obsolete and resets the previous frame pointer. No
38 // frames are freed though as the caller can still access them. 45 // frames are freed though as the caller can still access them.
39 void SetAllFramesNeedUpdate(); 46 void Reset();
40 47
41 ScreenCaptureFrame* current_frame() const { 48 SharedDesktopFrame* current_frame() const {
42 return frames_[current_].get(); 49 return frames_[current_].get();
43 } 50 }
44 51
45 bool current_frame_needs_update() const { 52 SharedDesktopFrame* previous_frame() const {
46 return !current_frame() || needs_update_[current_]; 53 return frames_[(current_ + kQueueLength - 1) % kQueueLength].get();
47 } 54 }
48 55
49 ScreenCaptureFrame* previous_frame() const { return previous_; }
50
51 private: 56 private:
52 // Index of the current frame. 57 // Index of the current frame.
53 int current_; 58 int current_;
54 59
55 static const int kQueueLength = 2; 60 static const int kQueueLength = 2;
56 scoped_ptr<ScreenCaptureFrame> frames_[kQueueLength]; 61 scoped_ptr<SharedDesktopFrame> frames_[kQueueLength];
57
58 // True if the corresponding frame needs to be re-allocated.
59 bool needs_update_[kQueueLength];
60
61 // Points to the previous frame if any.
62 ScreenCaptureFrame* previous_;
63 62
64 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameQueue); 63 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameQueue);
65 }; 64 };
66 65
67 } // namespace media 66 } // namespace media
68 67
69 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_ 68 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_
OLDNEW
« no previous file with comments | « media/video/capture/screen/screen_capture_frame.cc ('k') | media/video/capture/screen/screen_capture_frame_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698