⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vod.cpp

📁 vod vod vod vod
💻 CPP
📖 第 1 页 / 共 5 页
字号:
			RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl);
			RMFSetPropertyValue(ctrl_prop, RM_PROPERTY_HWLIB, "AUDIO_SET", "eaVolumeRight", 50);
			RMFSetPropertyValue(ctrl_prop, RM_PROPERTY_HWLIB, "AUDIO_SET", "eaVolumeLeft", 50);
}
int keystart()
{
			int i=0;
			RMTpropertyControl ctrl_prop;
	  	 if (RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl)!=RM_OK)
		    {	fprintf(stderr, "get handle is error\n");
    		  return -1;
    		}      
			RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl);
			RMFSetPropertyValue(ctrl_prop, RM_PROPERTY_HWLIB, "AUDIO_SET", "eaVolumeRight", 0);
			RMFSetPropertyValue(ctrl_prop, RM_PROPERTY_HWLIB, "AUDIO_SET", "eaVolumeLeft", 0);
			RMFPlayFile(ctrl_file);
			timeout=1;
}

int keystop()
{
			RMFStopFile(ctrl_file);

		
}


int keyreplay()
{
	
	
		if (!IFMute)
			{
				IFFastPlay=false;
				IFPause=false;
				delete icon;
	  		icon = new fgl::FGBitmap("osdimage/play.bmp");
				osd_disp_stat=4;
				id_times=10;
			}
		
	    RMFStopFile(ctrl_file);
			RMFCloseControlInterface(ctrl);
			openDVDfile(curplaypath);
			printf("replay:%s\n",curplaypath); 
			RMFGetControlHandle((void **) &ctrl_file, RM_CONTROL_FILE, ctrl);
			RMFPlayFile(ctrl_file);
			
			//RMFGetControlHandle((void **) &ctrl_file, RM_CONTROL_FILE, ctrl);
			//RMFPauseFile(ctrl_file);
			//RMFStopFile(ctrl_file);
		///	RMFPlayFile(ctrl_file);
}

int keyPause()
{
	//RMTfileControl ctrl_file;
 	//RMFGetControlHandle((void **) &ctrl_file, RM_CONTROL_FILE, ctrl);
	RMFPauseFile(ctrl_file);
}


int LR(int left_right)
{
		RMTpropertyControl ctrl_prop;
   	
   	
	   if (RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl)!=RM_OK)
    {	fprintf(stderr, "get handle is error\n");
      return -1;
    	}      
				
				if (left_right==1)
				{RMFSetPropertyValue(ctrl_prop, RM_PROPERTY_HWLIB, "AUDIO_SET", "eAudioMode", eAudioMode_MonoRight);}
				else
				{RMFSetPropertyValue(ctrl_prop, RM_PROPERTY_HWLIB, "AUDIO_SET", "eAudioMode", eAudioMode_MonoLeft);}
				
	}




bool CheckAudio(int type)
{
		switch (type){
case STREAM_TYPE_RESERVED:
			return false;		
		break;
case STREAM_TYPE_MPEG1_VIDEO:
 	   return false;
 	 break;
case STREAM_TYPE_MPEG2_VIDEO:
		 return false;	
	 break;
case STREAM_TYPE_MPEG1_AUDIO:
			return true;
	 break;
case STREAM_TYPE_MPEG2_AUDIO:
			return true;
	 break;
case STREAM_TYPE_MPEG2_PRIVATE:
	return true;
	 break;
case STREAM_TYPE_MPEG2_PES_PRIVATE:
	return true;
	 break;
case STREAM_TYPE_MHEG:
	return true;
	 break;
case STREAM_TYPE_DSMCC:
	return true;
	 break;
case STREAM_TYPE_H222:
	return true;
	 break;
case STREAM_TYPE_DSMCC_A:
	return true;
	 break;
case STREAM_TYPE_DSMCC_B:
	return true;
	 break;
case STREAM_TYPE_DSMCC_C:
	return true;
	 break;
case STREAM_TYPE_DSMCC_D:
	return true;
	 break;
case STREAM_TYPE_MPEG1_AUX:
	return true;
	 break;
case STREAM_TYPE_AAC_ADTS:
	return true;
	 break;
case STREAM_TYPE_MPEG4_VIDEO:
			return false;
	 break;
case STREAM_TYPE_MPEG4_AUDIO:
	return true;
	 break;
case STREAM_TYPE_FLEXMUX_PES:
	return true;
	 break;
case STREAM_TYPE_FLEXMUX_SYSTEM:
	return true;
	 break;
case STREAM_TYPE_DSMCC_SDP:
	return true;
	 break;
case STREAM_TYPE_SUBPICTURE:
	return true;
	 break;
case STREAM_TYPE_AC3:
	return true;
	 break;
case STREAM_TYPE_PCM:
	return true;
	 break;
case STREAM_TYPE_NAVIGATION:
	return true;
	 break;
case STREAM_TYPE_DTS:
	return true;
	 break;
}	
}

