vp8_temporal_layers.h 2.7 KB

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