src/scheduler.h

00001 /*
00002   The oRTP library is an RTP (Realtime Transport Protocol - rfc3550) stack.
00003   Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef SCHEDULER_H
00021 #define SCHEDULER_H
00022 
00023 #include "ortp/rtpsession.h"
00024 #include "ortp/sessionset.h"
00025 #include "rtptimer.h"
00026 
00027 
00028 struct _RtpScheduler {
00029  
00030         RtpSession *list;       /* list of scheduled sessions*/
00031         SessionSet      all_sessions;  /* mask of scheduled sessions */
00032         int             all_max;                /* the highest pos in the all mask */
00033         SessionSet  r_sessions;         /* mask of sessions that have a recv event */
00034         int             r_max;
00035         SessionSet      w_sessions;             /* mask of sessions that have a send event */
00036         int             w_max;
00037         SessionSet      e_sessions;     /* mask of session that have error event */
00038         int             e_max;
00039         int max_sessions;               /* the number of position in the masks */
00040   /* GMutex  *unblock_select_mutex; */
00041         ortp_cond_t   unblock_select_cond;
00042         ortp_mutex_t    lock;
00043         ortp_thread_t thread;
00044         int thread_running;
00045         struct _RtpTimer *timer;
00046         uint32_t time_;       /*number of miliseconds elapsed since the start of the thread */
00047         uint32_t timer_inc;     /* the timer increment in milisec */
00048 };
00049 
00050 typedef struct _RtpScheduler RtpScheduler;
00051         
00052 RtpScheduler * rtp_scheduler_new(void);
00053 void rtp_scheduler_set_timer(RtpScheduler *sched,RtpTimer *timer);
00054 void rtp_scheduler_start(RtpScheduler *sched);
00055 void rtp_scheduler_stop(RtpScheduler *sched);
00056 void rtp_scheduler_destroy(RtpScheduler *sched);
00057 
00058 void rtp_scheduler_add_session(RtpScheduler *sched, RtpSession *session);
00059 void rtp_scheduler_remove_session(RtpScheduler *sched, RtpSession *session);
00060 
00061 void * rtp_scheduler_schedule(void * sched);
00062 
00063 #define rtp_scheduler_lock(sched)       ortp_mutex_lock(&(sched)->lock)
00064 #define rtp_scheduler_unlock(sched)     ortp_mutex_unlock(&(sched)->lock)
00065 
00066 /* void rtp_scheduler_add_set(RtpScheduler *sched, SessionSet *set); */
00067 
00068 RtpScheduler * ortp_get_scheduler(void);
00069 #endif

Generated on Thu Apr 5 18:59:20 2007 for oRTP by  doxygen 1.5.1