linphone-developers
[Top][All Lists]
Advanced

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

[Linphone-developers] ORTP Audio&Video Receiver


From: Pierluigi Cifani
Subject: [Linphone-developers] ORTP Audio&Video Receiver
Date: Mon, 21 Feb 2011 16:03:21 +0100

Hello guys, I have to set up a RTP server that is supposed to receive both audio and video in the same thread. I am posting you a snippet of my code just to see if you can help me out. 

The parameters set-up is this:

ortp_init();

ortp_scheduler_init();

ortp_set_log_file(rtpLog);

eXosip_guess_localip (AF_INET, localip, 128);


if (This->connection->video_mode) max=2;

else Debug::DbgLog(Id(This)|EDbgDebug,"Audio Only Session\n");


for (j=0; j<max; j++) {

session[j]=rtp_session_new(RTP_SESSION_RECVONLY);

rtp_session_set_scheduling_mode(session[j],1);

rtp_session_set_blocking_mode(session[j],1);


if (j == 0){

rtp_session_set_local_addr(session[j],localip, This->connection->audio_port);

rtp_session_set_remote_addr(session[j],This->connection->remote_ip,This->connection->audio_port);

rtp_session_set_payload_type(session[j],0); //payload for ulaw


} else {

Debug::DbgLog(Id(This)|EDbgDebug,"Setting up Video\n");

rtp_session_set_local_addr(session[j],localip, This->connection->video_port);

rtp_session_set_remote_addr(session[j],This->connection->remote_ip,This->connection->video_port);

rtp_session_set_payload_type(session[j],99); //payload for h264

}

rtp_session_set_recv_buf_size(session[j],1*1024*1024);

rtp_session_set_connected_mode(session[j],TRUE);

rtp_session_set_symmetric_rtp(session[j],TRUE);

rtp_session_enable_adaptive_jitter_compensation(session[j],TRUE);

rtp_session_set_jitter_compensation(session[j],160);

} //init sessions



The main receive loop, (where I make the select to check if there is information available in the sockets) looks like this:

a_sck = (int) rtp_session_get_rtp_socket(session[0]);

if (This->connection->video_mode) {

v_sck = (int) rtp_session_get_rtp_socket(session[1]);

Debug::DbgLog(Id(this)|EDbgDebug,"RTP Receiving Audio/Video Packets, Ports: %d/%d\n",

  this->connection->audio_port, this->connection->video_port);

}


while(This->cond){


FD_ZERO(&socks);

FD_SET(v_sck,&socks);

FD_SET(a_sck,&socks);


select(std::max(v_sck,a_sck)+1, &socks, NULL, NULL, NULL);


if (FD_ISSET(v_sck, &socks)){

this->HandleVideo(session[1],vts);

vts+=160;

}

if (FD_ISSET(a_sck, &socks)){

this->HandleAudio(session[0],ts);

ts+=160;

}

}

where HandleVideo and HandleAudio look like this (only posting HandleAudio, since HandleVideo is basically the same, and the problem is more noticeable in the Audio stream)

void CRtpServer::HandleAudio(RtpSession *session, uint32_t ts){

int  size;

unsigned char *buffer = NULL;


mblk_t *m=rtp_session_recvm_with_ts(session,ts);


if (m){

if (iFirstAudio){

iFirstAudio = false;

iFirstAudioTs = rtp_get_timestamp(m);

iFirstAudioSeq = rtp_get_seqnumber(m);

}

iLastSeqAudioRecv = rtp_get_seqnumber(m) - iFirstAudioSeq;


size = rtp_get_payload(m,&buffer);

OnRtpAudioFrame(buffer, size, rtp_get_timestamp(m) - iFirstAudioTs);

}

return;

}

 
What I'm having problems with is that there is a HUUUGE amount of lost packets, even on the same network; and when I mean huge, I'm not exaggerating, it's like 1 lost packet every 8 received (average), and with Wireshark receives all of the packets flawlessly and in a perfect sequence.

What could it be? is there some kind of parameter set wrongly? Thanks for any help guys, I would really appreciate it

reply via email to

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