Commit b50d3b3a authored by Simon Morlat's avatar Simon Morlat

add command to reset jitter buffer from ms2 interface

parent 4448148a
...@@ -24,19 +24,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -24,19 +24,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <mediastreamer2/msfilter.h> #include <mediastreamer2/msfilter.h>
#include <ortp/ortp.h> #include <ortp/ortp.h>
#define MS_RTP_RECV_SET_SESSION MS_FILTER_METHOD(MS_RTP_RECV_ID,0,RtpSession*) #define MS_RTP_RECV_SET_SESSION MS_FILTER_METHOD(MS_RTP_RECV_ID,0,RtpSession*)
#define MS_RTP_SEND_SET_SESSION MS_FILTER_METHOD(MS_RTP_SEND_ID,0,RtpSession*) #define MS_RTP_RECV_RESET_JITTER_BUFFER MS_FILTER_METHOD_NO_ARG(MS_RTP_RECV_ID,1)
#define MS_RTP_SEND_SEND_DTMF MS_FILTER_METHOD(MS_RTP_SEND_ID,1,const char)
#define MS_RTP_SEND_MUTE_MIC MS_FILTER_METHOD_NO_ARG(MS_RTP_SEND_ID,3)
#define MS_RTP_SEND_UNMUTE_MIC MS_FILTER_METHOD_NO_ARG(MS_RTP_SEND_ID,4)
#define MS_RTP_SEND_SET_SESSION MS_FILTER_METHOD(MS_RTP_SEND_ID,0,RtpSession*)
#define MS_RTP_SEND_SEND_DTMF MS_FILTER_METHOD(MS_RTP_SEND_ID,1,const char)
#define MS_RTP_SEND_SET_DTMF_DURATION MS_FILTER_METHOD(MS_RTP_SEND_ID,2,int)
#define MS_RTP_SEND_MUTE_MIC MS_FILTER_METHOD_NO_ARG(MS_RTP_SEND_ID,3)
#define MS_RTP_SEND_UNMUTE_MIC MS_FILTER_METHOD_NO_ARG(MS_RTP_SEND_ID,4)
#define MS_RTP_SEND_SET_RELAY_SESSION_ID MS_FILTER_METHOD(MS_RTP_SEND_ID,5,const char *) #define MS_RTP_SEND_SET_RELAY_SESSION_ID MS_FILTER_METHOD(MS_RTP_SEND_ID,5,const char *)
#define MS_RTP_SEND_SET_DTMF_DURATION MS_FILTER_METHOD(MS_RTP_SEND_ID,1,int)
extern MSFilterDesc ms_rtp_send_desc; extern MSFilterDesc ms_rtp_send_desc;
extern MSFilterDesc ms_rtp_recv_desc; extern MSFilterDesc ms_rtp_recv_desc;
......
...@@ -70,7 +70,7 @@ static void send_stun_packet(RtpSession *s) ...@@ -70,7 +70,7 @@ static void send_stun_packet(RtpSession *s)
static void sender_init(MSFilter * f) static void sender_init(MSFilter * f)
{ {
SenderData *d = (SenderData *)ms_new(SenderData, 1); SenderData *d = (SenderData *)ms_new0(SenderData, 1);
d->session = NULL; d->session = NULL;
d->tsoff = 0; d->tsoff = 0;
...@@ -451,13 +451,14 @@ struct ReceiverData { ...@@ -451,13 +451,14 @@ struct ReceiverData {
int rate; int rate;
int nchannels; int nchannels;
bool_t starting; bool_t starting;
bool_t reset_jb;
}; };
typedef struct ReceiverData ReceiverData; typedef struct ReceiverData ReceiverData;
static void receiver_init(MSFilter * f) static void receiver_init(MSFilter * f)
{ {
ReceiverData *d = (ReceiverData *)ms_new(ReceiverData, 1); ReceiverData *d = (ReceiverData *)ms_new0(ReceiverData, 1);
d->session = NULL; d->session = NULL;
d->rate = 8000; d->rate = 8000;
d->nchannels = 1; d->nchannels = 1;
...@@ -524,6 +525,13 @@ static int receiver_set_ch(MSFilter *f, void *arg) { ...@@ -524,6 +525,13 @@ static int receiver_set_ch(MSFilter *f, void *arg) {
return 0; return 0;
} }
static int receiver_reset_jitter_buffer(MSFilter *f, void *arg) {
ReceiverData *d = (ReceiverData *)f->data;
d->reset_jb = TRUE;
return 0;
}
static void receiver_preprocess(MSFilter * f){ static void receiver_preprocess(MSFilter * f){
ReceiverData *d = (ReceiverData *) f->data; ReceiverData *d = (ReceiverData *) f->data;
d->starting=TRUE; d->starting=TRUE;
...@@ -537,6 +545,12 @@ static void receiver_process(MSFilter * f) ...@@ -537,6 +545,12 @@ static void receiver_process(MSFilter * f)
if (d->session == NULL) if (d->session == NULL)
return; return;
if (d->reset_jb){
ms_message("Reseting jitter buffer");
rtp_session_resync(d->session);
d->reset_jb=FALSE;
}
if (d->starting){ if (d->starting){
PayloadType *pt=rtp_profile_get_payload( PayloadType *pt=rtp_profile_get_payload(
...@@ -559,6 +573,7 @@ static void receiver_process(MSFilter * f) ...@@ -559,6 +573,7 @@ static void receiver_process(MSFilter * f)
static MSFilterMethod receiver_methods[] = { static MSFilterMethod receiver_methods[] = {
{ MS_RTP_RECV_SET_SESSION , receiver_set_session }, { MS_RTP_RECV_SET_SESSION , receiver_set_session },
{ MS_RTP_RECV_RESET_JITTER_BUFFER, receiver_reset_jitter_buffer },
{ MS_FILTER_GET_SAMPLE_RATE , receiver_get_sr }, { MS_FILTER_GET_SAMPLE_RATE , receiver_get_sr },
{ MS_FILTER_GET_NCHANNELS , receiver_get_ch }, { MS_FILTER_GET_NCHANNELS , receiver_get_ch },
{ MS_FILTER_SET_NCHANNELS , receiver_set_ch }, { MS_FILTER_SET_NCHANNELS , receiver_set_ch },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment