[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: [Linphone-developers] How to realize DTX with oRTPlib?

From: Машкин С В
Subject: Re: Re: [Linphone-developers] How to realize DTX with oRTPlib?
Date: Sat, 01 Mar 2008 14:48:36 +0300

Hi, Simon!

I've realized the "patch", and it seems, that it works...

The "patch" is only 4 additional strings in rtp_session_sendm_with_ts() body

and 1 string in its description).

With this patch if mp==NULL, rtp_session_sendm_with_ts() does not send any 

but does process timestamp and tx-rtpsession-time.

P.S.: For experimental tests I used


 G.729-annexb ITU vocoder (to form mp),

 Ethereal (to check rtp-streams),

 remote eyeBeam ip-phone software.

Serg Ma


New "patched" version of rtp_session_sendm_with_ts(),

additional strings are marked by (***).

Used original version of ortplib is oRTP-0.13.1.



 *      Send the rtp datagram @mp to the destination set by 

 *      with timestamp @timestamp. For audio data, the timestamp is the number

 *      of the first sample resulting of the data transmitted. See rfc1889 for 

 *      If @mp is NULL, no rtp datagram will be sent. (***)

 *  The packet (@mp) is freed once it is sended.


 address@hidden session a rtp session.

 address@hidden mp a rtp packet presented as a mblk_t.

 address@hidden timestamp the timestamp of the data to be sent.

 * @return the number of bytes sent over the network.



rtp_session_sendm_with_ts (RtpSession * session, mblk_t *mp, uint32_t timestamp)


        rtp_header_t *rtp;

        uint32_t packet_time;

        int error = 0;

        int packsize;

        RtpScheduler *sched=session->sched;

        RtpStream *stream=&session->rtp;

        if (session->flags & RTP_SESSION_SEND_NOT_STARTED)


                session->rtp.snd_ts_offset = timestamp;

                /* Set initial last_rcv_time to first send time. */

                if ((session->flags & RTP_SESSION_RECV_NOT_STARTED)

                || session->mode == RTP_SESSION_SENDONLY)


                        gettimeofday(&session->last_recv_time, NULL);


                if (session->flags & RTP_SESSION_SCHEDULED)


                        session->rtp.snd_time_offset = sched->time_;


                rtp_session_unset_flag (session,RTP_SESSION_SEND_NOT_STARTED);


        /* if we are in blocking mode, then suspend the process until the 
scheduler it's time to send  the

         * next packet */

        /* if the timestamp of the packet queued is older than current time, 
then you we must

         * not block */

        if (session->flags & RTP_SESSION_SCHEDULED)


                packet_time =

                        rtp_session_ts_to_time (session,

                                     timestamp -

                                     session->rtp.snd_ts_offset) +


                /*ortp_message("rtp_session_send_with_ts: packet_time=%i 


                if (TIME_IS_STRICTLY_NEWER_THAN (packet_time, sched->time_))


wait_point_wakeup_at(&session->snd.wp,packet_time,(session->flags & 

                        session_set_clr(&sched->w_sessions,session);    /* the 
session has written */




                        session_set_set(&sched->w_sessions,session);    /*to 
indicate select to return immediately */




        if(mp==NULL) {                                    //(***)

                session->rtp.snd_last_ts = timestamp;     //(***)

                return 0;                                 //(***)

        }                                                 //(***)



        packsize = msgdsize(mp) ;



        if (session->snd.telephone_events_pt==rtp->paytype)



                rtp->seq_number = session->rtp.snd_seq;




        session->rtp.snd_last_ts = timestamp;

        ortp_global_stats.sent += packsize;

        stream->stats.sent += packsize;



        error = rtp_session_rtp_send (session, mp);

        /*send RTCP packet if needed */


        /* receives rtcp packet if session is send-only*/

        /*otherwise it is done in rtp_session_recvm_with_ts */

        if (session->mode==RTP_SESSION_SENDONLY) rtp_session_rtcp_recv(session);

        return error;



> > Can rtp_session_sendm_with_ts() send nothing when input

> >

> > argument mp==NULL?

> >

> >

> >

> > If it can't, may be it is good idea to make the patch?


> Yes I think can be a possibility. I realize the session_set* api is not very 

> suitable for discontinuous transmission.

> Do you have a strong requirement for using this session_set api ?

> Alternatively you can just create one thread per session and use 

> rtp_session_sendm_with_ts() with blocking mode.

> In that case, when sending the packet that comes after a silence periods, so 

> with a timestamp in the future, then rtp_session_sendm_with_ts() will block 

> until it's really time for the packet to be sent.


> Simon


> >

> >

> >

> P.S.: But may be there is standard way to realize DTX with oRTPlib?

> >

> >

> >

> > Thanks.

> >

> > Serg Ma

reply via email to

[Prev in Thread] Current Thread [Next in Thread]