Index: webrtc/media/base/adaptedvideosource.h |
diff --git a/webrtc/media/base/adaptedvideosource.h b/webrtc/media/base/adaptedvideosource.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..fe1021a8ec3dd7fb691c79c10f5972e6e72d697a |
--- /dev/null |
+++ b/webrtc/media/base/adaptedvideosource.h |
@@ -0,0 +1,69 @@ |
+/* |
+ * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#ifndef WEBRTC_MEDIA_BASE_ADAPTEDVIDEOSOURCE_H_ |
+#define WEBRTC_MEDIA_BASE_ADAPTEDVIDEOSOURCE_H_ |
+ |
+#include "webrtc/base/timestampaligner.h" |
+#include "webrtc/media/base/videoadapter.h" |
+#include "webrtc/media/base/videobroadcaster.h" |
+ |
+namespace rtc { |
+ |
+class AdaptedVideoSource : public VideoBroadcaster { |
+ public: |
+ AdaptedVideoSource(); |
+ |
+ bool enable_video_adapter() const { return enable_video_adapter_; } |
+ void set_enable_video_adapter(bool enable_video_adapter) { |
+ enable_video_adapter_ = enable_video_adapter; |
+ } |
+ cricket::VideoAdapter* video_adapter() { return &video_adapter_; } |
+ |
+ // Reports the appropriate frame size after adaptation. Returns true |
+ // if a frame is wanted. Returns false if there are no interested |
+ // sinks, or if the VideoAdapter decides to drop the frame. |
+ |
+ // This function also implements timestamp translation/filtering. |
+ // |camera_time_ns| is the camera's timestamp for the captured |
+ // frame; it is expected to have good accuracy, but it may use an |
+ // arbitrary epoch and a small possibly free-running with a frequency |
+ // slightly different from the system clock. |system_time_us| is the |
+ // monotonic system time (in the same scale as rtc::TimeMicros) when |
+ // the frame was captured; the application is expected to read the |
+ // system time as soon as possible after frame capture, but it may |
+ // suffer scheduling jitter or poor system clock resolution. The |
+ // output |translated_camera_time_us| is a combined timestamp, |
+ // taking advantage of the supposedly higher accuracy in the camera |
+ // timestamp, but using the same epoch and frequency as system time. |
+ bool AdaptFrame(int width, |
+ int height, |
+ int64_t camera_time_us, |
+ int64_t system_time_us, |
+ int* out_width, |
+ int* out_height, |
+ int* crop_width, |
+ int* crop_height, |
+ int* crop_x, |
+ int* crop_y, |
+ int64_t* translated_camera_time_us); |
+ |
+ protected: |
+ void UpdateWants() EXCLUSIVE_LOCKS_REQUIRED(sinks_and_wants_lock_); |
+ |
+ private: |
+ TimestampAligner timestamp_aligner_; |
+ bool enable_video_adapter_; |
+ cricket::VideoAdapter video_adapter_; |
+}; |
+ |
+} // namespace rtc |
+ |
+#endif // WEBRTC_MEDIA_BASE_ADAPTEDVIDEOSOURCE_H_ |