Пример #1
0
/**
 * Set async I/O polling method. This function can also be called while the
 * program is running.
 *
 * @param method New polling method
 *
 * @return 0 if success, otherwise errorcode
 */
int poll_method_set(enum poll_method method)
{
	struct re *re;
	int err;

	switch (method) {

#ifdef HAVE_POLL
	case METHOD_POLL:
		break;
#endif
#ifdef HAVE_SELECT
	case METHOD_SELECT:
		break;
#endif
#ifdef HAVE_EPOLL
	case METHOD_EPOLL:
		if (!epoll_check())
			return EINVAL;
		break;
#endif
#ifdef HAVE_ACTSCHED
	case METHOD_ACTSCHED:
		break;
#endif
	default:
		DEBUG_WARNING("poll method not supported: '%s'\n",
			      poll_method_name(method));
		return EINVAL;
	}

	re = re_get();
	re->method = method;
	re->update = true;

	DEBUG_INFO("Setting async I/O polling method to `%s'\n",
		   poll_method_name(re->method));

	err = fd_setsize(DEFAULT_MAXFDS);
	if (err)
		return err;

	err = poll_init(re);
	if (err)
		return err;

	return rebuild_fds(re);
}
Пример #2
0
int audio_encoder_set(struct audio *a, const struct aucodec *ac,
			  int pt_tx, const char *params, struct user_extra_data_t *user_data)
{
	struct autx *tx;
	int err = 0;
	bool reset;

	if (!a || !ac)
		return EINVAL;

	tx = &a->tx;

	reset = !aucodec_equal(ac, tx->ac);

	if (ac != tx->ac) {
		re_printf("Set audio encoder: %s %uHz %dch\n", ac->name, get_srate(ac), ac->ch);

		/* Audio source must be stopped first */
		if (reset) {
			tx->ausrc = mem_deref(tx->ausrc);
		}

		tx->is_g722 = (0 == str_casecmp(ac->name, "G722"));
		tx->enc = mem_deref(tx->enc);
		tx->ac = ac;
	}

	if (ac->encupdh) {
		struct auenc_param prm;

		prm.ptime = tx->ptime;

		err = ac->encupdh(&tx->enc, ac, &prm, params);
		if (err) {
			DEBUG_WARNING("alloc encoder: %m\n", err);
			return err;
		}
	}

	stream_set_srate(a->strm, get_srate(ac), get_srate(ac));
	stream_update_encoder(a->strm, pt_tx);

	if (!tx->ausrc) {
		err |= audio_start(a, user_data);
	}

	return err;
}
Пример #3
0
void stream_send_fir(struct stream *s, bool pli)
{
	int err;

	if (!s)
		return;

	if (pli)
		err = rtcp_send_pli(s->rtp, s->ssrc_rx);
	else
		err = rtcp_send_fir(s->rtp, rtp_sess_ssrc(s->rtp));

	if (err) {
		DEBUG_WARNING("Send FIR: %m\n", err);
	}
}
Пример #4
0
/**
 * Get one frame from the jitter buffer
 *
 * @param jb   Jitter buffer
 * @param hdr  Returned RTP Header
 * @param mem  Pointer to memory object storage - referenced on success
 *
 * @return 0 if success, otherwise errorcode
 */
