| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 public: | 52 public: |
| 53 // Memory buffer returned by Client::ReserveOutputBuffer(). | 53 // Memory buffer returned by Client::ReserveOutputBuffer(). |
| 54 class CAPTURE_EXPORT Buffer { | 54 class CAPTURE_EXPORT Buffer { |
| 55 public: | 55 public: |
| 56 virtual ~Buffer() = 0; | 56 virtual ~Buffer() = 0; |
| 57 virtual int id() const = 0; | 57 virtual int id() const = 0; |
| 58 virtual gfx::Size dimensions() const = 0; | 58 virtual gfx::Size dimensions() const = 0; |
| 59 virtual size_t mapped_size() const = 0; | 59 virtual size_t mapped_size() const = 0; |
| 60 virtual void* data(int plane) = 0; | 60 virtual void* data(int plane) = 0; |
| 61 void* data() { return data(0); } | 61 void* data() { return data(0); } |
| 62 virtual ClientBuffer AsClientBuffer(int plane) = 0; | |
| 63 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) | 62 #if defined(OS_POSIX) && !(defined(OS_MACOSX) && !defined(OS_IOS)) |
| 64 virtual base::FileDescriptor AsPlatformFile() = 0; | 63 virtual base::FileDescriptor AsPlatformFile() = 0; |
| 65 #endif | 64 #endif |
| 65 virtual bool IsBackedByVideoFrame() const = 0; |
| 66 virtual scoped_refptr<VideoFrame> GetVideoFrame() = 0; |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 virtual ~Client() {} | 69 virtual ~Client() {} |
| 69 | 70 |
| 70 // Captured a new video frame, data for which is pointed to by |data|. | 71 // Captured a new video frame, data for which is pointed to by |data|. |
| 71 // | 72 // |
| 72 // The format of the frame is described by |frame_format|, and is assumed to | 73 // The format of the frame is described by |frame_format|, and is assumed to |
| 73 // be tightly packed. This method will try to reserve an output buffer and | 74 // be tightly packed. This method will try to reserve an output buffer and |
| 74 // copy from |data| into the output buffer. If no output buffer is | 75 // copy from |data| into the output buffer. If no output buffer is |
| 75 // available, the frame will be silently dropped. |reference_time| is | 76 // available, the frame will be silently dropped. |reference_time| is |
| (...skipping 26 matching lines...) Expand all Loading... |
| 102 VideoPixelStorage storage) = 0; | 103 VideoPixelStorage storage) = 0; |
| 103 | 104 |
| 104 // Captured new video data, held in |frame| or |buffer|, respectively for | 105 // Captured new video data, held in |frame| or |buffer|, respectively for |
| 105 // OnIncomingCapturedVideoFrame() and OnIncomingCapturedBuffer(). | 106 // OnIncomingCapturedVideoFrame() and OnIncomingCapturedBuffer(). |
| 106 // | 107 // |
| 107 // In both cases, as the frame is backed by a reservation returned by | 108 // In both cases, as the frame is backed by a reservation returned by |
| 108 // ReserveOutputBuffer(), delivery is guaranteed and will require no | 109 // ReserveOutputBuffer(), delivery is guaranteed and will require no |
| 109 // additional copies in the browser process. | 110 // additional copies in the browser process. |
| 110 // See OnIncomingCapturedData for details of |reference_time| and | 111 // See OnIncomingCapturedData for details of |reference_time| and |
| 111 // |timestamp|. | 112 // |timestamp|. |
| 113 // TODO(chfremer): Consider removing one of the two in order to simplify the |
| 114 // interface. |
| 112 virtual void OnIncomingCapturedBuffer( | 115 virtual void OnIncomingCapturedBuffer( |
| 113 std::unique_ptr<Buffer> buffer, | 116 std::unique_ptr<Buffer> buffer, |
| 114 const VideoCaptureFormat& frame_format, | 117 const VideoCaptureFormat& frame_format, |
| 115 base::TimeTicks reference_time, | 118 base::TimeTicks reference_time, |
| 116 base::TimeDelta timestamp) = 0; | 119 base::TimeDelta timestamp) = 0; |
| 117 virtual void OnIncomingCapturedVideoFrame( | 120 virtual void OnIncomingCapturedVideoFrame( |
| 118 std::unique_ptr<Buffer> buffer, | 121 std::unique_ptr<Buffer> buffer, |
| 119 const scoped_refptr<VideoFrame>& frame) = 0; | 122 const scoped_refptr<VideoFrame>& frame) = 0; |
| 120 | 123 |
| 121 // Attempts to reserve the same Buffer provided in the last call to one of | 124 // Attempts to reserve the same Buffer provided in the last call to one of |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 230 |
| 228 private: | 231 private: |
| 229 // Gets the power line frequency from the current system time zone if this is | 232 // Gets the power line frequency from the current system time zone if this is |
| 230 // defined, otherwise returns 0. | 233 // defined, otherwise returns 0. |
| 231 PowerLineFrequency GetPowerLineFrequencyForLocation() const; | 234 PowerLineFrequency GetPowerLineFrequencyForLocation() const; |
| 232 }; | 235 }; |
| 233 | 236 |
| 234 } // namespace media | 237 } // namespace media |
| 235 | 238 |
| 236 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ | 239 #endif // MEDIA_CAPTURE_VIDEO_VIDEO_CAPTURE_DEVICE_H_ |
| OLD | NEW |