Exemple #1
0
int pack_item(tlv_t * item, void * outbuf, uint32_t * outsize)
{
	int ret = 0;

	if ((NULL == item) || (NULL == outbuf) || (NULL == outsize)) {
		return -1;
	}

	switch (item->type) {
		case TLV_TYPE_INT8:
		case TLV_TYPE_UINT8:
			ret = pack_int8((uint8_t *)(item->value), outbuf, outsize);
			break;
		case TLV_TYPE_INT16:
		case TLV_TYPE_UINT16:
			ret = pack_int16((uint16_t *)(item->value), outbuf, outsize);
			break;
		case TLV_TYPE_INT32:
		case TLV_TYPE_UINT32:
			ret = pack_int32((uint32_t *)(item->value), outbuf, outsize);
			break;
		case TLV_TYPE_BYTES:
			ret = pack_bytes(item->value, item->length, outbuf, outsize);
			break;
		case TLV_TYPE_MSG:
			ret = msg_pack((message_t *)(item->value), outbuf, outsize);
			break;
		default:
			ret = -1;
			break;
	}

	return ret;
}
Exemple #2
0
/*
 * Build the output buffer and push/synch to an external recipient,
 * taking mapping function, alpha population functions, and timing-
 * related metadata.
 */
static void ch_step(struct rwstat_ch* ch)
{
	struct rwstat_ch_priv* chp = ch->priv;

	struct arcan_event outev = {
		.category = EVENT_EXTERNAL,
		.ext.kind = EVENT_EXTERNAL_FRAMESTATUS,
		.ext.framestatus.framenumber = ch->priv->cnt_local,
		.ext.framestatus.pts = ch->priv->cnt_total,
	};

	size_t ntw = chp->base * chp->base;
	ch->event(ch, &outev);

/*
 * Notify about the packing mode active for this frame. This is
 * needed for the parent to be able to determine what each byte
 * corresponds to.
 */
	if (chp->status_dirty){
		outev.ext.kind = EVENT_EXTERNAL_STREAMINFO;
		outev.ext.streaminf.streamid = 0;
		outev.ext.streaminf.datakind = 0;
		outev.ext.streaminf.langid[0] = 'a' + chp->pack;
		outev.ext.streaminf.langid[1] = 'a' + chp->map;
		outev.ext.streaminf.langid[2] = 'a' + chp->pack_sz;
		chp->status_dirty = false;
		ch->event(ch, &outev);
	}

	if ( 1 == (chp->clock & (RW_CLK_SLIDE)) )
		rebuild_hgram(chp);

	if (chp->amode == RW_ALPHA_ENTBASE)
		update_entalpha(chp, chp->ent_base);

	else if (chp->amode == RW_ALPHA_PTN)
		update_ptnalpha(chp);

	for (size_t i = 0; i < chp->buf_sz; i += chp->pack_sz)
		pack_bytes(chp, &chp->buf[i], i / chp->pack_sz);

	chp->cont->addr->vpts = ch->priv->cnt_total;
	arcan_shmif_signal(chp->cont, SHMIF_SIGVID);
	chp->cnt_local = chp->cnt_total;

/* non-sparse mappings require an output flush */
	if (chp->map == MAP_TUPLE || chp->map == MAP_TUPLE_ACC){
		shmif_pixel val = SHMIF_RGBA(0x00, 0x00, 0x00, 0xff);
		for (size_t i = 0; i < ntw; i++)
			chp->cont->vidp[i] = val;
	}
}