int jbuf_get(struct jbuf *jb, struct rtp_header *hdr, void **mem)
{
	struct frame *f;

	if (!jb || !hdr || !mem)
		return EINVAL;

	STAT_INC(n_get);

	if (jb->n <= jb->min || !jb->framel.head) {
		DEBUG_INFO("not enough buffer frames - wait.. (n=%u min=%u)\n",
			   jb->n, jb->min);
		STAT_INC(n_underflow);
		return ENOENT;
	}

	/* When we get one frame F[i], check that the next frame F[i+1]
	   is present and have a seq no. of seq[i] + 1 !
	   if not, we should consider that packet lost */

	f = jb->framel.head->data;

#if JBUF_STAT
	/* Check timestamp of previously played frame */
	if (jb->seq_get) {
		const int16_t seq_diff = f->hdr.seq - jb->seq_get;
		if (seq_less(f->hdr.seq, jb->seq_get)) {
			DEBUG_WARNING("get: seq=%u too late\n", f->hdr.seq);
		}
		else if (seq_diff > 1) {
			STAT_ADD(n_lost, 1);
			DEBUG_INFO("get: n_lost: diff=%d,seq=%u,seq_get=%u\n",
				   seq_diff, f->hdr.seq, jb->seq_get);
		}
	}

	/* Update sequence number for 'get' */
	jb->seq_get = f->hdr.seq;
#endif

	*hdr = f->hdr;
	*mem = mem_ref(f->mem);

	frame_deref(jb, f);

	return 0;
}
Пример #5
0
static int mod_srtp_init(void)
{
	err_status_t err;

	err = srtp_init();
	if (err_status_ok != err) {
		DEBUG_WARNING("srtp_init() failed (%H)\n",
			      errstatus_print, err);
		return ENOSYS;
	}

	menc_register(&menc_srtp_opt);
	menc_register(&menc_srtp_mand);
	menc_register(&menc_srtp_mandf);

	return 0;
}
jboolean JNICALL ScriptMethodsServerUINamespace::clearSuiDataSourceContainer(JNIEnv * env, jobject self, jint pageId, jstring dataSourceContainer)
{
	JavaStringParam localDataSource(dataSourceContainer);

	ServerUIPage * const p = ServerUIManager::getPage(pageId);
	if(!p)
	{
		DEBUG_WARNING(true, ("SUI: Could not find page %d, cannot clear datasource", pageId));
		return JNI_FALSE;
	}

	std::string ds;
	JavaLibrary::convert(localDataSource, ds);

	p->clearDataSourceContainer(ds);
	return JNI_TRUE;
}
Пример #7
0
int audio_decoder_set(struct audio *a, const struct aucodec *ac,
		      int pt_rx, const char *params)
{
	struct aurx *rx;
	bool reset = false;
	int err = 0;

	if (!a || !ac)
		return EINVAL;

	rx = &a->rx;

	reset = !aucodec_equal(ac, rx->ac);

	if (ac != rx->ac) {

		(void)re_fprintf(stderr, "Set audio decoder: %s %uHz %dch\n",
				 ac->name, get_srate(ac), ac->ch);

		rx->pt = pt_rx;
		rx->ac = ac;
		rx->dec = mem_deref(rx->dec);
	}

	if (ac->decupdh) {
		err = ac->decupdh(&rx->dec, ac, params);
		if (err) {
			DEBUG_WARNING("alloc decoder: %m\n", err);
			return err;
		}
	}

	stream_set_srate(a->strm, get_srate(ac), get_srate(ac));

	if (reset) {

		rx->auplay = mem_deref(rx->auplay);

		/* Reset audio filter chain */
		list_flush(&a->filtl);

		err |= audio_start(a);
	}

	return err;
}
Пример #8
0
/**
 * Read a block of memory from a memory buffer
 *
 * @param mb   Memory buffer
 * @param buf  Buffer to read data to
 * @param size Size of buffer
 *
 * @return 0 if success, otherwise errorcode
 */
int mbuf_read_mem(struct mbuf *mb, uint8_t *buf, size_t size)
{
	if (!mb || !buf)
		return EINVAL;

	if (size > mbuf_get_left(mb)) {
		DEBUG_WARNING("tried to read beyond mbuf end (%u > %u)\n",
			      size, mbuf_get_left(mb));
		return EOVERFLOW;
	}

	memcpy(buf, mb->buf + mb->pos, size);

	mb->pos += size;

	return 0;
}
Пример #9
0
const char* inet_ntop(int af, const void *src, char *dst, size_t size)
{
	switch (af) {

	case AF_INET:
		return inet_ntop4(src, dst, size);

#ifdef HAVE_INET6
	case AF_INET6:
		return inet_ntop6(src, dst, size);
#endif

	default:
		DEBUG_WARNING("inet_ntop: unknown address family %d\n", af);
		return NULL;
	}
}
Пример #10
0
/**
 * Call the application event handler
 *
 * @param re     Poll state
 * @param fd     File descriptor
 * @param flags  Event flags
 */
