blob: 17f16046c0dbfc7305cd8fa0024e85f41b59d5c0 [file] [log] [blame]
Patrik Höglund9e194032018-01-04 15:58:20 +01001/*
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_VIDEOSOURCEINTERFACE_H_
12#define API_VIDEOSOURCEINTERFACE_H_
13
14#include <limits>
15
16#include "api/optional.h"
Niels Möllerc6ce9c52018-05-11 11:15:30 +020017#include "api/video/video_sink_interface.h"
Patrik Höglund9e194032018-01-04 15:58:20 +010018
19namespace rtc {
20
21// VideoSinkWants is used for notifying the source of properties a video frame
22// should have when it is delivered to a certain sink.
23struct VideoSinkWants {
24 VideoSinkWants();
Paulina Hensmana680a6a2018-04-05 11:42:24 +020025 VideoSinkWants(const VideoSinkWants&);
Patrik Höglund9e194032018-01-04 15:58:20 +010026 ~VideoSinkWants();
27 // Tells the source whether the sink wants frames with rotation applied.
28 // By default, any rotation must be applied by the sink.
29 bool rotation_applied = false;
30
31 // Tells the source that the sink only wants black frames.
32 bool black_frames = false;
33
34 // Tells the source the maximum number of pixels the sink wants.
35 int max_pixel_count = std::numeric_limits<int>::max();
36 // Tells the source the desired number of pixels the sinks wants. This will
37 // typically be used when stepping the resolution up again when conditions
38 // have improved after an earlier downgrade. The source should select the
39 // closest resolution to this pixel count, but if max_pixel_count is set, it
40 // still sets the absolute upper bound.
41 rtc::Optional<int> target_pixel_count;
42 // Tells the source the maximum framerate the sink wants.
43 int max_framerate_fps = std::numeric_limits<int>::max();
44};
45
46template <typename VideoFrameT>
47class VideoSourceInterface {
48 public:
49 virtual void AddOrUpdateSink(VideoSinkInterface<VideoFrameT>* sink,
50 const VideoSinkWants& wants) = 0;
51 // RemoveSink must guarantee that at the time the method returns,
52 // there is no current and no future calls to VideoSinkInterface::OnFrame.
53 virtual void RemoveSink(VideoSinkInterface<VideoFrameT>* sink) = 0;
54
55 protected:
56 virtual ~VideoSourceInterface() {}
57};
58
59} // namespace rtc
60#endif // API_VIDEOSOURCEINTERFACE_H_