|
1 // Copyright (c) 2010 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 OMXILPORTIMPL_H |
|
23 #define OMXILPORTIMPL_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
|
27 #include <openmax/il/common/omxilspecversion.h> |
|
28 #include <openmax/il/common/omxilport.h> |
|
29 |
|
30 /** |
|
31 OpenMAX IL component port base implementation class. |
|
32 */ |
|
33 class COmxILPortImpl : public CBase |
|
34 { |
|
35 public: |
|
36 static const TInt KMaxBufferMarksQueueSize = 10; |
|
37 static COmxILPortImpl* NewL(const TOmxILCommonPortData& aCommonPortData, COmxILPort& aPort); |
|
38 ~COmxILPortImpl(); |
|
39 |
|
40 OMX_ERRORTYPE GetParameter( |
|
41 OMX_INDEXTYPE aParamIndex, |
|
42 TAny* apComponentParameterStructure) const; |
|
43 |
|
44 OMX_ERRORTYPE SetParameter( |
|
45 OMX_INDEXTYPE aParamIndex, |
|
46 const TAny* apComponentParameterStructure, |
|
47 TBool& aUpdateProcessingFunction); |
|
48 |
|
49 OMX_ERRORTYPE GetConfig( |
|
50 OMX_INDEXTYPE aConfigIndex, |
|
51 TAny* apComponentConfigStructure) const; |
|
52 |
|
53 OMX_ERRORTYPE SetConfig( |
|
54 OMX_INDEXTYPE aConfigIndex, |
|
55 const TAny* apComponentConfigStructure, |
|
56 TBool& aUpdateProcessingFunction); |
|
57 |
|
58 OMX_ERRORTYPE GetExtensionIndex( |
|
59 OMX_STRING aParameterName, |
|
60 OMX_INDEXTYPE* apIndexType) const; |
|
61 |
|
62 OMX_ERRORTYPE PopulateBuffer( |
|
63 OMX_BUFFERHEADERTYPE** appBufferHdr, |
|
64 const OMX_PTR apAppPrivate, |
|
65 OMX_U32 aSizeBytes, |
|
66 OMX_U8* apBuffer, |
|
67 TBool& portPopulationCompleted); |
|
68 |
|
69 OMX_ERRORTYPE FreeBuffer( |
|
70 OMX_BUFFERHEADERTYPE* apBufferHeader, |
|
71 TBool& portDepopulationCompleted); |
|
72 |
|
73 OMX_ERRORTYPE TunnelRequest( |
|
74 OMX_HANDLETYPE aTunneledComp, |
|
75 OMX_U32 aTunneledPort, |
|
76 OMX_TUNNELSETUPTYPE* apTunnelSetup); |
|
77 |
|
78 OMX_ERRORTYPE PopulateTunnel( |
|
79 TBool& portPopulationCompleted); |
|
80 |
|
81 OMX_ERRORTYPE FreeTunnel( |
|
82 TBool& portDepopulationCompleted); |
|
83 |
|
84 TBool SetBufferSent( |
|
85 OMX_BUFFERHEADERTYPE* apBufferHeader, |
|
86 TBool& aBufferMarkedWithOwnMark); |
|
87 |
|
88 TBool SetBufferReturned( |
|
89 OMX_BUFFERHEADERTYPE* apBufferHeader); |
|
90 |
|
91 void SetTransitionToDisabled(); |
|
92 |
|
93 void SetTransitionToEnabled(); |
|
94 |
|
95 void SetTransitionToDisabledCompleted(); |
|
96 |
|
97 void SetTransitionToEnabledCompleted(); |
|
98 |
|
99 OMX_ERRORTYPE StoreBufferMark( |
|
100 const OMX_MARKTYPE* pMark); |
|
101 |
|
102 OMX_ERRORTYPE SetComponentRoleDefaults( |
|
103 TUint aComponentRoleIndex); |
|
104 |
|
105 OMX_ERRORTYPE DoPortReconfiguration( |
|
106 TUint aPortSettingsIndex, |
|
107 const TDesC8& aPortSettings, |
|
108 OMX_EVENTTYPE& aEventForILClient); |
|
109 |
|
110 inline OMX_DIRTYPE Direction() const; |
|
111 |
|
112 inline TBool IsEnabled() const; |
|
113 |
|
114 inline TBool IsPopulated() const; |
|
115 |
|
116 inline TBool IsDePopulated() const; |
|
117 |
|
118 inline TBool IsTunnelled() const; |
|
119 |
|
120 inline TBool IsTunnelledAndBufferSupplier() const; |
|
121 |
|
122 virtual TBool HasAllBuffersAtHome() const; |
|
123 |
|
124 TBool IsTransitioningToEnabled() const; |
|
125 |
|
126 inline TBool IsTransitioningToDisabled() const; |
|
127 |
|
128 virtual TBool IsBufferAtHome( |
|
129 OMX_BUFFERHEADERTYPE* apHeaderHeader) const; |
|
130 |
|
131 inline OMX_U32 Index() const; |
|
132 |
|
133 inline OMX_PORTDOMAINTYPE Domain() const; |
|
134 |
|
135 inline OMX_U32 Count() const; |
|
136 |
|
137 inline OMX_BUFFERHEADERTYPE* const& operator[](TInt anIndex) const; |
|
138 |
|
139 inline OMX_BUFFERHEADERTYPE*& operator[](TInt anIndex); |
|
140 |
|
141 inline OMX_U32 BufferMarkPropagationPort() const; |
|
142 |
|
143 protected: |
|
144 |
|
145 class TBufferMarkInfo; |
|
146 |
|
147 /** |
|
148 Buffer mark info list |
|
149 */ |
|
150 class TBufferMarkInfoQue : |
|
151 public TSglQue<TBufferMarkInfo> |
|
152 { |
|
153 |
|
154 public: |
|
155 |
|
156 // Convenience typedef.... |
|
157 typedef TSglQue<TBufferMarkInfo> Tq; |
|
158 |
|
159 public: |
|
160 |
|
161 inline explicit TBufferMarkInfoQue(TInt aOffset); |
|
162 |
|
163 inline TBufferMarkInfo* First() const; |
|
164 |
|
165 inline void AddLast(TBufferMarkInfo& aRef); |
|
166 |
|
167 inline void Remove(TBufferMarkInfo& aRef); |
|
168 |
|
169 inline TInt Elements() const; |
|
170 |
|
171 inline void ResetAndDestroy(); |
|
172 |
|
173 private: |
|
174 |
|
175 TBufferMarkInfoQue(); |
|
176 void AddFirst(TBufferMarkInfo& aRef); |
|
177 TBool IsFirst(const TBufferMarkInfo* aPtr) const; |
|
178 TBool IsLast(const TBufferMarkInfo* aPtr) const; |
|
179 |
|
180 TBufferMarkInfo* Last() const; |
|
181 |
|
182 private: |
|
183 |
|
184 TInt iNumElements; |
|
185 |
|
186 }; |
|
187 |
|
188 |
|
189 class TBufferInfo; |
|
190 |
|
191 private: |
|
192 |
|
193 enum TPortIntermediateState |
|
194 { |
|
195 EPortNotTransitioning, |
|
196 EPortTransitioningToDisabled, |
|
197 EPortTransitioningToEnabled |
|
198 }; |
|
199 |
|
200 |
|
201 protected: |
|
202 |
|
203 COmxILPortImpl(const TOmxILCommonPortData& aCommonPortData, COmxILPort& aPort); |
|
204 |
|
205 public: |
|
206 template<typename T> |
|
207 inline OMX_ERRORTYPE GetParamStructureFromTunnel( |
|
208 T& aComponentConfigStructure, OMX_INDEXTYPE aParamIndex) const; |
|
209 |
|
210 OMX_ERRORTYPE StoreBufferMark( |
|
211 OMX_HANDLETYPE& ipMarkTargetComponent, |
|
212 OMX_PTR& ipMarkData); |
|
213 |
|
214 void CleanUpPort(); |
|
215 |
|
216 inline const OMX_PARAM_PORTDEFINITIONTYPE& GetParamPortDefinition() const; |
|
217 inline const OMX_HANDLETYPE& GetTunnelledComponent() const; |
|
218 inline const OMX_U32& GetTunnelledPort() const; |
|
219 inline OMX_PARAM_PORTDEFINITIONTYPE& GetParamPortDefinition(); |
|
220 inline OMX_HANDLETYPE& GetTunnelledComponent(); |
|
221 inline OMX_U32& GetTunnelledPort(); |
|
222 |
|
223 private: |
|
224 |
|
225 // Tunnelled component |
|
226 OMX_HANDLETYPE iTunnelledComponent; |
|
227 |
|
228 // Tunnelled component's port |
|
229 OMX_U32 iTunnelledPort; |
|
230 |
|
231 // Buffer headers store |
|
232 RArray<TBufferInfo> iBufferHeaders; |
|
233 |
|
234 // Buffer marks store |
|
235 TBufferMarkInfoQue iBufferMarks; |
|
236 |
|
237 // Port's intermediate state to enabled or disabled |
|
238 TPortIntermediateState iTransitionState; |
|
239 |
|
240 // Associated port that will be used to propagate buffer marks |
|
241 OMX_U32 iBufferMarkPropagationPortIndex; |
|
242 |
|
243 // This is a flag that is set when the port receives the first |
|
244 // OMX_UseBuffer (non-supplier ports). This will be used to know when |
|
245 // SetParameter will be allowed |
|
246 OMX_BOOL aFirstUseBufferHasBeenReceived; |
|
247 |
|
248 // OpenMAX IL port definition structure |
|
249 OMX_PARAM_PORTDEFINITIONTYPE iParamPortDefinition; |
|
250 |
|
251 // OpenMAX IL buffer supplier structure |
|
252 OMX_PARAM_BUFFERSUPPLIERTYPE iParamCompBufferSupplier; |
|
253 |
|
254 COmxILPort& iOmxILPort; |
|
255 |
|
256 }; |
|
257 |
|
258 /** |
|
259 Buffer mark info structure |
|
260 */ |
|
261 class COmxILPortImpl::TBufferMarkInfo |
|
262 { |
|
263 |
|
264 public: |
|
265 |
|
266 inline explicit TBufferMarkInfo( |
|
267 const OMX_MARKTYPE*& apMark, |
|
268 TBool aOwnMark = ETrue); |
|
269 |
|
270 inline TBufferMarkInfo( |
|
271 OMX_HANDLETYPE& apMarkTargetComponent, |
|
272 OMX_PTR& apMarkData, |
|
273 TBool aOwnMark = ETrue); |
|
274 |
|
275 public: |
|
276 |
|
277 OMX_HANDLETYPE ipMarkTargetComponent; |
|
278 OMX_PTR ipMarkData; |
|
279 TBool iOwnMark; |
|
280 TSglQueLink iLink; |
|
281 |
|
282 }; |
|
283 |
|
284 /** |
|
285 Buffer info structure |
|
286 */ |
|
287 class COmxILPortImpl::TBufferInfo |
|
288 { |
|
289 |
|
290 public: |
|
291 |
|
292 enum THeaderLocationProperty |
|
293 { |
|
294 EBufferAtHome = 0x01, |
|
295 EBufferAway = 0x00 |
|
296 }; |
|
297 |
|
298 enum THeaderOwnershipProperty |
|
299 { |
|
300 EBufferOwned = 0x02, |
|
301 EBufferNotOwned = 0x00 |
|
302 }; |
|
303 |
|
304 public: |
|
305 |
|
306 inline TBufferInfo(OMX_BUFFERHEADERTYPE* apHeader, |
|
307 THeaderLocationProperty aLocation, |
|
308 THeaderOwnershipProperty aOwnership, |
|
309 OMX_U8* apBuffer, |
|
310 OMX_PTR apApp, |
|
311 OMX_PTR apPlatform, |
|
312 OMX_PTR apPort); |
|
313 |
|
314 inline explicit TBufferInfo(OMX_BUFFERHEADERTYPE* apHeader); |
|
315 |
|
316 static TBool Compare(const TBufferInfo& aBi1, |
|
317 const TBufferInfo& aBi2); |
|
318 |
|
319 inline const OMX_BUFFERHEADERTYPE* GetHeader() const; |
|
320 |
|
321 inline OMX_BUFFERHEADERTYPE* GetHeader(); |
|
322 |
|
323 inline operator OMX_BUFFERHEADERTYPE*&(); |
|
324 |
|
325 inline operator OMX_BUFFERHEADERTYPE* const&() const; |
|
326 |
|
327 inline OMX_U8* GetBufferPointer() const; |
|
328 |
|
329 inline OMX_U8* GetBufferPointer(); |
|
330 |
|
331 inline OMX_PTR GetPortPointer() const; |
|
332 |
|
333 inline OMX_PTR GetPortPointer(); |
|
334 |
|
335 inline OMX_PTR GetPlatformPointer() const; |
|
336 |
|
337 inline OMX_PTR GetPlatformPointer(); |
|
338 |
|
339 inline OMX_PTR GetAppPointer() const; |
|
340 |
|
341 inline OMX_PTR GetAppPointer(); |
|
342 |
|
343 inline void SetBufferAtHome(); |
|
344 |
|
345 inline void SetBufferAway(); |
|
346 |
|
347 inline void SetBufferOwned(); |
|
348 |
|
349 inline void SetBufferNotOwned(); |
|
350 |
|
351 inline TBool IsBufferAtHome() const; |
|
352 |
|
353 inline TBool IsBufferOwned() const; |
|
354 |
|
355 private: |
|
356 |
|
357 enum THeaderPropertyMask |
|
358 { |
|
359 EBufferAwayMask = 0xFE, |
|
360 EBufferNotOwnedMask = 0xFD |
|
361 }; |
|
362 |
|
363 private: |
|
364 |
|
365 OMX_BUFFERHEADERTYPE* ipHeader; |
|
366 TUint8 iBufferProperties; |
|
367 OMX_U8* ipBuffer; |
|
368 OMX_PTR ipApp; |
|
369 OMX_PTR ipPlatform; |
|
370 OMX_PTR ipPort; |
|
371 |
|
372 }; |
|
373 |
|
374 #include "omxilportimpl.inl" |
|
375 #endif // OMXILPORTIMPL_H |