Ejemplo n.º 1
0
static inline void build_style_frame(anim_frame *frame, JSObject *target) {

	#define ADD_PROP(const_name, prop)								\
		_ADD_PROP(const_name, prop, false);							\
		_ADD_PROP(const_name, d ## prop, true);

	#define _ADD_PROP(const_name, prop, _is_delta) do {				\
		jsval value;												\
		JS_GetProperty(cx, target, #prop, &value);					\
		double prop_val;											\
		JS_ValueToNumber(cx, value, &prop_val);						\
		if (!isnan(prop_val)) {										\
			style_prop *p = anim_frame_add_style_prop(frame);		\
			p->name = const_name;									\
			p->is_delta = _is_delta;								\
			p->target = prop_val;									\
		}															\
	} while(0)
	JSContext *cx = get_js_context();
	ADD_PROP(X, x);
	ADD_PROP(Y, y);
	ADD_PROP(WIDTH, width);
	ADD_PROP(HEIGHT, height);
	ADD_PROP(R, r);
	ADD_PROP(ANCHOR_X, anchorX);
	ADD_PROP(ANCHOR_Y, anchorY);
	ADD_PROP(OPACITY, opacity);
	ADD_PROP(SCALE, scale);

	frame->type = STYLE_FRAME;
}
Ejemplo n.º 2
0
int dvb_tune(int aid, transponder * tp)
{
	int bclear, bpol, iProp = 0;
	adapter *ad = get_adapter(aid);
	int fd_frontend = ad->fe;

	int freq = tp->freq;
	struct dtv_property p_cmd[20];
	struct dtv_properties p =
	{ .num = 0, .props = p_cmd };
	struct dvb_frontend_event ev;

	struct dtv_property p_clear[] =
	{
	{ .cmd = DTV_CLEAR }, };

	struct dtv_properties cmdseq_clear =
	{ .num = 1, .props = p_clear };

	memset(p_cmd, 0, sizeof(p_cmd));
	bclear = getTick();

	if ((ioctl(fd_frontend, FE_SET_PROPERTY, &cmdseq_clear)) == -1)
	{
		LOG("FE_SET_PROPERTY DTV_CLEAR failed for fd %d: %s", fd_frontend,
				strerror(errno));
		//        return -1;
	}

	switch (tp->sys)
	{
	case SYS_DVBS:
	case SYS_DVBS2:

		bpol = getTick();
		freq = setup_switch(fd_frontend, tp);
		if (freq < MIN_FRQ_DVBS || freq > MAX_FRQ_DVBS)
			LOG_AND_RETURN(-404, "Frequency %d is not within range ", freq)

		ADD_PROP(DTV_SYMBOL_RATE, tp->sr)
		ADD_PROP(DTV_INNER_FEC, tp->fec)
		ADD_PROP(DTV_PILOT, tp->plts)
		ADD_PROP(DTV_ROLLOFF, tp->ro)
		ADD_PROP(DTV_STREAM_ID, tp->plp)

		LOG(
				"tuning to %d(%d) pol: %s (%d) sr:%d fec:%s delsys:%s mod:%s rolloff:%s pilot:%s, ts clear=%d, ts pol=%d",
				tp->freq, freq, get_pol(tp->pol), tp->pol, tp->sr,
				fe_fec[tp->fec], fe_delsys[tp->sys], fe_modulation[tp->mtype],
				fe_rolloff[tp->ro], fe_pilot[tp->plts], bclear, bpol)
		break;

	case SYS_DVBT:
	case SYS_DVBT2:

		if (tp->freq < MIN_FRQ_DVBT || tp->freq > MAX_FRQ_DVBT)
			LOG_AND_RETURN(-404, "Frequency %d is not within range ", tp->freq)

		freq = freq * 1000;
		ADD_PROP(DTV_BANDWIDTH_HZ, tp->bw)
		ADD_PROP(DTV_CODE_RATE_HP, tp->fec)
		ADD_PROP(DTV_CODE_RATE_LP, tp->fec)
		ADD_PROP(DTV_GUARD_INTERVAL, tp->gi)
		ADD_PROP(DTV_TRANSMISSION_MODE, tp->tmode)
		ADD_PROP(DTV_HIERARCHY, HIERARCHY_AUTO)
		ADD_PROP(DTV_STREAM_ID, tp->plp & 0xFF)

		LOG(
				"tuning to %d delsys: %s bw:%d inversion:%s mod:%s fec:%s guard:%s transmission: %s, ts clear = %d",
				freq, fe_delsys[tp->sys], tp->bw, fe_specinv[tp->inversion],
				fe_modulation[tp->mtype], fe_fec[tp->fec], fe_gi[tp->gi],
				fe_tmode[tp->tmode], bclear)
		break;

	case SYS_DVBC2:
	case SYS_DVBC_ANNEX_A:

		if (tp->freq < MIN_FRQ_DVBC || tp->freq > MAX_FRQ_DVBC)
			LOG_AND_RETURN(-404, "Frequency %d is not within range ", tp->freq)

		freq = freq * 1000;
		ADD_PROP(DTV_SYMBOL_RATE, tp->sr)
		ADD_PROP(DTV_STREAM_ID, ((tp->ds & 0xFF) << 8) | (tp->plp & 0xFF))
		// valid for DD DVB-C2 devices

		LOG("tuning to %d sr:%d specinv:%s delsys:%s mod:%s ts clear =%d", freq,
				tp->sr, fe_specinv[tp->inversion], fe_delsys[tp->sys],
				fe_modulation[tp->mtype], bclear)
		break;

	case SYS_ATSC:
	case SYS_DVBC_ANNEX_B:

		if (tp->freq < MIN_FRQ_DVBC || tp->freq > MAX_FRQ_DVBC)
			LOG_AND_RETURN(-404, "Frequency %d is not within range ", tp->freq)

		if (tp->mtype == 0)
			tp->mtype = QAM_AUTO;

		freq = freq * 1000;

		LOG("tuning to %d delsys:%s mod:%s specinv:%s ts clear=%d", freq,
				fe_delsys[tp->sys], fe_modulation[tp->mtype],
				fe_specinv[tp->inversion], bclear)

		break;

	case SYS_ISDBT:

		if (tp->freq < MIN_FRQ_DVBT || tp->freq > MAX_FRQ_DVBT)
			LOG_AND_RETURN(-404, "Frequency %d is not within range ", tp->freq)

		freq = freq * 1000;
		ADD_PROP(DTV_ISDBT_PARTIAL_RECEPTION, 0)
		ADD_PROP(DTV_BANDWIDTH_HZ, tp->bw)
//	    ADD_PROP(DTV_ISDBT_LAYERA_SEGMENT_COUNT,   1);  
//	    ADD_PROP(DTV_ISDBT_LAYER_ENABLED,   1); 

		LOG("tuning to %d delsys: %s bw:%d inversion:%s , ts clear = %d", freq,
				fe_delsys[tp->sys], tp->bw, fe_specinv[tp->inversion], bclear)
		;

		break;
	default:
		LOG("tuninng to unknown delsys: %s freq %s ts clear = %d", freq,
				fe_delsys[tp->sys], bclear)
		break;
	}

	ADD_PROP(DTV_FREQUENCY, freq)
	ADD_PROP(DTV_INVERSION, tp->inversion)
	ADD_PROP(DTV_MODULATION, tp->mtype);
	ADD_PROP(DTV_DELIVERY_SYSTEM, tp->sys);
	ADD_PROP(DTV_TUNE, 0)

	p.num = iProp;
	/* discard stale QPSK events */
	while (1)
	{
		if (ioctl(fd_frontend, FE_GET_EVENT, &ev) == -1)
			break;
	}

	if ((ioctl(fd_frontend, FE_SET_PROPERTY, &p)) == -1)
		if (ioctl(fd_frontend, FE_SET_PROPERTY, &p) == -1)
		{
			perror("FE_SET_PROPERTY TUNE failed");
			LOG("set property failed");
			return -404;
		}

	return 0;
}

int dvb_set_pid(adapter *a, uint16_t i_pid)
{
	char buf[100];
	int fd;
	int hw, ad;

	hw = a->pa;
	ad = a->fn;
	if (i_pid > 8192)
		LOG_AND_RETURN(-1, "pid %d > 8192 for /dev/dvb/adapter%d/demux%d",
				i_pid, hw, ad);

	sprintf(buf, "/dev/dvb/adapter%d/demux%d", hw, ad);
	if ((fd = open(buf, O_RDWR | O_NONBLOCK)) < 0)
	{
		LOG("Could not open demux device /dev/dvb/adapter%d/demux%d: %s ", hw,
				ad, strerror (errno));
		return -1;
	}

	struct dmx_pes_filter_params s_filter_params;

	memset(&s_filter_params, 0, sizeof(s_filter_params));
	s_filter_params.pid = i_pid;
	s_filter_params.input = DMX_IN_FRONTEND;
	s_filter_params.output = DMX_OUT_TS_TAP;
	s_filter_params.flags = DMX_IMMEDIATE_START;
	s_filter_params.pes_type = DMX_PES_OTHER;

	if (ioctl(fd, DMX_SET_PES_FILTER, &s_filter_params) < 0)
	{
		int pids[MAX_PIDS];
		int ep;
		ep = get_enabled_pids(a, (int *) pids, MAX_PIDS);
		LOG("failed setting filter on %d (%s), enabled pids %d", i_pid,
				strerror (errno), ep);
		return -1;
	}

	LOG("setting filter on PID %d for fd %d", i_pid, fd);

	return fd;
}