⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ortp.c

📁 ortp协议栈(实时传输协议)
💻 C
字号:
/*  The oRTP LinPhone RTP library intends to provide basics for a RTP stack.  Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org  This library is free software; you can redistribute it and/or  modify it under the terms of the GNU Lesser General Public  License as published by the Free Software Foundation; either  version 2.1 of the License, or (at your option) any later version.  This library is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  Lesser General Public License for more details.  You should have received a copy of the GNU Lesser General Public  License along with this library; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include "ortp.h"rtp_stats_t ortp_global_stats;#ifdef ENABLE_MEMCHECKgint ortp_allocations=0;#endif#ifdef BUILD_SCHEDULERstatic RtpScheduler *ortp_scheduler;#endif#ifdef HAVE_GLIBvoid dummy_log(const gchar *log_domain,                                             GLogLevelFlags log_level,                                             const gchar *message,                                             gpointer user_data){	return;}#endif/** *ortp_init: * *	Initialize the oRTP library. You should call this function first before using *	oRTP API.**/ void ortp_init(){#ifdef HAVE_GLIB	g_log_set_handler ("oRTP", G_LOG_LEVEL_MESSAGE, dummy_log, NULL);	if (!g_thread_supported()) g_thread_init (NULL);#endif	av_profile_init(&av_profile);	ortp_global_stats_reset();}/** *ortp_scheduler_init: * *	Initialize the oRTP scheduler. You only have to do that if you intend to use the *	scheduled mode of the #RtpSession in your application. *	**/void ortp_scheduler_init(){#ifdef BUILD_SCHEDULER#ifdef HOST_IS_HPUX	/* on hpux, we must block sigalrm on the main process, because signal delivery	is ?random?, well, sometimes the SIGALRM goes to both the main thread and the 	scheduler thread */	sigset_t set;	sigemptyset(&set);	sigaddset(&set,SIGALRM);	sigprocmask(SIG_BLOCK,&set,NULL);#endif /*HOST_IS_HPUX*/	ortp_scheduler=rtp_scheduler_new();	rtp_scheduler_start(ortp_scheduler);	//sleep(1);#else	g_warning("ortp_init_scheduler: ERROR: scheduler is not compiled !");#endif}/** *ortp_exit: * * Gracefully uninitialize the library, including shutdowning the scheduler if it was started. *	**/void ortp_exit(){#ifdef BUILD_SCHEDULER	if (ortp_scheduler!=NULL)	{		rtp_scheduler_destroy(ortp_scheduler);		ortp_scheduler=NULL;	}#endif}/** *ortp_get_scheduler: * *	Returns a pointer to the scheduler, NULL if it was not running. *	The application developer should have to call this function. * *Returns: a pointer to the scheduler.**/#ifdef BUILD_SCHEDULERRtpScheduler * ortp_get_scheduler(){	if (ortp_scheduler==NULL) g_error("Cannot use the scheduled mode: the scheduler is not "									"started. Call ortp_scheduler_init() at the begginning of the application.");	return ortp_scheduler;}#endif#ifdef HAVE_GLIBvoid ortp_log( const gchar *log_domain,                                             GLogLevelFlags log_level,                                             const gchar *message,                                             gpointer user_data){	fprintf((FILE*) user_data,"%s: %s\n",log_domain,message);}#endif#ifndef TARGET_IS_HPUXKERNEL/** *ortp_set_debug_file: *@domain:	one of "oRTP" or "oRTP-stats" logging domain. *@file: a FILE pointer where to output the messages from the domain. ***/void ortp_set_debug_file(gchar *domain,FILE *file){#ifdef HAVE_GLIB	if (file!=NULL)		g_log_set_handler (domain, G_LOG_LEVEL_MESSAGE, ortp_log, (gpointer)file);	else g_log_set_handler (domain, G_LOG_LEVEL_MESSAGE, dummy_log, NULL);#endif}#endifvoid ortp_global_stats_display(){	rtp_stats_display(&ortp_global_stats,"Global statistics");#ifdef ENABLE_MEMCHECK		printf("Unfreed allocations: %i\n",ortp_allocations);#endif}void rtp_stats_display(rtp_stats_t *stats, char *header){#ifdef HAVE_GLIB	g_log("oRTP-stats",G_LOG_LEVEL_MESSAGE,#else	printf(#endif			"\n   %s :\n packet_sent=%lld\n sent=%lld bytes\n packet_recv=%lld\n hw_recv=%lld bytes\n recv=%lld bytes\n unavaillable=%lld bytes\n outoftime=%lld\n bad=%lld\n discarded=%lld\n",			header,stats->packet_sent,stats->sent,stats->packet_recv,stats->hw_recv, stats->recv,stats->unavaillable,			stats->outoftime,stats->bad,stats->discarded);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -