19 #include <stdlib.h> |
19 #include <stdlib.h> |
20 #include <assert.h> |
20 #include <assert.h> |
21 |
21 |
22 #include "xaseekitf.h" |
22 #include "xaseekitf.h" |
23 |
23 |
24 #ifdef _GSTREAMER_BACKEND_ |
24 #include "xaseekitfadaptation.h" |
25 #include "XASeekItfAdaptation.h" |
25 #include "xaplayitfadaptation.h" |
26 #include "XAPlayItfAdaptation.h" |
|
27 #endif |
|
28 #include "xathreadsafety.h" |
26 #include "xathreadsafety.h" |
29 |
27 #include "xaplayitfadaptationmmf.h" |
30 |
28 #include "xaseekitfadaptationmmf.h" |
31 /** |
29 /** |
32 * XASeekItfImpl* GetImpl(XASeekItf self) |
30 * XASeekItfImpl* GetImpl(XASeekItf self) |
33 * Description: Validate interface pointer and cast it to implementation pointer. |
31 * Description: Validate interface pointer and cast it to implementation pointer. |
34 */ |
32 */ |
35 static XASeekItfImpl* GetImpl(XASeekItf self) |
33 static XASeekItfImpl* GetImpl(XASeekItf self) |
70 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
68 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
71 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
69 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
72 return XA_RESULT_PARAMETER_INVALID; |
70 return XA_RESULT_PARAMETER_INVALID; |
73 } |
71 } |
74 |
72 |
75 #ifdef _GSTREAMER_BACKEND_ |
73 |
76 /* Get duration of the content */ |
74 if(impl->adapCtx->fwtype == FWMgrFWMMF) |
77 if(XAPlayItfAdapt_GetDuration(impl->adapCtx, &duration) != XA_RESULT_SUCCESS) |
75 { |
78 { |
76 /* Get duration of the content */ |
79 /* invalid parameter */ |
77 if(XAPlayItfAdaptMMF_GetDuration((XAAdaptationBaseCtx*)impl->adapCtx, &duration) != XA_RESULT_SUCCESS) |
80 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
78 { |
81 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
79 /* invalid parameter */ |
82 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
80 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
83 return XA_RESULT_PARAMETER_INVALID; |
81 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
84 } |
82 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
85 #endif |
83 return XA_RESULT_PARAMETER_INVALID; |
86 |
84 } |
87 if(pos > duration) |
85 if(pos > duration) |
88 { |
86 { |
89 /* invalid parameter */ |
87 /* invalid parameter */ |
90 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
88 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
91 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
89 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
92 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
90 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
93 return XA_RESULT_PARAMETER_INVALID; |
91 return XA_RESULT_PARAMETER_INVALID; |
94 } |
92 } |
95 |
93 |
96 if(seekMode != XA_SEEKMODE_FAST && seekMode != XA_SEEKMODE_ACCURATE) |
94 if(seekMode != XA_SEEKMODE_FAST && seekMode != XA_SEEKMODE_ACCURATE) |
97 { |
95 { |
98 /* seek mode unsupported */ |
96 /* seek mode unsupported */ |
99 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
97 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
100 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
98 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
101 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
99 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
102 return XA_RESULT_FEATURE_UNSUPPORTED; |
100 return XA_RESULT_FEATURE_UNSUPPORTED; |
103 } |
101 } |
104 |
102 |
105 #ifdef _GSTREAMER_BACKEND_ |
103 ret = XASeekItfAdaptMMF_SetPosition(impl->adapCtx, pos, seekMode); |
106 ret = XASeekItfAdapt_SetPosition(impl->adapCtx, pos, seekMode); |
104 if(ret == XA_RESULT_SUCCESS) |
107 #endif |
105 { |
108 if(ret == XA_RESULT_SUCCESS) |
106 impl->playbackPosition = pos; |
109 { |
107 impl->seekMode = seekMode; |
110 impl->playbackPosition = pos; |
108 } |
111 impl->seekMode = seekMode; |
109 } |
112 } |
110 else |
|
111 { |
|
112 /* Get duration of the content */ |
|
113 if(XAPlayItfAdaptGST_GetDuration((XAAdaptationGstCtx*)impl->adapCtx, &duration) != XA_RESULT_SUCCESS) |
|
114 { |
|
115 /* invalid parameter */ |
|
116 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
|
117 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
118 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
|
119 return XA_RESULT_PARAMETER_INVALID; |
|
120 } |
|
121 if(pos > duration) |
|
122 { |
|
123 /* invalid parameter */ |
|
124 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
|
125 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
126 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
|
127 return XA_RESULT_PARAMETER_INVALID; |
|
128 } |
|
129 |
|
130 if(seekMode != XA_SEEKMODE_FAST && seekMode != XA_SEEKMODE_ACCURATE) |
|
131 { |
|
132 /* seek mode unsupported */ |
|
133 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
|
134 DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED"); |
|
135 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
|
136 return XA_RESULT_FEATURE_UNSUPPORTED; |
|
137 } |
|
138 |
|
139 ret = XASeekItfAdapt_SetPosition((XAAdaptationGstCtx*)impl->adapCtx, pos, seekMode); |
|
140 if(ret == XA_RESULT_SUCCESS) |
|
141 { |
|
142 impl->playbackPosition = pos; |
|
143 impl->seekMode = seekMode; |
|
144 } |
|
145 |
|
146 } |
113 |
147 |
114 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
148 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
115 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
149 DEBUG_API("<-XASeekItfImpl_SetPosition"); |
116 return ret; |
150 return ret; |
117 } |
151 } |
137 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
171 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
138 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
172 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
139 return XA_RESULT_PARAMETER_INVALID; |
173 return XA_RESULT_PARAMETER_INVALID; |
140 } |
174 } |
141 |
175 |
142 #ifdef _GSTREAMER_BACKEND_ |
176 if(impl->adapCtx->fwtype == FWMgrFWMMF) |
143 /* Get duration of the content */ |
177 { |
144 if(XAPlayItfAdapt_GetDuration(impl->adapCtx, &duration) != XA_RESULT_SUCCESS) |
178 /* Get duration of the content */ |
145 { |
179 if(XAPlayItfAdaptMMF_GetDuration((XAAdaptationBaseCtx*)impl->adapCtx, &duration) != XA_RESULT_SUCCESS) |
146 /* invalid parameter */ |
180 { |
147 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
181 /* invalid parameter */ |
148 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
182 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
149 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
183 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
150 return XA_RESULT_PARAMETER_INVALID; |
184 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
151 } |
185 return XA_RESULT_PARAMETER_INVALID; |
152 #endif |
186 } |
153 if(endPos > duration && endPos != XA_TIME_UNKNOWN) |
187 if(endPos > duration && endPos != XA_TIME_UNKNOWN) |
154 { |
188 { |
155 /* invalid parameter */ |
189 /* invalid parameter */ |
156 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
190 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
157 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
191 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
158 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
192 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
159 return XA_RESULT_PARAMETER_INVALID; |
193 return XA_RESULT_PARAMETER_INVALID; |
160 } |
194 } |
161 |
195 |
162 #ifdef _GSTREAMER_BACKEND_ |
196 ret = XASeekItfAdaptMMF_SetLoop(impl->adapCtx, loopEnable, startPos, endPos); |
163 ret = XASeekItfAdapt_SetLoop(impl->adapCtx, loopEnable, startPos, endPos); |
197 if(ret == XA_RESULT_SUCCESS) |
164 #endif |
198 { |
165 if(ret == XA_RESULT_SUCCESS) |
199 impl->loopEnable = loopEnable; |
166 { |
200 impl->startPos = startPos; |
167 impl->loopEnable = loopEnable; |
201 impl->endPos = endPos; |
168 impl->startPos = startPos; |
202 } |
169 impl->endPos = endPos; |
203 } |
170 } |
204 else |
|
205 { |
|
206 /* Get duration of the content */ |
|
207 if(XAPlayItfAdaptGST_GetDuration((XAAdaptationGstCtx*)impl->adapCtx, &duration) != XA_RESULT_SUCCESS) |
|
208 { |
|
209 /* invalid parameter */ |
|
210 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
|
211 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
212 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
|
213 return XA_RESULT_PARAMETER_INVALID; |
|
214 } |
|
215 if(endPos > duration && endPos != XA_TIME_UNKNOWN) |
|
216 { |
|
217 /* invalid parameter */ |
|
218 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
|
219 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
|
220 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
|
221 return XA_RESULT_PARAMETER_INVALID; |
|
222 } |
|
223 |
|
224 ret = XASeekItfAdapt_SetLoop((XAAdaptationGstCtx*)impl->adapCtx, loopEnable, startPos, endPos); |
|
225 if(ret == XA_RESULT_SUCCESS) |
|
226 { |
|
227 impl->loopEnable = loopEnable; |
|
228 impl->startPos = startPos; |
|
229 impl->endPos = endPos; |
|
230 } |
|
231 |
|
232 } |
171 |
233 |
172 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
234 XA_IMPL_THREAD_SAFETY_EXIT( XATSMediaPlayer ); |
173 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
235 DEBUG_API("<-XASeekItfImpl_SetLoop"); |
174 return ret; |
236 return ret; |
175 } |
237 } |