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