static void fd_handler(struct re *re, int fd, int flags)
{
	const uint64_t tick = tmr_jiffies();
	uint32_t diff;

	DEBUG_INFO("event on fd=%d (flags=0x%02x)...\n", fd, flags);

	re->fhs[fd].fh(flags, re->fhs[fd].arg);

	diff = (uint32_t)(tmr_jiffies() - tick);

	if (diff > MAX_BLOCKING) {
		DEBUG_WARNING("long async blocking: %u>%u ms (h=%p arg=%p)\n",
			      diff, MAX_BLOCKING,
			      re->fhs[fd].fh, re->fhs[fd].arg);
	}
}
Пример #11
0
static void decode_param(const struct pl *name, const struct pl *val,
			 void *arg)
{
	struct aucodec_st *st = arg;
	int err;

	if (0 == pl_strcasecmp(name, "bitrate")) {
		st->bitrate = pl_u32(val) * 1000;
	}
	else if (0 == pl_strcasecmp(name, "frame-size")) {
		st->frame_size = pl_u32(val);

		if (st->frame_size & 0x1) {
			DEBUG_WARNING("frame-size is NOT even: %u\n",
				      st->frame_size);
		}
	}
	else if (0 == pl_strcasecmp(name, "low-overhead")) {
		struct pl fs, bpfv;
		uint32_t i;

		st->low_overhead = true;

		err = re_regex(val->p, val->l, "[0-9]+/[0-9,]+", &fs, &bpfv);
		if (err)
			return;

		st->frame_size = pl_u32(&fs);

		for (i=0; i<ARRAY_SIZE(st->bpfv) && bpfv.l > 0; i++) {
			struct pl bpf, co;

			co.l = 0;
			if (re_regex(bpfv.p, bpfv.l, "[0-9]+[,]*", &bpf, &co))
				break;

			pl_advance(&bpfv, bpf.l + co.l);

			st->bpfv[i] = pl_u32(&bpf);
		}
		st->bpfn = i;
	}
	else {
		DEBUG_NOTICE("unknown param: %r = %r\n", name, val);
	}
}
Пример #12
0
void rtcp_sess_rx_rtp(struct rtcp_sess *sess, uint16_t seq, uint32_t ts,
		      uint32_t ssrc, size_t payload_size,
		      const struct sa *peer)
{
	struct rtp_member *mbr;

	if (!sess)
		return;

	mbr = get_member(sess, ssrc);
	if (!mbr) {
		DEBUG_NOTICE("could not add member: 0x%08x\n", ssrc);
		return;
	}

	if (!mbr->s) {
		mbr->s = mem_zalloc(sizeof(*mbr->s), NULL);
		if (!mbr->s) {
			DEBUG_NOTICE("could not add sender: 0x%08x\n", ssrc);
			return;
		}

		/* first packet - init sequence number */
		source_init_seq(mbr->s, seq);
		mbr->s->max_seq = seq - 1;
		/* probation not used */
		sa_cpy(&mbr->s->rtp_peer, peer);
		++sess->senderc;
	}

	if (!source_update_seq(mbr->s, seq)) {
		DEBUG_WARNING("rtp_update_seq() returned 0\n");
	}

	if (sess->srate_rx) {

		uint32_t ts_arrive;

		/* Convert from wall-clock time to timestamp units */
		ts_arrive = (uint32_t)(tmr_jiffies()) * sess->srate_rx / 1000;

		source_calc_jitter(mbr->s, ts, ts_arrive);
	}

	mbr->s->rtp_rx_bytes += payload_size;
}
Пример #13
0
static int play_alloc(struct auplay_st **stp, struct auplay *ap,
		      struct auplay_prm *prm, const char *device,
		      auplay_write_h *wh, void *arg)
{
	struct auplay_st *st;
	int err;
	int i;

	(void)device;

	if (play_dev_count < 1) {
		DEBUG_WARNING("no winwave play devices\n");
		return ENODEV;
	}

	st = mem_zalloc(sizeof(*st), auplay_destructor);
	if (!st)
		return ENOMEM;

	st->ap  = mem_ref(ap);
	st->wh  = wh;
	st->arg = arg;
	if (prm) {
		prm->fmt = AUFMT_S16LE;
		st->prm = *prm;
	}

	err = write_stream_open(st);
	if (err)
		goto out;

	/* The write runs at 100ms intervals
	 * prepare enough buffers to suite its needs
	 */
	for (i = 0; i < 5; i++)
		dsp_write(st);

 out:
	if (err)
		mem_deref(st);
	else
		*stp = st;

	return err;
}
Пример #14
0
void CTcpSock::RunL()
{
	DEBUG_INFO("CTcpSock RunL (%p) iStatus=%d ts=%p\n", this,
		   iStatus.Int(), ts);

	/* This happens after calling cancel functions in socket */
	if (iStatus == KErrCancel || iStatus == KErrAbort) {
		iStatus = KErrNone;
		return;
	}
	else if (iStatus != KErrNone) {
		DEBUG_WARNING("RunL received iStatus %d\n", iStatus.Int());
	}

	/* Incoming CONNECT */
	DEBUG_INFO("CTcpSock RunL (%p) Incoming CONNECT\n", this);
	ts->tcp_conn_handler();
}
Пример #15
0
static void tcp_conn_handler(const struct sa *peer, void *arg)
{
	struct ice_lcand *lcand = arg;
	int err;

#if 0
	trice_printf(lcand->icem,
		    "[local=%H] incoming TCP-connect from %J\n",
		    trice_cand_print, lcand, peer);
#endif

	err = trice_conn_alloc(&lcand->icem->connl, lcand->icem,
			     lcand->attr.compid, false,
			     &lcand->attr.addr, peer, lcand->ts, lcand->layer,
			     tcpconn_frame_handler, lcand);
	if (err) {
		DEBUG_WARNING("ice_conn_alloc error (%m)\n", err);
	}
}
Пример #16
0
static void add_wave_in(struct ausrc_st *st)
{
	MMRESULT   res;
	struct dspbuf *db = &st->bufs[st->pos];
	WAVEHDR *wh = &db->wh;

	wh->lpData = (LPSTR)db->mb->buf;
	wh->dwBufferLength = db->mb->size;
	wh->dwBytesRecorded = 0;
	wh->dwFlags = 0;
	wh->dwUser = (DWORD_PTR) db->mb;
	waveInPrepareHeader(st->wavein, wh, sizeof(WAVEHDR));
	res = waveInAddBuffer(st->wavein, wh, sizeof(WAVEHDR));
	if (res != MMSYSERR_NOERROR)
		DEBUG_WARNING("add_wave_in: waveOutWrite fail: %08x\n", res);
	INC_RPOS(st->pos);

	st->inuse++;
}
void ServerIntangibleObjectTemplate::_Ingredient::getIngredientsMax(SimpleIngredient &data, int index, bool versionOk) const
{
	const ServerIntangibleObjectTemplate::_Ingredient * base = NULL;
	if (m_baseData != NULL)
	{
		base = dynamic_cast<const ServerIntangibleObjectTemplate::_Ingredient *>(m_baseData);
	}

	if (!m_ingredientsLoaded)
	{
		if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == NULL)
		{
			DEBUG_WARNING(true, ("Returning default value for missing parameter ingredients in template %s", DataResource::getName()));
			return ;
		}
		else
		{
			DEBUG_FATAL(base == NULL, ("Template parameter ingredients has not been defined in template %s!", DataResource::getName()));
			base->getIngredientsMax(data, index, versionOk);
			return;
		}
	}

	if (m_ingredientsAppend && base != NULL)
	{
		int baseCount = base->getIngredientsCount();
		if (index < baseCount)
			{
				base->getIngredientsMax(data, index, versionOk);
				return;
			}
		index -= baseCount;
	}

	DEBUG_FATAL(index < 0 || static_cast<size_t>(index) >= m_ingredients.size(), ("template param index out of range"));
	const ObjectTemplate * structTemplate = (*m_ingredients[index]).getValue();
	NOT_NULL(structTemplate);
	const _SimpleIngredient *param = dynamic_cast<const _SimpleIngredient *>(structTemplate);
	NOT_NULL(param);
	data.name = param->getName(versionOk);
	data.ingredient = param->getIngredient(versionOk);
	data.count = param->getCountMax(versionOk);
}	// ServerIntangibleObjectTemplate::_Ingredient::getIngredientsMax
Пример #18
0
/**
 * Debug all allocated memory objects
 */
