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: MediaRecorder MMF Adaptation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include <string.h> |
18 #include <string.h> |
19 #include <assert.h> |
19 #include <assert.h> |
20 #include "xamediarecorderadaptctxmmf.h" |
20 #include "xamediarecorderadaptctxmmf.h" |
21 #include "xaadaptationmmf.h" |
21 #include "xaadaptationmmf.h" |
22 #include "cmmfbackendengine.h" |
22 #include "cmmfbackendengine.h" |
23 #include "xaadptbasectx.h" |
23 #include "xaadptbasectx.h" |
24 //#include "XAMetadataAdaptation.h" |
|
25 //#include "XAStaticCapsAdaptation.h" |
|
26 |
|
27 |
24 |
28 extern XAboolean cameraRealized; |
25 extern XAboolean cameraRealized; |
29 |
|
30 //extern XACameraAdaptationCtx_* cameraCtx; |
|
31 |
|
32 |
|
33 |
26 |
34 /* |
27 /* |
35 * XAAdaptationBaseCtx* XAMediaRecorderAdaptMMF_Create() |
28 * XAAdaptationBaseCtx* XAMediaRecorderAdaptMMF_Create() |
36 * Allocates memory for Media Recorder Adaptation Context and makes 1st phase initialization |
29 * Allocates memory for Media Recorder Adaptation Context and makes 1st phase initialization |
37 * @param XADataSource *pAudioSrc - pointer to OMX-AL audio source |
30 * @param XADataSource *pAudioSrc - pointer to OMX-AL audio source |
46 XAuint32 locType = 0; |
39 XAuint32 locType = 0; |
47 XAresult res; |
40 XAresult res; |
48 XADataLocator_IODevice *ioDevice; |
41 XADataLocator_IODevice *ioDevice; |
49 DEBUG_API("->XAMediaRecorderAdaptMMF_Create"); |
42 DEBUG_API("->XAMediaRecorderAdaptMMF_Create"); |
50 |
43 |
51 pSelf = (XAMediaRecorderAdaptationMMFCtx*)calloc(1, sizeof(XAMediaRecorderAdaptationMMFCtx)); |
44 pSelf = (XAMediaRecorderAdaptationMMFCtx*) calloc(1, |
|
45 sizeof(XAMediaRecorderAdaptationMMFCtx)); |
52 if (pSelf) |
46 if (pSelf) |
53 { |
47 { |
54 if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj), |
48 if (XAAdaptationBaseMMF_Init(&(pSelf->baseObj), |
55 XAMediaRecorderAdaptation) != XA_RESULT_SUCCESS) |
49 XAMediaRecorderAdaptation) != XA_RESULT_SUCCESS) |
56 { |
50 { |
57 DEBUG_ERR("Failed to init base context!!!"); |
51 DEBUG_ERR("Failed to init base context!!!"); |
58 free(pSelf); |
52 free(pSelf); |
59 pSelf = NULL; |
53 pSelf = NULL; |
60 } |
54 } |
61 else |
55 else |
62 { |
56 { |
63 pSelf->xaAudioSource = pAudioSrc; |
57 pSelf->xaAudioSource = pAudioSrc; |
64 pSelf->xaVideoSource = pImageVideoSrc; |
58 pSelf->xaVideoSource = pImageVideoSrc; |
65 pSelf->xaSink = pDataSnk; |
59 pSelf->xaSink = pDataSnk; |
66 pSelf->xaRecordState = XA_RECORDSTATE_STOPPED; |
60 pSelf->xaRecordState = XA_RECORDSTATE_STOPPED; |
94 if (locType == XA_DATALOCATOR_IODEVICE) |
88 if (locType == XA_DATALOCATOR_IODEVICE) |
95 { |
89 { |
96 ioDevice |
90 ioDevice |
97 = (XADataLocator_IODevice*) (pImageVideoSrc->pLocator); |
91 = (XADataLocator_IODevice*) (pImageVideoSrc->pLocator); |
98 if (ioDevice->deviceType == XA_IODEVICE_CAMERA |
92 if (ioDevice->deviceType == XA_IODEVICE_CAMERA |
99 |
93 |
100 && !cameraRealized |
94 && !cameraRealized |
101 |
95 |
102 ) |
96 ) |
103 { |
97 { |
104 DEBUG_ERR("Preconditions violated - Camera object not realized"); |
98 DEBUG_ERR("Preconditions violated - Camera object not realized"); |
105 XAAdaptationBaseMMF_Free(&pSelf->baseObj); |
99 XAAdaptationBaseMMF_Free(&pSelf->baseObj); |
106 free(pSelf); |
100 free(pSelf); |
107 pSelf = NULL; |
101 pSelf = NULL; |
108 } |
102 } |
109 } |
103 } |
110 } |
104 } |
111 } |
105 } |
112 |
106 else |
113 if(pSelf) |
|
114 { |
107 { |
115 res = mmf_backend_engine_init(&(pSelf->mmfContext) ); |
108 DEBUG_ERR("Failed to create XAMediaRecorderAdaptationMMFCtx !!!"); |
116 if(!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
109 return NULL; |
|
110 } |
|
111 |
|
112 if (pSelf) |
|
113 { |
|
114 res = mmf_backend_engine_init(&(pSelf->mmfContext)); |
|
115 if (!(pSelf->mmfContext) || (res != XA_RESULT_SUCCESS)) |
117 { |
116 { |
118 DEBUG_ERR("Failed to init mmf context!!!"); |
117 DEBUG_ERR("Failed to init mmf context!!!"); |
119 free(pSelf); |
118 free(pSelf); |
120 pSelf = NULL; |
119 pSelf = NULL; |
121 } |
120 } |
122 } |
121 } |
123 |
122 |
124 DEBUG_API("<-XAMediaRecorderAdaptMMF_Create"); |
123 DEBUG_API("<-XAMediaRecorderAdaptMMF_Create"); |
125 return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj); |
124 return (XAAdaptationBaseCtx*) (&pSelf->baseObj.baseObj); |
126 } |
125 } |
127 |
126 |
128 /* |
127 /* |
133 */ |
132 */ |
134 XAresult XAMediaRecorderAdaptMMF_PostInit(XAAdaptationMMFCtx* bCtx) |
133 XAresult XAMediaRecorderAdaptMMF_PostInit(XAAdaptationMMFCtx* bCtx) |
135 { |
134 { |
136 |
135 |
137 XAresult ret = XA_RESULT_SUCCESS; |
136 XAresult ret = XA_RESULT_SUCCESS; |
138 XADataLocator_URI* tempUri; |
137 XADataLocator_URI* tempUri; |
139 XADataFormat_MIME* tempFormat; |
138 XADataFormat_MIME* tempFormat; |
140 XAMediaRecorderAdaptationMMFCtx *pSelf = (XAMediaRecorderAdaptationMMFCtx*)bCtx; |
139 XAMediaRecorderAdaptationMMFCtx *pSelf; |
141 DEBUG_API("->XAMediaRecorderAdapt_PostInit"); |
140 DEBUG_API("->XAMediaRecorderAdapt_PostInit"); |
142 if(pSelf->mmfContext) |
141 if(bCtx) |
143 { |
142 { |
144 tempUri = (XADataLocator_URI*)(pSelf->xaSink->pLocator); |
143 ret = XA_RESULT_PARAMETER_INVALID; |
145 tempFormat = (XADataFormat_MIME*)(pSelf->xaSink->pFormat); |
144 return ret; |
146 mmf_set_recorder_uri(pSelf->mmfContext, (char *)(tempUri->URI), tempFormat->containerType); |
145 } |
147 mmf_set_adapt_context(pSelf->mmfContext, &(pSelf->baseObj)); |
146 |
|
147 pSelf = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
|
148 if (pSelf->mmfContext) |
|
149 { |
|
150 tempUri = (XADataLocator_URI*) (pSelf->xaSink->pLocator); |
|
151 tempFormat = (XADataFormat_MIME*) (pSelf->xaSink->pFormat); |
|
152 ret = mmf_set_recorder_uri(pSelf->mmfContext, (char *) (tempUri->URI), |
|
153 tempFormat->containerType); |
|
154 if(ret == XA_RESULT_SUCCESS) |
|
155 { |
|
156 ret = mmf_set_adapt_context(pSelf->mmfContext, &(pSelf->baseObj)); |
|
157 } |
148 } |
158 } |
149 |
159 |
150 DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); |
160 DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); |
151 return ret; |
161 return ret; |
152 } |
162 } |
157 * @param ctx - Media Recorder Adaptation context to be destroyed |
167 * @param ctx - Media Recorder Adaptation context to be destroyed |
158 */ |
168 */ |
159 void XAMediaRecorderAdaptMMF_Destroy(XAAdaptationMMFCtx* bCtx) |
169 void XAMediaRecorderAdaptMMF_Destroy(XAAdaptationMMFCtx* bCtx) |
160 { |
170 { |
161 XAMediaRecorderAdaptationMMFCtx* ctx = NULL; |
171 XAMediaRecorderAdaptationMMFCtx* ctx = NULL; |
162 |
172 |
163 DEBUG_API("->XAMediaRecorderAdaptMMF_Destroy"); |
173 DEBUG_API("->XAMediaRecorderAdaptMMF_Destroy"); |
164 |
174 |
165 if (bCtx == NULL) |
175 if (bCtx == NULL) |
166 { |
176 { |
167 DEBUG_ERR("Invalid parameter!!");DEBUG_API("<-XAMediaRecorderAdaptMMF_Destroy"); |
177 DEBUG_ERR("Invalid parameter!!"); |
|
178 DEBUG_API("<-XAMediaRecorderAdaptMMF_Destroy"); |
168 return; |
179 return; |
169 } |
180 } |
170 ctx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
181 ctx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
171 |
182 |
172 if(ctx->mmfContext) |
183 if (ctx->mmfContext) |
173 { |
184 { |
174 mmf_backend_engine_deinit(ctx->mmfContext); |
185 mmf_backend_engine_deinit(ctx->mmfContext); |
175 } |
186 } |
176 XAAdaptationBaseMMF_Free(bCtx); |
187 XAAdaptationBaseMMF_Free(bCtx); |
177 |
188 |