1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <stdio.h> |
|
19 #include <stdlib.h> |
|
20 #include <assert.h> |
|
21 #include "xaimageeffectsitf.h" |
|
22 |
|
23 #include "xaimageeffectsitfadaptation.h" |
|
24 |
|
25 static XAImageEffectsItfImpl* GetImpl(XAImageEffectsItf self) |
|
26 { |
|
27 if(self) |
|
28 { |
|
29 XAImageEffectsItfImpl* impl = (XAImageEffectsItfImpl*)(*self); |
|
30 if(impl && (impl == impl->self)) |
|
31 { |
|
32 return impl; |
|
33 } |
|
34 } |
|
35 return NULL; |
|
36 } |
|
37 |
|
38 /** |
|
39 * Base interface XAImageEffectsItf implementation |
|
40 */ |
|
41 |
|
42 /** |
|
43 * XAresult XAImageEffectsItfImpl_QuerySupportedImageEffects(XAImageEffectsItf self, |
|
44 * XAuint32 index, |
|
45 * XAuint32 *pImageEffectId) |
|
46 * Description: Queries image effects supported. |
|
47 **/ |
|
48 XAresult XAImageEffectsItfImpl_QuerySupportedImageEffects(XAImageEffectsItf self, |
|
49 XAuint32 index, |
|
50 XAuint32 *pImageEffectId) |
|
51 { |
|
52 XAresult ret = XA_RESULT_SUCCESS; |
|
53 XAImageEffectsItfImpl* impl = GetImpl(self); |
|
54 DEBUG_API("->XAImageEffectsItfImpl_QuerySupportedImageEffects"); |
|
55 |
|
56 if(!impl || !pImageEffectId) |
|
57 { |
|
58 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
59 /* invalid parameter */ |
|
60 DEBUG_API("<-XAImageEffectsItfImpl_QuerySupportedImageEffects"); |
|
61 return XA_RESULT_PARAMETER_INVALID; |
|
62 } |
|
63 |
|
64 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
65 if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED ) |
|
66 { |
|
67 DEBUG_API("<-XAImageEffectsItfImpl_QuerySupportedImageEffects"); |
|
68 return ret; |
|
69 } |
|
70 |
|
71 ret = XAImageEffectsItfAdapt_QuerySupportedImageEffects((XAAdaptationGstCtx*)impl->adapCtx, index, |
|
72 pImageEffectId); |
|
73 |
|
74 if( ret == XA_RESULT_SUCCESS ) |
|
75 { |
|
76 impl->index = index; |
|
77 } |
|
78 |
|
79 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
80 |
|
81 DEBUG_API("<-XAImageEffectsItfImpl_QuerySupportedImageEffects"); |
|
82 return ret; |
|
83 } |
|
84 |
|
85 /** |
|
86 * XAresult XAImageEffectsItfImpl_EnableImageEffect(XAImageEffectsItf self, |
|
87 * XAuint32 imageEffectID |
|
88 * Description: Enables an image effect. |
|
89 **/ |
|
90 XAresult XAImageEffectsItfImpl_EnableImageEffect(XAImageEffectsItf self, |
|
91 XAuint32 imageEffectID) |
|
92 { |
|
93 XAresult ret = XA_RESULT_SUCCESS; |
|
94 XAImageEffectsItfImpl* impl = GetImpl(self); |
|
95 DEBUG_API("->XAImageEffectsItfImpl_EnableImageEffect"); |
|
96 |
|
97 if(!impl) |
|
98 { |
|
99 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
100 /* invalid parameter */ |
|
101 DEBUG_API("<-XAImageEffectsItfImpl_EnableImageEffect"); |
|
102 return XA_RESULT_PARAMETER_INVALID; |
|
103 } |
|
104 |
|
105 |
|
106 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
107 if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED ) |
|
108 { |
|
109 DEBUG_API("<-XAImageEffectsItfImpl_EnableImageEffect"); |
|
110 return ret; |
|
111 } |
|
112 |
|
113 ret = XAImageEffectsItfAdapt_EnableImageEffect((XAAdaptationGstCtx*)impl->adapCtx, imageEffectID); |
|
114 |
|
115 if( ret == XA_RESULT_SUCCESS ) |
|
116 { |
|
117 impl->imageEffectID = imageEffectID; |
|
118 } |
|
119 |
|
120 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
121 |
|
122 DEBUG_API("<-XAImageEffectsItfImpl_EnableImageEffect"); |
|
123 return ret; |
|
124 } |
|
125 |
|
126 /** |
|
127 * XAresult XAImageEffectsItfImpl_DisableImageEffect(XAImageEffectsItf self, |
|
128 * XAuint32 imageEffectID) |
|
129 * Description: Disable an image effect. |
|
130 **/ |
|
131 XAresult XAImageEffectsItfImpl_DisableImageEffect(XAImageEffectsItf self, |
|
132 XAuint32 imageEffectID) |
|
133 { |
|
134 XAresult ret = XA_RESULT_SUCCESS; |
|
135 XAImageEffectsItfImpl* impl = GetImpl(self); |
|
136 DEBUG_API("->XAImageEffectsItfImpl_DisableImageEffect"); |
|
137 |
|
138 if(!impl) |
|
139 { |
|
140 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
141 /* invalid parameter */ |
|
142 DEBUG_API("<-XAImageEffectsItfImpl_DisableImageEffect"); |
|
143 return XA_RESULT_PARAMETER_INVALID; |
|
144 } |
|
145 |
|
146 |
|
147 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
148 if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED ) |
|
149 { |
|
150 DEBUG_API("<-XAImageEffectsItfImpl_DisableImageEffect"); |
|
151 return ret; |
|
152 } |
|
153 |
|
154 ret = XAImageEffectsItfAdapt_DisableImageEffect((XAAdaptationGstCtx*)impl->adapCtx, imageEffectID); |
|
155 |
|
156 if( ret == XA_RESULT_SUCCESS ) |
|
157 { |
|
158 impl->imageEffectID = NO_IMAGE_EFFECTS; |
|
159 } |
|
160 |
|
161 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
162 |
|
163 DEBUG_API("<-XAImageEffectsItfImpl_DisableImageEffect"); |
|
164 return ret; |
|
165 } |
|
166 |
|
167 /** |
|
168 * XAresult XAImageEffectsItfImpl_IsImageEffectEnabled(XAImageEffectsItf self, |
|
169 * XAuint32 imageEffectID, |
|
170 * XAboolean *pEnabled) |
|
171 * Description: Checks to see if an image effect is enabled. |
|
172 **/ |
|
173 XAresult XAImageEffectsItfImpl_IsImageEffectEnabled(XAImageEffectsItf self, |
|
174 XAuint32 imageEffectID, |
|
175 XAboolean *pEnabled) |
|
176 { |
|
177 XAresult ret = XA_RESULT_SUCCESS; |
|
178 XAImageEffectsItfImpl* impl = GetImpl(self); |
|
179 DEBUG_API("->XAImageEffectsItfImpl_IsImageEffectEnabled"); |
|
180 |
|
181 if(!impl || !pEnabled) |
|
182 { |
|
183 DEBUG_ERR("XA_RESUT_PARAMETER_INVALID"); |
|
184 /* invalid parameter */ |
|
185 DEBUG_API("<-XAImageEffectsItfImpl_IsImageEffectEnabled"); |
|
186 return XA_RESULT_PARAMETER_INVALID; |
|
187 } |
|
188 |
|
189 |
|
190 ret = XAAdaptationBase_ThreadEntry(impl->adapCtx); |
|
191 if( ret == XA_RESULT_PARAMETER_INVALID || ret == XA_RESULT_PRECONDITIONS_VIOLATED ) |
|
192 { |
|
193 DEBUG_API("<-XAImageEffectsItfImpl_IsImageEffectEnabled"); |
|
194 return ret; |
|
195 } |
|
196 |
|
197 ret = XAImageEffectsItfAdapt_IsImageEffectEnabled((XAAdaptationGstCtx*)impl->adapCtx, imageEffectID, |
|
198 pEnabled); |
|
199 |
|
200 XAAdaptationBase_ThreadExit(impl->adapCtx); |
|
201 |
|
202 DEBUG_API("<-XAImageEffectsItfImpl_IsImageEffectEnabled"); |
|
203 return ret; |
|
204 } |
|
205 |
|
206 /** |
|
207 * XAImageEffectsItfImpl -specific methods |
|
208 **/ |
|
209 |
|
210 /** |
|
211 * XAImageEffectsItfImplImpl* XAImageEffectsItfImpl_Create() |
|
212 * @return XAImageEffectsItfImplImpl* - Pointer to ImageEffectsItf interface implementation |
|
213 **/ |
|
214 XAImageEffectsItfImpl* XAImageEffectsItfImpl_Create(XAAdaptationBaseCtx *adapCtx) |
|
215 { |
|
216 XAImageEffectsItfImpl* self = (XAImageEffectsItfImpl*) |
|
217 calloc(1,sizeof(XAImageEffectsItfImpl)); |
|
218 DEBUG_API("->XAImageEffectsItfImpl_Create"); |
|
219 if(self) |
|
220 { |
|
221 /* init itf default implementation */ |
|
222 self->itf.DisableImageEffect = XAImageEffectsItfImpl_DisableImageEffect; |
|
223 self->itf.EnableImageEffect = XAImageEffectsItfImpl_EnableImageEffect; |
|
224 self->itf.IsImageEffectEnabled = XAImageEffectsItfImpl_IsImageEffectEnabled; |
|
225 self->itf.QuerySupportedImageEffects = XAImageEffectsItfImpl_QuerySupportedImageEffects; |
|
226 |
|
227 /* init variables */ |
|
228 self->enabled = XA_BOOLEAN_FALSE; |
|
229 self->index = 0; |
|
230 self->imageEffectID = NO_IMAGE_EFFECTS; |
|
231 self->adapCtx = adapCtx; |
|
232 |
|
233 self->self = self; |
|
234 } |
|
235 DEBUG_API("<-XAImageEffectsItfImpl_Create"); |
|
236 return self; |
|
237 } |
|
238 |
|
239 /** |
|
240 * void XAImageEffectsItfImpl_Free(XAImageEffectsItfImpl* self) |
|
241 * @param XAImageEffectsItfImpl* self - |
|
242 **/ |
|
243 void XAImageEffectsItfImpl_Free(XAImageEffectsItfImpl* self) |
|
244 { |
|
245 DEBUG_API("->XAImageEffectsItfImpl_Free"); |
|
246 assert(self==self->self); |
|
247 free(self); |
|
248 DEBUG_API("<-XAImageEffectsItfImpl_Free"); |
|
249 } |
|