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

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

Issue 1826643003: Add frame refresh to VideoCaptureDevice, and buffer pool resurrection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: REBASE before commit Created 4 years, 9 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // additional copies in the browser process. 235 // additional copies in the browser process.
236 virtual void OnIncomingCapturedBuffer( 236 virtual void OnIncomingCapturedBuffer(
237 scoped_ptr<Buffer> buffer, 237 scoped_ptr<Buffer> buffer,
238 const VideoCaptureFormat& frame_format, 238 const VideoCaptureFormat& frame_format,
239 const base::TimeTicks& timestamp) = 0; 239 const base::TimeTicks& timestamp) = 0;
240 virtual void OnIncomingCapturedVideoFrame( 240 virtual void OnIncomingCapturedVideoFrame(
241 scoped_ptr<Buffer> buffer, 241 scoped_ptr<Buffer> buffer,
242 const scoped_refptr<VideoFrame>& frame, 242 const scoped_refptr<VideoFrame>& frame,
243 const base::TimeTicks& timestamp) = 0; 243 const base::TimeTicks& timestamp) = 0;
244 244
245 // Attempts to reserve the same Buffer provided in the last call to one of
246 // the OnIncomingCapturedXXX() methods. This will fail if the content of the
247 // Buffer has not been preserved, or if the |dimensions|, |format|, or
248 // |storage| disagree with how it was reserved via ReserveOutputBuffer().
249 // When this operation fails, nullptr will be returned.
250 virtual scoped_ptr<Buffer> ResurrectLastOutputBuffer(
251 const gfx::Size& dimensions,
252 VideoPixelFormat format,
253 VideoPixelStorage storage) = 0;
254
245 // An error has occurred that cannot be handled and VideoCaptureDevice must 255 // An error has occurred that cannot be handled and VideoCaptureDevice must
246 // be StopAndDeAllocate()-ed. |reason| is a text description of the error. 256 // be StopAndDeAllocate()-ed. |reason| is a text description of the error.
247 virtual void OnError(const tracked_objects::Location& from_here, 257 virtual void OnError(const tracked_objects::Location& from_here,
248 const std::string& reason) = 0; 258 const std::string& reason) = 0;
249 259
250 // VideoCaptureDevice requests the |message| to be logged. 260 // VideoCaptureDevice requests the |message| to be logged.
251 virtual void OnLog(const std::string& message) {} 261 virtual void OnLog(const std::string& message) {}
252 262
253 // Returns the current buffer pool utilization, in the range 0.0 (no buffers 263 // Returns the current buffer pool utilization, in the range 0.0 (no buffers
254 // are in use by producers or consumers) to 1.0 (all buffers are in use). 264 // are in use by producers or consumers) to 1.0 (all buffers are in use).
255 virtual double GetBufferPoolUtilization() const = 0; 265 virtual double GetBufferPoolUtilization() const = 0;
256 }; 266 };
257 267
258 virtual ~VideoCaptureDevice(); 268 virtual ~VideoCaptureDevice();
259 269
260 // Prepares the camera for use. After this function has been called no other 270 // Prepares the video capturer for use. StopAndDeAllocate() must be called
261 // applications can use the camera. StopAndDeAllocate() must be called before 271 // before the object is deleted.
262 // the object is deleted.
263 virtual void AllocateAndStart(const VideoCaptureParams& params, 272 virtual void AllocateAndStart(const VideoCaptureParams& params,
264 scoped_ptr<Client> client) = 0; 273 scoped_ptr<Client> client) = 0;
265 274
266 // Deallocates the camera, possibly asynchronously. 275 // In cases where the video capturer self-pauses (e.g., a screen capturer
276 // where the screen's content has not changed in a while), consumers may call
277 // this to request a "refresh frame" be delivered to the Client. This is used
278 // in a number of circumstances, such as:
279 //
280 // 1. An additional consumer of video frames is starting up and requires a
281 // first frame (as opposed to not receiving a frame for an indeterminate
282 // amount of time).
283 // 2. A few repeats of the same frame would allow a lossy video encoder to
284 // improve the video quality of unchanging content.
285 //
286 // The default implementation is a no-op. VideoCaptureDevice implementations
287 // are not required to honor this request, especially if they do not
288 // self-pause and/or if honoring the request would cause them to exceed their
289 // configured maximum frame rate. Any VideoCaptureDevice that does self-pause,
290 // however, should provide an implementation of this method that makes
291 // reasonable attempts to honor these requests.
292 virtual void RequestRefreshFrame() {}
293
294 // Deallocates the video capturer, possibly asynchronously.
267 // 295 //
268 // This call requires the device to do the following things, eventually: put 296 // This call requires the device to do the following things, eventually: put
269 // camera hardware into a state where other applications could use it, free 297 // hardware into a state where other applications could use it, free the
270 // the memory associated with capture, and delete the |client| pointer passed 298 // memory associated with capture, and delete the |client| pointer passed into
271 // into AllocateAndStart. 299 // AllocateAndStart.
272 // 300 //
273 // If deallocation is done asynchronously, then the device implementation must 301 // If deallocation is done asynchronously, then the device implementation must
274 // ensure that a subsequent AllocateAndStart() operation targeting the same ID 302 // ensure that a subsequent AllocateAndStart() operation targeting the same ID
275 // would be sequenced through the same task runner, so that deallocation 303 // would be sequenced through the same task runner, so that deallocation
276 // happens first. 304 // happens first.
277 virtual void StopAndDeAllocate() = 0; 305 virtual void StopAndDeAllocate() = 0;
278 306
279 // Gets the power line frequency, either from the params if specified by the 307 // Gets the power line frequency, either from the params if specified by the
280 // user or from the current system time zone. 308 // user or from the current system time zone.
281 PowerLineFrequency GetPowerLineFrequency( 309 PowerLineFrequency GetPowerLineFrequency(
282 const VideoCaptureParams& params) const; 310 const VideoCaptureParams& params) const;
283 311
284 private: 312 private:
285 // Gets the power line frequency from the current system time zone if this is 313 // Gets the power line frequency from the current system time zone if this is
286 // defined, otherwise returns 0. 314 // defined, otherwise returns 0.
287 PowerLineFrequency GetPowerLineFrequencyForLocation() const; 315 PowerLineFrequency GetPowerLineFrequencyForLocation() const;
288 }; 316 };
289 317
290 } // namespace media 318 } // namespace media
291 319
292 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_ 320 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURE_DEVICE_H_
OLDNEW
« no previous file with comments | « media/capture/video/fake_video_capture_device_unittest.cc ('k') | media/capture/video/video_capture_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698