|
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 #include "omxilvideoport.h" |
|
23 #include "omxilutil.h" |
|
24 #include "log.h" |
|
25 |
|
26 EXPORT_C |
|
27 COmxILVideoPort::COmxILVideoPort( |
|
28 const TOmxILCommonPortData& aCommonPortData, |
|
29 const RArray<OMX_VIDEO_CODINGTYPE>& aSupportedVideoFormats, |
|
30 const RArray<OMX_COLOR_FORMATTYPE>& aSupportedColorFormats) |
|
31 : |
|
32 COmxILPort(aCommonPortData) |
|
33 { |
|
34 DEBUG_PRINTF(_L8("COmxILVideoPort::COmxILVideoPort")); |
|
35 |
|
36 // Performing a deep copy of these arrays inside a C++ constructor is unsafe. |
|
37 // Items should be added to these arrays directly inside the derived class' ConstructL(). |
|
38 __ASSERT_ALWAYS(aSupportedVideoFormats.Count() == 0 && aSupportedColorFormats.Count() == 0, User::Invariant()); |
|
39 TInt numVideoFormats = iSupportedVideoFormats.Count(); |
|
40 TInt numColorFormats = iSupportedColorFormats.Count(); |
|
41 iParamVideoPortFormat.nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); |
|
42 iParamVideoPortFormat.nVersion = aCommonPortData.iOmxVersion; |
|
43 iParamVideoPortFormat.nPortIndex = aCommonPortData.iPortIndex; |
|
44 iParamVideoPortFormat.nIndex = numVideoFormats ? numVideoFormats - 1 : 0; |
|
45 iParamVideoPortFormat.eCompressionFormat = numVideoFormats ? iSupportedVideoFormats[0] : OMX_VIDEO_CodingUnused; |
|
46 iParamVideoPortFormat.eColorFormat = numColorFormats ? iSupportedColorFormats[0] : OMX_COLOR_FormatUnused; |
|
47 iParamVideoPortFormat.xFramerate = 0;//aCommonPortData.xFramerate???; |
|
48 |
|
49 } |
|
50 |
|
51 EXPORT_C |
|
52 COmxILVideoPort::~COmxILVideoPort() |
|
53 { |
|
54 DEBUG_PRINTF(_L8("COmxILVideoPort::~COmxILVideoPort")); |
|
55 iSupportedVideoFormats.Close(); |
|
56 iSupportedColorFormats.Close(); |
|
57 } |
|
58 |
|
59 EXPORT_C OMX_ERRORTYPE |
|
60 COmxILVideoPort::GetLocalOmxParamIndexes(RArray<TUint>& aIndexArray) const |
|
61 { |
|
62 DEBUG_PRINTF(_L8("COmxILVideoPort::GetLocalOmxParamIndexes")); |
|
63 |
|
64 // Always collect local indexes from parent |
|
65 OMX_ERRORTYPE omxRetValue = COmxILPort::GetLocalOmxParamIndexes(aIndexArray); |
|
66 |
|
67 if (OMX_ErrorNone != omxRetValue) |
|
68 { |
|
69 return omxRetValue; |
|
70 } |
|
71 |
|
72 TInt err = aIndexArray.InsertInOrder(OMX_IndexParamVideoPortFormat); |
|
73 |
|
74 // Note that index duplication is OK. |
|
75 if (KErrNone != err && KErrAlreadyExists != err) |
|
76 { |
|
77 return OMX_ErrorInsufficientResources; |
|
78 } |
|
79 |
|
80 return OMX_ErrorNone; |
|
81 |
|
82 } |
|
83 |
|
84 EXPORT_C OMX_ERRORTYPE |
|
85 COmxILVideoPort::GetLocalOmxConfigIndexes(RArray<TUint>& aIndexArray) const |
|
86 { |
|
87 DEBUG_PRINTF(_L8("COmxILVideoPort::GetLocalOmxConfigIndexes")); |
|
88 |
|
89 // Always collect local indexes from parent |
|
90 return COmxILPort::GetLocalOmxConfigIndexes(aIndexArray); |
|
91 |
|
92 } |
|
93 |
|
94 EXPORT_C OMX_ERRORTYPE COmxILVideoPort::GetParameter(OMX_INDEXTYPE aParamIndex, TAny* apComponentParameterStructure) const |
|
95 { |
|
96 DEBUG_PRINTF(_L8("COmxILVideoPort::GetParameter")); |
|
97 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
98 |
|
99 switch(aParamIndex) |
|
100 { |
|
101 case OMX_IndexParamVideoPortFormat: |
|
102 { |
|
103 if (OMX_ErrorNone != (omxRetValue = |
|
104 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
105 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
106 sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)))) |
|
107 { |
|
108 return omxRetValue; |
|
109 } |
|
110 |
|
111 OMX_VIDEO_PARAM_PORTFORMATTYPE* videoPortDefinition = static_cast<OMX_VIDEO_PARAM_PORTFORMATTYPE*>(apComponentParameterStructure); |
|
112 |
|
113 if(OMX_VIDEO_CodingUnused == iParamVideoPortFormat.eCompressionFormat) |
|
114 { |
|
115 if (videoPortDefinition->nIndex >= iSupportedColorFormats.Count()) |
|
116 { |
|
117 return OMX_ErrorNoMore; |
|
118 } |
|
119 videoPortDefinition->eColorFormat = iSupportedColorFormats[videoPortDefinition->nIndex]; |
|
120 } |
|
121 else |
|
122 { |
|
123 if (videoPortDefinition->nIndex >= iSupportedVideoFormats.Count()) |
|
124 { |
|
125 return OMX_ErrorNoMore; |
|
126 } |
|
127 videoPortDefinition->eCompressionFormat = iSupportedVideoFormats[videoPortDefinition->nIndex]; |
|
128 } |
|
129 videoPortDefinition->xFramerate = iParamVideoPortFormat.xFramerate; |
|
130 break; |
|
131 } |
|
132 default: |
|
133 { |
|
134 // Try the parent's indexes |
|
135 return COmxILPort::GetParameter(aParamIndex, apComponentParameterStructure); |
|
136 } |
|
137 }; |
|
138 |
|
139 return OMX_ErrorNone; |
|
140 } |
|
141 |
|
142 EXPORT_C OMX_ERRORTYPE COmxILVideoPort::SetParameter(OMX_INDEXTYPE aParamIndex, const TAny* apComponentParameterStructure, TBool& aUpdateProcessingFunction) |
|
143 { |
|
144 DEBUG_PRINTF(_L8("COmxILVideoPort::SetParameter")); |
|
145 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
146 |
|
147 switch(aParamIndex) |
|
148 { |
|
149 case OMX_IndexParamVideoPortFormat: |
|
150 { |
|
151 if (OMX_ErrorNone != (omxRetValue = |
|
152 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
153 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
154 sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)))) |
|
155 { |
|
156 return omxRetValue; |
|
157 } |
|
158 |
|
159 const OMX_VIDEO_PARAM_PORTFORMATTYPE *componentParameterStructure = static_cast<const OMX_VIDEO_PARAM_PORTFORMATTYPE*>(apComponentParameterStructure); |
|
160 |
|
161 if(OMX_VIDEO_CodingUnused == componentParameterStructure->eCompressionFormat) |
|
162 { |
|
163 if(OMX_COLOR_FormatUnused == componentParameterStructure->eColorFormat) |
|
164 { |
|
165 // Both Compression Format and Color can not be Unused at the same time. |
|
166 return OMX_ErrorBadParameter; |
|
167 } |
|
168 |
|
169 if(iParamVideoPortFormat.eColorFormat != componentParameterStructure->eColorFormat) |
|
170 { |
|
171 if(KErrNotFound == iSupportedColorFormats.Find(componentParameterStructure->eColorFormat)) |
|
172 { |
|
173 return OMX_ErrorUnsupportedSetting; |
|
174 } |
|
175 else |
|
176 { |
|
177 iParamVideoPortFormat.eColorFormat = componentParameterStructure->eColorFormat; |
|
178 } |
|
179 aUpdateProcessingFunction = ETrue; |
|
180 } |
|
181 |
|
182 if(iParamVideoPortFormat.xFramerate != componentParameterStructure->xFramerate) |
|
183 { |
|
184 iParamVideoPortFormat.xFramerate = componentParameterStructure->xFramerate; |
|
185 aUpdateProcessingFunction = ETrue; |
|
186 } |
|
187 } |
|
188 else |
|
189 { |
|
190 // Data is compressed. Change relevant variables. |
|
191 if (OMX_COLOR_FormatUnused != componentParameterStructure->eColorFormat) |
|
192 { |
|
193 // Both Compression Format and Color can not be Unused at the same time. |
|
194 return OMX_ErrorBadParameter; |
|
195 } |
|
196 |
|
197 if (iParamVideoPortFormat.eCompressionFormat != componentParameterStructure->eCompressionFormat) |
|
198 { |
|
199 if(KErrNotFound == iSupportedVideoFormats.Find(componentParameterStructure->eCompressionFormat)) |
|
200 { |
|
201 return OMX_ErrorUnsupportedSetting; |
|
202 } |
|
203 else |
|
204 { |
|
205 iParamVideoPortFormat.eCompressionFormat = componentParameterStructure->eCompressionFormat; |
|
206 aUpdateProcessingFunction = ETrue; |
|
207 } |
|
208 } |
|
209 } |
|
210 break; |
|
211 } |
|
212 default: |
|
213 { |
|
214 // Try the parent's indexes |
|
215 return COmxILPort::SetParameter(aParamIndex, apComponentParameterStructure, aUpdateProcessingFunction); |
|
216 } |
|
217 }; |
|
218 return OMX_ErrorNone; |
|
219 } |