• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 #ifndef PVMF_RTCP_TIMER_H_INCLUDED
19 #define PVMF_RTCP_TIMER_H_INCLUDED
20 
21 #ifndef OSCL_BASE_H_INCLUDED
22 #include "oscl_base.h"
23 #endif
24 #ifndef PVLOGGER_H_INCLUDED
25 #include "pvlogger.h"
26 #endif
27 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
28 #include "oscl_scheduler_ao.h"
29 #endif
30 #ifndef PVMF_RETURN_CODES_H_INCLUDED
31 #include "pvmf_return_codes.h"
32 #endif
33 #ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
34 #include "pvmf_simple_media_buffer.h"
35 #endif
36 #ifndef PVMF_MEDIA_DATA_H_INCLUDED
37 #include "pvmf_media_data.h"
38 #endif
39 #ifndef PVMF_RESIZABLE_SIMPLE_MEDIAMSG_H_INCLUDED
40 #include "pvmf_resizable_simple_mediamsg.h"
41 #endif
42 #ifndef PVMF_SM_TUNABLES_H_INCLUDED
43 #include "pvmf_sm_tunables.h"
44 #endif
45 
46 /*
47 oscl_mem_aligned_size(sizeof(PVMFMediaData)) +
48 oscl_mem_aligned_size(sizeof(OsclRefCounterDA)) +
49 oscl_mem_aligned_size(sizeof(MediaDataCleanupDA)) +
50 sizeof(PVMFMediaMsgHeader));
51 */
52 #define PVMF_MEDIA_DATA_CLASS_SIZE 128
53 
54 /* RTCP Packet Mem Pool Allocator */
55 class PVMFRTCPMemPool
56 {
57     public:
ipMediaDataMemPool(NULL)58         PVMFRTCPMemPool(uint32 aNumRTCPBufs = DEFAULT_RTCP_MEM_POOL_BUFFERS): ipMediaDataMemPool(NULL)
59         {
60             ipMediaDataMemPool = OSCL_NEW(OsclMemPoolFixedChunkAllocator, (aNumRTCPBufs, PVMF_MEDIA_DATA_CLASS_SIZE));
61         }
62 
~PVMFRTCPMemPool()63         ~PVMFRTCPMemPool()
64         {
65             if (ipMediaDataMemPool)
66             {
67                 ipMediaDataMemPool->removeRef();
68             }
69         }
70 
GetMediaDataImpl(uint32 size)71         OsclSharedPtr<PVMFMediaDataImpl> GetMediaDataImpl(uint32 size)
72         {
73             return (ipRTCPRRMsgBufAlloc->allocate(size));
74         }
75 
76         PVMFResizableSimpleMediaMsgAlloc* ipRTCPRRMsgBufAlloc;
77         /* Memory pool for media data objects */
78         OsclMemPoolFixedChunkAllocator* ipMediaDataMemPool;
79 };
80 
81 class PvmfRtcpTimer;
82 
83 /**
84  * Observer class for the rtcp timer AO
85  */
86 class PvmfRtcpTimerObserver
87 {
88     public:
~PvmfRtcpTimerObserver()89         virtual ~PvmfRtcpTimerObserver() {}
90         /**
91          * A timer event, indicating that the RTCP timer has expired.
92          */
93         virtual void RtcpTimerEvent() = 0;
94 };
95 
96 /**
97  * RTCP timer object to Jitter Buffer node. This object generates events at
98  * specified RTCP time intervals
99  */
100 class PvmfRtcpTimer : public OsclTimerObject
101 {
102     public:
103         PvmfRtcpTimer(PvmfRtcpTimerObserver* aObserver);
104 
105         virtual ~PvmfRtcpTimer();
106 
107         /** Start RTCP Timer */
108         PVMFStatus Start();
109 
110         /** Reset RTCP Timer */
111         PVMFStatus setRTCPInterval(uint32 rtcpTimeIntervalInMicroSecs);
112 
113         /** Stop Timer events */
114         PVMFStatus Stop();
115 
getRTCPBuffAlloc()116         PVMFRTCPMemPool* getRTCPBuffAlloc()
117         {
118             return &iRTCPBufAlloc;
119         }
120 
121     private:
122         void Run();
123 
124         PVMFResizableSimpleMediaMsgAlloc* createRTCPRRBufAllocReSize();
125 
126         uint32 iRTCPTimeIntervalInMicroSecs;
127         PvmfRtcpTimerObserver* iObserver;
128         PVLogger* ipLogger;
129         bool iStarted;
130 
131         PVMFRTCPMemPool iRTCPBufAlloc;
132         OsclMemPoolResizableAllocator* iBufAlloc;
133         PVMFResizableSimpleMediaMsgAlloc* iImplAlloc;
134 };
135 #endif // PVMF_RTCP_TIMER_H_INCLUDED
136