资源简介
Linux 下RTP实时打包发送H.264码流
代码片段和文件信息
/*=============================================================================
* FileName: rtp.c
* Desc: rtp payload h.264 data
* Author: licaibiao
* LastChange: 2017-04-07
* =============================================================================*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “rtp.h“
//#define DEBUG_LOG
typedef struct
{
int startcodeprefix_len; //! 4 for parameter sets and first slice in picture 3 for everything else (suggested)
unsigned len; //! Length of the NAL unit (Excluding the start code which does not belong to the NALU)
unsigned max_size; //! Nal Unit Buffer size
int forbidden_bit; //! should be always FALSE
int nal_reference_idc; //! NALU_PRIORITY_xxxx
int nal_unit_type; //! NALU_TYPE_xxxx
char *buf; //! contains the first byte followed by the EBSP
unsigned short lost_packets; //! true if packet loss is detected
} NALU_t;
FILE *bits = NULL; //!< the bit stream file
static int FindStartCode2 (unsigned char *Buf);//查找开始字符0x000001
static int FindStartCode3 (unsigned char *Buf);//查找开始字符0x00000001
static int info2=0;
static int info3=0;
RTP_FIXED_HEADER *rtp_hdr;
NALU_HEADER *nalu_hdr;
FU_INDICATOR *fu_ind;
FU_HEADER *fu_hdr;
NALU_t *AllocNALU(int buffersize)
{
NALU_t *n;
if ((n = (NALU_t*)calloc (1 sizeof (NALU_t))) == NULL)
{
printf(“AllocNALU: n“);
exit(0);
}
n->max_size = buffersize;
if((n->buf = (char*)calloc (buffersize sizeof (char))) == NULL)
{
free (n);
printf (“AllocNALU: n->buf“);
exit(0);
}
return n;
}
void FreeNALU(NALU_t *n)
{
if (n)
{
if (n->buf)
{
free(n->buf);
n->buf=NULL;
}
free (n);
}
}
void OpenBitstreamFile (char *fn)
{
if (NULL == (bits = fopen(fn “rb“)))
{
printf(“open file error\n“);
exit(0);
}
}
//这个函数输入为一个NAL结构体,主要功能为得到一个完整的NALU并保存在NALU_t的buf中,获取他的长度,填充FIDCTYPE位。
//并且返回两个开始字符之间间隔的字节数,即包含有前缀的NALU的长度
//前缀之后的第一个字节为 NALU_HEADER
int GetAnnexbNALU (NALU_t *nalu)
{
int pos = 0;
int rewind;
int StartCodeFound;
unsigned char *Buf;
if ((Buf = (unsigned char*)calloc (nalu->max_size sizeof(char))) == NULL)
printf (“GetAnnexbNALU: Could not allocate Buf memory\n“);
printf(“nalu->max_size=%d\n“(int)nalu->max_size);
memset(Buf0nalu->max_size);
nalu->startcodeprefix_len = 3;//初始化码流序列的开始字符为3个字节
if (3 != fread (Buf 1 3 bits))//从码流中读3个字节
{
free(Buf);
return 0;
}
info2 = FindStartCode2 (Buf);//判断是否为0x000001
if(info2 != 1)
{
//如果不是,
相关资源
- 从零开始学习音视频编程技术41 H.26
-
H264Pla
yer41H.264播放器.zip - live555-20181214基于ARM-linux从网络摄像机
- Hi3521A/Hi3520DV300 H.264编解码处理器用
- ScreenReceiver46接收rtp流解析并解码播放
- H.264 (H264)文件800_600.264,分辨率8
- 深入理解视频编解码技术 基于H.264标
- GES SRTP OPC Server
- Hi3559V100 中文用户指南
- H.264中文版和英文版官方手册(PDF高清
- h.264在fpga上的实现
- 从零开始学习音视频编程技术41 H.26
- Hi3531A H.264编解码处理器用户指南
- Qt基于RTP打包H.264
- Qt基于librtmp推送H.264
- h.264和mpeg-4视频压缩--欧阳合译中文清
- cef_binary_78.3.9+gc7345f2+chromium-78.0.3904.
- CEF 3.3497.1817 x86带ffmpeg支持H.264/MP3/AA
- CEF 3.3396.1785 macOS 64位 带ffmpeg支持H.2
- H.264码流分析器 1.1
- H264文件分析器
- CEF 3.3396.1782 x86带ffmpeg支持H.264/MP3/MP
- 岳维功 ortp-realease.pdf
- jrtplib 3.9
- 帧内预测解析
- jrtplib移植到安卓
- 实时传输RTP代码
- linuxRTP打包发送
- H265 RTP封装格式
- 基于H.265的RTP封装
评论
共有 条评论