linphone-developers
[Top][All Lists]
Advanced

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

[Linphone-developers] Problem of ortp library


From: xiang duan
Subject: [Linphone-developers] Problem of ortp library
Date: Fri, 11 Feb 2011 17:39:45 +0800

Dear linphone team,

I used ortp library to transfer some data in android app.Two RtpSession created in native code,one for sending and another for receiving,method of rtp_session_destroy used to destroy these two RtpSession when exiting.

The app is ok ,but it couldn't receive data when I exit and restart.I know the rtp_unint() method has bean called.

If something wrong please let me know,thanks.

#include "ortp/ortp.h"
#include <android/log.h>
#include <string.h>
#include <stdlib.h>
#include "rtp.h"

RtpSession *session;
RtpSession *sessionr;
uint32_t user_ts=0;
char* ssrc;
static char* TAG="rtp";
ortp_thread_t threadid;

int cond=1;

void rtp_send(char *data){
    int i;
    int error;
    error=rtp_session_send_with_ts(session,data,320,user_ts);
    user_ts+=160;
}

void stop_handler(int signum)
{
cond=0;
}

static void* receive_init(RtpSession *s){
char buffer[320];
int err;
uint32_t ts=0;
int stream_received=0;
FILE *outfile;
int local_port;
int have_more;
int i;
while(cond)
{
have_more=1;
while (have_more){
err=rtp_session_recv_with_ts(s,buffer,320,ts,&have_more);
if (err>0) stream_received=1;
                __android_log_print(ANDROID_LOG_DEBUG,TAG,"%d",err);
// this is to avoid to write to disk some silence before the first RTP packet is returned
if ((stream_received) && (err>0)) {
   //i received some data
                             callback(buffer); 
}
ts+=160;
}
//ortp_message("Receiving packet.");
}
}
void rtp_stoprecv(){
    stop_handler(0);
}

int rtp_init(char* addr,int port){
    
int jittcomp=40;
bool_t adapt=TRUE;

ortp_init();
ortp_scheduler_init();
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR);
session=rtp_session_new(RTP_SESSION_SENDONLY);
rtp_session_set_scheduling_mode(session,1);
rtp_session_set_blocking_mode(session,1);
rtp_session_set_connected_mode(session,TRUE);
rtp_session_set_remote_addr(session,addr,port);
rtp_session_set_payload_type(session,0);
ssrc=getenv("SSRC");
if (ssrc!=NULL) {
printf("using SSRC=%i.\n",atoi(ssrc));
rtp_session_set_ssrc(session,atoi(ssrc));
}


sessionr=rtp_session_new(RTP_SESSION_RECVONLY);
rtp_session_set_scheduling_mode(sessionr,1);
rtp_session_set_blocking_mode(sessionr,1);
rtp_session_set_local_addr(sessionr,"0.0.0.0",5006);
rtp_session_set_connected_mode(sessionr,TRUE);
rtp_session_set_symmetric_rtp(sessionr,TRUE);
rtp_session_enable_adaptive_jitter_compensation(sessionr,adapt);
rtp_session_set_jitter_compensation(sessionr,jittcomp);
rtp_session_set_payload_type(sessionr,0);
//rtp_session_signal_connect(sessionr,"ssrc_changed",(RtpCallback)ssrc_cb,0);
rtp_session_signal_connect(sessionr,"ssrc_changed",(RtpCallback)rtp_session_reset,0);

 __android_log_write(ANDROID_LOG_DEBUG,TAG,"init successfully");
         ortp_thread_create(&threadid,0,(void*(*)(void*))receive_init,sessionr);
    
return 1;
}

int rtp_uninit(){
rtp_session_destroy(session);
rtp_session_destroy(sessionr);
ortp_exit();
ortp_global_stats_display();
         __android_log_write(ANDROID_LOG_DEBUG,TAG,"uninit successfully");
return 1;
}


reply via email to

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