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 <string.h> |
|
22 |
|
23 #include "xaglobals.h" |
|
24 #include "xaimagedecodercapabilitiesitf.h" |
|
25 |
|
26 #include "xacapabilitiesmgr.h" |
|
27 |
|
28 /* XAImageDecoderCapabilitiesItfImpl* GetImpl |
|
29 * Description: Validate interface pointer and cast it to implementation pointer. |
|
30 */ |
|
31 static XAImageDecoderCapabilitiesItfImpl* GetImpl(XAImageDecoderCapabilitiesItf self) |
|
32 { |
|
33 if( self ) |
|
34 { |
|
35 XAImageDecoderCapabilitiesItfImpl* impl = (XAImageDecoderCapabilitiesItfImpl*)(*self); |
|
36 if( impl && (impl == impl->self) ) |
|
37 { |
|
38 return impl; |
|
39 } |
|
40 } |
|
41 return NULL; |
|
42 } |
|
43 |
|
44 /** |
|
45 * Base interface XAImageDecoderCapabilitiesItf implementation |
|
46 **/ |
|
47 |
|
48 /* XAresult XAImageDecoderCapabilitiesItfImpl_GetImageDecoderCapabilities |
|
49 * Description: Retrieves image decoder capabilities. |
|
50 */ |
|
51 XAresult XAImageDecoderCapabilitiesItfImpl_GetImageDecoderCapabilities( |
|
52 XAImageDecoderCapabilitiesItf self, |
|
53 XAuint32* pDecoderId, |
|
54 XAImageCodecDescriptor* pDescriptor) |
|
55 { |
|
56 XAImageDecoderCapabilitiesItfImpl* impl = NULL; |
|
57 XAresult res = XA_RESULT_SUCCESS; |
|
58 DEBUG_API("->XAImageDecoderCapabilitiesItfImpl_GetImageDecoderCapabilities"); |
|
59 |
|
60 impl = GetImpl(self); |
|
61 if( !impl || !pDecoderId ) |
|
62 { |
|
63 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
64 res = XA_RESULT_PARAMETER_INVALID; |
|
65 } |
|
66 else |
|
67 { |
|
68 if( !pDescriptor ) |
|
69 { /* query number of image decoders */ |
|
70 *pDecoderId = impl->numCodecs; |
|
71 } |
|
72 else |
|
73 { |
|
74 /* query capabilities from adaptation using codec id */ |
|
75 |
|
76 XACapabilities temp; |
|
77 memset(pDescriptor,0,sizeof(XAImageCodecDescriptor)); |
|
78 /* here pEncoderId refers to index rather than codec id */ |
|
79 res = XACapabilitiesMgr_GetCapsByIdx(NULL, (XACapsType)(XACAP_DECODER|XACAP_IMAGE), *pDecoderId, &temp); |
|
80 if( res == XA_RESULT_SUCCESS ) |
|
81 { |
|
82 XAImageCodecDescriptor* desc = (XAImageCodecDescriptor*)(&temp.pEntry); |
|
83 /* map applicable values to XAAudioCodecCapabilities */ |
|
84 pDescriptor->codecId = temp.xaid; |
|
85 pDescriptor->maxWidth = desc->maxWidth; |
|
86 pDescriptor->maxHeight = desc->maxHeight; |
|
87 } |
|
88 |
|
89 } |
|
90 } |
|
91 |
|
92 DEBUG_API("<-XAImageDecoderCapabilitiesItfImpl_GetImageDecoderCapabilities"); |
|
93 return res; |
|
94 } |
|
95 |
|
96 /* XAresult XAImageDecoderCapabilitiesItfImpl_QueryColorFormats |
|
97 * Description: This method is used to query the color formats supported |
|
98 * by the image decoder. |
|
99 */ |
|
100 XAresult XAImageDecoderCapabilitiesItfImpl_QueryColorFormats( |
|
101 const XAImageDecoderCapabilitiesItf self, |
|
102 XAuint32* pIndex, |
|
103 XAuint32* pColorFormats) |
|
104 { |
|
105 XAImageDecoderCapabilitiesItfImpl* impl = NULL; |
|
106 XAresult res = XA_RESULT_SUCCESS; |
|
107 DEBUG_API("->XAImageDecoderCapabilitiesItfImpl_QueryColorFormats"); |
|
108 impl = GetImpl(self); |
|
109 if( !impl || !pIndex ) |
|
110 { |
|
111 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
112 res = XA_RESULT_PARAMETER_INVALID; |
|
113 } |
|
114 else |
|
115 { |
|
116 |
|
117 res = XACapabilitiesMgr_QueryColorFormats(NULL, pIndex, pColorFormats); |
|
118 |
|
119 } |
|
120 DEBUG_API("<-XAImageDecoderCapabilitiesItfImpl_QueryColorFormats"); |
|
121 return res; |
|
122 } |
|
123 |
|
124 /** |
|
125 * XAImageDecoderCapabilitiesItfImpl -specific methods |
|
126 **/ |
|
127 |
|
128 /* XAImageDecoderCapabilitiesItfImpl_Create |
|
129 * Description: Allocate and initialize XAImageDecoderCapabilitiesItfImpl |
|
130 */ |
|
131 XAImageDecoderCapabilitiesItfImpl* XAImageDecoderCapabilitiesItfImpl_Create() |
|
132 { |
|
133 XAImageDecoderCapabilitiesItfImpl* self = (XAImageDecoderCapabilitiesItfImpl*) |
|
134 calloc(1,sizeof(XAImageDecoderCapabilitiesItfImpl)); |
|
135 DEBUG_API("->XAImageDecoderCapabilitiesItfImpl_Create"); |
|
136 |
|
137 if( self ) |
|
138 { |
|
139 /* init itf default implementation */ |
|
140 self->itf.GetImageDecoderCapabilities = |
|
141 XAImageDecoderCapabilitiesItfImpl_GetImageDecoderCapabilities; |
|
142 self->itf.QueryColorFormats = |
|
143 XAImageDecoderCapabilitiesItfImpl_QueryColorFormats; |
|
144 |
|
145 |
|
146 /* init variables */ |
|
147 assert( XACapabilitiesMgr_GetCapsCount( NULL, (XACapsType)(XACAP_DECODER|XACAP_IMAGE), |
|
148 &(self->numCodecs) ) == XA_RESULT_SUCCESS ); |
|
149 |
|
150 self->self = self; |
|
151 } |
|
152 DEBUG_API("<-XAImageDecoderCapabilitiesItfImpl_Create"); |
|
153 return self; |
|
154 } |
|
155 |
|
156 /* void XAImageDecoderCapabilitiesItfImpl_Free |
|
157 * Description: Free all resources reserved at XAImageDecoderCapabilitiesItfImpl |
|
158 */ |
|
159 void XAImageDecoderCapabilitiesItfImpl_Free(XAImageDecoderCapabilitiesItfImpl* self) |
|
160 { |
|
161 DEBUG_API("->XAImageDecoderCapabilitiesItfImpl_Free"); |
|
162 assert(self==self->self); |
|
163 free(self); |
|
164 DEBUG_API("<-XAImageDecoderCapabilitiesItfImpl_Free"); |
|
165 } |
|