oRTP分析
接口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()
{
static bool_t initialized=FALSE;
if (initialized) return;
initialized=TRUE;
#ifdef __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 /* __hpux */
__ortp_scheduler=rtp_scheduler_new();
rtp_scheduler_start(__ortp_scheduler);
}
struct _RtpScheduler {
RtpSession *list; /* list of scheduled sessions*/
SessionSet all_sessions; /* mask of scheduled sessions */
int all_max; /* the highest pos in the all mask */
SessionSet r_sessions; /* mask of sessions that have a recv event */
int r_max;
SessionSet w_sessions; /* mask of sessions that have a send event */
int w_max;
SessionSet e_sessions; /* mask of session that have error event */
int e_max;
int max_sessions; /* the number of position in the masks */
/* GMutex *unblock_select_mutex; */
ortp_cond_t unblock_select_cond;
ortp_mutex_t lock;
ortp_thread_t thread;
int thread_running;
struct _RtpTimer *timer;
uint32_t time_; /*number of miliseconds elapsed since the start of the thread */
uint32_t timer_inc; /* the timer increment in milisec */
};
typedef struct _RtpScheduler RtpScheduler;
在该接口中创建一个RtpScheduler类型的结构体__ortp_scheduler,并调用rtp_scheduler_init初始化它。
初始化完后调用rtp_scheduler_start启动调度任务
调度任务的执行体为rtp_scheduler_schedule,参数为调度结构体自身