author | hgs |
Fri, 11 Jun 2010 19:59:23 -0500 | |
changeset 25 | 6f7ceef7b1d1 |
parent 21 | 2ed61feeead6 |
child 28 | ebf79c79991a |
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 <assert.h> |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
#include <stdlib.h> |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
#include "xamediaplayeradaptctxmmf.h" |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include "xaadaptationmmf.h" |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include "xaobjectitf.h" |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include "cmmfbackendengine.h" |
19 | 24 |
#include "cmetadatautilityitf.h" |
25 |
||
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
/* |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
* XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_Create() |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
* 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
|
29 |
* @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
|
30 |
* @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
|
31 |
* @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
|
32 |
* @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
|
33 |
* @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
|
34 |
*/ |
25 | 35 |
XAAdaptationBaseCtx* XAMediaPlayerAdaptMMF_Create(XADataSource *pDataSrc, |
36 |
XADataSource *pBankSrc, XADataSink *pAudioSnk, |
|
37 |
XADataSink *pImageVideoSnk, XADataSink *pVibra, XADataSink *pLEDArray) |
|
38 |
{ |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
39 |
XAMediaPlayerAdaptationMMFCtx *pSelf = NULL; |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
40 |
XAuint32 locType = 0; |
25 | 41 |
XADataLocator_IODevice *ioDevice; |
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
XAresult res; |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
43 |
DEBUG_API("->XAMediaPlayerAdaptMMF_Create"); |
25 | 44 |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
pSelf = calloc(1, sizeof(XAMediaPlayerAdaptationMMFCtx)); |
25 | 46 |
if (pSelf) |
47 |
{ |
|
48 |
if (pDataSrc) |
|
49 |
{ |
|
50 |
locType = *((XAuint32*) (pDataSrc->pLocator)); |
|
51 |
if (locType == XA_DATALOCATOR_IODEVICE) |
|
19 | 52 |
{ |
25 | 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 |
} |
|
19 | 60 |
} |
25 | 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 |
} |
|
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, |
|
103 |
&(pSelf->baseObj)); |
|
104 |
if (pDataSrc) |
|
105 |
{ |
|
106 |
pSelf->mmfMetadataContext |
|
107 |
= mmf_metadata_utility_init( |
|
108 |
(char *) (((XADataLocator_URI*) (pDataSrc->pLocator))->URI)); |
|
109 |
if (!pSelf->mmfMetadataContext) |
|
110 |
{ |
|
111 |
DEBUG_ERR("Failed to init mmf metadata context!!!"); |
|
112 |
pSelf->mmfMetadataContext = NULL; |
|
113 |
} |
|
114 |
} |
|
115 |
else |
|
116 |
{ |
|
117 |
DEBUG_ERR("Failed to create XAMediaPlayerAdaptationMMFCtx !!!"); |
|
118 |
return NULL; |
|
119 |
} |
|
120 |
} |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
|
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
25 | 123 |
return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj); |
124 |
} |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
125 |
|
21 | 126 |
/* |
127 |
* XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_CreateRadio() |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
|
21 | 129 |
* @returns XAMediaPlayerAdaptationMMFCtx* - Pointer to created context, NULL if error occurs. |
130 |
*/ |
|
25 | 131 |
XAAdaptationBaseCtx* XAMediaPlayerAdaptMMF_CreateRadio( |
132 |
XAMediaPlayerAdaptationMMFCtx *pSelf, XADataSource *pDataSrc, |
|
133 |
XADataSource *pBankSrc, XADataSink *pAudioSnk, |
|
134 |
XADataSink *pImageVideoSnk, XADataSink *pVibra, XADataSink *pLEDArray) |
|
135 |
{ |
|
21 | 136 |
XAresult res; |
137 |
DEBUG_API("->XAMediaPlayerAdaptMMF_CreateRadio"); |
|
138 |
||
25 | 139 |
res = XAAdaptationBaseMMF_Init(&(pSelf->baseObj), XARadioAdaptation); |
140 |
if (res != XA_RESULT_SUCCESS) |
|
141 |
{ |
|
142 |
DEBUG_ERR("Failed to init base context!!!"); |
|
143 |
free(pSelf); |
|
144 |
pSelf = NULL; |
|
145 |
return NULL; |
|
146 |
} |
|
147 |
||
148 |
pSelf->isForRadio = XA_BOOLEAN_TRUE; |
|
149 |
pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF; |
|
21 | 150 |
pSelf->xaSource = pDataSrc; |
151 |
pSelf->xaBankSrc = pBankSrc; |
|
152 |
pSelf->xaAudioSink = pAudioSnk; |
|
153 |
pSelf->xaVideoSink = pImageVideoSnk; |
|
154 |
pSelf->xaLEDArray = pLEDArray; |
|
155 |
pSelf->xaVibra = pVibra; |
|
156 |
pSelf->curMirror = XA_VIDEOMIRROR_NONE; |
|
157 |
pSelf->curRotation = 0; |
|
158 |
pSelf->isobjsrc = XA_BOOLEAN_FALSE; |
|
159 |
pSelf->cameraSinkSynced = XA_BOOLEAN_FALSE; |
|
160 |
/*pSelf->waitData = XA_BOOLEAN_FALSE;*/ |
|
161 |
||
25 | 162 |
res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
163 |
if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
|
164 |
{ |
|
165 |
/* TODO Check to make sure there is no undeleted MMF objects here*/ |
|
166 |
DEBUG_ERR("Failed to init mmf context!!!"); |
|
167 |
free(pSelf); |
|
168 |
pSelf = NULL; |
|
169 |
return NULL; |
|
170 |
}DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
|
171 |
return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj); |
|
21 | 172 |
} |
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
173 |
|
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
174 |
/* |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
175 |
* XAresult XAMediaPlayerAdaptMMF_PostInit() |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
176 |
* 2nd phase initialization of Media Player Adaptation Context |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
177 |
* @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
|
178 |
* @return XAresult - Success value |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
179 |
*/ |
25 | 180 |
XAresult XAMediaPlayerAdaptMMF_PostInit(XAAdaptationMMFCtx* bCtx) |
181 |
{ |
|
19 | 182 |
XAresult ret = XA_RESULT_PRECONDITIONS_VIOLATED; |
25 | 183 |
XAMediaPlayerAdaptationMMFCtx *pSelf = NULL; |
184 |
if(!bCtx) |
|
185 |
{ |
|
186 |
ret = XA_RESULT_PARAMETER_INVALID; |
|
187 |
return ret; |
|
188 |
} |
|
189 |
||
190 |
pSelf = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
|
19 | 191 |
|
192 |
DEBUG_API("->XAMediaPlayerAdaptMMF_PostInit"); |
|
25 | 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 |
} |
|
21 | 202 |
|
25 | 203 |
if (pSelf->mmfContext) |
204 |
{ |
|
205 |
XADataLocator_URI* tempUri = |
|
206 |
(XADataLocator_URI*) (pSelf->xaSource->pLocator); |
|
207 |
XADataFormat_MIME* tempFormat = |
|
208 |
(XADataFormat_MIME*) (pSelf->xaSource->pFormat); |
|
209 |
ret = XA_RESULT_SUCCESS; |
|
210 |
if (pSelf->xaVideoSink) |
|
211 |
{ |
|
212 |
ret = mmf_setup_native_display(pSelf->mmfContext, |
|
213 |
pSelf->xaVideoSink); |
|
214 |
} |
|
215 |
if (ret == XA_RESULT_SUCCESS) |
|
216 |
{ |
|
217 |
ret = mmf_set_player_uri(pSelf->mmfContext, |
|
218 |
(char *) (tempUri->URI), tempFormat->containerType); |
|
219 |
} |
|
220 |
} |
|
19 | 221 |
} |
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
222 |
DEBUG_API("<-XAMediaPlayerAdaptMMF_PostInit"); |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
223 |
return ret; |
25 | 224 |
} |
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
225 |
|
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
226 |
/* |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
227 |
* void XAMediaPlayerAdaptMMF_Destroy( XAMediaPlayerAdaptationMMFCtx* ctx ) |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
228 |
* Destroys Media Player Adaptation Context |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
229 |
* @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
|
230 |
*/ |
25 | 231 |
void XAMediaPlayerAdaptMMF_Destroy(XAAdaptationMMFCtx* bCtx) |
232 |
{ |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
233 |
XAMediaPlayerAdaptationMMFCtx* ctx = NULL; |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
234 |
|
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
235 |
DEBUG_API("->XAMediaPlayerAdaptMMF_Destroy"); |
25 | 236 |
if (bCtx == NULL) |
237 |
{ |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
238 |
DEBUG_ERR("Invalid parameter!!"); |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
239 |
DEBUG_API("<-XAMediaPlayerAdaptMMF_Destroy"); |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
240 |
return; |
25 | 241 |
} |
242 |
ctx = (XAMediaPlayerAdaptationMMFCtx*) bCtx; |
|
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
243 |
|
25 | 244 |
if (ctx->mmfContext) |
19 | 245 |
{ |
246 |
mmf_backend_engine_deinit(ctx->mmfContext); |
|
247 |
} |
|
248 |
||
25 | 249 |
if (ctx->mmfMetadataContext) |
250 |
{ |
|
251 |
mmf_metadata_utility_destroy(ctx->mmfMetadataContext); |
|
252 |
} |
|
253 |
||
254 |
XAAdaptationBaseMMF_Free(bCtx); |
|
255 |
||
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
256 |
free(ctx); |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
257 |
ctx = NULL; |
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
258 |
|
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
259 |
DEBUG_API("<-XAMediaPlayerAdaptMMF_Destroy"); |
25 | 260 |
} |
12
5a06f39ad45b
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
261 |