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