Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_ | |
| 6 #define MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "media/base/media_export.h" | |
| 13 #include "media/base/video_frame.h" | |
| 14 #include "media/video/capture/video_capture_types.h" | |
| 15 | |
| 16 namespace media { | |
| 17 | |
| 18 // VideoCapturerSource is an interface representing the source for | |
| 19 // captured video. An implementation will periodically call the frame | |
| 20 // callback with new video frames. | |
| 21 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
| |
| 22 : 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.
| |
| 23 public: | |
| 24 // This callback is used to deliver video frames. | |
| 25 // | |
| 26 // |estimated_capture_time| - The capture time of the delivered video | |
| 27 // frame. This field represents the local time at which either: 1) the frame | |
| 28 // was generated, if it was done so locally; or 2) the targeted play-out time | |
| 29 // of the frame, if it was generated from a remote source. Either way, an | |
| 30 // implementation should not present the frame before this point-in-time. This | |
| 31 // value is NOT a high-resolution timestamp, and so it should not be used as a | |
| 32 // presentation time; but, instead, it should be used for buffering playback | |
| 33 // and for A/V synchronization purposes. NOTE: It is possible for this value | |
| 34 // to be null if the current implementation lacks this timing information. | |
| 35 // | |
| 36 // |video_frame->timestamp()| gives the presentation timestamp of the video | |
| 37 // frame relative to the first frame generated by the corresponding source. | |
| 38 // Because a source can start generating frames before a subscriber is added, | |
| 39 // the first video frame delivered may not have timestamp equal to 0. | |
| 40 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.
| |
| 41 void(const scoped_refptr<media::VideoFrame>& video_frame, | |
| 42 const media::VideoCaptureFormat& format, | |
| 43 const base::TimeTicks& estimated_capture_time)> | |
| 44 VideoCaptureDeliverFrameCB; | |
| 45 | |
| 46 typedef base::Callback<void(const media::VideoCaptureFormats&)> | |
| 47 VideoCaptureDeviceFormatsCB; | |
| 48 | |
| 49 typedef base::Callback<void(bool)> RunningCallback; | |
| 50 | |
| 51 // Collects the formats that can currently be used. | |
| 52 // |max_requested_height|, |max_requested_width|, and | |
| 53 // |max_requested_frame_rate| is used by Tab and Screen capture to decide what | |
| 54 // resolution/framerate to generate. |callback| is triggered when the formats | |
| 55 // have been collected. | |
| 56 virtual void GetCurrentSupportedFormats( | |
| 57 int max_requested_width, | |
| 58 int max_requested_height, | |
| 59 double max_requested_frame_rate, | |
| 60 const VideoCaptureDeviceFormatsCB& callback) = 0; | |
| 61 | |
| 62 // Starts capturing frames using the resolution in |params|. | |
| 63 // |new_frame_callback| is triggered when a new video frame is available. | |
| 64 // If capturing is started successfully then |running_callback| will be | |
| 65 // called with a parameter of true. /* FIXME */ | |
| 66 // If capturing fails to start or stopped due to an external event then | |
| 67 // |running_callback| will be called with a parameter of false. | |
| 68 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.
| |
| 69 const media::VideoCaptureParams& params, | |
| 70 const VideoCaptureDeliverFrameCB& new_frame_callback, | |
| 71 const RunningCallback& running_callback) = 0; | |
| 72 | |
| 73 // Stops capturing frames and clears all callbacks including the | |
| 74 // 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.
| |
| 75 // delete this object. | |
| 76 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
| |
| 77 | |
| 78 protected: | |
| 79 friend class base::RefCountedThreadSafe<VideoCapturerSource>; | |
| 80 virtual ~VideoCapturerSource(); | |
| 81 }; | |
| 82 | |
| 83 } // namespace media | |
| 84 | |
| 85 #endif // MEDIA_VIDEO_CAPTURE_VIDEO_CAPTURER_SOURCE_H_ | |
| OLD | NEW |