123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #ifndef MEDIA_BASE_RTP_UTILS_H_
- #define MEDIA_BASE_RTP_UTILS_H_
- #include "absl/strings/string_view.h"
- #include "api/array_view.h"
- #include "rtc_base/byte_order.h"
- #include "rtc_base/system/rtc_export.h"
- namespace rtc {
- struct PacketTimeUpdateParams;
- }
- namespace cricket {
- const size_t kMinRtpPacketLen = 12;
- const size_t kMaxRtpPacketLen = 2048;
- const size_t kMinRtcpPacketLen = 4;
- struct RtpHeader {
- int payload_type;
- int seq_num;
- uint32_t timestamp;
- uint32_t ssrc;
- };
- enum RtcpTypes {
- kRtcpTypeSR = 200,
- kRtcpTypeRR = 201,
- kRtcpTypeSDES = 202,
- kRtcpTypeBye = 203,
- kRtcpTypeApp = 204,
- kRtcpTypeRTPFB = 205,
- kRtcpTypePSFB = 206,
- };
- enum class RtpPacketType {
- kRtp,
- kRtcp,
- kUnknown,
- };
- bool GetRtpPayloadType(const void* data, size_t len, int* value);
- bool GetRtpSeqNum(const void* data, size_t len, int* value);
- bool GetRtpTimestamp(const void* data, size_t len, uint32_t* value);
- bool GetRtpSsrc(const void* data, size_t len, uint32_t* value);
- bool GetRtpHeaderLen(const void* data, size_t len, size_t* value);
- bool GetRtcpType(const void* data, size_t len, int* value);
- bool GetRtcpSsrc(const void* data, size_t len, uint32_t* value);
- bool GetRtpHeader(const void* data, size_t len, RtpHeader* header);
- bool SetRtpSsrc(void* data, size_t len, uint32_t value);
- bool SetRtpHeader(void* data, size_t len, const RtpHeader& header);
- bool IsRtpPacket(rtc::ArrayView<const char> packet);
- bool IsRtcpPacket(rtc::ArrayView<const char> packet);
- RtpPacketType InferRtpPacketType(rtc::ArrayView<const char> packet);
- bool IsValidRtpPayloadType(int payload_type);
- bool IsValidRtpPacketSize(RtpPacketType packet_type, size_t size);
- absl::string_view RtpPacketTypeToString(RtpPacketType packet_type);
- bool RTC_EXPORT ValidateRtpHeader(const uint8_t* rtp,
- size_t length,
- size_t* header_length);
- bool UpdateRtpAbsSendTimeExtension(uint8_t* rtp,
- size_t length,
- int extension_id,
- uint64_t time_us);
- bool RTC_EXPORT
- ApplyPacketOptions(uint8_t* data,
- size_t length,
- const rtc::PacketTimeUpdateParams& packet_time_params,
- uint64_t time_us);
- }
- #endif
|