int track(int trackid)
{
			RMuint32 numberOfStreams = 0;
			RMuint32 i;
			RMdemuxStreamType demuxStreamType;
			RMstreamId  audioStream,changeStream[3],OneStream,TwoStream;
			RMTpropertyControl ctrl_prop;	 	
			RMint32 selectedAudioStream;
							
			RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl);

			RMFGetPropertyValue(ctrl_prop, RM_PROPERTY_EXTERNAL, "DEMUX", "NumberOfStreams", &numberOfStreams);
			printf("Number of Streams : %lu\n", numberOfStreams);
			
			if ((numberOfStreams < 3)||(trackid>(numberOfStreams-1)))
				return -1;
			
			bool first=false;
			int trackcount=0;
			for (i=0; i<numberOfStreams; i++)
			 {
					demuxStreamType.streamNumber=i;
					RMFGetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL,"DEMUX", "StreamType", &demuxStreamType, sizeof(RMdemuxStreamType));
				if (CheckAudio(demuxStreamType.demuxStreamType))
					{
						changeStream[trackcount].id=demuxStreamType.streamPID;
					  changeStream[trackcount].subId=demuxStreamType.streamSubID;
//					  printf ("Track %d Stream No %lu, PID 0x%04X, SubPID 0x%02X\n",trackcount,demuxStreamType.streamPID,demuxStreamType.streamSubID);
					  trackcount++;
					}
	//				printf ("Stream No %lu, PID 0x%04X, SubPID 0x%02X\n",i,demuxStreamType.streamPID,demuxStreamType.streamSubID);
		   }
   if (trackcount <2)
   	 return -1;
   	 
   if (trackid==1)
				RMFSetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL, "DEMUX", "AudioPID", &changeStream[0], sizeof(RMstreamId));

	 if (trackid==2)
				RMFSetGenericProperty(ctrl_prop, RM_PROPERTY_EXTERNAL, "DEMUX", "AudioPID", &changeStream[1], sizeof(RMstreamId));

		//	printf ("selected PID 0x%04X, SubPID 0x%02X\n",changeStream[0].id,changeStream[0].subId);
	 	//	printf ("selected PID 0x%04X, SubPID 0x%02X\n",changeStream[1].id,changeStream[1].subId);
	   	 
 	 //设置左右声道音量都为50
 	 RMFSetPropertyValue(ctrl_prop, RM_PROPERTY_HWLIB, "AUDIO_SET", "eAudioMode", eAudioMode_Stereo);	
 	}



int FastPlay()
{
	
if (IFFastPlay)
	{
//		RMFPauseFile(ctrl_file);
		RMFPlayFile(ctrl_file); 
		setsound(50);
		IFFastPlay=false;
		delete icon;
		icon = new fgl::FGBitmap("osdimage/play.bmp");
		osd_disp_stat=4;
		id_times=10;
		
	}
else
	{	RMFPauseFile(ctrl_file);
		RMFFastForwardFile(ctrl_file, 4);	
		IFFastPlay=true;
		
		IFPause=false;
		IFMute=false;
		
		delete icon;
		icon = new fgl::FGBitmap("osdimage/cc.bmp");
		osd_disp_stat=4;
		id_times=100;
	}
}

