video_stream_input_state.cc (2422B)
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 <optional> 14 15 #include "api/video/video_codec_type.h" 16 #include "api/video_codecs/video_encoder.h" 17 18 namespace webrtc { 19 20 VideoStreamInputState::VideoStreamInputState() 21 : has_input_(false), 22 frame_size_pixels_(std::nullopt), 23 frames_per_second_(0), 24 video_codec_type_(VideoCodecType::kVideoCodecGeneric), 25 min_pixels_per_frame_(kDefaultMinPixelsPerFrame), 26 single_active_stream_pixels_(std::nullopt) {} 27 28 void VideoStreamInputState::set_has_input(bool has_input) { 29 has_input_ = has_input; 30 } 31 32 void VideoStreamInputState::set_frame_size_pixels( 33 std::optional<int> frame_size_pixels) { 34 frame_size_pixels_ = frame_size_pixels; 35 } 36 37 void VideoStreamInputState::set_frames_per_second(int frames_per_second) { 38 frames_per_second_ = frames_per_second; 39 } 40 41 void VideoStreamInputState::set_video_codec_type( 42 VideoCodecType video_codec_type) { 43 video_codec_type_ = video_codec_type; 44 } 45 46 void VideoStreamInputState::set_min_pixels_per_frame(int min_pixels_per_frame) { 47 min_pixels_per_frame_ = min_pixels_per_frame; 48 } 49 50 void VideoStreamInputState::set_single_active_stream_pixels( 51 std::optional<int> single_active_stream_pixels) { 52 single_active_stream_pixels_ = single_active_stream_pixels; 53 } 54 55 bool VideoStreamInputState::has_input() const { 56 return has_input_; 57 } 58 59 std::optional<int> VideoStreamInputState::frame_size_pixels() const { 60 return frame_size_pixels_; 61 } 62 63 int VideoStreamInputState::frames_per_second() const { 64 return frames_per_second_; 65 } 66 67 VideoCodecType VideoStreamInputState::video_codec_type() const { 68 return video_codec_type_; 69 } 70 71 int VideoStreamInputState::min_pixels_per_frame() const { 72 return min_pixels_per_frame_; 73 } 74 75 std::optional<int> VideoStreamInputState::single_active_stream_pixels() const { 76 return single_active_stream_pixels_; 77 } 78 79 bool VideoStreamInputState::HasInputFrameSizeAndFramesPerSecond() const { 80 return has_input_ && frame_size_pixels_.has_value(); 81 } 82 83 } // namespace webrtc