--- Begin Message ---
I've been experimenting with Linphone 1.1pre2 a little bit - conecting
with Liknsys/Sipura ATA and Asterisk.
1. ATA get's confused by 101 response - I've changed that to 180 it it
works perfectly.
2. I wanted to be able to send multiple voice frames in single RTP
packet (to lower RTP overhead) - e.g. single 60ms RTP packet containing
2 iLBC 30ms frames.
I've added new fields to MSRtpSend to support that, and also moved the
bytes_per_compressed_frame from ILBC to MSFilter - so that RTPSend can
calculate payload size also for dynamic codec like iLBC.
Framing is currently fixed to 2, but this should be quite easy to make
it configurable.
Waclaw Sierek
[EMAIL PROTECTED]
diff -ur org/linphone-1.1.0pre2/exosip/udp.c tmp/linphone-1.1.0pre2/exosip/udp.c
--- org/linphone-1.1.0pre2/exosip/udp.c 2005-07-25 18:43:23.000000000 +0200
+++ tmp/linphone-1.1.0pre2/exosip/udp.c 2005-08-12 10:28:29.000000000 +0200
@@ -802,7 +802,7 @@
ADD_ELEMENT(eXosip.j_calls, jc);
- i = _eXosip_build_response_default(&answer, NULL, 101, evt->sip);
+ i = _eXosip_build_response_default(&answer, NULL, 180, evt->sip);
if (i!=0)
{
OSIP_TRACE (osip_trace
@@ -1068,7 +1068,7 @@
eXosip_notify_init(&jn, evt->sip);
_eXosip_notify_set_refresh_interval(jn, evt->sip);
- i = _eXosip_build_response_default(&answer, NULL, 101, evt->sip);
+ i = _eXosip_build_response_default(&answer, NULL, 180, evt->sip);
if (i!=0)
{
OSIP_TRACE (osip_trace
diff -ur org/linphone-1.1.0pre2/mediastreamer/msfilter.h tmp/linphone-1.1.0pre2/mediastreamer/msfilter.h
--- org/linphone-1.1.0pre2/mediastreamer/msfilter.h 2005-07-29 14:16:13.000000000 +0200
+++ tmp/linphone-1.1.0pre2/mediastreamer/msfilter.h 2005-08-16 16:31:09.000000000 +0200
@@ -53,6 +53,7 @@
gint min_fifo_size; /* set when linking*/
gint r_mingran; /* read minimum granularity (for fifos).
It can be zero so that the filter can accept any size of reading data*/
+ gint bytes_per_compressed_frame; /* for dynamic codec like iLBC */
MSFifo **infifos; /*pointer to a table of pointer to input fifos*/
MSFifo **outfifos; /*pointer to a table of pointer to output fifos*/
MSQueue **inqueues; /*pointer to a table of pointer to input queues*/
diff -ur org/linphone-1.1.0pre2/mediastreamer/msilbcenc.c tmp/linphone-1.1.0pre2/mediastreamer/msilbcenc.c
--- org/linphone-1.1.0pre2/mediastreamer/msilbcenc.c 2005-07-29 15:40:54.000000000 +0200
+++ tmp/linphone-1.1.0pre2/mediastreamer/msilbcenc.c 2005-08-17 13:42:19.000000000 +0200
@@ -159,11 +159,11 @@
switch (r->ms_per_frame) {
case 20:
r->samples_per_frame = BLOCKL_20MS;
- r->bytes_per_compressed_frame = NO_OF_BYTES_20MS;
+ MS_FILTER(r)->bytes_per_compressed_frame = NO_OF_BYTES_20MS;
break;
case 30:
r->samples_per_frame = BLOCKL_30MS;
- r->bytes_per_compressed_frame = NO_OF_BYTES_30MS;
+ MS_FILTER(r)->bytes_per_compressed_frame = NO_OF_BYTES_30MS;
break;
default:
g_error("Bad bitrate value (%i) for ilbc encoder!", r->ms_per_frame);
@@ -181,7 +181,7 @@
r->bitrate = 15200;
r->ms_per_frame = 20;
r->samples_per_frame = BLOCKL_20MS;
- r->bytes_per_compressed_frame = NO_OF_BYTES_20MS;
+ MS_FILTER(r)->bytes_per_compressed_frame = NO_OF_BYTES_20MS;
ms_filter_init(MS_FILTER(r));
MS_FILTER(r)->infifos=r->f_inputs;
@@ -223,7 +223,7 @@
g_warning( "src=%p\n", src);
return;
}
- m=ms_message_new(r->bytes_per_compressed_frame);
+ m=ms_message_new(MS_FILTER(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);
diff -ur org/linphone-1.1.0pre2/mediastreamer/msilbcenc.h tmp/linphone-1.1.0pre2/mediastreamer/msilbcenc.h
--- org/linphone-1.1.0pre2/mediastreamer/msilbcenc.h 2005-07-29 15:41:05.000000000 +0200
+++ tmp/linphone-1.1.0pre2/mediastreamer/msilbcenc.h 2005-08-16 16:32:08.000000000 +0200
@@ -57,7 +57,6 @@
int bitrate;
int ms_per_frame;
int samples_per_frame;
- int bytes_per_compressed_frame;
} MSILBCEncoder;
typedef struct _MSILBCEncoderClass
diff -ur org/linphone-1.1.0pre2/mediastreamer/msossread.c tmp/linphone-1.1.0pre2/mediastreamer/msossread.c
--- org/linphone-1.1.0pre2/mediastreamer/msossread.c 2005-03-04 17:39:31.000000000 +0100
+++ tmp/linphone-1.1.0pre2/mediastreamer/msossread.c 2005-08-18 11:03:21.000000000 +0200
@@ -104,7 +104,7 @@
g_return_if_fail(f->sndcard!=NULL);
g_return_if_fail(f->gran>0);
- if (snd_card_can_read(f->sndcard)){
+ while(snd_card_can_read(f->sndcard)){
int got;
ms_fifo_get_write_ptr(fifo,f->gran,(void**)&p);
g_return_if_fail(p!=NULL);
diff -ur org/linphone-1.1.0pre2/mediastreamer/msrtpsend.c tmp/linphone-1.1.0pre2/mediastreamer/msrtpsend.c
--- org/linphone-1.1.0pre2/mediastreamer/msrtpsend.c 2005-07-14 16:45:45.000000000 +0200
+++ tmp/linphone-1.1.0pre2/mediastreamer/msrtpsend.c 2005-08-18 10:52:46.000000000 +0200
@@ -57,6 +57,8 @@
r->ts_inc=0;
r->flags=0;
r->delay=0;
+ r->frames_per_packet=2;
+ r->ptr = r->payload;
}
void ms_rtp_send_class_init(MSRtpSendClass *klass)
@@ -112,7 +114,7 @@
guint skip;
guint32 synctime=sync->time;
- g_return_if_fail(gran>0);
+ g_return_if_fail(gran>0 && r->packet_size<MAX_RTP_PAYLOAD);
if (r->rtpsession==NULL) return;
ms_filter_lock(MS_FILTER(r));
@@ -135,14 +139,34 @@
{
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);
-
+ if((msg=ms_queue_get(qi))!=NULL)
+ {
+ if(r->ptr+msg->size<r->payload+MAX_RTP_PAYLOAD)
+ {
+ if(!skip)
+ {
+ memcpy(r->ptr,msg->data,msg->size);
+ r->ptr+=msg->size;
+ }
+ }
+ else
+ {
+ // something went wrong, reset
+ r->ptr = r->payload;
}
ms_message_destroy(msg);
+ if((r->ptr - r->payload) >= r->packet_size)
+ {
+ if((r->ptr - r->payload) == r->packet_size)
+ {
+ ts=get_new_timestamp(r,synctime);
+ //printf("Sending packet %d:%d\n",r->packet_size,ts);
+ rtp_session_send_with_ts(r->rtpsession,r->payload,r->packet_size,ts);
+ }
+ // else
+ // printf("Invalid framing: %d != %d\n",r->ptr-r->payload,r->packet_size);
+ r->ptr = r->payload;
+ }
}
}
ms_filter_unlock(MS_FILTER(r));
@@ -167,6 +191,7 @@
MSFilter *codec;
MSCodecInfo *info;
r->sync=sync;
+ r->ptr = r->payload;
codec=ms_filter_search_upstream_by_type(MS_FILTER(r),MS_FILTER_AUDIO_CODEC);
if (codec==NULL) codec=ms_filter_search_upstream_by_type(MS_FILTER(r),MS_FILTER_VIDEO_CODEC);
if (codec==NULL){
@@ -181,9 +206,9 @@
/* dont'use the normal frame size: this is a variable frame size codec */
/* use the MS_FILTER(codec)->r_mingran */
ts_inc=MS_FILTER(codec)->r_mingran/2;
- psize=0;
+ psize=codec->bytes_per_compressed_frame;
}
- ms_rtp_send_set_timing(r,ts_inc,psize);
+ ms_rtp_send_set_timing(r,r->frames_per_packet*ts_inc,r->frames_per_packet*psize);
}
}
diff -ur org/linphone-1.1.0pre2/mediastreamer/msrtpsend.h tmp/linphone-1.1.0pre2/mediastreamer/msrtpsend.h
--- org/linphone-1.1.0pre2/mediastreamer/msrtpsend.h 2005-03-04 17:05:14.000000000 +0100
+++ tmp/linphone-1.1.0pre2/mediastreamer/msrtpsend.h 2005-08-18 10:22:03.000000000 +0200
@@ -36,6 +36,8 @@
#define MSRTPSEND_DEF_GRAN 4096/* the default granularity*/
+#define MAX_RTP_PAYLOAD 1400
+
struct _MSRtpSend
{
/* the MSCopy derivates from MSFilter, so the MSFilter object MUST be the first of the MSCopy object
@@ -50,6 +52,9 @@
gint packet_size;
guint flags;
guint delay; /* number of _proccess call which must be skipped */
+ guint frames_per_packet;
+ gchar payload[MAX_RTP_PAYLOAD];
+ gchar *ptr;
#define RTPSEND_CONFIGURED (1)
};
diff -ur org/linphone-1.1.0pre2/mediastreamer/mstimer.c tmp/linphone-1.1.0pre2/mediastreamer/mstimer.c
--- org/linphone-1.1.0pre2/mediastreamer/mstimer.c 2005-03-03 13:14:26.000000000 +0100
+++ tmp/linphone-1.1.0pre2/mediastreamer/mstimer.c 2005-08-18 11:04:11.000000000 +0200
@@ -33,7 +33,6 @@
ms_sync_init(MS_SYNC(sync));
MS_SYNC(sync)->attached_filters=sync->filters;
memset(sync->filters,0,MSTIMER_MAX_FILTERS*sizeof(MSFilter*));
- MS_SYNC(sync)->samples_per_tick=160;
ms_timer_set_interval(sync,20);
sync->state=MS_TIMER_STOPPED;
}
@@ -106,6 +105,7 @@
MS_SYNC(timer)->ticks=0;
MS_SYNC(timer)->interval=milisec;
+ MS_SYNC(timer)->samples_per_tick=8*milisec;
timer->interval.tv_sec=milisec/1000;
timer->interval.tv_usec=(milisec % 1000)*1000;
timer->milisec=milisec;
--- End Message ---