int Pause()
{
	if (IFPause)
	{
		RMFPlayFile(ctrl_file);
		setsound(50); 
		IFPause=false;
		delete icon;
	  icon = new fgl::FGBitmap("osdimage/play.bmp");
		osd_disp_stat=4;
		id_times=10;
	}
else
	{	RMFPauseFile(ctrl_file);		
		IFPause=true;
		
		IFFastPlay=false;
		IFMute=false;

		delete icon;
	  icon = new fgl::FGBitmap("osdimage/dd.bmp");
		osd_disp_stat=4;
		id_times=100;
	}
}


	
int Mute()
{
	if (IFFastPlay||IFPause)
		return -1;
	
	RMTpropertyControl ctrl_prop;	 	
  RMFGetControlHandle((void **) &ctrl_prop, RM_CONTROL_PROPERTY, ctrl);
if (IFMute)
	{
	setsound(50);
	IFMute=false;
	delete icon;
  icon = new fgl::FGBitmap("osdimage/nomute.bmp");
	osd_disp_stat=4;
	id_times=10;
  }
else
	{
	setsound(0);
	IFMute=true;
	
	IFFastPlay=false;
	IFPause=false;

	delete icon;
  icon = new fgl::FGBitmap("osdimage/mute.bmp");
	osd_disp_stat=4;
	id_times=100;
	}
}

int keyLR()
{  	
		char c[4];
		if (IFFastPlay||IFPause||IFMute)
		return -1;
		
				fprintf(stderr,"curcode:%s\n",curplaycode);
				sprintf(c,"%c",curplaycode[1]);
				code_one_bit=atoi(c);
				sprintf(c,"%c",curplaycode[2]);
				code_sec_bit=atoi(c);
				fprintf(stderr,"one bit:%d  sec bit:%d\n",code_one_bit,code_sec_bit);
		
		if (strcmp(curplaycode,"NULL")==0)  
		      {
		      	delete icon;
						icon = new fgl::FGBitmap("osdimage/aa.bmp");
						osd_disp_stat=4;
						id_times=10;
		      	LR(atoi(LR_val));
				   	return 0;
				  }	
		
				
		if(karaok) //无伴唱
			{
				delete icon;
				icon = new fgl::FGBitmap("osdimage/bb.bmp");
				osd_disp_stat=4;
				id_times=10;
				if (code_sec_bit==0) //单轨
						if(code_one_bit==0)
							 	 LR(0);
							else
								 LR(1);
						
				else								 //双轨	
					{
						if (code_sec_bit==1)
					     track(1);
					  if (code_sec_bit==2)
					  	 track(2);
					}
			}
    else       //有伴唱
      {
      	delete icon;
				icon = new fgl::FGBitmap("osdimage/aa.bmp");
				osd_disp_stat=4;
				id_times=10;
      	if (code_sec_bit==0) //单轨
						{
							if(code_one_bit==0)
							 	 LR(1);
							else
								 LR(0);
							}
				else								 //双轨	
					{
						if (code_sec_bit==1)
					     track(2);
					  if (code_sec_bit==2)
					  	 track(1);
					}
      	
      }     
      
      if (karaok) 
      	printf("原唱\n");
      else
      	printf("伴唱\n");
}
//**************************************dvdebd

bool GetSQLTime()
{
char query[256];
char tmp[256];
char *pp[5];


sprintf(query,"SELECT datepart(hour,getdate())as h,datepart(minute,getdate()) as m,DATEDIFF(minute, getdate(),etime) as ts ,rtrim(expenseid),tbl_parameter.para from tbl_room,tbl_parameter where tbl_room.id='%s' and tbl_parameter.id='Marquee'",hostname);

do_query(tds,query);
 get_tds_one_row(tds,tmp);
 if (strlen(tmp)>1)
 	{
	 split(tmp,pp);	   
   sprintf(query,"%02d:%02d 余%s分",atoi(pp[0]),atoi(pp[1]),pp[2]);
   strcpy(expenseid,pp[3]);
   strcpy(ctmp,pp[4]);
  }
redrawtext(wnd,b,query,400,460,220,20,song18);
printf("yutime:%d \n",atoi(pp[2]));

if (atoi(pp[2] )<1)
	ISTIMEUP=true;
else
	ISTIMEUP=false;
	
}

