You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
4.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  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 CALL_RTP_PAYLOAD_PARAMS_H_
  11. #define CALL_RTP_PAYLOAD_PARAMS_H_
  12. #include <array>
  13. #include "absl/types/optional.h"
  14. #include "api/video_codecs/video_encoder.h"
  15. #include "call/rtp_config.h"
  16. #include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h"
  17. #include "modules/rtp_rtcp/source/rtp_video_header.h"
  18. #include "modules/video_coding/include/video_codec_interface.h"
  19. namespace webrtc {
  20. class RtpRtcp;
  21. // State for setting picture id and tl0 pic idx, for VP8 and VP9
  22. // TODO(nisse): Make these properties not codec specific.
  23. class RtpPayloadParams final {
  24. public:
  25. RtpPayloadParams(const uint32_t ssrc, const RtpPayloadState* state);
  26. RtpPayloadParams(const RtpPayloadParams& other);
  27. ~RtpPayloadParams();
  28. RTPVideoHeader GetRtpVideoHeader(const EncodedImage& image,
  29. const CodecSpecificInfo* codec_specific_info,
  30. int64_t shared_frame_id);
  31. uint32_t ssrc() const;
  32. RtpPayloadState state() const;
  33. private:
  34. void SetCodecSpecific(RTPVideoHeader* rtp_video_header,
  35. bool first_frame_in_picture);
  36. void SetGeneric(const CodecSpecificInfo* codec_specific_info,
  37. int64_t frame_id,
  38. bool is_keyframe,
  39. RTPVideoHeader* rtp_video_header);
  40. void Vp8ToGeneric(const CodecSpecificInfoVP8& vp8_info,
  41. int64_t shared_frame_id,
  42. bool is_keyframe,
  43. RTPVideoHeader* rtp_video_header);
  44. void H264ToGeneric(const CodecSpecificInfoH264& h264_info,
  45. int64_t shared_frame_id,
  46. bool is_keyframe,
  47. RTPVideoHeader* rtp_video_header);
  48. void GenericToGeneric(int64_t shared_frame_id,
  49. bool is_keyframe,
  50. RTPVideoHeader* rtp_video_header);
  51. // TODO(bugs.webrtc.org/10242): Delete SetDependenciesVp8Deprecated() and move
  52. // the logic in SetDependenciesVp8New() into Vp8ToGeneric() once all hardware
  53. // wrappers have been updated.
  54. void SetDependenciesVp8Deprecated(
  55. const CodecSpecificInfoVP8& vp8_info,
  56. int64_t shared_frame_id,
  57. bool is_keyframe,
  58. int spatial_index,
  59. int temporal_index,
  60. bool layer_sync,
  61. RTPVideoHeader::GenericDescriptorInfo* generic);
  62. void SetDependenciesVp8New(const CodecSpecificInfoVP8& vp8_info,
  63. int64_t shared_frame_id,
  64. bool is_keyframe,
  65. bool layer_sync,
  66. RTPVideoHeader::GenericDescriptorInfo* generic);
  67. // TODO(bugs.webrtc.org/10242): Remove once all encoder-wrappers are updated.
  68. // Holds the last shared frame id for a given (spatial, temporal) layer.
  69. std::array<std::array<int64_t, RtpGenericFrameDescriptor::kMaxTemporalLayers>,
  70. RtpGenericFrameDescriptor::kMaxSpatialLayers>
  71. last_shared_frame_id_;
  72. // TODO(eladalon): When additional codecs are supported,
  73. // set kMaxCodecBuffersCount to the max() of these codecs' buffer count.
  74. static constexpr size_t kMaxCodecBuffersCount =
  75. CodecSpecificInfoVP8::kBuffersCount;
  76. // Maps buffer IDs to the frame-ID stored in them.
  77. std::array<int64_t, kMaxCodecBuffersCount> buffer_id_to_frame_id_;
  78. // Until we remove SetDependenciesVp8Deprecated(), we should make sure
  79. // that, for a given object, we either always use
  80. // SetDependenciesVp8Deprecated(), or always use SetDependenciesVp8New().
  81. // TODO(bugs.webrtc.org/10242): Remove.
  82. absl::optional<bool> new_version_used_;
  83. const uint32_t ssrc_;
  84. RtpPayloadState state_;
  85. const bool generic_picture_id_experiment_;
  86. const bool generic_descriptor_experiment_;
  87. };
  88. } // namespace webrtc
  89. #endif // CALL_RTP_PAYLOAD_PARAMS_H_