nbLPCM++;
uint8_t  MpegaudoDetectAudio(char *name, mpegAudioTrack *audioTrack){    	uint8_t streamid,audiostreamid=0x00;	mParser *parser;	uint32_t nbAC3=0,nbMpeg=0,nbLPCM=0;	int32_t pts;	uint32_t vid=0;	uint8_t token;	// clear it before using it. Default = not present.	memset(audioTrack,0,sizeof(mpegAudioTrack)*24);	printf("audio Id: %x\n",audiostreamid);		parser=new mParser();		if(!parser->open(name))		{				GUI_Alert("Error reading mpeg !");				delete parser;				return 0;		}	if(parser->read8i()==0x47) // Mpeg TS	{		uint32_t nb;		ADM_TsTrackInfo *info;				if(! ADM_TsParse(name,&nb,&info)) return 0;				uint32_t nbvid=0;		uint32_t id;				printf("Found %d tracks\n",nb);		for(uint32_t i=0;i<nb;i++)		{			id=info[i].es;			printf("Id:%x\n",id);			if(id>=0xc0 && id<=0xcf) // Mpeg1/2 audio			{				audioTrack[nbMpeg].presence=1;				audioTrack[nbMpeg].shift=i;				nbMpeg++;							}			else			if(id==0xbd) // private stream			{				audioTrack[nbAC3+8].presence=1;				audioTrack[nbAC3+8].shift=i;				nbAC3++;			}			else if(id>=0xE0 && id<=0xEF)			{				if(!nbvid) vid=i;				nbvid++;			}		}		if(!nbvid)		{			GUI_Alert("No video track found!");			return 0;		}		printf("Video is pid :%x\n",vid);		if((nbAC3+nbMpeg)==0)		{			GUI_Alert("No audio track found\n");			return 0;			}		// Now that we have the video stream		// we can compute the a/v sync value		nbAC3=nbMpeg=0;		int64_t vidPts=info[vid].pts;				int64_t audPts=0;		uint32_t track;		double d;				printf("Vid is tack %d, with pts %lu\n",vid,info[vid].pts);		for(uint32_t i=0;i<8;i++)		{			//printf("%d<\n",i);						if(audioTrack[i].presence)			{				track=audioTrack[i].shift;				audPts=info[track].pts;				printf("MPEG aud %lu %d\n",audPts,audioTrack[i].shift);				d=vidPts;				d-=audPts;				d/=90.;				audioTrack[i].shift=(int32_t)floor(d);				printf("%ld ms\n",(int32_t)floor(d));				getMP2AudioTrackInfo(name,info[track].pid, &audioTrack[i].channels, 								&audioTrack[i].bitrate,1);							}			if(audioTrack[i+8].presence)			{								track=audioTrack[i+8].shift;				audPts=info[track].pts;				printf("AC3 aud %li %d\n",audPts,audioTrack[i+8].shift);				d=vidPts;				d-=audPts;				d/=90.;				audioTrack[i+8].shift=(int32_t)floor(d);				printf("%ld ms\n",(int32_t)floor(d));				getAC3AudioTrackInfo(name,info[track].pid, &audioTrack[i+8].channels, 								&audioTrack[i+8].bitrate,1);							}					}				return 1;					}	else	{	parser->setpos(0);	parser->sync(&token);	// first identify stream type (ES/PS)	delete parser;	switch(token)		{				case 0xb3: // video es									// no audio in video es									printf("video es, no audio\n");									return 0;									break;				case 0xba : // program stream ?	(vob/mpeg/VCD)									break;				default:								printf("\n unrecognized stream\n");								return 0;		}		printf("Program stream");	// First we do a quick pick to find what is present in the stream	//	ADM_mpegDemuxerProgramStream *parser;	uint8_t id;		parser=new ADM_mpegDemuxerProgramStream(0xE0,0xFF);	if(!parser->open(name)) 	{		delete parser;		return 0;	}		uint32_t count=5000; // =~ 10 Mbytes scanned	while(count>0)	{		if(!parser->peekPacket(&id)) break;		if(id>=0xC0 && id<=0xc7) 		{			audioTrack[id-0xC0].presence=1;		}		if(id>=0xA0 && id<=0xA7) 		{			audioTrack[id-0xA0+16].presence=1;		}		if(id<=0x7)		{		 audioTrack[id+8].presence=1;		}		count--;	}	delete parser;	// Then we do get more info on the present stream(s)	for(uint32_t i=0;i<8;i++)		{					if(audioTrack[i+8].presence)				if(tryAudioTrack(name,i,&audioTrack[i+8]))			{				printf("AC3 %d is present\n",i);								nbAC3++;			}			if(audioTrack[i].presence)			if(tryAudioTrack(name,0xc0+i,&audioTrack[i]))			{					printf("Mpeg %d is present \n",i,&audioTrack[i]);				nbMpeg++;			}			if(audioTrack[i+16].presence)			if(tryAudioTrack(name,0xA0+i,&audioTrack[i+16]))			{				printf("LPCM %d is present \n",i);			}		}				printf("Found %d ac3  tracks\n",nbAC3);		printf("Found %d mpg  tracks\n",nbMpeg);		printf("Found %d lpcm tracks\n",nbLPCM);		if(nbAC3+nbLPCM+nbMpeg==0) 			{				printf("could not find audio track\n");					return 0;			}	}		return 1;}