linphone-developers
[Top][All Lists]
Advanced

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

[Linphone-developers] Re: Linphone-developers Digest, Vol 1, Issue 24


From: Peter Wang
Subject: [Linphone-developers] Re: Linphone-developers Digest, Vol 1, Issue 24
Date: Wed, 18 Dec 2002 11:21:17 +0800
User-agent: Internet Messaging Program (IMP) 4.0-cvs

Hi,
   I find a minor bug in rtpsession.c,the value of "session->ssrc" is alaways 
0,so I change the code to like this:

mblk_t * rtp_session_create_packet(RtpSession *session,gint header_size, char 
*payload, gint payload_size)
{
        mblk_t *mp;
        gint msglen=header_size+payload_size;
        rtp_header_t *rtp;
        
        mp=allocb(msglen,BPRI_MED);
#ifdef _KERNEL
        if (mp==NULL) return NULL;
#endif
        rtp=(rtp_header_t*)mp->b_rptr;
        rtp->version = 2;
        rtp->padbit = 0;
        rtp->extbit = 0;
        rtp->markbit= 0;
        rtp->cc = 0;
        //rtp_session_lock(session);
        rtp->paytype = session->payload_type;
/* Added by Peter Wang */
    if(session->ssrc == 0) {
        randomize();
        session->ssrc = rand();
    }
        rtp->ssrc = session->ssrc;
        //rtp_session_unlock(session);
        rtp->timestamp = 0;     /* set later, when packet is sended */
        rtp->seq_number = 0; /*set later, when packet is sended */
        /*copy the payload */
        mp->b_wptr+=header_size;
        memcpy(mp->b_wptr,payload,payload_size);
        mp->b_wptr+=payload_size;
        return mp;
}

And I also find a bug in rtpmod.c, as we know,the newest packet should put to 
the tail of queue,but the rtp_putq will
put  it to the head of queue.

/* put an rtp packet in queue. It is called by rtp_parse()*/
void rtp_putq(queue_t *q, mblk_t *mp)
{
        mblk_t *tmp;
        rtp_header_t *rtp=(rtp_header_t*)mp->b_rptr,*tmprtp;
        /* insert message block by increasing time stamp order : the last (at 
the bottom)
                message of the queue is the newest*/
        g_message("rtp_putq(): Enqueuing packet with ts=%i",rtp->timestamp);
        tmp=q->q_last;
        
        /* Modify by Peter Wang */
        if ((tmp==NULL) ||
 RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(((rtp_header_t 
*)tmp->b_rptr)->timestamp,rtp->timestamp)) {
                putq(q,mp);
                return;
        }
        /* we look at the queue from bottom to top, because enqueued packets 
have a better chance
        to be enqueued at the bottom, since there are surely newer */
        while (tmp!=NULL)
        {
                tmprtp=(rtp_header_t*)tmp->b_rptr;
                g_message("rtp_putq(): Seeing packet with 
ts=%i",tmprtp->timestamp);
                
                if (rtp->timestamp == tmprtp->timestamp)
                {
                        if (rtp->seq_number== tmprtp->seq_number)
                        {
                                /* this is a duplicated packet. Don't queue it 
*/
                                g_message("rtp_putq: duplicated message.");
                                freemsg(mp);
                                return;
                        }
#if 0
                        else if (rtp->paytype==tmprtp->paytype){
                                /* else link it to the already present packet */
                                tmp->b_cont->b_cont=mp->b_cont;
                                /* free the header message*/
                                freeb(mp);
                                return;
                        }
#endif
                        /* else this is a different packet. It must be queued */
                        insq(q,tmp->b_next,mp);
                        return;
                }
                if 
RTP_TIMESTAMP_IS_STRICTLY_NEWER_THAN(rtp->timestamp,tmprtp->timestamp)
                {
                        /* insert mp just before tmp */
                        insq(q,tmp->b_next,mp);
                        g_message("mp=%x inserted before %x. q->q_first=%i, 
q->q_last=%i",
                                                mp,
                                                tmp,
                                                
((rtp_header_t*)q->q_first->b_rptr)->timestamp,
                                                
((rtp_header_t*)q->q_last->b_rptr)->timestamp);
                        return;
                }
                tmp=tmp->b_prev;
        }
        /* this packet is the oldest, it has to be 
        placed on top of the queue */
        insq(q,q->q_first,mp);
        
}




--------------------------------------------------------
欢迎使用my169免费邮箱系统 http://webmail.my169.com



reply via email to

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