OLD | NEW |
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 // VideoCaptureDevice is the abstract base class for realizing video capture | 5 // VideoCaptureDevice is the abstract base class for realizing video capture |
6 // device support in Chromium. It provides the interface for OS dependent | 6 // device support in Chromium. It provides the interface for OS dependent |
7 // implementations. | 7 // implementations. |
8 // The class is created and functions are invoked on a thread owned by | 8 // The class is created and functions are invoked on a thread owned by |
9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS | 9 // VideoCaptureManager. Capturing is done on other threads, depending on the OS |
10 // specific implementation. | 10 // specific implementation. |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "media/capture/video/video_capture_device_descriptor.h" | 34 #include "media/capture/video/video_capture_device_descriptor.h" |
35 #include "media/capture/video_capture_types.h" | 35 #include "media/capture/video_capture_types.h" |
36 #include "ui/gfx/gpu_memory_buffer.h" | 36 #include "ui/gfx/gpu_memory_buffer.h" |
37 | 37 |
38 namespace tracked_objects { | 38 namespace tracked_objects { |
39 class Location; | 39 class Location; |
40 } // namespace tracked_objects | 40 } // namespace tracked_objects |
41 | 41 |
42 namespace media { | 42 namespace media { |
43 | 43 |
44 class CAPTURE_EXPORT FrameBufferPool { | |
45 public: | |
46 virtual ~FrameBufferPool() {} | |
47 | |
48 virtual void SetBufferHold(int buffer_id) = 0; | |
49 virtual void ReleaseBufferHold(int buffer_id) = 0; | |
50 }; | |
51 | |
52 class CAPTURE_EXPORT VideoFrameConsumerFeedbackObserver { | 44 class CAPTURE_EXPORT VideoFrameConsumerFeedbackObserver { |
53 public: | 45 public: |
54 virtual ~VideoFrameConsumerFeedbackObserver() {} | 46 virtual ~VideoFrameConsumerFeedbackObserver() {} |
55 | 47 |
56 // During processing of a video frame, consumers may report back their | 48 // During processing of a video frame, consumers may report back their |
57 // utilization level to the source device. The device may use this information | 49 // utilization level to the source device. The device may use this information |
58 // to adjust the rate of data it pushes out. Values are interpreted as | 50 // to adjust the rate of data it pushes out. Values are interpreted as |
59 // follows: | 51 // follows: |
60 // Less than 0.0 is meaningless and should be ignored. 1.0 indicates a | 52 // Less than 0.0 is meaningless and should be ignored. 1.0 indicates a |
61 // maximum sustainable utilization. Greater than 1.0 indicates the consumer | 53 // maximum sustainable utilization. Greater than 1.0 indicates the consumer |
(...skipping 17 matching lines...) Expand all Loading... |
79 class CAPTURE_EXPORT VideoCaptureDevice | 71 class CAPTURE_EXPORT VideoCaptureDevice |
80 : public VideoFrameConsumerFeedbackObserver { | 72 : public VideoFrameConsumerFeedbackObserver { |
81 public: | 73 public: |
82 | 74 |
83 // Interface defining the methods that clients of VideoCapture must have. It | 75 // Interface defining the methods that clients of VideoCapture must have. It |
84 // is actually two-in-one: clients may implement OnIncomingCapturedData() or | 76 // is actually two-in-one: clients may implement OnIncomingCapturedData() or |
85 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them. | 77 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them. |
86 // All clients must implement OnError(). | 78 // All clients must implement OnError(). |
87 class CAPTURE_EXPORT Client { | 79 class CAPTURE_EXPORT Client { |
88 public: | 80 public: |
89 // Move-only type representing access to a buffer handle as well as | 81 // Struct bundling several parameters being passed between a |
90 // read-write permission to its contents. | 82 // VideoCaptureDevice and its VideoCaptureDevice::Client. |
91 class CAPTURE_EXPORT Buffer { | 83 struct CAPTURE_EXPORT Buffer { |
92 public: | 84 public: |
93 // Destructor-only interface for encapsulating scoped access permission to | 85 // Destructor-only interface for encapsulating scoped access permission to |
94 // a Buffer. | 86 // a Buffer. |
95 class CAPTURE_EXPORT ScopedAccessPermission { | 87 class CAPTURE_EXPORT ScopedAccessPermission { |
96 public: | 88 public: |
97 virtual ~ScopedAccessPermission() {} | 89 virtual ~ScopedAccessPermission() {} |
98 }; | 90 }; |
99 | 91 |
100 class CAPTURE_EXPORT HandleProvider { | 92 class CAPTURE_EXPORT HandleProvider { |
101 public: | 93 public: |
102 virtual ~HandleProvider() {} | 94 virtual ~HandleProvider() {} |
103 virtual mojo::ScopedSharedBufferHandle | 95 virtual mojo::ScopedSharedBufferHandle |
104 GetHandleForInterProcessTransit() = 0; | 96 GetHandleForInterProcessTransit() = 0; |
105 virtual base::SharedMemoryHandle | 97 virtual base::SharedMemoryHandle |
106 GetNonOwnedSharedMemoryHandleForLegacyIPC() = 0; | 98 GetNonOwnedSharedMemoryHandleForLegacyIPC() = 0; |
107 virtual std::unique_ptr<VideoCaptureBufferHandle> | 99 virtual std::unique_ptr<VideoCaptureBufferHandle> |
108 GetHandleForInProcessAccess() = 0; | 100 GetHandleForInProcessAccess() = 0; |
109 }; | 101 }; |
110 | 102 |
111 Buffer(); | 103 Buffer(); |
112 Buffer(int buffer_id, | 104 Buffer(int buffer_id, |
113 int frame_feedback_id, | 105 int frame_feedback_id, |
114 std::unique_ptr<HandleProvider> handle_provider, | 106 std::unique_ptr<HandleProvider> handle_provider, |
115 std::unique_ptr<ScopedAccessPermission> access_permission); | 107 std::unique_ptr<ScopedAccessPermission> access_permission); |
116 ~Buffer(); | 108 ~Buffer(); |
117 Buffer(Buffer&& other); | 109 Buffer(Buffer&& other); |
118 Buffer& operator=(Buffer&& other); | 110 Buffer& operator=(Buffer&& other); |
119 | 111 |
120 bool is_valid() const { return handle_provider_ != nullptr; } | 112 bool is_valid() const { return handle_provider != nullptr; } |
121 int id() const { return id_; } | |
122 int frame_feedback_id() const { return frame_feedback_id_; } | |
123 HandleProvider* handle_provider() const { return handle_provider_.get(); } | |
124 | 113 |
125 private: | 114 int id; |
126 std::unique_ptr<HandleProvider> handle_provider_; | 115 int frame_feedback_id; |
127 std::unique_ptr<ScopedAccessPermission> access_permission_; | 116 std::unique_ptr<HandleProvider> handle_provider; |
128 int id_; | 117 std::unique_ptr<ScopedAccessPermission> access_permission; |
129 int frame_feedback_id_; | |
130 | |
131 DISALLOW_COPY_AND_ASSIGN(Buffer); | |
132 }; | 118 }; |
133 | 119 |
134 virtual ~Client() {} | 120 virtual ~Client() {} |
135 | 121 |
136 // Captured a new video frame, data for which is pointed to by |data|. | 122 // Captured a new video frame, data for which is pointed to by |data|. |
137 // | 123 // |
138 // The format of the frame is described by |frame_format|, and is assumed to | 124 // The format of the frame is described by |frame_format|, and is assumed to |
139 // be tightly packed. This method will try to reserve an output buffer and | 125 // be tightly packed. This method will try to reserve an output buffer and |
140 // copy from |data| into the output buffer. If no output buffer is | 126 // copy from |data| into the output buffer. If no output buffer is |
141 // available, the frame will be silently dropped. |reference_time| is | 127 // available, the frame will be silently dropped. |reference_time| is |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 288 |
303 private: | 289 private: |
304 // Gets the power line frequency from the current system time zone if this is | 290 // Gets the power line frequency from the current system time zone if this is |
305 // defined, otherwise returns 0. | 291 // defined, otherwise returns 0. |
306 PowerLineFrequency GetPowerLineFrequencyForLocation() const; | 292 PowerLineFrequency GetPowerLineFrequencyForLocation() const; |
307 }; | 293 }; |
308 | 294 |
309 } // namespace media | 295 } // namespace media |
310 | 296 |
311 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ | 297 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ |
OLD | NEW |