91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 386KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-26
  • 語言: C/C++
  • 標簽: rtp??實現??代碼??

資源簡介

rtp協議的c語言實現demo,有具體的樣例,編譯后直接執行即可

資源截圖

代碼片段和文件信息

//?NALDecoder.cpp?:?Defines?the?entry?point?for?the?console?application.

#include?
#include?
#include?
#include?
#include?“h264.h“
#include?“initsock.h“

CInitSock?initSock; //?初始化Winsock庫

//為NALU_t結構體分配內存空間

NALU_t?*AllocNALU(int?buffersize)
{
NALU_t?*pNalu;
if?((pNalu?=?(NALU_t*)calloc?(1?sizeof?(NALU_t)))?==?NULL) {
printf(“AllocNALU:?Nalu“);
exit(0);
}

pNalu->max_size=buffersize;
if?((pNalu->buf?=?(char*)calloc?(buffersize?sizeof?(char)))?==?NULL) {
free?(pNalu);
printf?(“AllocNALU:?Nalu->buf“);
exit(0);
}
return?pNalu;
}

//釋放
void?FreeNALU(NALU_t?*pNalu)
{
if?(pNalu) {
if?(pNalu->buf) {
free(pNalu->buf);
pNalu->buf=NULL;
}
free?(pNalu);
}
}

static?int?FindStartCode2?(unsigned?char?*Buf)
{
if(Buf[0]!=0?||?Buf[1]!=0?||?Buf[2]?!=1)?return?0;?//判斷是否為0x000001如果是返回1
else?return?1;
}

static?int?FindStartCode3?(unsigned?char?*Buf)
{
if(Buf[0]!=0?||?Buf[1]!=0?||?Buf[2]?!=0?||?Buf[3]?!=1)?return?0;//判斷是否為0x00000001如果是返回1
else?return?1;
}

//?這個函數輸入為一個NAL結構體,主要功能為得到一個完整的NALU并保存在NALU_t的buf中,獲取他的長度,填充FIDCTYPE位。
//?并且返回兩個開始字符之間間隔的字節數,即包含有前綴的NALU的長度
int?GetAnnexbNALU?(NALU_t?*pNalu?FILE?*bits)
{
int?info2=0?info3=0;
int?pos?=?0;
int?StartCodeFound?rewind;
unsigned?char?*Buf;

if?((Buf?=?(unsigned?char*)calloc?(pNalu->max_size??sizeof(char)))?==?NULL)?
printf?(“GetAnnexbNALU:?Could?not?allocate?Buf?memory\n“);

if?(3?!=?fread?(Buf?1?3?bits))?{ //從碼流中讀3個字節
free(Buf);
return?-1;
????}
if?(Buf[0]!=0?||?Buf[1]!=0)?{
free(Buf);
return?-1;
}
if?(Buf[2]==1)?{
pNalu->startcodeprefix_len=3;???//初始化碼流序列的開始字符為3個字節
pos?=3;
}else?{
if?(1?!=?fread?(Buf+3?1?1?bits))?{ //從碼流中讀1個字節
free(Buf);
return?-1;
}
if?(Buf[2]!=0?||?Buf[3]!=1)?{
free(Buf);
return?-1;
}
pos?=?4;
pNalu->startcodeprefix_len?=?4;
}

//查找下一個開始字符的標志位
StartCodeFound?=?0;
info2?=?0;
info3?=?0;
????while?(!StartCodeFound)??{
if?(feof?(bits))?{ //判斷是否到了文件尾
break;
}
Buf[pos++]?=?fgetc?(bits);//讀一個字節到BUF中
info3?=?FindStartCode3(&Buf[pos-4]);//判斷是否為0x00000001
if(info3?!=?1)
info2?=?FindStartCode2(&Buf[pos-3]);//判斷是否為0x000001
StartCodeFound?=(info2|info3);
}
if?(StartCodeFound)?{
//?Here?we?have?found?another?start?code?(and?read?length?of?startcode?bytes?more?than?we?should
//?have.??Hence?go?back?in?the?file
rewind?=?(info3?==?1)??-4?:?-3;
if?(0?!=?fseek?(bits?rewind?SEEK_CUR))?{?//?把文件指針指向前一個NALU的末尾
free(Buf);
printf(“GetAnnexbNALU:?Cannot?fseek?in?the?bit?stream?file“);
}

}?else?{
rewind?=?-1;
}

//?Here?the?Start?code?the?complete?NALU?and?the?next?start?code?is?in?the?Buf.??
//?The?size?of?Buf?is?pos?pos+rewind?are?the?number?of?bytes?excluding?the?next
//?start?code?and?(pos+rewind)-startcodeprefix_len?is?the?size?of?the?NALU?excluding?the?start?code
pNalu->len?=?(pos+rewind)-pNalu->sta

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????2163??2010-12-29?08:26??NALDecoder\h264.h

?????文件????????461??2010-12-27?12:19??NALDecoder\initsock.h

?????文件??????10206??2010-12-29?08:26??NALDecoder\NALDecoder.cpp

?????文件???????4670??2010-12-27?09:54??NALDecoder\NALDecoder.dsp

?????文件????????543??2008-07-01?09:37??NALDecoder\NALDecoder.dsw

?????文件?????208963??2010-12-29?08:26??NALDecoder\NALDecoder.exe

?????文件??????50176??2010-12-29?08:26??NALDecoder\NALDecoder.ncb

?????文件??????50688??2010-12-29?08:26??NALDecoder\NALDecoder.opt

?????文件???????1267??2010-12-29?08:26??NALDecoder\NALDecoder.plg

?????文件???????1232??2008-07-01?09:37??NALDecoder\ReadMe.txt

?????文件??????93550??2006-07-25?17:57??NALDecoder\test.264

?????文件?????243860??2009-12-04?21:22??NALDecoder\test22.264

?????文件?????????82??2010-12-28?10:18??NALDecoder\w.sdp

?????目錄??????????0??2010-12-29?08:27??NALDecoder

?????文件????????599??2014-06-12?15:20??readme.txt

?????文件??????15872??2014-06-12?15:25??H264RTP打包方法.doc

-----------?---------??----------?-----??----

???????????????684332????????????????????16


評論

共有 條評論