|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 /** |
|
18 @file |
|
19 @internalComponent |
|
20 */ |
|
21 |
|
22 #ifndef OMXILFSM_H |
|
23 #define OMXILFSM_H |
|
24 |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <openmax/il/khronos/v1_x/OMX_Core.h> |
|
28 #include <e32msgqueue.h> |
|
29 |
|
30 #include "omxilcommand.h" |
|
31 |
|
32 // forward declarations |
|
33 class COmxILPortManager; |
|
34 class COmxILConfigManager; |
|
35 class MOmxILCallbackManagerIf; |
|
36 class COmxILComponent; |
|
37 class COmxILProcessingFunction; |
|
38 |
|
39 /** |
|
40 FSM Panic category |
|
41 */ |
|
42 _LIT(KOmxILFsmPanicCategory, "OmxILFsm"); |
|
43 |
|
44 /** |
|
45 FSM class that represents the main FSM context object of the State |
|
46 pattern. It delegates most events for processing to the current state |
|
47 object. |
|
48 */ |
|
49 NONSHARABLE_CLASS(COmxILFsm) : public CBase |
|
50 { |
|
51 |
|
52 public: |
|
53 |
|
54 static const TInt KMaxMsgQueueEntries = 10; |
|
55 |
|
56 enum TStateIndex |
|
57 { |
|
58 EStateInvalid = OMX_StateInvalid, |
|
59 EStateLoaded = OMX_StateLoaded, |
|
60 EStateIdle = OMX_StateIdle, |
|
61 EStateExecuting = OMX_StateExecuting, |
|
62 EStatePause = OMX_StatePause, |
|
63 EStateWaitForResources = OMX_StateWaitForResources, |
|
64 ESubStateLoadedToIdle, |
|
65 ESubStateIdleToLoaded, |
|
66 ESubStateExecutingToIdle, |
|
67 ESubStatePauseToIdle, |
|
68 EStateMax |
|
69 }; |
|
70 |
|
71 |
|
72 public: |
|
73 |
|
74 IMPORT_C static COmxILFsm* NewL(COmxILComponent& aComponent, |
|
75 COmxILProcessingFunction& aProcFunction, |
|
76 COmxILPortManager& aPortManager, |
|
77 COmxILConfigManager& aConfigManager, |
|
78 MOmxILCallbackManagerIf& aCallbacks); |
|
79 |
|
80 ~COmxILFsm(); |
|
81 |
|
82 OMX_ERRORTYPE InitFsm(); |
|
83 |
|
84 COmxILComponent* GetComponent() const; |
|
85 |
|
86 // |
|
87 // OpenMAX IL API calls |
|
88 // |
|
89 |
|
90 OMX_ERRORTYPE GetComponentVersion(OMX_STRING aComponentName, |
|
91 OMX_VERSIONTYPE* pComponentVersion, |
|
92 OMX_VERSIONTYPE* pSpecVersion, |
|
93 OMX_UUIDTYPE* pComponentUUID) const; |
|
94 |
|
95 OMX_ERRORTYPE SendCommand(OMX_COMMANDTYPE Cmd, |
|
96 TUint32 nParam1, |
|
97 TAny* apCmdData); |
|
98 |
|
99 OMX_ERRORTYPE GetParameter(OMX_INDEXTYPE aParamIndex, |
|
100 TAny* apComponentParameterStructure) const; |
|
101 |
|
102 OMX_ERRORTYPE SetParameter(OMX_INDEXTYPE aParamIndex, |
|
103 const TAny* apComponentParameterStructure); |
|
104 |
|
105 OMX_ERRORTYPE GetConfig(OMX_INDEXTYPE aConfigIndex, |
|
106 TAny* apComponentConfigStructure) const; |
|
107 |
|
108 OMX_ERRORTYPE SetConfig(OMX_INDEXTYPE aConfigIndex, |
|
109 const TAny* apComponentConfigStructure); |
|
110 |
|
111 OMX_ERRORTYPE GetExtensionIndex(OMX_STRING aParameterName, |
|
112 OMX_INDEXTYPE* apIndexType) const; |
|
113 |
|
114 OMX_ERRORTYPE GetState(OMX_STATETYPE* apState) const; |
|
115 |
|
116 OMX_ERRORTYPE ComponentTunnelRequest(OMX_U32 aPort, |
|
117 OMX_HANDLETYPE aTunneledComp, |
|
118 OMX_U32 aTunneledPort, |
|
119 OMX_TUNNELSETUPTYPE* apTunnelSetup); |
|
120 |
|
121 OMX_ERRORTYPE UseBuffer(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
122 OMX_U32 aPortIndex, |
|
123 OMX_PTR apAppPrivate, |
|
124 OMX_U32 aSizeBytes, |
|
125 OMX_U8* apBuffer); |
|
126 |
|
127 OMX_ERRORTYPE AllocateBuffer(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
128 OMX_U32 aPortIndex, |
|
129 OMX_PTR apAppPrivate, |
|
130 OMX_U32 aSizeBytes); |
|
131 |
|
132 OMX_ERRORTYPE FreeBuffer(OMX_U32 aPortIndex, |
|
133 OMX_BUFFERHEADERTYPE* apBuffer); |
|
134 |
|
135 OMX_ERRORTYPE EmptyThisBuffer(OMX_BUFFERHEADERTYPE* apBuffer); |
|
136 |
|
137 OMX_ERRORTYPE FillThisBuffer(OMX_BUFFERHEADERTYPE* apBuffer); |
|
138 |
|
139 OMX_ERRORTYPE SetCallbacks(const OMX_CALLBACKTYPE* apCallbacks, |
|
140 const OMX_PTR apAppData); |
|
141 |
|
142 OMX_ERRORTYPE UseEGLImage(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
143 OMX_U32 aPortIndex, |
|
144 OMX_PTR aAppPrivate, |
|
145 void* eglImage); |
|
146 |
|
147 OMX_ERRORTYPE ComponentRoleEnum(OMX_U8* aRole, |
|
148 OMX_U32 aIndex) const; |
|
149 |
|
150 private: |
|
151 |
|
152 // Declaration of nested private state classes |
|
153 class COmxILState; |
|
154 class COmxILStateInvalid; |
|
155 class COmxILStateLoaded; |
|
156 class COmxILStateLoadedToIdle; |
|
157 class COmxILStateWaitForResources; |
|
158 class COmxILStateIdle; |
|
159 class COmxILStateIdleToLoaded; |
|
160 class COmxILStateExecuting; |
|
161 class COmxILStateExecutingToIdle; |
|
162 class COmxILStatePause; |
|
163 class COmxILStatePauseToIdle; |
|
164 class MOmxILPauseOrExecutingToIdle; |
|
165 |
|
166 // Note that the following friends don't break COmxILFsm's interface as all |
|
167 // friends below are COmxILFsm's private nested classes and therefore they |
|
168 // are logically part of COmxILFsm implementation |
|
169 friend class COmxILState; |
|
170 friend class COmxILStateInvalid; |
|
171 friend class COmxILStateLoaded; |
|
172 friend class COmxILStateLoadedToIdle; |
|
173 friend class COmxILStateWaitForResources; |
|
174 friend class COmxILStateIdle; |
|
175 friend class COmxILStateIdleToLoaded; |
|
176 friend class COmxILStateExecuting; |
|
177 friend class COmxILStateExecutingToIdle; |
|
178 friend class COmxILStatePause; |
|
179 friend class COmxILStatePauseToIdle; |
|
180 friend class MOmxILPauseOrExecutingToIdle; |
|
181 |
|
182 private: |
|
183 |
|
184 COmxILFsm(COmxILComponent& aComponent, |
|
185 COmxILProcessingFunction& aProcFunction, |
|
186 COmxILPortManager& aPortManager, |
|
187 COmxILConfigManager& aConfigManager, |
|
188 MOmxILCallbackManagerIf& aCallbacks); |
|
189 |
|
190 void ConstructL(); |
|
191 |
|
192 OMX_ERRORTYPE PopulateBuffer(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
193 OMX_U32 aPortIndex, |
|
194 OMX_PTR apAppPrivate, |
|
195 OMX_U32 aSizeBytes, |
|
196 OMX_U8* apBuffer); |
|
197 |
|
198 OMX_ERRORTYPE FsmTransition(TStateIndex aNewState); |
|
199 |
|
200 OMX_ERRORTYPE FsmTransition(TUint32 aNewState); |
|
201 |
|
202 OMX_ERRORTYPE SendOmxErrorEventIfNeeded(OMX_ERRORTYPE aError) const; |
|
203 |
|
204 OMX_ERRORTYPE SendOmxErrorEventIfNeeded(OMX_ERRORTYPE aError); |
|
205 |
|
206 private: |
|
207 |
|
208 COmxILComponent& iComponent; |
|
209 COmxILProcessingFunction& iProcFunction; |
|
210 COmxILPortManager& iPortManager; |
|
211 COmxILConfigManager& iConfigManager; |
|
212 MOmxILCallbackManagerIf& iCallbacks; |
|
213 |
|
214 RPointerArray<COmxILState> iStates; |
|
215 TStateIndex iCurrentStateIndex; |
|
216 COmxILState* ipCurrentState; |
|
217 |
|
218 }; |
|
219 |
|
220 |
|
221 #endif // OMXILFSM_H |