1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: Media Player Adapt Code MMF |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <assert.h> |
18 #include <assert.h> |
19 #include <stdlib.h> |
19 #include <stdlib.h> |
20 #include "xamediaplayeradaptctxmmf.h" |
20 #include "xamediaplayeradaptctxmmf.h" |
21 #include "xaadaptationmmf.h" |
21 #include "xaadaptationmmf.h" |
22 #include "xaobjectitf.h" |
22 #include "xaobjectitf.h" |
23 #include "cmmfbackendengine.h" |
23 #include "cmmfbackendengine.h" |
24 |
|
25 #include "cmetadatautilityitf.h" |
24 #include "cmetadatautilityitf.h" |
26 |
|
27 |
|
28 |
25 |
29 /* |
26 /* |
30 * XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_Create() |
27 * XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_Create() |
31 * Allocates memory for Media Player Adaptation Context and makes 1st phase initialization |
28 * Allocates memory for Media Player Adaptation Context and makes 1st phase initialization |
32 * @param XADataSource *pDataSrc - pointer to OMX-AL data source |
29 * @param XADataSource *pDataSrc - pointer to OMX-AL data source |
33 * @param XADataSource *pBankSrc - pointer to instrument bank structure in Mobile DLS, if NULL default will be used. |
30 * @param XADataSource *pBankSrc - pointer to instrument bank structure in Mobile DLS, if NULL default will be used. |
34 * @param XADataSink *pAudioSnk - pointer to OMX-AL audio sink definition |
31 * @param XADataSink *pAudioSnk - pointer to OMX-AL audio sink definition |
35 * @param XADataSink *pImageVideoSnk - pointer to OMX-AL image and video sink definition |
32 * @param XADataSink *pImageVideoSnk - pointer to OMX-AL image and video sink definition |
36 * @returns XAMediaPlayerAdaptationMMFCtx* - Pointer to created context, NULL if error occurs. |
33 * @returns XAMediaPlayerAdaptationMMFCtx* - Pointer to created context, NULL if error occurs. |
37 */ |
34 */ |
38 XAAdaptationBaseCtx* XAMediaPlayerAdaptMMF_Create(XADataSource *pDataSrc, XADataSource *pBankSrc, |
35 XAAdaptationBaseCtx* XAMediaPlayerAdaptMMF_Create(XADataSource *pDataSrc, |
39 XADataSink *pAudioSnk, XADataSink *pImageVideoSnk, |
36 XADataSource *pBankSrc, XADataSink *pAudioSnk, |
40 XADataSink *pVibra, XADataSink *pLEDArray) |
37 XADataSink *pImageVideoSnk, XADataSink *pVibra, XADataSink *pLEDArray) |
41 { |
38 { |
42 XAMediaPlayerAdaptationMMFCtx *pSelf = NULL; |
39 XAMediaPlayerAdaptationMMFCtx *pSelf = NULL; |
43 XAuint32 locType = 0; |
40 XAuint32 locType = 0; |
44 XADataLocator_IODevice *ioDevice; |
41 XADataLocator_IODevice *ioDevice; |
45 XAresult res; |
42 XAresult res; |
46 DEBUG_API("->XAMediaPlayerAdaptMMF_Create"); |
43 DEBUG_API("->XAMediaPlayerAdaptMMF_Create"); |
|
44 |
|
45 pSelf = calloc(1, sizeof(XAMediaPlayerAdaptationMMFCtx)); |
|
46 if (pSelf) |
|
47 { |
|
48 if (pDataSrc) |
|
49 { |
|
50 locType = *((XAuint32*) (pDataSrc->pLocator)); |
|
51 if (locType == XA_DATALOCATOR_IODEVICE) |
|
52 { |
|
53 ioDevice = (XADataLocator_IODevice*) (pDataSrc->pLocator); |
|
54 if (ioDevice->deviceType == XA_IODEVICE_RADIO) |
|
55 { |
|
56 return XAMediaPlayerAdaptMMF_CreateRadio(pSelf, pDataSrc, |
|
57 pBankSrc, pAudioSnk, pImageVideoSnk, pVibra, |
|
58 pLEDArray); |
|
59 } |
|
60 } |
|
61 } |
|
62 if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj), |
|
63 XAMediaPlayerAdaptation) != XA_RESULT_SUCCESS) |
|
64 { |
|
65 DEBUG_ERR("Failed to init base context!!!"); |
|
66 free(pSelf); |
|
67 pSelf = NULL; |
|
68 } |
|
69 else |
|
70 { |
|
71 pSelf->isForRadio = XA_BOOLEAN_FALSE; |
|
72 pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF; |
|
73 pSelf->xaSource = pDataSrc; |
|
74 pSelf->xaBankSrc = pBankSrc; |
|
75 pSelf->xaAudioSink = pAudioSnk; |
|
76 pSelf->xaVideoSink = pImageVideoSnk; |
|
77 pSelf->xaLEDArray = pLEDArray; |
|
78 pSelf->xaVibra = pVibra; |
|
79 pSelf->curMirror = XA_VIDEOMIRROR_NONE; |
|
80 pSelf->curRotation = 0; |
|
81 pSelf->isobjsrc = XA_BOOLEAN_FALSE; |
|
82 pSelf->cameraSinkSynced = XA_BOOLEAN_FALSE; |
|
83 } |
|
84 } |
|
85 else |
|
86 { |
|
87 DEBUG_ERR("Failed to create XAMediaPlayerAdaptationMMFCtx !!!"); |
|
88 return NULL; |
|
89 } |
47 |
90 |
48 pSelf = calloc(1, sizeof(XAMediaPlayerAdaptationMMFCtx)); |
91 if (pSelf) |
49 if ( pSelf) |
92 { |
50 { |
93 res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
51 if ( pDataSrc ) |
94 if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
52 { |
95 { |
53 locType = *((XAuint32*)(pDataSrc->pLocator)); |
96 /* TODO Check to make sure there is no undeleted MMF objects here*/ |
54 if ( locType == XA_DATALOCATOR_IODEVICE ) |
97 DEBUG_ERR("Failed to init mmf context!!!"); |
55 { |
98 free(pSelf); |
56 ioDevice = (XADataLocator_IODevice*)(pDataSrc->pLocator); |
99 pSelf = NULL; |
57 if ( ioDevice->deviceType == XA_IODEVICE_RADIO ) |
100 return NULL; |
58 { |
101 } |
59 return XAMediaPlayerAdaptMMF_CreateRadio(pSelf, pDataSrc, pBankSrc, pAudioSnk, pImageVideoSnk, pVibra, pLEDArray); |
102 res = mmf_set_play_adapt_context(pSelf->mmfContext, |
60 } |
103 &(pSelf->baseObj)); |
61 } |
104 if (pDataSrc) |
62 } |
105 { |
63 if( XAAdaptationBaseMMF_Init(&(pSelf->baseObj),XAMediaPlayerAdaptation) != XA_RESULT_SUCCESS ) |
106 pSelf->mmfMetadataContext |
64 { |
107 = mmf_metadata_utility_init( |
65 DEBUG_ERR("Failed to init base context!!!"); |
108 (char *) (((XADataLocator_URI*) (pDataSrc->pLocator))->URI)); |
66 free(pSelf); |
109 if (!pSelf->mmfMetadataContext) |
67 pSelf = NULL; |
110 { |
68 } |
111 DEBUG_ERR("Failed to init mmf metadata context!!!"); |
69 else |
112 pSelf->mmfMetadataContext = NULL; |
70 { |
113 } |
71 pSelf->isForRadio = XA_BOOLEAN_FALSE; |
114 } |
72 pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF; |
115 else |
73 pSelf->xaSource = pDataSrc; |
116 { |
74 pSelf->xaBankSrc = pBankSrc; |
117 DEBUG_ERR("Failed to create XAMediaPlayerAdaptationMMFCtx !!!"); |
75 pSelf->xaAudioSink = pAudioSnk; |
118 return NULL; |
76 pSelf->xaVideoSink = pImageVideoSnk; |
119 } |
77 pSelf->xaLEDArray = pLEDArray; |
120 } |
78 pSelf->xaVibra = pVibra; |
|
79 pSelf->curMirror = XA_VIDEOMIRROR_NONE; |
|
80 pSelf->curRotation = 0; |
|
81 pSelf->isobjsrc = XA_BOOLEAN_FALSE; |
|
82 pSelf->cameraSinkSynced = XA_BOOLEAN_FALSE; |
|
83 /*pSelf->waitData = XA_BOOLEAN_FALSE;*/ |
|
84 } |
|
85 } |
|
86 else |
|
87 { |
|
88 DEBUG_ERR("Failed to create XAMediaPlayerAdaptationMMFCtx !!!"); |
|
89 return NULL; |
|
90 } |
|
91 if(pSelf) |
|
92 { |
|
93 res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
|
94 if(!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
|
95 { |
|
96 /* TODO Check to make sure there is no undeleted MMF objects here*/ |
|
97 DEBUG_ERR("Failed to init mmf context!!!"); |
|
98 free(pSelf); |
|
99 pSelf = NULL; |
|
100 return NULL; |
|
101 } |
|
102 res = mmf_set_play_adapt_context(pSelf->mmfContext, &(pSelf->baseObj)); |
|
103 if(pDataSrc) |
|
104 { |
|
105 pSelf->mmfMetadataContext = mmf_metadata_utility_init((char *)(( (XADataLocator_URI*)(pDataSrc->pLocator))->URI)); |
|
106 if(!pSelf->mmfMetadataContext) |
|
107 { |
|
108 DEBUG_ERR("Failed to init mmf metadata context!!!"); |
|
109 pSelf->mmfMetadataContext = NULL; |
|
110 } |
|
111 } |
|
112 else |
|
113 { |
|
114 DEBUG_ERR("Failed to create XAMediaPlayerAdaptationMMFCtx !!!"); |
|
115 return NULL; |
|
116 } |
|
117 } |
|
118 |
121 |
119 DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
122 DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
120 return (XAAdaptationBaseCtx*)(&pSelf->baseObj.baseObj); |
123 return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj); |
121 } |
124 } |
122 |
125 |
123 /* |
126 /* |
124 * XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_CreateRadio() |
127 * XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_CreateRadio() |
125 |
128 |
126 * @returns XAMediaPlayerAdaptationMMFCtx* - Pointer to created context, NULL if error occurs. |
129 * @returns XAMediaPlayerAdaptationMMFCtx* - Pointer to created context, NULL if error occurs. |
127 */ |
130 */ |
128 XAAdaptationBaseCtx* XAMediaPlayerAdaptMMF_CreateRadio(XAMediaPlayerAdaptationMMFCtx *pSelf, XADataSource *pDataSrc, XADataSource *pBankSrc, |
131 XAAdaptationBaseCtx* XAMediaPlayerAdaptMMF_CreateRadio( |
129 XADataSink *pAudioSnk, XADataSink *pImageVideoSnk, |
132 XAMediaPlayerAdaptationMMFCtx *pSelf, XADataSource *pDataSrc, |
130 XADataSink *pVibra, XADataSink *pLEDArray) |
133 XADataSource *pBankSrc, XADataSink *pAudioSnk, |
131 { |
134 XADataSink *pImageVideoSnk, XADataSink *pVibra, XADataSink *pLEDArray) |
|
135 { |
132 XAresult res; |
136 XAresult res; |
133 DEBUG_API("->XAMediaPlayerAdaptMMF_CreateRadio"); |
137 DEBUG_API("->XAMediaPlayerAdaptMMF_CreateRadio"); |
134 |
138 |
135 res = XAAdaptationBaseMMF_Init(&(pSelf->baseObj), XARadioAdaptation); |
139 res = XAAdaptationBaseMMF_Init(&(pSelf->baseObj), XARadioAdaptation); |
136 if (res != XA_RESULT_SUCCESS) |
140 if (res != XA_RESULT_SUCCESS) |
137 { |
141 { |
138 DEBUG_ERR("Failed to init base context!!!"); |
142 DEBUG_ERR("Failed to init base context!!!"); |
139 free(pSelf); |
143 free(pSelf); |
140 pSelf = NULL; |
144 pSelf = NULL; |
141 return NULL; |
145 return NULL; |
142 } |
146 } |
143 |
147 |
144 pSelf->isForRadio = XA_BOOLEAN_TRUE; |
148 pSelf->isForRadio = XA_BOOLEAN_TRUE; |
145 pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF; |
149 pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF; |
146 pSelf->xaSource = pDataSrc; |
150 pSelf->xaSource = pDataSrc; |
147 pSelf->xaBankSrc = pBankSrc; |
151 pSelf->xaBankSrc = pBankSrc; |
148 pSelf->xaAudioSink = pAudioSnk; |
152 pSelf->xaAudioSink = pAudioSnk; |
149 pSelf->xaVideoSink = pImageVideoSnk; |
153 pSelf->xaVideoSink = pImageVideoSnk; |
150 pSelf->xaLEDArray = pLEDArray; |
154 pSelf->xaLEDArray = pLEDArray; |
153 pSelf->curRotation = 0; |
157 pSelf->curRotation = 0; |
154 pSelf->isobjsrc = XA_BOOLEAN_FALSE; |
158 pSelf->isobjsrc = XA_BOOLEAN_FALSE; |
155 pSelf->cameraSinkSynced = XA_BOOLEAN_FALSE; |
159 pSelf->cameraSinkSynced = XA_BOOLEAN_FALSE; |
156 /*pSelf->waitData = XA_BOOLEAN_FALSE;*/ |
160 /*pSelf->waitData = XA_BOOLEAN_FALSE;*/ |
157 |
161 |
158 res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
162 res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
159 if(!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
163 if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
160 { |
164 { |
161 /* TODO Check to make sure there is no undeleted MMF objects here*/ |
165 /* TODO Check to make sure there is no undeleted MMF objects here*/ |
162 DEBUG_ERR("Failed to init mmf context!!!"); |
166 DEBUG_ERR("Failed to init mmf context!!!"); |
163 free(pSelf); |
167 free(pSelf); |
164 pSelf = NULL; |
168 pSelf = NULL; |
165 return NULL; |
169 return NULL; |
166 } |
170 }DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
167 DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
171 return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj); |
168 return (XAAdaptationBaseCtx*)(&pSelf->baseObj.baseObj); |
172 } |
169 } |
|
170 |
173 |
171 /* |
174 /* |
172 * XAresult XAMediaPlayerAdaptMMF_PostInit() |
175 * XAresult XAMediaPlayerAdaptMMF_PostInit() |
173 * 2nd phase initialization of Media Player Adaptation Context |
176 * 2nd phase initialization of Media Player Adaptation Context |
174 * @param XAMediaPlayerAdaptationMMFCtx* ctx - pointer to Media Player adaptation context |
177 * @param XAMediaPlayerAdaptationMMFCtx* ctx - pointer to Media Player adaptation context |
175 * @return XAresult - Success value |
178 * @return XAresult - Success value |
176 */ |
179 */ |
177 XAresult XAMediaPlayerAdaptMMF_PostInit( XAAdaptationMMFCtx* bCtx ) |
180 XAresult XAMediaPlayerAdaptMMF_PostInit(XAAdaptationMMFCtx* bCtx) |
178 { |
181 { |
179 XAresult ret = XA_RESULT_PRECONDITIONS_VIOLATED; |
182 XAresult ret = XA_RESULT_PRECONDITIONS_VIOLATED; |
180 XAMediaPlayerAdaptationMMFCtx *pSelf = (XAMediaPlayerAdaptationMMFCtx*)bCtx; |
183 XAMediaPlayerAdaptationMMFCtx *pSelf = NULL; |
|
184 if(!bCtx) |
|
185 { |
|
186 ret = XA_RESULT_PARAMETER_INVALID; |
|
187 return ret; |
|
188 } |
|
189 |
|
190 pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
181 |
191 |
182 DEBUG_API("->XAMediaPlayerAdaptMMF_PostInit"); |
192 DEBUG_API("->XAMediaPlayerAdaptMMF_PostInit"); |
|
193 |
|
194 ret = XAAdaptationBaseMMF_PostInit(bCtx); |
|
195 if(ret == XA_RESULT_SUCCESS) |
|
196 { |
|
197 if (pSelf->isForRadio) |
|
198 { |
|
199 DEBUG_API("<-XAMediaPlayerAdaptMMF_PostInit"); |
|
200 return XA_RESULT_SUCCESS; |
|
201 } |
183 |
202 |
184 XAAdaptationBaseMMF_PostInit(bCtx); |
203 if (pSelf->mmfContext) |
185 |
204 { |
186 if (pSelf->isForRadio) |
205 XADataLocator_URI* tempUri = |
187 { |
206 (XADataLocator_URI*) (pSelf->xaSource->pLocator); |
188 DEBUG_API("<-XAMediaPlayerAdaptMMF_PostInit"); |
207 XADataFormat_MIME* tempFormat = |
189 return XA_RESULT_SUCCESS; |
208 (XADataFormat_MIME*) (pSelf->xaSource->pFormat); |
190 } |
209 ret = XA_RESULT_SUCCESS; |
191 |
210 if (pSelf->xaVideoSink) |
192 if(pSelf->mmfContext) |
211 { |
193 { |
212 ret = mmf_setup_native_display(pSelf->mmfContext, |
194 XADataLocator_URI* tempUri = (XADataLocator_URI*)(pSelf->xaSource->pLocator); |
213 pSelf->xaVideoSink); |
195 XADataFormat_MIME* tempFormat = (XADataFormat_MIME*)(pSelf->xaSource->pFormat); |
214 } |
196 ret = XA_RESULT_SUCCESS; |
215 if (ret == XA_RESULT_SUCCESS) |
197 if(pSelf->xaVideoSink) |
216 { |
198 { |
217 ret = mmf_set_player_uri(pSelf->mmfContext, |
199 ret = mmf_setup_native_display(pSelf->mmfContext, pSelf->xaVideoSink); |
218 (char *) (tempUri->URI), tempFormat->containerType); |
200 } |
219 } |
201 if (ret == XA_RESULT_SUCCESS) |
220 } |
202 { |
221 } |
203 ret = mmf_set_player_uri(pSelf->mmfContext, (char *)(tempUri->URI), tempFormat->containerType); |
|
204 } |
|
205 } |
|
206 DEBUG_API("<-XAMediaPlayerAdaptMMF_PostInit"); |
222 DEBUG_API("<-XAMediaPlayerAdaptMMF_PostInit"); |
207 return ret; |
223 return ret; |
208 } |
224 } |
209 |
225 |
210 /* |
226 /* |
211 * void XAMediaPlayerAdaptMMF_Destroy( XAMediaPlayerAdaptationMMFCtx* ctx ) |
227 * void XAMediaPlayerAdaptMMF_Destroy( XAMediaPlayerAdaptationMMFCtx* ctx ) |
212 * Destroys Media Player Adaptation Context |
228 * Destroys Media Player Adaptation Context |
213 * @param ctx - Media Player Adaptation context to be destroyed |
229 * @param ctx - Media Player Adaptation context to be destroyed |
214 */ |
230 */ |
215 void XAMediaPlayerAdaptMMF_Destroy( XAAdaptationMMFCtx* bCtx ) |
231 void XAMediaPlayerAdaptMMF_Destroy(XAAdaptationMMFCtx* bCtx) |
216 { |
232 { |
217 XAMediaPlayerAdaptationMMFCtx* ctx = NULL; |
233 XAMediaPlayerAdaptationMMFCtx* ctx = NULL; |
218 |
234 |
219 |
|
220 DEBUG_API("->XAMediaPlayerAdaptMMF_Destroy"); |
235 DEBUG_API("->XAMediaPlayerAdaptMMF_Destroy"); |
221 if(bCtx == NULL) |
236 if (bCtx == NULL) |
222 { |
237 { |
223 DEBUG_ERR("Invalid parameter!!"); |
238 DEBUG_ERR("Invalid parameter!!"); |
224 DEBUG_API("<-XAMediaPlayerAdaptMMF_Destroy"); |
239 DEBUG_API("<-XAMediaPlayerAdaptMMF_Destroy"); |
225 return; |
240 return; |
226 } |
241 } |
227 ctx = (XAMediaPlayerAdaptationMMFCtx*)bCtx; |
242 ctx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
228 |
243 |
229 if(ctx->mmfContext) |
244 if (ctx->mmfContext) |
230 { |
245 { |
231 mmf_backend_engine_deinit(ctx->mmfContext); |
246 mmf_backend_engine_deinit(ctx->mmfContext); |
232 } |
247 } |
233 |
248 |
234 if(ctx->mmfMetadataContext) |
249 if (ctx->mmfMetadataContext) |
235 { |
250 { |
236 mmf_metadata_utility_destroy(ctx->mmfMetadataContext); |
251 mmf_metadata_utility_destroy(ctx->mmfMetadataContext); |
237 } |
252 } |
238 |
253 |
239 XAAdaptationBaseMMF_Free( bCtx ); |
254 XAAdaptationBaseMMF_Free(bCtx); |
240 |
255 |
241 free(ctx); |
256 free(ctx); |
242 ctx = NULL; |
257 ctx = NULL; |
243 |
258 |
244 DEBUG_API("<-XAMediaPlayerAdaptMMF_Destroy"); |
259 DEBUG_API("<-XAMediaPlayerAdaptMMF_Destroy"); |
245 } |
260 } |
246 |
261 |
247 |
|