26 * Sets record state to GStreamer. |
26 * Sets record state to GStreamer. |
27 * @param XAAdaptationBaseCtx *ctx - Adaptation context |
27 * @param XAAdaptationBaseCtx *ctx - Adaptation context |
28 * XAuint32 state - Record state to be set |
28 * XAuint32 state - Record state to be set |
29 * @return XAresult ret - Success value |
29 * @return XAresult ret - Success value |
30 */ |
30 */ |
31 XAresult XARecordItfAdaptMMF_SetRecordState(XAAdaptationMMFCtx *bCtx, XAuint32 state) |
31 XAresult XARecordItfAdaptMMF_SetRecordState(XAAdaptationMMFCtx *bCtx, |
32 { |
32 XAuint32 state) |
|
33 { |
33 XAresult ret = XA_RESULT_SUCCESS; |
34 XAresult ret = XA_RESULT_SUCCESS; |
34 int mmfretCode; |
35 int mmfretCode; |
35 XAAdaptEvent stalledevent = {XA_RECORDITFEVENTS, XA_RECORDEVENT_HEADSTALLED, 0, NULL}; |
36 XAAdaptEvent stalledevent = |
|
37 { |
|
38 XA_RECORDITFEVENTS, XA_RECORDEVENT_HEADSTALLED, 0, NULL |
|
39 }; |
36 XAMediaRecorderAdaptationMMFCtx* mCtx = NULL; |
40 XAMediaRecorderAdaptationMMFCtx* mCtx = NULL; |
37 DEBUG_API_A1("->XARecordItfAdaptMMF_SetRecordState %s",RECORDSTATENAME(state)); |
41 DEBUG_API_A1("->XARecordItfAdaptMMF_SetRecordState %s",RECORDSTATENAME(state)); |
38 if(!bCtx) |
42 if (!bCtx) |
39 { |
43 { |
40 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
44 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdaptMMF_SetRecordState"); |
41 DEBUG_API("<-XARecordItfAdaptMMF_SetRecordState"); |
45 return XA_RESULT_PARAMETER_INVALID; |
42 return XA_RESULT_PARAMETER_INVALID; |
46 } |
43 } |
|
44 |
47 |
45 mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
48 mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
46 |
49 |
47 mCtx->isRecord = XA_BOOLEAN_TRUE; |
50 mCtx->isRecord = XA_BOOLEAN_TRUE; |
48 |
51 |
49 switch ( state ) |
52 switch (state) |
50 { |
53 { |
51 case XA_RECORDSTATE_STOPPED: |
54 case XA_RECORDSTATE_STOPPED: |
52 { |
55 { |
53 mmfretCode= mmf_stop_recording(mCtx->mmfContext, TRUE); |
56 mmfretCode = mmf_stop_recording(mCtx->mmfContext, TRUE); |
54 if(mmfretCode != XA_RESULT_SUCCESS) |
57 if (mmfretCode != XA_RESULT_SUCCESS) |
55 { |
58 { |
56 ret = XA_RESULT_PARAMETER_INVALID; |
59 ret = XA_RESULT_PARAMETER_INVALID; |
57 } |
60 } |
58 break; |
61 break; |
59 } |
62 } |
60 case XA_RECORDSTATE_PAUSED: |
63 case XA_RECORDSTATE_PAUSED: |
61 { |
64 { |
62 mmfretCode = mmf_stop_recording(mCtx->mmfContext,FALSE); |
65 mmfretCode = mmf_stop_recording(mCtx->mmfContext, FALSE); |
63 if(mmfretCode != XA_RESULT_SUCCESS) |
66 if (mmfretCode != XA_RESULT_SUCCESS) |
64 { |
67 { |
65 ret = XA_RESULT_PARAMETER_INVALID; |
68 ret = XA_RESULT_PARAMETER_INVALID; |
66 } |
69 } |
67 else |
70 else |
68 { |
71 { |
69 XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj, &stalledevent ); |
72 XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj, |
70 } |
73 &stalledevent); |
71 break; |
74 } |
72 } |
75 break; |
|
76 } |
73 case XA_RECORDSTATE_RECORDING: |
77 case XA_RECORDSTATE_RECORDING: |
74 { |
78 { |
75 mmfretCode = mmf_start_recording(mCtx->mmfContext); |
79 mmfretCode = mmf_start_recording(mCtx->mmfContext); |
76 if(mmfretCode != XA_RESULT_SUCCESS) |
80 if (mmfretCode != XA_RESULT_SUCCESS) |
77 { |
81 { |
78 ret = XA_RESULT_PARAMETER_INVALID; |
82 ret = XA_RESULT_PARAMETER_INVALID; |
79 } |
83 } |
80 break; |
84 break; |
81 } |
85 } |
82 default: |
86 default: |
83 DEBUG_ERR("Unhandled state"); |
87 DEBUG_ERR("Unhandled state") |
|
88 ; |
84 ret = XA_RESULT_PARAMETER_INVALID; |
89 ret = XA_RESULT_PARAMETER_INVALID; |
85 break; |
90 break; |
86 } |
91 } |
87 |
92 |
88 if( ret == XA_RESULT_SUCCESS ) |
93 if (ret == XA_RESULT_SUCCESS) |
89 { |
94 { |
90 mCtx->xaRecordState = state; |
95 mCtx->xaRecordState = state; |
91 } |
96 } |
92 |
|
93 |
97 |
94 DEBUG_API("<-XARecordItfAdaptMMF_SetRecordState %d"); |
98 DEBUG_API("<-XARecordItfAdaptMMF_SetRecordState %d"); |
95 return ret; |
99 return ret; |
96 } |
100 } |
97 |
101 |
98 /* |
102 /* |
99 * XAresult XARecordItfAdapt_GetRecordState(XAAdaptationBaseCtx *bCtx, XAuint32 *state) |
103 * XAresult XARecordItfAdapt_GetRecordState(XAAdaptationBaseCtx *bCtx, XAuint32 *state) |
100 * Description: Return record state |
104 * Description: Return record state |
101 */ |
105 */ |
102 XAresult XARecordItfAdaptMMF_GetRecordState(XAAdaptationMMFCtx *bCtx, XAuint32 *state) |
106 XAresult XARecordItfAdaptMMF_GetRecordState(XAAdaptationMMFCtx *bCtx, |
103 { |
107 XAuint32 *state) |
|
108 { |
104 XAMediaRecorderAdaptationMMFCtx* mCtx = NULL; |
109 XAMediaRecorderAdaptationMMFCtx* mCtx = NULL; |
105 DEBUG_API("->XARecordItfAdaptMMF_GetRecordState"); |
110 DEBUG_API("->XARecordItfAdaptMMF_GetRecordState"); |
106 |
111 |
107 if(!bCtx) |
112 if (!bCtx) |
108 { |
113 { |
109 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
114 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdaptMMF_GetRecordState"); |
110 DEBUG_API("<-XARecordItfAdaptMMF_GetRecordState"); |
115 return XA_RESULT_PARAMETER_INVALID; |
111 return XA_RESULT_PARAMETER_INVALID; |
116 } |
112 } |
|
113 |
117 |
114 mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
118 mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
115 |
119 |
116 *state = mCtx->xaRecordState; |
120 *state = mCtx->xaRecordState; |
117 |
121 |
118 DEBUG_API("<-XARecordItfAdaptMMF_GetRecordState"); |
122 DEBUG_API("<-XARecordItfAdaptMMF_GetRecordState"); |
119 return XA_RESULT_SUCCESS; |
123 return XA_RESULT_SUCCESS; |
120 } |
124 } |
121 |
125 |
122 /* |
126 /* |
123 * XAresult XARecordItfAdapt_GetPosition(XAAdaptationBaseCtx *ctx, AdaptationContextIDS ctxIDs, XAmillisecond *pMsec) |
127 * XAresult XARecordItfAdapt_GetPosition(XAAdaptationBaseCtx *ctx, AdaptationContextIDS ctxIDs, XAmillisecond *pMsec) |
124 * @param XAAdaptationBaseCtx *ctx - Adaptation context, this will be casted to correct type regarding to contextID value given as 2nd parameter |
128 * @param XAAdaptationBaseCtx *ctx - Adaptation context, this will be casted to correct type regarding to contextID value given as 2nd parameter |
125 * XAmillisecond *pMsec - Pointer where to store current position in stream. |
129 * XAmillisecond *pMsec - Pointer where to store current position in stream. |
126 * @return XAresult ret - Success value |
130 * @return XAresult ret - Success value |
127 */ |
131 */ |
128 XAresult XARecordItfAdaptMMF_GetPosition(XAAdaptationMMFCtx *bCtx, XAmillisecond *pMsec) |
132 XAresult XARecordItfAdaptMMF_GetPosition(XAAdaptationMMFCtx *bCtx, |
129 { |
133 XAmillisecond *pMsec) |
|
134 { |
130 XAresult ret = XA_RESULT_SUCCESS; |
135 XAresult ret = XA_RESULT_SUCCESS; |
131 XAuint64 position; |
136 XAuint64 position; |
132 XAMediaRecorderAdaptationMMFCtx* mCtx = NULL; |
137 XAMediaRecorderAdaptationMMFCtx* mCtx = NULL; |
133 DEBUG_API("->XARecordItfAdaptMMF_GetPosition"); |
138 DEBUG_API("->XARecordItfAdaptMMF_GetPosition"); |
134 |
139 |
135 if(!bCtx) |
140 if (!bCtx) |
136 { |
141 { |
137 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
142 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdaptMMF_GetPosition"); |
138 DEBUG_API("<-XARecordItfAdaptMMF_GetPosition"); |
|
139 /* invalid parameter */ |
143 /* invalid parameter */ |
140 return XA_RESULT_PARAMETER_INVALID; |
144 ret = XA_RESULT_PARAMETER_INVALID; |
141 } |
145 return ret; |
|
146 } |
142 mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
147 mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
143 mmf_get_record_position(mCtx->mmfContext, &position); |
148 ret = mmf_get_record_position(mCtx->mmfContext, &position); |
144 |
149 |
145 *pMsec = (XAmillisecond)position; |
150 *pMsec = (XAmillisecond) position; |
146 |
151 |
147 DEBUG_API("<-XARecordItfAdaptMMF_GetPosition"); |
152 DEBUG_API("<-XARecordItfAdaptMMF_GetPosition"); |
148 return ret; |
153 return ret; |
149 } |
154 } |
150 |
155 |
151 /* |
156 /* |
152 * gboolean XARecordItfAdapt_PositionUpdate(gpointer ctx) |
157 * gboolean XARecordItfAdapt_PositionUpdate(gpointer ctx) |
153 * callback. |
158 * callback. |
154 * If position tracking enabled, periodic timer calls this method every XA_ADAPT_PU_INTERVAL msecs |
159 * If position tracking enabled, periodic timer calls this method every XA_ADAPT_PU_INTERVAL msecs |
155 * @return false to stop periodic calls |
160 * @return false to stop periodic calls |
156 */ |
161 */ |
157 gboolean XARecordItfAdaptMMF_PositionUpdate(gpointer ctx, XAuint64 position) |
162 gboolean XARecordItfAdaptMMF_PositionUpdate(gpointer ctx, XAuint64 position) |
158 { |
163 { |
159 XAAdaptationMMFCtx *bCtx = (XAAdaptationMMFCtx*) ctx; |
164 XAAdaptationMMFCtx *bCtx = (XAAdaptationMMFCtx*) ctx; |
160 XAMediaRecorderAdaptationMMFCtx* mCtx = (XAMediaRecorderAdaptationMMFCtx*) ctx; |
165 XAMediaRecorderAdaptationMMFCtx* mCtx = |
161 XAAdaptEvent event = {XA_RECORDITFEVENTS, XA_ADAPT_POSITION_UPDATE_EVT, 1, NULL}; |
166 (XAMediaRecorderAdaptationMMFCtx*) ctx; |
|
167 XAAdaptEvent event = |
|
168 { |
|
169 XA_RECORDITFEVENTS, XA_ADAPT_POSITION_UPDATE_EVT, 1, NULL |
|
170 }; |
162 DEBUG_API("->XARecordItfAdapt_PositionUpdate"); |
171 DEBUG_API("->XARecordItfAdapt_PositionUpdate"); |
163 |
172 |
164 if( mCtx && mCtx->trackpositionenabled ) |
173 if (mCtx && mCtx->trackpositionenabled) |
165 { |
174 { |
166 XAmillisecond posInMsec = 0; |
175 XAmillisecond posInMsec = 0; |
167 { |
176 { |
168 XARecordItfAdaptMMF_GetPosition(bCtx , &posInMsec); |
177 XARecordItfAdaptMMF_GetPosition(bCtx, &posInMsec); |
169 event.data = &posInMsec; |
178 event.data = &posInMsec; |
170 DEBUG_API_A1("XARecordItfAdapt_PositionUpdate: pos %lu ms", posInMsec); |
179 DEBUG_API_A1("XARecordItfAdapt_PositionUpdate: pos %lu ms", posInMsec); |
171 XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj, &event ); |
180 XAAdaptationBase_SendAdaptEvents(&bCtx->baseObj, &event); |
172 } |
181 }DEBUG_API_A1("<-XARecordItfAdapt_PositionUpdate: %d", mCtx->runpositiontimer); |
173 DEBUG_API_A1("<-XARecordItfAdapt_PositionUpdate: %d", mCtx->runpositiontimer); |
182 return (mCtx->runpositiontimer); |
174 return( mCtx->runpositiontimer ); |
183 } |
175 } |
|
176 /* return false to stop timer */ |
184 /* return false to stop timer */ |
177 return FALSE; |
185 return FALSE; |
178 } |
186 } |
179 |
187 |
180 /* |
188 /* |
181 * XAresult XARecordItfAdapt_EnablePositionTracking |
189 * XAresult XARecordItfAdapt_EnablePositionTracking |
182 * Enable/disable periodic position tracking callbacks |
190 * Enable/disable periodic position tracking callbacks |
183 */ |
191 */ |
184 XAresult XARecordItfAdaptMMF_EnablePositionTracking(XAAdaptationMMFCtx *bCtx, XAboolean enable) |
192 XAresult XARecordItfAdaptMMF_EnablePositionTracking(XAAdaptationMMFCtx *bCtx, |
185 { |
193 XAboolean enable) |
186 XAMediaRecorderAdaptationMMFCtx* mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
194 { |
|
195 XAMediaRecorderAdaptationMMFCtx* mCtx = |
|
196 (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
187 DEBUG_API_A1("->XARecordItfAdapt_EnablePositionTracking (enable: %lu)", enable); |
197 DEBUG_API_A1("->XARecordItfAdapt_EnablePositionTracking (enable: %lu)", enable); |
188 |
198 |
189 if(!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
199 if (!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
190 { |
200 { |
191 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
201 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking"); |
192 DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking"); |
|
193 /* invalid parameter */ |
202 /* invalid parameter */ |
194 return XA_RESULT_PARAMETER_INVALID; |
203 return XA_RESULT_PARAMETER_INVALID; |
195 } |
204 } |
196 |
|
197 |
205 |
198 /* create a timer to track position of playback */ |
206 /* create a timer to track position of playback */ |
199 if(enable && !(mCtx->trackpositionenabled)) |
207 if (enable && !(mCtx->trackpositionenabled)) |
200 { |
208 { |
201 mCtx->trackpositionenabled = XA_BOOLEAN_TRUE; |
209 mCtx->trackpositionenabled = XA_BOOLEAN_TRUE; |
202 //mCtx->positionCb = &XARecordItfAdaptMMF_PositionUpdate; |
210 //mCtx->positionCb = &XARecordItfAdaptMMF_PositionUpdate; |
203 |
211 |
204 } |
212 } |
205 else if (!enable && (mCtx->trackpositionenabled)) |
213 else if (!enable && (mCtx->trackpositionenabled)) |
206 { |
214 { |
207 mCtx->trackpositionenabled = XA_BOOLEAN_FALSE; |
215 mCtx->trackpositionenabled = XA_BOOLEAN_FALSE; |
208 if(mCtx->runpositiontimer > 0) |
216 if (mCtx->runpositiontimer > 0) |
209 { |
217 { |
210 mCtx->runpositiontimer=0; |
218 mCtx->runpositiontimer = 0; |
211 } |
219 } |
212 } |
220 } |
213 |
221 |
214 DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking"); |
222 DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking"); |
215 return XA_RESULT_SUCCESS; |
223 return XA_RESULT_SUCCESS; |
216 } |
224 } |
217 |
225 |
218 XAresult XARecordItfAdaptMMF_SetPositionUpdatePeriod(XAAdaptationMMFCtx *bCtx, XAmillisecond pMsec) |
226 XAresult XARecordItfAdaptMMF_SetPositionUpdatePeriod( |
219 { |
227 XAAdaptationMMFCtx *bCtx, XAmillisecond pMsec) |
220 XAMediaRecorderAdaptationMMFCtx* mCtx = (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
228 { |
|
229 XAresult ret = XA_RESULT_SUCCESS; |
|
230 XAMediaRecorderAdaptationMMFCtx* mCtx = |
|
231 (XAMediaRecorderAdaptationMMFCtx*) bCtx; |
221 DEBUG_API_A1("->XARecordItfAdaptMMF_SetPositionUpdatePeriod (pMsec: %lu)", pMsec); |
232 DEBUG_API_A1("->XARecordItfAdaptMMF_SetPositionUpdatePeriod (pMsec: %lu)", pMsec); |
222 |
233 |
223 if(!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
234 if (!bCtx || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
224 { |
235 { |
225 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
236 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking"); |
226 DEBUG_API("<-XARecordItfAdapt_EnablePositionTracking"); |
237 /* invalid parameter */ |
227 /* invalid parameter */ |
238 return XA_RESULT_PARAMETER_INVALID; |
228 return XA_RESULT_PARAMETER_INVALID; |
239 } |
229 } |
240 |
230 |
241 ret = mmf_set_record_position_update_period(mCtx->mmfContext, pMsec); |
231 mmf_set_record_position_update_period(mCtx->mmfContext, pMsec); |
242 return ret; |
232 return XA_RESULT_SUCCESS; |
243 } |
233 } |
|