123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- #ifndef MEDIA_BASE_VIDEO_ADAPTER_H_
- #define MEDIA_BASE_VIDEO_ADAPTER_H_
- #include <stdint.h>
- #include <utility>
- #include "absl/types/optional.h"
- #include "api/video/video_source_interface.h"
- #include "media/base/video_common.h"
- #include "rtc_base/constructor_magic.h"
- #include "rtc_base/synchronization/mutex.h"
- #include "rtc_base/system/rtc_export.h"
- #include "rtc_base/thread_annotations.h"
- namespace cricket {
- class RTC_EXPORT VideoAdapter {
- public:
- VideoAdapter();
-
-
- explicit VideoAdapter(int source_resolution_alignment);
- virtual ~VideoAdapter();
-
-
-
-
- bool AdaptFrameResolution(int in_width,
- int in_height,
- int64_t in_timestamp_ns,
- int* cropped_width,
- int* cropped_height,
- int* out_width,
- int* out_height) RTC_LOCKS_EXCLUDED(mutex_);
-
-
-
-
-
-
-
-
-
- void OnOutputFormatRequest(const absl::optional<VideoFormat>& format)
- RTC_LOCKS_EXCLUDED(mutex_);
-
-
-
-
-
-
-
-
- void OnOutputFormatRequest(
- const absl::optional<std::pair<int, int>>& target_aspect_ratio,
- const absl::optional<int>& max_pixel_count,
- const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(mutex_);
-
-
-
-
- void OnOutputFormatRequest(
- const absl::optional<std::pair<int, int>>& target_landscape_aspect_ratio,
- const absl::optional<int>& max_landscape_pixel_count,
- const absl::optional<std::pair<int, int>>& target_portrait_aspect_ratio,
- const absl::optional<int>& max_portrait_pixel_count,
- const absl::optional<int>& max_fps) RTC_LOCKS_EXCLUDED(mutex_);
-
-
-
-
-
-
-
-
-
-
- void OnSinkWants(const rtc::VideoSinkWants& sink_wants)
- RTC_LOCKS_EXCLUDED(mutex_);
-
-
- int GetTargetPixels() const;
-
-
- float GetMaxFramerate() const;
- private:
-
- bool KeepFrame(int64_t in_timestamp_ns) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- int frames_in_ RTC_GUARDED_BY(mutex_);
- int frames_out_ RTC_GUARDED_BY(mutex_);
- int frames_scaled_ RTC_GUARDED_BY(mutex_);
- int adaption_changes_
- RTC_GUARDED_BY(mutex_);
- int previous_width_ RTC_GUARDED_BY(mutex_);
- int previous_height_
- RTC_GUARDED_BY(mutex_);
- const bool variable_start_scale_factor_;
-
- const int source_resolution_alignment_;
-
-
-
- int resolution_alignment_ RTC_GUARDED_BY(mutex_);
-
- absl::optional<int64_t> next_frame_timestamp_ns_ RTC_GUARDED_BY(mutex_);
-
-
-
- absl::optional<std::pair<int, int>> target_landscape_aspect_ratio_
- RTC_GUARDED_BY(mutex_);
- absl::optional<int> max_landscape_pixel_count_ RTC_GUARDED_BY(mutex_);
- absl::optional<std::pair<int, int>> target_portrait_aspect_ratio_
- RTC_GUARDED_BY(mutex_);
- absl::optional<int> max_portrait_pixel_count_ RTC_GUARDED_BY(mutex_);
- absl::optional<int> max_fps_ RTC_GUARDED_BY(mutex_);
- int resolution_request_target_pixel_count_ RTC_GUARDED_BY(mutex_);
- int resolution_request_max_pixel_count_ RTC_GUARDED_BY(mutex_);
- int max_framerate_request_ RTC_GUARDED_BY(mutex_);
-
- mutable webrtc::Mutex mutex_;
- RTC_DISALLOW_COPY_AND_ASSIGN(VideoAdapter);
- };
- }
- #endif
|