OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_MEDIA_BASE_ADAPTEDVIDEOSOURCE_H_ |
| 12 #define WEBRTC_MEDIA_BASE_ADAPTEDVIDEOSOURCE_H_ |
| 13 |
| 14 #include "webrtc/base/timestampaligner.h" |
| 15 #include "webrtc/media/base/videoadapter.h" |
| 16 #include "webrtc/media/base/videobroadcaster.h" |
| 17 |
| 18 namespace rtc { |
| 19 |
| 20 class AdaptedVideoSource : public VideoBroadcaster { |
| 21 public: |
| 22 AdaptedVideoSource(); |
| 23 |
| 24 bool enable_video_adapter() const { return enable_video_adapter_; } |
| 25 void set_enable_video_adapter(bool enable_video_adapter) { |
| 26 enable_video_adapter_ = enable_video_adapter; |
| 27 } |
| 28 cricket::VideoAdapter* video_adapter() { return &video_adapter_; } |
| 29 |
| 30 // Reports the appropriate frame size after adaptation. Returns true |
| 31 // if a frame is wanted. Returns false if there are no interested |
| 32 // sinks, or if the VideoAdapter decides to drop the frame. |
| 33 |
| 34 // This function also implements timestamp translation/filtering. |
| 35 // |camera_time_ns| is the camera's timestamp for the captured |
| 36 // frame; it is expected to have good accuracy, but it may use an |
| 37 // arbitrary epoch and a small possibly free-running with a frequency |
| 38 // slightly different from the system clock. |system_time_us| is the |
| 39 // monotonic system time (in the same scale as rtc::TimeMicros) when |
| 40 // the frame was captured; the application is expected to read the |
| 41 // system time as soon as possible after frame capture, but it may |
| 42 // suffer scheduling jitter or poor system clock resolution. The |
| 43 // output |translated_camera_time_us| is a combined timestamp, |
| 44 // taking advantage of the supposedly higher accuracy in the camera |
| 45 // timestamp, but using the same epoch and frequency as system time. |
| 46 bool AdaptFrame(int width, |
| 47 int height, |
| 48 int64_t camera_time_us, |
| 49 int64_t system_time_us, |
| 50 int* out_width, |
| 51 int* out_height, |
| 52 int* crop_width, |
| 53 int* crop_height, |
| 54 int* crop_x, |
| 55 int* crop_y, |
| 56 int64_t* translated_camera_time_us); |
| 57 |
| 58 protected: |
| 59 void UpdateWants() EXCLUSIVE_LOCKS_REQUIRED(sinks_and_wants_lock_); |
| 60 |
| 61 private: |
| 62 TimestampAligner timestamp_aligner_; |
| 63 bool enable_video_adapter_; |
| 64 cricket::VideoAdapter video_adapter_; |
| 65 }; |
| 66 |
| 67 } // namespace rtc |
| 68 |
| 69 #endif // WEBRTC_MEDIA_BASE_ADAPTEDVIDEOSOURCE_H_ |
OLD | NEW |