void mem_debug(void)
{
#if MEM_DEBUG
	uint32_t n;

	mem_lock();
	n = list_count(&meml);
	mem_unlock();

	if (!n)
		return;

	DEBUG_WARNING("Memory leaks (%u):\n", n);

	mem_lock();
	(void)list_apply(&meml, true, debug_handler, NULL);
	mem_unlock();
#endif
}
Пример #19
0
void CUdpSocket::RunL()
{
	DEBUG_INFO("RunL iStatus=%d\n", iStatus.Int());

	/* This happens after calling cancel functions in socket */
	if (iStatus == KErrCancel || iStatus == KErrAbort) {
		iStatus = KErrNone;
	}
	else if (iStatus == KErrGeneral) {
		/* cache error code */
		us->cerr = ECONNREFUSED;
	}
	else if (iStatus != KErrNone) {
		DEBUG_WARNING("RunL received iStatus %d\n", iStatus.Int());
	}
	else if (iBufRx.Length()) {
		us->recv();
	}
}
Пример #20
0
static void *read_thread(void *arg)
{
	struct vidsrc_st *st = arg;

	while (st->run) {
		ssize_t n;

		n = read(st->fd, st->mb->buf, st->mb->size);
		if ((ssize_t)st->mb->size != n) {
			DEBUG_WARNING("video read: %d -> %d bytes\n",
				      st->mb->size, n);
			continue;
		}

		call_frame_handler(st, st->mb->buf);
	}

	return NULL;
}
void ServerManufactureSchematicObjectTemplate::getAttributesMax(SchematicAttribute &data, int index) const
{
	const ServerManufactureSchematicObjectTemplate * base = NULL;
	if (m_baseData != NULL)
	{
		base = dynamic_cast<const ServerManufactureSchematicObjectTemplate *>(m_baseData);
	}

	if (!m_attributesLoaded)
	{
		if (ms_allowDefaultTemplateParams && /*!m_versionOk &&*/ base == NULL)
		{
			DEBUG_WARNING(true, ("Returning default value for missing parameter attributes in template %s", DataResource::getName()));
			return ;
		}
		else
		{
			DEBUG_FATAL(base == NULL, ("Template parameter attributes has not been defined in template %s!", DataResource::getName()));
			base->getAttributesMax(data, index);
			return;
		}
	}

	if (m_attributesAppend && base != NULL)
	{
		int baseCount = base->getAttributesCount();
		if (index < baseCount)
			{
				base->getAttributesMax(data, index);
				return;
			}
		index -= baseCount;
	}

	DEBUG_FATAL(index < 0 || static_cast<size_t>(index) >= m_attributes.size(), ("template param index out of range"));
	const ObjectTemplate * structTemplate = (*m_attributes[index]).getValue();
	NOT_NULL(structTemplate);
	const _SchematicAttribute *param = dynamic_cast<const _SchematicAttribute *>(structTemplate);
	NOT_NULL(param);
	data.name = param->getName(m_versionOk);
	data.value = param->getValueMax(m_versionOk);
}	// ServerManufactureSchematicObjectTemplate::getAttributesMax
Пример #22
0
/**
 * Check List and Timer State Updates
 */
