You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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. #ifndef API_VIDEO_VIDEO_SOURCE_INTERFACE_H_
  11. #define API_VIDEO_VIDEO_SOURCE_INTERFACE_H_
  12. #include <limits>
  13. #include "absl/types/optional.h"
  14. #include "api/video/video_sink_interface.h"
  15. #include "rtc_base/system/rtc_export.h"
  16. namespace rtc {
  17. // VideoSinkWants is used for notifying the source of properties a video frame
  18. // should have when it is delivered to a certain sink.
  19. struct RTC_EXPORT VideoSinkWants {
  20. VideoSinkWants();
  21. VideoSinkWants(const VideoSinkWants&);
  22. ~VideoSinkWants();
  23. // Tells the source whether the sink wants frames with rotation applied.
  24. // By default, any rotation must be applied by the sink.
  25. bool rotation_applied = false;
  26. // Tells the source that the sink only wants black frames.
  27. bool black_frames = false;
  28. // Tells the source the maximum number of pixels the sink wants.
  29. int max_pixel_count = std::numeric_limits<int>::max();
  30. // Tells the source the desired number of pixels the sinks wants. This will
  31. // typically be used when stepping the resolution up again when conditions
  32. // have improved after an earlier downgrade. The source should select the
  33. // closest resolution to this pixel count, but if max_pixel_count is set, it
  34. // still sets the absolute upper bound.
  35. absl::optional<int> target_pixel_count;
  36. // Tells the source the maximum framerate the sink wants.
  37. int max_framerate_fps = std::numeric_limits<int>::max();
  38. };
  39. template <typename VideoFrameT>
  40. class VideoSourceInterface {
  41. public:
  42. virtual ~VideoSourceInterface() = default;
  43. virtual void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* sink,
  44. const VideoSinkWants& wants) = 0;
  45. // RemoveSink must guarantee that at the time the method returns,
  46. // there is no current and no future calls to VideoSinkInterface::OnFrame.
  47. virtual void RemoveSink(VideoSinkInterface<VideoFrameT>* sink) = 0;
  48. };
  49. } // namespace rtc
  50. #endif // API_VIDEO_VIDEO_SOURCE_INTERFACE_H_