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

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

Issue 1983193002: Decouple capture timestamp and reference time (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change OnIncomingCapturedBuffer Sig Created 4 years, 7 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.
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 #endif 193 #endif
194 }; 194 };
195 195
196 virtual ~Client() {} 196 virtual ~Client() {}
197 197
198 // Captured a new video frame, data for which is pointed to by |data|. 198 // Captured a new video frame, data for which is pointed to by |data|.
199 // 199 //
200 // The format of the frame is described by |frame_format|, and is assumed to 200 // The format of the frame is described by |frame_format|, and is assumed to
201 // be tightly packed. This method will try to reserve an output buffer and 201 // be tightly packed. This method will try to reserve an output buffer and
202 // copy from |data| into the output buffer. If no output buffer is 202 // copy from |data| into the output buffer. If no output buffer is
203 // available, the frame will be silently dropped. 203 // available, the frame will be silently dropped. |reference_time| is
204 // system clock time when we detect the capture happens, it is used for
205 // Audio/Video sync, not an exact presentation time for playout, because it
206 // could contain noise. |timestamp| measures the ideal time span between the
207 // first frame in the stream and the current frame; however, however, the
miu 2016/05/25 01:51:30 s/however, however,/however,/
qiangchen 2016/05/25 16:46:17 Done.
208 // time source is determined by the platform's device driver and is often
209 // not the system clock, or even has a drift with respect to system clock.
204 virtual void OnIncomingCapturedData(const uint8_t* data, 210 virtual void OnIncomingCapturedData(const uint8_t* data,
205 int length, 211 int length,
206 const VideoCaptureFormat& frame_format, 212 const VideoCaptureFormat& frame_format,
207 int clockwise_rotation, 213 int clockwise_rotation,
208 const base::TimeTicks& timestamp) = 0; 214 base::TimeTicks reference_time,
215 base::TimeDelta timestamp) = 0;
209 216
210 // Reserve an output buffer into which contents can be captured directly. 217 // Reserve an output buffer into which contents can be captured directly.
211 // The returned Buffer will always be allocated with a memory size suitable 218 // The returned Buffer will always be allocated with a memory size suitable
212 // for holding a packed video frame with pixels of |format| format, of 219 // for holding a packed video frame with pixels of |format| format, of
213 // |dimensions| frame dimensions. It is permissible for |dimensions| to be 220 // |dimensions| frame dimensions. It is permissible for |dimensions| to be
214 // zero; in which case the returned Buffer does not guarantee memory 221 // zero; in which case the returned Buffer does not guarantee memory
215 // backing, but functions as a reservation for external input for the 222 // backing, but functions as a reservation for external input for the
216 // purposes of buffer throttling. 223 // purposes of buffer throttling.
217 // 224 //
218 // The output buffer stays reserved and mapped for use until the Buffer 225 // The output buffer stays reserved and mapped for use until the Buffer
219 // object is destroyed or returned. 226 // object is destroyed or returned.
220 virtual std::unique_ptr<Buffer> ReserveOutputBuffer( 227 virtual std::unique_ptr<Buffer> ReserveOutputBuffer(
221 const gfx::Size& dimensions, 228 const gfx::Size& dimensions,
222 VideoPixelFormat format, 229 VideoPixelFormat format,
223 VideoPixelStorage storage) = 0; 230 VideoPixelStorage storage) = 0;
224 231
225 // Captured new video data, held in |frame| or |buffer|, respectively for 232 // Captured new video data, held in |frame| or |buffer|, respectively for
226 // OnIncomingCapturedVideoFrame() and OnIncomingCapturedBuffer(). 233 // OnIncomingCapturedVideoFrame() and OnIncomingCapturedBuffer().
227 // 234 //
228 // In both cases, as the frame is backed by a reservation returned by 235 // In both cases, as the frame is backed by a reservation returned by
229 // ReserveOutputBuffer(), delivery is guaranteed and will require no 236 // ReserveOutputBuffer(), delivery is guaranteed and will require no
230 // additional copies in the browser process. 237 // additional copies in the browser process.
238 // See OnIncomingCapturedData for details of |reference_time| and
239 // |timestamp|.
231 virtual void OnIncomingCapturedBuffer( 240 virtual void OnIncomingCapturedBuffer(
232 std::unique_ptr<Buffer> buffer, 241 std::unique_ptr<Buffer> buffer,
233 const VideoCaptureFormat& frame_format, 242 const VideoCaptureFormat& frame_format,
234 const base::TimeTicks& timestamp) = 0; 243 base::TimeTicks reference_time,
244 base::TimeDelta timestamp) = 0;
235 virtual void OnIncomingCapturedVideoFrame( 245 virtual void OnIncomingCapturedVideoFrame(
236 std::unique_ptr<Buffer> buffer, 246 std::unique_ptr<Buffer> buffer,
237 const scoped_refptr<VideoFrame>& frame, 247 const scoped_refptr<VideoFrame>& frame,
238 const base::TimeTicks& timestamp) = 0; 248 base::TimeTicks reference_time) = 0;
239 249
240 // Attempts to reserve the same Buffer provided in the last call to one of 250 // Attempts to reserve the same Buffer provided in the last call to one of
241 // the OnIncomingCapturedXXX() methods. This will fail if the content of the 251 // the OnIncomingCapturedXXX() methods. This will fail if the content of the
242 // Buffer has not been preserved, or if the |dimensions|, |format|, or 252 // Buffer has not been preserved, or if the |dimensions|, |format|, or
243 // |storage| disagree with how it was reserved via ReserveOutputBuffer(). 253 // |storage| disagree with how it was reserved via ReserveOutputBuffer().
244 // When this operation fails, nullptr will be returned. 254 // When this operation fails, nullptr will be returned.
245 virtual std::unique_ptr<Buffer> ResurrectLastOutputBuffer( 255 virtual std::unique_ptr<Buffer> ResurrectLastOutputBuffer(
246 const gfx::Size& dimensions, 256 const gfx::Size& dimensions,
247 VideoPixelFormat format, 257 VideoPixelFormat format,
248 VideoPixelStorage storage) = 0; 258 VideoPixelStorage storage) = 0;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 326
317 private: 327 private:
318 // Gets the power line frequency from the current system time zone if this is 328 // Gets the power line frequency from the current system time zone if this is
319 // defined, otherwise returns 0. 329 // defined, otherwise returns 0.
320 PowerLineFrequency GetPowerLineFrequencyForLocation() const; 330 PowerLineFrequency GetPowerLineFrequencyForLocation() const;
321 }; 331 };
322 332
323 } // namespace media 333 } // namespace media
324 334
325 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 335 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698