void icem_checklist_update(struct icem *icem)
{
	struct le *le;
	bool compl;
	int err = 0;

	compl = iscompleted(icem);
	if (!compl)
		return;

	/*
	 * If there is not a pair in the valid list for each component of the
	 * media stream, the state of the check list is set to Failed.
	 */
	for (le = icem->compl.head; le; le = le->next) {

		struct icem_comp *comp = le->data;

		if (!icem_candpair_find_compid(&icem->validl, comp->id)) {
			DEBUG_WARNING("{%s.%u} no valid candidate pair"
				      " (validlist=%u)\n",
				      icem->name, comp->id,
				      list_count(&icem->validl));
			err = ENOENT;
			break;
		}

		concluding_ice(comp);

		if (!comp->cp_sel)
			continue;

		icem_comp_keepalive(comp, true);
	}

	icem->state = err ? CHECKLIST_FAILED : CHECKLIST_COMPLETED;

	if (icem->chkh) {
		icem->chkh(err, icem->ice->lrole == ROLE_CONTROLLING,
			   icem->arg);
	}
}
Пример #23
0
static int read_stream_open(struct ausrc_st *st)
{
	MMRESULT err;
	WAVEFORMATEX  wfmt;
	int i;

	/* Open an audio INPUT stream. */
	st->wavein = NULL;
	st->pos = 0;
	st->rdy = false;
	st->stop = false;

	for (i = 0; i < READ_BUFFERS; i++) {
		memset(&st->bufs[i].wh, 0, sizeof(WAVEHDR));
		st->bufs[i].mb = mbuf_alloc(2 * st->prm.frame_size);
	}

	wfmt.wFormatTag      = WAVE_FORMAT_PCM;
	wfmt.nChannels       = st->prm.ch;
	wfmt.nSamplesPerSec  = st->prm.srate;
	wfmt.wBitsPerSample  = 16;
	wfmt.nBlockAlign     = (st->prm.ch * wfmt.wBitsPerSample) / 8;
	wfmt.nAvgBytesPerSec = wfmt.nSamplesPerSec * wfmt.nBlockAlign;
	wfmt.cbSize          = 0;
	err = waveInOpen(&st->wavein,
			  WAVE_MAPPER,
			  &wfmt,
			  (DWORD_PTR) waveInCallback,
			  (DWORD_PTR) st,
			  CALLBACK_FUNCTION | WAVE_FORMAT_DIRECT);
	if (err != MMSYSERR_NOERROR) {
		DEBUG_WARNING("waveInOpen: failed %d\n", err);
		return EINVAL;
	}
	/* Prepare enough IN buffers to suite at least 50ms of data */
	for (i = 0; i < READ_BUFFERS; i++)
		add_wave_in(st);

	waveInStart(st->wavein);

	return 0;
}
Пример #24
0
int trice_alloc(struct trice **icemp, const struct trice_conf *conf,
	       bool controlling,
	       const char *lufrag, const char *lpwd)
{
	struct trice *icem;
	int err = 0;

	if (!icemp || !lufrag || !lpwd)
		return EINVAL;

	if (str_len(lufrag) < 4 || str_len(lpwd) < 22) {
		DEBUG_WARNING("alloc: lufrag/lpwd is too short\n");
		return EINVAL;
	}

	icem = mem_zalloc(sizeof(*icem), trice_destructor);
	if (!icem)
		return ENOMEM;

	icem->conf = conf ? *conf : conf_default;
	list_init(&icem->lcandl);
	list_init(&icem->rcandl);
	list_init(&icem->checkl);
	list_init(&icem->validl);

	icem->controlling = controlling;
	icem->tiebrk = rand_u64();


	err |= str_dup(&icem->lufrag, lufrag);
	err |= str_dup(&icem->lpwd, lpwd);
	if (err)
		goto out;

 out:
	if (err)
		mem_deref(icem);
	else
		*icemp = icem;

	return err;
}
Пример #25
0
/**
 * Listen to a SIP Session socket for incoming connections
 *
 * @param sockp    Pointer to allocated SIP Session socket
 * @param sip      SIP Stack instance
 * @param htsize   Hashtable size
 * @param connh    Connection handler
 * @param arg      Handler argument
 *
 * @return 0 if success, otherwise errorcode
 */
