Work around WebKeyboardEvent.domCode not being set on OS X.
[chromium-blink-merge.git] / media / base / video_capturer_source.h
blob774f28da02faf97e188a1eaffc5e5308b877c764
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_
6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/single_thread_task_runner.h"
14 #include "media/base/media_export.h"
15 #include "media/base/video_capture_types.h"
16 #include "media/base/video_frame.h"
18 namespace media {
20 // VideoCapturerSource is an interface representing the source for
21 // captured video. An implementation will periodically call the frame
22 // callback with new video frames.
23 class MEDIA_EXPORT VideoCapturerSource {
24 public:
25 virtual ~VideoCapturerSource();
27 // This callback is used to deliver video frames.
29 // |estimated_capture_time| - The capture time of the delivered video
30 // frame. This field represents the local time at which either: 1) the frame
31 // was generated, if it was done so locally; or 2) the targeted play-out time
32 // of the frame, if it was generated from a remote source. Either way, an
33 // implementation should not present the frame before this point-in-time. This
34 // value is NOT a high-resolution timestamp, and so it should not be used as a
35 // presentation time; but, instead, it should be used for buffering playback
36 // and for A/V synchronization purposes. NOTE: It is possible for this value
37 // to be null if the current implementation lacks this timing information.
39 // |video_frame->timestamp()| gives the presentation timestamp of the video
40 // frame relative to the first frame generated by the corresponding source.
41 // Because a source can start generating frames before a subscriber is added,
42 // the first video frame delivered may not have timestamp equal to 0.
43 typedef base::Callback<
44 void(const scoped_refptr<media::VideoFrame>& video_frame,
45 const base::TimeTicks& estimated_capture_time)>
46 VideoCaptureDeliverFrameCB;
48 typedef base::Callback<void(const media::VideoCaptureFormats&)>
49 VideoCaptureDeviceFormatsCB;
51 typedef base::Callback<void(bool)> RunningCallback;
53 // Collects the formats that can currently be used.
54 // |max_requested_height|, |max_requested_width|, and
55 // |max_requested_frame_rate| is used by Tab and Screen capture to decide what
56 // resolution/framerate to generate. |callback| is triggered when the formats
57 // have been collected.
58 virtual void GetCurrentSupportedFormats(
59 int max_requested_width,
60 int max_requested_height,
61 double max_requested_frame_rate,
62 const VideoCaptureDeviceFormatsCB& callback) = 0;
64 // Starts capturing frames using the resolution in |params|.
65 // |new_frame_callback| is triggered on |frame_callback_task_runner|
66 // when a new video frame is available.
67 // If capturing is started successfully then |running_callback| will be
68 // called with a parameter of true. Note that some implementations may
69 // simply reject StartCapture (by calling running_callback with a false
70 // argument) if called with the wrong task runner.
71 // If capturing fails to start or stopped due to an external event then
72 // |running_callback| will be called with a parameter of false.
73 // |running_callback| will always be called on the same thread as the
74 // StartCapture.
75 virtual void StartCapture(
76 const media::VideoCaptureParams& params,
77 const VideoCaptureDeliverFrameCB& new_frame_callback,
78 scoped_refptr<base::SingleThreadTaskRunner> frame_callback_task_runner,
79 const RunningCallback& running_callback) = 0;
81 // Stops capturing frames and clears all callbacks including the
82 // SupportedFormatsCallback callback. Note that queued frame callbacks
83 // may still occur after this call, so the caller must take care to
84 // use refcounted or weak references in |new_frame_callback|.
85 virtual void StopCapture() = 0;
88 } // namespace media
90 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_