Пример #1
0
void ms_MULAWdecoder_process(MSMULAWDecoder *r)
{
	MSFifo *fi,*fo;
	int inlen,outlen;
	gchar *s,*d;
	int i;
	/* process output fifos, but there is only one for this class of filter*/
	
	/* this is the simplest process function design:
	the filter declares a r_mingran of MULAW_DECODER_RMAXGRAN, so the mediastreamer's
	scheduler will call the process function each time there is MULAW_DECODER_RMAXGRAN
	bytes to read in the input fifo. If there is more, then it will call it several
	time in order to the fifo to be completetly processed.
	This is very simple, but not very efficient because of the multiple call function
	of MSFilterProcessFunc that may happen.
	The MSAlawEncoder implements another design; see it.
	*/
	
	fi=r->f_inputs[0];
	fo=r->f_outputs[0];
	
 	inlen=ms_fifo_get_read_ptr(fi,MULAW_DECODER_RMAXGRAN,(void**)&s);
	if (s==NULL) g_error("ms_MULAWdecoder_process: internal error.");
 	outlen=ms_fifo_get_write_ptr(fo,MULAW_DECODER_WMAXGRAN,(void**)&d);
 	if (d!=NULL)
 	{
 		for(i=0;i<MULAW_DECODER_RMAXGRAN;i++)
 		{
 			*((gint16*)d)=ulaw_to_s16( (unsigned char) s[i]);
 			d+=2;
 		}
 	}
 	else g_warning("MSMULAWDecoder: Discarding samples !!");
}
Пример #2
0
void ms_rtp_send_process(MSRtpSend *r)
{
	MSFifo *fi;
	MSQueue *qi;
	MSSync *sync= r->sync;
	int gran=ms_sync_get_samples_per_tick(sync);
	guint32 ts;
	void *s;
	guint skip;
	guint32 synctime=sync->time;
	
	g_return_if_fail(gran>0);
	if (r->rtpsession==NULL) return;

	ms_filter_lock(MS_FILTER(r));
	skip=r->delay!=0;
	if (skip) r->delay--;
	/* process output fifo and output queue*/
	fi=r->f_inputs[0];
	if (fi!=NULL)
	{
		ts=get_new_timestamp(r,synctime);
		/* try to read r->packet_size bytes and send them in a rtp packet*/
		ms_fifo_get_read_ptr(fi,r->packet_size,&s);
		if (!skip){
			rtp_session_send_with_ts(r->rtpsession,s,r->packet_size,ts);
			ms_trace("len=%i, ts=%i ",r->packet_size,ts);
		}
	}
	qi=r->q_inputs[0];
	if (qi!=NULL)
	{
		MSMessage *msg;
		/* read a MSMessage and send it through the network*/
		while ( (msg=ms_queue_get(qi))!=NULL){
			ts=get_new_timestamp(r,synctime);
			if (!skip) {
				/*g_message("Sending packet with ts=%u",ts);*/
				rtp_session_send_with_ts(r->rtpsession,msg->data,msg->size,ts);
				
			}
			ms_message_destroy(msg);
		}
	}
	ms_filter_unlock(MS_FILTER(r));
}
Пример #3
0
void ms_ilbc_encoder_process(MSILBCEncoder *r)
{
	MSFifo *fi;
	MSQueue *qo;
	MSMessage *m;
	void *src=NULL;
	float speech[ILBC_MAX_SAMPLES_PER_FRAME];
	
	/* process output fifos, but there is only one for this class of filter*/
	
	qo=r->q_outputs[0];
	fi=r->f_inputs[0];
	ms_fifo_get_read_ptr(fi,r->samples_per_frame*2,&src);
	if (src==NULL) {
		g_warning( "src=%p\n", src);
		return;
	}
	m=ms_message_new(r->bytes_per_compressed_frame);

	ilbc_read_16bit_samples((gint16*)src, speech, r->samples_per_frame);
	iLBC_encode((unsigned char *)m->data, speech, &r->ilbc_enc);
	ms_queue_put(qo,m);
}