int sipsess_listen(struct sipsess_sock **sockp, struct sip *sip,
		   int htsize, sipsess_conn_h *connh, void *arg)
{
	struct sipsess_sock *sock;
	int err;

	DEBUG_WARNING("re.sipsess.listen.sipsess_listen()\n");
	if (!sockp || !sip || !htsize)
		return EINVAL;

	sock = mem_zalloc(sizeof(*sock), destructor);
	if (!sock)
		return ENOMEM;

	err = sip_listen(&sock->lsnr_resp, sip, false, response_handler, sock);
	if (err)
		goto out;

	err = sip_listen(&sock->lsnr_req, sip, true, request_handler, sock);
	if (err)
		goto out;

	err = hash_alloc(&sock->ht_sess, htsize);
	if (err)
		goto out;

	err = hash_alloc(&sock->ht_ack, htsize);
	if (err)
		goto out;

	sock->sip   = sip;
	sock->connh = connh ? connh : internal_connect_handler;
	sock->arg   = connh ? arg : sock;

 out:
	if (err)
		mem_deref(sock);
	else
		*sockp = sock;

	return err;
}
Пример #26
0
void stream_start_keepalive(struct stream *s)
{
	const char *rtpkeep;

	if (!s)
		return;

	rtpkeep = ua_param(call_get_ua(s->call), "rtpkeep");

	s->rtpkeep = mem_deref(s->rtpkeep);

	if (rtpkeep && sdp_media_rformat(s->sdp, NULL)) {
		int err;
		err = rtpkeep_alloc(&s->rtpkeep, rtpkeep,
				    IPPROTO_UDP, s->rtp, s->sdp);
		if (err) {
			DEBUG_WARNING("rtpkeep_alloc failed: %m\n", err);
		}
	}
}
Пример #27
0
/**
 * Decode SDP session attributes
 *
 * @param ice   ICE Session
 * @param name  Name of the SDP attribute
 * @param value Value of the SDP attribute (optional)
 *
 * @return 0 if success, otherwise errorcode
 */
