Live555本地保存H264/PCM视频音频帧附加SPS/PPS


项目用到,这里备份以后防止忘记:


#include "liveMedia.hh"
#include "BasicUsageEnvironment.hh"

static char NALHeader[]={0x00 ,0x00 ,0x00 ,0x01};

void SaveSPS_PPS(MediaSubsession& fSubsession,const char* savePath_)
{
	unsigned int Num=0 ;
	unsigned int &SPropRecords =Num;

	SPropRecord *p_record=NULL ;
	p_record=parseSPropParameterSets(fSubsession.fmtp_spropparametersets(),SPropRecords);
	if(p_record!=NULL){
		for(int i=0;i<Num;i++){
			Fprintf_Binary(savePath_,NALHeader,4);
			Fprintf_Binary(savePath_,(char*)p_record[i].sPropBytes,p_record[i].sPropLength);
		}
		delete[] p_record ;
	}
}
void SaveVideoFrame(MediaSubsession& fSubsession,const char* savePath_,char* frameNAL_, int frameSize_)
{
	if(strcmp(fSubsession.mediumName(),"video")){
		return ;
	}
	Fprintf_Binary(savePath_,NALHeader,4);
	Fprintf_Binary(savePath_,frameNAL_,frameSize_);
}
void SaveAudioFrame(MediaSubsession& fSubsession,const char* savePath_,char* frameNAL_, int frameSize_)
{
	if(strcmp(fSubsession.mediumName(),"audio")){
		return ;
	}
	Fprintf_Binary(savePath_,NALHeader,4);
	Fprintf_Binary(savePath_,frameNAL_,frameSize_);
}





你可能感兴趣的:(保存,PCM,h.264,Live555)