|
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 #include <openmax/il/common/omxilstatedefs.h> |
|
30 |
|
31 // forward declarations |
|
32 class MOmxILPortManagerIf; |
|
33 class COmxILConfigManager; |
|
34 class MOmxILCallbackManagerIf; |
|
35 class COmxILComponent; |
|
36 class COmxILProcessingFunction; |
|
37 |
|
38 /** |
|
39 FSM Panic category |
|
40 */ |
|
41 _LIT(KOmxILFsmPanicCategory, "OmxILFsm"); |
|
42 |
|
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 public: |
|
56 |
|
57 static COmxILFsm* NewL(COmxILComponent& aComponent, |
|
58 COmxILProcessingFunction& aProcFunction, |
|
59 MOmxILPortManagerIf& aPortManager, |
|
60 COmxILConfigManager& aConfigManager, |
|
61 MOmxILCallbackManagerIf& aCallbacks); |
|
62 |
|
63 ~COmxILFsm(); |
|
64 |
|
65 OMX_ERRORTYPE InitFsm(); |
|
66 |
|
67 COmxILComponent* GetComponent() const; |
|
68 |
|
69 // |
|
70 // OpenMAX IL API calls |
|
71 // |
|
72 |
|
73 OMX_ERRORTYPE GetComponentVersion(OMX_STRING aComponentName, |
|
74 OMX_VERSIONTYPE* pComponentVersion, |
|
75 OMX_VERSIONTYPE* pSpecVersion, |
|
76 OMX_UUIDTYPE* pComponentUUID) const; |
|
77 |
|
78 OMX_ERRORTYPE SendCommand(OMX_COMMANDTYPE Cmd, |
|
79 TUint32 nParam1, |
|
80 TAny* apCmdData); |
|
81 |
|
82 OMX_ERRORTYPE GetParameter(OMX_INDEXTYPE aParamIndex, |
|
83 TAny* apComponentParameterStructure) const; |
|
84 |
|
85 OMX_ERRORTYPE SetParameter(OMX_INDEXTYPE aParamIndex, |
|
86 const TAny* apComponentParameterStructure); |
|
87 |
|
88 OMX_ERRORTYPE GetConfig(OMX_INDEXTYPE aConfigIndex, |
|
89 TAny* apComponentConfigStructure) const; |
|
90 |
|
91 OMX_ERRORTYPE SetConfig(OMX_INDEXTYPE aConfigIndex, |
|
92 const TAny* apComponentConfigStructure); |
|
93 |
|
94 OMX_ERRORTYPE GetExtensionIndex(OMX_STRING aParameterName, |
|
95 OMX_INDEXTYPE* apIndexType) const; |
|
96 |
|
97 OMX_ERRORTYPE GetState(OMX_STATETYPE* apState) const; |
|
98 |
|
99 OMX_ERRORTYPE ComponentTunnelRequest(OMX_U32 aPort, |
|
100 OMX_HANDLETYPE aTunneledComp, |
|
101 OMX_U32 aTunneledPort, |
|
102 OMX_TUNNELSETUPTYPE* apTunnelSetup); |
|
103 |
|
104 OMX_ERRORTYPE UseBuffer(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
105 OMX_U32 aPortIndex, |
|
106 OMX_PTR apAppPrivate, |
|
107 OMX_U32 aSizeBytes, |
|
108 OMX_U8* apBuffer); |
|
109 |
|
110 OMX_ERRORTYPE AllocateBuffer(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
111 OMX_U32 aPortIndex, |
|
112 OMX_PTR apAppPrivate, |
|
113 OMX_U32 aSizeBytes); |
|
114 |
|
115 OMX_ERRORTYPE FreeBuffer(OMX_U32 aPortIndex, |
|
116 OMX_BUFFERHEADERTYPE* apBuffer); |
|
117 |
|
118 OMX_ERRORTYPE EmptyThisBuffer(OMX_BUFFERHEADERTYPE* apBuffer); |
|
119 |
|
120 OMX_ERRORTYPE FillThisBuffer(OMX_BUFFERHEADERTYPE* apBuffer); |
|
121 |
|
122 OMX_ERRORTYPE SetCallbacks(const OMX_CALLBACKTYPE* apCallbacks, |
|
123 const OMX_PTR apAppData); |
|
124 |
|
125 OMX_ERRORTYPE UseEGLImage(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
126 OMX_U32 aPortIndex, |
|
127 OMX_PTR aAppPrivate, |
|
128 void* eglImage); |
|
129 |
|
130 OMX_ERRORTYPE ComponentRoleEnum(OMX_U8* aRole, |
|
131 OMX_U32 aIndex) const; |
|
132 |
|
133 private: |
|
134 |
|
135 // Declaration of nested private state classes |
|
136 class COmxILState; |
|
137 class COmxILStateInvalid; |
|
138 class COmxILStateLoaded; |
|
139 class COmxILStateLoadedToIdle; |
|
140 class COmxILStateWaitForResources; |
|
141 class COmxILStateIdle; |
|
142 class COmxILStateIdleToLoaded; |
|
143 class COmxILStateExecuting; |
|
144 class COmxILStateExecutingToIdle; |
|
145 class COmxILStatePause; |
|
146 class COmxILStatePauseToIdle; |
|
147 class MOmxILPauseOrExecutingToIdle; |
|
148 |
|
149 // Note that the following friends don't break COmxILFsm's interface as all |
|
150 // friends below are COmxILFsm's private nested classes and therefore they |
|
151 // are logically part of COmxILFsm implementation |
|
152 friend class COmxILState; |
|
153 friend class COmxILStateInvalid; |
|
154 friend class COmxILStateLoaded; |
|
155 friend class COmxILStateLoadedToIdle; |
|
156 friend class COmxILStateWaitForResources; |
|
157 friend class COmxILStateIdle; |
|
158 friend class COmxILStateIdleToLoaded; |
|
159 friend class COmxILStateExecuting; |
|
160 friend class COmxILStateExecutingToIdle; |
|
161 friend class COmxILStatePause; |
|
162 friend class COmxILStatePauseToIdle; |
|
163 friend class MOmxILPauseOrExecutingToIdle; |
|
164 |
|
165 private: |
|
166 |
|
167 COmxILFsm(COmxILComponent& aComponent, |
|
168 COmxILProcessingFunction& aProcFunction, |
|
169 MOmxILPortManagerIf& aPortManager, |
|
170 COmxILConfigManager& aConfigManager, |
|
171 MOmxILCallbackManagerIf& aCallbacks); |
|
172 |
|
173 void ConstructL(); |
|
174 |
|
175 OMX_ERRORTYPE PopulateBuffer(OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
176 OMX_U32 aPortIndex, |
|
177 OMX_PTR apAppPrivate, |
|
178 OMX_U32 aSizeBytes, |
|
179 OMX_U8* apBuffer); |
|
180 |
|
181 OMX_ERRORTYPE FsmTransition(TStateIndex aNewState); |
|
182 |
|
183 OMX_ERRORTYPE FsmTransition(TUint32 aNewState); |
|
184 |
|
185 OMX_ERRORTYPE SendOmxErrorEventIfNeeded(OMX_ERRORTYPE aError) const; |
|
186 |
|
187 OMX_ERRORTYPE SendOmxErrorEventIfNeeded(OMX_ERRORTYPE aError); |
|
188 |
|
189 private: |
|
190 |
|
191 COmxILComponent& iComponent; |
|
192 COmxILProcessingFunction& iProcFunction; |
|
193 MOmxILPortManagerIf& iPortManager; |
|
194 COmxILConfigManager& iConfigManager; |
|
195 MOmxILCallbackManagerIf& iCallbacks; |
|
196 |
|
197 RPointerArray<COmxILState> iStates; |
|
198 TStateIndex iCurrentStateIndex; |
|
199 COmxILState* ipCurrentState; |
|
200 |
|
201 }; |
|
202 |
|
203 |
|
204 #endif // OMXILFSM_H |