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

Side by Side Diff: media/video/capture/video_capture_device.h

Issue 1090273006: Revert of VideoCapture: add support for GpuMemoryBuffer allocation and lifetime mgmt in VideoCaptureBufferPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 unified diff | Download patch
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 // 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.
11 11
12 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 12 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
13 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 13 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
14 14
15 #include <list> 15 #include <list>
16 #include <string> 16 #include <string>
17 17
18 #include "base/logging.h" 18 #include "base/logging.h"
19 #include "base/memory/ref_counted.h" 19 #include "base/memory/ref_counted.h"
20 #include "base/memory/scoped_ptr.h" 20 #include "base/memory/scoped_ptr.h"
21 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
22 #include "base/time/time.h" 22 #include "base/time/time.h"
23 #include "media/base/media_export.h" 23 #include "media/base/media_export.h"
24 #include "media/base/video_capture_types.h" 24 #include "media/base/video_capture_types.h"
25 #include "media/base/video_frame.h" 25 #include "media/base/video_frame.h"
26 #include "ui/gfx/gpu_memory_buffer.h"
27 26
28 namespace media { 27 namespace media {
29 28
30 class MEDIA_EXPORT VideoCaptureDevice { 29 class MEDIA_EXPORT VideoCaptureDevice {
31 public: 30 public:
32 // Represents a capture device name and ID. 31 // Represents a capture device name and ID.
33 // You should not create an instance of this class directly by e.g. setting 32 // You should not create an instance of this class directly by e.g. setting
34 // various properties directly. Instead use 33 // various properties directly. Instead use
35 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to 34 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to
36 // cache your own copy of a name, you can do so via the copy constructor. 35 // cache your own copy of a name, you can do so via the copy constructor.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // Manages a list of Name entries. 188 // Manages a list of Name entries.
190 typedef std::list<Name> Names; 189 typedef std::list<Name> Names;
191 190
192 // Interface defining the methods that clients of VideoCapture must have. It 191 // Interface defining the methods that clients of VideoCapture must have. It
193 // is actually two-in-one: clients may implement OnIncomingCapturedData() or 192 // is actually two-in-one: clients may implement OnIncomingCapturedData() or
194 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them. 193 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them.
195 // All clients must implement OnError(). 194 // All clients must implement OnError().
196 class MEDIA_EXPORT Client { 195 class MEDIA_EXPORT Client {
197 public: 196 public:
198 // Memory buffer returned by Client::ReserveOutputBuffer(). 197 // Memory buffer returned by Client::ReserveOutputBuffer().
199 class MEDIA_EXPORT Buffer { 198 class Buffer : public base::RefCountedThreadSafe<Buffer> {
200 public: 199 public:
201 virtual ~Buffer() = 0;
202 virtual int id() const = 0; 200 virtual int id() const = 0;
201 virtual void* data() const = 0;
203 virtual size_t size() const = 0; 202 virtual size_t size() const = 0;
204 virtual void* data() = 0; 203
205 virtual ClientBuffer AsClientBuffer() = 0; 204 protected:
205 friend class base::RefCountedThreadSafe<Buffer>;
206 virtual ~Buffer() {}
206 }; 207 };
207 208
208 virtual ~Client() {} 209 virtual ~Client() {}
209 210
210 // Captured a new video frame, data for which is pointed to by |data|. 211 // Captured a new video frame, data for which is pointed to by |data|.
211 // 212 //
212 // The format of the frame is described by |frame_format|, and is assumed to 213 // The format of the frame is described by |frame_format|, and is assumed to
213 // be tightly packed. This method will try to reserve an output buffer and 214 // be tightly packed. This method will try to reserve an output buffer and
214 // copy from |data| into the output buffer. If no output buffer is 215 // copy from |data| into the output buffer. If no output buffer is
215 // available, the frame will be silently dropped. 216 // available, the frame will be silently dropped.
(...skipping 17 matching lines...) Expand all
233 const base::TimeTicks& timestamp) = 0; 234 const base::TimeTicks& timestamp) = 0;
234 235
235 // Reserve an output buffer into which contents can be captured directly. 236 // Reserve an output buffer into which contents can be captured directly.
236 // The returned Buffer will always be allocated with a memory size suitable 237 // The returned Buffer will always be allocated with a memory size suitable
237 // for holding a packed video frame with pixels of |format| format, of 238 // for holding a packed video frame with pixels of |format| format, of
238 // |dimensions| frame dimensions. It is permissible for |dimensions| to be 239 // |dimensions| frame dimensions. It is permissible for |dimensions| to be
239 // zero; in which case the returned Buffer does not guarantee memory 240 // zero; in which case the returned Buffer does not guarantee memory
240 // backing, but functions as a reservation for external input for the 241 // backing, but functions as a reservation for external input for the
241 // purposes of buffer throttling. 242 // purposes of buffer throttling.
242 // 243 //
243 // The output buffer stays reserved and mapped for use until the Buffer 244 // The output buffer stays reserved for use until the Buffer object is
244 // object is destroyed or returned. 245 // destroyed.
245 virtual scoped_ptr<Buffer> ReserveOutputBuffer( 246 virtual scoped_refptr<Buffer> ReserveOutputBuffer(
246 media::VideoPixelFormat format, 247 media::VideoPixelFormat format,
247 const gfx::Size& dimensions) = 0; 248 const gfx::Size& dimensions) = 0;
248 249
249 // Captured new video data, held in |frame| or |buffer|, respectively for 250 // Captured a new video frame, held in |frame|.
250 // OnIncomingCapturedVideoFrame() and OnIncomingCapturedBuffer().
251 // 251 //
252 // In both cases, as the frame is backed by a reservation returned by 252 // As the frame is backed by a reservation returned by
253 // ReserveOutputBuffer(), delivery is guaranteed and will require no 253 // ReserveOutputBuffer(), delivery is guaranteed and will require no
254 // additional copies in the browser process. 254 // additional copies in the browser process.
255 virtual void OnIncomingCapturedBuffer(
256 scoped_ptr<Buffer> buffer,
257 const VideoCaptureFormat& frame_format,
258 const base::TimeTicks& timestamp) = 0;
259 virtual void OnIncomingCapturedVideoFrame( 255 virtual void OnIncomingCapturedVideoFrame(
260 scoped_ptr<Buffer> buffer, 256 const scoped_refptr<Buffer>& buffer,
261 const scoped_refptr<VideoFrame>& frame, 257 const scoped_refptr<media::VideoFrame>& frame,
262 const base::TimeTicks& timestamp) = 0; 258 const base::TimeTicks& timestamp) = 0;
263 259
264 // An error has occurred that cannot be handled and VideoCaptureDevice must 260 // An error has occurred that cannot be handled and VideoCaptureDevice must
265 // be StopAndDeAllocate()-ed. |reason| is a text description of the error. 261 // be StopAndDeAllocate()-ed. |reason| is a text description of the error.
266 virtual void OnError(const std::string& reason) = 0; 262 virtual void OnError(const std::string& reason) = 0;
267 263
268 // VideoCaptureDevice requests the |message| to be logged. 264 // VideoCaptureDevice requests the |message| to be logged.
269 virtual void OnLog(const std::string& message) {} 265 virtual void OnLog(const std::string& message) {}
270 }; 266 };
271 267
(...skipping 23 matching lines...) Expand all
295 int GetPowerLineFrequencyForLocation() const; 291 int GetPowerLineFrequencyForLocation() const;
296 292
297 protected: 293 protected:
298 static const int kPowerLine50Hz = 50; 294 static const int kPowerLine50Hz = 50;
299 static const int kPowerLine60Hz = 60; 295 static const int kPowerLine60Hz = 60;
300 }; 296 };
301 297
302 } // namespace media 298 } // namespace media
303 299
304 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 300 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW
« no previous file with comments | « media/video/capture/fake_video_capture_device_unittest.cc ('k') | media/video/capture/video_capture_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698