Use single FrameBufferController in VP8, created by a factory.
This CL paves the way to making FrameBufferController injectable.
LibvpxVp8Encoder can manage multiple streams. Prior to this CL,
each stream had its own frame buffer controller, all of them held
in a vector by LibvpxVp8Encoder. This complicated the code and
produced some code duplication (cf. SetupTemporalLayers).
This CL:
1. Replaces CreateVp8TemporalLayers() by a factory. (Later CLs
will make this factory injectable.)
2. Makes LibvpxVp8Encoder use a single controller. This single
controller will, in the case of multiple streams, delegate
its work to multiple controllers, but that fact is not visible
to LibvpxVp8Encoder.
This CL also squashes CL #126046 (Send notifications of RTT and
PLR changes to Vp8FrameBufferController) into it.
Bug: webrtc:10382
Change-Id: Id9b55734bebb457acc276f34a7a9e52cc19c8eb9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126483
Commit-Queue: Elad Alon <eladalon@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27206}
diff --git a/api/video_codecs/vp8_temporal_layers.h b/api/video_codecs/vp8_temporal_layers.h
index 61a9def..d5d29cd 100644
--- a/api/video_codecs/vp8_temporal_layers.h
+++ b/api/video_codecs/vp8_temporal_layers.h
@@ -11,8 +11,10 @@
#ifndef API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_
#define API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_
+#include <memory>
#include <vector>
+#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/vp8_frame_buffer_controller.h"
#include "api/video_codecs/vp8_frame_config.h"
@@ -22,28 +24,43 @@
// kFixedPattern uses a fixed repeating pattern of 1-4 layers.
// kBitrateDynamic can allocate frames dynamically to 1 or 2 layers, based on
// the bitrate produced.
+// TODO(eladalon): Remove this enum.
enum class Vp8TemporalLayersType { kFixedPattern, kBitrateDynamic };
// This interface defines a way of getting the encoder settings needed to
// realize a temporal layer structure.
-class Vp8TemporalLayers : public Vp8FrameBufferController {
+class Vp8TemporalLayers final : public Vp8FrameBufferController {
public:
+ explicit Vp8TemporalLayers(
+ std::vector<std::unique_ptr<Vp8FrameBufferController>>&& controllers);
~Vp8TemporalLayers() override = default;
- bool SupportsEncoderFrameDropping() const override = 0;
+ size_t StreamCount() const override;
- void OnRatesUpdated(const std::vector<uint32_t>& bitrates_bps,
- int framerate_fps) override = 0;
+ bool SupportsEncoderFrameDropping(size_t stream_index) const override;
- bool UpdateConfiguration(Vp8EncoderConfig* cfg) override = 0;
+ void OnRatesUpdated(size_t stream_index,
+ const std::vector<uint32_t>& bitrates_bps,
+ int framerate_fps) override;
- Vp8FrameConfig UpdateLayerConfig(uint32_t rtp_timestamp) override = 0;
+ bool UpdateConfiguration(size_t stream_index, Vp8EncoderConfig* cfg) override;
- void OnEncodeDone(uint32_t rtp_timestamp,
+ Vp8FrameConfig UpdateLayerConfig(size_t stream_index,
+ uint32_t rtp_timestamp) override;
+
+ void OnEncodeDone(size_t stream_index,
+ uint32_t rtp_timestamp,
size_t size_bytes,
bool is_keyframe,
int qp,
- CodecSpecificInfo* info) override = 0;
+ CodecSpecificInfo* info) override;
+
+ void OnPacketLossRateUpdate(float packet_loss_rate) override;
+
+ void OnRttUpdate(int64_t rtt_ms) override;
+
+ private:
+ std::vector<std::unique_ptr<Vp8FrameBufferController>> controllers_;
};
} // namespace webrtc