Chromium Code Reviews| Index: media/video/capture/video_capturer_source.h |
| diff --git a/media/video/capture/video_capturer_source.h b/media/video/capture/video_capturer_source.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..806401de6ee2278d24d2fd33fab66f7d140da374 |
| --- /dev/null |
| +++ b/media/video/capture/video_capturer_source.h |
| @@ -0,0 +1,85 @@ |
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_ |
| +#define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| +#include "base/basictypes.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "media/base/media_export.h" |
| +#include "media/base/video_frame.h" |
| +#include "media/video/capture/video_capture_types.h" |
| + |
| +namespace media { |
| + |
| +// VideoCapturerSource is an interface representing the source for |
| +// captured video. An implementation will periodically call the frame |
| +// callback with new video frames. |
| +class MEDIA_EXPORT VideoCapturerSource |
|
Alpha Left Google
2015/02/04 03:07:52
I think this is best put in media/base. media/vide
hubbe
2015/02/05 20:23:00
That leaves a rather awkward dependency on video_c
|
| + : public base::RefCountedThreadSafe<media::VideoCapturerSource> { |
|
Alpha Left Google
2015/02/04 03:07:53
There's no need for this to be ref counted thread
hubbe
2015/02/05 20:23:00
Done.
|
| + public: |
| + // This callback is used to deliver video frames. |
| + // |
| + // |estimated_capture_time| - The capture time of the delivered video |
| + // frame. This field represents the local time at which either: 1) the frame |
| + // was generated, if it was done so locally; or 2) the targeted play-out time |
| + // of the frame, if it was generated from a remote source. Either way, an |
| + // implementation should not present the frame before this point-in-time. This |
| + // value is NOT a high-resolution timestamp, and so it should not be used as a |
| + // presentation time; but, instead, it should be used for buffering playback |
| + // and for A/V synchronization purposes. NOTE: It is possible for this value |
| + // to be null if the current implementation lacks this timing information. |
| + // |
| + // |video_frame->timestamp()| gives the presentation timestamp of the video |
| + // frame relative to the first frame generated by the corresponding source. |
| + // Because a source can start generating frames before a subscriber is added, |
| + // the first video frame delivered may not have timestamp equal to 0. |
| + typedef base::Callback< |
|
Alpha Left Google
2015/02/04 03:07:52
Please remove the definition of VideoCaptureDelive
hubbe
2015/02/05 20:23:00
Done.
|
| + void(const scoped_refptr<media::VideoFrame>& video_frame, |
| + const media::VideoCaptureFormat& format, |
| + const base::TimeTicks& estimated_capture_time)> |
| + VideoCaptureDeliverFrameCB; |
| + |
| + typedef base::Callback<void(const media::VideoCaptureFormats&)> |
| + VideoCaptureDeviceFormatsCB; |
| + |
| + typedef base::Callback<void(bool)> RunningCallback; |
| + |
| + // Collects the formats that can currently be used. |
| + // |max_requested_height|, |max_requested_width|, and |
| + // |max_requested_frame_rate| is used by Tab and Screen capture to decide what |
| + // resolution/framerate to generate. |callback| is triggered when the formats |
| + // have been collected. |
| + virtual void GetCurrentSupportedFormats( |
| + int max_requested_width, |
| + int max_requested_height, |
| + double max_requested_frame_rate, |
| + const VideoCaptureDeviceFormatsCB& callback) = 0; |
| + |
| + // Starts capturing frames using the resolution in |params|. |
| + // |new_frame_callback| is triggered when a new video frame is available. |
| + // If capturing is started successfully then |running_callback| will be |
| + // called with a parameter of true. /* FIXME */ |
| + // If capturing fails to start or stopped due to an external event then |
| + // |running_callback| will be called with a parameter of false. |
| + virtual void StartCapture( |
|
Alpha Left Google
2015/02/04 03:07:52
I see this interface is extracted from MediaStream
hubbe
2015/02/05 20:23:00
Added task runner, added documentation.
|
| + const media::VideoCaptureParams& params, |
| + const VideoCaptureDeliverFrameCB& new_frame_callback, |
| + const RunningCallback& running_callback) = 0; |
| + |
| + // Stops capturing frames and clears all callbacks including the |
| + // SupportedFormatsCallback callback. Waits until it is safe to |
|
Alpha Left Google
2015/02/04 03:07:52
There shouldn't be any wait.
hubbe
2015/02/05 20:23:00
Changed to not require wait.
|
| + // delete this object. |
| + virtual void StopCapture() = 0; |
|
Alpha Left Google
2015/02/04 03:07:52
Note that it is okay that |new_frame_callback| is
hubbe
2015/02/05 20:23:00
Changed to state that there might be additional ca
|
| + |
| + protected: |
| + friend class base::RefCountedThreadSafe<VideoCapturerSource>; |
| + virtual ~VideoCapturerSource(); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_ |