修改码率适应公网低带宽
parent
f9b2b3dda8
commit
756f205b05
|
@ -14,3 +14,4 @@ device/mpp/sample/venc/su.WK3
|
||||||
device/mpp/sample/venc/su.PS
|
device/mpp/sample/venc/su.PS
|
||||||
device/mpp/sample/venc/su.PRI
|
device/mpp/sample/venc/su.PRI
|
||||||
device/mpp/sample/venc/su.PR
|
device/mpp/sample/venc/su.PR
|
||||||
|
device/mpp/sample/venc/Makefile2
|
||||||
|
|
|
@ -332,28 +332,24 @@ HI_S32 SAMPLE_COMM_VENC_SaveH264(FILE* fpH264File, VENC_STREAM_S *pstStream)
|
||||||
printf("islice ");
|
printf("islice ");
|
||||||
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_SEI) {
|
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_SEI) {
|
||||||
printf("sei ");
|
printf("sei ");
|
||||||
// break; // ignore sei frame
|
|
||||||
}
|
}
|
||||||
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_SPS)
|
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_SPS)
|
||||||
printf("sps ");
|
printf("sps ");
|
||||||
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_IPSLICE)
|
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_IPSLICE)
|
||||||
printf("islice ");
|
printf("islice ");
|
||||||
/*
|
|
||||||
fwrite(pstStream->pstPack[i].pu8Addr + pstStream->pstPack[i].u32Offset ,
|
fwrite(pstStream->pstPack[i].pu8Addr + pstStream->pstPack[i].u32Offset ,
|
||||||
pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset, 1, fpH264File);*/
|
pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset, 1, fpH264File);
|
||||||
unsigned char *p = pstStream->pstPack[i].pu8Addr;
|
unsigned char *p = pstStream->pstPack[i].pu8Addr;
|
||||||
printf("h264 header file %d length %d nal count %d offset %x %x %x %x %x %x %x %x\r\n",
|
printf("h264 header file %d length %d nal count %d offset %x %x %x %x %x %x %x %x\r\n",
|
||||||
pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset,
|
pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset,
|
||||||
i,
|
i,
|
||||||
pstStream->pstPack[i].u32Offset,
|
pstStream->pstPack[i].u32Offset,
|
||||||
p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
|
p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
|
||||||
|
|
||||||
int packCnt = Pack264AndSend(
|
int packCnt = Pack264AndSend(
|
||||||
pstStream->pstPack[i].pu8Addr
|
pstStream->pstPack[i].pu8Addr + pstStream->pstPack[i].u32Offset
|
||||||
,pstStream->pstPack[i].u32Len
|
,pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset
|
||||||
, gRtspclient);
|
, gRtspclient);
|
||||||
|
|
||||||
|
|
||||||
fflush(fpH264File);
|
fflush(fpH264File);
|
||||||
}
|
}
|
||||||
return HI_SUCCESS;
|
return HI_SUCCESS;
|
||||||
|
@ -533,20 +529,21 @@ HI_S32 SAMPLE_COMM_VENC_Start(VENC_CHN VencChn, PAYLOAD_TYPE_E enType,
|
||||||
if(SAMPLE_RC_CBR == enRcMode)
|
if(SAMPLE_RC_CBR == enRcMode)
|
||||||
{
|
{
|
||||||
stVencChnAttr.stRcAttr.enRcMode = VENC_RC_MODE_H264CBR;
|
stVencChnAttr.stRcAttr.enRcMode = VENC_RC_MODE_H264CBR;
|
||||||
stH264Cbr.u32Gop = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:25;
|
stH264Cbr.u32Gop = (VIDEO_ENCODING_MODE_PAL== enNorm)?3:3;
|
||||||
stH264Cbr.u32StatTime = 1; /* stream rate statics time(s) */
|
stH264Cbr.u32StatTime = 1; /* stream rate statics time(s) */
|
||||||
stH264Cbr.u32SrcFrmRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:25;/* input (vi) frame rate */
|
stH264Cbr.u32SrcFrmRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?3:3;/* input (vi) frame rate */
|
||||||
stH264Cbr.fr32DstFrmRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?25:25;/* target frame rate */
|
stH264Cbr.fr32DstFrmRate = (VIDEO_ENCODING_MODE_PAL== enNorm)?3:3;/* target frame rate */
|
||||||
|
|
||||||
switch (enSize)
|
switch (enSize)
|
||||||
{
|
{
|
||||||
case PIC_QCIF:
|
case PIC_QCIF:
|
||||||
stH264Cbr.u32BitRate = 256; /* average bit rate */
|
stH264Cbr.u32BitRate = 80; /* average bit rate */
|
||||||
break;
|
break;
|
||||||
case PIC_QVGA: /* 320 * 240 */
|
case PIC_QVGA: /* 320 * 240 */
|
||||||
|
stH264Cbr.u32BitRate = 80;
|
||||||
case PIC_CIF:
|
case PIC_CIF:
|
||||||
|
|
||||||
stH264Cbr.u32BitRate = 512;
|
stH264Cbr.u32BitRate = 80;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PIC_D1:
|
case PIC_D1:
|
||||||
|
@ -1299,7 +1296,7 @@ HI_VOID* SAMPLE_COMM_VENC_GetVencStreamProc(HI_VOID *p)
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
step 2.5 : save frame to file
|
step 2.5 : save frame to file
|
||||||
*******************************************************/
|
*******************************************************/
|
||||||
if( i == 1){
|
if(i == 2){
|
||||||
s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType[i], pFile[i], &stStream);
|
s32Ret = SAMPLE_COMM_VENC_SaveStream(enPayLoadType[i], pFile[i], &stStream);
|
||||||
if (HI_SUCCESS != s32Ret)
|
if (HI_SUCCESS != s32Ret)
|
||||||
{
|
{
|
||||||
|
|
|
@ -157,7 +157,7 @@ int SendRecord(RtspClient *p,CallBack *c){
|
||||||
|
|
||||||
int SendRtpPackage(RtspClient *p,unsigned char *buf,int length) {
|
int SendRtpPackage(RtspClient *p,unsigned char *buf,int length) {
|
||||||
int ret = Send(p->sock,(char*)buf,length);
|
int ret = Send(p->sock,(char*)buf,length);
|
||||||
printf("request send %d ,send rtp pack %d \r\n",length,ret,buf);
|
//printf("request send %d ,send rtp pack %d \r\n",length,ret,buf);
|
||||||
if(0 > ret){
|
if(0 > ret){
|
||||||
CloseConn(p->sock);
|
CloseConn(p->sock);
|
||||||
p->conn = FALSE;
|
p->conn = FALSE;
|
||||||
|
|
Binary file not shown.
|
@ -155,7 +155,7 @@ int Pack264AndSend(unsigned char *frame,int size,RtspClient * p){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int packCnt = (size - 5) /MAX_RTP_LEN;
|
int packCnt = (size - 5) /MAX_RTP_LEN;
|
||||||
printf("%d package pack\r\n",packCnt);
|
// printf("%d package pack\r\n",packCnt);
|
||||||
if(packCnt == 0) {
|
if(packCnt == 0) {
|
||||||
header.seq = htons(seq++);
|
header.seq = htons(seq++);
|
||||||
sendLength = size - 5 + sizeof(FuIdentifier) + sizeof(CRtpHeader) + sizeof(rtspInterleavedFrameHeader);
|
sendLength = size - 5 + sizeof(FuIdentifier) + sizeof(CRtpHeader) + sizeof(rtspInterleavedFrameHeader);
|
||||||
|
@ -193,7 +193,7 @@ int Pack264AndSend(unsigned char *frame,int size,RtspClient * p){
|
||||||
rtspInterleavedFrameHeader.length = htons(MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader));
|
rtspInterleavedFrameHeader.length = htons(MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader));
|
||||||
}else{
|
}else{
|
||||||
sendLength = (size - 5)%MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader) + sizeof(RtspInterleavedFrameHeader);
|
sendLength = (size - 5)%MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader) + sizeof(RtspInterleavedFrameHeader);
|
||||||
printf("last package send %d length\r\n",sendLength);
|
//printf("last package send %d length\r\n",sendLength);
|
||||||
rtspInterleavedFrameHeader.length = htons((size - 5)%MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader));
|
rtspInterleavedFrameHeader.length = htons((size - 5)%MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader));
|
||||||
}
|
}
|
||||||
nalUnit.Header.End = 1;
|
nalUnit.Header.End = 1;
|
||||||
|
|
Loading…
Reference in New Issue