vp8_temporal_layers.h (2761B)
1 /* 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 11 #ifndef API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_ 12 #define API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 #include <memory> 17 #include <vector> 18 19 #include "api/fec_controller_override.h" 20 #include "api/video_codecs/video_encoder.h" 21 #include "api/video_codecs/vp8_frame_buffer_controller.h" 22 #include "api/video_codecs/vp8_frame_config.h" 23 24 namespace webrtc { 25 26 // Two different flavors of temporal layers are currently available: 27 // kFixedPattern uses a fixed repeating pattern of 1-4 layers. 28 // kBitrateDynamic can allocate frames dynamically to 1 or 2 layers, based on 29 // the bitrate produced. 30 // TODO(eladalon): Remove this enum. 31 enum class Vp8TemporalLayersType { kFixedPattern, kBitrateDynamic }; 32 33 // This interface defines a way of getting the encoder settings needed to 34 // realize a temporal layer structure. 35 class Vp8TemporalLayers final : public Vp8FrameBufferController { 36 public: 37 Vp8TemporalLayers( 38 std::vector<std::unique_ptr<Vp8FrameBufferController>>&& controllers, 39 FecControllerOverride* fec_controller_override); 40 ~Vp8TemporalLayers() override = default; 41 42 void SetQpLimits(size_t stream_index, int min_qp, int max_qp) override; 43 44 size_t StreamCount() const override; 45 46 bool SupportsEncoderFrameDropping(size_t stream_index) const override; 47 48 void OnRatesUpdated(size_t stream_index, 49 const std::vector<uint32_t>& bitrates_bps, 50 int framerate_fps) override; 51 52 Vp8EncoderConfig UpdateConfiguration(size_t stream_index) override; 53 54 Vp8FrameConfig NextFrameConfig(size_t stream_index, 55 uint32_t rtp_timestamp) override; 56 57 void OnEncodeDone(size_t stream_index, 58 uint32_t rtp_timestamp, 59 size_t size_bytes, 60 bool is_keyframe, 61 int qp, 62 CodecSpecificInfo* info) override; 63 64 void OnFrameDropped(size_t stream_index, uint32_t rtp_timestamp) override; 65 66 void OnPacketLossRateUpdate(float packet_loss_rate) override; 67 68 void OnRttUpdate(int64_t rtt_ms) override; 69 70 void OnLossNotification( 71 const VideoEncoder::LossNotification& loss_notification) override; 72 73 private: 74 std::vector<std::unique_ptr<Vp8FrameBufferController>> controllers_; 75 }; 76 77 } // namespace webrtc 78 79 #endif // API_VIDEO_CODECS_VP8_TEMPORAL_LAYERS_H_