25 #include "xaengine.h" |
25 #include "xaengine.h" |
26 /* |
26 /* |
27 * compare two XAInterfaceIDs, return true if same |
27 * compare two XAInterfaceIDs, return true if same |
28 */ |
28 */ |
29 XAboolean XACommon_EqualIIds(XAInterfaceID idA, XAInterfaceID idB) |
29 XAboolean XACommon_EqualIIds(XAInterfaceID idA, XAInterfaceID idB) |
30 { |
30 { |
31 XAboolean nodeOk; |
31 XAboolean nodeOk; |
32 XAuint16 nodeIdx; |
32 XAuint16 nodeIdx; |
33 if(idA==idB) return XA_BOOLEAN_TRUE; |
33 if (idA == idB) |
34 if(!idA||!idB) return XA_BOOLEAN_FALSE; |
34 return XA_BOOLEAN_TRUE; |
35 if( idA->time_low == idB->time_low && |
35 if (!idA || !idB) |
36 idA->time_mid == idB->time_mid && |
36 return XA_BOOLEAN_FALSE; |
37 idA->time_hi_and_version == idB->time_hi_and_version && |
37 if (idA->time_low == idB->time_low && idA->time_mid == idB->time_mid |
38 idA->clock_seq == idB->clock_seq) |
38 && idA->time_hi_and_version == idB->time_hi_and_version |
39 { |
39 && idA->clock_seq == idB->clock_seq) |
40 nodeOk = XA_BOOLEAN_TRUE; |
40 { |
41 for(nodeIdx = 0; nodeIdx < sizeof(idA->node); nodeIdx++ ) |
41 nodeOk = XA_BOOLEAN_TRUE; |
42 { |
42 for (nodeIdx = 0; nodeIdx < sizeof(idA->node); nodeIdx++) |
43 if(idA->node[nodeIdx] != idB->node[nodeIdx]) |
43 { |
44 { |
44 if (idA->node[nodeIdx] != idB->node[nodeIdx]) |
45 nodeOk = XA_BOOLEAN_FALSE; |
45 { |
46 break; |
46 nodeOk = XA_BOOLEAN_FALSE; |
47 } |
47 break; |
48 } |
48 } |
49 if(nodeOk) |
49 } |
50 { |
50 if (nodeOk) |
51 return XA_BOOLEAN_TRUE; |
51 { |
|
52 return XA_BOOLEAN_TRUE; |
52 } |
53 } |
53 } |
54 } |
54 return XA_BOOLEAN_FALSE; |
55 return XA_BOOLEAN_FALSE; |
55 } |
56 } |
56 |
57 |
57 /* Check source availability and content type. Return error only if we are sure |
58 /* Check source availability and content type. Return error only if we are sure |
58 * content is not valid, otherwise let adaptation try to identify and use content. |
59 * content is not valid, otherwise let adaptation try to identify and use content. |
59 * @param type: on return, contains content type, if known. |
60 * @param type: on return, contains content type, if known. |
60 * @return Success code |
61 * @return Success code |
61 */ |
62 */ |
62 XAresult XACommon_CheckDataSource(XADataSource* source, XAMediaType* type) |
63 XAresult XACommon_CheckDataSource(XADataSource* source, XAMediaType* type) |
63 { |
|
64 XAresult ret=XA_RESULT_SUCCESS; |
|
65 XAchar* fname=NULL; |
|
66 XAchar* mime=NULL; |
|
67 XAboolean isLocal=XA_BOOLEAN_FALSE; |
|
68 |
|
69 |
|
70 if(!source || !source->pLocator) |
|
71 { |
64 { |
|
65 XAresult ret = XA_RESULT_SUCCESS; |
|
66 XAchar* fname = NULL; |
|
67 XAchar* mime = NULL; |
|
68 XAboolean isLocal = XA_BOOLEAN_FALSE; |
|
69 |
|
70 if (!source || !source->pLocator) |
|
71 { |
72 DEBUG_ERR("Invalid XADataSource structure!!"); |
72 DEBUG_ERR("Invalid XADataSource structure!!"); |
73 return XA_RESULT_PARAMETER_INVALID; |
73 return XA_RESULT_PARAMETER_INVALID; |
74 } |
74 } |
75 |
75 |
76 /* check URI availability */ |
76 /* check URI availability */ |
77 if( *(XAuint32*)(source->pLocator) == XA_DATALOCATOR_URI ) |
77 if (*(XAuint32*) (source->pLocator) == XA_DATALOCATOR_URI) |
78 { |
78 { |
79 fname = (XAchar*)((XADataLocator_URI*)(source->pLocator))->URI; |
79 fname = (XAchar*) ((XADataLocator_URI*) (source->pLocator))->URI; |
80 /* check protocol prefix */ |
80 /* check protocol prefix */ |
81 if(strstr((char*)fname,":///")) |
81 if (strstr((char*) fname, "://")) |
82 { |
82 { |
83 if(strncmp((char*)fname, "file:///", 8) == 0) |
83 if (strncmp((char*) fname, "file:///", 8) == 0) |
84 { |
84 { |
85 isLocal=XA_BOOLEAN_TRUE; |
85 isLocal = XA_BOOLEAN_TRUE; |
86 fname += 8; |
86 fname += 8; |
87 } |
87 } |
88 else |
88 else |
89 { /* add support for other protocols if needed */ |
89 { /* add support for other protocols if needed */ |
90 isLocal=XA_BOOLEAN_FALSE; |
90 isLocal = XA_BOOLEAN_FALSE; |
91 } |
91 } |
92 } |
92 } |
93 else |
93 else |
94 { |
94 { |
95 isLocal=XA_BOOLEAN_TRUE; |
95 isLocal = XA_BOOLEAN_TRUE; |
96 } |
96 } |
97 if(isLocal) |
97 if (isLocal) |
98 { |
98 { |
99 FILE* file=fopen((char*)fname, "r"); |
99 FILE* file = fopen((char*) fname, "r"); |
100 if(!file) |
100 if (!file) |
101 { |
101 { |
102 DEBUG_INFO_A1("%s not found from filesystem", fname); |
102 DEBUG_INFO_A1("%s not found from filesystem", fname); |
103 ret = XA_RESULT_CONTENT_NOT_FOUND; |
103 ret = XA_RESULT_CONTENT_NOT_FOUND; |
104 } |
104 } |
105 else |
105 else |
106 { |
106 { |
107 fclose(file); |
107 fclose(file); |
108 } |
108 } |
109 } |
109 } |
110 } |
110 } |
111 |
111 |
112 /* check content type */ |
112 /* check content type */ |
113 if( type ) |
113 if (type) |
114 { |
114 { |
115 if(source->pFormat) |
115 if (source->pFormat) |
116 { |
116 { |
117 switch( *(XAuint32*)source->pFormat ) |
117 switch (*(XAuint32*) source->pFormat) |
118 { |
118 { |
119 case XA_DATAFORMAT_MIME: |
119 case XA_DATAFORMAT_MIME: |
120 { |
120 { |
121 /* try to parse mimetype first */ |
121 /* try to parse mimetype first */ |
122 mime = ((XADataFormat_MIME*)(source->pFormat))->mimeType; |
122 mime = ((XADataFormat_MIME*) (source->pFormat))->mimeType; |
123 if(mime && (strncmp((char*)mime,"audio",5)==0)) |
123 if (mime && (strncmp((char*) mime, "audio", 5) == 0)) |
124 { |
124 { |
125 *type = XA_MEDIATYPE_AUDIO; |
125 *type = XA_MEDIATYPE_AUDIO; |
126 } |
126 } |
127 else if(mime && (strncmp((char*)mime,"video",5)==0)) |
127 else if (mime && (strncmp((char*) mime, "video", 5) == 0)) |
128 { |
128 { |
129 *type = XA_MEDIATYPE_VIDEO; |
129 *type = XA_MEDIATYPE_VIDEO; |
130 } |
130 } |
131 else if(mime && (strncmp((char*)mime,"image",5)==0)) |
131 else if (mime && (strncmp((char*) mime, "image", 5) == 0)) |
132 { |
132 { |
133 *type = XA_MEDIATYPE_IMAGE; |
133 *type = XA_MEDIATYPE_IMAGE; |
134 } |
134 } |
135 else |
135 else |
136 { |
136 { |
137 /* try to parse containertype next */ |
137 /* try to parse containertype next */ |
138 switch( ((XADataFormat_MIME*)(source->pFormat))->containerType ) |
138 switch (((XADataFormat_MIME*) (source->pFormat))->containerType) |
139 { |
139 { |
140 case XA_CONTAINERTYPE_M4A: |
140 case XA_CONTAINERTYPE_M4A: |
141 case XA_CONTAINERTYPE_MP3: |
141 case XA_CONTAINERTYPE_MP3: |
142 case XA_CONTAINERTYPE_WAV: |
142 case XA_CONTAINERTYPE_WAV: |
143 case XA_CONTAINERTYPE_XMF_0: |
143 case XA_CONTAINERTYPE_XMF_0: |
144 case XA_CONTAINERTYPE_XMF_1: |
144 case XA_CONTAINERTYPE_XMF_1: |
175 case XA_CONTAINERTYPE_RAW: |
175 case XA_CONTAINERTYPE_RAW: |
176 case XA_CONTAINERTYPE_UNSPECIFIED: |
176 case XA_CONTAINERTYPE_UNSPECIFIED: |
177 default: |
177 default: |
178 *type = XA_MEDIATYPE_UNKNOWN; |
178 *type = XA_MEDIATYPE_UNKNOWN; |
179 break; |
179 break; |
|
180 } |
180 } |
181 } |
181 } |
182 } |
182 } |
183 break; |
183 break; |
|
184 |
184 |
185 case XA_DATAFORMAT_PCM: |
185 case XA_DATAFORMAT_PCM: |
186 *type = XA_MEDIATYPE_AUDIO; |
186 *type = XA_MEDIATYPE_AUDIO; |
187 break; |
187 break; |
188 |
188 |
189 case XA_DATAFORMAT_RAWIMAGE: |
189 case XA_DATAFORMAT_RAWIMAGE: |
190 *type = XA_MEDIATYPE_IMAGE; |
190 *type = XA_MEDIATYPE_IMAGE; |
191 break; |
191 break; |
192 |
192 |
193 default: |
193 default: |
194 *type = XA_MEDIATYPE_UNKNOWN; |
194 *type = XA_MEDIATYPE_UNKNOWN; |
195 DEBUG_INFO("Warning: unknown dataformat"); |
195 DEBUG_INFO("Warning: unknown dataformat") |
196 break; |
196 ; |
197 } |
197 break; |
198 } |
198 } |
|
199 } |
199 else |
200 else |
200 { |
201 { |
201 DEBUG_ERR("Warning: no data format set"); |
202 DEBUG_ERR("Warning: no data format set"); |
202 *type = XA_MEDIATYPE_UNKNOWN; |
203 *type = XA_MEDIATYPE_UNKNOWN; |
203 } |
204 } |
204 |
205 |
205 /* Expand this list if add new supported media type */ |
206 /* Expand this list if add new supported media type */ |
206 /* If media type unknow check it from file extension */ |
207 /* If media type unknow check it from file extension */ |
207 if(*type == XA_MEDIATYPE_UNKNOWN && fname) |
208 if (*type == XA_MEDIATYPE_UNKNOWN && fname) |
208 { |
209 { |
209 if( (strstr((char*)fname,".wav")) || (strstr((char*)fname,".mid")) |
210 if ((strstr((char*) fname, ".wav")) || (strstr((char*) fname, |
210 || (strstr((char*)fname,".amr"))) |
211 ".mid")) || (strstr((char*) fname, ".amr"))) |
211 { |
212 { |
212 *type = XA_MEDIATYPE_AUDIO; |
213 *type = XA_MEDIATYPE_AUDIO; |
213 } |
214 } |
214 if( (strstr((char*)fname,".avi")) || (strstr((char*)fname,".ogg")) ) |
215 if ((strstr((char*) fname, ".avi")) || (strstr((char*) fname, |
215 { |
216 ".ogg"))) |
216 |
217 { |
217 } |
218 |
218 if(strstr((char*)fname,".jpg")) |
219 } |
219 { |
220 if (strstr((char*) fname, ".jpg")) |
|
221 { |
220 *type = XA_MEDIATYPE_IMAGE; |
222 *type = XA_MEDIATYPE_IMAGE; |
221 } |
223 } |
222 } |
224 } |
|
225 } |
|
226 return ret; |
223 } |
227 } |
224 return ret; |
|
225 } |
|
226 |
228 |
227 /* Validate XADataSink and XADataSrc object creation parameters. |
229 /* Validate XADataSink and XADataSrc object creation parameters. |
228 * @return Success code |
230 * @return Success code |
229 */ |
231 */ |
230 XAresult XACommon_ValidateDataLocator(XAuint32 pCounter, void* pSnk, ... ) |
232 XAresult XACommon_ValidateDataLocator(XAuint32 pCounter, void* pSnk, ...) |
231 { |
233 { |
232 va_list argptr; |
234 va_list argptr; |
233 XAuint32 counter = 0; |
235 XAuint32 counter = 0; |
234 XADataLocator_URI* uri = NULL; |
236 XADataLocator_URI* uri = NULL; |
235 XADataLocator_NativeDisplay* display = NULL; |
237 XADataLocator_NativeDisplay* display = NULL; |
236 XADataLocator_OutputMix* omix = NULL; |
238 XADataLocator_OutputMix* omix = NULL; |
238 XADataLocator_IODevice* iodevice = NULL; |
240 XADataLocator_IODevice* iodevice = NULL; |
239 XAresult ret = XA_RESULT_SUCCESS; |
241 XAresult ret = XA_RESULT_SUCCESS; |
240 XADataSink* xaSnk = NULL; |
242 XADataSink* xaSnk = NULL; |
241 DEBUG_API("->XACommon_ValidateDataLocator"); |
243 DEBUG_API("->XACommon_ValidateDataLocator"); |
242 |
244 |
243 xaSnk = (XADataSink*)pSnk; |
245 xaSnk = (XADataSink*) pSnk; |
244 |
246 |
245 /* Initialize variable arguments. */ |
247 /* Initialize variable arguments. */ |
246 //va_start (argptr, xaSnk); TL: Replaced with: |
248 va_start (argptr, pSnk); |
247 va_start (argptr, pSnk); |
249 while (counter < pCounter) |
248 while( counter < pCounter ) |
250 { |
249 { |
251 if (counter > 0) |
250 if( counter > 0) |
252 { |
251 { |
|
252 /*XADataSink and XADataSrc are equivalent, use XADataSink for both*/ |
253 /*XADataSink and XADataSrc are equivalent, use XADataSink for both*/ |
253 xaSnk = va_arg(argptr, XADataSink*); |
254 xaSnk = va_arg(argptr, XADataSink*); |
254 } |
255 } |
255 if( !xaSnk ) |
256 if( !xaSnk ) |
256 { /*NULL sinks/sources are possible, not checked here*/ |
257 { /*NULL sinks/sources are possible, not checked here*/ |
257 counter++; |
258 counter++; |
258 continue; |
259 continue; |
259 } |
260 } |
260 else if( !xaSnk->pLocator ) |
261 else if( !xaSnk->pLocator ) |
261 { |
262 { |
262 DEBUG_ERR_A1("NULL XADataLocator in parameter %d",(int)counter); |
263 DEBUG_ERR_A1("NULL XADataLocator in parameter %d",(int)counter); |
263 ret = XA_RESULT_PARAMETER_INVALID; |
264 ret = XA_RESULT_PARAMETER_INVALID; |
264 va_end(argptr); |
265 va_end(argptr); |
265 DEBUG_API("<-XACommon_ValidateDataLocator"); |
266 DEBUG_API("<-XACommon_ValidateDataLocator"); |
266 return ret; |
267 return ret; |
267 } |
268 } |
268 switch ( *(XAuint32*)(xaSnk->pLocator) ) |
269 switch ( *(XAuint32*)(xaSnk->pLocator) ) |
269 { |
270 { |
|
271 case XA_DEFAULTDEVICEID_AUDIOOUTPUT: |
|
272 DEBUG_INFO("XA_DEFAULTDEVICEID_AUDIOOUTPUT"); |
|
273 uri = (XADataLocator_URI*)xaSnk->pLocator; |
|
274 break; |
270 case XA_DATALOCATOR_URI: |
275 case XA_DATALOCATOR_URI: |
271 DEBUG_INFO("XA_DATALOCATOR_URI"); |
276 DEBUG_INFO("XA_DATALOCATOR_URI"); |
272 uri = (XADataLocator_URI*)xaSnk->pLocator; |
277 uri = (XADataLocator_URI*)xaSnk->pLocator; |
273 if( !uri->URI && !xaSnk->pFormat ) |
278 if( !uri->URI && !xaSnk->pFormat ) |
274 { |
279 { |
275 DEBUG_ERR("Invalid parameter set for uri "); |
280 DEBUG_ERR("Invalid parameter set for uri "); |
|
281 ret = XA_RESULT_PARAMETER_INVALID; |
|
282 } |
|
283 break; |
|
284 case XA_DATALOCATOR_NATIVEDISPLAY: |
|
285 DEBUG_INFO("Sink locator type - XA_DATALOCATOR_NATIVEDISPLAY"); |
|
286 display = (XADataLocator_NativeDisplay*)(xaSnk->pLocator); |
|
287 if( !display->hDisplay || !display->hWindow ) |
|
288 { |
|
289 /*No action at this time*/ |
|
290 DEBUG_INFO("Warning - no display or window handle set"); |
|
291 } |
|
292 break; |
|
293 case XA_DATALOCATOR_OUTPUTMIX: |
|
294 DEBUG_INFO("Sink locator type - XA_DATALOCATOR_OUTPUTMIX"); |
|
295 { |
|
296 omix = (XADataLocator_OutputMix*)(xaSnk->pLocator); |
|
297 if ( !omix->outputMix ) |
|
298 { |
|
299 DEBUG_ERR("Invalid parameter set for outputmix"); |
276 ret = XA_RESULT_PARAMETER_INVALID; |
300 ret = XA_RESULT_PARAMETER_INVALID; |
277 } |
|
278 break; |
|
279 case XA_DATALOCATOR_NATIVEDISPLAY: |
|
280 DEBUG_INFO("Sink locator type - XA_DATALOCATOR_NATIVEDISPLAY"); |
|
281 display = (XADataLocator_NativeDisplay*)(xaSnk->pLocator); |
|
282 if( !display->hDisplay || !display->hWindow ) |
|
283 { |
|
284 /*No action at this time*/ |
|
285 DEBUG_INFO("Warning - no display or window handle set"); |
|
286 } |
|
287 break; |
|
288 case XA_DATALOCATOR_OUTPUTMIX: |
|
289 DEBUG_INFO("Sink locator type - XA_DATALOCATOR_OUTPUTMIX"); |
|
290 { |
|
291 omix = (XADataLocator_OutputMix*)(xaSnk->pLocator); |
|
292 if ( !omix->outputMix ) |
|
293 { |
|
294 DEBUG_ERR("Invalid parameter set for outputmix"); |
|
295 ret = XA_RESULT_PARAMETER_INVALID; |
|
296 } |
301 } |
297 } |
302 } |
298 break; |
303 break; |
299 case XA_DATALOCATOR_ADDRESS: |
304 case XA_DATALOCATOR_ADDRESS: |
300 DEBUG_INFO("XA_DATALOCATOR_ADDRESS"); |
305 DEBUG_INFO("XA_DATALOCATOR_ADDRESS"); |
301 address = (XADataLocator_Address*)(xaSnk->pLocator); |
306 address = (XADataLocator_Address*)(xaSnk->pLocator); |
302 if( !address->pAddress && !xaSnk->pFormat ) |
307 if( !address->pAddress && !xaSnk->pFormat ) |
303 { |
308 { |
304 DEBUG_ERR("Invalid parameter set for address"); |
309 DEBUG_ERR("Invalid parameter set for address"); |
305 ret = XA_RESULT_PARAMETER_INVALID; |
310 ret = XA_RESULT_PARAMETER_INVALID; |
306 } |
311 } |
307 break; |
312 break; |
308 case XA_DATALOCATOR_IODEVICE: |
313 case XA_DATALOCATOR_IODEVICE: |
309 DEBUG_INFO("XA_DATALOCATOR_IODEVICE"); |
314 DEBUG_INFO("XA_DATALOCATOR_IODEVICE"); |
310 iodevice = (XADataLocator_IODevice*)(xaSnk->pLocator); |
315 iodevice = (XADataLocator_IODevice*)(xaSnk->pLocator); |
311 if( iodevice->device ) |
316 if( iodevice->device ) |
312 { |
317 { |
313 DEBUG_INFO("Media object as IODevice"); |
318 DEBUG_INFO("Media object as IODevice"); |
314 } |
319 } |
315 else |
320 else |
316 { |
321 { |
317 DEBUG_INFO("Iodevice id used"); |
322 DEBUG_INFO("Iodevice id used"); |
318 } |
323 } |
319 break; |
324 break; |
320 default: |
325 default: |
321 DEBUG_ERR("Incorrect data locator for sink.") |
326 DEBUG_ERR("Incorrect data locator for sink.") |
322 ret = XA_RESULT_PARAMETER_INVALID; |
327 ret = XA_RESULT_PARAMETER_INVALID; |
323 break; |
328 break; |
324 } |
329 } |
325 counter ++; |
330 counter ++; |
326 } |
331 } |
327 va_end(argptr); |
332 va_end(argptr); |
328 DEBUG_API("<-XACommon_ValidateDataLocator"); |
333 DEBUG_API("<-XACommon_ValidateDataLocator"); |
329 return ret; |
334 return ret; |
330 } |
335 } |