1 Star 0 Fork 22

xzg2021/BXC_gb28181Player

forked from Vanishi/BXC_gb28181Player 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Rtp.cpp 1.87 KB
一键复制 编辑 原始数据 按行查看 历史
Vanishi 提交于 2023-07-30 19:23 . init
//
// Created by bxc on 2023/4/18.
// 作者:北小菜
// 邮箱:[email protected]
// 西瓜视频主页:https://www.ixigua.com/home/4171970536803763
// 哔哩哔哩主页:https://space.bilibili.com/487906612/
//
#include "Rtp.h"
#include <stdio.h>
#include <string.h>
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){
rtpPacket->rtpHeader.csrcLen = csrcLen;
rtpPacket->rtpHeader.extension = extension;
rtpPacket->rtpHeader.padding = padding;
rtpPacket->rtpHeader.version = version;
rtpPacket->rtpHeader.payloadType = payloadType;
rtpPacket->rtpHeader.marker = marker;
rtpPacket->rtpHeader.seq = seq;
rtpPacket->rtpHeader.timestamp = timestamp;
rtpPacket->rtpHeader.ssrc = ssrc;
}
int parseRtpHeader(uint8_t* headerBuf, struct RtpHeader* rtpHeader){
memset(rtpHeader,0,sizeof(*rtpHeader));
/* byte 0 */
rtpHeader->version = (headerBuf[0] & 0xC0) >> 6;
rtpHeader->padding = (headerBuf[0] & 0x20) >> 5;
rtpHeader->extension = (headerBuf[0] & 0x10) >> 4;
rtpHeader->csrcLen = (headerBuf[0] & 0x0F);
/* byte 1 */
rtpHeader->marker = (headerBuf[1] & 0x80) >> 7;
rtpHeader->payloadType = (headerBuf[1] & 0x7F);
/* bytes 2,3 */
rtpHeader->seq = ((headerBuf[2] & 0xFF) << 8) | (headerBuf[3] & 0xFF);
/* bytes 4-7 */
rtpHeader->timestamp = ((headerBuf[4] & 0xFF) << 24) | ((headerBuf[5] & 0xFF) << 16)
| ((headerBuf[6] & 0xFF) << 8)
| ((headerBuf[7] & 0xFF));
/* bytes 8-11 */
rtpHeader->ssrc = ((headerBuf[8] & 0xFF) << 24) | ((headerBuf[9] & 0xFF) << 16)
| ((headerBuf[10] & 0xFF) << 8)
| ((headerBuf[11] & 0xFF));
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/xzg2021/BXC_gb28181Player.git
[email protected]:xzg2021/BXC_gb28181Player.git
xzg2021
BXC_gb28181Player
BXC_gb28181Player
master

搜索帮助