int ice_sdp_decode(struct ice *ice, const char *name, const char *value)
{
	if (!ice)
		return EINVAL;

	if (0 == str_casecmp(name, ice_attr_lite)) {
		if (ICE_MODE_LITE == ice->lmode) {
			DEBUG_WARNING("we are lite, peer is also lite!\n");
			return EPROTO;
		}
		ice->rmode = ICE_MODE_LITE;
		ice->lrole = ROLE_CONTROLLING;
	}
	else if (0 == str_casecmp(name, ice_attr_ufrag))
		return ufrag_decode(ice, value);
	else if (0 == str_casecmp(name, ice_attr_pwd))
		return pwd_decode(ice, value);

	return 0;
}
Пример #28
0
static void sniff_stun(struct mbuf *mb)
{
	struct stun_msg *msg;
	size_t pos;
	int err;

	pos = mb->pos;
	err = stun_msg_decode(&msg, mb, NULL);
	if (err) {
		DEBUG_WARNING("could not decode STUN packet (%m)\n", err);
		return;
	}

	stun_msg_attr_apply(msg, stun_attr_handler, 0);
	(void)re_printf("\n");

	mem_deref(msg);

	mb->pos = pos;
}
const StringId ServerIntangibleObjectTemplate::_SchematicAttribute::getName(bool versionOk, bool testData) const
{
#ifdef _DEBUG
StringId testDataValue = DefaultStringId;
#else
UNREF(testData);
#endif

	const ServerIntangibleObjectTemplate::_SchematicAttribute * base = NULL;
	if (m_baseData != NULL)
	{
		base = dynamic_cast<const ServerIntangibleObjectTemplate::_SchematicAttribute *>(m_baseData);
#ifdef _DEBUG
		if (testData && base != NULL)
			testDataValue = base->getName(true);
#endif
	}

	if (!m_name.isLoaded())
	{
		if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == NULL)
		{
			DEBUG_WARNING(true, ("Returning default value for missing parameter name in template %s", DataResource::getName()));
			return DefaultStringId;
		}
		else
		{
			DEBUG_FATAL(base == NULL, ("Template parameter name has not been defined in template %s!", DataResource::getName()));
			return base->getName(versionOk);
		}
	}

	const StringId value = m_name.getValue();
#ifdef _DEBUG
	if (testData && base != NULL)
	{
	}
#endif

	return value;
}	// ServerIntangibleObjectTemplate::_SchematicAttribute::getName
const std::string & ServerIntangibleObjectTemplate::_Ingredient::getSkillCommand(bool versionOk, bool testData) const
{
#ifdef _DEBUG
std::string testDataValue = DefaultString;
#else
UNREF(testData);
#endif

	const ServerIntangibleObjectTemplate::_Ingredient * base = NULL;
	if (m_baseData != NULL)
	{
		base = dynamic_cast<const ServerIntangibleObjectTemplate::_Ingredient *>(m_baseData);
#ifdef _DEBUG
		if (testData && base != NULL)
			testDataValue = base->getSkillCommand(true);
#endif
	}

	if (!m_skillCommand.isLoaded())
	{
		if (ms_allowDefaultTemplateParams && /*!versionOk &&*/ base == NULL)
		{
			DEBUG_WARNING(true, ("Returning default value for missing parameter skillCommand in template %s", DataResource::getName()));
			return DefaultString;
		}
		else
		{
			DEBUG_FATAL(base == NULL, ("Template parameter skillCommand has not been defined in template %s!", DataResource::getName()));
			return base->getSkillCommand(versionOk);
		}
	}

	const std::string & value = m_skillCommand.getValue();
#ifdef _DEBUG
	if (testData && base != NULL)
	{
	}
#endif

	return value;
}	// ServerIntangibleObjectTemplate::_Ingredient::getSkillCommand