static void ch_event(struct rwstat_ch* ch, arcan_event* ev)
{
	arcan_shmif_enqueue(ch->priv->cont, ev);
}
Exemple #3
0
int unpack_item(uint16_t type, uint16_t id, void * inbuf, uint16_t length, tlv_t * outtlv)
{
	uint32_t outsize = 0;
	int ret = 0;
	void * value = NULL;
	message_t * newmsg = NULL;

	value = malloc(length);
	if (NULL == value) {
		return -1;
	}

	switch (id) {
		case TLV_TYPE_INT8:
		case TLV_TYPE_UINT8:
			outsize = length;
			ret = pack_int8((uint8_t *)inbuf, (uint8_t *)value, &outsize);
			break;
		case TLV_TYPE_INT16:
		case TLV_TYPE_UINT16:
			outsize = length;
			ret = unpack_int16((uint16_t *)inbuf, (uint16_t *)value, &outsize);
			break;
		case TLV_TYPE_INT32:
		case TLV_TYPE_UINT32:
			outsize = length;
			ret = unpack_int32((uint32_t *)inbuf, (uint32_t *)value, &outsize);
			break;
		case TLV_TYPE_BYTES:
			outsize = length;
			ret = pack_bytes(inbuf, length, value, &outsize);
			break;
		case TLV_TYPE_MSG:
			newmsg = msg_unpack((uint8_t *)inbuf, length);
			if (NULL == newmsg) {
				free(value);
				return -1;
			}
			memcpy(value, newmsg, MSG_SIZE(newmsg));
			free(newmsg);
			break;
		default:
			free(value);
			return -1;
	}

	if (0 != ret) {
		free(value);
	}

	outtlv->id = id;
	outtlv->type = type;
	outtlv->length = length;
	outtlv->value = value;

	return ret;
}
Exemple #4
0
int 
unpack_value(tlv_type_t type, uint16_t id, void *inbuf, uint16_t length, tlv_t *out_tlv) {
  int b = 0;
  uint32_t out_sz = 0;
  void *value = NULL;

  if (NULL == inbuf || NULL == out_tlv) {
    return -1;
  }

  value = malloc(length);
  if (NULL == value) {
    return -1;
  }

  switch(type) {
  case TLV_TYPE_INT8:
  case TLV_TYPE_UINT8:
    b = pack_int8((uint8_t*)inbuf, (uint8_t*)value, &out_sz);
    break;

  case TLV_TYPE_INT16:
  case TLV_TYPE_UINT16:
    b = unpack_int16((uint16_t*)inbuf, (uint16_t*)value, &out_sz);
    break;

  case TLV_TYPE_INT32:
  case TLV_TYPE_UINT32:
    b = unpack_int32((uint32_t*)inbuf, (uint32_t*)value, &out_sz);
    break;

  case TLV_TYPE_BYTES:
    out_sz = length;
    b = pack_bytes(inbuf, length, value, &out_sz);
    break;

  default:
    b = -1;
    break;
  }

  if (b != 0) {
    free(value);
    return -1;
  }

  out_tlv->id = id;
  out_tlv->type = type;
  out_tlv->length = length;
  out_tlv->value = value;

  return b;
}
Exemple #5
0
int 
pack_value (tlv_t *tlv, void *outbuf, uint32_t *out_sz) {
  if (NULL == tlv || NULL == outbuf || NULL == out_sz) {
    return -1;
  }

  int b = 0;

  switch (tlv->type) {

  case TLV_TYPE_INT8:
  case TLV_TYPE_UINT8:
    b = pack_int8((uint8_t*)(tlv->value), outbuf, out_sz);
    break;

  case TLV_TYPE_INT16:
  case TLV_TYPE_UINT16:
    b = pack_int16((uint16_t*)(tlv->value), outbuf, out_sz);
    break;

  case TLV_TYPE_INT32:
  case TLV_TYPE_UINT32:
    b = pack_int32((uint32_t*)(tlv->value), outbuf, out_sz);
    break;

  case TLV_TYPE_BYTES:
    b = pack_bytes(tlv->value, tlv->length, outbuf, out_sz);
    break;

  default:
    b = -1;
    break;
  }

  return b;
}
Exemple #6
0
int unpack_item(tlv_type_t type, uint16_t id, void * inbuf, uint16_t length, tlv_t * outtlv)
{
	uint32_t outsize = 0;
	int ret = 0;
	void * value = NULL;
	message_t * newmsg = NULL;

	if ((NULL == inbuf) || (NULL == outtlv)) {
		return -1;
	}

	value = malloc(length);
	if (NULL == value) {
		return -1;
	}

	switch (type) {
		case TLV_TYPE_INT8:
		case TLV_TYPE_UINT8:
			outsize = length;
			ret = pack_int8((uint8_t *)inbuf, (uint8_t *)value, &outsize);
			break;

		case TLV_TYPE_INT16:
		case TLV_TYPE_UINT16:
			outsize = length;
			ret = unpack_int16((uint16_t *)inbuf, (uint16_t *)value, &outsize);
			break;

		case TLV_TYPE_INT32:
		case TLV_TYPE_UINT32:
			outsize = length;
			ret = unpack_int32((uint32_t *)inbuf, (uint32_t *)value, &outsize);
			break;

		case TLV_TYPE_BYTES:
			outsize = length;
			ret = pack_bytes(inbuf, length, value, &outsize);
			break;

		case TLV_TYPE_MSG:
			newmsg = msg_unpack((uint8_t *)inbuf, length);
			if (NULL == newmsg) {
				ret = -1;
				break;
			}

			free(value);
			value = (void *)newmsg;
			ret = 0;
			break;

		default:
			ret = -1;
	}

	if (0 != ret) {
		free(value);
		goto exit;
	}

	outtlv->id = id;
	outtlv->type = type;
	outtlv->length = length;
	outtlv->value = value;

exit:
	return ret;
}