[pjsip] Conf por hangs after random time

Manuel Quinteiro mquinteiro at cic-systems.com
Tue Apr 29 13:44:51 EDT 2008


Hi!

I have created my own port, every think works ok, but some times, after random 
time the callbacks get_frame and  put_frame never call again.

Do you see something rong?

Some parts of code are:

main() {
....
	status = pjsua_create();
		/* Init pjsua */
	{
		pjsua_config cfg;
		pjsua_logging_config log_cfg;
		pjsua_config_default(&cfg);
		cfg.cb.on_incoming_call = &on_incoming_call;
		cfg.cb.on_call_media_state = &on_call_media_state;
		cfg.cb.on_call_state = &on_call_state;

		pjsua_logging_config_default(&log_cfg);
		log_cfg.console_level = 0; 

		
		status = pjsua_init(&cfg, &log_cfg, NULL);
		
		if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status);
	}

	pjmedia_myprot_port_create(pjsua_var.pool, 44100,  1,288, 16, &myport, 
serverPort);

	pjsua_conf_add_port(pjsua_var.pool, myport, &numPort);
.
.
}


static void on_call_media_state(pjsua_call_id call_id)
{
	pjsua_call_info ci;
	
	pjsua_call_get_info(call_id, &ci);
	if (ci.media_status == PJSUA_CALL_MEDIA_ACTIVE) {
		pjsua_conf_connect(ci.conf_slot, numPort);
		pjsua_conf_connect(numPort, ci.conf_slot);
	}
}


PJ_DEF(pj_status_t) pjmedia_ucog_port_create( pj_pool_t *pool,
			unsigned sampling_rate,
			unsigned channel_count,
			unsigned samples_per_frame,
			unsigned bits_per_sample,
			pjmedia_port **p_port,
			int mixerPort)
{
	
	pjmedia_port *port;
	const pj_str_t name = pj_str("ucog-port");

	PJ_ASSERT_RETURN(pool && p_port, PJ_EINVAL);

	port = PJ_POOL_ZALLOC_T(pool, pjmedia_port);
	PJ_ASSERT_RETURN(pool != NULL, PJ_ENOMEM);

	pjmedia_port_info_init(&port->info, &name, SIGNATURE, sampling_rate,
							channel_count, bits_per_sample, samples_per_frame);

	port->get_frame = &ucog_get_frame;
	port->put_frame = &ucog_put_frame;
	port->on_destroy = &ucog_on_destroy;

	ntrama=0;
	*p_port = port;
	
	
	slen=sizeof(si_other);
	
.
.
.
	
	// Creamos Feedback para el interlocutor.
	
	for(int i=0;i< 44100;i++){
		senalSeno[i]= sin(i/11)*15000;
	}
	txframe=0;
	return PJ_SUCCESS;
}


static pj_status_t ucog_put_frame(pjmedia_port *this_port, 
								  const pjmedia_frame *frame)
{
	PJ_UNUSED_ARG(this_port);
	PJ_UNUSED_ARG(frame);

	if(frame->type==1) {
		procFrame(frame->buf, frame->size);
	}
	return PJ_SUCCESS;
}


static pj_status_t ucog_get_frame(pjmedia_port *this_port, 
								  pjmedia_frame *frame)
{
	
	frame->type = PJMEDIA_FRAME_TYPE_AUDIO;
	frame->size = this_port->info.samples_per_frame * 2;
	frame->timestamp.u32.lo += this_port->info.samples_per_frame;
	memcpy(frame->buf, senalSeno, frame->size);
	txframe++;
	return PJ_SUCCESS;
}


-- 
Manuel





More information about the pjsip mailing list