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

📄 scan.c

📁 dvb在linux下搜索电台的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
			} 	ptest->type = FE_QAM;	ptest->param.inversion = caps_inversion;	ptest->param.u.qam.symbol_rate = 6900000;	ptest->param.u.qam.fec_inner = FEC_NONE;	ptest->param.u.qam.modulation = this_qam;		// 20060705 -> fixed	ptest=&test;	memcpy (&frontend_parameters, &ptest->param, sizeof(struct dvb_frontend_parameters));	for (channel=2; channel <= 4; channel++) {		f=36500000 + channel*7000000;		test.type 			= FE_QAM;		test.param.inversion 		= caps_inversion;		test.param.u.qam.modulation 	= this_qam;		test.param.u.qam.symbol_rate 	= 6900000;		test.param.u.qam.fec_inner 	= caps_fec;                test.param.frequency 		= f;		memcpy (&frontend_parameters, &ptest->param, \			sizeof(struct dvb_frontend_parameters));		if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {			dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6900,this_qam);			continue;			}		usleep (1000000);		info("%d: ", frontend_parameters.frequency/1000);		for (cnt=0;cnt<5;cnt++) {			ret = check_frontend(frontend_fd,0);        		if (ret == 1) break;			usleep(100000);			}		if (ret == 0) {	// may be unusual symbolrate = 6875 ?			test.type 			= FE_QAM;			test.param.inversion 		= caps_inversion;			test.param.u.qam.modulation 	= this_qam;			test.param.u.qam.symbol_rate 	= 6875000;			test.param.u.qam.fec_inner 	= caps_fec;           	    	test.param.frequency 		= f;			memcpy (&frontend_parameters, &ptest->param, \				sizeof(struct dvb_frontend_parameters));			if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {				dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6875,this_qam);				continue;				}			usleep (1000000);			for (cnt=0;cnt<5;cnt++) {				ret = check_frontend(frontend_fd,0);        			if (ret == 1) break;				usleep(100000);				}			}				if (ret == 0) {			info("\n");			continue;			}		if (__tune_to_transponder (frontend_fd, ptest,0) < 0)			continue;		t = alloc_transponder(f);		t->type 			= ptest->type;		t->param.inversion 		= ptest->param.inversion;		t->param.u.qam.symbol_rate 	= ptest->param.u.qam.symbol_rate;		t->param.u.qam.fec_inner 	= ptest->param.u.qam.fec_inner;		t->param.u.qam.modulation 	= ptest->param.u.qam.modulation;		info("signal ok (S%dC%sM%s)\n",			t->param.u.qam.symbol_rate/1000,			fec_name[t->param.u.qam.fec_inner],			qam_name[t->param.u.qam.modulation]);		}	for (channel=1; channel <= 10; channel++) {		f=100500000 + channel*7000000;		test.type 			= FE_QAM;		test.param.inversion 		= caps_inversion;		test.param.u.qam.modulation 	= this_qam;		test.param.u.qam.symbol_rate 	= 6900000;		test.param.u.qam.fec_inner 	= caps_fec;                test.param.frequency 		= f;		memcpy (&frontend_parameters, &ptest->param, \			sizeof(struct dvb_frontend_parameters));		if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {			dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6900,this_qam);			continue;			}		usleep (1000000);		info("%d: ", frontend_parameters.frequency/1000);		for (cnt=0;cnt<5;cnt++) {			ret = check_frontend(frontend_fd,0);        		if (ret == 1) break;			usleep(100000);			}		if (ret == 0) {	// may be unusual symbolrate = 6875 ?			test.type 			= FE_QAM;			test.param.inversion 		= caps_inversion;			test.param.u.qam.modulation 	= this_qam;			test.param.u.qam.symbol_rate 	= 6875000;			test.param.u.qam.fec_inner 	= caps_fec;           	    	test.param.frequency 		= f;			memcpy (&frontend_parameters, &ptest->param, \				sizeof(struct dvb_frontend_parameters));			if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {				dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6875,this_qam);				continue;				}			usleep (1000000);			for (cnt=0;cnt<5;cnt++) {				ret = check_frontend(frontend_fd,0);        			if (ret == 1) break;				usleep(100000);				}			}				if (ret == 0) {			info("\n");			continue;			}		if (__tune_to_transponder (frontend_fd, ptest,0) < 0)			continue;		t = alloc_transponder(f);		t->type 			= ptest->type;		t->param.inversion 		= ptest->param.inversion;		t->param.u.qam.symbol_rate 	= ptest->param.u.qam.symbol_rate;		t->param.u.qam.fec_inner 	= ptest->param.u.qam.fec_inner;		t->param.u.qam.modulation 	= ptest->param.u.qam.modulation;		info("signal ok (S%dC%sM%s)\n",			t->param.u.qam.symbol_rate/1000,			fec_name[t->param.u.qam.fec_inner],			qam_name[t->param.u.qam.modulation]);		}	for (channel=1; channel <= 9; channel++) {		f=97000000 + channel*8000000;		test.type 			= FE_QAM;		test.param.inversion 		= caps_inversion;		test.param.u.qam.modulation 	= this_qam;		test.param.u.qam.symbol_rate 	= 6900000;		test.param.u.qam.fec_inner 	= caps_fec;                test.param.frequency 		= f;		memcpy (&frontend_parameters, &ptest->param, \			sizeof(struct dvb_frontend_parameters));		if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {			dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6900,this_qam);			continue;			}		usleep (1000000);		info("%d: ", frontend_parameters.frequency/1000);		for (cnt=0;cnt<5;cnt++) {			ret = check_frontend(frontend_fd,0);        		if (ret == 1) break;			usleep(100000);			}		if (ret == 0) {	// may be unusual symbolrate = 6875 ?			test.type 			= FE_QAM;			test.param.inversion 		= caps_inversion;			test.param.u.qam.modulation 	= this_qam;			test.param.u.qam.symbol_rate 	= 6875000;			test.param.u.qam.fec_inner 	= caps_fec;           	    	test.param.frequency 		= f;			memcpy (&frontend_parameters, &ptest->param, \				sizeof(struct dvb_frontend_parameters));			if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {				dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6875,this_qam);				continue;				}			usleep (1000000);			for (cnt=0;cnt<5;cnt++) {				ret = check_frontend(frontend_fd,0);        			if (ret == 1) break;				usleep(100000);				}			}				if (ret == 0) {			info("\n");			continue;			}		if (__tune_to_transponder (frontend_fd, ptest,0) < 0)			continue;		t = alloc_transponder(f);		t->type 			= ptest->type;		t->param.inversion 		= ptest->param.inversion;		t->param.u.qam.symbol_rate 	= ptest->param.u.qam.symbol_rate;		t->param.u.qam.fec_inner 	= ptest->param.u.qam.fec_inner;		t->param.u.qam.modulation 	= ptest->param.u.qam.modulation;		info("signal ok (S%dC%sM%s)\n",			t->param.u.qam.symbol_rate/1000,			fec_name[t->param.u.qam.fec_inner],			qam_name[t->param.u.qam.modulation]);		}	for (channel=5; channel <= 22; channel++) {		f=142500000 + channel*7000000;		test.type 			= FE_QAM;		test.param.inversion 		= caps_inversion;		test.param.u.qam.modulation 	= this_qam;		test.param.u.qam.symbol_rate 	= 6900000;		test.param.u.qam.fec_inner 	= caps_fec;                test.param.frequency 		= f;		memcpy (&frontend_parameters, &ptest->param, \			sizeof(struct dvb_frontend_parameters));		if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {			dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6900,this_qam);			continue;			}		usleep (1000000);		info("%d: ", frontend_parameters.frequency/1000);		for (cnt=0;cnt<5;cnt++) {			ret = check_frontend(frontend_fd,0);        		if (ret == 1) break;			usleep(100000);			}		if (ret == 0) {	// may be unusual symbolrate = 6875 ?			test.type 			= FE_QAM;			test.param.inversion 		= caps_inversion;			test.param.u.qam.modulation 	= this_qam;			test.param.u.qam.symbol_rate 	= 6875000;			test.param.u.qam.fec_inner 	= caps_fec;           	    	test.param.frequency 		= f;			memcpy (&frontend_parameters, &ptest->param, \				sizeof(struct dvb_frontend_parameters));			if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {				dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6875,this_qam);				continue;				}			usleep (1000000);			for (cnt=0;cnt<5;cnt++) {				ret = check_frontend(frontend_fd,0);        			if (ret == 1) break;				usleep(100000);				}			}				if (ret == 0) {			info("\n");			continue;			}		if (__tune_to_transponder (frontend_fd, ptest,0) < 0)			continue;		t = alloc_transponder(f);		t->type 			= ptest->type;		t->param.inversion 		= ptest->param.inversion;		t->param.u.qam.symbol_rate 	= ptest->param.u.qam.symbol_rate;		t->param.u.qam.fec_inner 	= ptest->param.u.qam.fec_inner;		t->param.u.qam.modulation 	= ptest->param.u.qam.modulation;		info("signal ok (S%dC%sM%s)\n",			t->param.u.qam.symbol_rate/1000,			fec_name[t->param.u.qam.fec_inner],			qam_name[t->param.u.qam.modulation]);		} 	for (channel=21; channel <= 90; channel++) {        /* debug: channel = (346 - 138) / 8; { */		f=138000000 + channel*8000000;		test.type 			= FE_QAM;		test.param.inversion 		= caps_inversion;		test.param.u.qam.modulation 	= this_qam;		test.param.u.qam.symbol_rate 	= 6900000;		test.param.u.qam.fec_inner 	= caps_fec;                test.param.frequency 		= f;		memcpy (&frontend_parameters, &ptest->param, \			sizeof(struct dvb_frontend_parameters));		if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {			dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6900,this_qam);			continue;			}		usleep (1000000);		info("%d: ", frontend_parameters.frequency/1000);		for (cnt=0;cnt<5;cnt++) {			ret = check_frontend(frontend_fd,0);        		if (ret == 1) break;			usleep(100000);			}		if (ret == 0) {	/* may be unusual symbolrate = 6875 ? */			test.type 			= FE_QAM;			test.param.inversion 		= caps_inversion;			test.param.u.qam.modulation 	= this_qam;			test.param.u.qam.symbol_rate 	= 6875000;			test.param.u.qam.fec_inner 	= caps_fec;           	    	test.param.frequency 		= f;			memcpy (&frontend_parameters, &ptest->param, \				sizeof(struct dvb_frontend_parameters));			if (ioctl(frontend_fd, FE_SET_FRONTEND, &frontend_parameters) < 0) {				dprintf(1, "%s:%d: Setting frontend parameters failed f%d sr%d m%d", __FUNCTION__,__LINE__,f,6875,this_qam);				continue;				}			usleep (1000000);			for (cnt=0;cnt<5;cnt++) {				ret = check_frontend(frontend_fd,0);        			if (ret == 1) break;				usleep(100000);				}			}				if (ret == 0) {			info("\n");			continue;			}		if (__tune_to_transponder (frontend_fd, ptest,0) < 0)			continue;		t = alloc_transponder(f);		t->type 			= ptest->type;		t->param.inversion 		= ptest->param.inversion;		t->param.u.qam.symbol_rate 	= ptest->param.u.qam.symbol_rate;		t->param.u.qam.fec_inner 	= ptest->param.u.qam.fec_inner;		t->param.u.qam.modulation 	= ptest->param.u.qam.modulation;		info("signal ok (S%dC%sM%s)\n",			t->param.u.qam.symbol_rate/1000,			fec_name[t->param.u.qam.fec_inner],			qam_name[t->param.u.qam.modulation]);		}	  if (caps_qam == QAM_AUTO) break;	// 20060705	  }	}return tune_to_next_transponder(frontend_fd);}static void scan_tp (void){	struct section_buf s0;	struct section_buf s1;	struct section_buf s2;	struct section_buf s3;	/**	 *  filter timeouts > min repetition rates specified in ETR211	 */	setup_filter (&s0, demux_devname, 0x00, 0x00, 1, 0, 5); /* PAT */	setup_filter (&s1, demux_devname, 0x11, 0x42, 1, 0, 5); /* SDT */	add_filter (&s0);	add_filter (&s1);	if (!current_tp_only || output_format != OUTPUT_PIDS) {		setup_filter (&s2, demux_devname, 0x10, 0x40, 1, 0, 15); /* NIT */		add_filter (&s2);		if (get_other_nits) {			/* get NIT-others			 * Note: There is more than one NIT-other: one per			 * network, separated by the network_id.			 */			setup_filter (&s3, demux_devname, 0x10, 0x41, 1, 1, 15);			add_filter (&s3);		}	}	do {		read_filters ();	} while (!(list_empty(&running_filters) &&		   list_empty(&waiting_filters)));}static void network_scan (int frontend_fd){	if (initial_tune (frontend_fd) < 0) {		error("Sorry - i couldn't get any working frequency/transponder\n Nothing to scan!!\n");		return;	}	do {		scan_tp();	} while (tune_to_next_transponder(frontend_fd) == 0);}static char sat_polarisation (struct transponder *t){	return 'h';}static void dump_lists (void){	struct list_head *p1, *p2;	struct transponder *t;	struct service *s;	int n = 0, i, index = 0;	char sn[20];	list_for_each(p1, &scanned_transponders) {		t = list_entry(p1, struct transponder, list);		list_for_each(p2, &t->services) {			n++;		}	}	info("dumping lists (%d services)\n", n);	list_for_each(p1, &scanned_transponders) {		t = list_entry(p1, struct transponder, list);		if (output_format == OUTPUT_DVBSCAN_TUNING_DATA) {			dvbscan_dump_tuningdata (stdout,				   t->type,				   &t->param,				   index);			index++;			continue;			}					list_for_each(p2, &t->services) {			s = list_entry(p2, struct service, list);			if (!s->service_name) {				/* not in SDT */				snprintf(sn, sizeof(sn), "[%04x]", s->service_id);				s->service_name = strdup(sn);			}			/* ':' is field separator in vdr service lists */			for (i = 0; s->service_name[i]; i++) {				if (s->service_name[i] == ':')					s->service_name[i] = ' ';			}			for (i = 0; s->provider_name && s->provider_name[i]; i++) {				if (s->provider_name[i] == ':')					s->provider_name[i] = ' ';			}			if (s->video_pid && !(serv_select & 1))						// vpid, this is tv				continue; /* no TV services */			if (!s->video_pid &&  (s->audio_num || s->ac3_pid) && !(serv_select & 2))	// no vpid, but apid or ac3pid, this is radio				continue; /* no radio services */			if (!s->video_pid && !(s->audio_num || s->ac3_pid) && !(serv_select & 4))	// no vpid, no apid, no ac3pid, this is service/other				continue; /* no data/other services */			if (s->scrambled && !ca_select)							// caid, this is scrambled tv or radio				continue; /* FTA only */			switch (output_format)			{			  case OUTPUT_VDR:				vdr_dump_service_parameter_set (stdout,						    s->service_name,						    s->provider_name,						    t->type,						    &t->param,						    sat_polarisation(t),						    s->video_pid,						    s->pcr_pid,						    s->audio_pid,						    s->audio_lang,						    s->audio_num,						    s->teletext_pid,						    s->scrambled,						    //FIXME: s->subtitling_p

⌨️ 快捷键说明

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