Exemple #1
0
MyJPEGVideoSource::MyJPEGVideoSource(UsageEnvironment& env, int streamID, int Quality)
	: FramedSource(env)
	, fStreamID(streamID)
	, fMaxOutputPacketSize(1428) //1448 -20
	, fPTS(0)
	, fSessionID(0)
	, fType(0)
	, fPrecision(0)
	, fWidth(0)
	, fHeight(0)
	, fFragmentOffset(0)
	, fFragmentBeginAddr(NULL)
	, fFragmentLeftSize(0)
{
	fQ = (u_int8_t)(Quality & 0xFF);
	fQuantizationTables = new u_int8_t[128];
#ifdef CONFIG_APP_IPCAM_USE_BSBUFFER
	//open bs buffer
	hBsBuffer = gmi_bs_shm_open(fStreamID);
	uPacketReadSN = 0;
#endif
}
int main(int argc,char*argv[])
{
	int ret;
	void* handle=NULL;
	int streamid=0;
	char *file=NULL;
	void *pBuffer=NULL;
	u32 bufsize=0;

	if (argc < 3)
	{
		fprintf(stderr,"%s streamid dumpfilename\n",argv[0]);
		exit(3);
	}

	streamid = atoi(argv[1]);
	file = argv[2];

	handle = gmi_bs_shm_open(streamid);
	if (handle == NULL)
	{
		APP_ERROR("\n");
		ret = -3;
		goto out;
	}

	ret = GetH264Buffer(handle,&pBuffer,&bufsize);
	if (ret < 0)
	{
		APP_ERROR("\n");
		goto out;
	}

	if (ret == 1)
	{
		fprintf(stderr,"get iframe\n");
	}
	else if (ret == 2)
	{
		fprintf(stderr,"get jpeg\n");
	}

	ret = WriteToFile(file,pBuffer,bufsize);
	if (ret < 0)
	{
		APP_ERROR("\n");
		goto out;
	}

	ret = 0;
	
out:
	if (handle)
	{
		gmi_bs_shm_close(handle);
	}
	handle = NULL;

	if (pBuffer)
	{
		free(pBuffer);
	}
	pBuffer = NULL;
	bufsize = 0;
	return ret;	
}