tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

video_stream_input_state_provider.cc (2134B)


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