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

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: q 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 10
11 namespace webrtc {
12 class DesktopFrame;
13 } // namespace webrtc
14
11 namespace media { 15 namespace media {
12 16
13 class ScreenCaptureFrame;
14
15 // Represents a queue of reusable video frames. Provides access to the 'current' 17 // 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 18 // frame - the frame that the caller is working with at the moment, and to
17 // the 'previous' frame - the predecessor of the current frame swapped by 19 // the 'previous' frame - the predecessor of the current frame swapped by
18 // DoneWithCurrentFrame() call, if any. 20 // MoveToNextFrame() call, if any.
Wez 2013/04/26 18:48:14 EmitCurrentFrameAndMoveToNext()?
alexeypa (please no reviews) 2013/04/26 21:33:58 nit: it is EmitCurrentFrameAndMoveToNext() in the
Sergey Ulanov 2013/05/07 22:25:50 Done.
Sergey Ulanov 2013/05/07 22:25:50 Done.
19 // 21 //
20 // The caller is expected to (re)allocate frames if current_frame_needs_update() 22 // The caller is expected to (re)allocate frames if current_frame_needs_update()
21 // is set. The caller can mark all frames in the queue for reallocation (when, 23 // is set. The caller can mark all frames in the queue for reallocation (when,
22 // say, frame dimensions change). The queue records which frames need updating 24 // say, frame dimensions change). The queue records which frames need updating
23 // which the caller can query. 25 // which the caller can query.
24 class ScreenCaptureFrameQueue { 26 class ScreenCaptureFrameQueue {
25 public: 27 public:
26 ScreenCaptureFrameQueue(); 28 ScreenCaptureFrameQueue();
27 ~ScreenCaptureFrameQueue(); 29 ~ScreenCaptureFrameQueue();
28 30
29 // Moves to the next frame in the queue, moving the 'current' frame to become 31 // Moves to the next frame in the queue, moving the 'current' frame to become
30 // the 'previous' one. 32 // the 'previous' one.
31 void DoneWithCurrentFrame(); 33 webrtc::DesktopFrame* EmitCurrentFrameAndMoveToNext();
Wez 2013/04/26 18:48:14 Why not call this MoveToNextFrame() and document t
Wez 2013/04/26 18:48:14 CLarify the ownership of the returned frame, for t
Wez 2013/04/26 18:48:14 Also, for calls that return something and transfer
Sergey Ulanov 2013/05/07 22:25:50 Done.
Sergey Ulanov 2013/05/07 22:25:50 MoveToNextFrame() is not verbose enough.
Sergey Ulanov 2013/05/07 22:25:50 Right, but the frame is actually "emitted" by the
32 34
33 // Replaces the current frame with a new one allocated by the caller. 35 // Replaces the current frame with a new one allocated by the caller.
34 // The existing frame (if any) is destroyed. 36 // The existing frame (if any) is destroyed.
35 void ReplaceCurrentFrame(scoped_ptr<ScreenCaptureFrame> frame); 37 void ReplaceCurrentFrame(scoped_ptr<webrtc::DesktopFrame> frame);
36 38
37 // Marks all frames obsolete and resets the previous frame pointer. No 39 // Marks all frames obsolete and resets the previous frame pointer. No
38 // frames are freed though as the caller can still access them. 40 // frames are freed though as the caller can still access them.
39 void SetAllFramesNeedUpdate(); 41 void SetAllFramesNeedUpdate();
40 42
41 ScreenCaptureFrame* current_frame() const { 43 webrtc::DesktopFrame* current_frame() const {
42 return frames_[current_].get(); 44 return frames_[current_];
43 } 45 }
44 46
45 bool current_frame_needs_update() const { 47 bool current_frame_needs_update() const {
Wez 2013/04/26 18:48:14 You don't need this any more; just delete the fram
Sergey Ulanov 2013/05/07 22:25:50 Yes, thanks!
46 return !current_frame() || needs_update_[current_]; 48 return !current_frame() || needs_update_[current_];
47 } 49 }
48 50
49 ScreenCaptureFrame* previous_frame() const { return previous_; } 51 webrtc::DesktopFrame* previous_frame() const { return previous_; }
50 52
51 private: 53 private:
54 class EmittedFrame;
55 friend class EmittedFrame;
56
57 void ReturnEmittedFrame(webrtc::DesktopFrame* frame);
Wez 2013/04/26 18:48:14 nit: Please document what this is for.
Sergey Ulanov 2013/05/07 22:25:50 Done.
58
52 // Index of the current frame. 59 // Index of the current frame.
53 int current_; 60 int current_;
54 61
55 static const int kQueueLength = 2; 62 static const int kQueueLength = 2;
56 scoped_ptr<ScreenCaptureFrame> frames_[kQueueLength]; 63 webrtc::DesktopFrame* frames_[kQueueLength];
64 EmittedFrame* emitted_frames_[kQueueLength];
57 65
58 // True if the corresponding frame needs to be re-allocated. 66 // True if the corresponding frame needs to be re-allocated.
59 bool needs_update_[kQueueLength]; 67 bool needs_update_[kQueueLength];
60 68
61 // Points to the previous frame if any. 69 // Points to the previous frame if any.
62 ScreenCaptureFrame* previous_; 70 webrtc::DesktopFrame* previous_;
63 71
64 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameQueue); 72 DISALLOW_COPY_AND_ASSIGN(ScreenCaptureFrameQueue);
65 }; 73 };
66 74
67 } // namespace media 75 } // namespace media
68 76
69 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_ 77 #endif // MEDIA_VIDEO_CAPTURE_SCREEN_SCREEN_CAPTURE_FRAME_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698