RTP connection without SIP and SDP between 2 endopoint

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

 



Hi all
   I've created RTP connection between two Endpoint without using SIP and SDP protocls. I've created media endpoint and pool and ioqueue and created rtp&rtcp port by pjmedia_transport_udp_create2 and attached by pjmedia_transport_attach and called by pj_ioqueue_poll when i create a RTP packet via packETH threre are no acction in on_rx_RTP and on_rx_tcp.
rtpMediaTester is the major configuration function. 
any body has IDEA.
best 
abbas  

int rtpMediaTester(void)
{

	unsigned i;
	pj_str_t s;
	pj_status_t status;
	char ip_addr[32];
	pj_uint16_t	rtp_port;

	pj_ioqueue_t   ioqueue;


	pj_sockaddr_in dstaddr, srcaddr;

	/* Must init PJLIB first */

	struct media_stream audio;
	int c;
	unsigned count = 0, net_event_count = 0;
	pj_thread_t **Dptr_thread ,*ptr_thread ; 
	pjmedia_stream_info siTMP;	
	pj_str_t tstSTR;
	pj_time_val max_timeout = {0,10};
	pj_time_val timeout = { 0, 0};
			timeout.sec = timeout.msec = 0;

	status = pj_init();
	if (status != PJ_SUCCESS)
		return 1;
	//pj_bzero(&audio , sizeof(audio));
	/* Get local IP address for the default IP address */
	{
		const pj_str_t *hostname;
		pj_sockaddr_in tmp_addr;
		char *addr;
		    int c;
		

		/* Bind server socket. */
	//	pj_bzero(&dstaddr, sizeof(dstaddr));
	//	dstaddr.sin_family = pj_AF_INET();
	//	dstaddr.sin_port = pj_htons(RTP_START_PORT);
	//	dstaddr.sin_addr = pj_inet_addr(pj_cstr(&s, CADDRESS));


		/* Bind client socket. */
		pj_bzero(&srcaddr, sizeof(srcaddr));
		srcaddr.sin_family = pj_AF_INET();
		srcaddr.sin_port = pj_htons(RTP_START_PORT);

		srcaddr.sin_addr = pj_inet_addr(pj_cstr(&s, SADDRESS));


		//hostname = pj_gethostname();
		//  pj_sockaddr_in_init(&tmp_addr, hostname, 0);
		//  addr = pj_inet_ntoa(tmp_addr.sin_addr);
		pj_ansi_strcpy(ip_addr, SADDRESS);
	}

	/* Init defaults */
	app.max_calls = 1;
	app.thread_count = 1;
	app.sip_port = 5060;
	app.rtp_start_port = RTP_START_PORT;
	app.local_addr = pj_str(ip_addr);
	app.log_level = 5;
	app.app_log_level = 3;
	app.log_filename = NULL;
	
	/* Must create a pool factory before we can allocate any memory. */
		pj_caching_pool_init(&app.cp, &pj_pool_factory_default_policy, 0);


	/* Create application pool for misc. */
	app.pool = pj_pool_create(&app.cp.factory, "app", 1000, 1000, NULL);
	/**/
	status = pjmedia_endpt_create(&app.cp.factory, NULL, 1, &app.med_endpt);
	
	/* Create ioqueue. */
	status = pj_ioqueue_create( app.pool, PJ_IOQUEUE_MAX_HANDLES, &app.ioqueue);
	
	/* RTP port counter */
	rtp_port = (pj_uint16_t)(app.rtp_start_port & 0xFFFE);

	status = pjmedia_transport_udp_create2(app.med_endpt,"rtptester",&app.local_addr,rtp_port, 0, &audio.transport);
	
		pj_bzero(&dstaddr, sizeof(dstaddr));
		dstaddr.sin_family = pj_AF_INET();
		dstaddr.sin_port = pj_htons(RTP_START_PORT);
		dstaddr.sin_addr = pj_inet_addr(pj_cstr(&s, CADDRESS));

		//audio.si.rem_addr.ipv4 = dstaddr;
//		pj_bzero(&audio,sizeof(audio));
//		pj_memcpy(&audio.si.rem_addr.ipv4,&dstaddr , sizeof(dstaddr));
		
   
		pj_bzero(&siTMP ,sizeof(pjmedia_stream_info));
		siTMP.type = PJMEDIA_TYPE_AUDIO;
		siTMP.proto = PJMEDIA_TP_PROTO_RTP_AVP;
		  pj_bzero(&tstSTR,sizeof(tstSTR));
		 tstSTR = pj_str(CADDRESS);
				
		 //pj_memcpy(&tstSTR ,pj_str(CADDRESS),sizeof(tstSTR));

		status = pj_sockaddr_init(pj_AF_INET(), &audio.si.rem_addr,&tstSTR , RTP_START_PORT);
		
		pj_memcpy(&audio.si.rem_addr ,&tstSTR,sizeof(tstSTR));

		status = pj_sockaddr_init(pj_AF_INET(), &audio.si.rem_addr,&tstSTR , RTP_START_PORT+1);
		pj_memcpy(&audio.si.rem_rtcp ,&tstSTR,sizeof(tstSTR));
		
		//pj_memcpy(&audio.si.rem_addr ,tstSTR,sizeof(tstSTR));
		status = pjmedia_transport_attach(audio.transport, &audio, 
		&audio.si.rem_addr, 
		&audio.si.rem_rtcp, 
		sizeof(pj_sockaddr_in),
		&on_rx_rtp,
		&on_rx_rtcp);
		// pj_thread_t **Dptr_thread ,*ptr_thread ; 

		status = pj_thread_create( app.pool, "media", &media_thread, &audio,	0, 0, &audio.thread);
		/* Set maximum timed out entries to process in a single poll. */
		pj_timer_heap_set_max_timed_out_per_poll(&app.timer_heap,	PJSIP_MAX_TIMED_OUT_ENTRIES);
		timeout.msec = 10;	
		
		//c = pj_timer_heap_poll( app.med_endpt->timer_heap, &timeout );
		//pj_bzero(&ioqueue,sizeof(ioqueue));
		do{
			
			c = pj_timer_heap_poll( &app.timer_heap, &timeout );
			if (c > 0)
				count += c;
			if (timeout.msec >= 1000) timeout.msec = 999;

			if ((timeout.sec>max_timeout.sec)||((timeout.sec ==max_timeout.sec)&&(timeout.msec>max_timeout.msec)))
			{
				timeout = max_timeout;
			}

		do {
					
			c = pj_ioqueue_poll(app.ioqueue,&timeout);
			if (c < 0) {				
				pj_thread_sleep(PJ_TIME_VAL_MSEC(timeout));
							
			} else if (c == 0) {
				break;
			} else {
				net_event_count += c;
				timeout.sec = timeout.msec = 0;
			}
			
		}while( c>0 );

		}while (1);
	/* Shutdown PJLIB */
	pj_shutdown();
	return 0;
}



      



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux