sipxmedialib  Version 3.3
RTCPTimer.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 // Border Guard
13 #ifndef _RTCPTimer_h
14 #define _RTCPTimer_h
15 
16 #include "rtcp/RtcpConfig.h"
17 
18 // Includes
19 #ifndef WIN32
20 #include <time.h>
21 #endif
22 
23 #include "IRTCPConnection.h"
24 #include "IRTCPSession.h"
25 
26 #ifdef __pingtel_on_posix__
27 #include "os/OsTime.h"
28 #include "os/OsCallback.h"
29 #include "os/OsTimer.h"
30 #endif
31 
32 
33 // Defines
34 #define MILLI2SECS 1000
35 #define MILLI2NANO 1000000
36 
53 {
54 
55 // Public Methods
56 public:
57 
77  CRTCPTimer(unsigned long ulTimerPeriod);
78 
79 
100  virtual ~CRTCPTimer(void);
101 
122  bool Initialize(void);
123 
144  virtual void SetReportTimer(unsigned long ulTimerPeriod);
145 
162  virtual unsigned long GetReportTimer(void);
163 
186  virtual void RTCPReportingAlarm(IRTCPConnection *piRTCPConnection=NULL,
187  IRTCPSession *piRTCPSession=NULL) {};
188 
189 
190 protected: // Protected Methods
191 
210  bool Shutdown(void);
211 
212 private: // Private Methods
213 
214 #ifdef WIN32 /* [ */
215 
234  bool CreateTimerThread(void);
235 
236 
237 
256  static unsigned int __stdcall TimerThreadProc(void * lpParameter);
257 
258 #elif defined(_VXWORKS) /* ] [ */
259 
279  static void ReportingAlarm(timer_t tTimer, intptr_t iArgument);
280 
281 #elif defined(__pingtel_on_posix__) /* ] [ */
282 
283  static void ReportingAlarm(const intptr_t userData, const intptr_t eventData);
284 
285 #endif /* ] */
286 
287 
288 private: // Private Data Members
289 
300  unsigned long m_ulTimerPeriod;
301 #ifdef _VXWORKS /* [ */
302  struct itimerspec m_stTimeout;
303 #endif /* ] */
304 
305 
306 #ifdef WIN32 /* [ */
307 
317  HANDLE m_hTerminateEvent;
318 
329  HANDLE m_hTimerThread;
330 
331 #elif defined(_VXWORKS) /* ] [ */
332 
342  timer_t m_tTimer;
343 
344 #elif defined(__pingtel_on_posix__)
345  OsTime * m_pTimeout;
346  OsCallback * m_pCallback;
347  OsTimer * m_pTimer;
348 #endif /* ] */
349 
350 };
351 
370 inline void CRTCPTimer::SetReportTimer(unsigned long ulTimerPeriod)
371 {
372 
373  m_ulTimerPeriod = ulTimerPeriod;
374 #ifdef _VXWORKS /* [ */
375  // Set the next fire value
376  m_stTimeout.it_value.tv_sec = ulTimerPeriod / MILLI2SECS;
377  m_stTimeout.it_value.tv_nsec = (ulTimerPeriod % MILLI2SECS) * MILLI2NANO;
378 
379  // Set the next fire interval (period timer) as the value
380  m_stTimeout.it_interval.tv_sec = ulTimerPeriod / MILLI2SECS;
381  m_stTimeout.it_interval.tv_nsec = (ulTimerPeriod % MILLI2SECS) * MILLI2NANO;
382 #endif /* ] */
383 
384 }
385 
402 inline unsigned long CRTCPTimer::GetReportTimer(void)
403 {
404 
405  return(m_ulTimerPeriod);
406 
407 }
408 
409 #endif
#define MILLI2NANO
Definition: RTCPTimer.h:35
#define MILLI2SECS
Definition: RTCPTimer.h:34
virtual ~CRTCPTimer(void)
bool Shutdown(void)
bool Initialize(void)
virtual unsigned long GetReportTimer(void)
Definition: RTCPTimer.h:402
virtual void RTCPReportingAlarm(IRTCPConnection *piRTCPConnection=NULL, IRTCPSession *piRTCPSession=NULL)
Definition: RTCPTimer.h:186
unsigned long m_ulTimerPeriod
Definition: RTCPTimer.h:300
virtual void SetReportTimer(unsigned long ulTimerPeriod)
Definition: RTCPTimer.h:370
Definition: RTCPTimer.h:52
CRTCPTimer(unsigned long ulTimerPeriod)