blob: 9d1641cd0dd658b4093337373b5f39c079d4e30c [file] [log] [blame]
Niels Möller0327c2d2018-05-21 14:09:31 +02001/*
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 API_VIDEO_VIDEO_SOURCE_INTERFACE_H_
12#define API_VIDEO_VIDEO_SOURCE_INTERFACE_H_
13
14#include <limits>
15
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020016#include "absl/types/optional.h"
Niels Möller0327c2d2018-05-21 14:09:31 +020017#include "api/video/video_sink_interface.h"
Mirko Bonadeiac194142018-10-22 17:08:37 +020018#include "rtc_base/system/rtc_export.h"
Niels Möller0327c2d2018-05-21 14:09:31 +020019
20namespace rtc {
21
22// VideoSinkWants is used for notifying the source of properties a video frame
23// should have when it is delivered to a certain sink.
Mirko Bonadeiac194142018-10-22 17:08:37 +020024struct RTC_EXPORT VideoSinkWants {
Niels Möller0327c2d2018-05-21 14:09:31 +020025 VideoSinkWants();
26 VideoSinkWants(const VideoSinkWants&);
27 ~VideoSinkWants();
28 // Tells the source whether the sink wants frames with rotation applied.
29 // By default, any rotation must be applied by the sink.
30 bool rotation_applied = false;
31
32 // Tells the source that the sink only wants black frames.
33 bool black_frames = false;
34
35 // Tells the source the maximum number of pixels the sink wants.
36 int max_pixel_count = std::numeric_limits<int>::max();
37 // Tells the source the desired number of pixels the sinks wants. This will
38 // typically be used when stepping the resolution up again when conditions
39 // have improved after an earlier downgrade. The source should select the
40 // closest resolution to this pixel count, but if max_pixel_count is set, it
41 // still sets the absolute upper bound.
Danil Chapovalov0bc58cf2018-06-21 13:32:56 +020042 absl::optional<int> target_pixel_count;
Niels Möller0327c2d2018-05-21 14:09:31 +020043 // Tells the source the maximum framerate the sink wants.
44 int max_framerate_fps = std::numeric_limits<int>::max();
45};
46
47template <typename VideoFrameT>
48class VideoSourceInterface {
49 public:
Niels Möller1c931c42018-12-18 16:08:11 +010050 virtual ~VideoSourceInterface() = default;
51
Niels Möller0327c2d2018-05-21 14:09:31 +020052 virtual void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* sink,
53 const VideoSinkWants& wants) = 0;
54 // RemoveSink must guarantee that at the time the method returns,
55 // there is no current and no future calls to VideoSinkInterface::OnFrame.
56 virtual void RemoveSink(VideoSinkInterface<VideoFrameT>* sink) = 0;
Niels Möller0327c2d2018-05-21 14:09:31 +020057};
58
59} // namespace rtc
60#endif // API_VIDEO_VIDEO_SOURCE_INTERFACE_H_