19
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <assert.h>
|
|
19 |
#include <string.h>
|
|
20 |
#include "gst/gst.h"
|
|
21 |
#include "gst/gstbuffer.h"
|
|
22 |
#include "gst/app/gstappsrc.h"
|
|
23 |
#include "xaobjectitf.h"
|
|
24 |
#include "xacameradevice.h"
|
|
25 |
#include "xaradiodevice.h"
|
|
26 |
#include "xaoutputmix.h"
|
|
27 |
#include "xamediaplayeradaptctx.h"
|
|
28 |
#include "xacameraadaptctx.h"
|
|
29 |
#include <stdlib.h>
|
21
|
30 |
|
|
31 |
#ifdef OMAX_CAMERABIN
|
19
|
32 |
extern XAboolean cameraRealized;
|
21
|
33 |
|
19
|
34 |
extern XACameraAdaptationCtx_* cameraCtx;
|
21
|
35 |
#else
|
|
36 |
XAboolean cameraRealized = XA_BOOLEAN_FALSE;
|
|
37 |
XACameraAdaptationCtx_* cameraCtx = NULL;
|
|
38 |
#endif
|
19
|
39 |
/*
|
|
40 |
* XAAdaptationGstCtx* XAAdaptationGst_Create()
|
|
41 |
* 1st phase initialization function for Adaptation Base context structure.
|
|
42 |
* Reserves memory for base context and initializes GStreamer FW.
|
|
43 |
*/
|
|
44 |
XAresult XAAdaptationGst_Init( XAAdaptationGstCtx* pSelf, XAuint32 ctxId )
|
|
45 |
{
|
|
46 |
DEBUG_API("->XAAdaptationGst_Init");
|
|
47 |
|
|
48 |
if ( pSelf )
|
|
49 |
{
|
|
50 |
if(XAAdaptationBase_Init(&(pSelf->baseObj), ctxId) != XA_RESULT_SUCCESS)
|
|
51 |
{
|
|
52 |
DEBUG_ERR("Failed to init base context!!!");
|
|
53 |
free(pSelf);
|
|
54 |
pSelf = NULL;
|
|
55 |
}
|
|
56 |
else
|
|
57 |
{
|
|
58 |
GError* gerror = 0;
|
|
59 |
|
|
60 |
/* Add default handler for Gst-bus messages */
|
|
61 |
pSelf->busCb = XAAdaptationGst_GstBusCb;
|
|
62 |
|
|
63 |
// VASU MOD BEGINS
|
|
64 |
pSelf->cond_mutx_inited = XA_BOOLEAN_FALSE;
|
|
65 |
// VASU MOD ENDS
|
|
66 |
|
|
67 |
sem_init(&(pSelf->semAsyncWait),0,0);
|
|
68 |
|
|
69 |
|
|
70 |
if ( !gst_init_check( NULL, NULL, &gerror ) )
|
|
71 |
{
|
|
72 |
DEBUG_ERR("Gst Initalization failure.");
|
|
73 |
return XA_RESULT_INTERNAL_ERROR;
|
|
74 |
}
|
|
75 |
|
|
76 |
}
|
|
77 |
}
|
|
78 |
else
|
|
79 |
{
|
|
80 |
DEBUG_ERR("Invalid Gst Base Context.")
|
|
81 |
return XA_RESULT_PARAMETER_INVALID;
|
|
82 |
}
|
|
83 |
|
|
84 |
DEBUG_API("<-XAAdaptationGst_Init");
|
|
85 |
return XA_RESULT_SUCCESS;
|
|
86 |
}
|
|
87 |
|
|
88 |
/*
|
|
89 |
* XAresult XAAdaptationGst_PostInit()
|
|
90 |
* 2nd phase initialization for Adaptation Base.
|
|
91 |
*/
|
|
92 |
XAresult XAAdaptationGst_PostInit( XAAdaptationGstCtx* ctx )
|
|
93 |
{
|
|
94 |
XAresult ret = XA_RESULT_SUCCESS;
|
|
95 |
DEBUG_API("->XAAdaptationGst_PostInit");
|
|
96 |
// VASU MOD BEGINS
|
|
97 |
XAAdaptationBase_PostInit(&ctx->baseObj);
|
|
98 |
|
|
99 |
ctx->thread_launched = XA_BOOLEAN_FALSE;
|
|
100 |
pthread_mutex_init(&(ctx->ds_mutex), NULL);
|
|
101 |
pthread_cond_init(&(ctx->ds_condition), NULL);
|
|
102 |
ctx->cond_mutx_inited = XA_BOOLEAN_TRUE;
|
|
103 |
|
|
104 |
|
|
105 |
// VASU MOD ENDS
|
|
106 |
DEBUG_API("<-XAAdaptationGst_PostInit");
|
|
107 |
return ret;
|
|
108 |
}
|
|
109 |
|
|
110 |
/*
|
|
111 |
* void XAAdaptationGst_Free( XAAdaptationGstCtx* ctx )
|
|
112 |
* Frees all Base context variables .
|
|
113 |
*/
|
|
114 |
void XAAdaptationGst_Free( XAAdaptationGstCtx* ctx )
|
|
115 |
{
|
|
116 |
GstElement* fakesink = NULL;
|
|
117 |
DEBUG_API("->XAAdaptationGst_Free");
|
|
118 |
|
|
119 |
if ( ctx->bin )
|
|
120 |
{
|
|
121 |
fakesink = gst_bin_get_by_name(GST_BIN(ctx->bin), "fakesink");
|
|
122 |
if ( fakesink )
|
|
123 |
{
|
|
124 |
gst_element_set_state( GST_ELEMENT(fakesink), GST_STATE_NULL);
|
|
125 |
gst_object_unref(fakesink);
|
|
126 |
}
|
|
127 |
|
|
128 |
if ( gst_element_set_state(GST_ELEMENT(ctx->bin), GST_STATE_NULL )!=GST_STATE_CHANGE_SUCCESS )
|
|
129 |
{ /*not much we can do*/
|
|
130 |
DEBUG_ERR("WARNING: Failed to change to NULL state before deletion!!")
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
if(ctx->asynctimer)
|
|
135 |
{ /*cancel timer*/
|
|
136 |
g_source_remove(ctx->asynctimer);
|
|
137 |
}
|
|
138 |
sem_post(&(ctx->semAsyncWait));
|
|
139 |
sem_destroy(&(ctx->semAsyncWait));
|
|
140 |
|
|
141 |
XAAdaptationGst_StopGstListener(ctx);
|
|
142 |
|
|
143 |
if ( ctx->bin )
|
|
144 |
{
|
|
145 |
gst_object_unref(ctx->bin);
|
|
146 |
}
|
|
147 |
|
|
148 |
//g_array_free(ctx->evtHdlrs, TRUE);
|
|
149 |
// VASU MOD BEGINS
|
|
150 |
if (ctx->cond_mutx_inited == XA_BOOLEAN_TRUE)
|
|
151 |
{
|
|
152 |
ctx->thread_launched = XA_BOOLEAN_FALSE;
|
|
153 |
pthread_mutex_destroy(&(ctx->ds_mutex));
|
|
154 |
pthread_cond_destroy(&(ctx->ds_condition));
|
|
155 |
ctx->cond_mutx_inited = XA_BOOLEAN_FALSE;
|
|
156 |
}
|
|
157 |
// VASU MOD ENDS
|
|
158 |
XAAdaptationBase_Free(&ctx->baseObj);
|
|
159 |
|
|
160 |
DEBUG_API("<-XAAdaptationGst_Free");
|
|
161 |
}
|
|
162 |
|
|
163 |
|
|
164 |
/*
|
|
165 |
* gboolean XAAdaptationBase_GstBusCb( GstBus *bus, GstMessage *message, gpointer data )
|
|
166 |
* Default Gst-bus message handler (Callback)
|
|
167 |
*/
|
|
168 |
gboolean XAAdaptationGst_GstBusCb( GstBus *bus, GstMessage *message, gpointer data )
|
|
169 |
{
|
|
170 |
GError *error;
|
|
171 |
gchar *debug;
|
|
172 |
DEBUG_API("->XAAdaptationGst_GstBusCb");
|
|
173 |
DEBUG_INFO_A2("Received Gst callback \"%s\" from \"%s\"",
|
|
174 |
GST_MESSAGE_TYPE_NAME(message),
|
|
175 |
GST_OBJECT_NAME(GST_MESSAGE_SRC(message)));
|
|
176 |
|
|
177 |
switch( GST_MESSAGE_TYPE(message))
|
|
178 |
{
|
|
179 |
case GST_MESSAGE_ERROR:
|
|
180 |
gst_message_parse_error( message, &error, &debug );
|
|
181 |
DEBUG_INFO_A1("%s", debug);
|
|
182 |
break;
|
|
183 |
case GST_MESSAGE_EOS:
|
|
184 |
break;
|
|
185 |
case GST_MESSAGE_UNKNOWN:
|
|
186 |
break;
|
|
187 |
case GST_MESSAGE_WARNING:
|
|
188 |
break;
|
|
189 |
case GST_MESSAGE_INFO:
|
|
190 |
break;
|
|
191 |
case GST_MESSAGE_TAG:
|
|
192 |
break;
|
|
193 |
case GST_MESSAGE_BUFFERING:
|
|
194 |
break;
|
|
195 |
case GST_MESSAGE_STATE_CHANGED:
|
|
196 |
break;
|
|
197 |
case GST_MESSAGE_STATE_DIRTY:
|
|
198 |
break;
|
|
199 |
case GST_MESSAGE_STEP_DONE:
|
|
200 |
break;
|
|
201 |
case GST_MESSAGE_CLOCK_PROVIDE:
|
|
202 |
break;
|
|
203 |
case GST_MESSAGE_CLOCK_LOST:
|
|
204 |
break;
|
|
205 |
case GST_MESSAGE_NEW_CLOCK:
|
|
206 |
break;
|
|
207 |
case GST_MESSAGE_STRUCTURE_CHANGE:
|
|
208 |
break;
|
|
209 |
case GST_MESSAGE_STREAM_STATUS:
|
|
210 |
break;
|
|
211 |
case GST_MESSAGE_APPLICATION:
|
|
212 |
break;
|
|
213 |
case GST_MESSAGE_ELEMENT:
|
|
214 |
break;
|
|
215 |
case GST_MESSAGE_SEGMENT_START:
|
|
216 |
break;
|
|
217 |
case GST_MESSAGE_SEGMENT_DONE:
|
|
218 |
break;
|
|
219 |
case GST_MESSAGE_DURATION:
|
|
220 |
break;
|
|
221 |
case GST_MESSAGE_LATENCY:
|
|
222 |
break;
|
|
223 |
case GST_MESSAGE_ASYNC_START:
|
|
224 |
break;
|
|
225 |
case GST_MESSAGE_ASYNC_DONE:
|
|
226 |
break;
|
|
227 |
case GST_MESSAGE_ANY:
|
|
228 |
break;
|
|
229 |
default:
|
|
230 |
DEBUG_INFO("Unhandled Gst-Bus message");
|
|
231 |
break;
|
|
232 |
}
|
|
233 |
DEBUG_API("<-XAAdaptationGst_GstBusCb");
|
|
234 |
return TRUE;
|
|
235 |
}
|
|
236 |
|
|
237 |
XAresult XAAdaptationGst_InitGstListener(XAAdaptationGstCtx* ctx)
|
|
238 |
{
|
|
239 |
int ret;
|
|
240 |
DEBUG_API("->XAAdaptationGst_InitGstListener");
|
|
241 |
if ( ctx->bin )
|
|
242 |
{
|
|
243 |
ctx->bus = gst_pipeline_get_bus( GST_PIPELINE( ctx->bin ));
|
|
244 |
}
|
|
245 |
if( !ctx->bus )
|
|
246 |
{
|
|
247 |
DEBUG_ERR("could not get gst bus!")
|
|
248 |
return XA_RESULT_INTERNAL_ERROR;
|
|
249 |
}
|
|
250 |
ret = pthread_create(&(ctx->busloopThr), NULL, (XAAdaptationGst_LaunchGstListener),(void*)ctx);
|
|
251 |
// VASU MOD BEGINS
|
|
252 |
if ( ctx->thread_launched == XA_BOOLEAN_FALSE )
|
|
253 |
{
|
|
254 |
// Wait until the thread is created
|
|
255 |
pthread_mutex_lock(&(ctx->ds_mutex));
|
|
256 |
pthread_cond_wait(&(ctx->ds_condition), &(ctx->ds_mutex));
|
|
257 |
pthread_mutex_unlock(&(ctx->ds_mutex));
|
|
258 |
// VASU MOD ENDS
|
|
259 |
}
|
|
260 |
if(ret)
|
|
261 |
{
|
|
262 |
DEBUG_ERR_A1("could not create thread!! (%d)",ret)
|
|
263 |
return XA_RESULT_INTERNAL_ERROR;
|
|
264 |
}
|
|
265 |
DEBUG_API("<-XAAdaptationGst_InitGstListener");
|
|
266 |
return XA_RESULT_SUCCESS;
|
|
267 |
}
|
|
268 |
|
|
269 |
void * XAAdaptationGst_LaunchGstListener(void* args)
|
|
270 |
{
|
|
271 |
XAAdaptationGstCtx* ctx = (XAAdaptationGstCtx*)args;
|
|
272 |
DEBUG_API("->XAAdaptationGst_LaunchGstListener");
|
|
273 |
// VASU MOD BEGINS
|
|
274 |
// Signal calling thread that this thread creation is completed
|
|
275 |
ctx->thread_launched = XA_BOOLEAN_TRUE;
|
|
276 |
pthread_mutex_lock(&(ctx->ds_mutex));
|
|
277 |
pthread_cond_signal(&(ctx->ds_condition));
|
|
278 |
pthread_mutex_unlock(&(ctx->ds_mutex));
|
|
279 |
// VASU MOD ENDS
|
|
280 |
|
|
281 |
ctx->busloop = g_main_loop_new( NULL, FALSE );
|
|
282 |
if ( !ctx->busloop )
|
|
283 |
{
|
|
284 |
DEBUG_ERR("Glib main loop failure.")
|
|
285 |
DEBUG_API("<-XAAdaptationGst_LaunchGstListener");
|
|
286 |
assert(0);
|
|
287 |
}
|
|
288 |
else
|
|
289 |
{
|
|
290 |
DEBUG_INFO("Start Glib main loop")
|
|
291 |
g_main_loop_run(ctx->busloop);
|
|
292 |
DEBUG_INFO("Glib main loop stopped - exiting thread")
|
|
293 |
DEBUG_API("<-XAAdaptationGst_LaunchGstListener");
|
|
294 |
pthread_exit(NULL);
|
|
295 |
}
|
|
296 |
return NULL;
|
|
297 |
}
|
|
298 |
|
|
299 |
void XAAdaptationGst_StopGstListener(XAAdaptationGstCtx* ctx)
|
|
300 |
{
|
|
301 |
DEBUG_API("->XAAdaptationGst_StopGstListener");
|
|
302 |
if(ctx->busloop)
|
|
303 |
{
|
|
304 |
g_main_loop_quit (ctx->busloop);
|
|
305 |
g_main_loop_unref(ctx->busloop);
|
|
306 |
}
|
|
307 |
if(ctx->bus)
|
|
308 |
{
|
|
309 |
gst_object_unref(ctx->bus);
|
|
310 |
ctx->bus = NULL;
|
|
311 |
}
|
|
312 |
DEBUG_API("<-XAAdaptationGst_StopGstListener");
|
|
313 |
}
|
|
314 |
|
|
315 |
/*
|
|
316 |
* ASynchronous operation managing
|
|
317 |
**/
|
|
318 |
|
|
319 |
/* NOTE: This should NOT be called from gst callbacks - danger of deadlock!!
|
|
320 |
*/
|
|
321 |
void XAAdaptationGst_PrepareAsyncWait(XAAdaptationGstCtx* ctx)
|
|
322 |
{
|
|
323 |
DEBUG_API("->XAAdaptationGst_PrepareAsyncWait");
|
|
324 |
|
|
325 |
if( ctx->waitingasyncop )
|
|
326 |
{ /*wait previous async op*/
|
|
327 |
DEBUG_INFO("::WARNING:: previous asynch still ongoing!!!");
|
|
328 |
DEBUG_INFO(">>>> WAIT PREVIOUS");
|
|
329 |
sem_wait(&(ctx->semAsyncWait));
|
|
330 |
DEBUG_INFO("<<<< PREVIOUS COMPLETED");
|
|
331 |
}
|
|
332 |
sem_init(&(ctx->semAsyncWait),0,0);
|
|
333 |
|
|
334 |
ctx->waitingasyncop = XA_BOOLEAN_TRUE;
|
|
335 |
DEBUG_API("<-XAAdaptationGst_PrepareAsyncWait");
|
|
336 |
}
|
|
337 |
|
|
338 |
void XAAdaptationGst_StartAsyncWait(XAAdaptationGstCtx* ctx)
|
|
339 |
{
|
|
340 |
DEBUG_API("->XAAdaptationGst_StartAsyncWait");
|
|
341 |
|
|
342 |
/* timeout to try to avoid gst freeze in rollup */
|
|
343 |
ctx->asynctimer = g_timeout_add(XA_ADAPT_ASYNC_TIMEOUT,
|
|
344 |
XAAdaptationGst_CancelAsyncWait, ctx);
|
|
345 |
/* check flag once again if callback already happened before wait */
|
|
346 |
if(ctx->waitingasyncop)
|
|
347 |
{
|
|
348 |
DEBUG_INFO(">>>> ASYNC STARTS");
|
|
349 |
sem_wait(&(ctx->semAsyncWait));
|
|
350 |
DEBUG_INFO("<<<< ASYNC COMPLETED");
|
|
351 |
}
|
|
352 |
else
|
|
353 |
{
|
|
354 |
DEBUG_INFO("<> async completed already");
|
|
355 |
}
|
|
356 |
/*cancel timer*/
|
|
357 |
if(ctx->asynctimer)
|
|
358 |
{
|
|
359 |
g_source_remove(ctx->asynctimer);
|
|
360 |
}
|
|
361 |
ctx->waitingasyncop = XA_BOOLEAN_FALSE;
|
|
362 |
|
|
363 |
DEBUG_API("<-XAAdaptationGst_StartAsyncWait");
|
|
364 |
}
|
|
365 |
|
|
366 |
/* async operation timeout callback*/
|
|
367 |
gboolean XAAdaptationGst_CancelAsyncWait(gpointer ctx)
|
|
368 |
{
|
|
369 |
XAAdaptationGstCtx* bCtx = (XAAdaptationGstCtx*)ctx;
|
|
370 |
DEBUG_API("->XAAdaptationGst_CancelAsyncWait");
|
|
371 |
if( bCtx->waitingasyncop )
|
|
372 |
{
|
|
373 |
DEBUG_ERR_A3("ASYNC TIMED OUT : current %d, gsttarget %d, wanted %d",
|
|
374 |
GST_STATE(bCtx->bin), GST_STATE_TARGET(bCtx->bin), bCtx->binWantedState);
|
|
375 |
bCtx->waitingasyncop = XA_BOOLEAN_FALSE;
|
|
376 |
sem_post(&(bCtx->semAsyncWait));
|
|
377 |
}
|
|
378 |
DEBUG_API("<-XAAdaptationGst_CancelAsyncWait");
|
|
379 |
/* return false to remove timer */
|
|
380 |
return FALSE;
|
|
381 |
}
|
|
382 |
|
|
383 |
void XAAdaptationGst_CompleteAsyncWait(XAAdaptationGstCtx* ctx)
|
|
384 |
{
|
|
385 |
DEBUG_API("->XAAdaptationGst_CompleteAsyncWait");
|
|
386 |
if( ctx->waitingasyncop )
|
|
387 |
{
|
|
388 |
int i;
|
|
389 |
ctx->waitingasyncop = XA_BOOLEAN_FALSE;
|
|
390 |
sem_getvalue(&(ctx->semAsyncWait),&i);
|
|
391 |
DEBUG_INFO_A1("Asynch operation succeeded, sem value %d",i);
|
|
392 |
if(i<=0)
|
|
393 |
{ /* only post if locked */
|
|
394 |
sem_post(&(ctx->semAsyncWait));
|
|
395 |
}
|
|
396 |
else if(i>0)
|
|
397 |
{ /* should not be, reset semaphore */
|
|
398 |
sem_init(&(ctx->semAsyncWait),0,0);
|
|
399 |
}
|
|
400 |
}
|
|
401 |
DEBUG_API("<-XAAdaptationGst_CompleteAsyncWait");
|
|
402 |
}
|
|
403 |
|
|
404 |
/**
|
|
405 |
* GstElement* XAAdaptationGst_CreateGstSource( XADataSource* xaSrc, const XAchar *name )
|
|
406 |
* @param XADataSource* xaSnk - XADataSource defining gst source to create
|
|
407 |
* @param const XAchar *name - string for naming the gst element
|
|
408 |
* @param XAboolean *isobj - (out param) is source another XA object?
|
|
409 |
* @return GstElement* - return newly created gst source element
|
|
410 |
* Description: Create gst source element corresponding to XA source structure
|
|
411 |
*/
|
|
412 |
GstElement* XAAdaptationGst_CreateGstSource( XADataSource* xaSrc, const char *name, XAboolean *isobj, XAboolean *isPCM, XAboolean *isRawImage )
|
|
413 |
{
|
|
414 |
XAuint32 locType = 0;
|
|
415 |
GstElement* gstSrc = NULL;
|
|
416 |
char* fname=NULL;
|
|
417 |
XADataLocator_URI* uri = NULL;
|
|
418 |
XADataLocator_IODevice* ioDevice = NULL;
|
21
|
419 |
#ifdef OMAX_CAMERABIN
|
19
|
420 |
XACameraDeviceImpl* cameraDevice = NULL;
|
21
|
421 |
XAObjectItfImpl* pObj = NULL;
|
|
422 |
#endif
|
19
|
423 |
XARadioDeviceImpl* radioDevice = NULL;
|
|
424 |
|
|
425 |
DEBUG_API("->XAAdaptationGst_CreateGstSource");
|
|
426 |
if( !xaSrc || !xaSrc->pLocator || !isobj )
|
|
427 |
{
|
|
428 |
return NULL;
|
|
429 |
}
|
|
430 |
*isobj = XA_BOOLEAN_FALSE;
|
|
431 |
if( xaSrc && xaSrc->pFormat && *((XAuint32*)(xaSrc->pFormat))==XA_DATAFORMAT_PCM && isPCM )
|
|
432 |
{
|
|
433 |
*isPCM = XA_BOOLEAN_TRUE;
|
|
434 |
}
|
|
435 |
if( xaSrc && xaSrc->pFormat && *((XAuint32*)(xaSrc->pFormat))==XA_DATAFORMAT_RAWIMAGE && isRawImage )
|
|
436 |
{
|
|
437 |
*isRawImage = XA_BOOLEAN_TRUE;
|
|
438 |
}
|
|
439 |
locType = *((XAuint32*)(xaSrc->pLocator));
|
|
440 |
switch ( locType )
|
|
441 |
{
|
|
442 |
case XA_DATALOCATOR_URI:
|
|
443 |
DEBUG_INFO("XA_DATALOCATOR_URI");
|
|
444 |
uri = (XADataLocator_URI*)xaSrc->pLocator;
|
|
445 |
gstSrc = gst_element_factory_make("filesrc",name);
|
|
446 |
if ( uri->URI != NULL )
|
|
447 |
{
|
|
448 |
DEBUG_INFO_A1("URI: %s", uri->URI);
|
|
449 |
if(strncmp((char *)uri->URI, "file:///", 8) == 0)
|
|
450 |
{
|
|
451 |
fname = (char *)&((uri->URI)[8]);
|
|
452 |
}
|
|
453 |
else
|
|
454 |
{
|
|
455 |
fname = (char *)uri->URI;
|
|
456 |
}
|
|
457 |
DEBUG_INFO_A1("->filesystem path %s", fname);
|
|
458 |
g_object_set( G_OBJECT(gstSrc), "location", fname, NULL );
|
|
459 |
/*check for pcm - decodebin does not know how to handle raw PCM files */
|
|
460 |
if( isPCM && strstr(fname, ".pcm") )
|
|
461 |
{
|
|
462 |
DEBUG_INFO("PCM file detected");
|
|
463 |
*isPCM=XA_BOOLEAN_TRUE;
|
|
464 |
}
|
|
465 |
}
|
|
466 |
else
|
|
467 |
{
|
|
468 |
DEBUG_ERR("No uri specified.");
|
|
469 |
return NULL;
|
|
470 |
}
|
|
471 |
break; /* XA_DATALOCATOR_URI */
|
|
472 |
|
|
473 |
|
|
474 |
case XA_DATALOCATOR_IODEVICE:
|
|
475 |
DEBUG_INFO("XA_DATALOCATOR_IODEVICE");
|
|
476 |
ioDevice = (XADataLocator_IODevice*)(xaSrc->pLocator);
|
|
477 |
switch ( ioDevice->deviceType )
|
|
478 |
{
|
|
479 |
case XA_IODEVICE_AUDIOINPUT:
|
|
480 |
{
|
|
481 |
DEBUG_INFO("XA_IODEVICE_AUDIOINPUT");
|
|
482 |
DEBUG_INFO_A1("ioDevice->deviceID: %x", ioDevice->deviceID);
|
|
483 |
switch (ioDevice->deviceID )
|
|
484 |
{
|
|
485 |
//case XA_ADAPTID_ALSASRC: //Krishna
|
|
486 |
case XA_ADAPTID_DEVSOUNDSRC:
|
|
487 |
//DEBUG_INFO("alsasrc"); //Krishna
|
|
488 |
DEBUG_INFO("devsoundsrc");
|
|
489 |
gstSrc = gst_element_factory_make("devsoundsrc",name); //Krishna - changed to devsoundsrc
|
|
490 |
g_object_set (G_OBJECT (gstSrc), "num-buffers", 80, NULL);
|
|
491 |
break;
|
|
492 |
case XA_ADAPTID_AUDIOTESTSRC:
|
|
493 |
/*fall through*/
|
|
494 |
default:
|
|
495 |
DEBUG_INFO("audiotestsrc");
|
|
496 |
gstSrc = gst_element_factory_make("audiotestsrc",name);
|
|
497 |
break;
|
|
498 |
}
|
|
499 |
break;
|
|
500 |
}
|
21
|
501 |
#ifdef OMAX_CAMERABIN
|
|
502 |
|
19
|
503 |
case XA_IODEVICE_CAMERA:
|
|
504 |
{
|
|
505 |
DEBUG_INFO("XA_IODEVICE_CAMERA");
|
|
506 |
if ( ioDevice->device )
|
|
507 |
{ /*source is camera object*/
|
|
508 |
DEBUG_INFO("Use camerabin as source.");
|
|
509 |
/* Get camerabin from source object */
|
|
510 |
pObj = (XAObjectItfImpl*)(*ioDevice->device);
|
|
511 |
cameraDevice = (XACameraDeviceImpl*)(pObj);
|
|
512 |
/*TODO we had to remove this line below since adaptationCtx
|
|
513 |
* was not a member of structure*/
|
|
514 |
|
|
515 |
gstSrc = GST_ELEMENT(((XAAdaptationGstCtx*)(cameraDevice->adaptationCtx))->bin);
|
|
516 |
/* refcount increase is needed to keep this not being deleted after use */
|
|
517 |
gst_object_ref(GST_OBJECT(gstSrc));
|
|
518 |
*isobj = XA_BOOLEAN_TRUE;
|
|
519 |
}
|
|
520 |
else
|
|
521 |
{
|
|
522 |
DEBUG_INFO_A1("ioDevice->deviceID: %x", ioDevice->deviceID);
|
|
523 |
switch (ioDevice->deviceID )
|
|
524 |
{
|
|
525 |
case XA_ADAPTID_V4L2SRC:
|
|
526 |
DEBUG_INFO("Camera deviceID: v4l2src ");
|
|
527 |
|
|
528 |
break;
|
|
529 |
case XA_ADAPTID_VIDEOTESTSRC:
|
|
530 |
DEBUG_INFO("Camera deviceID: videotestsrc");
|
|
531 |
|
|
532 |
break;
|
|
533 |
default:
|
|
534 |
case XA_DEFAULTDEVICEID_CAMERA:
|
|
535 |
DEBUG_INFO("Camera deviceID:Default");
|
|
536 |
|
|
537 |
break;
|
|
538 |
}
|
|
539 |
if ( cameraCtx )
|
|
540 |
{
|
|
541 |
gstSrc = GST_ELEMENT(cameraCtx->baseObj.bin);
|
|
542 |
gst_object_ref(GST_OBJECT(gstSrc));
|
|
543 |
*isobj = XA_BOOLEAN_TRUE;
|
|
544 |
}
|
|
545 |
else
|
|
546 |
{
|
|
547 |
DEBUG_ERR("No camera object created!");
|
|
548 |
return NULL;
|
|
549 |
}
|
|
550 |
}
|
|
551 |
break;
|
|
552 |
}
|
21
|
553 |
#endif
|
19
|
554 |
case XA_IODEVICE_RADIO:
|
|
555 |
DEBUG_INFO("XA_IODEVICE_RADIO");
|
|
556 |
if ( ioDevice->device )
|
|
557 |
{
|
|
558 |
DEBUG_INFO("Use radio pipeline as source.");
|
|
559 |
/* Get radio_pipeline and set it to base context */
|
|
560 |
radioDevice = (XARadioDeviceImpl*)(*ioDevice->device);
|
|
561 |
/* radio does not have actual bin, only source element*/
|
|
562 |
gstSrc = GST_ELEMENT(((XAAdaptationGstCtx*)radioDevice->adaptationCtx)->bin);
|
|
563 |
/* refcount increase is needed to keep this not being deleted after use */
|
|
564 |
gst_object_ref(GST_OBJECT(gstSrc));
|
|
565 |
/**isobj = XA_BOOLEAN_TRUE;*/
|
|
566 |
}
|
|
567 |
break;
|
|
568 |
default:
|
|
569 |
{
|
|
570 |
DEBUG_ERR("Unsupported IODevice.");
|
|
571 |
break;
|
|
572 |
}
|
|
573 |
}
|
|
574 |
break; /* XA_DATALOCATOR_IODEVICE */
|
|
575 |
|
|
576 |
/* case XA_DATALOCATOR_CONTENTPIPE:
|
|
577 |
{
|
|
578 |
DEBUG_INFO("XA_DATALOCATOR_CONTENTPIPE");
|
|
579 |
gstSrc = gst_element_factory_make("appsrc",name);
|
|
580 |
break;
|
|
581 |
}*/
|
|
582 |
case XA_DATALOCATOR_ADDRESS:
|
|
583 |
{
|
|
584 |
XADataLocator_Address* address = (XADataLocator_Address*)(xaSrc->pLocator);
|
|
585 |
gstSrc = gst_element_factory_make("appsrc", name);
|
|
586 |
/* init gst buffer from datalocator */
|
|
587 |
if( gstSrc )
|
|
588 |
{
|
|
589 |
/* init GST buffer from XADataLocator*/
|
|
590 |
GstBuffer* userBuf = gst_buffer_new();
|
|
591 |
if( userBuf )
|
|
592 |
{
|
|
593 |
userBuf->size = address->length;
|
|
594 |
userBuf->data = address->pAddress;
|
|
595 |
/* push the whole buffer to appsrc so it is ready for preroll */
|
|
596 |
DEBUG_INFO("Pushing buffer");
|
|
597 |
gst_app_src_push_buffer( GST_APP_SRC(gstSrc), userBuf );
|
|
598 |
DEBUG_INFO_A1("Sent buffer at 0x%x to appsrc", userBuf );
|
|
599 |
gst_app_src_end_of_stream( GST_APP_SRC(gstSrc) );
|
|
600 |
}
|
|
601 |
else
|
|
602 |
{
|
|
603 |
DEBUG_ERR("Failure allocating buffer!");
|
|
604 |
}
|
|
605 |
}
|
|
606 |
else
|
|
607 |
{
|
|
608 |
DEBUG_ERR("Failure creating appsrc!");
|
|
609 |
}
|
|
610 |
}
|
|
611 |
break;
|
|
612 |
|
|
613 |
default:
|
|
614 |
DEBUG_ERR("Incorrect data locator for source.")
|
|
615 |
break;
|
|
616 |
}
|
|
617 |
|
|
618 |
if ( gstSrc )
|
|
619 |
{
|
|
620 |
DEBUG_INFO_A1("Created gstreamer source element at %x", gstSrc);
|
|
621 |
}
|
|
622 |
|
|
623 |
DEBUG_API("<-XAAdaptationGst_CreateGstSource");
|
|
624 |
return gstSrc;
|
|
625 |
}
|
|
626 |
|
|
627 |
|
|
628 |
/**
|
|
629 |
* GstElement* XAAdaptationGst_CreateGstSink( XADataSink* xaSnk, const XAchar *name )
|
|
630 |
* @param XADataSink* xaSnk - XADataSink defining gst sink to create
|
|
631 |
* @param const XAchar *name - string for naming the gst element
|
|
632 |
* @return GstElement* - return newly created gst sink element
|
|
633 |
* Description: Create gst sink element corresponding to XA sink structure
|
|
634 |
*/
|
|
635 |
GstElement* XAAdaptationGst_CreateGstSink( XADataSink* xaSnk, const char *name, XAboolean *isobj )
|
|
636 |
{
|
|
637 |
XAuint32 locType = 0;
|
|
638 |
GstElement* gstSnk = NULL;
|
|
639 |
XADataLocator_URI* uri = NULL;
|
|
640 |
DEBUG_API("->XAAdaptationGst_CreateGstSink");
|
|
641 |
if(!xaSnk || !xaSnk->pLocator)
|
|
642 |
{
|
|
643 |
DEBUG_INFO("Warning! No sink specified, use fakesink");
|
|
644 |
gstSnk = gst_element_factory_make("fakesink",name);
|
|
645 |
if(!gstSnk)
|
|
646 |
{
|
|
647 |
DEBUG_ERR("Cannot create sink!");
|
|
648 |
return NULL;
|
|
649 |
}
|
|
650 |
g_object_set( G_OBJECT(gstSnk),"async", FALSE, NULL);
|
|
651 |
}
|
|
652 |
else
|
|
653 |
{
|
|
654 |
locType = *((XAuint32*)(xaSnk->pLocator));
|
|
655 |
switch ( locType )
|
|
656 |
{
|
|
657 |
case XA_DATALOCATOR_URI:
|
|
658 |
DEBUG_INFO("XA_DATALOCATOR_URI");
|
|
659 |
uri = (XADataLocator_URI*)xaSnk->pLocator;
|
|
660 |
gstSnk = gst_element_factory_make("filesink",name);
|
|
661 |
if(!gstSnk)
|
|
662 |
{
|
|
663 |
DEBUG_ERR("Cannot create sink!");
|
|
664 |
return NULL;
|
|
665 |
}
|
|
666 |
if ( uri->URI != NULL )
|
|
667 |
{
|
|
668 |
XAchar *fname;
|
|
669 |
DEBUG_INFO_A1("URI: %s", uri->URI);
|
|
670 |
if(strncmp((char *)uri->URI, "file:///", 8) == 0)
|
|
671 |
{
|
|
672 |
fname = &((uri->URI)[8]);
|
|
673 |
}
|
|
674 |
else
|
|
675 |
{
|
|
676 |
fname = uri->URI;
|
|
677 |
}
|
|
678 |
DEBUG_INFO_A1("->filesystem path %s", fname);
|
|
679 |
g_object_set( G_OBJECT(gstSnk),"location", fname,
|
|
680 |
"async", FALSE,
|
|
681 |
"qos", FALSE,
|
|
682 |
"max-lateness", (gint64)(-1),
|
|
683 |
NULL);
|
|
684 |
}
|
|
685 |
else
|
|
686 |
{
|
|
687 |
DEBUG_ERR("No recording output uri specified.");
|
|
688 |
return NULL;
|
|
689 |
}
|
|
690 |
break;
|
|
691 |
case XA_DATALOCATOR_NATIVEDISPLAY:
|
|
692 |
DEBUG_INFO("Sink locator type - XA_DATALOCATOR_NATIVEDISPLAY");
|
|
693 |
#ifdef USE_NGA_SURFACES
|
|
694 |
gstSnk = gst_element_factory_make("devvideosink","devvideosink");
|
|
695 |
#else
|
|
696 |
gstSnk = gst_element_factory_make("ximagesink",name);
|
|
697 |
#endif /*USE_NGA_SURFACES*/
|
|
698 |
if(!gstSnk)
|
|
699 |
{
|
|
700 |
DEBUG_ERR("Cannot create sink!");
|
|
701 |
return NULL;
|
|
702 |
}
|
|
703 |
g_object_set( G_OBJECT(gstSnk), "force-aspect-ratio", TRUE,
|
|
704 |
"async", FALSE,
|
|
705 |
"qos", FALSE,
|
|
706 |
"handle-events", TRUE,
|
|
707 |
"handle-expose", TRUE,
|
|
708 |
"max-lateness", (gint64)(-1),
|
|
709 |
NULL);
|
|
710 |
break;
|
|
711 |
case XA_DATALOCATOR_OUTPUTMIX:
|
|
712 |
DEBUG_INFO("Sink locator type - XA_DATALOCATOR_OUTPUTMIX");
|
|
713 |
{
|
|
714 |
/* Get OutputMix adaptation from data locator */
|
|
715 |
XADataLocator_OutputMix* omix = (XADataLocator_OutputMix*)(xaSnk->pLocator);
|
|
716 |
if ( omix->outputMix )
|
|
717 |
{
|
|
718 |
XAOMixImpl* omixDevice = (XAOMixImpl*)(*omix->outputMix);
|
|
719 |
|
|
720 |
if(omixDevice)
|
|
721 |
{
|
|
722 |
/*TODO we had to remove this line below since adaptationCtx
|
|
723 |
* was not a member of structure*/
|
|
724 |
|
|
725 |
/*gstSnk = XAOutputMixAdapt_GetSink(omixDevice->adaptationCtx);*/
|
|
726 |
if(!gstSnk)
|
|
727 |
{
|
|
728 |
DEBUG_ERR("Cannot create sink!");
|
|
729 |
return NULL;
|
|
730 |
}
|
|
731 |
*isobj = XA_BOOLEAN_TRUE;
|
|
732 |
}
|
|
733 |
else
|
|
734 |
{
|
|
735 |
DEBUG_ERR("Warning - NULL outputmix object - default audio output used");
|
|
736 |
gstSnk = gst_element_factory_make("alsasink",name);
|
|
737 |
}
|
|
738 |
}
|
|
739 |
else
|
|
740 |
{
|
|
741 |
DEBUG_ERR("Warning - NULL outputmix object - default audio output used");
|
|
742 |
gstSnk = gst_element_factory_make("alsasink",name);
|
|
743 |
}
|
|
744 |
|
|
745 |
}
|
|
746 |
break;
|
|
747 |
/* case XA_DATALOCATOR_CONTENTPIPE:
|
|
748 |
DEBUG_INFO("XA_DATALOCATOR_CONTENTPIPE");
|
|
749 |
gstSnk = gst_element_factory_make("appsink",name);
|
|
750 |
break;*/
|
|
751 |
case XA_DATALOCATOR_ADDRESS:
|
|
752 |
{
|
|
753 |
gstSnk = gst_element_factory_make("appsink", name);
|
|
754 |
/* Not actually object sink, but attribute used to notify recorder
|
|
755 |
* about appsink (no object sinks applicable in this use case)
|
|
756 |
**/
|
|
757 |
*isobj=TRUE;
|
|
758 |
}
|
|
759 |
break;
|
|
760 |
case XA_DATALOCATOR_IODEVICE:
|
|
761 |
/* when only valid IOdevice sinks vibra and LED sinks implemented
|
|
762 |
* at adaptation level, add handling here (in this implementation,
|
|
763 |
* no handling needed as only dummy implementations for those)
|
|
764 |
**/
|
|
765 |
default:
|
|
766 |
DEBUG_ERR("Incorrect data locator for sink.")
|
|
767 |
break;
|
|
768 |
}
|
|
769 |
}
|
|
770 |
if (gstSnk )
|
|
771 |
{
|
|
772 |
DEBUG_INFO_A1("Created gstreamer sink element at %x", gstSnk);
|
|
773 |
}
|
|
774 |
DEBUG_API("<-XAAdaptationGst_CreateGstSink");
|
|
775 |
return gstSnk;
|
|
776 |
}
|
|
777 |
|
|
778 |
/**
|
|
779 |
* GstElement* XAAdaptationGst_CreateVideoPP( )
|
|
780 |
* @return GstElement* - return newly created gst pipeline element
|
|
781 |
* Description: Create video processing pipeline
|
|
782 |
*/
|
|
783 |
GstElement* XAAdaptationGst_CreateVideoPP( )
|
|
784 |
{
|
|
785 |
GstElement *vpp;
|
|
786 |
DEBUG_API("->XAAdaptationGst_CreateVideoPP");
|
|
787 |
vpp = gst_pipeline_new("videopp");
|
|
788 |
if( vpp )
|
|
789 |
{
|
|
790 |
GstPad *ghostsink, *ghostsrc;
|
|
791 |
GstElement *col1,
|
|
792 |
*col2,
|
|
793 |
*rotate,
|
|
794 |
*mirror,
|
|
795 |
*box,
|
|
796 |
*crop,
|
|
797 |
*gamma,
|
|
798 |
*balance,
|
|
799 |
*scale,
|
|
800 |
*scale2,
|
|
801 |
#ifdef USE_NGA_SURFACES
|
|
802 |
*identity,
|
|
803 |
#endif /*USE_NGA_SURFACES*/
|
|
804 |
*queue;
|
|
805 |
|
|
806 |
|
|
807 |
/* Crete ffmpegcolorspace to convert stream to correct format */
|
|
808 |
col1 = gst_element_factory_make( "ffmpegcolorspace", "pp_colsp1");
|
|
809 |
if(col1)
|
|
810 |
{
|
|
811 |
DEBUG_INFO("Created ffmpegcolorspace element");
|
|
812 |
gst_bin_add(GST_BIN(vpp), col1);
|
|
813 |
/* make this bin link point*/
|
|
814 |
ghostsink = gst_element_get_static_pad(col1,"sink");
|
|
815 |
if(ghostsink)
|
|
816 |
{
|
|
817 |
gst_element_add_pad(vpp, gst_ghost_pad_new("videopp_sink",ghostsink));
|
|
818 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
819 |
}
|
|
820 |
}
|
|
821 |
|
|
822 |
/* create video crop, this will be sink for videoPP pipeline */
|
|
823 |
crop = gst_element_factory_make( "videocrop", "pp_crop");
|
|
824 |
if(crop)
|
|
825 |
{
|
|
826 |
DEBUG_INFO("Created crop element");
|
|
827 |
gst_bin_add(GST_BIN(vpp), crop);
|
|
828 |
}
|
|
829 |
|
|
830 |
/* create video rotate */
|
|
831 |
rotate = gst_element_factory_make( "videoflip", "pp_rotate");
|
|
832 |
if(rotate)
|
|
833 |
{
|
|
834 |
DEBUG_INFO("Created rotate element");
|
|
835 |
g_object_set(G_OBJECT(rotate), "method", FLIP_NONE, NULL);
|
|
836 |
gst_bin_add(GST_BIN(vpp), rotate);
|
|
837 |
}
|
|
838 |
|
|
839 |
/* create video mirror */
|
|
840 |
mirror = gst_element_factory_make( "videoflip", "pp_mirror");
|
|
841 |
if(mirror)
|
|
842 |
{
|
|
843 |
DEBUG_INFO("Created mirror element");
|
|
844 |
g_object_set(G_OBJECT(mirror), "method", FLIP_NONE, NULL);
|
|
845 |
gst_bin_add(GST_BIN(vpp), mirror);
|
|
846 |
}
|
|
847 |
|
|
848 |
/* create video box */
|
|
849 |
box = gst_element_factory_make( "videobox", "pp_box");
|
|
850 |
if(box)
|
|
851 |
{
|
|
852 |
DEBUG_INFO("Created videobox element");
|
|
853 |
gst_bin_add(GST_BIN(vpp), box);
|
|
854 |
}
|
|
855 |
|
|
856 |
/* create video balance */
|
|
857 |
balance = gst_element_factory_make( "videobalance", "pp_balance");
|
|
858 |
if(balance)
|
|
859 |
{
|
|
860 |
DEBUG_INFO("Created balance element");
|
|
861 |
gst_bin_add(GST_BIN(vpp), balance);
|
|
862 |
}
|
|
863 |
|
|
864 |
/* create video gamma */
|
|
865 |
gamma = gst_element_factory_make( "gamma", "pp_gamma");
|
|
866 |
if(gamma)
|
|
867 |
{
|
|
868 |
DEBUG_INFO("Created gamma element");
|
|
869 |
gst_bin_add(GST_BIN(vpp), gamma);
|
|
870 |
}
|
|
871 |
|
|
872 |
/* Create videoscale element to scale postprocessed output to correct size */
|
|
873 |
scale = gst_element_factory_make("videoscale", "pp_scale");
|
|
874 |
if ( scale )
|
|
875 |
{
|
|
876 |
DEBUG_INFO("Created videoscale element");
|
|
877 |
gst_bin_add(GST_BIN(vpp), scale);
|
|
878 |
}
|
|
879 |
scale2 = gst_element_factory_make("videoscale", "pp_scale2");
|
|
880 |
if ( scale2 )
|
|
881 |
{
|
|
882 |
GstPad *pad = NULL;
|
|
883 |
GstCaps *caps = NULL;
|
|
884 |
DEBUG_INFO("Created videoscale element");
|
|
885 |
pad = gst_element_get_static_pad(scale2,"src");
|
|
886 |
caps = gst_caps_new_simple("video/x-raw-yuv",
|
|
887 |
"width", G_TYPE_INT,0,
|
|
888 |
"height", G_TYPE_INT,0,
|
|
889 |
NULL);
|
|
890 |
gst_pad_set_caps(pad, caps);
|
|
891 |
gst_bin_add(GST_BIN(vpp), scale2);
|
|
892 |
}
|
|
893 |
|
|
894 |
/* create video queue */
|
|
895 |
queue = gst_element_factory_make( "queue", "vpp_queue");
|
|
896 |
if(queue)
|
|
897 |
{
|
|
898 |
DEBUG_INFO("Created queue element");
|
|
899 |
gst_bin_add(GST_BIN(vpp), queue);
|
|
900 |
#ifdef USE_NGA_SURFACES
|
|
901 |
/* make this bin link point*/
|
|
902 |
ghostsink = gst_element_get_static_pad(queue,"sink");
|
|
903 |
if(ghostsink)
|
|
904 |
{
|
|
905 |
gst_element_add_pad(vpp, gst_ghost_pad_new("videopp_src",ghostsink));
|
|
906 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
907 |
}
|
|
908 |
#endif /*USE_NGA_SURFACES*/
|
|
909 |
}
|
|
910 |
|
|
911 |
|
|
912 |
/* Crete ffmpegcolorspace to convert stream to correct format */
|
|
913 |
col2 = gst_element_factory_make( "ffmpegcolorspace", "pp_colsp2");
|
|
914 |
if(col2)
|
|
915 |
{
|
|
916 |
DEBUG_INFO("Created ffmpegcolorspace element");
|
|
917 |
gst_bin_add(GST_BIN(vpp), col2);
|
|
918 |
/* make this bin link point*/
|
|
919 |
ghostsrc = gst_element_get_static_pad(col2,"src");
|
|
920 |
if(ghostsrc)
|
|
921 |
{
|
|
922 |
gst_element_add_pad(vpp, gst_ghost_pad_new("videopp_src",ghostsrc));
|
|
923 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
924 |
}
|
|
925 |
}
|
|
926 |
|
|
927 |
#ifdef USE_NGA_SURFACES
|
|
928 |
//shyward
|
|
929 |
/* create identity element */
|
|
930 |
identity = gst_element_factory_make( "identity", "identity" );
|
|
931 |
if(identity)
|
|
932 |
{
|
|
933 |
DEBUG_INFO("Created identity element");
|
|
934 |
gst_bin_add(GST_BIN(vpp), identity);
|
|
935 |
/* make this bin link point*/
|
|
936 |
ghostsrc = gst_element_get_static_pad(identity,"src");
|
|
937 |
if(ghostsrc)
|
|
938 |
{
|
|
939 |
gst_element_add_pad(vpp, gst_ghost_pad_new("videopp_sink",ghostsrc));
|
|
940 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
941 |
}
|
|
942 |
}
|
|
943 |
if( !(gst_element_link_many(queue,identity,NULL)) )
|
|
944 |
#else
|
|
945 |
//shyward - thins code assumes all the elements will have been created, which is not true
|
|
946 |
if( !(gst_element_link_many(col1,
|
|
947 |
scale,
|
|
948 |
crop,
|
|
949 |
rotate,
|
|
950 |
mirror,
|
|
951 |
box,
|
|
952 |
balance,
|
|
953 |
gamma,
|
|
954 |
queue,
|
|
955 |
scale2,
|
|
956 |
#ifdef USE_NGA_SURFACES
|
|
957 |
identity,
|
|
958 |
#endif /*USE_NGA_SURFACES*/
|
|
959 |
col2,
|
|
960 |
NULL)
|
|
961 |
) )
|
|
962 |
#endif /*USE_NGA_SURFACES*/
|
|
963 |
{
|
|
964 |
DEBUG_ERR("Could not link videopp elements!!");
|
|
965 |
gst_object_unref(vpp);
|
|
966 |
vpp = NULL;
|
|
967 |
}
|
|
968 |
}
|
|
969 |
DEBUG_API("<-XAAdaptationGst_CreateVideoPP");
|
|
970 |
return vpp;
|
|
971 |
}
|
|
972 |
|
|
973 |
/**
|
|
974 |
* GstElement* XAAdaptationGst_CreateFixedSizeRecordVideoPP( )
|
|
975 |
* @return GstElement* - return newly created gst pipeline element
|
|
976 |
* Description: Create video processing pipeline with fixed output size to TEST_VIDEO_WIDTH x TEST_VIDEO_HEIGHT
|
|
977 |
* experimental implementation for changing recorder output size
|
|
978 |
*/
|
|
979 |
GstElement* XAAdaptationGst_CreateFixedSizeVideoPP( )
|
|
980 |
{
|
|
981 |
GstElement *vpp;
|
|
982 |
DEBUG_API("->XAAdaptationGst_CreateFixedSizeVideoPP");
|
|
983 |
vpp = gst_pipeline_new("videopp");
|
|
984 |
if( vpp )
|
|
985 |
{
|
|
986 |
GstPad *ghostsink, *ghostsrc;
|
|
987 |
GstElement *col1,
|
|
988 |
*col2,
|
|
989 |
*rotate,
|
|
990 |
*mirror,
|
|
991 |
*box,
|
|
992 |
*crop,
|
|
993 |
*gamma,
|
|
994 |
*balance,
|
|
995 |
*scale,
|
|
996 |
*scale2,
|
|
997 |
*filter,
|
|
998 |
*queue;
|
|
999 |
|
|
1000 |
|
|
1001 |
/* Crete ffmpegcolorspace to convert stream to correct format */
|
|
1002 |
col1 = gst_element_factory_make( "ffmpegcolorspace", "pp_colsp1");
|
|
1003 |
if(col1)
|
|
1004 |
{
|
|
1005 |
DEBUG_INFO("Created ffmpegcolorspace element");
|
|
1006 |
gst_bin_add(GST_BIN(vpp), col1);
|
|
1007 |
/* make this bin link point*/
|
|
1008 |
ghostsink = gst_element_get_static_pad(col1,"sink");
|
|
1009 |
if(ghostsink)
|
|
1010 |
{
|
|
1011 |
gst_element_add_pad(vpp, gst_ghost_pad_new("videopp_sink",ghostsink));
|
|
1012 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
1013 |
}
|
|
1014 |
}
|
|
1015 |
|
|
1016 |
/* create video crop, this will be sink for videoPP pipeline */
|
|
1017 |
crop = gst_element_factory_make( "videocrop", "pp_crop");
|
|
1018 |
if(crop)
|
|
1019 |
{
|
|
1020 |
DEBUG_INFO("Created crop element");
|
|
1021 |
gst_bin_add(GST_BIN(vpp), crop);
|
|
1022 |
}
|
|
1023 |
|
|
1024 |
/* create video rotate */
|
|
1025 |
rotate = gst_element_factory_make( "videoflip", "pp_rotate");
|
|
1026 |
if(rotate)
|
|
1027 |
{
|
|
1028 |
DEBUG_INFO("Created rotate element");
|
|
1029 |
g_object_set(G_OBJECT(rotate), "method", FLIP_NONE, NULL);
|
|
1030 |
gst_bin_add(GST_BIN(vpp), rotate);
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
/* create video mirror */
|
|
1034 |
mirror = gst_element_factory_make( "videoflip", "pp_mirror");
|
|
1035 |
if(mirror)
|
|
1036 |
{
|
|
1037 |
DEBUG_INFO("Created mirror element");
|
|
1038 |
g_object_set(G_OBJECT(mirror), "method", FLIP_NONE, NULL);
|
|
1039 |
gst_bin_add(GST_BIN(vpp), mirror);
|
|
1040 |
}
|
|
1041 |
|
|
1042 |
/* create video box */
|
|
1043 |
box = gst_element_factory_make( "videobox", "pp_box");
|
|
1044 |
if(box)
|
|
1045 |
{
|
|
1046 |
DEBUG_INFO("Created videobox element");
|
|
1047 |
gst_bin_add(GST_BIN(vpp), box);
|
|
1048 |
}
|
|
1049 |
|
|
1050 |
/* create video balance */
|
|
1051 |
balance = gst_element_factory_make( "videobalance", "pp_balance");
|
|
1052 |
if(balance)
|
|
1053 |
{
|
|
1054 |
DEBUG_INFO("Created balance element");
|
|
1055 |
gst_bin_add(GST_BIN(vpp), balance);
|
|
1056 |
}
|
|
1057 |
|
|
1058 |
/* create video gamma */
|
|
1059 |
gamma = gst_element_factory_make( "gamma", "pp_gamma");
|
|
1060 |
if(gamma)
|
|
1061 |
{
|
|
1062 |
DEBUG_INFO("Created gamma element");
|
|
1063 |
gst_bin_add(GST_BIN(vpp), gamma);
|
|
1064 |
}
|
|
1065 |
|
|
1066 |
/* Create videoscale element to scale postprocessed output to correct size */
|
|
1067 |
scale = gst_element_factory_make("videoscale", "pp_scale");
|
|
1068 |
if ( scale )
|
|
1069 |
{
|
|
1070 |
DEBUG_INFO("Created videoscale element");
|
|
1071 |
gst_bin_add(GST_BIN(vpp), scale);
|
|
1072 |
}
|
|
1073 |
scale2 = gst_element_factory_make("videoscale", "pp_scale2");
|
|
1074 |
if ( scale2 )
|
|
1075 |
{
|
|
1076 |
GstPad *pad = NULL;
|
|
1077 |
GstCaps *caps = NULL;
|
|
1078 |
DEBUG_INFO("Created videoscale element");
|
|
1079 |
pad = gst_element_get_static_pad(scale2,"src");
|
|
1080 |
caps = gst_caps_new_simple("video/x-raw-yuv",
|
|
1081 |
"width", G_TYPE_INT,0,
|
|
1082 |
"height", G_TYPE_INT,0,
|
|
1083 |
NULL);
|
|
1084 |
gst_pad_set_caps(pad, caps);
|
|
1085 |
gst_bin_add(GST_BIN(vpp), scale2);
|
|
1086 |
}
|
|
1087 |
|
|
1088 |
/* create capsfilter for fixed video size */
|
|
1089 |
filter = gst_element_factory_make("capsfilter", "pp_filter");
|
|
1090 |
if ( filter )
|
|
1091 |
{
|
|
1092 |
|
|
1093 |
g_object_set( G_OBJECT(filter), "caps",
|
|
1094 |
gst_caps_new_simple("video/x-raw-yuv",
|
|
1095 |
"width", G_TYPE_INT, TEST_VIDEO_WIDTH,
|
|
1096 |
"height", G_TYPE_INT, TEST_VIDEO_HEIGHT, NULL)
|
|
1097 |
,NULL );
|
|
1098 |
gst_bin_add(GST_BIN(vpp), filter);
|
|
1099 |
}
|
|
1100 |
|
|
1101 |
/* create video queue */
|
|
1102 |
queue = gst_element_factory_make( "queue", "vpp_queue");
|
|
1103 |
if(queue)
|
|
1104 |
{
|
|
1105 |
gst_bin_add(GST_BIN(vpp), queue);
|
|
1106 |
}
|
|
1107 |
|
|
1108 |
|
|
1109 |
/* Crete ffmpegcolorspace to convert stream to correct format */
|
|
1110 |
col2 = gst_element_factory_make( "ffmpegcolorspace", "pp_colsp2");
|
|
1111 |
if(col2)
|
|
1112 |
{
|
|
1113 |
DEBUG_INFO("Created ffmpegcolorspace element");
|
|
1114 |
gst_bin_add(GST_BIN(vpp), col2);
|
|
1115 |
/* make this bin link point*/
|
|
1116 |
ghostsrc = gst_element_get_static_pad(col2,"src");
|
|
1117 |
if(ghostsrc)
|
|
1118 |
{
|
|
1119 |
gst_element_add_pad(vpp, gst_ghost_pad_new("videopp_src",ghostsrc));
|
|
1120 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1121 |
}
|
|
1122 |
}
|
|
1123 |
if( !(gst_element_link_many(col1,
|
|
1124 |
scale,
|
|
1125 |
crop,
|
|
1126 |
rotate,
|
|
1127 |
mirror,
|
|
1128 |
box,
|
|
1129 |
balance,
|
|
1130 |
gamma,
|
|
1131 |
queue,
|
|
1132 |
scale2,
|
|
1133 |
filter,
|
|
1134 |
col2,
|
|
1135 |
NULL)
|
|
1136 |
) )
|
|
1137 |
{
|
|
1138 |
DEBUG_ERR("Could not link videopp elements!!");
|
|
1139 |
gst_object_unref(vpp);
|
|
1140 |
vpp = NULL;
|
|
1141 |
}
|
|
1142 |
}
|
|
1143 |
DEBUG_API("<-XAAdaptationGst_CreateFixedSizeVideoPP");
|
|
1144 |
return vpp;
|
|
1145 |
}
|
|
1146 |
|
|
1147 |
|
|
1148 |
|
|
1149 |
/**
|
|
1150 |
* GstElement* XAAdaptationGst_CreateVideoPPBlackScr( )
|
|
1151 |
* @return GstElement* - return newly created gst pipeline element
|
|
1152 |
* Description: Create video processing pipeline for black screen
|
|
1153 |
*/
|
|
1154 |
GstElement* XAAdaptationGst_CreateVideoPPBlackScr( )
|
|
1155 |
{
|
|
1156 |
GstElement *vppBScr;
|
|
1157 |
DEBUG_API("->XAAdaptationGst_CreateVideoPPBlackScr");
|
|
1158 |
vppBScr = gst_pipeline_new("videoppBScr");
|
|
1159 |
if( vppBScr )
|
|
1160 |
{
|
|
1161 |
GstPad *ghostsrc=NULL;
|
|
1162 |
GstElement *testVideo=NULL, *scale=NULL;
|
|
1163 |
GstElement *ffmpegcolorspace=NULL;
|
|
1164 |
|
|
1165 |
testVideo = gst_element_factory_make( "videotestsrc", "videotest");
|
|
1166 |
if(testVideo)
|
|
1167 |
{
|
|
1168 |
DEBUG_INFO("Created videotestsrc element");
|
|
1169 |
|
|
1170 |
g_object_set(G_OBJECT(testVideo), "pattern", (gint)2, "num-buffers", (gint)1, NULL);
|
|
1171 |
gst_bin_add(GST_BIN(vppBScr), testVideo);
|
|
1172 |
}
|
|
1173 |
|
|
1174 |
scale = gst_element_factory_make("videoscale", "BSrc_scale");
|
|
1175 |
if(scale)
|
|
1176 |
{
|
|
1177 |
DEBUG_INFO("Created videoscale element");
|
|
1178 |
gst_bin_add(GST_BIN(vppBScr), scale);
|
|
1179 |
/* make this bin link point*/
|
|
1180 |
ghostsrc = gst_element_get_static_pad(scale,"src");
|
|
1181 |
if(ghostsrc)
|
|
1182 |
{
|
|
1183 |
gst_element_add_pad(vppBScr, gst_ghost_pad_new("videoppBSrc_src",ghostsrc));
|
|
1184 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1185 |
}
|
|
1186 |
}
|
|
1187 |
ffmpegcolorspace = gst_element_factory_make("ffmpegcolorspace", "BlackScrFfmpeg");
|
|
1188 |
gst_bin_add(GST_BIN(vppBScr), ffmpegcolorspace);
|
|
1189 |
if( !(gst_element_link_many(testVideo, ffmpegcolorspace, scale, NULL)) )
|
|
1190 |
{
|
|
1191 |
DEBUG_ERR("Could not link videoppBSrc elements!!");
|
|
1192 |
gst_object_unref(vppBScr);
|
|
1193 |
vppBScr = NULL;
|
|
1194 |
}
|
|
1195 |
}
|
|
1196 |
DEBUG_API("<-XAAdaptationGst_CreateVideoPPBlackScr");
|
|
1197 |
return vppBScr;
|
|
1198 |
}
|
|
1199 |
|
|
1200 |
/**
|
|
1201 |
* GstElement* XAAdaptationGst_CreateInputSelector( )
|
|
1202 |
* @return GstElement* - return newly created input selector
|
|
1203 |
* Description: Create input selector to processing between black screen and video screen
|
|
1204 |
*/
|
|
1205 |
GstElement* XAAdaptationGst_CreateInputSelector( )
|
|
1206 |
{
|
|
1207 |
GstElement *inputSelector;
|
|
1208 |
DEBUG_API("->XAAdaptationGst_CreateInputSelector");
|
|
1209 |
inputSelector = gst_element_factory_make("input-selector", "input-selector");
|
|
1210 |
if( inputSelector )
|
|
1211 |
{
|
|
1212 |
g_object_set(G_OBJECT(inputSelector), "select-all", TRUE, NULL);
|
|
1213 |
}
|
|
1214 |
DEBUG_API("<-XAAdaptationGst_CreateInputSelector");
|
|
1215 |
return inputSelector;
|
|
1216 |
}
|
|
1217 |
|
|
1218 |
/**
|
|
1219 |
* GstElement* XAAdaptationGst_CreateAudioPP( )
|
|
1220 |
* @return GstElement* - return newly created gst pipeline element
|
|
1221 |
* Description: Create video processing pipeline
|
|
1222 |
*/
|
|
1223 |
GstElement* XAAdaptationGst_CreateAudioPP( )
|
|
1224 |
{
|
|
1225 |
GstElement *app;
|
|
1226 |
gboolean ok = TRUE;
|
|
1227 |
DEBUG_API("->XAAdaptationGst_CreateAudioPP");
|
|
1228 |
app = gst_pipeline_new("audiopp");
|
|
1229 |
if( app )
|
|
1230 |
{
|
|
1231 |
GstPad *ghostsink, *ghostsrc;
|
|
1232 |
GstElement *ac,*vol,*eq,*queue,*pan, *ac2;
|
|
1233 |
|
|
1234 |
/* first and last elements should be audioconverts to match sink and encoder formats */
|
|
1235 |
ac = gst_element_factory_make( "audioconvert", "pp_ac");
|
|
1236 |
if (ac)
|
|
1237 |
{
|
|
1238 |
ok = gst_bin_add(GST_BIN(app), ac);
|
|
1239 |
/* make this bin link point*/
|
|
1240 |
if (ok)
|
|
1241 |
{
|
|
1242 |
ghostsink = gst_element_get_static_pad(ac,"sink");
|
|
1243 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("sink",ghostsink));
|
|
1244 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
1245 |
}
|
|
1246 |
}
|
|
1247 |
ac2 = gst_element_factory_make( "audioconvert", "pp_ac2");
|
|
1248 |
if (ac2 && ok)
|
|
1249 |
{
|
|
1250 |
ok = gst_bin_add(GST_BIN(app), ac2);
|
|
1251 |
/* make this bin link point*/
|
|
1252 |
if (ok)
|
|
1253 |
{
|
|
1254 |
ghostsrc = gst_element_get_static_pad(ac2,"src");
|
|
1255 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("src",ghostsrc));
|
|
1256 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1257 |
}
|
|
1258 |
}
|
|
1259 |
|
|
1260 |
vol = gst_element_factory_make( "volume", "pp_vol");
|
|
1261 |
/* create volume controller */
|
|
1262 |
if (vol && ok)
|
|
1263 |
{
|
|
1264 |
ok = gst_bin_add(GST_BIN(app), vol);
|
|
1265 |
g_object_set( G_OBJECT(vol), "volume", (gdouble)1, NULL );
|
|
1266 |
}
|
|
1267 |
/* create 10-band equalizer */
|
|
1268 |
eq = gst_element_factory_make( "equalizer-10bands", "pp_equ");
|
|
1269 |
if (eq && ok)
|
|
1270 |
{
|
|
1271 |
ok = gst_bin_add(GST_BIN(app), eq);
|
|
1272 |
}
|
|
1273 |
/* create audio queue */
|
|
1274 |
queue = gst_element_factory_make( "queue", "app_queue");
|
|
1275 |
if(queue && ok)
|
|
1276 |
{
|
|
1277 |
ok = gst_bin_add(GST_BIN(app), queue);
|
|
1278 |
g_object_set (G_OBJECT (queue), "max-size-buffers", 2, NULL);
|
|
1279 |
}
|
|
1280 |
/* create audio pan effect */
|
|
1281 |
pan = gst_element_factory_make( "audiopanorama", "pp_pan");
|
|
1282 |
if (pan && ok)
|
|
1283 |
{
|
|
1284 |
ok = gst_bin_add(GST_BIN(app), pan);
|
|
1285 |
}
|
|
1286 |
|
|
1287 |
if (ac && ok)
|
|
1288 |
{
|
|
1289 |
if (queue)
|
|
1290 |
{
|
|
1291 |
ok = gst_element_link(ac, queue);
|
|
1292 |
}
|
|
1293 |
else if (vol)
|
|
1294 |
{
|
|
1295 |
ok = gst_element_link(ac, vol);
|
|
1296 |
}
|
|
1297 |
else if (pan)
|
|
1298 |
{
|
|
1299 |
ok = gst_element_link(ac, pan);
|
|
1300 |
}
|
|
1301 |
else if (eq)
|
|
1302 |
{
|
|
1303 |
ok = gst_element_link(ac, eq);
|
|
1304 |
}
|
|
1305 |
else if (ac2)
|
|
1306 |
{
|
|
1307 |
ok = gst_element_link(ac, ac2);
|
|
1308 |
}
|
|
1309 |
}
|
|
1310 |
if (queue && ok)
|
|
1311 |
{
|
|
1312 |
if (vol)
|
|
1313 |
{
|
|
1314 |
ok = gst_element_link(queue, vol);
|
|
1315 |
}
|
|
1316 |
else if (pan)
|
|
1317 |
{
|
|
1318 |
ok = gst_element_link(queue, pan);
|
|
1319 |
}
|
|
1320 |
else if (eq)
|
|
1321 |
{
|
|
1322 |
ok = gst_element_link(queue, eq);
|
|
1323 |
}
|
|
1324 |
else if (ac2)
|
|
1325 |
{
|
|
1326 |
ok = gst_element_link(queue, ac2);
|
|
1327 |
}
|
|
1328 |
}
|
|
1329 |
if (vol && ok)
|
|
1330 |
{
|
|
1331 |
if (pan)
|
|
1332 |
{
|
|
1333 |
ok = gst_element_link(vol, pan);
|
|
1334 |
}
|
|
1335 |
else if (eq)
|
|
1336 |
{
|
|
1337 |
ok = gst_element_link(vol, eq);
|
|
1338 |
}
|
|
1339 |
else if (ac2)
|
|
1340 |
{
|
|
1341 |
ok = gst_element_link(vol, ac2);
|
|
1342 |
}
|
|
1343 |
}
|
|
1344 |
if (pan && ok)
|
|
1345 |
{
|
|
1346 |
if (eq)
|
|
1347 |
{
|
|
1348 |
ok = gst_element_link(pan, eq);
|
|
1349 |
}
|
|
1350 |
else if (ac2)
|
|
1351 |
{
|
|
1352 |
ok = gst_element_link(pan, ac2);
|
|
1353 |
}
|
|
1354 |
}
|
|
1355 |
if (eq && ok)
|
|
1356 |
{
|
|
1357 |
if (ac2)
|
|
1358 |
{
|
|
1359 |
ok = gst_element_link(eq, ac2);
|
|
1360 |
}
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
if (ac)
|
|
1364 |
{
|
|
1365 |
// ghost sink above
|
|
1366 |
}
|
|
1367 |
else if (queue && ok)
|
|
1368 |
{
|
|
1369 |
/* make this bin link point*/
|
|
1370 |
ghostsink = gst_element_get_static_pad(queue,"sink");
|
|
1371 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("sink",ghostsink));
|
|
1372 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
1373 |
}
|
|
1374 |
else if (vol && ok)
|
|
1375 |
{
|
|
1376 |
/* make this bin link point*/
|
|
1377 |
ghostsink = gst_element_get_static_pad(vol,"sink");
|
|
1378 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("sink",ghostsink));
|
|
1379 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
1380 |
}
|
|
1381 |
else if (pan && ok)
|
|
1382 |
{
|
|
1383 |
/* make this bin link point*/
|
|
1384 |
ghostsink = gst_element_get_static_pad(pan,"sink");
|
|
1385 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("sink",ghostsink));
|
|
1386 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
1387 |
}
|
|
1388 |
else if (eq && ok)
|
|
1389 |
{
|
|
1390 |
/* make this bin link point*/
|
|
1391 |
ghostsink = gst_element_get_static_pad(eq,"sink");
|
|
1392 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("sink",ghostsink));
|
|
1393 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
1394 |
}
|
|
1395 |
else if (ac2 && ok)
|
|
1396 |
{
|
|
1397 |
/* make this bin link point*/
|
|
1398 |
ghostsink = gst_element_get_static_pad(ac2,"sink");
|
|
1399 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("sink",ghostsink));
|
|
1400 |
gst_object_unref(GST_OBJECT(ghostsink));
|
|
1401 |
}
|
|
1402 |
|
|
1403 |
if (ac2)
|
|
1404 |
{
|
|
1405 |
// ghost src above
|
|
1406 |
}
|
|
1407 |
else if (eq && ok)
|
|
1408 |
{
|
|
1409 |
/* make this bin link point*/
|
|
1410 |
ghostsrc = gst_element_get_static_pad(eq,"src");
|
|
1411 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("src",ghostsrc));
|
|
1412 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1413 |
}
|
|
1414 |
else if (pan && ok)
|
|
1415 |
{
|
|
1416 |
/* make this bin link point*/
|
|
1417 |
ghostsrc = gst_element_get_static_pad(pan,"src");
|
|
1418 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("src",ghostsrc));
|
|
1419 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1420 |
}
|
|
1421 |
else if (vol && ok)
|
|
1422 |
{
|
|
1423 |
/* make this bin link point*/
|
|
1424 |
ghostsrc = gst_element_get_static_pad(vol,"src");
|
|
1425 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("src",ghostsrc));
|
|
1426 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1427 |
}
|
|
1428 |
else if (queue && ok)
|
|
1429 |
{
|
|
1430 |
/* make this bin link point*/
|
|
1431 |
ghostsrc = gst_element_get_static_pad(queue,"src");
|
|
1432 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("src",ghostsrc));
|
|
1433 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1434 |
}
|
|
1435 |
else if (ac && ok)
|
|
1436 |
{
|
|
1437 |
/* make this bin link point*/
|
|
1438 |
ghostsrc = gst_element_get_static_pad(ac,"src");
|
|
1439 |
ok = gst_element_add_pad(app, gst_ghost_pad_new("src",ghostsrc));
|
|
1440 |
gst_object_unref(GST_OBJECT(ghostsrc));
|
|
1441 |
}
|
|
1442 |
|
|
1443 |
// if( !(gst_element_link_many(ac, queue, vol, ac2, NULL)) )
|
|
1444 |
// if( !(gst_element_link_many(ac, queue, vol, pan, eq, ac2, NULL)) )
|
|
1445 |
if (!ok)
|
|
1446 |
{
|
|
1447 |
DEBUG_ERR("Could not link audiopp elements!!");
|
|
1448 |
gst_object_unref(app);
|
|
1449 |
app = NULL;
|
|
1450 |
}
|
|
1451 |
}
|
|
1452 |
|
|
1453 |
DEBUG_API("<-XAAdaptationGst_CreateAudioPP");
|
|
1454 |
return app;
|
|
1455 |
}
|
|
1456 |
|
|
1457 |
/* called when pad is actually blocking/ gets unblocked*/
|
|
1458 |
void XAAdaptationGst_PadBlockCb(GstPad *pad, gboolean blocked, gpointer user_data)
|
|
1459 |
{
|
|
1460 |
DEBUG_API_A2("->XAAdaptationGst_PadBlockCb pad \"%s\" of \"%s\" ",
|
|
1461 |
GST_OBJECT_NAME(pad),
|
|
1462 |
GST_OBJECT_NAME(gst_pad_get_parent_element(pad)) );
|
|
1463 |
DEBUG_API_A1("<-XAAdaptationGst_PadBlockCb blocked:%d",blocked);
|
|
1464 |
}
|
|
1465 |
|
|
1466 |
/* utility to set same fields for all media types in caps */
|
|
1467 |
void XAAdaptationGst_SetAllCaps (GstCaps * caps, char *field, ...)
|
|
1468 |
{
|
|
1469 |
GstStructure *structure;
|
|
1470 |
va_list var_args;
|
|
1471 |
int i;
|
|
1472 |
|
|
1473 |
for (i = 0; i < gst_caps_get_size (caps); i++)
|
|
1474 |
{
|
|
1475 |
structure = gst_caps_get_structure (caps, i);
|
|
1476 |
va_start (var_args, field);
|
|
1477 |
gst_structure_set_valist (structure, field, var_args);
|
|
1478 |
va_end (var_args);
|
|
1479 |
}
|
|
1480 |
}
|
|
1481 |
|
|
1482 |
|