|
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 /** |
|
19 * @file |
|
20 * @internalTechnology |
|
21 */ |
|
22 |
|
23 #ifndef OMXILFILESOURCEPROCESSINGFUNCTION_H |
|
24 #define OMXILFILESOURCEPROCESSINGFUNCTION_H |
|
25 |
|
26 #include <openmax/il/common/omxilprocessingfunction.h> |
|
27 #include <e32base.h> |
|
28 #include <e32msgqueue.h> |
|
29 #include <f32file.h> |
|
30 #include <openmax/il/khronos/v1_x/OMX_Component.h> |
|
31 |
|
32 class COmxILFileSourceProcessingFunction : public COmxILProcessingFunction |
|
33 { |
|
34 public: |
|
35 static COmxILFileSourceProcessingFunction* NewL(MOmxILCallbackNotificationIf& aCallbacks); |
|
36 ~COmxILFileSourceProcessingFunction(); |
|
37 |
|
38 OMX_ERRORTYPE StateTransitionIndication(TStateIndex aNewState); |
|
39 OMX_ERRORTYPE BufferFlushingIndication(TUint32 aPortIndex, OMX_DIRTYPE aDirection); |
|
40 OMX_ERRORTYPE ParamIndication(OMX_INDEXTYPE aParamIndex, const TAny* apComponentParameterStructure); |
|
41 OMX_ERRORTYPE ConfigIndication(OMX_INDEXTYPE aConfigIndex, const TAny* apComponentConfigStructure); |
|
42 OMX_ERRORTYPE BufferIndication(OMX_BUFFERHEADERTYPE* apBufferHeader, OMX_DIRTYPE aDirection); |
|
43 OMX_BOOL BufferRemovalIndication(OMX_BUFFERHEADERTYPE* apBufferHeader, OMX_DIRTYPE aDirection); |
|
44 |
|
45 MOmxILCallbackNotificationIf& GetCallbacks(); |
|
46 |
|
47 /** can return NULL if parameter has not been set. */ |
|
48 const HBufC* FileName() const; |
|
49 const HBufC8* Uri() const; |
|
50 |
|
51 private: |
|
52 COmxILFileSourceProcessingFunction(MOmxILCallbackNotificationIf& aCallbacks); |
|
53 void ConstructL(); |
|
54 |
|
55 void InitFileAndUriL(); |
|
56 OMX_ERRORTYPE SetFileName(const OMX_PARAM_CONTENTURITYPE* aContentUriType); |
|
57 |
|
58 private: |
|
59 RPointerArray<OMX_BUFFERHEADERTYPE> iBuffersToFill; |
|
60 OMX_STATETYPE iState; |
|
61 HBufC8* ipUri; |
|
62 HBufC* ipFileName; |
|
63 |
|
64 private: |
|
65 class CPFHelper; |
|
66 class CBufferArrivalHandler; |
|
67 |
|
68 class CFileSourceAccess : public CActive |
|
69 { |
|
70 friend class CPFHelper; |
|
71 public: |
|
72 static CFileSourceAccess* NewL(COmxILFileSourceProcessingFunction& aParent); |
|
73 ~CFileSourceAccess(); |
|
74 |
|
75 // from CActive |
|
76 void RunL(); |
|
77 void DoCancel(); |
|
78 |
|
79 TInt Execute(); |
|
80 void Pause(); |
|
81 void Stop(); |
|
82 void Idle(); |
|
83 |
|
84 void CancelDataTransfer(); |
|
85 |
|
86 TInt ProcessNextBuffer(); |
|
87 |
|
88 private: |
|
89 CFileSourceAccess(COmxILFileSourceProcessingFunction& aParent); |
|
90 void ConstructL(); |
|
91 |
|
92 private: |
|
93 COmxILFileSourceProcessingFunction& iParent; |
|
94 OMX_BUFFERHEADERTYPE* iCurrentBuffer; |
|
95 |
|
96 RFs iFs; |
|
97 RFile iFileHandle; |
|
98 TInt iBufferOffset; |
|
99 TPtr8 iReadBuffer; |
|
100 TBool iEOSFlag; // Notifies that end of file has been reached. |
|
101 TInt iEOSBufferNotificationCount; // counts the number of responses to buffer notification when URI is unspecified |
|
102 |
|
103 } *ipFileSourceAccess; |
|
104 |
|
105 class CPFHelper : public CActive |
|
106 { |
|
107 public: |
|
108 static CPFHelper* NewL(COmxILFileSourceProcessingFunction& aParent, CFileSourceAccess& aFileSourceAccess, CBufferArrivalHandler& aBufferArrivalHandler); |
|
109 ~CPFHelper(); |
|
110 |
|
111 static OMX_ERRORTYPE ConvertSymbianErrorType(TInt aError); |
|
112 |
|
113 // from CActive |
|
114 void RunL(); |
|
115 void DoCancel(); |
|
116 |
|
117 TInt ExecuteAsync(); |
|
118 TInt StopAsync(); |
|
119 TInt PauseAsync(); |
|
120 void StopSync(); |
|
121 TInt IdleAsync(); |
|
122 TInt FlushIndication(); |
|
123 OMX_BOOL RemoveBufferIndication(OMX_BUFFERHEADERTYPE* apBufferHeader); |
|
124 |
|
125 enum TMessageType |
|
126 { |
|
127 EExecuteCommand, |
|
128 EStopCommand, |
|
129 EPauseCommand, |
|
130 ECancelCommand, |
|
131 EIdleCommand, |
|
132 EFlushCommand, |
|
133 ERemoveBufferCommand |
|
134 }; |
|
135 |
|
136 class TProcMessage |
|
137 { |
|
138 public: |
|
139 TMessageType iType; |
|
140 TAny* iPtr; |
|
141 }; |
|
142 |
|
143 class TBufferRemovalArgs |
|
144 { |
|
145 public: |
|
146 OMX_BUFFERHEADERTYPE* ipHeader; // Input parameter. Not owned |
|
147 OMX_BOOL* iHdrRemoved; // Return parameter. Not owned |
|
148 }; |
|
149 |
|
150 RMsgQueue<TProcMessage> iMsgQueue; |
|
151 |
|
152 private: |
|
153 CPFHelper(COmxILFileSourceProcessingFunction& aParent, CFileSourceAccess& aFileSourceAccess,CBufferArrivalHandler& aBufferArrivalHandler); |
|
154 void ConstructL(); |
|
155 |
|
156 TInt ProcessQueue(); |
|
157 void PerformFlush(); |
|
158 OMX_BOOL PerformBufferRemoval(OMX_BUFFERHEADERTYPE* apBufferHeader); |
|
159 |
|
160 private: |
|
161 COmxILFileSourceProcessingFunction& iParent; |
|
162 CFileSourceAccess& iFileSourceAccess; |
|
163 CBufferArrivalHandler& iBufferArrivalHandler; |
|
164 RThread iRunLContext; |
|
165 RSemaphore iWaitSemaphore; |
|
166 } *ipPFHelper; |
|
167 |
|
168 class CBufferArrivalHandler : public CActive |
|
169 { |
|
170 public: |
|
171 static CBufferArrivalHandler* NewL(COmxILFileSourceProcessingFunction& aParent, CFileSourceAccess& aFileSourceAccess); |
|
172 ~CBufferArrivalHandler(); |
|
173 |
|
174 TInt BufferIndication(OMX_BUFFERHEADERTYPE* apBufferHeader); |
|
175 void FlushIndication(); |
|
176 OMX_BOOL RemoveBufferIndication(OMX_BUFFERHEADERTYPE* apBufferHeader); |
|
177 |
|
178 // CActive |
|
179 void RunL(); |
|
180 void DoCancel(); |
|
181 |
|
182 private: |
|
183 CBufferArrivalHandler(COmxILFileSourceProcessingFunction& aParent, CFileSourceAccess& aFileSourceAccess); |
|
184 void ConstructL(); |
|
185 |
|
186 private: |
|
187 class TBufferIndicationMessage |
|
188 { |
|
189 public: |
|
190 OMX_BUFFERHEADERTYPE* iBufferHdr; // Not owned |
|
191 }; |
|
192 |
|
193 RMsgQueue<TBufferIndicationMessage> iMsgQueue; |
|
194 COmxILFileSourceProcessingFunction& iParent; |
|
195 CFileSourceAccess& iFileSourceAccess; |
|
196 } *ipBufferArrivalHandler; |
|
197 }; |
|
198 |
|
199 #endif // OMXILFILESOURCEPROCESSINGFUNCTION_H |
|
200 |