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