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

  • 大小: 24.66MB
    文件類型: .gz
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-07-03
  • 語言: 其他
  • 標(biāo)簽: RTP??h.264??

資源簡介

Linux 下RTP實時打包發(fā)送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;??????????????//!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);??
}??
}??

//這個函數(shù)輸入為一個NAL結(jié)構(gòu)體,主要功能為得到一個完整的NALU并保存在NALU_t的buf中,獲取他的長度,填充FIDCTYPE位。??
//并且返回兩個開始字符之間間隔的字節(jié)數(shù),即包含有前綴的NALU的長度
//前綴之后的第一個字節(jié)為?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個字節(jié)??
if?(3?!=?fread?(Buf?1?3?bits))//從碼流中讀3個字節(jié)??
{??
free(Buf);??
return?0;??
}??
info2?=?FindStartCode2?(Buf);//判斷是否為0x000001???
if(info2?!=?1)???
{??
//如果不是,

評論

共有 條評論