• 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_EVENT_NOTIFIER_H
19 #define PVMF_JB_EVENT_NOTIFIER_H
20 
21 #ifndef OSCL_BASE_H_INCLUDED
22 #include "oscl_base.h"
23 #endif
24 
25 #ifndef PVLOGGER_H_INCLUDED
26 #include "pvlogger.h"
27 #endif
28 
29 #ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
30 #include "pvmf_media_clock.h"
31 #endif
32 
33 #ifndef PVMF_JITTER_BUFFER_COMMON_INTERNAL_H
34 #include "pvmf_jitter_buffer_common_internal.h"
35 #endif
36 
37 enum CLOCK_NOTIFICATION_INTF_TYPE
38 {
39     CLOCK_NOTIFICATION_INTF_TYPE_UNKNOWN,
40     CLOCK_NOTIFICATION_INTF_TYPE_NONDECREASING,
41     CLOCK_NOTIFICATION_INTF_TYPE_CLIENTPLAYBACK,
42     CLOCK_NOTIFICATION_INTF_TYPE_ESTIMATEDSERVER
43 };
44 
45 class PVMFJBEventNotifierObserver
46 {
47     public:
48         virtual void ProcessCallback(CLOCK_NOTIFICATION_INTF_TYPE aClockNotificationInterfaceType, uint32 aCallBkId, const OsclAny* aContext, PVMFStatus aStatus) = 0;
49 };
50 class PVMFJBEventNotificationRequestInfo;
51 class PVMFJBEventNotifierRequestInfo
52 {
53     public:
PVMFJBEventNotifierRequestInfo()54         PVMFJBEventNotifierRequestInfo(): ipRequestInfo(NULL)
55                 , iCallBackId(0) {}
56         PVMFJBEventNotificationRequestInfo* ipRequestInfo;
57         uint32  iCallBackId;
58 };
59 
60 class NonDecClkNotificationInterfaceObserver: public PVMFMediaClockNotificationsObs
61 {
62     public:
NonDecClkNotificationInterfaceObserver(Oscl_Vector<PVMFJBEventNotifierRequestInfo *,OsclMemAllocator> & aJBEvntNtfrRequestInfoVectNonDecClk)63         NonDecClkNotificationInterfaceObserver(Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator>& aJBEvntNtfrRequestInfoVectNonDecClk)
64                 : irJBEvntNtfrRequestInfoVectNonDecClk(aJBEvntNtfrRequestInfoVectNonDecClk)
65         {
66             ipLogger = PVLogger::GetLoggerObject("PVMFJBEventNotifier");
67         }
68         void ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 aDelta, const OsclAny* aContextData, PVMFStatus aStatus);
69         virtual void NotificationsInterfaceDestroyed();
70     private:
71         Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator>& irJBEvntNtfrRequestInfoVectNonDecClk;
72         PVLogger* ipLogger;
73 };
74 
75 class EstimatedSrvrClkNotificationInterfaceObserver: public PVMFMediaClockNotificationsObs
76 {
77     public:
EstimatedSrvrClkNotificationInterfaceObserver(Oscl_Vector<PVMFJBEventNotifierRequestInfo *,OsclMemAllocator> & aJBEvntNtfrRequestInfoVectEstimatedServClk)78         EstimatedSrvrClkNotificationInterfaceObserver(Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator>& aJBEvntNtfrRequestInfoVectEstimatedServClk)
79                 : irJBEvntNtfrRequestInfoVectEstimatedServClk(aJBEvntNtfrRequestInfoVectEstimatedServClk)
80         {
81             ipLogger = PVLogger::GetLoggerObject("PVMFJBEventNotifier");
82         }
83         void ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 aDelta, const OsclAny* aContextData, PVMFStatus aStatus);
84         virtual void NotificationsInterfaceDestroyed();
85     private:
86         Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator>& irJBEvntNtfrRequestInfoVectEstimatedServClk;
87         PVLogger* ipLogger;
88 };
89 
90 class ClientPlaybackClkNotificationInterfaceObserver: public PVMFMediaClockNotificationsObs
91 {
92     public:
ClientPlaybackClkNotificationInterfaceObserver(Oscl_Vector<PVMFJBEventNotifierRequestInfo *,OsclMemAllocator> & aJBEvntNtfrRequestInfoVectClientPlaybackClk)93         ClientPlaybackClkNotificationInterfaceObserver(Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator>& aJBEvntNtfrRequestInfoVectClientPlaybackClk):
94                 irJBEvntNtfrRequestInfoVectClientPlaybackClk(aJBEvntNtfrRequestInfoVectClientPlaybackClk)
95         {
96             ipLogger = PVLogger::GetLoggerObject("PVMFJBEventNotifier");
97         }
98         void ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 aDelta, const OsclAny* aContextData, PVMFStatus aStatus);
99         virtual void NotificationsInterfaceDestroyed();
100     private:
101         Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator>& irJBEvntNtfrRequestInfoVectClientPlaybackClk;
102         PVLogger* ipLogger;
103 };
104 
105 class PVMFJBEventNotificationRequestInfo
106 {
107     public:
108         PVMFJBEventNotificationRequestInfo(CLOCK_NOTIFICATION_INTF_TYPE aClockNotificationsIntfType, PVMFJBEventNotifierObserver* aObserver, OsclAny* aContext = NULL)
iClockNotificationIntfType(aClockNotificationsIntfType)109                 : iClockNotificationIntfType(aClockNotificationsIntfType)
110                 , ipObserver(aObserver)
111                 , ipContext(aContext)
112         {
113         }
114 
PVMFJBEventNotificationRequestInfo(const PVMFJBEventNotificationRequestInfo & aJBNotificationReqinfo)115         PVMFJBEventNotificationRequestInfo(const PVMFJBEventNotificationRequestInfo& aJBNotificationReqinfo)
116         {
117             iClockNotificationIntfType = aJBNotificationReqinfo.iClockNotificationIntfType;
118             ipObserver = aJBNotificationReqinfo.ipObserver;
119             ipContext = aJBNotificationReqinfo.ipContext;
120         }
121 
GetContextData()122         const OsclAny* GetContextData() const
123         {
124             return ipContext;
125         }
126 
GetMediaClockNotificationsInterfaceType()127         CLOCK_NOTIFICATION_INTF_TYPE GetMediaClockNotificationsInterfaceType() const
128         {
129             return  iClockNotificationIntfType;
130         }
131 
GetObserver()132         PVMFJBEventNotifierObserver* GetObserver() const
133         {
134             return ipObserver;
135         }
136 
137     private:
138         CLOCK_NOTIFICATION_INTF_TYPE iClockNotificationIntfType;
139         PVMFJBEventNotifierObserver* ipObserver;
140         const OsclAny* ipContext;
141 };
142 
143 class PVMFJBEventNotifier
144 {
145     public:
146         OSCL_IMPORT_REF static PVMFJBEventNotifier* New(PVMFMediaClock& aNonDecreasingClock, PVMFMediaClock& aClientPlaybackClock, PVMFMediaClock& aEstimatedServerClock);
147         OSCL_IMPORT_REF bool RequestCallBack(const PVMFJBEventNotificationRequestInfo& aNotificationRequestInfo, uint32 aDelay, uint32& aCallBkId);
148         OSCL_IMPORT_REF bool RequestAbsoluteTimeCallBack(const PVMFJBEventNotificationRequestInfo& aNotificationRequestInfo, uint32 aAbsoluteTime, uint32& aCallBkId);
149         OSCL_IMPORT_REF void CancelCallBack(const PVMFJBEventNotificationRequestInfo& aNotificationRequestInfo, uint32 aCallBkId);
150         OSCL_IMPORT_REF void CancelAllPendingCallbacks(CLOCK_NOTIFICATION_INTF_TYPE aType, PVMFJBEventNotifierObserver* aObserver = NULL);
151         OSCL_IMPORT_REF void CancelAllPendingCallbacks();
152         OSCL_IMPORT_REF ~PVMFJBEventNotifier();
153     private:
154         /**
155 
156         */
PVMFJBEventNotifier(PVMFMediaClock & aNonDecreasingClock,PVMFMediaClock & aClientPlaybackClock,PVMFMediaClock & aEstimatedServerClock)157         PVMFJBEventNotifier(PVMFMediaClock& aNonDecreasingClock, PVMFMediaClock& aClientPlaybackClock, PVMFMediaClock& aEstimatedServerClock)
158                 : irNonDecreasingClock(aNonDecreasingClock)
159                 , irClientPlaybackClock(aClientPlaybackClock)
160                 , irEstimatedServerClock(aEstimatedServerClock)
161                 , ipNonDecreasingClockNotificationsInf(NULL)
162                 , ipClientPlayBackClockNotificationsInf(NULL)
163                 , ipEstimatedClockNotificationsInf(NULL)
164                 , ipNonDecreasingClkNotificationInterfaceObserver(NULL)
165                 , ipClientPlaybackClkNotificationInterfaceObserver(NULL)
166                 , ipEstimatedSrvrClkNotificationInterfaceObserver(NULL)
167         {}
168 
169         //Can leave: Yes
170         //Possible leave code (s): OsclErrNoMemory
171         void Construct();
172         void CleanUp();
173         void CancelCallBack(CLOCK_NOTIFICATION_INTF_TYPE aType, PVMFJBEventNotifierObserver* aObserver, uint32& aCallBkId);
174 
175         PVMFMediaClock& irNonDecreasingClock;
176         PVMFMediaClock& irClientPlaybackClock;
177         PVMFMediaClock& irEstimatedServerClock;
178 
179         //Notification interfaces
180         PVMFMediaClockNotificationsInterface* ipNonDecreasingClockNotificationsInf;
181         PVMFMediaClockNotificationsInterface* ipClientPlayBackClockNotificationsInf;
182         PVMFMediaClockNotificationsInterface* ipEstimatedClockNotificationsInf;
183 
184         NonDecClkNotificationInterfaceObserver* ipNonDecreasingClkNotificationInterfaceObserver;
185         ClientPlaybackClkNotificationInterfaceObserver* ipClientPlaybackClkNotificationInterfaceObserver;
186         EstimatedSrvrClkNotificationInterfaceObserver* ipEstimatedSrvrClkNotificationInterfaceObserver;
187 
188         //Todo: Need to consider data structure for efficeincy of removing elements in between (linked list?)
189         Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator> iJBEvntNtfrRequestInfoVectEstimatedServClk;
190         Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator> iJBEvntNtfrRequestInfoVectClientPlaybackClk;
191         Oscl_Vector<PVMFJBEventNotifierRequestInfo*, OsclMemAllocator> iJBEvntNtfrRequestInfoVectNonDecClk;
192 
193         PVLogger* ipLogger;
194 };
195 #endif
196