• 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 PV_COMMON_TYPES_H_INCLUDED
19 #define PV_COMMON_TYPES_H_INCLUDED
20 
21 //  INCLUDES
22 #ifndef OSCL_TYPES_H_INCLUDED
23 #include "oscl_types.h"
24 #endif
25 
26 #ifndef OSCL_MEM_H_INCLUDED
27 #include "oscl_mem.h"
28 #endif
29 
30 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
31 #include "oscl_string_containers.h"
32 #endif
33 
34 // CONSTANTS
35 
36 // MACROS
37 #define PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE 8
38 
39 // DATA TYPES
40 /* Temporary definitions */
41 typedef int32 TPVCmnCommandType;
42 typedef int32 TPVCmnCommandId;
43 typedef int32 TPVCmnCommandStatus;
44 typedef int32 TPVCmnEventType;
45 typedef void* TPVCmnExclusivePtr;
46 typedef void* TPVCmnInterfacePtr;
47 typedef int32 TPVCmnResponseType;
48 typedef int32 TPVCmnSDKModuleInfo;
49 typedef uint8* TPVCmnMIMEType;
50 typedef uint32 TPVCmnUUID;
51 typedef int32 CPVCmnVideoCaps;
52 typedef int32 CPVCmnVideoPrefs;
53 typedef int32 CPVCmnAudioCaps;
54 typedef int32 CPVCmnAudioPrefs;
55 
56 struct TPVCmnSDKInfo
57 {
TPVCmnSDKInfoTPVCmnSDKInfo58     TPVCmnSDKInfo()
59     {
60         iDate = 0x00000000;
61     }
62     TPVCmnSDKInfo& operator=(const TPVCmnSDKInfo& aSDKInfo)
63     {
64         iLabel = aSDKInfo.iLabel;
65         iDate = aSDKInfo.iDate;
66         return *this;
67     }
68 
69     OSCL_StackString<80> iLabel;
70     uint32 iDate; // 0xyyyymmdd
71 };
72 
73 // FUNCTION PROTOTYPES
74 
75 
76 // FORWARD DECLARATIONS
77 
78 
79 // CLASS DECLARATION
80 /**
81  * CPVCmnInterfaceObserverMessage Class
82  *
83  * CPVCmnInterfaceObserverMessage is the interface to the pv2way SDK, which
84  * allows initialization, control, and termination of a two-way terminal.
85  * The application is expected to contain and maintain a pointer to the
86  * CPV2WayInterface instance at all times that a call is active.
87  * The CPV2WayFactory factory class is to be used to create and
88  * delete instances of this class
89  **/
90 class CPVCmnInterfaceObserverMessage
91 {
92     public:
CPVCmnInterfaceObserverMessage()93         CPVCmnInterfaceObserverMessage() {}
CPVCmnInterfaceObserverMessage(TPVCmnResponseType aResponseType)94         CPVCmnInterfaceObserverMessage(TPVCmnResponseType aResponseType): iResponseType(aResponseType) {}
95 
~CPVCmnInterfaceObserverMessage()96         virtual ~CPVCmnInterfaceObserverMessage() {};
GetResponseType()97         TPVCmnResponseType GetResponseType() const
98         {
99             return iResponseType;
100         }
GetPriority()101         virtual int GetPriority()const
102         {
103             return iPriority;
104         }
105         TPVCmnResponseType iResponseType;
106         int iPriority;
107         int iOrder;
108 };
109 
110 class CPVCmnInterfaceObserverMessageCompare
111 {
112     public:
compare(CPVCmnInterfaceObserverMessage * a,CPVCmnInterfaceObserverMessage * b)113         int compare(CPVCmnInterfaceObserverMessage *a, CPVCmnInterfaceObserverMessage *b) const
114         {
115             if (a->GetPriority() < b->GetPriority())
116                 return 1;//prioritized
117             else
118                 return (a->iOrder > b->iOrder);//fifo
119         }
120 };
121 
122 /**
123  * CPVCmnCmdResp Class
124  *
125  * CPVCmnCmdResp class is used to pass completion status on previously issued
126  * commands
127  **/
128 class CPVCmnInterfaceCmdMessage;
129 class CPVCmnCmdResp : public CPVCmnInterfaceObserverMessage
130 {
131     public:
132         /**
133          * Constructor for CPVCmnCmdResp
134          */
135         CPVCmnCmdResp(TPVCmnCommandType aType, TPVCmnCommandId aId, void* aContext, TPVCmnCommandStatus aStatus, void* aResponseData = NULL, int aResponseDataSize = 0, TPVCmnResponseType aResponseType = NULL):
CPVCmnInterfaceObserverMessage(aResponseType)136                 CPVCmnInterfaceObserverMessage(aResponseType), iCmdType(aType), iCmdId(aId), iContext(aContext), iStatus(aStatus), iResponseData(aResponseData), iResponseDataSize(aResponseDataSize) {}
137 
138         /**
139          * @return Returns the command type that is being completed.
140          */
GetCmdType()141         TPVCmnCommandType GetCmdType()const
142         {
143             return iCmdType;
144         }
145 
146         /**
147          * @return Returns the unique ID associated with a command of this type.
148          */
GetCmdId()149         TPVCmnCommandId GetCmdId()const
150         {
151             return iCmdId;
152         }
153 
154         /**
155          * @return Returns the opaque data that was passed in with the command.
156          */
GetContext()157         void* GetContext()const
158         {
159             return iContext;
160         }
161 
162         /**
163          * @return Returns the completion status of the command
164          */
GetCmdStatus()165         TPVCmnCommandStatus GetCmdStatus()const
166         {
167             return iStatus;
168         }
169 
170         /**
171          * @return Returns additional data asociated with the command.  This is to be interpreted
172                    based on the command type and the return status
173          */
GetResponseData()174         void* GetResponseData()const
175         {
176             return iResponseData;
177         }
GetResponseDataSize()178         int GetResponseDataSize()const
179         {
180             return iResponseDataSize;
181         }
182 
183     protected:
184         TPVCmnCommandType iCmdType;
185         TPVCmnCommandId iCmdId;
186         void* iContext;
187         TPVCmnCommandStatus iStatus;
188         void* iResponseData;
189         int iResponseDataSize;
190 };
191 
192 
193 /**
194  * CPVCmnAsyncEvent Class
195  *
196  * CPVCmnAsyncEvent is the base class used to pass unsolicited error and informational
197  * indications to the user. Additional information can be tagged based on the specific
198  * event
199  **/
200 class CPVCmnAsyncEvent : public CPVCmnInterfaceObserverMessage
201 {
202     public:
203         CPVCmnAsyncEvent(TPVCmnEventType aEventType, TPVCmnExclusivePtr aExclusivePtr, const uint8 *aLocalBuffer = NULL, uint32 aLocalBufSize = 0, TPVCmnResponseType aResponseType = NULL) :
CPVCmnInterfaceObserverMessage(aResponseType)204                 CPVCmnInterfaceObserverMessage(aResponseType),  iEventType(aEventType), iExclusivePtr(aExclusivePtr)
205         {
206             if (aLocalBuffer)
207             {
208                 if (aLocalBufSize > PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE)
209                 {
210                     oscl_memcpy(iLocalBuffer, aLocalBuffer, PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE);
211                 }
212                 else
213                 {
214                     oscl_memcpy(iLocalBuffer, aLocalBuffer, aLocalBufSize);
215                 }
216             }
217         }
218 
~CPVCmnAsyncEvent()219         ~CPVCmnAsyncEvent() {}
220 
221         /**
222          * @return Returns the Event type that has been received
223          */
GetEventType()224         TPVCmnEventType GetEventType()const
225         {
226             return iEventType;
227         }
228 
229         /**
230          * @return Returns the opaque data asociated with the event.
231          */
GetEventData(TPVCmnExclusivePtr & aPtr)232         void GetEventData(TPVCmnExclusivePtr& aPtr)const
233         {
234             aPtr = iExclusivePtr;
235         }
236 
237         /**
238          * @return Returns the local data asociated with the event.
239          */
GetLocalBuffer()240         uint8 * GetLocalBuffer()
241         {
242             return &iLocalBuffer[0];
243         }
244 
245     protected:
246         TPVCmnEventType iEventType;
247         TPVCmnExclusivePtr iExclusivePtr;
248         uint8 iLocalBuffer[PV_COMMON_ASYNC_EVENT_LOCAL_BUF_SIZE];
249 };
250 
251 typedef CPVCmnAsyncEvent CPVCmnAsyncInfoEvent;
252 
253 typedef CPVCmnAsyncEvent CPVCmnAsyncErrorEvent;
254 
255 class MPVCmnErrorEventObserver
256 {
257     public:
~MPVCmnErrorEventObserver()258         virtual ~MPVCmnErrorEventObserver() {}
259         virtual void HandleErrorEventL(const CPVCmnAsyncErrorEvent& aEvent) = 0;
260 };
261 
262 class MPVCmnInfoEventObserver
263 {
264     public:
~MPVCmnInfoEventObserver()265         virtual ~MPVCmnInfoEventObserver() {}
266         virtual void HandleInformationalEventL(const CPVCmnAsyncInfoEvent& aEvent) = 0;
267 };
268 
269 class MPVCmnCmdStatusObserver
270 {
271     public:
~MPVCmnCmdStatusObserver()272         virtual ~MPVCmnCmdStatusObserver() {}
273         virtual void CommandCompletedL(const CPVCmnCmdResp& aResponse) = 0;
274 };
275 
276 #endif //
277 
278 
279