23 #include "omxilportmanager.h" |
23 #include "omxilportmanager.h" |
24 #include "omxilprocessingfunction.h" |
24 #include "omxilprocessingfunction.h" |
25 #include "omxilcallbackmanager.h" |
25 #include "omxilcallbackmanager.h" |
26 #include "omxilutil.h" |
26 #include "omxilutil.h" |
27 |
27 |
|
28 /** |
|
29 Static NewL for two-phase construction |
|
30 |
|
31 @param aProcessingFunction The component's processing function |
|
32 |
|
33 @param aCallbacks The component's callback manager |
|
34 |
|
35 @param aOmxVersion The IL Spec version in use |
|
36 |
|
37 @param aNumberOfAudioPorts Number of audio ports in the component |
|
38 |
|
39 @param aStartAudioPortNumber The start index for audio ports |
|
40 |
|
41 @param aNumberOfImagePorts Number of image ports in the component |
|
42 |
|
43 @param aStartImagePortNumber The start index for image ports |
|
44 |
|
45 @param aNumberOfVideoPorts Number of video ports in the component |
|
46 |
|
47 @param aStartVideoPortNumber The start index for video ports |
|
48 |
|
49 @param aNumberOfOtherPorts Number of other ports in the component |
|
50 |
|
51 @param aStartOtherPortNumber The start index for other ports |
|
52 |
|
53 @param aImmediateReturnTimeBuffer This only applies to components with a |
|
54 clock client port. Indicates whether the Port Manager must forward an |
|
55 arriving clock buffer to the Callback Manager (ETrue) or to the |
|
56 Processing Function (EFalse) . If the clock buffer is to be forwarded to |
|
57 the Processing Function, this will happen using the BufferIndication |
|
58 function of the component's PF. Otherwise, PF's MediaTimeIndication is |
|
59 used instead. |
|
60 */ |
28 EXPORT_C COmxILPortManager* |
61 EXPORT_C COmxILPortManager* |
29 COmxILPortManager::NewL( |
62 COmxILPortManager::NewL( |
30 COmxILProcessingFunction& aProcessingFunction, |
63 COmxILProcessingFunction& aProcessingFunction, |
31 MOmxILCallbackManagerIf& aCallbacks, |
64 MOmxILCallbackManagerIf& aCallbacks, |
32 const OMX_VERSIONTYPE& aOmxVersion, |
65 const OMX_VERSIONTYPE& aOmxVersion, |
43 DEBUG_PRINTF(_L8("COmxILPortManager::NewL")); |
76 DEBUG_PRINTF(_L8("COmxILPortManager::NewL")); |
44 |
77 |
45 COmxILPortManager* self = |
78 COmxILPortManager* self = |
46 new (ELeave)COmxILPortManager( |
79 new (ELeave)COmxILPortManager( |
47 aProcessingFunction, |
80 aProcessingFunction, |
48 aCallbacks, |
81 aCallbacks); |
49 aOmxVersion, |
|
50 aNumberOfAudioPorts, |
|
51 aStartAudioPortNumber, |
|
52 aNumberOfImagePorts, |
|
53 aStartImagePortNumber, |
|
54 aNumberOfVideoPorts, |
|
55 aStartVideoPortNumber, |
|
56 aNumberOfOtherPorts, |
|
57 aStartOtherPortNumber, |
|
58 aImmediateReturnTimeBuffer); |
|
59 |
82 |
60 CleanupStack::PushL(self); |
83 CleanupStack::PushL(self); |
61 self->ConstructL(); |
84 self->ConstructL(aProcessingFunction, |
|
85 aCallbacks, |
|
86 aOmxVersion, |
|
87 aNumberOfAudioPorts, |
|
88 aStartAudioPortNumber, |
|
89 aNumberOfImagePorts, |
|
90 aStartImagePortNumber, |
|
91 aNumberOfVideoPorts, |
|
92 aStartVideoPortNumber, |
|
93 aNumberOfOtherPorts, |
|
94 aStartOtherPortNumber, |
|
95 aImmediateReturnTimeBuffer); |
62 CleanupStack::Pop(self); |
96 CleanupStack::Pop(self); |
63 return self; |
97 return self; |
64 } |
98 } |
65 |
99 |
66 void |
100 void |
67 COmxILPortManager::ConstructL() |
101 COmxILPortManager::ConstructL( |
68 { |
102 COmxILProcessingFunction& /* aProcessingFunction */, |
69 DEBUG_PRINTF(_L8("COmxILPortManager::ConstructL")); |
103 MOmxILCallbackManagerIf& /* aCallbacks */, |
70 |
|
71 InsertParamIndexL(OMX_IndexParamAudioInit); |
|
72 InsertParamIndexL(OMX_IndexParamImageInit); |
|
73 InsertParamIndexL(OMX_IndexParamVideoInit); |
|
74 InsertParamIndexL(OMX_IndexParamOtherInit); |
|
75 |
|
76 |
|
77 if(iAudioParamInit.nStartPortNumber != 0) |
|
78 { |
|
79 User::Leave(KErrArgument); |
|
80 } |
|
81 |
|
82 if (iImageParamInit.nPorts > 0) |
|
83 { |
|
84 if (iAudioParamInit.nPorts != |
|
85 iImageParamInit.nStartPortNumber) |
|
86 { |
|
87 User::Leave(KErrArgument); |
|
88 } |
|
89 } |
|
90 |
|
91 if (iVideoParamInit.nPorts > 0) |
|
92 { |
|
93 if ((iAudioParamInit.nPorts + |
|
94 iImageParamInit.nPorts) != |
|
95 iVideoParamInit.nStartPortNumber) |
|
96 { |
|
97 User::Leave(KErrArgument); |
|
98 } |
|
99 } |
|
100 |
|
101 if (iOtherParamInit.nPorts > 0) |
|
102 { |
|
103 if ((iAudioParamInit.nPorts + |
|
104 iImageParamInit.nPorts + |
|
105 iVideoParamInit.nPorts) != |
|
106 iOtherParamInit.nStartPortNumber) |
|
107 { |
|
108 User::Leave(KErrArgument); |
|
109 } |
|
110 } |
|
111 |
|
112 } |
|
113 |
|
114 COmxILPortManager::COmxILPortManager( |
|
115 COmxILProcessingFunction& aProcessingFunction, |
|
116 MOmxILCallbackManagerIf& aCallbacks, |
|
117 const OMX_VERSIONTYPE& aOmxVersion, |
104 const OMX_VERSIONTYPE& aOmxVersion, |
118 OMX_U32 aNumberOfAudioPorts, |
105 OMX_U32 aNumberOfAudioPorts, |
119 OMX_U32 aStartAudioPortNumber, |
106 OMX_U32 aStartAudioPortNumber, |
120 OMX_U32 aNumberOfImagePorts, |
107 OMX_U32 aNumberOfImagePorts, |
121 OMX_U32 aStartImagePortNumber, |
108 OMX_U32 aStartImagePortNumber, |
122 OMX_U32 aNumberOfVideoPorts, |
109 OMX_U32 aNumberOfVideoPorts, |
123 OMX_U32 aStartVideoPortNumber, |
110 OMX_U32 aStartVideoPortNumber, |
124 OMX_U32 aNumberOfOtherPorts, |
111 OMX_U32 aNumberOfOtherPorts, |
125 OMX_U32 aStartOtherPortNumber, |
112 OMX_U32 aStartOtherPortNumber, |
126 OMX_BOOL aImmediateReturnTimeBuffer) |
113 OMX_BOOL aImmediateReturnTimeBuffer) |
127 : |
114 { |
128 iProcessingFunction(aProcessingFunction), |
115 DEBUG_PRINTF(_L8("COmxILPortManager::ConstructL")); |
129 iCallbacks(aCallbacks), |
116 |
130 iAllPorts(), |
117 iImmediateReturnTimeBuffer = aImmediateReturnTimeBuffer; |
131 iImmediateReturnTimeBuffer(aImmediateReturnTimeBuffer) |
|
132 { |
|
133 DEBUG_PRINTF(_L8("COmxILPortManager::COmxILPortManager")); |
|
134 |
118 |
135 iAudioParamInit.nSize = sizeof(OMX_PORT_PARAM_TYPE); |
119 iAudioParamInit.nSize = sizeof(OMX_PORT_PARAM_TYPE); |
136 iAudioParamInit.nVersion = aOmxVersion; |
120 iAudioParamInit.nVersion = aOmxVersion; |
137 iAudioParamInit.nPorts = aNumberOfAudioPorts; |
121 iAudioParamInit.nPorts = aNumberOfAudioPorts; |
138 iAudioParamInit.nStartPortNumber = aStartAudioPortNumber; |
122 iAudioParamInit.nStartPortNumber = aStartAudioPortNumber; |
149 |
133 |
150 iOtherParamInit.nSize = sizeof(OMX_PORT_PARAM_TYPE); |
134 iOtherParamInit.nSize = sizeof(OMX_PORT_PARAM_TYPE); |
151 iOtherParamInit.nVersion = aOmxVersion; |
135 iOtherParamInit.nVersion = aOmxVersion; |
152 iOtherParamInit.nPorts = aNumberOfOtherPorts; |
136 iOtherParamInit.nPorts = aNumberOfOtherPorts; |
153 iOtherParamInit.nStartPortNumber = aStartOtherPortNumber; |
137 iOtherParamInit.nStartPortNumber = aStartOtherPortNumber; |
|
138 |
|
139 |
|
140 InsertParamIndexL(OMX_IndexParamAudioInit); |
|
141 InsertParamIndexL(OMX_IndexParamImageInit); |
|
142 InsertParamIndexL(OMX_IndexParamVideoInit); |
|
143 InsertParamIndexL(OMX_IndexParamOtherInit); |
|
144 |
|
145 |
|
146 if(iAudioParamInit.nStartPortNumber != 0) |
|
147 { |
|
148 User::Leave(KErrArgument); |
|
149 } |
|
150 |
|
151 if (iImageParamInit.nPorts > 0) |
|
152 { |
|
153 if (iAudioParamInit.nPorts != |
|
154 iImageParamInit.nStartPortNumber) |
|
155 { |
|
156 User::Leave(KErrArgument); |
|
157 } |
|
158 } |
|
159 |
|
160 if (iVideoParamInit.nPorts > 0) |
|
161 { |
|
162 if ((iAudioParamInit.nPorts + |
|
163 iImageParamInit.nPorts) != |
|
164 iVideoParamInit.nStartPortNumber) |
|
165 { |
|
166 User::Leave(KErrArgument); |
|
167 } |
|
168 } |
|
169 |
|
170 if (iOtherParamInit.nPorts > 0) |
|
171 { |
|
172 if ((iAudioParamInit.nPorts + |
|
173 iImageParamInit.nPorts + |
|
174 iVideoParamInit.nPorts) != |
|
175 iOtherParamInit.nStartPortNumber) |
|
176 { |
|
177 User::Leave(KErrArgument); |
|
178 } |
|
179 } |
|
180 |
|
181 } |
|
182 |
|
183 COmxILPortManager::COmxILPortManager( |
|
184 COmxILProcessingFunction& aProcessingFunction, |
|
185 MOmxILCallbackManagerIf& aCallbacks) |
|
186 : |
|
187 iProcessingFunction(aProcessingFunction), |
|
188 iCallbacks(aCallbacks), |
|
189 iAllPorts() |
|
190 { |
|
191 DEBUG_PRINTF(_L8("COmxILPortManager::COmxILPortManager")); |
154 |
192 |
155 } |
193 } |
156 |
194 |
157 COmxILPortManager::~COmxILPortManager() |
195 COmxILPortManager::~COmxILPortManager() |
158 { |
196 { |
725 COmxILPortManager::FreeBuffer(OMX_U32 aPortIndex, |
767 COmxILPortManager::FreeBuffer(OMX_U32 aPortIndex, |
726 OMX_BUFFERHEADERTYPE* apBufferHeader, |
768 OMX_BUFFERHEADERTYPE* apBufferHeader, |
727 TBool& portDepopulationCompleted, |
769 TBool& portDepopulationCompleted, |
728 OMX_BOOL aPortIsDisabled /* = OMX_FALSE */) |
770 OMX_BOOL aPortIsDisabled /* = OMX_FALSE */) |
729 { |
771 { |
730 DEBUG_PRINTF2(_L8("COmxILPortManager::FreeBuffer : BUFFER [%X]"), apBufferHeader); |
772 DEBUG_PRINTF3(_L8("COmxILPortManager::FreeBuffer : PORT[%u] BUFFER [%X]"), aPortIndex, apBufferHeader); |
731 |
773 |
732 // Check the index of the port.. |
774 // Check the index of the port.. |
733 if (CheckPortIndex(aPortIndex) != OMX_ErrorNone) |
775 if (CheckPortIndex(aPortIndex) != OMX_ErrorNone) |
734 { |
776 { |
735 return OMX_ErrorBadPortIndex; |
777 return OMX_ErrorBadPortIndex; |
1177 |
1223 |
1178 OMX_ERRORTYPE |
1224 OMX_ERRORTYPE |
1179 COmxILPortManager::BufferIndication( |
1225 COmxILPortManager::BufferIndication( |
1180 OMX_BUFFERHEADERTYPE* apBufferHeader, |
1226 OMX_BUFFERHEADERTYPE* apBufferHeader, |
1181 OMX_DIRTYPE aDirection, |
1227 OMX_DIRTYPE aDirection, |
1182 OMX_BOOL aPortIsDisabled /* = OMX_FALSE */) |
1228 OMX_BOOL /* aPortIsDisabled = OMX_FALSE */) |
1183 { |
1229 { |
1184 DEBUG_PRINTF2(_L8("COmxILPortManager::BufferIndication : BUFFER [%X]"), apBufferHeader); |
|
1185 |
1230 |
1186 OMX_U32 portIndex = aDirection == OMX_DirInput ? |
1231 OMX_U32 portIndex = aDirection == OMX_DirInput ? |
1187 apBufferHeader->nInputPortIndex : apBufferHeader->nOutputPortIndex; |
1232 apBufferHeader->nInputPortIndex : apBufferHeader->nOutputPortIndex; |
1188 |
1233 |
|
1234 DEBUG_PRINTF3(_L8("COmxILPortManager::BufferIndication : PORT[%u] BUFFER [%X] "), |
|
1235 portIndex, apBufferHeader); |
|
1236 |
1189 // Check the index of the port.. |
1237 // Check the index of the port.. |
1190 if (CheckPortIndex(portIndex) != OMX_ErrorNone) |
1238 if (CheckPortIndex(portIndex) != OMX_ErrorNone) |
1191 { |
1239 { |
1192 return OMX_ErrorBadPortIndex; |
1240 return OMX_ErrorBadPortIndex; |
1193 } |
1241 } |
1197 |
1245 |
1198 // Check that port direction is the correct one... |
1246 // Check that port direction is the correct one... |
1199 if (pPort->Direction() != aDirection) |
1247 if (pPort->Direction() != aDirection) |
1200 { |
1248 { |
1201 return OMX_ErrorBadPortIndex; |
1249 return OMX_ErrorBadPortIndex; |
1202 } |
|
1203 |
|
1204 if (!pPort->IsEnabled() && |
|
1205 !pPort->IsTransitioningToDisabled() && |
|
1206 !pPort->IsTransitioningToEnabled()) |
|
1207 { |
|
1208 return OMX_ErrorIncorrectStateOperation; |
|
1209 } |
|
1210 |
|
1211 // Check port enabled property... |
|
1212 if (OMX_TRUE == aPortIsDisabled && |
|
1213 pPort->IsEnabled()) |
|
1214 { |
|
1215 // There is an indication from the FSM that the port must be disabled, |
|
1216 // otherwise, the buffer indication is not allowed in the current |
|
1217 // state. |
|
1218 return OMX_ErrorIncorrectStateOperation; |
|
1219 } |
1250 } |
1220 |
1251 |
1221 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
1252 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
1222 // Check whether this port is a buffer supplier... |
1253 // Check whether this port is a buffer supplier... |
1223 if (pPort->IsTunnelledAndBufferSupplier() && |
1254 if (pPort->IsTunnelledAndBufferSupplier() && |
1335 COmxILPortManager::BufferReturnIndication( |
1365 COmxILPortManager::BufferReturnIndication( |
1336 OMX_BUFFERHEADERTYPE* apBufferHeader, |
1366 OMX_BUFFERHEADERTYPE* apBufferHeader, |
1337 OMX_DIRTYPE aDirection, |
1367 OMX_DIRTYPE aDirection, |
1338 TBool& aAllBuffersReturned) |
1368 TBool& aAllBuffersReturned) |
1339 { |
1369 { |
1340 DEBUG_PRINTF2(_L8("COmxILPortManager::BufferReturnIndication : [%X]"), apBufferHeader); |
|
1341 |
1370 |
1342 aAllBuffersReturned = EFalse; |
1371 aAllBuffersReturned = EFalse; |
1343 |
1372 |
1344 OMX_U32 portIndex = aDirection == OMX_DirInput ? |
1373 OMX_U32 portIndex = aDirection == OMX_DirInput ? |
1345 apBufferHeader->nInputPortIndex : apBufferHeader->nOutputPortIndex; |
1374 apBufferHeader->nInputPortIndex : apBufferHeader->nOutputPortIndex; |
|
1375 |
|
1376 DEBUG_PRINTF3(_L8("COmxILPortManager::BufferReturnIndication : PORT[%u] BUFFER [%X]"), |
|
1377 portIndex, apBufferHeader); |
1346 |
1378 |
1347 // Check the index of the port.. |
1379 // Check the index of the port.. |
1348 if (CheckPortIndex(portIndex) != OMX_ErrorNone) |
1380 if (CheckPortIndex(portIndex) != OMX_ErrorNone) |
1349 { |
1381 { |
1350 return OMX_ErrorBadPortIndex; |
1382 return OMX_ErrorBadPortIndex; |
1422 pPort = iAllPorts[i]; |
1454 pPort = iAllPorts[i]; |
1423 } |
1455 } |
1424 |
1456 |
1425 if (pPort->IsEnabled() && pPort->Count()) |
1457 if (pPort->IsEnabled() && pPort->Count()) |
1426 { |
1458 { |
1427 if (pPort->IsTunnelledAndBufferSupplier() && |
1459 // If port is tunnelled: |
1428 !pPort->HasAllBuffersAtHome()) |
1460 // |
|
1461 // - Output ports buffers are sent to the processing function when |
|
1462 // flushed |
|
1463 // |
|
1464 // - Input ports buffers are sent upstream. |
|
1465 // |
|
1466 // If port is non-tunnelled: |
|
1467 // - Buffers are ejected always... |
|
1468 if (pPort->IsTunnelled()) |
1429 { |
1469 { |
1430 // Remove buffers from PF only... |
1470 // Remove buffers from PF only... |
1431 RemoveBuffersFromPfOrCm(pPort, OMX_TRUE); |
1471 RemoveBuffersFromPfOrCm(pPort, OMX_TRUE); |
1432 |
1472 |
1433 if (aEjectBuffers) |
1473 if (aEjectBuffers) |
1434 { |
1474 { |
1435 // Now we need to send input buffers upstream and ouput |
1475 // Now we need to send input buffers upstream and ouput |
1436 // buffers to the PF... |
1476 // buffers to the PF... this is done by |
1437 if ((omxRetValue = InitiateTunnellingDataFlow()) |
1477 // InitiateTunnellingDataFlow |
1438 != OMX_ErrorNone) |
1478 if ((omxRetValue = InitiateTunnellingDataFlow( |
|
1479 pPort->Index(), OMX_TRUE)) != OMX_ErrorNone) |
1439 { |
1480 { |
1440 // The flush has failed, we need to notify the IL Cient |
1481 // The flush has failed, we need to notify the IL Cient |
1441 // via EventHandler... |
1482 // via EventHandler... |
1442 iCallbacks.ErrorEventNotification(omxRetValue); |
1483 iCallbacks.ErrorEventNotification(omxRetValue); |
1443 flushSuccessful = EFalse; |
1484 flushSuccessful = EFalse; |
1444 } |
1485 } |
1445 } |
1486 } |
1446 |
|
1447 } |
1487 } |
1448 else |
1488 else |
1449 { |
1489 { |
|
1490 // All other ports are simply flushed... |
1450 portsToFlush.Append(pPort); |
1491 portsToFlush.Append(pPort); |
1451 } |
1492 } |
1452 } |
1493 } |
1453 // Notify flushing completed, even if there was nothing to |
1494 // Notify flushing completed, even if there was nothing to |
1454 // flush... |
1495 // flush... |
1869 COmxILPortManager::PortSettingsChangeIndication(OMX_U32 aPortIndex, |
1909 COmxILPortManager::PortSettingsChangeIndication(OMX_U32 aPortIndex, |
1870 TUint aPortSettingsIndex, |
1910 TUint aPortSettingsIndex, |
1871 const TDesC8& aPortSettings, |
1911 const TDesC8& aPortSettings, |
1872 OMX_EVENTTYPE& aEventForILClient) |
1912 OMX_EVENTTYPE& aEventForILClient) |
1873 { |
1913 { |
1874 DEBUG_PRINTF2(_L8("COmxILPortManager::PortSettingsChangeIndication: PORT[%d] "), aPortIndex); |
1914 DEBUG_PRINTF2(_L8("COmxILPortManager::PortSettingsChangeIndication: PORT[%u] "), aPortIndex); |
1875 |
1915 |
1876 // Check the index of the port.. |
1916 // Check the index of the port.. |
1877 if (CheckPortIndex(aPortIndex) != OMX_ErrorNone) |
1917 if (CheckPortIndex(aPortIndex) != OMX_ErrorNone) |
1878 { |
1918 { |
1879 return OMX_ErrorBadPortIndex; |
1919 return OMX_ErrorBadPortIndex; |