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