|
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 #include "log.h" |
|
22 #include "omxilvideoportimpl.h" |
|
23 #include <openmax/il/common/omxilvideoport.h> |
|
24 #include <openmax/il/common/omxilutil.h> |
|
25 |
|
26 COmxILVideoPortImpl* COmxILVideoPortImpl::NewL(const RArray<OMX_VIDEO_CODINGTYPE>& aSupportedVideoFormats, |
|
27 const RArray<OMX_COLOR_FORMATTYPE>& aSupportedColorFormats, |
|
28 const TOmxILCommonPortData& aCommonPortData) |
|
29 { |
|
30 COmxILVideoPortImpl* self = new (ELeave) COmxILVideoPortImpl(); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(aSupportedVideoFormats, aSupportedColorFormats, aCommonPortData); |
|
33 CleanupStack::Pop(); |
|
34 return self; |
|
35 } |
|
36 |
|
37 void COmxILVideoPortImpl::ConstructL(const RArray<OMX_VIDEO_CODINGTYPE>& aSupportedVideoFormats, |
|
38 const RArray<OMX_COLOR_FORMATTYPE>& aSupportedColorFormats, |
|
39 const TOmxILCommonPortData& aCommonPortData) |
|
40 { |
|
41 |
|
42 TUint count = aSupportedVideoFormats.Count(); |
|
43 for (TInt i = 0; i < count; i++) |
|
44 { |
|
45 iSupportedVideoFormats.AppendL(aSupportedVideoFormats[i]); |
|
46 } |
|
47 |
|
48 count = aSupportedColorFormats.Count(); |
|
49 for (TInt i = 0; i < count; i++) |
|
50 { |
|
51 iSupportedColorFormats.AppendL(aSupportedColorFormats[i]); |
|
52 } |
|
53 |
|
54 TInt numVideoFormats = iSupportedVideoFormats.Count(); |
|
55 TInt numColorFormats = iSupportedColorFormats.Count(); |
|
56 iParamVideoPortFormat.nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE); |
|
57 iParamVideoPortFormat.nVersion = aCommonPortData.iOmxVersion; |
|
58 iParamVideoPortFormat.nPortIndex = aCommonPortData.iPortIndex; |
|
59 iParamVideoPortFormat.nIndex = numVideoFormats ? numVideoFormats - 1 : 0; |
|
60 iParamVideoPortFormat.eCompressionFormat = numVideoFormats ? iSupportedVideoFormats[0] : OMX_VIDEO_CodingUnused; |
|
61 iParamVideoPortFormat.eColorFormat = numColorFormats ? iSupportedColorFormats[0] : OMX_COLOR_FormatUnused; |
|
62 iParamVideoPortFormat.xFramerate = 0;//aCommonPortData.xFramerate???; |
|
63 } |
|
64 |
|
65 COmxILVideoPortImpl::COmxILVideoPortImpl() |
|
66 { |
|
67 DEBUG_PRINTF(_L8("COmxILVideoPortImpl::COmxILVideoPortImpl")); |
|
68 } |
|
69 |
|
70 COmxILVideoPortImpl::~COmxILVideoPortImpl() |
|
71 { |
|
72 DEBUG_PRINTF(_L8("COmxILVideoPortImpl::~COmxILVideoPortImpl")); |
|
73 iSupportedVideoFormats.Close(); |
|
74 iSupportedColorFormats.Close(); |
|
75 } |
|
76 |
|
77 OMX_ERRORTYPE COmxILVideoPortImpl::GetParameter(OMX_INDEXTYPE aParamIndex, TAny* apComponentParameterStructure) const |
|
78 { |
|
79 DEBUG_PRINTF(_L8("COmxILVideoPortImpl::GetParameter")); |
|
80 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
81 |
|
82 switch(aParamIndex) |
|
83 { |
|
84 case OMX_IndexParamVideoPortFormat: |
|
85 { |
|
86 if (OMX_ErrorNone != (omxRetValue = |
|
87 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
88 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
89 sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)))) |
|
90 { |
|
91 return omxRetValue; |
|
92 } |
|
93 |
|
94 OMX_VIDEO_PARAM_PORTFORMATTYPE* videoPortDefinition = static_cast<OMX_VIDEO_PARAM_PORTFORMATTYPE*>(apComponentParameterStructure); |
|
95 |
|
96 if(OMX_VIDEO_CodingUnused == iParamVideoPortFormat.eCompressionFormat) |
|
97 { |
|
98 if (videoPortDefinition->nIndex >= iSupportedColorFormats.Count()) |
|
99 { |
|
100 return OMX_ErrorNoMore; |
|
101 } |
|
102 videoPortDefinition->eColorFormat = iSupportedColorFormats[videoPortDefinition->nIndex]; |
|
103 } |
|
104 else |
|
105 { |
|
106 if (videoPortDefinition->nIndex >= iSupportedVideoFormats.Count()) |
|
107 { |
|
108 return OMX_ErrorNoMore; |
|
109 } |
|
110 videoPortDefinition->eCompressionFormat = iSupportedVideoFormats[videoPortDefinition->nIndex]; |
|
111 } |
|
112 videoPortDefinition->xFramerate = iParamVideoPortFormat.xFramerate; |
|
113 break; |
|
114 } |
|
115 default: |
|
116 __ASSERT_ALWAYS(EFalse, User::Panic(KOmxILVideoPortPanicCategory, 1)); |
|
117 }; |
|
118 |
|
119 return OMX_ErrorNone; |
|
120 } |
|
121 |
|
122 OMX_ERRORTYPE COmxILVideoPortImpl::SetParameter(OMX_INDEXTYPE aParamIndex, const TAny* apComponentParameterStructure, TBool& aUpdateProcessingFunction) |
|
123 { |
|
124 DEBUG_PRINTF(_L8("COmxILVideoPortImpl::SetParameter")); |
|
125 OMX_ERRORTYPE omxRetValue = OMX_ErrorNone; |
|
126 switch(aParamIndex) |
|
127 { |
|
128 case OMX_IndexParamVideoPortFormat: |
|
129 { |
|
130 if (OMX_ErrorNone != (omxRetValue = |
|
131 TOmxILUtil::CheckOmxStructSizeAndVersion( |
|
132 const_cast<OMX_PTR>(apComponentParameterStructure), |
|
133 sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE)))) |
|
134 { |
|
135 return omxRetValue; |
|
136 } |
|
137 |
|
138 const OMX_VIDEO_PARAM_PORTFORMATTYPE *componentParameterStructure = static_cast<const OMX_VIDEO_PARAM_PORTFORMATTYPE*>(apComponentParameterStructure); |
|
139 |
|
140 if (!UpdateColorFormat(iParamVideoPortFormat.eColorFormat, componentParameterStructure->eColorFormat, aUpdateProcessingFunction)) |
|
141 { |
|
142 return OMX_ErrorUnsupportedSetting; |
|
143 } |
|
144 |
|
145 if (!UpdateCodingType(iParamVideoPortFormat.eCompressionFormat, componentParameterStructure->eCompressionFormat, aUpdateProcessingFunction)) |
|
146 { |
|
147 return OMX_ErrorUnsupportedSetting; |
|
148 } |
|
149 |
|
150 if(iParamVideoPortFormat.eCompressionFormat == OMX_VIDEO_CodingUnused) |
|
151 { |
|
152 if(iParamVideoPortFormat.xFramerate != componentParameterStructure->xFramerate) |
|
153 { |
|
154 iParamVideoPortFormat.xFramerate = componentParameterStructure->xFramerate; |
|
155 aUpdateProcessingFunction = ETrue; |
|
156 } |
|
157 } |
|
158 break; |
|
159 } |
|
160 default: |
|
161 __ASSERT_ALWAYS(EFalse, User::Panic(KOmxILVideoPortPanicCategory, 1)); |
|
162 }; |
|
163 return OMX_ErrorNone; |
|
164 } |
|
165 |
|
166 TBool COmxILVideoPortImpl::UpdateColorFormat(OMX_COLOR_FORMATTYPE& aOldColor, OMX_COLOR_FORMATTYPE aNewColor, TBool& aUpdated) |
|
167 { |
|
168 if (aNewColor != aOldColor) |
|
169 { |
|
170 if(iSupportedColorFormats.Find(aNewColor) == KErrNotFound) |
|
171 { |
|
172 return EFalse; |
|
173 } |
|
174 aOldColor = aNewColor; |
|
175 aUpdated = ETrue; |
|
176 } |
|
177 |
|
178 return ETrue; |
|
179 } |
|
180 |
|
181 TBool COmxILVideoPortImpl::UpdateCodingType(OMX_VIDEO_CODINGTYPE& aOldCodingType, OMX_VIDEO_CODINGTYPE aNewCodingType, TBool& aUpdated) |
|
182 { |
|
183 if (aNewCodingType != aOldCodingType) |
|
184 { |
|
185 if(iSupportedVideoFormats.Find(aNewCodingType) == KErrNotFound) |
|
186 { |
|
187 return EFalse; |
|
188 } |
|
189 aOldCodingType = aNewCodingType; |
|
190 aUpdated = ETrue; |
|
191 } |
|
192 |
|
193 return ETrue; |
|
194 } |
|
195 |
|
196 RArray<OMX_VIDEO_CODINGTYPE>& COmxILVideoPortImpl::GetSupportedVideoFormats() |
|
197 { |
|
198 return iSupportedVideoFormats; |
|
199 } |
|
200 |
|
201 RArray<OMX_COLOR_FORMATTYPE>& COmxILVideoPortImpl::GetSupportedColorFormats() |
|
202 { |
|
203 return iSupportedColorFormats; |
|
204 } |
|
205 |
|
206 OMX_VIDEO_PARAM_PORTFORMATTYPE& COmxILVideoPortImpl::GetParamVideoPortFormat() |
|
207 { |
|
208 return iParamVideoPortFormat; |
|
209 } |