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_provider.h" 12 13 #include "call/adaptation/video_stream_adapter.h" 14 15 namespace webrtc { 16 VideoStreamInputStateProvider(VideoStreamEncoderObserver * frame_rate_provider)17VideoStreamInputStateProvider::VideoStreamInputStateProvider( 18 VideoStreamEncoderObserver* frame_rate_provider) 19 : frame_rate_provider_(frame_rate_provider) {} 20 ~VideoStreamInputStateProvider()21VideoStreamInputStateProvider::~VideoStreamInputStateProvider() {} 22 OnHasInputChanged(bool has_input)23void VideoStreamInputStateProvider::OnHasInputChanged(bool has_input) { 24 MutexLock lock(&mutex_); 25 input_state_.set_has_input(has_input); 26 } 27 OnFrameSizeObserved(int frame_size_pixels)28void VideoStreamInputStateProvider::OnFrameSizeObserved(int frame_size_pixels) { 29 RTC_DCHECK_GT(frame_size_pixels, 0); 30 MutexLock lock(&mutex_); 31 input_state_.set_frame_size_pixels(frame_size_pixels); 32 } 33 OnEncoderSettingsChanged(EncoderSettings encoder_settings)34void VideoStreamInputStateProvider::OnEncoderSettingsChanged( 35 EncoderSettings encoder_settings) { 36 MutexLock lock(&mutex_); 37 input_state_.set_video_codec_type( 38 encoder_settings.encoder_config().codec_type); 39 input_state_.set_min_pixels_per_frame( 40 encoder_settings.encoder_info().scaling_settings.min_pixels_per_frame); 41 input_state_.set_single_active_stream_pixels( 42 VideoStreamAdapter::GetSingleActiveLayerPixels( 43 encoder_settings.video_codec())); 44 } 45 InputState()46VideoStreamInputState VideoStreamInputStateProvider::InputState() { 47 // GetInputFrameRate() is thread-safe. 48 int input_fps = frame_rate_provider_->GetInputFrameRate(); 49 MutexLock lock(&mutex_); 50 input_state_.set_frames_per_second(input_fps); 51 return input_state_; 52 } 53 54 } // namespace webrtc 55