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

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

Issue 1064963002: 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"
26 27
27 namespace media { 28 namespace media {
28 29
29 class MEDIA_EXPORT VideoCaptureDevice { 30 class MEDIA_EXPORT VideoCaptureDevice {
30 public: 31 public:
31 // Represents a capture device name and ID. 32 // Represents a capture device name and ID.
32 // You should not create an instance of this class directly by e.g. setting 33 // You should not create an instance of this class directly by e.g. setting
33 // various properties directly. Instead use 34 // various properties directly. Instead use
34 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to 35 // VideoCaptureDevice::GetDeviceNames to do this for you and if you need to
35 // cache your own copy of a name, you can do so via the copy constructor. 36 // cache your own copy of a name, you can do so via the copy constructor.
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Interface defining the methods that clients of VideoCapture must have. It 192 // Interface defining the methods that clients of VideoCapture must have. It
192 // is actually two-in-one: clients may implement OnIncomingCapturedData() or 193 // is actually two-in-one: clients may implement OnIncomingCapturedData() or
193 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them. 194 // ReserveOutputBuffer() + OnIncomingCapturedVideoFrame(), or all of them.
194 // All clients must implement OnError(). 195 // All clients must implement OnError().
195 class MEDIA_EXPORT Client { 196 class MEDIA_EXPORT Client {
196 public: 197 public:
197 // Memory buffer returned by Client::ReserveOutputBuffer(). 198 // Memory buffer returned by Client::ReserveOutputBuffer().
198 class Buffer : public base::RefCountedThreadSafe<Buffer> { 199 class Buffer : public base::RefCountedThreadSafe<Buffer> {
199 public: 200 public:
200 virtual int id() const = 0; 201 virtual int id() const = 0;
201 virtual void* data() const = 0;
202 virtual size_t size() const = 0; 202 virtual size_t size() const = 0;
203 virtual scoped_ptr<DataHandle> GetDataHandle() = 0;
miu 2015/04/15 19:12:40 Having a second level of acquiring a buffer seems
mcasas 2015/04/16 03:11:22 SG, with that assumption in mind and after double
204 virtual ClientBuffer AsClientBuffer() = 0;
203 205
204 protected: 206 protected:
205 friend class base::RefCountedThreadSafe<Buffer>; 207 friend class base::RefCountedThreadSafe<Buffer>;
206 virtual ~Buffer() {} 208 virtual ~Buffer() {}
207 }; 209 };
208 210
209 virtual ~Client() {} 211 virtual ~Client() {}
210 212
211 // Captured a new video frame, data for which is pointed to by |data|. 213 // Captured a new video frame, data for which is pointed to by |data|.
212 // 214 //
(...skipping 27 matching lines...) Expand all
240 // zero; in which case the returned Buffer does not guarantee memory 242 // zero; in which case the returned Buffer does not guarantee memory
241 // backing, but functions as a reservation for external input for the 243 // backing, but functions as a reservation for external input for the
242 // purposes of buffer throttling. 244 // purposes of buffer throttling.
243 // 245 //
244 // The output buffer stays reserved for use until the Buffer object is 246 // The output buffer stays reserved for use until the Buffer object is
245 // destroyed. 247 // destroyed.
246 virtual scoped_refptr<Buffer> ReserveOutputBuffer( 248 virtual scoped_refptr<Buffer> ReserveOutputBuffer(
247 media::VideoPixelFormat format, 249 media::VideoPixelFormat format,
248 const gfx::Size& dimensions) = 0; 250 const gfx::Size& dimensions) = 0;
249 251
250 // Captured a new video frame, held in |frame|. 252 // Captured new video data, held in |frame| or |buffer|, respectively for
253 // OnIncomingCapturedVideoFrame() and OnIncomingCapturedBuffer().
251 // 254 //
252 // As the frame is backed by a reservation returned by 255 // In both cases, as the frame is backed by a reservation returned by
253 // ReserveOutputBuffer(), delivery is guaranteed and will require no 256 // ReserveOutputBuffer(), delivery is guaranteed and will require no
254 // additional copies in the browser process. 257 // additional copies in the browser process.
258 virtual void OnIncomingCapturedBuffer(
259 const scoped_refptr<Buffer>& buffer,
260 const VideoCaptureFormat& frame_format,
261 const base::TimeTicks& timestamp) = 0;
255 virtual void OnIncomingCapturedVideoFrame( 262 virtual void OnIncomingCapturedVideoFrame(
256 const scoped_refptr<Buffer>& buffer, 263 const scoped_refptr<Buffer>& buffer,
257 const scoped_refptr<media::VideoFrame>& frame, 264 const scoped_refptr<VideoFrame>& frame,
258 const base::TimeTicks& timestamp) = 0; 265 const base::TimeTicks& timestamp) = 0;
259 266
260 // An error has occurred that cannot be handled and VideoCaptureDevice must 267 // An error has occurred that cannot be handled and VideoCaptureDevice must
261 // be StopAndDeAllocate()-ed. |reason| is a text description of the error. 268 // be StopAndDeAllocate()-ed. |reason| is a text description of the error.
262 virtual void OnError(const std::string& reason) = 0; 269 virtual void OnError(const std::string& reason) = 0;
263 270
264 // VideoCaptureDevice requests the |message| to be logged. 271 // VideoCaptureDevice requests the |message| to be logged.
265 virtual void OnLog(const std::string& message) {} 272 virtual void OnLog(const std::string& message) {}
266 }; 273 };
267 274
(...skipping 23 matching lines...) Expand all
291 int GetPowerLineFrequencyForLocation() const; 298 int GetPowerLineFrequencyForLocation() const;
292 299
293 protected: 300 protected:
294 static const int kPowerLine50Hz = 50; 301 static const int kPowerLine50Hz = 50;
295 static const int kPowerLine60Hz = 60; 302 static const int kPowerLine60Hz = 60;
296 }; 303 };
297 304
298 } // namespace media 305 } // namespace media
299 306
300 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 307 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698