Esempio n. 1
0
static int encode_pip(struct vidfilt_enc_st *st, struct vidframe *frame)
{
	struct selfview_enc *enc = (struct selfview_enc *)st;
	struct selfview *selfview = enc->selfview;
	int err = 0;

	if (!frame)
		return 0;

	lock_write_get(selfview->lock);
	if (!selfview->frame) {
		struct vidsz sz;

		/* Use size if configured, or else 20% of main window */
		if (selfview_size.w && selfview_size.h) {
			sz = selfview_size;
		}
		else {
			sz.w = frame->size.w / 5;
			sz.h = frame->size.h / 5;
		}

		err = vidframe_alloc(&selfview->frame, VID_FMT_YUV420P, &sz);
	}
	if (!err)
		vidconv(selfview->frame, frame, NULL);
	lock_rel(selfview->lock);

	return err;
}
Esempio n. 2
0
static void destructor(void *arg)
{
	struct selfview *st = arg;

	lock_write_get(st->lock);
	mem_deref(st->frame);
	lock_rel(st->lock);
	mem_deref(st->lock);
}
Esempio n. 3
0
static void tmr_repeat(void *arg)
{
	struct play *play = arg;

	lock_write_get(play->lock);

	play->mb->pos = 0;
	play->eof = false;

	tmr_start(&play->tmr, 1000, tmr_polling, arg);

	lock_rel(play->lock);
}
Esempio n. 4
0
static void destructor(void *arg)
{
	struct selfview *st = arg;

	list_unlink(&st->vf.le);

	mem_deref(st->disp);

	lock_write_get(st->lock);
	mem_deref(st->frame);
	lock_rel(st->lock);
	mem_deref(st->lock);
}
Esempio n. 5
0
static void mix_n_minus_1(struct session *sess, int16_t *dst,
		unsigned long nsamples)
{
	struct le *le;
	int32_t *dstmixv;
	int16_t *dstv = dst;
	int16_t *mixv;
	unsigned active = 0;

	for (le = sessionl.head; le; le = le->next) {
		struct session *msess = le->data;

		if (msess->run_play && msess != sess) {
			mixv = msess->st_play->sampv;
			dstmixv = sess->dstmix;

			lock_write_get(msess->plock);
			if (sess->trev > msess->prev)
				play_process(msess, nsamples);
			for (unsigned n = 0; n < nsamples; n++) {
				*dstmixv = *dstmixv + *mixv;
				++mixv;
				++dstmixv;
			}
			lock_rel(msess->plock);

			++active;
		}
	}

	if (active) {
		dstmixv = sess->dstmix;
		for (unsigned i = 0; i < nsamples; i++) {
			*dstmixv = *dstmixv + *dstv;
			++dstv;
			++dstmixv;
		}

		dstmixv = sess->dstmix;
		for (unsigned i = 0; i < nsamples; i++) {
			if (*dstmixv > SAMPLE_16BIT_MAX)
				*dstmixv = SAMPLE_16BIT_MAX;
			if (*dstmixv < SAMPLE_16BIT_MIN)
				*dstmixv = SAMPLE_16BIT_MIN;
			*dst = *dstmixv;
			*dstmixv = 0;
			++dst;
			++dstmixv;
		}
	}
}
Esempio n. 6
0
void rtcp_sess_tx_rtp(struct rtcp_sess *sess, uint32_t ts, size_t payload_size)
{
	if (!sess)
		return;

	lock_write_get(sess->lock);

	sess->txstat.osent += (uint32_t)payload_size;
	sess->txstat.psent += 1;

	if (sess->txstat.start == 0) {
		sess->txstat.ts_offset = ts;
		sess->txstat.start = time(NULL);
	}

	lock_rel(sess->lock);
}
Esempio n. 7
0
static void destructor(void *arg)
{
	struct play *play = arg;

	list_unlink(&play->le);
	tmr_cancel(&play->tmr);

	lock_write_get(play->lock);
	play->eof = true;
	lock_rel(play->lock);

	mem_deref(play->auplay);
	mem_deref(play->mb);
	mem_deref(play->lock);

	if (play->playp)
		*play->playp = NULL;
}
Esempio n. 8
0
static void tmr_polling(void *arg)
{
	struct play *play = arg;

	lock_write_get(play->lock);

	tmr_start(&play->tmr, 1000, tmr_polling, arg);

	if (play->eof) {
		if (play->repeat > 0)
			play->repeat--;

		if (play->repeat == 0)
			tmr_start(&play->tmr, 1, tmr_stop, arg);
		else
			tmr_start(&play->tmr, SILENCE_DUR, tmr_repeat, arg);
	}

	lock_rel(play->lock);
}
Esempio n. 9
0
void effect_play(struct session *sess, float* const output0,
		float* const output1, unsigned long nframes)
{

	if (!sess->run_play)
		return;

	struct auplay_st *st_play = sess->st_play;

	lock_write_get(sess->plock);
	if (sess->trev > sess->prev)
		play_process(sess, nframes*2);

	sample_move_dS_s16(output0, (char*)st_play->sampv,
			nframes, 4);
	sample_move_dS_s16(output1, (char*)st_play->sampv+2,
			nframes, 4);
	lock_rel(sess->plock);

	ws_meter_process(sess->ch+1, (float*)output0, nframes);
	++sess->trev;
}
Esempio n. 10
0
static int encode_pip(struct vidfilt_st *st, struct vidframe *frame)
{
	struct selfview *sv = (struct selfview *)st;
	int err = 0;

	if (!frame)
		return 0;

	lock_write_get(sv->lock);
	if (!sv->frame) {
		struct vidsz sz;

		sz.w = frame->size.w / 5;
		sz.h = frame->size.h / 5;

		err = vidframe_alloc(&sv->frame, VID_FMT_YUV420P, &sz);
	}
	if (!err)
		vidconv(sv->frame, frame, NULL);
	lock_rel(sv->lock);

	return err;
}
Esempio n. 11
0
/**
 * NOTE: DSP cannot be destroyed inside handler
 */
static bool write_handler(uint8_t *buf, size_t sz, void *arg)
{
	struct play *play = arg;

	lock_write_get(play->lock);

	if (play->eof)
		goto silence;

	if (mbuf_get_left(play->mb) < sz) {
		play->eof = true;
	}
	else {
		(void)mbuf_read_mem(play->mb, buf, sz);
	}

 silence:
	if (play->eof)
		memset(buf, 0, sz);

	lock_rel(play->lock);

	return true;
}