//**************
//现实剩余时间**
//**************
char *validate_wav_header(char *header, int verbose)
{
   WAVE_HEADER *wheader = (WAVE_HEADER *)header;

   /* first 4 bytes should be RIFF */

   if (strncmp(wheader->RiffID,"RIFF",4) != 0)
   {
      if (verbose)
         printf(".wav header dont have RIFF\n");
      return(NULL);
   }

   /* if (verbose) printf("RiffSize is %ld\n",wheader->RiffSize); */

   /* next 4 bytes should be WAVE */
   if (strncmp(wheader->WaveID,"WAVE",4) != 0)
   {
      if (verbose) printf("header dont have WAVE\n");
      return(NULL);
   }          

   /* next 4 bytes should be "fmt " */
   if (strncmp(wheader->FmtID,"fmt ",4) != 0)
   {
      if (verbose)
         printf("header dont have fmt\n");
      return(NULL);
   }           

   if (wheader->FmtSize != 16)
   {
      if (verbose)
        printf("this program only deals with 16 bit audio data\n");
        printf("bit:%d\n" ,wheader->FmtSize);

      return(NULL);
   }

   if (wheader->wFormatTag != 1)
   {
      if (verbose)
         printf("This wav is not PCM, we cant deal with it\n");
      return(NULL);
   }

   if (wheader->nChannels != 2)
   {
      if (verbose)
          printf("Presently we only deal with two channels, this has %d\n",
             wheader->nChannels);
      return(NULL);
   }        
   if (wheader->nSamplesPerSec != 44100)
   {
      if (verbose) 
         printf("Presently we only deal with 44100 hz, this has %ld\n",
            wheader->nSamplesPerSec);
      return(NULL);
   }  

   /* next 4 bytes should be "data" */
   if (strncmp(wheader->DataID,"data",4) == 0)
   {
   return (header + sizeof(WAVE_HEADER));	  
	}           
     else
	 {
     if (strncmp(wheader->DataID+2,"data",4) == 0)
     {
		 strcpy(wheader->DataID,"data");
         printf("data:%s",wheader->DataID);
		 return (header + sizeof(WAVE_HEADER)+2);	  
	 
	 }
	 else
	 {if (verbose) printf("header dont have data\n");
      return(NULL);
	 }	
	 
	 }
   
}

short get_peak_value(short *start, short *end)
{
   short the_max = 0;

   short *current = start;

   while (current < end)
   {
      if (abs(*current) > the_max)
         the_max = abs(*current);
      current++;
   }
   return the_max;
}

void create_wav_header(WAVE_HEADER *wheader,
   int nChannels,int nSamplesPerSec,int wBitsPerSample)
{
   /* first 4 bytes should be RIFF */

   strncpy(wheader->RiffID,"RIFF",4);

   /* next 4 bytes should be WAVE */
   strncpy(wheader->WaveID,"WAVE",4);

   /* next 4 bytes should be "fmt " */
   strncpy(wheader->FmtID,"fmt ",4);

   wheader->FmtSize = 16;

   wheader->wFormatTag = 1;

   wheader->nChannels = nChannels;
   wheader->nSamplesPerSec = nSamplesPerSec;
   wheader->nAvgBytesPerSec = nSamplesPerSec * nChannels * wBitsPerSample/8;
   wheader->wBitsPerSample = wBitsPerSample;
   wheader->nBlockAlign = nChannels * wBitsPerSample/8;

   strncpy(wheader->DataID,"data",4);
}




int open_dsp(WAVE_HEADER *wav_info)
{
   int dspfd;
   int status;
   int arg;

   /** open the sound device and set it up **/
   dspfd = open("/dev/dsp3",O_WRONLY);
   if (dspfd < 0) 
   {
      perror("open of /dev/dsp3 failed");
      return(-1);
   }
   arg = wav_info->wBitsPerSample;
   status = ioctl(dspfd, SOUND_PCM_WRITE_BITS, &arg);

   if (status == -1)
   {
      perror("SOUND_PCM_WRITE_BITS ioctl failed");
      return(-1);
   }
   if (arg != wa

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -