[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Linphone-developers] Patches for oRTP 0.12.0
From: |
Vadim Lebedev |
Subject: |
[Linphone-developers] Patches for oRTP 0.12.0 |
Date: |
Thu, 14 Dec 2006 20:00:24 +0100 |
User-agent: |
Mozilla Thunderbird 0.9 (X11/20041103) |
Hello,
I'm submitting patches for oRtp 0.12.0 for review
1) split-profiles.patch -- allows setting of different profiles for
sending/recieving directions
2) rtcp-memleak.patch -- fix a posiible memleak when handling incoming
rtcp packets
3) telephony-events.patch -- genearates better timestamp info for
telephony events packets, also add handling of FLASH and EVT_[A-D]
4) rtptransport.patch - introduces the concept of RtpTransport to allow
post/pre processing of network data
The patches should be applied in order 1 => 4.
Thanks
Vadim
Add support differen dynamic payload codes in each direction.
Move direction specific data into a 'snd' and 'rcv' structure objects.
diff -r afeb203d5ead include/ortp/rtpsession.h
--- a/include/ortp/rtpsession.h Tue Dec 12 12:58:13 2006 +0100
+++ b/include/ortp/rtpsession.h Wed Dec 13 16:39:06 2006 +0100
@@ -130,13 +130,13 @@ struct _RtpSession
{
RtpSession *next; /* next RtpSession, when the session are
enqueued by the scheduler */
int mask_pos; /* the position in the scheduler mask of RtpSession :
do not move this field: it is part of the ABI since the session_set macros use
it*/
- RtpProfile *profile;
- WaitPoint recv_wp;
- WaitPoint send_wp;
- uint32_t send_ssrc;
- uint32_t recv_ssrc;
- int send_pt;/* sent payload type */
- int recv_pt;/* recv payload type */
+ struct {
+ RtpProfile *profile;
+ int pt;
+ int ssrc;
+ WaitPoint wp;
+ int telephone_events_pt; /* the payload type used for telephony
events */
+ } snd,rcv;
int hw_recv_pt; /* recv payload type before jitter buffer */
int recv_buf_size;
RtpSignalTable on_ssrc_changed;
@@ -161,7 +161,6 @@ struct _RtpSession
struct timeval last_recv_time; /* Time of receiving the RTP/RTCP
packet. */
/* telephony events extension */
- int telephone_events_pt; /* the payload type used for telephony
events */
mblk_t *current_tev; /* the pending telephony events */
mblk_t *sd;
queue_t contributing_sources;
@@ -189,7 +188,11 @@ void rtp_session_set_scheduling_mode(Rtp
void rtp_session_set_scheduling_mode(RtpSession *session, int yesno);
void rtp_session_set_blocking_mode(RtpSession *session, int yesno);
void rtp_session_set_profile(RtpSession *session,RtpProfile *profile);
+void rtp_session_set_send_profile(RtpSession *session,RtpProfile *profile);
+void rtp_session_set_recv_profile(RtpSession *session,RtpProfile *profile);
RtpProfile *rtp_session_get_profile(RtpSession *session);
+RtpProfile *rtp_session_get_send_profile(RtpSession *session);
+RtpProfile *rtp_session_get_recv_profile(RtpSession *session);
int rtp_session_signal_connect(RtpSession *session,const char *signal_name,
RtpCallback cb, unsigned long user_data);
int rtp_session_signal_disconnect_by_callback(RtpSession *session,const char
*signal_name, RtpCallback cb);
void rtp_session_set_ssrc(RtpSession *session, uint32_t ssrc);
diff -r afeb203d5ead include/ortp/telephonyevents.h
--- a/include/ortp/telephonyevents.h Tue Dec 12 12:58:13 2006 +0100
+++ b/include/ortp/telephonyevents.h Wed Dec 13 17:19:16 2006 +0100
@@ -54,6 +54,8 @@ extern PayloadType payload_type_telephon
/* low level functions */
int rtp_session_telephone_events_supported(RtpSession *session);
+int rtp_session_send_telephone_events_supported(RtpSession *session);
+int rtp_session_recv_telephone_events_supported(RtpSession *session);
mblk_t *rtp_session_create_telephone_event_packet(RtpSession *session, int
start);
diff -r afeb203d5ead src/jitterctl.c
--- a/src/jitterctl.c Tue Dec 12 12:58:13 2006 +0100
+++ b/src/jitterctl.c Wed Dec 13 17:21:02 2006 +0100
@@ -127,8 +127,8 @@ rtp_session_set_jitter_compensation (Rtp
rtp_session_set_jitter_compensation (RtpSession * session, int milisec)
{
PayloadType *payload=NULL;
- if (session->recv_pt!=-1) {
- payload = rtp_profile_get_payload
(session->profile,session->recv_pt);
+ if (session->rcv.pt!=-1) {
+ payload = rtp_profile_get_payload
(session->rcv.profile,session->rcv.pt);
}/*else not set yet */
jitter_control_init(&session->rtp.jittctl,milisec,payload);
}
diff -r afeb203d5ead src/rtcp.c
--- a/src/rtcp.c Tue Dec 12 12:58:13 2006 +0100
+++ b/src/rtcp.c Wed Dec 13 17:24:26 2006 +0100
@@ -78,7 +78,7 @@ void rtp_session_set_source_description(
void rtp_session_set_source_description(RtpSession *session,
const char *cname, const char *name, const char *email, const char *phone,
const char *loc, const char *tool, const char *note){
- mblk_t *chunk = sdes_chunk_new(session->send_ssrc);
+ mblk_t *chunk = sdes_chunk_new(session->snd.ssrc);
mblk_t *m=chunk;
const char *_cname=cname;
if (_cname==NULL)
@@ -133,7 +133,7 @@ mblk_t* rtp_session_create_rtcp_sdes_pac
mp->b_wptr+=sizeof(rtcp_common_header_t);
/* concatenate all sdes chunks */
- sdes_chunk_set_ssrc(session->sd,session->send_ssrc);
+ sdes_chunk_set_ssrc(session->sd,session->snd.ssrc);
m=concatb(m,dupmsg(session->sd));
rc++;
@@ -248,7 +248,7 @@ static void report_block_init(report_blo
delay_snc_last_sr=(uint32_t) delay;
}
- b->ssrc=htonl(session->recv_ssrc);
+ b->ssrc=htonl(session->rcv.ssrc);
fl_cnpl=((loss_fraction&0xFF)<<24) | (stream->stats.cum_packet_loss &
0xFFFFFF);
b->fl_cnpl=htonl(fl_cnpl);
b->interarrival_jitter=htonl((uint32_t) stream->jittctl.inter_jitter);
@@ -263,7 +263,7 @@ static int rtcp_sr_init(RtpSession *sess
rtcp_sr_t *sr=(rtcp_sr_t*)buf;
if (size<sizeof(rtcp_sr_t)) return 0;
rtcp_common_header_init(&sr->ch,session,RTCP_SR,1,sizeof(rtcp_sr_t));
- sr->ssrc=htonl(session->send_ssrc);
+ sr->ssrc=htonl(session->snd.ssrc);
sender_info_init(&sr->si,session);
report_block_init(&sr->rb[0],session);
return sizeof(rtcp_sr_t);
@@ -273,7 +273,7 @@ static int rtcp_rr_init(RtpSession *sess
rtcp_rr_t *rr=(rtcp_rr_t*)buf;
if (size<sizeof(rtcp_rr_t)) return 0;
rtcp_common_header_init(&rr->ch,session,RTCP_RR,1,sizeof(rtcp_rr_t));
- rr->ssrc=htonl(session->send_ssrc);
+ rr->ssrc=htonl(session->snd.ssrc);
report_block_init(&rr->rb[0],session);
return sizeof(rtcp_rr_t);
}
@@ -282,7 +282,7 @@ static int rtcp_app_init(RtpSession *ses
rtcp_app_t *app=(rtcp_app_t*)buf;
if (size<sizeof(rtcp_app_t)) return 0;
rtcp_common_header_init(&app->ch,session,RTCP_APP,subtype,size);
- app->ssrc=htonl(session->send_ssrc);
+ app->ssrc=htonl(session->snd.ssrc);
memset(app->name,0,4);
strncpy(app->name,name,4);
return sizeof(rtcp_app_t);
@@ -379,7 +379,7 @@ rtp_session_bye(RtpSession *session, con
int ret;
/* Make a BYE packet (will be on the end of the compund packet). */
- bye = rtcp_create_simple_bye_packet(session->send_ssrc, reason);
+ bye = rtcp_create_simple_bye_packet(session->snd.ssrc, reason);
/* SR or RR should be determined by the fact whether st was sent,
not on the mode. But we follow the current ortplib logic. */
diff -r afeb203d5ead src/rtcpparse.c
--- a/src/rtcpparse.c Tue Dec 12 12:58:13 2006 +0100
+++ b/src/rtcpparse.c Wed Dec 13 17:26:28 2006 +0100
@@ -295,7 +295,7 @@ void report_block_parse(RtpSession *sess
{
rb->ssrc = ntohl(rb->ssrc);
- if ( rb->ssrc != session->send_ssrc )
+ if ( rb->ssrc != session->snd.ssrc )
{
ortp_debug("Received rtcp report block related to unknown ssrc (not from
us)... discarded");
@@ -394,7 +394,7 @@ void rtp_session_rtcp_parse(RtpSession *
report_block_t *rb;
int i;
- if ( ntohl(sr->ssrc) != session->recv_ssrc )
+ if ( ntohl(sr->ssrc) != session->rcv.ssrc )
{
ortp_debug("Receiving rtcp sr packet from unknown ssrc..
discarded");
return;
@@ -438,12 +438,12 @@ void rtp_session_rtcp_parse(RtpSession *
report_block_t *rb;
int i;
- if (session->recv_ssrc == 0)
+ if (session->rcv.ssrc == 0)
{
- /* recv_ssrc is not set, so we adopt the incoming one */
- session->recv_ssrc = ntohl(rr->ssrc);
+ /* rcv.ssrc is not set, so we adopt the incoming one */
+ session->rcv.ssrc = ntohl(rr->ssrc);
}
- else if ( ntohl(rr->ssrc) != session->recv_ssrc )
+ else if ( ntohl(rr->ssrc) != session->rcv.ssrc )
{
ortp_debug("Receiving rtcp rr packet from unknown ssrc..
discarded");
return;
@@ -480,19 +480,19 @@ void rtp_session_rtcp_parse(RtpSession *
- sclen;
int i;
char *reason = NULL;
- bool_t recv_ssrc_match = FALSE;
+ bool_t rcv_ssrc_match = FALSE;
if (reason_space_len < 0) {
ortp_debug("Receiving too short RTCP BYE packet... discarded");
return;
}
for (i = 0; i < bye->ch.rc; i++) {
- if (ntohl(bye->ssrc[i]) == session->recv_ssrc) {
- recv_ssrc_match = TRUE;
+ if (ntohl(bye->ssrc[i]) == session->rcv.ssrc) {
+ rcv_ssrc_match = TRUE;
break;
}
}
- if (recv_ssrc_match) {
+ if (rcv_ssrc_match) {
if (session->on_rtcp_bye.count > 0) {
/* Get reason. */
if (reason_space_len > 1) {
@@ -512,7 +512,7 @@ void rtp_session_rtcp_parse(RtpSession *
ortp_debug("Got RTCP BYE without RTCP BYE handler");
}
} else {
- ortp_debug("No SSRC in the BYE packet matched our recv_ssrc.");
+ ortp_debug("No SSRC in the BYE packet matched our rcv.ssrc.");
}
break;
}
diff -r afeb203d5ead src/rtpparse.c
--- a/src/rtpparse.c Tue Dec 12 12:58:13 2006 +0100
+++ b/src/rtpparse.c Wed Dec 13 17:12:30 2006 +0100
@@ -135,15 +135,15 @@ void rtp_session_rtp_parse(RtpSession *s
for (i=0;i<rtp->cc;i++)
rtp->csrc[i]=ntohl(rtp->csrc[i]);
- if (session->recv_ssrc!=0)
+ if (session->rcv.ssrc!=0)
{
/*the ssrc is set, so we must check it */
- if (session->recv_ssrc!=rtp->ssrc){
+ if (session->rcv.ssrc!=rtp->ssrc){
/*ortp_debug("rtp_parse: bad ssrc - %i",rtp->ssrc);*/
- session->recv_ssrc=rtp->ssrc;
+ session->rcv.ssrc=rtp->ssrc;
rtp_signal_table_emit(&session->on_ssrc_changed);
}
- }else session->recv_ssrc=rtp->ssrc;
+ }else session->rcv.ssrc=rtp->ssrc;
/* update some statistics */
{
@@ -158,7 +158,7 @@ void rtp_session_rtp_parse(RtpSession *s
}
/* check for possible telephone events */
- if (rtp->paytype==session->telephone_events_pt){
+ if (rtp->paytype==session->rcv.telephone_events_pt){
split_and_queue(&session->rtp.tev_rq,session->rtp.max_rq_size,mp,rtp,&i);
stats->discarded+=i;
ortp_global_stats.discarded+=i;
diff -r afeb203d5ead src/rtpsession.c
--- a/src/rtpsession.c Tue Dec 12 12:58:13 2006 +0100
+++ b/src/rtpsession.c Wed Dec 13 17:15:47 2006 +0100
@@ -225,12 +225,13 @@ rtp_session_init (RtpSession * session,
if ((mode == RTP_SESSION_SENDONLY) || (mode == RTP_SESSION_SENDRECV))
{
rtp_session_set_flag (session, RTP_SESSION_SEND_NOT_STARTED);
- session->send_ssrc=uint32_t_random();
+ session->snd.ssrc=uint32_t_random();
/* set default source description */
rtp_session_set_source_description(session,"address@hidden",NULL,NULL,
NULL,NULL,"oRTP-" ORTP_VERSION,"This is free
sofware (LGPL) !");
}
- session->telephone_events_pt=-1; /* not defined a priori */
+ session->snd.telephone_events_pt=-1; /* not defined a priori */
+ session->rcv.telephone_events_pt=-1; /* not defined a priori */
rtp_session_set_profile (session, &av_profile); /*the default profile
to work with */
session->rtp.socket=-1;
session->rtcp.socket=-1;
@@ -249,8 +250,8 @@ rtp_session_init (RtpSession * session,
rtp_signal_table_init
(&session->on_timestamp_jump,session,"timestamp_jump");
rtp_signal_table_init
(&session->on_network_error,session,"network_error");
rtp_signal_table_init (&session->on_rtcp_bye,session,"rtcp_bye");
- wait_point_init(&session->send_wp);
- wait_point_init(&session->recv_wp);
+ wait_point_init(&session->snd.wp);
+ wait_point_init(&session->rcv.wp);
/*defaults send payload type to 0 (pcmu)*/
rtp_session_set_send_payload_type(session,0);
/*sets supposed recv payload type to undefined */
@@ -360,8 +361,50 @@ void
void
rtp_session_set_profile (RtpSession * session, RtpProfile * profile)
{
- session->profile = profile;
+ session->snd.profile = profile;
+ session->rcv.profile = profile;
rtp_session_telephone_events_supported(session);
+}
+
+
+/**
+ *rtp_session_set_send_profile:
+ address@hidden: a rtp session
+ address@hidden: a rtp profile
+ *
+ * Set the RTP profile to be used for the sending by this session. By
default, all session are created by
+ * rtp_session_new() are initialized with the AV profile, as defined in
RFC 3551. The application
+ * can set any other profile instead using that function.
+ *
+ *
+**/
+
+void
+rtp_session_set_send_profile (RtpSession * session, RtpProfile * profile)
+{
+ session->snd.profile = profile;
+ rtp_session_send_telephone_events_supported(session);
+}
+
+
+
+/**
+ *rtp_session_set_recv_profile:
+ address@hidden: a rtp session
+ address@hidden: a rtp profile
+ *
+ * Set the RTP profile to be used for the receiveing by this session. By
default, all session are created by
+ * rtp_session_new() are initialized with the AV profile, as defined in
RFC 3551. The application
+ * can set any other profile instead using that function.
+ *
+ *
+**/
+
+void
+rtp_session_set_recv_profile (RtpSession * session, RtpProfile * profile)
+{
+ session->rcv.profile = profile;
+ rtp_session_recv_telephone_events_supported(session);
}
/**
@@ -372,7 +415,30 @@ rtp_session_set_profile (RtpSession * se
*
**/
RtpProfile *rtp_session_get_profile(RtpSession *session){
- return session->profile;
+ return session->snd.profile;
+}
+
+
+/**
+ *rtp_session_get_send_profile:
+ address@hidden: a rtp session
+ *
+ * Returns current send profile.
+ *
+**/
+RtpProfile *rtp_session_get_send_profile(RtpSession *session){
+ return session->snd.profile;
+}
+
+/**
+ *rtp_session_get_recv_profile:
+ address@hidden: a rtp session
+ *
+ * Returns current receive profile.
+ *
+**/
+RtpProfile *rtp_session_get_recv_profile(RtpSession *session){
+ return session->rcv.profile;
}
/**
@@ -495,13 +561,13 @@ void
void
rtp_session_set_ssrc (RtpSession * session, uint32_t ssrc)
{
- session->send_ssrc = ssrc;
+ session->snd.ssrc = ssrc;
}
void rtp_session_update_payload_type(RtpSession *session, int paytype){
/* check if we support this payload type */
- PayloadType *pt=rtp_profile_get_payload(session->profile,paytype);
+ PayloadType *pt=rtp_profile_get_payload(session->rcv.profile,paytype);
session->hw_recv_pt=paytype;
if (pt!=0){
ortp_message ("payload type changed to %i(%s) !",
@@ -528,7 +594,7 @@ int
int
rtp_session_set_send_payload_type (RtpSession * session, int paytype)
{
- session->send_pt=paytype;
+ session->snd.pt=paytype;
return 0;
}
@@ -539,7 +605,7 @@ rtp_session_set_send_payload_type (RtpSe
* Returns: the payload type currently used in outgoing rtp packets
**/
int rtp_session_get_send_payload_type(const RtpSession *session){
- return session->send_pt;
+ return session->snd.pt;
}
/**
@@ -558,9 +624,9 @@ rtp_session_set_recv_payload_type (RtpSe
rtp_session_set_recv_payload_type (RtpSession * session, int paytype)
{
PayloadType *pt;
- session->recv_pt=paytype;
+ session->rcv.pt=paytype;
session->hw_recv_pt=paytype;
- pt=rtp_profile_get_payload(session->profile,paytype);
+ pt=rtp_profile_get_payload(session->rcv.profile,paytype);
if (pt!=NULL){
payload_type_changed(session,pt);
}
@@ -574,7 +640,7 @@ rtp_session_set_recv_payload_type (RtpSe
* Returns: the payload type currently used in incoming rtp packets
**/
int rtp_session_get_recv_payload_type(const RtpSession *session){
- return session->recv_pt;
+ return session->rcv.pt;
}
/**
@@ -601,8 +667,8 @@ static void rtp_header_init_from_session
rtp->extbit = 0;
rtp->markbit= 0;
rtp->cc = 0;
- rtp->paytype = session->send_pt;
- rtp->ssrc = session->send_ssrc;
+ rtp->paytype = session->snd.pt;
+ rtp->ssrc = session->snd.ssrc;
rtp->timestamp = 0; /* set later, when packet is sended */
/* set a seq number */
rtp->seq_number=session->rtp.snd_seq;
@@ -754,14 +820,14 @@ rtp_session_sendm_with_ts (RtpSession *
session->rtp.snd_ts_offset) +
session->rtp.snd_time_offset;
/*ortp_message("rtp_session_send_with_ts: packet_time=%i
time=%i",packet_time,sched->time_);*/
- wait_point_lock(&session->send_wp);
+ wait_point_lock(&session->snd.wp);
if (TIME_IS_STRICTLY_NEWER_THAN (packet_time, sched->time_))
{
-
wait_point_wakeup_at(&session->send_wp,packet_time,(session->flags &
RTP_SESSION_BLOCKING_MODE)!=0);
+
wait_point_wakeup_at(&session->snd.wp,packet_time,(session->flags &
RTP_SESSION_BLOCKING_MODE)!=0);
session_set_clr(&sched->w_sessions,session); /* the
session has written */
}
else session_set_set(&sched->w_sessions,session); /*to
indicate select to return immediately */
- wait_point_unlock(&session->send_wp);
+ wait_point_unlock(&session->snd.wp);
}
@@ -770,7 +836,7 @@ rtp_session_sendm_with_ts (RtpSession *
packsize = msgdsize(mp) ;
rtp->timestamp=timestamp;
- if (session->telephone_events_pt==rtp->paytype)
+ if (session->snd.telephone_events_pt==rtp->paytype)
{
session->rtp.snd_seq++;
rtp->seq_number = session->rtp.snd_seq;
@@ -830,7 +896,7 @@ extern void rtcp_parse(RtpSession *sessi
static void payload_type_changed_notify(RtpSession *session, int paytype){
- session->recv_pt = paytype;
+ session->rcv.pt = paytype;
rtp_signal_table_emit (&session->on_payload_type_changed);
}
@@ -914,7 +980,7 @@ rtp_session_recvm_with_ts (RtpSession *
/* remember the difference between the last received on the
socket timestamp and the user timestamp */
session->rtp.rcv_diff_ts=session->rtp.hwrcv_diff_ts -
session->rtp.jittctl.jitt_comp_ts;
session->rtp.rcv_last_ret_ts = user_ts; /* just to have an init
value */
- session->recv_ssrc = rtp->ssrc;
+ session->rcv.ssrc = rtp->ssrc;
/* delete the recv synchronisation flag */
rtp_session_unset_flag (session, RTP_SESSION_RECV_SYNC);
}
@@ -941,7 +1007,7 @@ rtp_session_recvm_with_ts (RtpSession *
packet_ts=rtp->timestamp;
ortp_debug("Returning mp with ts=%i", packet_ts);
/* check for payload type changes */
- if (session->recv_pt != rtp->paytype)
+ if (session->rcv.pt != rtp->paytype)
{
payload_type_changed_notify(session, rtp->paytype);
}
@@ -982,14 +1048,14 @@ rtp_session_recvm_with_ts (RtpSession *
session->rtp.rcv_query_ts_offset) +
session->rtp.rcv_time_offset;
ortp_debug ("rtp_session_recvm_with_ts: packet_time=%i,
time=%i",packet_time, sched->time_);
- wait_point_lock(&session->recv_wp);
+ wait_point_lock(&session->rcv.wp);
if (TIME_IS_STRICTLY_NEWER_THAN (packet_time, sched->time_))
{
- wait_point_wakeup_at(&session->recv_wp,packet_time,
(session->flags & RTP_SESSION_BLOCKING_MODE)!=0);
+ wait_point_wakeup_at(&session->rcv.wp,packet_time,
(session->flags & RTP_SESSION_BLOCKING_MODE)!=0);
session_set_clr(&sched->r_sessions,session);
}
else session_set_set(&sched->r_sessions,session); /*to
unblock _select() immediately */
- wait_point_unlock(&session->recv_wp);
+ wait_point_unlock(&session->rcv.wp);
}
return mp;
}
@@ -1076,8 +1142,8 @@ int rtp_session_recv_with_ts (RtpSession
*have_more = 0;
mp = rtp_session_recvm_with_ts (session, ts);
- payload =rtp_profile_get_payload (session->profile,
- session->recv_pt);
+ payload =rtp_profile_get_payload (session->rcv.profile,
+ session->rcv.pt);
if (payload==NULL){
ortp_warning("rtp_session_recv_with_ts: unable to recv an
unsupported payload.");
if (mp!=NULL) freemsg(mp);
@@ -1174,8 +1240,8 @@ int rtp_session_recv_with_ts (RtpSession
return 0;
}
mp = rtp_session_recvm_with_ts (session, ts);
- payload = rtp_profile_get_payload (session->profile,
- session->recv_pt);
+ payload = rtp_profile_get_payload (session->rcv.profile,
+ session->rcv.pt);
if (payload==NULL){
ortp_warning("rtp_session_recv_with_ts: unable to recv
an unsupported payload.");
if (mp!=NULL) freemsg(mp);
@@ -1204,7 +1270,7 @@ uint32_t rtp_session_get_current_send_ts
uint32_t session_time;
RtpScheduler *sched=session->sched;
PayloadType *payload;
- payload=rtp_profile_get_payload(session->profile,session->send_pt);
+ payload=rtp_profile_get_payload(session->snd.profile,session->snd.pt);
return_val_if_fail(payload!=NULL, 0);
if ( (session->flags & RTP_SESSION_SCHEDULED)==0 ){
ortp_warning("can't guess current timestamp because session is
not scheduled.");
@@ -1231,7 +1297,7 @@ uint32_t rtp_session_get_current_recv_ts
uint32_t session_time;
RtpScheduler *sched=ortp_get_scheduler();
PayloadType *payload;
- payload=rtp_profile_get_payload(session->profile,session->recv_pt);
+ payload=rtp_profile_get_payload(session->rcv.profile,session->rcv.pt);
return_val_if_fail(payload!=NULL, 0);
if ( (session->flags & RTP_SESSION_SCHEDULED)==0 ){
ortp_warning("can't guess current timestamp because session is
not scheduled.");
@@ -1329,8 +1395,8 @@ void rtp_session_uninit (RtpSession * se
/* close sockets */
rtp_session_release_sockets(session);
- wait_point_uninit(&session->send_wp);
- wait_point_uninit(&session->recv_wp);
+ wait_point_uninit(&session->snd.wp);
+ wait_point_uninit(&session->rcv.wp);
if (session->current_tev!=NULL) freemsg(session->current_tev);
if (session->rtp.cached_mp!=NULL) freemsg(session->rtp.cached_mp);
if (session->rtcp.cached_mp!=NULL) freemsg(session->rtcp.cached_mp);
@@ -1525,12 +1591,12 @@ uint32_t rtp_session_time_to_ts(RtpSessi
uint32_t rtp_session_time_to_ts(RtpSession *session, int millisecs){
PayloadType *payload;
payload =
- rtp_profile_get_payload (session->profile,
- session->send_pt);
+ rtp_profile_get_payload (session->snd.profile,
+ session->snd.pt);
if (payload == NULL)
{
ortp_warning
- ("rtp_session_ts_to_t: use of unsupported payload type
%d.", session->send_pt);
+ ("rtp_session_ts_to_t: use of unsupported payload type
%d.", session->snd.pt);
return 0;
}
/* the return value is in milisecond */
@@ -1542,12 +1608,12 @@ uint32_t rtp_session_ts_to_time (RtpSess
{
PayloadType *payload;
payload =
- rtp_profile_get_payload (session->profile,
- session->send_pt);
+ rtp_profile_get_payload (session->snd.profile,
+ session->snd.pt);
if (payload == NULL)
{
ortp_warning
- ("rtp_session_ts_to_t: use of unsupported payload type
%d.", session->send_pt);
+ ("rtp_session_ts_to_t: use of unsupported payload type
%d.", session->snd.pt);
return 0;
}
/* the return value is in milisecond */
@@ -1560,18 +1626,18 @@ uint32_t rtp_session_ts_to_time (RtpSess
/* time is the number of miliseconds elapsed since the start of the scheduler
*/
void rtp_session_process (RtpSession * session, uint32_t time, RtpScheduler
*sched)
{
- wait_point_lock(&session->send_wp);
- if (wait_point_check(&session->send_wp,time)){
+ wait_point_lock(&session->snd.wp);
+ if (wait_point_check(&session->snd.wp,time)){
session_set_set(&sched->w_sessions,session);
- wait_point_wakeup(&session->send_wp);
- }
- wait_point_unlock(&session->send_wp);
+ wait_point_wakeup(&session->snd.wp);
+ }
+ wait_point_unlock(&session->snd.wp);
- wait_point_lock(&session->recv_wp);
- if (wait_point_check(&session->recv_wp,time)){
+ wait_point_lock(&session->rcv.wp);
+ if (wait_point_check(&session->rcv.wp,time)){
session_set_set(&sched->r_sessions,session);
- wait_point_wakeup(&session->recv_wp);
- }
- wait_point_unlock(&session->recv_wp);
-}
-
+ wait_point_wakeup(&session->rcv.wp);
+ }
+ wait_point_unlock(&session->rcv.wp);
+}
+
diff -r afeb203d5ead src/telephonyevents.c
--- a/src/telephonyevents.c Tue Dec 12 12:58:13 2006 +0100
+++ b/src/telephonyevents.c Wed Dec 13 17:21:58 2006 +0100
@@ -47,9 +47,45 @@ int rtp_session_telephone_events_support
int rtp_session_telephone_events_supported(RtpSession *session)
{
/* search for a telephony event payload in the current profile */
-
session->telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->profile,"telephone-event");
+
session->snd.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->snd.profile,"telephone-event");
+
session->rcv.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->rcv.profile,"telephone-event");
/*printf("Telephone event pt is %i\n",session->telephone_events_pt);*/
- return session->telephone_events_pt;
+ return session->snd.telephone_events_pt;
+}
+
+
+/**
+ *rtp_session_send_telephone_events_supported:
+ address@hidden : a rtp session
+ *
+ * Tells whether sending telephony events payload type is supported within
the context of the rtp
+ * session.
+ *
+ *Returns: the payload type number used for telephony events if found, -1 if
not found.
+**/
+int rtp_session_send_telephone_events_supported(RtpSession *session)
+{
+ /* search for a telephony event payload in the current profile */
+
session->snd.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->snd.profile,"telephone-event");
+ /*printf("Telephone event pt is %i\n",session->telephone_events_pt);*/
+ return session->snd.telephone_events_pt;
+}
+
+/**
+ *rtp_session_recv_telephone_events_supported:
+ address@hidden : a rtp session
+ *
+ * Tells whether receiving telephony events payload type is supported
within the context of the rtp
+ * session.
+ *
+ *Returns: the payload type number used for telephony events if found, -1 if
not found.
+**/
+int rtp_session_recv_telephone_events_supported(RtpSession *session)
+{
+ /* search for a telephony event payload in the current profile */
+
session->rcv.telephone_events_pt=rtp_profile_get_payload_number_from_mime(session->rcv.profile,"telephone-event");
+ /*printf("Telephone event pt is %i\n",session->telephone_events_pt);*/
+ return session->snd.telephone_events_pt;
}
@@ -71,7 +107,7 @@ mblk_t *rtp_session_create_telephone_eve
mblk_t *mp;
rtp_header_t *rtp;
- return_val_if_fail(session->telephone_events_pt!=-1,NULL);
+ return_val_if_fail(session->snd.telephone_events_pt!=-1,NULL);
mp=allocb(RTP_FIXED_HEADER_SIZE+TELEPHONY_EVENTS_ALLOCATED_SIZE,BPRI_MED);
if (mp==NULL) return NULL;
@@ -81,12 +117,12 @@ mblk_t *rtp_session_create_telephone_eve
rtp->padbit = 0;
rtp->extbit = 0;
rtp->cc = 0;
- rtp->ssrc = session->send_ssrc;
+ rtp->ssrc = session->snd.ssrc;
/* timestamp set later, when packet is sended */
/*seq number set later, when packet is sended */
/*set the payload type */
- rtp->paytype=session->telephone_events_pt;
+ rtp->paytype=session->snd.telephone_events_pt;
/*copy the payload */
mp->b_wptr+=RTP_FIXED_HEADER_SIZE;
@@ -247,7 +283,7 @@ int rtp_session_read_telephone_event(Rtp
telephone_event_t *tev;
rtp_header_t *hdr=(rtp_header_t*)packet->b_rptr;
return_val_if_fail(packet->b_cont!=NULL,-1);
- if (hdr->paytype!=session->telephone_events_pt) return 0; /* this is
not tel ev.*/
+ if (hdr->paytype!=session->rcv.telephone_events_pt) return 0; /* this
is not tel ev.*/
datasize=msgdsize(packet);
tev=*tab=(telephone_event_t*)packet->b_cont->b_rptr;
/* convert from network to host order what should be */
Fix rtcp memory leak
diff -r 230fb6c87661 src/rtpsession_inet.c
--- a/src/rtpsession_inet.c Wed Dec 13 17:30:14 2006 +0100
+++ b/src/rtpsession_inet.c Wed Dec 13 19:01:11 2006 +0100
@@ -849,6 +849,8 @@ void rtp_session_notify_inc_rtcp(RtpSess
d->packet=m;
rtp_session_dispatch_event(session,ev);
}
+ else
+ freemsg(m); /* avoid memory leak */
}
int
Fix contents of telephony event packets. Add support for additional telephony
events
diff -r f2f9a8ca5881 include/ortp/telephonyevents.h
--- a/include/ortp/telephonyevents.h Wed Dec 13 19:02:50 2006 +0100
+++ b/include/ortp/telephonyevents.h Thu Dec 14 13:02:01 2006 +0100
@@ -67,6 +67,7 @@ int rtp_session_read_telephone_event(Rtp
/* high level functions*/
int rtp_session_send_dtmf(RtpSession *session, char dtmf, uint32_t userts);
+int rtp_session_send_dtmf2(RtpSession *session, char dtmf, uint32_t userts,
int duration);
/* for high level telephony event callback */
void rtp_session_check_telephone_events(RtpSession *session, mblk_t *m0);
diff -r f2f9a8ca5881 src/telephonyevents.c
--- a/src/telephonyevents.c Wed Dec 13 19:02:50 2006 +0100
+++ b/src/telephonyevents.c Thu Dec 14 13:06:33 2006 +0100
@@ -185,8 +185,15 @@ int rtp_session_add_telephone_event(RtpS
**/
int rtp_session_send_dtmf(RtpSession *session, char dtmf, uint32_t userts)
{
+ return rtp_session_send_dtmf2(session, dtmf, userts, 480);
+}
+
+int rtp_session_send_dtmf2(RtpSession *session, char dtmf, uint32_t userts,
int duration)
+{
mblk_t *m1,*m2,*m3;
int tev_type;
+ int durationtier = duration/3;
+
/* create the first telephony event packet */
switch (dtmf){
case '1':
@@ -225,6 +232,33 @@ int rtp_session_send_dtmf(RtpSession *se
case '#':
tev_type=TEV_DTMF_POUND;
break;
+
+ case 'A':
+ case 'a':
+ tev_type=TEV_DTMF_A;
+ break;
+
+
+ case 'B':
+ case 'b':
+ tev_type=TEV_DTMF_B;
+ break;
+
+ case 'C':
+ case 'c':
+ tev_type=TEV_DTMF_C;
+ break;
+
+ case 'D':
+ case 'd':
+ tev_type=TEV_DTMF_D;
+ break;
+
+ case '!':
+ tev_type=TEV_FLASH;
+ break;
+
+
default:
ortp_warning("Bad dtmf: %c.",dtmf);
return -1;
@@ -232,20 +266,20 @@ int rtp_session_send_dtmf(RtpSession *se
m1=rtp_session_create_telephone_event_packet(session,1);
if (m1==NULL) return -1;
- rtp_session_add_telephone_event(session,m1,tev_type,0,0,160);
+ rtp_session_add_telephone_event(session,m1,tev_type,0,10,durationtier);
/* create a second packet */
m2=rtp_session_create_telephone_event_packet(session,0);
if (m2==NULL) return -1;
- rtp_session_add_telephone_event(session,m2,tev_type,0,0,320);
+ rtp_session_add_telephone_event(session,m2,tev_type,0,10,
durationtier+durationtier);
/* create a third and final packet */
m3=rtp_session_create_telephone_event_packet(session,0);
if (m3==NULL) return -1;
- rtp_session_add_telephone_event(session,m3,tev_type,1,0,480);
+ rtp_session_add_telephone_event(session,m3,tev_type,1,10,duration);
/* and now sends them */
rtp_session_sendm_with_ts(session,m1,userts);
- rtp_session_sendm_with_ts(session,m2,userts);
+ rtp_session_sendm_with_ts(session,m2,userts+durationtier);
/* the last packet is sent three times in order to improve reliability*/
m1=copymsg(m3);
m2=copymsg(m3);
@@ -257,11 +291,12 @@ int rtp_session_send_dtmf(RtpSession *se
it add one more copy for every buffer.
Using iomapped socket, it is possible to avoid the user to kernel copy.
*/
- rtp_session_sendm_with_ts(session,m3,userts);
- rtp_session_sendm_with_ts(session,m1,userts);
- rtp_session_sendm_with_ts(session,m2,userts);
+ rtp_session_sendm_with_ts(session,m3,userts+durationtier+durationtier);
+ rtp_session_sendm_with_ts(session,m1,userts+durationtier+durationtier);
+ rtp_session_sendm_with_ts(session,m2,userts+durationtier+durationtier);
return 0;
}
+
/**
*rtp_session_read_telephone_event:
Implement RtpTransport concept
diff -r b909584f0a79 include/ortp/rtpsession.h
--- a/include/ortp/rtpsession.h Thu Dec 14 19:48:49 2006 +0100
+++ b/include/ortp/rtpsession.h Thu Dec 14 19:56:24 2006 +0100
@@ -61,10 +61,26 @@ typedef struct _WaitPoint
uint32_t time;
bool_t wakeup;
} WaitPoint;
+
+typedef struct _RtpTransport
+{
+ void *data;
+ ortp_socket_t (*t_getsocket)(struct _RtpTransport *t);
+#ifdef ORTP_INET6
+ int (*t_sendto)(struct _RtpTransport *t, const void *buf, size_t len, int
flags, const struct sockaddr *to, socklen_t tolen);
+ int (*t_recvfrom)(struct _RtpTransport *t, void *buf, size_t len, int
flags, struct sockaddr *from, socklen_t *fromlen);
+#else
+ int (*t_sendto)(struct _RtpTransport *t, const void *buf, size_t len, int
flags, const struct sockaddr *to, socklen_t tolen);
+ int (*t_recvfrom)(struct _RtpTransport *t, void *buf, size_t len, int
flags, struct sockaddr *from, socklen_t *fromlen);
+#endif
+} RtpTransport;
+
+
typedef struct _RtpStream
{
ortp_socket_t socket;
+ struct _RtpTransport *tr;
int sockfamily;
int max_rq_size;
int time_jump;
@@ -113,6 +129,8 @@ typedef struct _RtcpStream
{
ortp_socket_t socket;
int sockfamily;
+ struct _RtpTransport *tr;
+
mblk_t *cached_mp;
#ifdef ORTP_INET6
struct sockaddr_storage rem_addr;
@@ -208,6 +226,7 @@ int rtp_session_set_remote_addr(RtpSessi
/* alternatively to the set_remote_addr() and set_local_addr(), an application
can give
a valid socket (potentially connect()ed )to be used by the RtpSession */
void rtp_session_set_sockets(RtpSession *session, int rtpfd, int rtcpfd);
+void rtp_session_set_transports(RtpSession *session, RtpTransport *rtptr,
RtpTransport *rtcptr);
/*those methods are provided for people who wants to send non-RTP messages
using the RTP/RTCP sockets */
ortp_socket_t rtp_session_get_rtp_socket(const RtpSession *session);
diff -r b909584f0a79 src/rtpsession.c
--- a/src/rtpsession.c Thu Dec 14 19:48:49 2006 +0100
+++ b/src/rtpsession.c Thu Dec 14 19:51:15 2006 +0100
@@ -1333,6 +1333,9 @@ void rtp_session_release_sockets(RtpSess
if (session->rtcp.socket>=0) close_socket (session->rtcp.socket);
session->rtp.socket=-1;
session->rtcp.socket=-1;
+ session->rtp.tr = 0;
+ session->rtcp.tr = 0;
+
/* don't discard remote addresses, then can be preserved for next use.
session->rtp.rem_addrlen=0;
session->rtcp.rem_addrlen=0;
@@ -1340,11 +1343,11 @@ void rtp_session_release_sockets(RtpSess
}
ortp_socket_t rtp_session_get_rtp_socket(const RtpSession *session){
- return session->rtp.socket;
+ return rtp_session_using_transport(session, rtp) ?
(session->rtp.tr->t_getsocket)(session->rtp.tr) : session->rtp.socket;
}
ortp_socket_t rtp_session_get_rtcp_socket(const RtpSession *session){
- return session->rtcp.socket;
+ return rtp_session_using_transport(session, rtcp) ?
(session->rtcp.tr->t_getsocket)(session->rtcp.tr) : session->rtcp.socket;
}
void rtp_session_register_event_queue(RtpSession *session, OrtpEvQueue *q){
diff -r b909584f0a79 src/rtpsession_inet.c
--- a/src/rtpsession_inet.c Thu Dec 14 19:48:49 2006 +0100
+++ b/src/rtpsession_inet.c Thu Dec 14 19:51:15 2006 +0100
@@ -629,6 +629,17 @@ void rtp_session_set_sockets(RtpSession
else
session->flags&=~(RTP_SESSION_USING_EXT_SOCKETS|RTP_SOCKET_CONNECTED|RTCP_SOCKET_CONNECTED);
}
+void rtp_session_set_transports(RtpSession *session, struct _RtpTransport
*rtptr, struct _RtpTransport *rtcptr)
+{
+ session->rtp.tr = rtptr;
+ session->rtcp.tr = rtcptr;
+ if (rtptr || rtcptr )
+ session->flags|=(RTP_SESSION_USING_TRANSPORT);
+ else session->flags&=~(RTP_SESSION_USING_TRANSPORT);
+}
+
+
+
/**
*rtp_session_flush_sockets:
address@hidden: a rtp session
@@ -647,6 +658,16 @@ void rtp_session_flush_sockets(RtpSessio
struct sockaddr from;
#endif
socklen_t fromlen=sizeof(from);
+ if (rtp_session_using_transport(session, rtp))
+ {
+ while
(session->rtp.tr->t_recvfrom(session->rtp.tr,trash,sizeof(trash),0,(struct
sockaddr *)&from,&fromlen)>0){};
+
+ if (session->rtcp.tr)
+ while
(session->rtcp.tr->t_recvfrom(session->rtcp.tr,trash,sizeof(trash),0,(struct
sockaddr *)&from,&fromlen)>0){};
+
+ return;
+ }
+
if (session->rtp.socket>=0){
while
(recvfrom(session->rtp.socket,trash,sizeof(trash),0,(struct sockaddr
*)&from,&fromlen)>0){};
}
@@ -723,7 +744,12 @@ rtp_session_rtp_send (RtpSession * sessi
if (m->b_cont!=NULL){
msgpullup(m,-1);
}
- error = sendto (sockfd, m->b_rptr, (int) (m->b_wptr - m->b_rptr),
+
+ if (rtp_session_using_transport(session, rtp))
+ error = (session->rtp.tr->t_sendto) (session->rtp.tr, m->b_rptr,
(int) (m->b_wptr - m->b_rptr),
+ 0,destaddr,destlen);
+ else
+ error = sendto (sockfd, m->b_rptr, (int) (m->b_wptr - m->b_rptr),
0,destaddr,destlen);
#endif
if (error < 0){
@@ -751,13 +777,18 @@ rtp_session_rtcp_send (RtpSession * sess
destlen=0;
}
- if (sockfd>=0 && (session->rtcp.rem_addrlen>0 ||using_connected_socket)
){
+ if ((sockfd>=0 || rtp_session_using_transport(session, rtcp)) &&
(session->rtcp.rem_addrlen>0 ||using_connected_socket) ){
#ifndef USE_SENDMSG
if (m->b_cont!=NULL){
msgpullup(m,-1);
}
- error = sendto (sockfd, m->b_rptr,
+ if (rtp_session_using_transport(session, rtcp))
+ error = (session->rtcp.tr->t_sendto) (sockfd, m->b_rptr,
+ (int) (m->b_wptr - m->b_rptr), 0,
+ destaddr, destlen);
+ else
+ error = sendto (sockfd, m->b_rptr,
(int) (m->b_wptr - m->b_rptr), 0,
destaddr, destlen);
#else
@@ -788,7 +819,7 @@ rtp_session_rtp_recv (RtpSession * sessi
mblk_t *mp;
bool_t sock_connected=(session->flags & RTP_SOCKET_CONNECTED);
- if (sockfd<0) return -1; /*session has no sockets for the moment*/
+ if ((sockfd<0) && !rtp_session_using_transport(session, rtp)) return
-1; /*session has no sockets for the moment*/
while (1)
{
@@ -799,7 +830,12 @@ rtp_session_rtp_recv (RtpSession * sessi
bufsz=(int) (mp->b_datap->db_lim - mp->b_datap->db_base);
if (sock_connected){
error=recv(sockfd,mp->b_wptr,bufsz,0);
- }else error = recvfrom(sockfd, mp->b_wptr,
+ }else if (rtp_session_using_transport(session, rtp))
+ error = (session->rtp.tr->t_recvfrom)(session->rtp.tr,
mp->b_wptr,
+ bufsz, 0,
+ (struct sockaddr *) &remaddr,
+ &addrlen);
+ else error = recvfrom(sockfd, mp->b_wptr,
bufsz, 0,
(struct sockaddr *) &remaddr,
&addrlen);
@@ -866,7 +902,7 @@ rtp_session_rtcp_recv (RtpSession * sess
mblk_t *mp;
bool_t sock_connected=session->flags & RTCP_SOCKET_CONNECTED;
- if (session->rtcp.socket<0) return -1; /*session has no rtcp sockets
for the moment*/
+ if (session->rtcp.socket<0 && !rtp_session_using_transport(session,
rtcp)) return -1; /*session has no rtcp sockets for the moment*/
while (1)
@@ -879,7 +915,14 @@ rtp_session_rtcp_recv (RtpSession * sess
error=recv(session->rtcp.socket,mp->b_wptr,RTCP_MAX_RECV_BUFSIZE,0);
}else {
addrlen=sizeof (remaddr);
- error=recvfrom (session->rtcp.socket, mp->b_wptr,
+
+ if (rtp_session_using_transport(session, rtcp))
+
error=(session->rtcp.tr->t_recvfrom)(session->rtcp.tr, mp->b_wptr,
+ RTCP_MAX_RECV_BUFSIZE, 0,
+ (struct sockaddr *) &remaddr,
+ &addrlen);
+ else
+ error=recvfrom (session->rtcp.socket, mp->b_wptr,
RTCP_MAX_RECV_BUFSIZE, 0,
(struct sockaddr *) &remaddr,
&addrlen);
diff -r b909584f0a79 src/rtpsession_priv.h
--- a/src/rtpsession_priv.h Thu Dec 14 19:48:49 2006 +0100
+++ b/src/rtpsession_priv.h Thu Dec 14 19:51:15 2006 +0100
@@ -32,9 +32,11 @@ typedef enum {
RTP_SESSION_IN_SCHEDULER=1<<6, /* the rtp session is in the scheduler
list */
RTP_SESSION_USING_EXT_SOCKETS=1<<7, /* the session is using externaly
supplied sockets */
RTP_SOCKET_CONNECTED=1<<8,
- RTCP_SOCKET_CONNECTED=1<<9
+ RTCP_SOCKET_CONNECTED=1<<9,
+ RTP_SESSION_USING_TRANSPORT=1<<10
}RtpSessionFlags;
+#define rtp_session_using_transport(s, stream) (((s)->flags &
RTP_SESSION_USING_TRANSPORT) && (s->stream.tr != 0))
void rtp_session_update_payload_type(RtpSession * session, int pt);
void rtp_putq(queue_t *q, mblk_t *mp);
- [Linphone-developers] Patches for oRTP 0.12.0,
Vadim Lebedev <=