// // Created by bxc on 2023/4/18. // 作者:北小菜 // 邮箱:bilibili_bxc@126.com // 西瓜视频主页:https://www.ixigua.com/home/4171970536803763 // 哔哩哔哩主页:https://space.bilibili.com/487906612/ // #ifndef GB28181PLAYER_RTP_H #define GB28181PLAYER_RTP_H #include #define RTP_VESION 2 #define RTP_PAYLOAD_TYPE_H264 96 #define RTP_PAYLOAD_TYPE_AAC 97 #define RTP_HEADER_SIZE 12 /* * * 0 1 2 3 * 7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * |V=2|P|X| CC |M| PT | sequence number | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | timestamp | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * | synchronization source (SSRC) identifier | * +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ * | contributing source (CSRC) identifiers | * : .... : * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ * */ struct RtpHeader{ /* byte 0 */ uint8_t csrcLen:4; uint8_t extension:1; uint8_t padding:1; uint8_t version:2; // 最高2位 /* byte 1 */ uint8_t payloadType:7; uint8_t marker:1; /* bytes 2,3 */ uint16_t seq; /* bytes 4-7 */ uint32_t timestamp; /* bytes 8-11 */ uint32_t ssrc; }; struct RtpPacket{ struct RtpHeader rtpHeader; uint8_t payload[0]; }; void rtpHeaderInit(struct RtpPacket* rtpPacket, uint8_t csrcLen, uint8_t extension, uint8_t padding, uint8_t version, uint8_t payloadType, uint8_t marker, uint16_t seq, uint32_t timestamp, uint32_t ssrc); int parseRtpHeader(uint8_t* headerBuf, struct RtpHeader* rtpHeader); #endif //GB28181PLAYER_RTP_H