equal
deleted
inserted
replaced
18 #include <pthread.h> |
18 #include <pthread.h> |
19 #include <gst/gst.h> |
19 #include <gst/gst.h> |
20 #include "xamediarecorderadaptctx.h" |
20 #include "xamediarecorderadaptctx.h" |
21 #include "xarecorditfadaptation.h" |
21 #include "xarecorditfadaptation.h" |
22 #include "xaadaptationgst.h" |
22 #include "xaadaptationgst.h" |
23 #include "xacameraadaptctx.h" |
23 |
24 |
24 |
25 /*forward declaration of position updater callback*/ |
25 /*forward declaration of position updater callback*/ |
26 gboolean XARecordItfAdapt_PositionUpdate(gpointer ctx); |
26 gboolean XARecordItfAdapt_PositionUpdate(gpointer ctx); |
27 |
|
28 extern XAboolean cameraRealized; |
|
29 extern XACameraAdaptationCtx_* cameraCtx; |
|
30 |
27 |
31 /* |
28 /* |
32 * XAresult XARecordItfAdapt_SetRecordState(XAAdaptationGstCtx *ctx, XAuint32 state) |
29 * XAresult XARecordItfAdapt_SetRecordState(XAAdaptationGstCtx *ctx, XAuint32 state) |
33 * Sets record state to GStreamer. |
30 * Sets record state to GStreamer. |
34 * @param XAAdaptationGstCtx *ctx - Adaptation context |
31 * @param XAAdaptationGstCtx *ctx - Adaptation context |
72 { |
69 { |
73 DEBUG_ERR("FAIL : post eos"); |
70 DEBUG_ERR("FAIL : post eos"); |
74 } |
71 } |
75 } |
72 } |
76 |
73 |
77 if (cameraCtx && cameraRealized && mCtx->isobjvsrc |
|
78 && mCtx->videosource) |
|
79 { |
|
80 cameraCtx->recording = XA_BOOLEAN_FALSE; |
|
81 |
|
82 if (!cameraCtx->playing && !cameraCtx->snapshotting) |
|
83 { |
|
84 /* Neither view finder or recorder is running -> pause camera */ |
|
85 if (GST_STATE( GST_ELEMENT(mCtx->videosource)) |
|
86 == GST_STATE_PLAYING) |
|
87 { |
|
88 GstStateChangeReturn gret; |
|
89 DEBUG_INFO("Stop camera source"); |
|
90 gret = gst_element_set_state( |
|
91 GST_ELEMENT(mCtx->videosource), |
|
92 GST_STATE_PAUSED); |
|
93 if (gret == GST_STATE_CHANGE_SUCCESS) |
|
94 gret = gst_element_get_state( |
|
95 GST_ELEMENT(mCtx->videosource), NULL, |
|
96 NULL, XA_ADAPT_ASYNC_TIMEOUT_SHORT_NSEC); |
|
97 } |
|
98 } |
|
99 } |
|
100 |
|
101 bCtx->binWantedState = GST_STATE_PAUSED; |
74 bCtx->binWantedState = GST_STATE_PAUSED; |
102 closeSink = XA_BOOLEAN_TRUE; |
75 closeSink = XA_BOOLEAN_TRUE; |
103 if (mCtx->runpositiontimer > 0) |
76 if (mCtx->runpositiontimer > 0) |
104 { |
77 { |
105 g_source_remove(mCtx->runpositiontimer); |
78 g_source_remove(mCtx->runpositiontimer); |
118 |
91 |
119 break; |
92 break; |
120 } |
93 } |
121 case XA_RECORDSTATE_PAUSED: |
94 case XA_RECORDSTATE_PAUSED: |
122 { |
95 { |
123 if (cameraCtx && cameraRealized && mCtx->isobjvsrc |
|
124 && mCtx->videosource) |
|
125 { |
|
126 cameraCtx->recording = XA_BOOLEAN_FALSE; |
|
127 if (!cameraCtx->playing && !cameraCtx->snapshotting) |
|
128 { |
|
129 /* Neither view finder or recorder is running -> pause camera */ |
|
130 if (GST_STATE( GST_ELEMENT(mCtx->videosource)) |
|
131 == GST_STATE_PLAYING) |
|
132 { |
|
133 GstStateChangeReturn gret; |
|
134 DEBUG_INFO("Stop camera source"); |
|
135 gret = gst_element_set_state( |
|
136 GST_ELEMENT(mCtx->videosource), |
|
137 GST_STATE_PAUSED); |
|
138 if (gret == GST_STATE_CHANGE_SUCCESS) |
|
139 gret = gst_element_get_state( |
|
140 GST_ELEMENT(mCtx->videosource), NULL, |
|
141 NULL, XA_ADAPT_ASYNC_TIMEOUT_SHORT_NSEC); |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 if (mCtx->xaRecordState == XA_RECORDSTATE_STOPPED |
96 if (mCtx->xaRecordState == XA_RECORDSTATE_STOPPED |
147 && mCtx->encodingchanged) |
97 && mCtx->encodingchanged) |
148 { |
98 { |
149 ret = XAMediaRecorderAdapt_ChangeEncoders(mCtx); |
99 ret = XAMediaRecorderAdapt_ChangeEncoders(mCtx); |
150 mCtx->encodingchanged = XA_BOOLEAN_FALSE; |
100 mCtx->encodingchanged = XA_BOOLEAN_FALSE; |
161 } |
111 } |
162 break; |
112 break; |
163 } |
113 } |
164 case XA_RECORDSTATE_RECORDING: |
114 case XA_RECORDSTATE_RECORDING: |
165 { |
115 { |
166 if (cameraCtx && mCtx->isobjvsrc) |
|
167 { |
|
168 cameraCtx->recording = XA_BOOLEAN_TRUE; |
|
169 } |
|
170 |
|
171 if (mCtx->xaRecordState == XA_RECORDSTATE_STOPPED |
116 if (mCtx->xaRecordState == XA_RECORDSTATE_STOPPED |
172 && (mCtx->encodingchanged)) |
117 && (mCtx->encodingchanged)) |
173 { |
118 { |
174 ret = XAMediaRecorderAdapt_ChangeEncoders(mCtx); |
119 ret = XAMediaRecorderAdapt_ChangeEncoders(mCtx); |
175 mCtx->encodingchanged = XA_BOOLEAN_FALSE; |
120 mCtx->encodingchanged = XA_BOOLEAN_FALSE; |
286 GST_STATE_PLAYING); |
231 GST_STATE_PLAYING); |
287 if (gret == GST_STATE_CHANGE_SUCCESS) |
232 if (gret == GST_STATE_CHANGE_SUCCESS) |
288 gret = gst_element_get_state(GST_ELEMENT(mCtx->videosource), |
233 gret = gst_element_get_state(GST_ELEMENT(mCtx->videosource), |
289 NULL, NULL, XA_ADAPT_ASYNC_TIMEOUT_SHORT_NSEC); |
234 NULL, NULL, XA_ADAPT_ASYNC_TIMEOUT_SHORT_NSEC); |
290 } |
235 } |
291 }DEBUG_API("<-XARecordItfAdapt_SetRecordState"); |
236 } |
|
237 DEBUG_API("<-XARecordItfAdapt_SetRecordState"); |
292 return ret; |
238 return ret; |
293 } |
239 } |
294 |
240 |
295 /* |
241 /* |
296 * XAresult XARecordItfAdapt_GetRecordState(XAAdaptationGstCtx *bCtx, XAuint32 *state) |
242 * XAresult XARecordItfAdapt_GetRecordState(XAAdaptationGstCtx *bCtx, XAuint32 *state) |