blob: dcf04c618b6e2db2222bbaf396b80cceaf707a13 [file] [log] [blame]
Erik Språng8abd56c2018-10-01 18:47:03 +02001/*
2 * Copyright (c) 2018 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
Erik Språng4529fbc2018-10-12 10:30:31 +020011#ifndef API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_
12#define API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_
Erik Språng8abd56c2018-10-01 18:47:03 +020013
Elad Aloncde8ab22019-03-20 11:56:20 +010014#include <memory>
Erik Språng8abd56c2018-10-01 18:47:03 +020015#include <vector>
16
Elad Aloncde8ab22019-03-20 11:56:20 +010017#include "api/video_codecs/video_codec.h"
Elad Alonde3360e2019-03-06 21:14:54 +010018#include "api/video_codecs/vp8_frame_buffer_controller.h"
Elad Alon411b49b2019-01-29 14:05:55 +010019#include "api/video_codecs/vp8_frame_config.h"
Elad Alonf5b216a2019-01-28 14:25:17 +010020
Erik Språng8abd56c2018-10-01 18:47:03 +020021namespace webrtc {
22
Erik Språng4529fbc2018-10-12 10:30:31 +020023// Two different flavors of temporal layers are currently available:
24// kFixedPattern uses a fixed repeating pattern of 1-4 layers.
25// kBitrateDynamic can allocate frames dynamically to 1 or 2 layers, based on
26// the bitrate produced.
Elad Aloncde8ab22019-03-20 11:56:20 +010027// TODO(eladalon): Remove this enum.
Erik Språng4529fbc2018-10-12 10:30:31 +020028enum class Vp8TemporalLayersType { kFixedPattern, kBitrateDynamic };
Erik Språng8abd56c2018-10-01 18:47:03 +020029
Erik Språng8abd56c2018-10-01 18:47:03 +020030// This interface defines a way of getting the encoder settings needed to
Erik Språng4529fbc2018-10-12 10:30:31 +020031// realize a temporal layer structure.
Elad Aloncde8ab22019-03-20 11:56:20 +010032class Vp8TemporalLayers final : public Vp8FrameBufferController {
Erik Språng8abd56c2018-10-01 18:47:03 +020033 public:
Elad Aloncde8ab22019-03-20 11:56:20 +010034 explicit Vp8TemporalLayers(
35 std::vector<std::unique_ptr<Vp8FrameBufferController>>&& controllers);
Elad Alonde3360e2019-03-06 21:14:54 +010036 ~Vp8TemporalLayers() override = default;
Erik Språng8abd56c2018-10-01 18:47:03 +020037
Elad Aloncde8ab22019-03-20 11:56:20 +010038 size_t StreamCount() const override;
Erik Språng8abd56c2018-10-01 18:47:03 +020039
Elad Aloncde8ab22019-03-20 11:56:20 +010040 bool SupportsEncoderFrameDropping(size_t stream_index) const override;
Erik Språng8abd56c2018-10-01 18:47:03 +020041
Elad Aloncde8ab22019-03-20 11:56:20 +010042 void OnRatesUpdated(size_t stream_index,
43 const std::vector<uint32_t>& bitrates_bps,
44 int framerate_fps) override;
Erik Språng8abd56c2018-10-01 18:47:03 +020045
Elad Aloncde8ab22019-03-20 11:56:20 +010046 bool UpdateConfiguration(size_t stream_index, Vp8EncoderConfig* cfg) override;
Erik Språng8abd56c2018-10-01 18:47:03 +020047
Elad Aloncde8ab22019-03-20 11:56:20 +010048 Vp8FrameConfig UpdateLayerConfig(size_t stream_index,
49 uint32_t rtp_timestamp) override;
50
51 void OnEncodeDone(size_t stream_index,
52 uint32_t rtp_timestamp,
Elad Alonde3360e2019-03-06 21:14:54 +010053 size_t size_bytes,
54 bool is_keyframe,
55 int qp,
Elad Aloncde8ab22019-03-20 11:56:20 +010056 CodecSpecificInfo* info) override;
57
Elad Alon6796ec22019-04-15 10:07:50 +020058 void OnFrameDropped(size_t stream_index, uint32_t rtp_timestamp) override;
59
Elad Aloncde8ab22019-03-20 11:56:20 +010060 void OnPacketLossRateUpdate(float packet_loss_rate) override;
61
62 void OnRttUpdate(int64_t rtt_ms) override;
63
Elad Alon6c371ca2019-04-04 12:28:51 +020064 void OnLossNotification(
65 const VideoEncoder::LossNotification loss_notification) override;
66
Elad Aloncde8ab22019-03-20 11:56:20 +010067 private:
68 std::vector<std::unique_ptr<Vp8FrameBufferController>> controllers_;
Erik Språng8abd56c2018-10-01 18:47:03 +020069};
70
71} // namespace webrtc
72
Erik Språng4529fbc2018-10-12 10:30:31 +020073#endif // API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_