Example #1
0
bool cPluginMcli::TunerSatelitePositionLookup(tuner_pool_t *tp, int pos) const
{
	if((tp->type != FE_QPSK) && (tp->type != FE_DVBS2)) {
		return true; // if not DVB-S or DVB-S2 return true
	}
	if(pos == NO_SAT_POS) {
		return true;
	}

	nc_lock_list ();
	netceiver_info_list_t *nc_list = nc_get_list ();
	satellite_list_t *satlist=NULL;
	for (int n = 0; n < nc_list->nci_num; n++) {
		netceiver_info_t *nci = nc_list->nci + n;
		int l=strlen(tp->uuid)-5;
		if(strncmp(nci->uuid, tp->uuid, l)) {
			continue;
		}
		satlist=TunerFindSatList(nci, tp->SatListName);
		if(satlist) {
			break;
		}
	}
	bool ret;
	if(satlist == NULL) {
                printf("Mcli::%s: No Satlist found \n", __FUNCTION__);
		ret = false;
	} else {
		ret=SatelitePositionLookup(satlist, pos);
		if (!ret) {
			printf("Mcli::%s: Pos %d not found in Satlist \n", __FUNCTION__, pos);
		}		
	}
	nc_unlock_list ();
	return ret;
}
Example #2
0
void find_netcv_adapter(adapter **a)
{
	int i, k, n, na;
	netceiver_info_list_t *nc_list;
	adapter *ad;

	// find 1st free adapter
	for (na = 0; na < MAX_ADAPTERS; na++)
		if (!a[na] || (a[na]->pa == -1 && a[na]->fn == -1)) break;

	/* call recv_init of libmcli to initialize the NetCeiver API */
	if(recv_init("vlan4", 23000))
		LOGL(0, "Netceiver init failed");
 
	fprintf(stderr, "REEL: Search for %d Netceivers... ", opts.netcv_count);
	n = 0;
	do
	{
		usleep(500000);
		fprintf(stderr, "####");
		nc_list = nc_get_list();
	} while (nc_list->nci_num < opts.netcv_count && n++ < 20);
	nc_lock_list ();
	fprintf(stderr, "\n");

	// loop trough list of found netceivers and ad them to list of adapters
	for (n = 0; n < nc_list->nci_num; n++) {
		netceiver_info_t *nci = nc_list->nci + n;
		fprintf (stderr, "Found NetCeiver: %s \n", nci->uuid);
			for (i = 0; i < nci->tuner_num; i++) {
				// TODO: implement disable (low prio)

				if (na >= MAX_ADAPTERS) break;
				if (!a[na]) a[na] = malloc1(sizeof(adapter));

				fprintf (stderr, "  Tuner: %s, Type %d\n", nci->tuner[i].fe_info.name, nci->tuner[i].fe_info.type);

				ad = a[na];
				ad->pa = 0;
				ad->fn = 0;
				sn[na].want_tune = 0;
				sn[na].want_commit = 0;
				sn[na].ncv_rec = NULL;

				/* initialize signal status info */
				ad->strength = 0;
				ad->max_strength = 0xff;
				ad->status = 0;
				ad->snr = 0;
				ad->max_snr = 0xff;
				ad->ber = 0;

				/* register callback functions in adapter structure */
				ad->open = (Open_device) netcv_open_device;
				ad->set_pid = (Set_pid) netcv_set_pid;
				ad->del_filters = (Del_filters) netcv_del_pid;
				ad->commit = (Adapter_commit) netcv_commit;
				ad->tune = (Tune) netcv_tune;
				ad->delsys = (Dvb_delsys) netcv_delsys;
				ad->post_init = (Adapter_commit) NULL;
				ad->close = (Adapter_commit) netcv_close;

				/* register delivery system type */
				for (k = 0; k < 10; k++) ad->sys[k] = 0;
				switch(nci->tuner[i].fe_info.type)
				{
				case FE_DVBS2:
					ad->sys[0] = ad->tp.sys = SYS_DVBS2;
					ad->sys[1] = SYS_DVBS;
					break;

				case FE_QPSK:
					ad->sys[0] = ad->tp.sys = SYS_DVBS;
					break;

				case FE_QAM:
					ad->sys[0] = ad->tp.sys = SYS_DVBC_ANNEX_A;
					break;

				case FE_OFDM:
					//ad->sys[0] = SYS_DVBT; // DVB-T not yet implemented...
					break;
				}

				na++; // increase number of tuner count
			}
	}
	nc_unlock_list(); // netceivers appearing after this will be recognized by libmcli but will not made available to minisatip

	for (; na < MAX_ADAPTERS; na++)
		if (a[na])
			a[na]->pa = a[na]->fn = -1;
}
Example #3
0
void cPluginMcli::Action (void)
{
	netceiver_info_list_t *nc_list = nc_get_list ();
//	printf ("Looking for netceivers out there....\n");
	bool channel_switch_ok = false;

#define NOTIFY_CAM_CHANGE 1
#ifdef NOTIFY_CAM_CHANGE
    int cam_stats[CAM_POOL_MAX] = { 0 };
    char menu_strings[CAM_POOL_MAX][MAX_MENU_STR_LEN];
    bool first_run = true;

    for (int i = 0; i < CAM_POOL_MAX; i++)
        menu_strings[i][0] = '\0';
#endif
    /** lets inform vdr and its plugins if TunerChange event happened */
	bool netCVChanged;

	while (Running ()) {
		netCVChanged = false;
		Lock ();
		if(!InitMcli()) {
			usleep (250 * 1000);
			continue;
		}
		nc_lock_list ();
		time_t now = time (NULL);
		bool tpa = false;

		for (int n = 0; n < nc_list->nci_num; n++) {
			netceiver_info_t *nci = nc_list->nci + n;

			//printf("cPluginMcli::Action: NCI Cam_Num: %d\n", nci->cam_num);

			if ((now - nci->lastseen) > MCLI_DEVICE_TIMEOUT) {
				if(CAMPoolDel(nci->uuid)) {
					printf  ("Mcli::%s: Remove CAMs from NetCeiver: [%s]\n", __FUNCTION__, nci->uuid);
					netCVChanged = true;
				}
			} else {
				int cpa = CAMPoolAdd(nci);
				if(cpa==1) {
					printf ("Mcli::%s: Add CAMs from NetCeiver: [%s] -> %d\n", __FUNCTION__, nci->uuid, cpa);
					netCVChanged = true;
				}
			}

                        if (netCVChanged) {
				for(int j = 0; j < nci->cam_num; j++) {

					const char *camstate;
					const char *cammode;

					switch(nci->cam[j].status) {
						case DVBCA_CAMSTATE_MISSING: 
							camstate="MISSING"; break;
						case DVBCA_CAMSTATE_INITIALISING:
							camstate="INIT"; break;
						case DVBCA_CAMSTATE_READY:
							camstate="READY"; break;
					}
					switch(nci->cam[j].flags) {
						case CA_SINGLE:
							cammode="CA_SINGLE"; break;
						case CA_MULTI_SID:
							cammode="CA_MULTI_SID"; break;
						case CA_MULTI_TRANSPONDER:
							cammode="CA_MULTI_TRANSPONDER"; break;
					}

					if (nci->cam[j].status != DVBCA_CAMSTATE_MISSING) {
						printf("Mcli::%s: Slot:%d CamModule '%s' State:%s Mode:%s\n", __FUNCTION__, j, nci->cam[j].menu_string, camstate, cammode);
					} else {
						printf("Mcli::%s: Slot:%d CamModule State:%s\n", __FUNCTION__, j, camstate);
					}
				}
			}



#if NOTIFY_CAM_CHANGE
            if (n == 0) {
                for(int j = 0; j < nci->cam_num && j < CAM_POOL_MAX; j++) {
                    if (nci->cam[j].status != cam_stats[j]) {
                        char buf[64];
                        if (nci->cam[j].status) {
                            if(nci->cam[j].status == 2 && !first_run) {
                                snprintf(buf, 64, tr("Module '%s' ready"), nci->cam[j].menu_string);
                                Skins.QueueMessage(mtInfo, buf);
                            }
                            cam_stats[j] = nci->cam[j].status;
                            strncpy(menu_strings[j], nci->cam[j].menu_string, MAX_MENU_STR_LEN);
                        } else if (nci->cam[j].status == 0) {
                            cam_stats[j] = nci->cam[j].status;
                            if (!first_run) {
                                snprintf(buf, 64, tr("Module '%s' removed"), (char*)menu_strings[j]);
                                Skins.QueueMessage(mtInfo, buf);
                            }
                            menu_strings[j][0] = '\0';
                        }
                    }
                }
                first_run = false;
            }
#endif

			for (int i = 0; i < nci->tuner_num; i++) {
				tuner_pool_t *t = TunerFindByUUID (nci->tuner[i].uuid);
				if (((now - nci->lastseen) > MCLI_DEVICE_TIMEOUT) || (nci->tuner[i].preference < 0) || !strlen (nci->tuner[i].uuid)) {
					if (t) {
						int pos=TunerPoolDel(t);
						printf  ("Mcli::%s: Remove Tuner %s [%s] @ %d\n", __FUNCTION__, nci->tuner[i].fe_info.name, nci->tuner[i].uuid, pos);
						//isyslog ("cPluginMcli::Action: Remove Tuner %s [%s] @ %d", nci->tuner[i].fe_info.name, nci->tuner[i].uuid, pos);
						netCVChanged = true;
					}
					continue;
				}
				if (!t) {
					tpa=TunerPoolAdd(nci->tuner+i);
					printf ("Mcli::%s: Add Tuner: %s [%s], Type %d @ %d\n", __FUNCTION__, nci->tuner[i].fe_info.name, nci->tuner[i].uuid, nci->tuner[i].fe_info.type, tpa);
					//isyslog ("cPluginMcli::Action: Add Tuner: %s [%s], Type %d @ %d", nci->tuner[i].fe_info.name, nci->tuner[i].uuid, nci->tuner[i].fe_info.type, tpa);
					netCVChanged = true;
				}
			}
		}
		nc_unlock_list ();
		Unlock ();
		UpdateDevices();

		if (netCVChanged) {
			//RC: disabled, see mantis #995
			//cPluginManager::CallAllServices("NetCeiver changed");
		}
        
//TB: reelvdr itself tunes if the first tuner appears, don't do it twice
#if 1 //ndef REELVDR
		if (tpa) {
			if (!channel_switch_ok) {	// the first tuner that was found, so make VDR retune to the channel it wants...
				cChannel *ch = Channels.GetByNumber (cDevice::CurrentChannel ());
				if (ch) {
					printf("Mcli::%s: cDevice::PrimaryDevice (%p)\n", __FUNCTION__, cDevice::PrimaryDevice ());
					channel_switch_ok = cDevice::PrimaryDevice ()->SwitchChannel (ch, true);
				}
			}
		} else {
			channel_switch_ok = 0;
		}
#endif

#ifdef TEMP_DISABLE_DEVICE
		TempDisableDevices();
#endif
		usleep (250 * 1000);
	}
}
Example #4
0
bool cPluginMcli::Service (const char *Id, void *Data)
{
	//printf ("Mcli::%s: \"%s\"\n", __FUNCTION__, Id);

	mclituner_info_t *infos = (mclituner_info_t *) Data;

	if (Id && strcmp (Id, "GetTunerInfo") == 0) {
		int j=0;
		time_t now = time (NULL);
		netceiver_info_list_t *nc_list = nc_get_list ();
		nc_lock_list ();
		for (int n = 0; n < nc_list->nci_num; n++) {
			netceiver_info_t *nci = nc_list->nci + n;
			if ((now - nci->lastseen) > MCLI_DEVICE_TIMEOUT) {
				continue;
			}
			for (int i = 0; i < nci->tuner_num && j < MAX_TUNERS_IN_MENU; i++) {
				strcpy (infos->name[j], nci->tuner[i].fe_info.name);
				infos->type[j] = nci->tuner[i].fe_info.type;
				infos->preference[j++] = nci->tuner[i].preference;
				printf("Mcli::%s: Tuner: %s\n", __FUNCTION__, nci->tuner[i].fe_info.name);
			}
		}
		nc_unlock_list ();
		return true;
	} else if (Id && strcmp (Id, "Reinit") == 0) {
		if (Data && strlen ((char *) Data) && (strncmp ((char *) Data, "eth", 3) || strncmp ((char *) Data, "br", 2))) {
			strncpy (m_cmd.iface, (char *) Data, IFNAMSIZ - 1);
		}
		reconfigure ();
		return true;
	} else if (Id && strcmp (Id, "Set tuner count") == 0) {
		if (Data) {
			  mcli_tuner_count_t *tuner_count = (mcli_tuner_count_t*)Data;
			int count;

			count = tuner_count->dvb_c;
			if (count < 0) count = MCLI_MAX_DEVICES;
			//SetupParse("DVB-C", itoa(count));
			m_cmd.tuner_type_limit[FE_QAM] = count;
			/* save settings to .conf*/
			SetupStore("DVB-C", count);

			count = tuner_count->dvb_t;
			if (count < 0) count = MCLI_MAX_DEVICES;
			//SetupParse("DVB-T", itoa(count));
			m_cmd.tuner_type_limit[FE_OFDM] = count;
			/* save settings to .conf*/
			SetupStore("DVB-T", count);

			count = tuner_count->dvb_s;
			if (count < 0) count = MCLI_MAX_DEVICES;
			//SetupParse("DVB-S", itoa(count));
			m_cmd.tuner_type_limit[FE_QPSK] = count;
			/* save settings to .conf*/
			SetupStore("DVB-S", count);

			count = tuner_count->dvb_s2;
			if (count < 0) count = MCLI_MAX_DEVICES;
			//SetupParse("DVB-S2", itoa(count));
			m_cmd.tuner_type_limit[FE_DVBS2] = count;
			/* save settings to .conf*/
			SetupStore("DVB-S2", count);
		}
		return true;
	} // set tuner count
	else if (Id && strcmp (Id, "Get tuner count") == 0) {
		if (Data) {
			mcli_tuner_count_t *tuner_count = (mcli_tuner_count_t*)Data;

			tuner_count->dvb_c = TunerCountByType(FE_QAM);
			tuner_count->dvb_t = TunerCountByType(FE_OFDM);
			tuner_count->dvb_s = TunerCountByType(FE_QPSK);
			tuner_count->dvb_s2 = TunerCountByType((fe_type_t)FE_DVBS2);
		}
		return true;
	}
	// Handle custom service requests from other plugins
	return false;
}