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

Side by Side Diff: remoting/host/video_frame_capturer.h

Issue 11363128: Converted VideoFrameCapturer callbacks into a VideoFrameCapturer::Delegate interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_ 5 #ifndef REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_
6 #define REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_ 6 #define REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // 43 //
44 // (4) Stop 44 // (4) Stop
45 // This is when post-capture steps are executed, such as releasing the 45 // This is when post-capture steps are executed, such as releasing the
46 // assertion that prevents the display from sleeping. 46 // assertion that prevents the display from sleeping.
47 // 47 //
48 // Implementation has to ensure the following guarantees: 48 // Implementation has to ensure the following guarantees:
49 // 1. Double buffering 49 // 1. Double buffering
50 // Since data can be read while another capture action is happening. 50 // Since data can be read while another capture action is happening.
51 class VideoFrameCapturer { 51 class VideoFrameCapturer {
52 public: 52 public:
53 // CaptureCompletedCallback is called when the capturer has completed. 53 // Provides callbacks used by the capturer to pass captured video frames and
54 typedef base::Callback<void(scoped_refptr<CaptureData>)> 54 // mouse cursor shapes to the processing pipeline.
55 CaptureCompletedCallback; 55 class Delegate {
56 public:
57 virtual ~Delegate() {}
56 58
57 // CursorShapeChangedCallback is called when the cursor shape has changed. 59 // Called when the capturer has completed. |capture_data| describes
58 typedef base::Callback<void(scoped_ptr<protocol::CursorShapeInfo>)> 60 // a captured frame.
59 CursorShapeChangedCallback; 61 virtual void OnCaptureCompleted(
Wez 2012/11/07 19:58:29 nit: OnCaptureFrameCompleted; I'd like to rename C
alexeypa (please no reviews) 2012/11/07 20:54:41 Ack.
62 scoped_refptr<CaptureData> capture_data) = 0;
63
64 // Called when the cursor shape has changed.
65 virtual void OnCursorShapeChanged(
66 scoped_ptr<protocol::CursorShapeInfo> cursor_shape) = 0;
67 };
60 68
61 virtual ~VideoFrameCapturer() {} 69 virtual ~VideoFrameCapturer() {}
62 70
63 // Create platform-specific capturer. 71 // Create platform-specific capturer.
64 static VideoFrameCapturer* Create(); 72 static VideoFrameCapturer* Create();
65 73
66 #if defined(OS_LINUX) 74 #if defined(OS_LINUX)
67 // Set whether the VideoFrameCapturer should try to use X DAMAGE support if it 75 // Set whether the VideoFrameCapturer should try to use X DAMAGE support if it
68 // is available. This needs to be called before the VideoFrameCapturer is 76 // is available. This needs to be called before the VideoFrameCapturer is
69 // created. 77 // created.
70 // This is used by the Virtual Me2Me host, since the XDamage extension is 78 // This is used by the Virtual Me2Me host, since the XDamage extension is
71 // known to work reliably in this case. 79 // known to work reliably in this case.
72 80
73 // TODO(lambroslambrou): This currently sets a global flag, referenced during 81 // TODO(lambroslambrou): This currently sets a global flag, referenced during
74 // VideoFrameCapturer::Create(). This is a temporary solution, until the 82 // VideoFrameCapturer::Create(). This is a temporary solution, until the
75 // DesktopEnvironment class is refactored to allow applications to control 83 // DesktopEnvironment class is refactored to allow applications to control
76 // the creation of various stubs (including the VideoFrameCapturer) - see 84 // the creation of various stubs (including the VideoFrameCapturer) - see
77 // http://crbug.com/104544 85 // http://crbug.com/104544
78 static void EnableXDamage(bool enable); 86 static void EnableXDamage(bool enable);
79 #endif // defined(OS_LINUX) 87 #endif // defined(OS_LINUX)
80 88
81 // Called at the beginning of a capturing session. 89 // Called at the beginning of a capturing session.
Wez 2012/11/07 19:58:29 nit: |delegate| remain valid until Stop() is calle
alexeypa (please no reviews) 2012/11/07 20:54:41 Done.
82 virtual void Start( 90 virtual void Start(Delegate* delegate) = 0;
83 const CursorShapeChangedCallback& callback) = 0;
84 91
85 // Called at the end of a capturing session. 92 // Called at the end of a capturing session.
86 virtual void Stop() = 0; 93 virtual void Stop() = 0;
87 94
88 // Return the pixel format of the screen. 95 // Returns the pixel format of the screen.
89 virtual media::VideoFrame::Format pixel_format() const = 0; 96 virtual media::VideoFrame::Format pixel_format() const = 0;
90 97
91 // Invalidate the specified region. 98 // Invalidates the specified region.
92 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0; 99 virtual void InvalidateRegion(const SkRegion& invalid_region) = 0;
93 100
94 // Capture the screen data associated with each of the accumulated 101 // Captures the screen data associated with each of the accumulated
95 // dirty region. 102 // dirty region. When the capture is complete, the delegate is notified even
96 // When the capture is complete, |callback| is called even if the dirty region 103 // if the dirty region is empty.
97 // is empty.
98 // 104 //
99 // It is OK to call this method while another thread is reading 105 // It is OK to call this method while another thread is reading
100 // data of the previous capture. 106 // data of the previous capture. There can be at most one concurrent read
101 // There can be at most one concurrent read going on when this 107 // going on when this method is called.
102 // method is called. 108 virtual void CaptureInvalidRegion() = 0;
103 virtual void CaptureInvalidRegion(
104 const CaptureCompletedCallback& callback) = 0;
105 109
106 // Get the size of the most recently captured screen. 110 // Get the size of the most recently captured screen.
107 virtual const SkISize& size_most_recent() const = 0; 111 virtual const SkISize& size_most_recent() const = 0;
108 }; 112 };
109 113
110 } // namespace remoting 114 } // namespace remoting
111 115
112 #endif // REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_ 116 #endif // REMOTING_HOST_VIDEO_FRAME_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698