资源简介
通过RTP发送h264码流,网上比较多的版本,可在上位机用vlc播放,是一个学习rtp协议的好例子

代码片段和文件信息
// NALDecoder.cpp : Defines the entry point for the console application.
//
#include
#include
#include
#include
#include “rtp.h“
#include
#include
#include
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 bool flag = true;
static int info2=0 info3=0;
RTP_FIXED_HEADER *rtp_hdr;
NALU_HEADER *nalu_hdr;
FU_INDICATOR *fu_ind;
FU_HEADER *fu_hdr;
/*BOOL InitWinsock()
{
int Error;
WORD VersionRequested;
WSADATA WsaData;
VersionRequested=MAKEWORD(22);
Error=WSAStartup(VersionRequested&WsaData); //启动WinSock2
if(Error!=0)
{
return FALSE;
}
else
{
if(LOBYTE(WsaData.wVersion)!=2||HIBYTE(WsaData.wHighVersion)!=2)
{
WSACleanup();
return FALSE;
}
}
return TRUE;
}*/
//为NALU_t结构体分配内存空间
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的长度
int GetAnnexbNALU (NALU_t *nalu)
{
int pos = 0;
int StartCodeFound rewind;
unsigned char *Buf;
if ((Buf = (unsigned char*)calloc (nalu->max_size sizeof(char))) == NULL)
printf (“GetAnnexbNALU: Could not allocate Buf memory\n“);
nalu->startcodeprefix_len=3;//初始化码流序列的开始字符为3个字节
if (3 != fread (Buf 1 3 bits))//从码流中读3个字节
{
free(Buf);
return 0;
}
info2 = FindStartCode2 (Buf);//判断是否为0x000001
if(info2 != 1)
{
//如果不是,再读一个字节
if(1 != fread(Buf+3 1 1 bits))//读一个字节
{
free(Buf);
return 0;
}
info3 = FindStartCode3 (Buf);//判断是否为0x00000001
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-04-18 16:27 RTP_H264\
文件 13192 2015-04-15 17:32 RTP_H264\rtp.c
文件 1516 2013-09-23 11:43 RTP_H264\rtp.h
- 上一篇:address.txt
- 下一篇:沈鑫剡《路由和交换技术实验实训》一书配套实验文件
相关资源
- JM阅读笔记(学习H264)
- h264 ip核,经过asic验证
- FFMEPG实现h264解码
- H264标准的详细图解
- RTMP_H265推流直播技术研讨
- vs2010 ffmpeg实时解码h264码流
- Qt基于FFmpeg播放本地 H.264H264文件
- 从ffmpeg中抽取的h264解码器,可用于
- ffmpeg解码sdl播放h264
- 使用ffmpeg将多张图片生成H264裸流并获
- ffmpeg h264 转换jpg
- ffmpeg_windows屏幕录制并编码成H264
- ffmpeg封装H264成MP4、AVI视频格式,及提
- H264实时编码RTSP直播
- h264经典学习指南书籍
- rtmp流播放工具
- h264裸流文件
- 内存H264+PCM发布rtmp.rar
- .h264文件裸流制作与播放
- rtsp-h264.zip
- 使用gpac封装MP4源码(新)
- 视频压缩编码H.264源代码
- H.264标准文档中文完整版
- 使用ffmpeg api解码h264视频码流,并且能
- H264流转为AVI文件
- 最全解码测试h264测试文件包
- h264视频流多个文件1080p
- jpeg-8c库 及H264转jpeg代码
- x264 vs2010工程
- H264裸流视频
评论
共有 条评论