• 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_JB_SESSION_DURATION_TIMER_H_INCLUDED
19 #define PVMF_JB_SESSION_DURATION_TIMER_H_INCLUDED
20 
21 #ifndef OSCL_BASE_H_INCLUDED
22 #include "oscl_base.h"
23 #endif
24 #ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
25 #include "pvmf_media_clock.h"
26 #endif
27 #ifndef PVLOGGER_H_INCLUDED
28 #include "pvlogger.h"
29 #endif
30 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
31 #include "oscl_scheduler_ao.h"
32 #endif
33 #ifndef PVMF_RETURN_CODES_H_INCLUDED
34 #include "pvmf_return_codes.h"
35 #endif
36 #ifndef PVMF_SM_TUNABLES_H_INCLUDED
37 #include "pvmf_sm_tunables.h"
38 #endif
39 
40 
41 /**
42  * Observer class for the session duration timer AO
43  */
44 class PvmfJBSessionDurationTimerObserver
45 {
46     public:
~PvmfJBSessionDurationTimerObserver()47         virtual ~PvmfJBSessionDurationTimerObserver() {}
48         /**
49          * A timer event, indicating that the timer has expired.
50          */
51         virtual void PVMFJBSessionDurationTimerEvent() = 0;
52 };
53 
54 /**
55  * Sessionduration timer object to Jitter Buffer node.
56  * This object generates event when the session duration expires
57  */
58 class PvmfJBSessionDurationTimer : public OsclTimerObject
59 {
60     public:
61         PvmfJBSessionDurationTimer(PvmfJBSessionDurationTimerObserver* aObserver);
62 
63         virtual ~PvmfJBSessionDurationTimer();
64 
65         /** Start Timer */
66         PVMFStatus Start();
67 
68         PVMFStatus setSessionDurationInMS(uint32 duration);
69 
getSessionDurationInMS()70         uint32 getSessionDurationInMS()
71         {
72             return iSessionDurationInMS;
73         }
74 
75         /** Stop Timer events */
76         PVMFStatus Stop();
77 
78         virtual PVMFStatus Cancel();
79 
IsTimerStarted()80         bool IsTimerStarted()
81         {
82             return iStarted;
83         }
84 
SetEstimatedServerClock(PVMFMediaClock * aEstimatedServerClock)85         void SetEstimatedServerClock(PVMFMediaClock* aEstimatedServerClock)
86         {
87             iEstimatedServerClock = aEstimatedServerClock;
88         }
89 
90         void EstimatedServerClockUpdated();
91 
GetExpectedEstimatedServClockValAtSessionEnd()92         uint32 GetExpectedEstimatedServClockValAtSessionEnd()
93         {
94             return iExpectedEstimatedServClockValAtSessionEnd;
95         }
96 
setCurrentMonitoringIntervalInMS(uint32 aCurrentMonitoringIntervalInMS)97         void setCurrentMonitoringIntervalInMS(uint32 aCurrentMonitoringIntervalInMS)
98         {
99             iCurrentMonitoringIntervalInMS = aCurrentMonitoringIntervalInMS;
100         }
101 
GetMonitoringIntervalElapsed()102         uint64 GetMonitoringIntervalElapsed()
103         {
104             return iMonitoringIntervalElapsed;
105         }
106 
UpdateElapsedSessionDuration(uint32 aElapsedTime)107         void UpdateElapsedSessionDuration(uint32 aElapsedTime)
108         {
109             iElapsedSessionDurationInMS += aElapsedTime;
110         }
111 
GetElapsedSessionDurationInMS()112         uint32 GetElapsedSessionDurationInMS()
113         {
114             return iElapsedSessionDurationInMS;
115         }
116 
GetEstimatedServClockValAtLastCancel()117         uint32 GetEstimatedServClockValAtLastCancel()
118         {
119             return iEstimatedServClockValAtLastCancel;
120         }
121 
ResetEstimatedServClockValAtLastCancel()122         void ResetEstimatedServClockValAtLastCancel()
123         {
124             iEstimatedServClockValAtLastCancel = 0;
125             if (iEstimatedServerClock != NULL)
126             {
127                 uint32 timebase32 = 0;
128                 bool overflowFlag = false;
129                 iEstimatedServerClock->GetCurrentTime32(iEstimatedServClockValAtLastCancel, overflowFlag,
130                                                         PVMF_MEDIA_CLOCK_MSEC, timebase32);
131             }
132         }
133 
134     private:
135         void Run();
136 
137         uint32 iCurrentMonitoringIntervalInMS;
138         uint32 iSessionDurationInMS;
139         uint32 iElapsedSessionDurationInMS;
140         PvmfJBSessionDurationTimerObserver* iObserver;
141         PVLogger* ipLogger;
142         bool iStarted;
143 
144         PVMFMediaClock iClock;
145         PVMFTimebase_Tickcount iClockTimeBase;
146         uint32 iTimerStartTimeInMS;
147         uint64 iMonitoringIntervalElapsed;
148 
149         PVMFMediaClock* iEstimatedServerClock;
150         uint32 iEstimatedServClockValAtLastCancel;
151         uint32 iExpectedEstimatedServClockValAtSessionEnd;
152 
153         PVLogger *ipClockLoggerSessionDuration;
154 };
155 
156 
157 #endif // PVMF_JB_SESSION_DURATION_TIMER_H_INCLUDED
158 
159 
160 
161 
162