Ejemplo n.º 1
0
void CVideoPlayDlg::UpdateProgramList()
{
	POSITION  pos = pTblList->GetHeadPosition();
	CTable  * pT , * pSdt = NULL;
	PMTSection * pPmtS;
	u16 ProgramNumber, VideoPid;
	CString ServiceName;
	CListCtrl * pListCtrl ;
	u8 ProgramIndex = 0;
	while(pos)
	{
		pT = (CTable *)(pTblList->GetNext(pos));
		
		if(pT->GetTableID()== ACTUAL_TRANSPORT_SERVICE_DESCRIPTION)
		{
			pSdt = pT;
		}
	}
	 pos = pTblList->GetHeadPosition();
	ProgramListCtrl.DeleteAllItems();
	while(pos)
	{
		pT = (CTable *)(pTblList->GetNext(pos));
		if(pT->GetTableID()== PROGRAM_MAP_INFORMATION)
		{
			pPmtS = (PMTSection * )(pT->GetSection()->GetSectionData());
			ProgramNumber = pPmtS->program_number_hi*256 + pPmtS->program_number_low;
			if((NULL == pSdt)||(0 == get_service_name(pSdt, ProgramNumber, ServiceName)))
			{
				ServiceName.Format("Program %d", ProgramNumber);;
			}
			VideoPid = get_video_pid(pT);
			ServiceName.AppendFormat(" vid : %d ",VideoPid);
			if(VideoPid  !=  INVALID_PID )
			{
				//GetDlgItem(IDC_LIST_OF_PROGRAMS);
				ProgramListCtrl.InsertItem(ProgramIndex,(LPCTSTR) ServiceName);
				ProgramListCtrl.SetItemData(ProgramIndex,(DWORD_PTR)VideoPid);
				
				ProgramIndex++;
			}
		}
	}
}
Ejemplo n.º 2
0
int DVBTune::open_tuner()
{
#ifdef HAVE_DVB
	char frontend_path[BCTEXTLEN];
	char demux_path[BCTEXTLEN];
	char dvr_path[BCTEXTLEN];

	sprintf(frontend_path, "/dev/dvb/adapter%d/frontend%d",
		get_device_number(),
		0);
	sprintf(demux_path, "/dev/dvb/adapter%d/demux%d",
		get_device_number(),
		0);
	sprintf(dvr_path, "/dev/dvb/adapter%d/dvr%d",
		get_device_number(),
		0);








	if((frontend_fd = ::open(frontend_path, O_RDWR)) < 0) 
	{
		fprintf(stderr, 
			"DVBTune::open_tuner %s: %s\n",
			frontend_path,
			strerror(errno));
		return 1;
	}


// Open transport stream for reading
	if((dvr_fd = ::open(dvr_path, O_RDONLY)) < 0)
	{
		fprintf(stderr, 
			"DVBTune::open_tuner %s: %s\n",
			dvr_path,
			strerror(errno));
		return 1;
	}

	struct dvb_frontend_parameters frontend_param;
	bzero(&frontend_param, sizeof(frontend_param));

// Set frequency
	int index = CLIP(TunerServer::get_channel(), 2, 69);
	int table = TunerServer::get_table();
	switch(table)
	{
		case NETTUNE_AIR:
			frontend_param.frequency = ntsc_dvb[index] * 1000000;
			frontend_param.u.vsb.modulation = VSB_8;
			break;
		case NETTUNE_CABLE:
    		frontend_param.frequency = catv_dvb[index] * 1000000;
    		frontend_param.u.vsb.modulation = QAM_AUTO;
			break;
	}


	if(ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_param) < 0)
	{
		fprintf(stderr, 
			"DVBTune::open_tuner FE_SET_FRONTEND frequency=%d: %s",
			frontend_param.frequency,
			strerror(errno));
		return 1;
	}

	if((video_fd = ::open(demux_path, O_RDWR)) < 0)
	{
		fprintf(stderr,
			"DVBTune::open_tuner %s for video: %s\n",
			demux_path,
			strerror(errno));
		return 1;
	}

//printf("DVBTune::open_tuner 0x%x 0x%x\n", get_audio_pid(), get_video_pid());
// Setting exactly one PES filter to 0x2000 dumps the entire
// transport stream.
	struct dmx_pes_filter_params pesfilter;
	if(!get_video_pid() && !get_audio_pid())
	{
		pesfilter.pid = 0x2000;
		pesfilter.input = DMX_IN_FRONTEND;
		pesfilter.output = DMX_OUT_TS_TAP;
		pesfilter.pes_type = DMX_PES_OTHER;
		pesfilter.flags = DMX_IMMEDIATE_START;
		if(ioctl(video_fd, DMX_SET_PES_FILTER, &pesfilter) < 0)
		{
			fprintf(stderr, 
				"DVBTune::open_tuner DMX_SET_PES_FILTER for raw: %s\n",	
				strerror(errno));
			return 1;
		}
	}


	if(get_video_pid())
	{


    	pesfilter.pid = get_video_pid();
    	pesfilter.input = DMX_IN_FRONTEND;
    	pesfilter.output = DMX_OUT_TS_TAP;
    	pesfilter.pes_type = DMX_PES_VIDEO;
    	pesfilter.flags = DMX_IMMEDIATE_START;
		if(ioctl(video_fd, DMX_SET_PES_FILTER, &pesfilter) < 0)
		{
			fprintf(stderr, 
				"DVBTune::open_tuner DMX_SET_PES_FILTER for video: %s\n",	
				strerror(errno));
			return 1;
		}
	}

	if(get_audio_pid())
	{
		if((audio_fd = ::open(demux_path, O_RDWR)) < 0)
		{
			fprintf(stderr,
				"DVBTune::open_tuner %s for audio: %s\n",
				demux_path,
				strerror(errno));
			return 1;
		}

    	pesfilter.pid = get_audio_pid();
    	pesfilter.input = DMX_IN_FRONTEND;
    	pesfilter.output = DMX_OUT_TS_TAP;
    	pesfilter.pes_type = DMX_PES_AUDIO;
    	pesfilter.flags = DMX_IMMEDIATE_START;
		if(ioctl(audio_fd, DMX_SET_PES_FILTER, &pesfilter) < 0)
		{
			fprintf(stderr, 
				"DVBTune::open_tuner DMX_SET_PES_FILTER for audio: %s\n",	
				strerror(errno));
			return 1;
		}
	}






	if(!thread)
	{
		thread = new DVBTuneThread(this);
		thread->start();
	}

	if(!status)
	{
		status = new DVBTuneStatus(this);
		status->start();
	}
	return 0;
#endif
	return 1;
}