blob: 4194352ded43c0aec66fe4ead8a81e51660e12bf [file] [log] [blame]
Erik Språng8abd56c2018-10-01 16:47:031/*
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 08:30:3111#ifndef API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_
12#define API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_
Erik Språng8abd56c2018-10-01 16:47:0313
Elad Aloncde8ab22019-03-20 10:56:2014#include <memory>
Erik Språng8abd56c2018-10-01 16:47:0315#include <vector>
16
Elad Aloncde8ab22019-03-20 10:56:2017#include "api/video_codecs/video_codec.h"
Elad Alonde3360e2019-03-06 20:14:5418#include "api/video_codecs/vp8_frame_buffer_controller.h"
Elad Alon411b49b2019-01-29 13:05:5519#include "api/video_codecs/vp8_frame_config.h"
Elad Alonf5b216a2019-01-28 13:25:1720
Erik Språng8abd56c2018-10-01 16:47:0321namespace webrtc {
22
Erik Språng4529fbc2018-10-12 08:30:3123// 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 10:56:2027// TODO(eladalon): Remove this enum.
Erik Språng4529fbc2018-10-12 08:30:3128enum class Vp8TemporalLayersType { kFixedPattern, kBitrateDynamic };
Erik Språng8abd56c2018-10-01 16:47:0329
Erik Språng8abd56c2018-10-01 16:47:0330// This interface defines a way of getting the encoder settings needed to
Erik Språng4529fbc2018-10-12 08:30:3131// realize a temporal layer structure.
Elad Aloncde8ab22019-03-20 10:56:2032class Vp8TemporalLayers final : public Vp8FrameBufferController {
Erik Språng8abd56c2018-10-01 16:47:0333 public:
Elad Aloncde8ab22019-03-20 10:56:2034 explicit Vp8TemporalLayers(
35 std::vector<std::unique_ptr<Vp8FrameBufferController>>&& controllers);
Elad Alonde3360e2019-03-06 20:14:5436 ~Vp8TemporalLayers() override = default;
Erik Språng8abd56c2018-10-01 16:47:0337
Elad Alonfb087812019-05-02 21:25:3438 void SetQpLimits(size_t stream_index, int min_qp, int max_qp) override;
39
Elad Aloncde8ab22019-03-20 10:56:2040 size_t StreamCount() const override;
Erik Språng8abd56c2018-10-01 16:47:0341
Elad Aloncde8ab22019-03-20 10:56:2042 bool SupportsEncoderFrameDropping(size_t stream_index) const override;
Erik Språng8abd56c2018-10-01 16:47:0343
Elad Aloncde8ab22019-03-20 10:56:2044 void OnRatesUpdated(size_t stream_index,
45 const std::vector<uint32_t>& bitrates_bps,
46 int framerate_fps) override;
Erik Språng8abd56c2018-10-01 16:47:0347
Elad Alonfb087812019-05-02 21:25:3448 Vp8EncoderConfig UpdateConfiguration(size_t stream_index) override;
Erik Språng8abd56c2018-10-01 16:47:0349
Elad Alon979c4426a2019-04-17 10:53:0850 Vp8FrameConfig NextFrameConfig(size_t stream_index,
51 uint32_t rtp_timestamp) override;
Elad Aloncde8ab22019-03-20 10:56:2052
53 void OnEncodeDone(size_t stream_index,
54 uint32_t rtp_timestamp,
Elad Alonde3360e2019-03-06 20:14:5455 size_t size_bytes,
56 bool is_keyframe,
57 int qp,
Elad Aloncde8ab22019-03-20 10:56:2058 CodecSpecificInfo* info) override;
59
Elad Alon6796ec22019-04-15 08:07:5060 void OnFrameDropped(size_t stream_index, uint32_t rtp_timestamp) override;
61
Elad Aloncde8ab22019-03-20 10:56:2062 void OnPacketLossRateUpdate(float packet_loss_rate) override;
63
64 void OnRttUpdate(int64_t rtt_ms) override;
65
Elad Alon6c371ca2019-04-04 10:28:5166 void OnLossNotification(
Elad Alon123ee9b2019-04-17 10:48:0667 const VideoEncoder::LossNotification& loss_notification) override;
Elad Alon6c371ca2019-04-04 10:28:5168
Elad Aloncde8ab22019-03-20 10:56:2069 private:
70 std::vector<std::unique_ptr<Vp8FrameBufferController>> controllers_;
Erik Språng8abd56c2018-10-01 16:47:0371};
72
73} // namespace webrtc
74
Erik Språng4529fbc2018-10-12 08:30:3175#endif // API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_