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 |
24 |
|
25 #include "cmetadatautilityitf.h" |
|
26 |
|
27 |
25 |
28 |
26 /* |
29 /* |
27 * XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_Create() |
30 * XAMediaPlayerAdaptationMMFCtx* XAMediaPlayerAdapt_Create() |
28 * Allocates memory for Media Player Adaptation Context and makes 1st phase initialization |
31 * Allocates memory for Media Player Adaptation Context and makes 1st phase initialization |
29 * @param XADataSource *pDataSrc - pointer to OMX-AL data source |
32 * @param XADataSource *pDataSrc - pointer to OMX-AL data source |
30 * @param XADataSource *pBankSrc - pointer to instrument bank structure in Mobile DLS, if NULL default will be used. |
33 * @param XADataSource *pBankSrc - pointer to instrument bank structure in Mobile DLS, if NULL default will be used. |
31 * @param XADataSink *pAudioSnk - pointer to OMX-AL audio sink definition |
34 * @param XADataSink *pAudioSnk - pointer to OMX-AL audio sink definition |
32 * @param XADataSink *pImageVideoSnk - pointer to OMX-AL image and video sink definition |
35 * @param XADataSink *pImageVideoSnk - pointer to OMX-AL image and video sink definition |
33 * @returns XAMediaPlayerAdaptationMMFCtx* - Pointer to created context, NULL if error occurs. |
36 * @returns XAMediaPlayerAdaptationMMFCtx* - Pointer to created context, NULL if error occurs. |
34 */ |
37 */ |
35 XAAdaptationBaseMMFCtx* XAMediaPlayerAdaptMMF_Create(XADataSource *pDataSrc, XADataSource *pBankSrc, |
38 XAAdaptationBaseCtx* XAMediaPlayerAdaptMMF_Create(XADataSource *pDataSrc, XADataSource *pBankSrc, |
36 XADataSink *pAudioSnk, XADataSink *pImageVideoSnk, |
39 XADataSink *pAudioSnk, XADataSink *pImageVideoSnk, |
37 XADataSink *pVibra, XADataSink *pLEDArray) |
40 XADataSink *pVibra, XADataSink *pLEDArray) |
38 { |
41 { |
39 XAMediaPlayerAdaptationMMFCtx *pSelf = NULL; |
42 XAMediaPlayerAdaptationMMFCtx *pSelf = NULL; |
40 XAuint32 locType = 0; |
43 XAuint32 locType = 0; |
42 DEBUG_API("->XAMediaPlayerAdaptMMF_Create"); |
45 DEBUG_API("->XAMediaPlayerAdaptMMF_Create"); |
43 |
46 |
44 pSelf = calloc(1, sizeof(XAMediaPlayerAdaptationMMFCtx)); |
47 pSelf = calloc(1, sizeof(XAMediaPlayerAdaptationMMFCtx)); |
45 if ( pSelf) |
48 if ( pSelf) |
46 { |
49 { |
47 #ifdef _GSTREAMER_BACKEND_ |
50 |
48 if( XAAdaptationBaseMMF_Init(&(pSelf->baseObj),0) |
51 if( XAAdaptationBaseMMF_Init(&(pSelf->baseObj),XAMediaPlayerAdaptation) |
49 != XA_RESULT_SUCCESS ) |
52 != XA_RESULT_SUCCESS ) |
50 { |
53 { |
51 DEBUG_ERR("Failed to init base context!!!"); |
54 DEBUG_ERR("Failed to init base context!!!"); |
52 free(pSelf); |
55 free(pSelf); |
53 pSelf = NULL; |
56 pSelf = NULL; |
54 } |
57 } |
55 else |
58 else |
56 #endif |
59 |
57 { |
60 { |
|
61 pSelf->baseObj.baseObj.fwtype = FWMgrFWMMF; |
58 pSelf->xaSource = pDataSrc; |
62 pSelf->xaSource = pDataSrc; |
59 pSelf->xaBankSrc = pBankSrc; |
63 pSelf->xaBankSrc = pBankSrc; |
60 pSelf->xaAudioSink = pAudioSnk; |
64 pSelf->xaAudioSink = pAudioSnk; |
61 pSelf->xaVideoSink = pImageVideoSnk; |
65 pSelf->xaVideoSink = pImageVideoSnk; |
62 pSelf->xaLEDArray = pLEDArray; |
66 pSelf->xaLEDArray = pLEDArray; |
77 //XADataLocator_IODevice *ioDevice = (XADataLocator_IODevice*)(pDataSrc->pLocator); |
81 //XADataLocator_IODevice *ioDevice = (XADataLocator_IODevice*)(pDataSrc->pLocator); |
78 } |
82 } |
79 } |
83 } |
80 } |
84 } |
81 |
85 |
|
86 else |
|
87 { |
|
88 DEBUG_ERR("Failed to create XAMediaPlayerAdaptationMMFCtx !!!"); |
|
89 return NULL; |
|
90 } |
82 if(pSelf) |
91 if(pSelf) |
|
92 { |
|
93 res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
|
94 if(!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
83 { |
95 { |
84 res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
96 /* TODO Check to make sure there is no undeleted MMF objects here*/ |
85 if(pSelf->mmfContext && res == XA_RESULT_SUCCESS) |
97 DEBUG_ERR("Failed to init mmf context!!!"); |
86 { |
98 free(pSelf); |
87 XADataLocator_URI* tempUri; |
99 pSelf = NULL; |
88 XADataFormat_MIME* tempFormat; |
100 return NULL; |
89 tempUri = (XADataLocator_URI*)(pSelf->xaSource->pLocator); |
|
90 tempFormat = (XADataFormat_MIME*)(pSelf->xaSource->pFormat); |
|
91 mmf_set_player_uri(pSelf->mmfContext, (char *)(tempUri->URI), tempFormat->containerType); |
|
92 if(pImageVideoSnk) |
|
93 { |
|
94 mmf_setup_native_display(pSelf->mmfContext, pImageVideoSnk); |
|
95 } |
|
96 } |
|
97 else |
|
98 { |
|
99 DEBUG_ERR("Failed to init mmf context!!!"); |
|
100 free(pSelf); |
|
101 pSelf = NULL; |
|
102 } |
|
103 } |
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 } |
104 |
118 |
105 DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
119 DEBUG_API("<-XAMediaPlayerAdaptMMF_Create"); |
106 return (XAAdaptationBaseMMFCtx*)pSelf; |
120 return (XAAdaptationBaseCtx*)(&pSelf->baseObj.baseObj); |
107 } |
121 } |
108 |
122 |
109 |
123 |
110 |
124 |
111 /* |
125 /* |
112 * XAresult XAMediaPlayerAdaptMMF_PostInit() |
126 * XAresult XAMediaPlayerAdaptMMF_PostInit() |
113 * 2nd phase initialization of Media Player Adaptation Context |
127 * 2nd phase initialization of Media Player Adaptation Context |
114 * @param XAMediaPlayerAdaptationMMFCtx* ctx - pointer to Media Player adaptation context |
128 * @param XAMediaPlayerAdaptationMMFCtx* ctx - pointer to Media Player adaptation context |
115 * @return XAresult - Success value |
129 * @return XAresult - Success value |
116 */ |
130 */ |
117 XAresult XAMediaPlayerAdaptMMF_PostInit( XAAdaptationBaseMMFCtx* bCtx ) |
131 XAresult XAMediaPlayerAdaptMMF_PostInit( XAAdaptationMMFCtx* bCtx ) |
118 { |
132 { |
119 XAresult ret = XA_RESULT_SUCCESS; |
133 XAresult ret = XA_RESULT_PRECONDITIONS_VIOLATED; |
|
134 XAMediaPlayerAdaptationMMFCtx *pSelf = (XAMediaPlayerAdaptationMMFCtx*)bCtx; |
|
135 |
|
136 DEBUG_API("->XAMediaPlayerAdaptMMF_PostInit"); |
|
137 |
|
138 XAAdaptationBaseMMF_PostInit(bCtx); |
|
139 |
|
140 if(pSelf->mmfContext) |
|
141 { |
|
142 XADataLocator_URI* tempUri = (XADataLocator_URI*)(pSelf->xaSource->pLocator); |
|
143 XADataFormat_MIME* tempFormat = (XADataFormat_MIME*)(pSelf->xaSource->pFormat); |
|
144 ret = XA_RESULT_SUCCESS; |
|
145 if(pSelf->xaVideoSink) |
|
146 { |
|
147 ret = mmf_setup_native_display(pSelf->mmfContext, pSelf->xaVideoSink); |
|
148 } |
|
149 if (ret == XA_RESULT_SUCCESS) |
|
150 { |
|
151 ret = mmf_set_player_uri(pSelf->mmfContext, (char *)(tempUri->URI), tempFormat->containerType); |
|
152 } |
|
153 } |
120 DEBUG_API("<-XAMediaPlayerAdaptMMF_PostInit"); |
154 DEBUG_API("<-XAMediaPlayerAdaptMMF_PostInit"); |
121 return ret; |
155 return ret; |
122 } |
156 } |
123 |
157 |
124 /* |
158 /* |
125 * void XAMediaPlayerAdaptMMF_Destroy( XAMediaPlayerAdaptationMMFCtx* ctx ) |
159 * void XAMediaPlayerAdaptMMF_Destroy( XAMediaPlayerAdaptationMMFCtx* ctx ) |
126 * Destroys Media Player Adaptation Context |
160 * Destroys Media Player Adaptation Context |
127 * @param ctx - Media Player Adaptation context to be destroyed |
161 * @param ctx - Media Player Adaptation context to be destroyed |
128 */ |
162 */ |
129 void XAMediaPlayerAdaptMMF_Destroy( XAAdaptationBaseMMFCtx* bCtx ) |
163 void XAMediaPlayerAdaptMMF_Destroy( XAAdaptationMMFCtx* bCtx ) |
130 { |
164 { |
131 XAMediaPlayerAdaptationMMFCtx* ctx = NULL; |
165 XAMediaPlayerAdaptationMMFCtx* ctx = NULL; |
132 |
166 |
133 |
167 |
134 DEBUG_API("->XAMediaPlayerAdaptMMF_Destroy"); |
168 DEBUG_API("->XAMediaPlayerAdaptMMF_Destroy"); |