• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace webrtc {
14 
VideoStreamInputStateProvider(VideoStreamEncoderObserver * frame_rate_provider)15 VideoStreamInputStateProvider::VideoStreamInputStateProvider(
16     VideoStreamEncoderObserver* frame_rate_provider)
17     : frame_rate_provider_(frame_rate_provider) {}
18 
~VideoStreamInputStateProvider()19 VideoStreamInputStateProvider::~VideoStreamInputStateProvider() {}
20 
OnHasInputChanged(bool has_input)21 void VideoStreamInputStateProvider::OnHasInputChanged(bool has_input) {
22   MutexLock lock(&mutex_);
23   input_state_.set_has_input(has_input);
24 }
25 
OnFrameSizeObserved(int frame_size_pixels)26 void VideoStreamInputStateProvider::OnFrameSizeObserved(int frame_size_pixels) {
27   RTC_DCHECK_GT(frame_size_pixels, 0);
28   MutexLock lock(&mutex_);
29   input_state_.set_frame_size_pixels(frame_size_pixels);
30 }
31 
OnEncoderSettingsChanged(EncoderSettings encoder_settings)32 void VideoStreamInputStateProvider::OnEncoderSettingsChanged(
33     EncoderSettings encoder_settings) {
34   MutexLock lock(&mutex_);
35   input_state_.set_video_codec_type(
36       encoder_settings.encoder_config().codec_type);
37   input_state_.set_min_pixels_per_frame(
38       encoder_settings.encoder_info().scaling_settings.min_pixels_per_frame);
39 }
40 
InputState()41 VideoStreamInputState VideoStreamInputStateProvider::InputState() {
42   // GetInputFrameRate() is thread-safe.
43   int input_fps = frame_rate_provider_->GetInputFrameRate();
44   MutexLock lock(&mutex_);
45   input_state_.set_frames_per_second(input_fps);
46   return input_state_;
47 }
48 
49 }  // namespace webrtc
50