Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 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 | #include "call/adaptation/video_stream_input_state.h" |
| 12 | |
| 13 | #include "api/video_codecs/video_encoder.h" |
| 14 | |
| 15 | namespace webrtc { |
| 16 | |
| 17 | VideoStreamInputState::VideoStreamInputState() |
| 18 | : has_input_(false), |
| 19 | frame_size_pixels_(absl::nullopt), |
Henrik Boström | 722fa4d | 2020-04-29 16:46:30 +0200 | [diff] [blame] | 20 | frames_per_second_(0), |
Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 21 | video_codec_type_(VideoCodecType::kVideoCodecGeneric), |
Åsa Persson | 1dd94a0 | 2021-02-18 14:20:03 +0100 | [diff] [blame] | 22 | min_pixels_per_frame_(kDefaultMinPixelsPerFrame), |
| 23 | single_active_stream_pixels_(absl::nullopt) {} |
Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 24 | |
| 25 | void VideoStreamInputState::set_has_input(bool has_input) { |
| 26 | has_input_ = has_input; |
| 27 | } |
| 28 | |
| 29 | void VideoStreamInputState::set_frame_size_pixels( |
| 30 | absl::optional<int> frame_size_pixels) { |
| 31 | frame_size_pixels_ = frame_size_pixels; |
| 32 | } |
| 33 | |
Henrik Boström | 722fa4d | 2020-04-29 16:46:30 +0200 | [diff] [blame] | 34 | void VideoStreamInputState::set_frames_per_second(int frames_per_second) { |
Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 35 | frames_per_second_ = frames_per_second; |
| 36 | } |
| 37 | |
| 38 | void VideoStreamInputState::set_video_codec_type( |
| 39 | VideoCodecType video_codec_type) { |
| 40 | video_codec_type_ = video_codec_type; |
| 41 | } |
| 42 | |
| 43 | void VideoStreamInputState::set_min_pixels_per_frame(int min_pixels_per_frame) { |
| 44 | min_pixels_per_frame_ = min_pixels_per_frame; |
| 45 | } |
| 46 | |
Åsa Persson | 1dd94a0 | 2021-02-18 14:20:03 +0100 | [diff] [blame] | 47 | void VideoStreamInputState::set_single_active_stream_pixels( |
| 48 | absl::optional<int> single_active_stream_pixels) { |
| 49 | single_active_stream_pixels_ = single_active_stream_pixels; |
| 50 | } |
| 51 | |
Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 52 | bool VideoStreamInputState::has_input() const { |
| 53 | return has_input_; |
| 54 | } |
| 55 | |
| 56 | absl::optional<int> VideoStreamInputState::frame_size_pixels() const { |
| 57 | return frame_size_pixels_; |
| 58 | } |
| 59 | |
Henrik Boström | 722fa4d | 2020-04-29 16:46:30 +0200 | [diff] [blame] | 60 | int VideoStreamInputState::frames_per_second() const { |
Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 61 | return frames_per_second_; |
| 62 | } |
| 63 | |
| 64 | VideoCodecType VideoStreamInputState::video_codec_type() const { |
| 65 | return video_codec_type_; |
| 66 | } |
| 67 | |
| 68 | int VideoStreamInputState::min_pixels_per_frame() const { |
| 69 | return min_pixels_per_frame_; |
| 70 | } |
| 71 | |
Åsa Persson | 1dd94a0 | 2021-02-18 14:20:03 +0100 | [diff] [blame] | 72 | absl::optional<int> VideoStreamInputState::single_active_stream_pixels() const { |
| 73 | return single_active_stream_pixels_; |
| 74 | } |
| 75 | |
Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 76 | bool VideoStreamInputState::HasInputFrameSizeAndFramesPerSecond() const { |
Henrik Boström | 722fa4d | 2020-04-29 16:46:30 +0200 | [diff] [blame] | 77 | return has_input_ && frame_size_pixels_.has_value(); |
Henrik Boström | d516b25 | 2020-04-17 12:10:59 +0200 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | } // namespace webrtc |