資源簡介
打包發送采用了兩種方式
1.使用socket套接字發送RTP打包的H264
2.使用jrtplib發送RTP打包的H264
可以通過VLC或者MPlayer解碼播放
詳見博客:http://blog.csdn.net/caoshangpa/article/details/53009604
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?“h264.h“
#include?“iostream“
#include?
#include?“rtpsession.h“
#include?“rtpudpv4transmitter.h“
#include?“rtpipv4address.h“
#include?“rtpsessionparams.h“
#include?“rtperrors.h“
#include?“rtppacket.h“
using?namespace?jrtplib;
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?RBSP
????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?info3=0;
RTP_FIXED_HEADER?*rtp_hdr;
NALU_HEADER?????*nalu_hdr;
FU_INDICATOR????*fu_ind;
FU_HEADER???????*fu_hdr;
//為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);
????}
}
//這個函數輸入為一個NALU_t結構體,主要功能為得到一個完整的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
????????if?(info3?!=?1)//如果不是,返回-1
????????{
????????????free(Buf);
????????????retur
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????93550??2012-02-28?19:45??Qt?RTP?H264\SendH264ToVLCWithJrtplib\176144.264
?????文件???25821394??2016-11-07?12:00??Qt?RTP?H264\SendH264ToVLCWithJrtplib\480320.264
?????文件?????845926??2016-01-14?15:08??Qt?RTP?H264\SendH264ToVLCWithJrtplib\debug\libjrtplib.dll
?????文件??????48394??2016-01-14?14:10??Qt?RTP?H264\SendH264ToVLCWithJrtplib\debug\libjthread.dll
?????文件?????150336??2016-11-07?15:36??Qt?RTP?H264\SendH264ToVLCWithJrtplib\debug\main.o
?????文件?????183233??2016-11-07?15:36??Qt?RTP?H264\SendH264ToVLCWithJrtplib\debug\SendH264ToVLCWithJrtplib.exe
?????文件???????2956??2016-11-04?12:32??Qt?RTP?H264\SendH264ToVLCWithJrtplib\h264.h
?????文件???????3703??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpapppacket.h
?????文件???????4049??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpbyepacket.h
?????文件???????4164??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpcompoundpacket.h
?????文件??????12166??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpcompoundpacketbuilder.h
?????文件???????3001??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcppacket.h
?????文件??????11786??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcppacketbuilder.h
?????文件???????6533??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcprrpacket.h
?????文件???????7359??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpscheduler.h
?????文件???????8306??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpsdesinfo.h
?????文件??????10914??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpsdespacket.h
?????文件???????7947??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpsrpacket.h
?????文件???????2811??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtcpunknownpacket.h
?????文件???????3561??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpaddress.h
?????文件???????3765??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpbyteaddress.h
?????文件???????3224??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpcollisionlist.h
?????文件???????2374??2015-11-25?14:24??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpconfig.h
?????文件???????1876??2011-02-02?10:45??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpdebug.h
?????文件???????3098??2011-02-02?10:45??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpdefines.h
?????文件??????11016??2011-08-29?15:43??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtperrors.h
?????文件???????9145??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpexternaltransmitter.h
?????文件???????8556??2011-08-29?15:43??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtphashtable.h
?????文件???????4690??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpinternalsourcedata.h
?????文件???????4087??2011-08-29?15:03??Qt?RTP?H264\SendH264ToVLCWithJrtplib\include\jrtplib\rtpipv4address.h
............此處省略69個文件信息
- 上一篇:Qt加載百度離線地圖
- 下一篇:Web安全攻防:滲透測試實戰指南 PDF 全書
評論
共有 條評論