blob: a3c0db1a04d5fa02c65844db7b1b3175fb3b83a4 [file] [log] [blame]
Elad Aloncde8ab22019-03-20 11:56:20 +01001/*
2 * Copyright (c) 2019 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 "api/video_codecs/vp8_temporal_layers.h"
12
13#include <utility>
14
15#include "rtc_base/checks.h"
16
17namespace webrtc {
18
19Vp8TemporalLayers::Vp8TemporalLayers(
20 std::vector<std::unique_ptr<Vp8FrameBufferController>>&& controllers)
21 : controllers_(std::move(controllers)) {
22 RTC_DCHECK(!controllers_.empty());
23 RTC_DCHECK(std::none_of(
24 controllers_.begin(), controllers_.end(),
25 [](const std::unique_ptr<Vp8FrameBufferController>& controller) {
26 return controller.get() == nullptr;
27 }));
28}
29
30size_t Vp8TemporalLayers::StreamCount() const {
31 return controllers_.size();
32}
33
34bool Vp8TemporalLayers::SupportsEncoderFrameDropping(
35 size_t stream_index) const {
36 RTC_DCHECK_LT(stream_index, controllers_.size());
37 return controllers_[stream_index]->SupportsEncoderFrameDropping(0);
38}
39
40void Vp8TemporalLayers::OnRatesUpdated(
41 size_t stream_index,
42 const std::vector<uint32_t>& bitrates_bps,
43 int framerate_fps) {
44 RTC_DCHECK_LT(stream_index, controllers_.size());
45 return controllers_[stream_index]->OnRatesUpdated(0, bitrates_bps,
46 framerate_fps);
47}
48
49bool Vp8TemporalLayers::UpdateConfiguration(size_t stream_index,
50 Vp8EncoderConfig* cfg) {
51 RTC_DCHECK_LT(stream_index, controllers_.size());
52 return controllers_[stream_index]->UpdateConfiguration(0, cfg);
53}
54
55Vp8FrameConfig Vp8TemporalLayers::UpdateLayerConfig(size_t stream_index,
56 uint32_t rtp_timestamp) {
57 RTC_DCHECK_LT(stream_index, controllers_.size());
58 return controllers_[stream_index]->UpdateLayerConfig(0, rtp_timestamp);
59}
60
61void Vp8TemporalLayers::OnEncodeDone(size_t stream_index,
62 uint32_t rtp_timestamp,
63 size_t size_bytes,
64 bool is_keyframe,
65 int qp,
66 CodecSpecificInfo* info) {
67 RTC_DCHECK_LT(stream_index, controllers_.size());
68 return controllers_[stream_index]->OnEncodeDone(0, rtp_timestamp, size_bytes,
69 is_keyframe, qp, info);
70}
71
72void Vp8TemporalLayers::OnPacketLossRateUpdate(float packet_loss_rate) {
73 for (auto& controller : controllers_) {
74 controller->OnPacketLossRateUpdate(packet_loss_rate);
75 }
76}
77
78void Vp8TemporalLayers::OnRttUpdate(int64_t rtt_ms) {
79 for (auto& controller : controllers_) {
80 controller->OnRttUpdate(rtt_ms);
81 }
82}
83
84} // namespace webrtc