209 pSelf->audioEncSettings.levelSetting = 0; |
209 pSelf->audioEncSettings.levelSetting = 0; |
210 pSelf->audioEncSettings.channelMode = 0; |
210 pSelf->audioEncSettings.channelMode = 0; |
211 pSelf->audioEncSettings.streamFormat = 0; |
211 pSelf->audioEncSettings.streamFormat = 0; |
212 pSelf->audioEncSettings.encodeOptions = 0; |
212 pSelf->audioEncSettings.encodeOptions = 0; |
213 pSelf->audioEncSettings.blockAlignment = 0; |
213 pSelf->audioEncSettings.blockAlignment = 0; |
214 } |
214 } |
215 } |
215 } |
216 |
216 |
217 DEBUG_API("<-XAMediaRecorderAdapt_Create"); |
217 DEBUG_API("<-XAMediaRecorderAdapt_Create"); |
218 return (XAAdaptationBaseCtx*) &pSelf->baseObj; |
218 return (XAAdaptationBaseCtx*) &pSelf->baseObj; |
219 } |
219 } |
220 |
220 |
221 /* |
221 /* |
222 * XAresult XAMediaRecorderAdapt_PostInit() |
222 * XAresult XAMediaRecorderAdapt_PostInit() |
223 * 2nd phase initialization of Media Recorder Adaptation Context |
223 * 2nd phase initialization of Media Recorder Adaptation Context |
224 * @param XAAdaptationGstCtx* ctx - pointer to Media Recorder adaptation context |
224 * @param XAAdaptationGstCtx* ctx - pointer to Media Recorder adaptation context |
225 * @return XAresult - Success value |
225 * @return XAresult - Success value |
226 */ |
226 */ |
227 XAresult XAMediaRecorderAdapt_PostInit(XAAdaptationGstCtx* bCtx) |
227 XAresult XAMediaRecorderAdapt_PostInit(XAAdaptationGstCtx* bCtx) |
228 { |
228 { |
229 GstStateChangeReturn gret; |
229 GstStateChangeReturn gret; |
230 |
230 |
231 XAresult ret = XA_RESULT_SUCCESS; |
231 XAresult ret = XA_RESULT_SUCCESS; |
232 XAMediaRecorderAdaptationCtx* ctx = NULL; |
232 XAMediaRecorderAdaptationCtx* ctx = NULL; |
233 DEBUG_API("->XAMediaRecorderAdapt_PostInit"); |
233 DEBUG_API("->XAMediaRecorderAdapt_PostInit"); |
234 if (bCtx == NULL || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
234 if (bCtx == NULL || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
235 { |
235 { |
236 DEBUG_ERR("Invalid parameter!!"); |
236 DEBUG_ERR("Invalid parameter!!"); |
237 DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); |
237 DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); |
238 return XA_RESULT_PARAMETER_INVALID; |
238 return XA_RESULT_PARAMETER_INVALID; |
239 } |
239 } |
240 ctx = (XAMediaRecorderAdaptationCtx*) bCtx; |
240 ctx = (XAMediaRecorderAdaptationCtx*) bCtx; |
241 |
241 |
242 ret = XAAdaptationGst_PostInit(bCtx); |
242 ret = XAAdaptationGst_PostInit(bCtx); |
243 if (ret != XA_RESULT_SUCCESS) |
243 if (ret != XA_RESULT_SUCCESS) |
244 { |
244 { |
245 DEBUG_ERR("Gst context postinit failed!!"); |
245 DEBUG_ERR("Gst context postinit failed!!"); |
246 return ret; |
246 return ret; |
247 } |
247 } |
248 |
248 |
249 /* top level bin for media recorder */ |
249 /* top level bin for media recorder */ |
250 bCtx->bin = gst_pipeline_new("media_recorder"); |
250 bCtx->bin = gst_pipeline_new("media_recorder"); |
251 |
251 |
252 /* Create Gst bus listener. */ |
252 /* Create Gst bus listener. */ |
253 ret = XAAdaptationGst_InitGstListener(bCtx); |
253 ret = XAAdaptationGst_InitGstListener(bCtx); |
254 if (ret != XA_RESULT_SUCCESS) |
254 if (ret != XA_RESULT_SUCCESS) |
255 { |
255 { |
256 DEBUG_ERR("Bus listener creation failed!!"); |
256 DEBUG_ERR("Bus listener creation failed!!"); |
257 return ret; |
257 return ret; |
258 } |
258 } |
259 /* Add Media Recorder specific handler */ |
259 /* Add Media Recorder specific handler */ |
260 if (bCtx->bus) |
260 if (bCtx->bus) |
261 { |
261 { |
262 bCtx->busCb = XAMediaRecorderAdapt_GstBusCb; |
262 bCtx->busCb = XAMediaRecorderAdapt_GstBusCb; |
263 gst_bus_add_signal_watch(bCtx->bus); |
263 gst_bus_add_signal_watch(bCtx->bus); |
264 g_signal_connect(bCtx->bus, "message::eos", G_CALLBACK(bCtx->busCb), ctx ); |
264 g_signal_connect(bCtx->bus, "message::eos", G_CALLBACK(bCtx->busCb), ctx ); |
265 g_signal_connect(bCtx->bus, "message::error", G_CALLBACK(bCtx->busCb), ctx ); |
265 g_signal_connect(bCtx->bus, "message::error", G_CALLBACK(bCtx->busCb), ctx ); |
266 g_signal_connect(bCtx->bus, "message::warning", G_CALLBACK(bCtx->busCb), ctx ); |
266 g_signal_connect(bCtx->bus, "message::warning", G_CALLBACK(bCtx->busCb), ctx ); |
267 g_signal_connect(bCtx->bus, "message::state-changed", G_CALLBACK(bCtx->busCb), ctx ); |
267 g_signal_connect(bCtx->bus, "message::state-changed", G_CALLBACK(bCtx->busCb), ctx ); |
268 g_signal_connect(bCtx->bus, "message::segment-done", G_CALLBACK(bCtx->busCb), ctx ); |
268 g_signal_connect(bCtx->bus, "message::segment-done", G_CALLBACK(bCtx->busCb), ctx ); |
269 g_signal_connect(bCtx->bus, "message::async-done", G_CALLBACK(bCtx->busCb), ctx ); |
269 g_signal_connect(bCtx->bus, "message::async-done", G_CALLBACK(bCtx->busCb), ctx ); |
270 } |
270 } |
271 else |
271 else |
272 { |
272 { |
273 DEBUG_ERR("Failed to create message bus"); |
273 DEBUG_ERR("Failed to create message bus"); |
274 return XA_RESULT_INTERNAL_ERROR; |
274 return XA_RESULT_INTERNAL_ERROR; |
275 } |
275 } |
276 |
276 |
277 XAMetadataAdapt_PreInit(bCtx); |
277 XAMetadataAdapt_PreInit(bCtx); |
278 |
278 |
279 /* create pipeline */ |
279 /* create pipeline */ |
280 ret = XAMediaRecorderAdapt_CreatePipeline(ctx); |
280 ret = XAMediaRecorderAdapt_CreatePipeline(ctx); |
281 if (ret != XA_RESULT_SUCCESS) |
281 if (ret != XA_RESULT_SUCCESS) |
282 { |
282 { |
283 DEBUG_ERR("Failed to create recorder pipeline"); |
283 DEBUG_ERR("Failed to create recorder pipeline"); |
284 return XA_RESULT_INTERNAL_ERROR; |
284 return XA_RESULT_INTERNAL_ERROR; |
285 } |
285 } |
286 |
286 |
287 #ifdef XA_IMPL_MEASURE_GST_DELAY |
287 #ifdef XA_IMPL_MEASURE_GST_DELAY |
288 bCtx->startTime = clock(); |
288 bCtx->startTime = clock(); |
289 #endif /* XA_IMPL_MEASURE_GST_DELAY */ |
289 #endif /* XA_IMPL_MEASURE_GST_DELAY */ |
290 /* roll up bin */ |
290 /* roll up bin */ |
291 bCtx->binWantedState = GST_STATE_PAUSED; |
291 bCtx->binWantedState = GST_STATE_PAUSED; |
292 XAAdaptationGst_PrepareAsyncWait(bCtx); |
292 XAAdaptationGst_PrepareAsyncWait(bCtx); |
293 gret = gst_element_set_state(GST_ELEMENT(bCtx->bin), bCtx->binWantedState); |
293 gret = gst_element_set_state(GST_ELEMENT(bCtx->bin), bCtx->binWantedState); |
294 if (gret == GST_STATE_CHANGE_ASYNC) |
294 if (gret == GST_STATE_CHANGE_ASYNC) |
295 { |
295 { |
296 DEBUG_INFO("Wait for preroll"); |
296 DEBUG_INFO("Wait for preroll"); |
297 XAAdaptationGst_StartAsyncWait(bCtx);DEBUG_INFO("Preroll ready"); |
297 XAAdaptationGst_StartAsyncWait(bCtx);DEBUG_INFO("Preroll ready"); |
298 } |
298 } |
299 else if (gret == GST_STATE_CHANGE_FAILURE) |
299 else if (gret == GST_STATE_CHANGE_FAILURE) |
300 { |
300 { |
301 DEBUG_ERR("Preroll FAILED"); |
301 DEBUG_ERR("Preroll FAILED"); |
302 /*ret = XA_RESULT_INTERNAL_ERROR;*/ |
302 /*ret = XA_RESULT_INTERNAL_ERROR;*/ |
303 } |
303 } |
304 #ifdef XA_IMPL_MEASURE_GST_DELAY |
304 #ifdef XA_IMPL_MEASURE_GST_DELAY |
305 bCtx->endTime = clock(); |
305 bCtx->endTime = clock(); |
306 double diff = bCtx->endTime - bCtx->startTime; |
306 double diff = bCtx->endTime - bCtx->startTime; |
307 diff = diff / CLOCKS_PER_SEC; |
307 diff = diff / CLOCKS_PER_SEC; |
308 DEBUG_API_A1( "Starting up bin took %.4lf secs",diff); |
308 DEBUG_API_A1( "Starting up bin took %.4lf secs",diff); |
311 |
311 |
312 bCtx->waitingasyncop = XA_BOOLEAN_FALSE; |
312 bCtx->waitingasyncop = XA_BOOLEAN_FALSE; |
313 |
313 |
314 DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); |
314 DEBUG_API("<-XAMediaRecorderAdapt_PostInit"); |
315 return ret; |
315 return ret; |
316 } |
316 } |
317 |
317 |
318 /* |
318 /* |
319 * void XAMediaRecorderAdapt_Destroy( XAAdaptationGstCtx* bCtx ) |
319 * void XAMediaRecorderAdapt_Destroy( XAAdaptationGstCtx* bCtx ) |
320 * Destroys Media Recorder Adaptation Context |
320 * Destroys Media Recorder Adaptation Context |
321 * @param ctx - Media Recorder Adaptation context to be destroyed |
321 * @param ctx - Media Recorder Adaptation context to be destroyed |
322 */ |
322 */ |
323 void XAMediaRecorderAdapt_Destroy(XAAdaptationGstCtx* bCtx) |
323 void XAMediaRecorderAdapt_Destroy(XAAdaptationGstCtx* bCtx) |
324 { |
324 { |
325 XAMediaRecorderAdaptationCtx* ctx = NULL; |
325 XAMediaRecorderAdaptationCtx* ctx = NULL; |
326 char* fname = NULL; |
326 char* fname = NULL; |
327 DEBUG_API("->XAMediaRecorderAdapt_Destroy"); |
327 DEBUG_API("->XAMediaRecorderAdapt_Destroy"); |
328 |
328 |
329 if (bCtx == NULL || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
329 if (bCtx == NULL || bCtx->baseObj.ctxId != XAMediaRecorderAdaptation) |
330 { |
330 { |
331 DEBUG_ERR("Invalid parameter!!"); |
331 DEBUG_ERR("Invalid parameter!!"); |
332 DEBUG_API("<-XAMediaRecorderAdapt_Destroy"); |
332 DEBUG_API("<-XAMediaRecorderAdapt_Destroy"); |
333 return; |
333 return; |
334 } |
334 } |
335 ctx = (XAMediaRecorderAdaptationCtx*) bCtx; |
335 ctx = (XAMediaRecorderAdaptationCtx*) bCtx; |
336 |
336 |
337 if (ctx->isRecord == XA_BOOLEAN_FALSE) |
337 if (ctx->isRecord == XA_BOOLEAN_FALSE) |
338 { |
338 { |
339 DEBUG_INFO("Removing unnecessary file."); |
339 DEBUG_INFO("Removing unnecessary file."); |
340 |
340 if (ctx->xaSink && *((XAuint32*) (ctx->xaSink->pLocator)) == XA_DATALOCATOR_URI) |
341 if (ctx->xaSink && *((XAuint32*) (ctx->xaSink->pLocator)) |
341 { |
342 == XA_DATALOCATOR_URI) |
342 if (strncmp( (char *)((XADataLocator_URI*)(ctx->xaSink->pLocator))->URI, "file:///", 8) == 0) |
343 { |
343 { |
344 if (strncmp( |
344 fname = (char *) &(((XADataLocator_URI*) (ctx->xaSink->pLocator))->URI[8]); |
345 (char *) ((XADataLocator_URI*) (ctx->xaSink->pLocator))->URI, |
345 } |
346 "file:///", 8) == 0) |
|
347 { |
|
348 fname |
|
349 = (char *) &(((XADataLocator_URI*) (ctx->xaSink->pLocator))->URI[8]); |
|
350 } |
|
351 else |
346 else |
352 { |
347 { |
353 fname |
348 fname = (char *) ((XADataLocator_URI*) (ctx->xaSink->pLocator))->URI; |
354 = (char *) ((XADataLocator_URI*) (ctx->xaSink->pLocator))->URI; |
349 } |
355 } |
|
356 |
|
357 if (remove(fname) != 0) |
350 if (remove(fname) != 0) |
358 { |
351 { |
359 DEBUG_ERR_A1("Cannot remove file %s", fname); |
352 DEBUG_ERR_A1("Cannot remove file %s", fname); |
360 } |
353 } |
361 } |
354 } |
362 } |
355 } |
363 |
356 |
364 if (ctx->isobjvsrc && ctx->videosource) |
357 if (ctx->isobjvsrc && ctx->videosource) |
365 { /* external source, unlink now */ |
358 { /* external source, unlink now */ |
366 gst_element_unlink(ctx->videosource, ctx->codecbin); |
359 gst_element_unlink(ctx->videosource, ctx->codecbin); |
367 GST_OBJECT_FLAG_SET(GST_OBJECT(ctx->videosource),GST_OBJECT_FLOATING); |
360 GST_OBJECT_FLAG_SET(GST_OBJECT(ctx->videosource),GST_OBJECT_FLOATING); |
368 } |
361 } |
369 if (bCtx->bus) |
362 if (bCtx->bus) |
370 { |
363 { |
371 gst_bus_remove_signal_watch(bCtx->bus); |
364 gst_bus_remove_signal_watch(bCtx->bus); |
372 } |
365 } |
373 XAAdaptationGst_CancelAsyncWait(bCtx); |
366 XAAdaptationGst_CancelAsyncWait(bCtx); |
374 |
367 |
375 if (ctx->runpositiontimer) |
368 if (ctx->runpositiontimer) |
376 { |
369 { |
377 g_source_remove(ctx->runpositiontimer); |
370 g_source_remove(ctx->runpositiontimer); |
378 } |
371 } |
379 |
372 |
380 XAAdaptationGst_Free(bCtx); |
373 XAAdaptationGst_Free(bCtx); |
381 |
374 |
382 free(ctx); |
375 free(ctx); |
383 ctx = NULL; |
376 ctx = NULL; |
384 |
377 |
385 DEBUG_API("<-XAMediaRecorderAdapt_Destroy"); |
378 DEBUG_API("<-XAMediaRecorderAdapt_Destroy"); |
386 } |
379 } |
387 |
380 |
388 /***************** INTERNAL FUNCTIONS *******************************/ |
381 /***************** INTERNAL FUNCTIONS *******************************/ |
389 |
382 |
390 /* |
383 /* |
391 * void XAMediaRecorderAdapt_CreatePipeline( XAMediaRecorderAdaptationCtx* ctx ); |
384 * void XAMediaRecorderAdapt_CreatePipeline( XAMediaRecorderAdaptationCtx* ctx ); |
392 */ |
385 */ |
393 XAresult XAMediaRecorderAdapt_CreatePipeline( |
386 XAresult XAMediaRecorderAdapt_CreatePipeline( |
394 XAMediaRecorderAdaptationCtx* ctx) |
387 XAMediaRecorderAdaptationCtx* ctx) |
395 { |
388 { |
396 XAresult ret = XA_RESULT_SUCCESS; |
389 XAresult ret = XA_RESULT_SUCCESS; |
397 DEBUG_API("->XAMediaRecorderAdapt_CreatePipeline"); |
390 DEBUG_API("->XAMediaRecorderAdapt_CreatePipeline"); |
398 |
391 |
399 /* Create the audio src */ |
392 /* Create the audio src */ |
400 if ( ctx->xaAudioSource ) |
393 if ( ctx->xaAudioSource ) |
401 { |
394 { |
402 /* create audio pipe source */ |
395 /* create audio pipe source */ |
403 ctx->audiosource = XAAdaptationGst_CreateGstSource( ctx->xaAudioSource, "audiosource", |
396 ctx->audiosource = XAAdaptationGst_CreateGstSource( ctx->xaAudioSource, "audiosource", |
404 &(ctx->isobjasrc), NULL, NULL ); |
397 &(ctx->isobjasrc), NULL, NULL ); |
405 |
398 |
406 if( ctx->audiosource ) |
399 if( ctx->audiosource ) |
407 { |
400 { |
408 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->audiosource)) |
401 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->audiosource)) |
409 { |
402 { |
410 DEBUG_API("Added audiosource to bin"); |
403 DEBUG_API("Added audiosource to bin"); |
411 } |
404 } |
412 else |
405 else |
413 { |
406 { |
414 DEBUG_API("Could not add audiosource to bin"); |
407 DEBUG_API("Could not add audiosource to bin"); |
415 return XA_RESULT_INTERNAL_ERROR; |
408 return XA_RESULT_INTERNAL_ERROR; |
416 } |
409 } |
417 } |
410 } |
418 else |
411 else |
419 { |
412 { |
420 DEBUG_ERR("Could not create audio source!!!!"); |
413 DEBUG_ERR("Could not create audio source!!!!"); |
421 return XA_RESULT_INTERNAL_ERROR; |
414 return XA_RESULT_INTERNAL_ERROR; |
422 } |
415 } |
423 } |
416 } |
424 |
417 |
425 /* create and add video pipeline */ |
418 /* create and add video pipeline */ |
426 ctx->codecbin = XAMediaRecorderAdapt_CreateEncodeBin(ctx); |
419 ctx->codecbin = XAMediaRecorderAdapt_CreateEncodeBin(ctx); |
427 if (ctx->codecbin) |
420 if (ctx->codecbin) |
428 { |
421 { |
429 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->codecbin)) |
422 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->codecbin)) |
430 { |
423 { |
431 DEBUG_API("->XAMediaRecorderAdapt_CreatePipeline: gst_bin_add success"); |
424 DEBUG_API("->XAMediaRecorderAdapt_CreatePipeline: gst_bin_add success"); |
432 } |
425 } |
433 else |
426 else |
434 { |
427 { |
435 DEBUG_ERR("Could not add codec bin"); |
428 DEBUG_ERR("Could not add codec bin"); |
436 return XA_RESULT_INTERNAL_ERROR; |
429 return XA_RESULT_INTERNAL_ERROR; |
437 } |
430 } |
438 } |
431 } |
439 else |
432 else |
440 { |
433 { |
441 DEBUG_ERR("Could not create encoding bin!!!"); |
434 DEBUG_ERR("Could not create encoding bin!!!"); |
442 return XA_RESULT_INTERNAL_ERROR; |
435 return XA_RESULT_INTERNAL_ERROR; |
443 } |
436 } |
444 |
437 |
445 /* create and add video pipeline if video source available and codec supports video */ |
438 /* create and add video pipeline if video source available and codec supports video */ |
446 if (ctx->xaVideoSource |
439 if (ctx->xaVideoSource |
447 && gst_element_get_pad(ctx->codecbin, "v_sink")) |
440 && gst_element_get_pad(ctx->codecbin, "v_sink")) |
448 { |
441 { |
449 /* create video pipe source */ |
442 /* create video pipe source */ |
450 ctx->videosource = XAAdaptationGst_CreateGstSource( |
443 ctx->videosource = XAAdaptationGst_CreateGstSource( |
451 ctx->xaVideoSource, "videosource", &(ctx->isobjvsrc), |
444 ctx->xaVideoSource, "videosource", &(ctx->isobjvsrc), |
452 NULL, NULL ); |
445 NULL, NULL ); |
453 if (!ctx->videosource) |
446 if (!ctx->videosource) |
454 { |
447 { |
455 DEBUG_ERR("Could not create video source!!!!"); |
448 DEBUG_ERR("Could not create video source!!!!"); |
456 return XA_RESULT_INTERNAL_ERROR; |
449 return XA_RESULT_INTERNAL_ERROR; |
457 } |
450 } |
458 |
451 |
459 if (!ctx->isobjvsrc) |
452 if (!ctx->isobjvsrc) |
460 { /* Add other than camera sources to media recorder bin */ |
453 { /* Add other than camera sources to media recorder bin */ |
461 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videosource); |
454 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videosource); |
462 } |
455 } |
463 else |
456 else |
464 { /* Don't add camera source to media recorder bin */ |
457 { /* Don't add camera source to media recorder bin */ |
465 GstCaps * encSrcCaps; |
458 GstCaps * encSrcCaps; |
466 encSrcCaps = gst_caps_new_simple( "video/x-raw-yuv", |
459 encSrcCaps = gst_caps_new_simple( "video/x-raw-yuv", |
467 "format", GST_TYPE_FOURCC,GST_MAKE_FOURCC('I','4','2','0'), |
460 "format", GST_TYPE_FOURCC,GST_MAKE_FOURCC('I','4','2','0'), |
468 "framerate", GST_TYPE_FRACTION, ctx->videoEncSettings.frameRate, 1, |
461 "framerate", GST_TYPE_FRACTION, ctx->videoEncSettings.frameRate, 1, |
469 NULL); |
462 NULL); |
470 DEBUG_INFO_A1("new camera encoding filter: %s",gst_caps_to_string(encSrcCaps)); |
463 DEBUG_INFO_A1("new camera encoding filter: %s",gst_caps_to_string(encSrcCaps)); |
471 g_object_set( G_OBJECT(ctx->videosource), "filter-caps",encSrcCaps,NULL); |
464 g_object_set( G_OBJECT(ctx->videosource), "filter-caps",encSrcCaps,NULL); |
472 gst_caps_unref(encSrcCaps); |
465 gst_caps_unref(encSrcCaps); |
473 } |
466 } |
474 /* create video filter for video encoder settings */ |
467 /* create video filter for video encoder settings */ |
475 ctx->videofilter = gst_element_factory_make("capsfilter", "videofilter"); |
468 ctx->videofilter = gst_element_factory_make("capsfilter", "videofilter"); |
476 if( ctx->videofilter ) |
469 if( ctx->videofilter ) |
477 { |
470 { |
478 GstCaps* encSrcCaps; |
471 GstCaps* encSrcCaps; |
479 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videofilter); |
472 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videofilter); |
480 encSrcCaps = gst_caps_new_simple("video/x-raw-yuv", |
473 encSrcCaps = gst_caps_new_simple("video/x-raw-yuv", |
481 "width", G_TYPE_INT, ctx->videoEncSettings.width, |
474 "width", G_TYPE_INT, ctx->videoEncSettings.width, |
482 "height", G_TYPE_INT, ctx->videoEncSettings.height, |
475 "height", G_TYPE_INT, ctx->videoEncSettings.height, |
529 |
522 |
530 mrGhostSink = gst_element_get_static_pad( GST_ELEMENT(ctx->videofilter), "sink"); |
523 mrGhostSink = gst_element_get_static_pad( GST_ELEMENT(ctx->videofilter), "sink"); |
531 gst_element_add_pad(ctx->baseObj.bin, gst_ghost_pad_new("MRObjSink",mrGhostSink)); |
524 gst_element_add_pad(ctx->baseObj.bin, gst_ghost_pad_new("MRObjSink",mrGhostSink)); |
532 if ( !gst_element_link_pads( GST_ELEMENT(ctx->videosource), "MRObjSrc", |
525 if ( !gst_element_link_pads( GST_ELEMENT(ctx->videosource), "MRObjSrc", |
533 GST_ELEMENT(ctx->baseObj.bin), "MRObjSink") ) |
526 GST_ELEMENT(ctx->baseObj.bin), "MRObjSink") ) |
534 { |
527 { |
535 DEBUG_ERR("Could not link camera:MRObjSrc to videofilter:MRObjSink"); |
528 DEBUG_ERR("Could not link camera:MRObjSrc to videofilter:MRObjSink"); |
536 return XA_RESULT_INTERNAL_ERROR; |
529 return XA_RESULT_INTERNAL_ERROR; |
537 } |
530 } |
538 |
531 |
539 if ( cameraBinGhostPad ) |
532 if ( cameraBinGhostPad ) |
540 { |
533 { |
541 gst_object_unref( cameraBinGhostPad ); |
534 gst_object_unref( cameraBinGhostPad ); |
542 } |
535 } |
543 if ( ghost ) |
536 if ( ghost ) |
544 { |
537 { |
545 gst_object_unref( ghost ); |
538 gst_object_unref( ghost ); |
546 } |
539 } |
547 if ( mrGhostSink ) |
540 if ( mrGhostSink ) |
548 { |
541 { |
549 gst_object_unref( mrGhostSink ); |
542 gst_object_unref( mrGhostSink ); |
550 } |
543 } |
551 if ( camTee ) |
544 if ( camTee ) |
552 { |
545 { |
553 gst_object_unref( camTee ); |
546 gst_object_unref( camTee ); |
554 } |
547 } |
555 } |
548 } |
556 } |
549 } |
557 /* create video processing pipeline */ |
550 /* create video processing pipeline */ |
558 #ifdef XA_IMPL_FIXED_VIDEO_SIZE |
551 #ifdef XA_IMPL_FIXED_VIDEO_SIZE |
559 ctx->videoppbin = XAAdaptationGst_CreateFixedSizeVideoPP( ); |
552 ctx->videoppbin = XAAdaptationGst_CreateFixedSizeVideoPP( ); |
560 #else |
553 #else |
561 ctx->videoppbin = XAAdaptationGst_CreateVideoPP( ); |
554 ctx->videoppbin = XAAdaptationGst_CreateVideoPP( ); |
562 #endif |
555 #endif |
563 if( ctx->videoppbin ) |
556 if( ctx->videoppbin ) |
564 { |
557 { |
565 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videoppbin); |
558 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videoppbin); |
566 if(!gst_element_link(ctx->videofilter, ctx->videoppbin)) |
559 if(!gst_element_link(ctx->videofilter, ctx->videoppbin)) |
567 { |
560 { |
568 DEBUG_ERR("Could not link videofilter to videopp!!"); |
561 DEBUG_ERR("Could not link videofilter to videopp!!"); |
569 return XA_RESULT_INTERNAL_ERROR; |
562 return XA_RESULT_INTERNAL_ERROR; |
570 } |
563 } |
571 } |
564 } |
572 else |
565 else |
573 { |
566 { |
574 DEBUG_ERR("Could not create video pp bin!!!!"); |
567 DEBUG_ERR("Could not create video pp bin!!!!"); |
575 return XA_RESULT_INTERNAL_ERROR; |
568 return XA_RESULT_INTERNAL_ERROR; |
576 } |
569 } |
577 /* create identity to extract buffers from */ |
570 /* create identity to extract buffers from */ |
578 ctx->videoextract = gst_element_factory_make("identity", "videoextract"); |
571 ctx->videoextract = gst_element_factory_make("identity", "videoextract"); |
579 if( ctx->videoextract ) |
572 if( ctx->videoextract ) |
580 { |
573 { |
581 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videoextract); |
574 gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->videoextract); |
582 if(!gst_element_link(ctx->videoppbin, ctx->videoextract)) |
575 if(!gst_element_link(ctx->videoppbin, ctx->videoextract)) |
583 { |
576 { |
584 DEBUG_ERR("Could not link videopp to videoextract!!"); |
577 DEBUG_ERR("Could not link videopp to videoextract!!"); |
585 return XA_RESULT_INTERNAL_ERROR; |
578 return XA_RESULT_INTERNAL_ERROR; |
586 } |
579 } |
587 } |
580 } |
588 else |
581 else |
589 { |
582 { |
590 DEBUG_ERR("Could not create videoextract!!!!"); |
583 DEBUG_ERR("Could not create videoextract!!!!"); |
591 return XA_RESULT_INTERNAL_ERROR; |
584 return XA_RESULT_INTERNAL_ERROR; |
592 } |
585 } |
593 if( ctx->videoextract ) |
586 if( ctx->videoextract ) |
594 { |
587 { |
595 if( !gst_element_link_pads(ctx->videoextract, "src", ctx->codecbin, "v_sink") ) |
588 if( !gst_element_link_pads(ctx->videoextract, "src", ctx->codecbin, "v_sink") ) |
596 { |
589 { |
597 DEBUG_INFO("Warning: could not link videoextract to codec!!"); |
590 DEBUG_INFO("Warning: could not link videoextract to codec!!"); |
598 } |
591 } |
599 } |
592 } |
600 } |
593 } |
601 else |
594 else |
602 { |
595 { |
603 DEBUG_INFO("No video input"); |
596 DEBUG_INFO("No video input"); |
604 } |
597 } |
605 |
598 |
606 /* create and add audio pipeline */ |
599 /* create and add audio pipeline */ |
607 if ( ctx->audiosource ) |
600 if ( ctx->audiosource ) |
608 { |
601 { |
609 #ifdef USE_AUDIO_PP |
602 #ifdef USE_AUDIO_PP |
610 /* create audio processing pipeline */ |
603 /* create audio processing pipeline */ |
611 ctx->audioppbin = XAAdaptationGst_CreateAudioPP( ); |
604 ctx->audioppbin = XAAdaptationGst_CreateAudioPP( ); |
612 if( ctx->audioppbin ) |
605 if( ctx->audioppbin ) |
613 { |
606 { |
614 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->audioppbin)) |
607 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->audioppbin)) |
615 { |
608 { |
616 DEBUG_INFO("Added audioppbin to bin"); |
609 DEBUG_INFO("Added audioppbin to bin"); |
617 } |
610 } |
618 else |
611 else |
619 { |
612 { |
620 DEBUG_ERR("Could not add audioppbin to bin"); |
613 DEBUG_ERR("Could not add audioppbin to bin"); |
621 return XA_RESULT_INTERNAL_ERROR; |
614 return XA_RESULT_INTERNAL_ERROR; |
622 } |
615 } |
623 if(!gst_element_link(ctx->audiosource, ctx->audioppbin)) |
616 if(!gst_element_link(ctx->audiosource, ctx->audioppbin)) |
624 { |
617 { |
625 DEBUG_ERR("Could not link audiofilter to audiopp!!"); |
618 DEBUG_ERR("Could not link audiofilter to audiopp!!"); |
626 return XA_RESULT_INTERNAL_ERROR; |
619 return XA_RESULT_INTERNAL_ERROR; |
627 } |
620 } |
628 |
621 } |
629 |
|
630 } |
|
631 else |
622 else |
632 { |
623 { |
633 DEBUG_ERR("Could not create audio pp bin!!!!"); |
624 DEBUG_ERR("Could not create audio pp bin!!!!"); |
634 return XA_RESULT_INTERNAL_ERROR; |
625 return XA_RESULT_INTERNAL_ERROR; |
635 } |
626 } |
636 #endif //USE_AUDIO_PP |
627 #endif //USE_AUDIO_PP |
637 |
628 |
638 /* create audio filter for audio encoder settings */ |
629 /* create audio filter for audio encoder settings */ |
639 |
630 |
640 // ret = XAMediaRecorderAdapt_CreateCapsFilter(ctx); |
631 // ret = XAMediaRecorderAdapt_CreateCapsFilter(ctx); |
641 // |
632 // |
642 // if ( XA_RESULT_SUCCESS != ret ) |
633 // if ( XA_RESULT_SUCCESS != ret ) |
643 // { |
634 // { |
644 // DEBUG_ERR("cannot create caps filter"); |
635 // DEBUG_ERR("cannot create caps filter"); |
645 // return ret; |
636 // return ret; |
646 // } |
637 // } |
647 // |
638 // |
648 // /*LINK : audiosource -> audiofilter */ |
639 // /*LINK : audiosource -> audiofilter */ |
649 // if(!gst_element_link(ctx->audiosource, ctx->audiofilter)) |
640 // if(!gst_element_link(ctx->audiosource, ctx->audiofilter)) |
650 // { |
641 // { |
651 // DEBUG_ERR("Could not link audiosource to audiofilter!!"); |
642 // DEBUG_ERR("Could not link audiosource to audiofilter!!"); |
652 // return XA_RESULT_INTERNAL_ERROR; |
643 // return XA_RESULT_INTERNAL_ERROR; |
653 // } |
644 // } |
654 |
645 |
655 /* if( !gst_element_link_pads_filtered(ctx->audiofilter, "src", ctx->codecbin, "sink", encSrcCaps) ) |
646 /* if( !gst_element_link_pads_filtered(ctx->audiofilter, "src", ctx->codecbin, "sink", encSrcCaps) ) |
656 { |
647 { |
657 DEBUG_INFO("Warning: could not link audiopp to codec!!"); |
648 DEBUG_INFO("Warning: could not link audiopp to codec!!"); |
658 return XA_RESULT_INTERNAL_ERROR; |
649 return XA_RESULT_INTERNAL_ERROR; |
659 } |
650 } |
660 */ |
651 */ |
661 #ifdef USE_AUDIO_PP |
652 #ifdef USE_AUDIO_PP |
662 if (!gst_element_link_filtered( ctx->audiofilter , ctx->audioppbin ,encSrcCaps)) |
653 if (!gst_element_link_filtered( ctx->audiofilter , ctx->audioppbin ,encSrcCaps)) |
663 { |
654 { |
664 DEBUG_INFO("Warning: could not link audiosource to audiopp!!"); |
655 DEBUG_INFO("Warning: could not link audiosource to audiopp!!"); |
665 return XA_RESULT_INTERNAL_ERROR; |
656 return XA_RESULT_INTERNAL_ERROR; |
666 } |
657 } |
667 if(!gst_element_link(ctx->audioppbin, ctx->codecbin)) |
658 if(!gst_element_link(ctx->audioppbin, ctx->codecbin)) |
668 { |
659 { |
669 DEBUG_INFO("Warning: could not link audioppbin to codecbin!!"); |
660 DEBUG_INFO("Warning: could not link audioppbin to codecbin!!"); |
670 return XA_RESULT_INTERNAL_ERROR; |
661 return XA_RESULT_INTERNAL_ERROR; |
671 } |
662 } |
672 #else |
663 #else |
673 //if(!gst_element_link(ctx->audiofilter, ctx->codecbin )) |
664 //if(!gst_element_link(ctx->audiofilter, ctx->codecbin )) |
674 if(!gst_element_link(ctx->audiosource, ctx->codecbin )) |
665 if(!gst_element_link(ctx->audiosource, ctx->codecbin )) |
675 { |
666 { |
676 DEBUG_ERR("Could not link audiosource to codecbin!!"); |
667 DEBUG_ERR("Could not link audiosource to codecbin!!"); |
677 return XA_RESULT_INTERNAL_ERROR; |
668 return XA_RESULT_INTERNAL_ERROR; |
678 } |
669 } |
679 else |
670 else |
680 { |
671 { |
681 DEBUG_INFO("Warning: link audiosource to codecbin is successfull with muxcaps!!"); |
672 DEBUG_INFO("Warning: link audiosource to codecbin is successfull with muxcaps!!"); |
682 } |
673 } |
683 #endif // USE_AUDIO_PP |
674 #endif // USE_AUDIO_PP |
684 } |
675 } |
685 else |
676 else |
686 { |
677 { |
687 DEBUG_INFO("No audio input"); |
678 DEBUG_INFO("No audio input"); |
688 } |
679 } |
689 |
680 |
690 /* create and add data sink */ |
681 /* create and add data sink */ |
691 ctx->datasink = XAAdaptationGst_CreateGstSink( ctx->xaSink, "datasink", &(ctx->isobjsink) ); |
682 ctx->datasink = XAAdaptationGst_CreateGstSink( ctx->xaSink, "datasink", &(ctx->isobjsink) ); |
692 if( ctx->datasink ) |
683 if( ctx->datasink ) |
693 { |
684 { |
694 if ( GST_IS_APP_SINK(ctx->datasink) ) |
685 if ( GST_IS_APP_SINK(ctx->datasink) ) |
695 { |
686 { |
696 gst_app_sink_set_emit_signals( GST_APP_SINK(ctx->datasink), TRUE ); |
687 gst_app_sink_set_emit_signals( GST_APP_SINK(ctx->datasink), TRUE ); |
697 } |
688 } |
698 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->datasink)) |
689 if (gst_bin_add(GST_BIN(ctx->baseObj.bin), ctx->datasink)) |
699 { |
690 { |
700 DEBUG_INFO("Added datasink to bin"); |
691 DEBUG_INFO("Added datasink to bin"); |
701 } |
692 } |
702 else |
693 else |
703 { |
694 { |
704 DEBUG_ERR("Could not add datasink to bin"); |
695 DEBUG_ERR("Could not add datasink to bin"); |
705 return XA_RESULT_INTERNAL_ERROR; |
696 return XA_RESULT_INTERNAL_ERROR; |
706 } |
697 } |
707 if(!gst_element_link(ctx->codecbin, ctx->datasink)) |
698 if(!gst_element_link(ctx->codecbin, ctx->datasink)) |
708 { |
699 { |
709 DEBUG_ERR("Could not link codec to sink!!"); |
700 DEBUG_ERR("Could not link codec to sink!!"); |
710 return XA_RESULT_INTERNAL_ERROR; |
701 return XA_RESULT_INTERNAL_ERROR; |
711 } |
702 } |
712 /* NOTE: no actual object sinks applicable, variable used to imply appsrc (recording to memory)*/ |
703 /* NOTE: no actual object sinks applicable, variable used to imply appsrc (recording to memory)*/ |
713 if(ctx->isobjsink) |
704 if(ctx->isobjsink) |
714 { |
705 { |
715 g_signal_connect(ctx->datasink, "new-buffer", |
706 g_signal_connect(ctx->datasink, "new-buffer", |
716 G_CALLBACK (XAMediaRecorderAdapt_BufferAvailable),ctx); |
707 G_CALLBACK (XAMediaRecorderAdapt_BufferAvailable),ctx); |
717 |
708 |
718 ret = XAImpl_CreateSemaphore( &(ctx->recThrCtx.bufInsufficientSem)); |
709 ret = XAImpl_CreateSemaphore( &(ctx->recThrCtx.bufInsufficientSem)); |
719 if ( ret != XA_RESULT_SUCCESS ) |
710 if ( ret != XA_RESULT_SUCCESS ) |
720 { |
711 { |
721 DEBUG_ERR("WARN: Could not create semaphore for recorder event handler!"); |
712 DEBUG_ERR("WARN: Could not create semaphore for recorder event handler!"); |
722 } |
713 } |
723 XAImpl_CreateThreadHandle( &(ctx->recordingEventThr) ); |
714 XAImpl_CreateThreadHandle( &(ctx->recordingEventThr) ); |
724 } |
715 } |
725 } |
716 } |
726 else |
717 else |
727 { |
718 { |
728 DEBUG_ERR("Could not create data sink!!!"); |
719 DEBUG_ERR("Could not create data sink!!!"); |
729 return XA_RESULT_INTERNAL_ERROR; |
720 return XA_RESULT_INTERNAL_ERROR; |
730 } |
721 } |
731 DEBUG_API("<-XAMediaRecorderAdapt_CreatePipeline"); |
722 DEBUG_API("<-XAMediaRecorderAdapt_CreatePipeline"); |
732 return ret; |
723 return ret; |
733 } |
724 } |
734 |
725 |
735 /* |
726 /* |
736 * XAresult XAMediaRecorderAdapt_CheckCodec( XAMediaRecorderAdaptationCtx_* mCtx ); |
727 * XAresult XAMediaRecorderAdapt_CheckCodec( XAMediaRecorderAdaptationCtx_* mCtx ); |
737 * Check codec compatibility and support with initiated datasink content |
728 * Check codec compatibility and support with initiated datasink content |
738 */ |
729 */ |
739 XAresult XAMediaRecorderAdapt_CheckCodec( XAMediaRecorderAdaptationCtx_* mCtx, XACapsType encType, XAuint32 encoderId ) |
730 XAresult XAMediaRecorderAdapt_CheckCodec( XAMediaRecorderAdaptationCtx_* mCtx, XACapsType encType, XAuint32 encoderId ) |
740 { |
731 { |
741 XAresult ret = XA_RESULT_SUCCESS; |
732 XAresult ret = XA_RESULT_SUCCESS; |
742 XAuint32 format; |
733 XAuint32 format; |
743 XACapabilities temp; |
734 XACapabilities temp; |
744 |
735 |
745 DEBUG_API("->XAMediaRecorderAdapt_CheckCodec"); |
736 DEBUG_API("->XAMediaRecorderAdapt_CheckCodec"); |
746 |
737 |
747 /*first, check if codec supported at all*/ |
738 /*first, check if codec supported at all*/ |
748 ret = XACapabilitiesMgr_GetCapsById(mCtx->baseObj.baseObj.capslist,(XACapsType)(XACAP_ENCODER|encType), encoderId, &temp); |
739 ret = XACapabilitiesMgr_GetCapsById(mCtx->baseObj.baseObj.capslist,(XACapsType)(XACAP_ENCODER|encType), encoderId, &temp); |
749 |
740 |
750 if( ret==XA_RESULT_SUCCESS ) |
741 if( ret==XA_RESULT_SUCCESS ) |
751 { |
742 { |
752 if(encType & (XACAP_VIDEO|XACAP_AUDIO)) |
743 if(encType & (XACAP_VIDEO|XACAP_AUDIO)) |
753 { |
744 { |
754 if(mCtx->xaSink && mCtx->xaSink->pFormat) |
745 if(mCtx->xaSink && mCtx->xaSink->pFormat) |
755 { |
746 { |
756 format = *(XAuint32*)(mCtx->xaSink->pFormat); |
747 format = *(XAuint32*)(mCtx->xaSink->pFormat); |
757 } |
748 } |
758 else |
|
759 { |
|
760 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
|
761 } |
|
762 } |
|
763 else |
749 else |
764 { |
750 { |
765 if(mCtx->snapshotVars.xaSink && mCtx->snapshotVars.xaSink->pFormat) |
751 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
766 { |
752 } |
767 format = *(XAuint32*)(mCtx->snapshotVars.xaSink->pFormat); |
753 } |
768 } |
754 else |
769 else |
755 { |
770 { |
756 if(mCtx->snapshotVars.xaSink && mCtx->snapshotVars.xaSink->pFormat) |
771 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
757 { |
772 } |
758 format = *(XAuint32*)(mCtx->snapshotVars.xaSink->pFormat); |
773 } |
759 } |
774 if(ret==XA_RESULT_SUCCESS) switch ( format ) |
760 else |
775 { |
761 { |
|
762 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
|
763 } |
|
764 } |
|
765 if(ret==XA_RESULT_SUCCESS) |
|
766 { |
|
767 switch ( format ) |
|
768 { |
776 case XA_DATAFORMAT_PCM: |
769 case XA_DATAFORMAT_PCM: |
777 if ( (encType == XACAP_AUDIO) && (encoderId == XA_AUDIOCODEC_PCM) ) |
770 if ( (encType == XACAP_AUDIO) && (encoderId == XA_AUDIOCODEC_PCM) ) |
778 { |
771 { |
779 ret=XA_RESULT_SUCCESS; |
772 ret=XA_RESULT_SUCCESS; |
780 } |
773 } |
781 else |
774 else |
782 { |
775 { |
783 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
776 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
784 } |
777 } |
785 break; |
778 break; |
786 |
779 |
787 case XA_DATAFORMAT_RAWIMAGE: |
780 case XA_DATAFORMAT_RAWIMAGE: |
788 if ( (encType == XACAP_IMAGE) && (encoderId == XA_IMAGECODEC_RAW) ) |
781 if ( (encType == XACAP_IMAGE) && (encoderId == XA_IMAGECODEC_RAW) ) |
789 { |
782 { |
790 ret=XA_RESULT_SUCCESS; |
783 ret=XA_RESULT_SUCCESS; |
791 } |
784 } |
792 else |
785 else |
793 { |
786 { |
794 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
787 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
795 } |
788 } |
796 break; |
789 break; |
797 |
790 |
798 case XA_DATAFORMAT_MIME: |
791 case XA_DATAFORMAT_MIME: |
799 DEBUG_INFO("XA_DATAFORMAT_MIME "); |
792 DEBUG_INFO("XA_DATAFORMAT_MIME "); |
800 { |
793 { |
801 XADataFormat_MIME* mime = ((XADataFormat_MIME*)mCtx->xaSink->pFormat); |
794 XADataFormat_MIME* mime = ((XADataFormat_MIME*)mCtx->xaSink->pFormat); |
802 DEBUG_INFO_A1("mime->containerType:%u",(int)mime->containerType); |
795 DEBUG_INFO_A1("mime->containerType:%u",(int)mime->containerType); |
803 DEBUG_INFO_A1("mime->mimeType:%s",mime->mimeType); |
796 DEBUG_INFO_A1("mime->mimeType:%s",mime->mimeType); |
804 switch ( mime->containerType ) |
797 switch ( mime->containerType ) |
805 { |
798 { |
806 case XA_CONTAINERTYPE_RAW: |
799 case XA_CONTAINERTYPE_RAW: |
807 if( ((encType == XACAP_AUDIO) && (encoderId == XA_AUDIOCODEC_PCM)) || |
800 if( ((encType == XACAP_AUDIO) && (encoderId == XA_AUDIOCODEC_PCM)) || |
808 ((encType == XACAP_VIDEO) && (encoderId == XA_ADAPTID_RAWVIDEO)) || |
801 ((encType == XACAP_VIDEO) && (encoderId == XA_ADAPTID_RAWVIDEO)) || |
809 ((encType == XACAP_IMAGE) && (encoderId == XA_IMAGECODEC_RAW)) ) |
802 ((encType == XACAP_IMAGE) && (encoderId == XA_IMAGECODEC_RAW)) ) |
810 { |
803 { |
811 ret=XA_RESULT_SUCCESS; |
804 ret=XA_RESULT_SUCCESS; |
812 } |
805 } |
813 else |
806 else |
814 { |
807 { |
815 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
808 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
816 } |
809 } |
817 break; |
810 break; |
818 |
811 |
819 case XA_CONTAINERTYPE_AVI: |
812 case XA_CONTAINERTYPE_AVI: |
820 if(encType == XACAP_VIDEO) |
813 if(encType == XACAP_VIDEO) |
821 { |
814 { |
822 switch(encoderId) |
815 switch(encoderId) |
823 { |
816 { |
824 case XA_ADAPTID_MOTIONJPEG: |
817 case XA_ADAPTID_MOTIONJPEG: |
825 case XA_ADAPTID_RAWVIDEO: |
818 case XA_ADAPTID_RAWVIDEO: |
826 ret=XA_RESULT_SUCCESS; |
819 ret=XA_RESULT_SUCCESS; |
827 break; |
820 break; |
828 default: |
821 default: |
829 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
822 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
830 break; |
823 break; |
831 } |
824 } |
832 } |
825 } |
833 else if(encType == XACAP_AUDIO) |
826 else if(encType == XACAP_AUDIO) |
834 { |
827 { |
835 switch(encoderId) |
828 switch(encoderId) |
836 { |
829 { |
837 case XA_AUDIOCODEC_PCM: |
830 case XA_AUDIOCODEC_PCM: |
838 ret=XA_RESULT_SUCCESS; |
831 ret=XA_RESULT_SUCCESS; |
839 break; |
832 break; |
840 default: |
833 default: |
841 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
834 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
842 break; |
835 break; |
843 } |
836 } |
844 } |
837 } |
845 else |
838 else |
846 { |
839 { |
847 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
840 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
848 } |
841 } |
849 break; |
842 break; |
850 |
843 |
851 case XA_CONTAINERTYPE_WAV: |
844 case XA_CONTAINERTYPE_WAV: |
852 if(encType == XACAP_AUDIO) |
845 if(encType == XACAP_AUDIO) |
853 { |
846 { |
854 switch(encoderId) |
847 switch(encoderId) |
855 { |
848 { |
856 case XA_AUDIOCODEC_PCM: |
849 case XA_AUDIOCODEC_PCM: |
857 ret=XA_RESULT_SUCCESS; |
850 ret=XA_RESULT_SUCCESS; |
858 break; |
851 break; |
859 default: |
852 default: |
860 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
853 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
861 break; |
854 break; |
862 } |
855 } |
863 } |
856 } |
864 else |
857 else |
865 { |
858 { |
866 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
859 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
867 } |
860 } |
868 break; |
861 break; |
869 |
862 |
870 case XA_CONTAINERTYPE_JPG: |
863 case XA_CONTAINERTYPE_JPG: |
871 if(encType == XACAP_VIDEO) |
864 if(encType == XACAP_VIDEO) |
872 { |
865 { |
873 switch(encoderId) |
866 switch(encoderId) |
874 { |
867 { |
875 case XA_ADAPTID_MOTIONJPEG: |
868 case XA_ADAPTID_MOTIONJPEG: |
876 ret=XA_RESULT_SUCCESS; |
869 ret=XA_RESULT_SUCCESS; |
877 break; |
870 break; |
878 default: |
871 default: |
879 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
872 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
880 break; |
873 break; |
881 } |
874 } |
882 } |
875 } |
883 else if(encType == XACAP_IMAGE) |
876 else if(encType == XACAP_IMAGE) |
884 { |
877 { |
885 switch(encoderId) |
878 switch(encoderId) |
886 { |
879 { |
887 case XA_IMAGECODEC_JPEG: |
880 case XA_IMAGECODEC_JPEG: |
888 ret=XA_RESULT_SUCCESS; |
881 ret=XA_RESULT_SUCCESS; |
889 break; |
882 break; |
890 default: |
883 default: |
891 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
884 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
892 break; |
885 break; |
893 } |
886 } |
894 } |
887 } |
895 else |
888 else |
896 { |
889 { |
897 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
890 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
898 } |
891 } |
899 break; |
892 break; |
900 |
893 |
901 case XA_CONTAINERTYPE_UNSPECIFIED: |
894 case XA_CONTAINERTYPE_UNSPECIFIED: |
902 if(strstr( (char *) mime->mimeType, "/ogg") != 0) |
895 if(strstr( (char *) mime->mimeType, "/ogg") != 0) |
903 { |
896 { |
904 if(encType == XACAP_VIDEO) |
897 if(encType == XACAP_VIDEO) |
|
898 { |
|
899 switch(encoderId) |
905 { |
900 { |
906 switch(encoderId) |
|
907 { |
|
908 case XA_ADAPTID_THEORA: |
901 case XA_ADAPTID_THEORA: |
909 ret=XA_RESULT_SUCCESS; |
902 ret=XA_RESULT_SUCCESS; |
910 break; |
903 break; |
911 default: |
904 default: |
912 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
905 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
913 break; |
906 break; |
914 } |
|
915 } |
907 } |
|
908 } |
916 else if(encType == XACAP_AUDIO) |
909 else if(encType == XACAP_AUDIO) |
|
910 { |
|
911 switch(encoderId) |
917 { |
912 { |
918 switch(encoderId) |
|
919 { |
|
920 case XA_ADAPTID_VORBIS: |
913 case XA_ADAPTID_VORBIS: |
921 ret=XA_RESULT_SUCCESS; |
914 ret=XA_RESULT_SUCCESS; |
922 break; |
915 break; |
923 default: |
916 default: |
924 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
917 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
925 break; |
918 break; |
926 } |
|
927 } |
919 } |
|
920 } |
928 else |
921 else |
929 { |
922 { |
930 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
923 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
931 } |
924 } |
932 } |
925 } |
933 else |
926 else |
934 { |
927 { |
935 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
928 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
936 } |
929 } |
937 break; |
930 break; |
938 case XA_CONTAINERTYPE_AMR: |
931 case XA_CONTAINERTYPE_AMR: |
939 if(encType == XACAP_AUDIO) |
932 if(encType == XACAP_AUDIO) |
940 { |
933 { |
941 switch(encoderId) |
934 switch(encoderId) |
942 { |
935 { |
943 case XA_AUDIOCODEC_AMR: |
936 case XA_AUDIOCODEC_AMR: |
944 ret=XA_RESULT_SUCCESS; |
937 ret=XA_RESULT_SUCCESS; |
945 break; |
938 break; |
946 default: |
939 default: |
947 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
940 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
948 break; |
941 break; |
949 } |
942 } |
950 } |
943 } |
951 else |
944 else |
952 { |
945 { |
953 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
946 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
954 } |
947 } |
955 break; |
948 break; |
956 case XA_CONTAINERTYPE_MP4: |
949 case XA_CONTAINERTYPE_MP4: |
957 if(encType == XACAP_AUDIO ) |
950 if(encType == XACAP_AUDIO ) |
958 { |
951 { |
959 switch(encoderId) |
952 switch(encoderId) |
960 { |
953 { |
961 case XA_AUDIOCODEC_AAC: |
954 case XA_AUDIOCODEC_AAC: |
962 ret=XA_RESULT_SUCCESS; |
955 ret=XA_RESULT_SUCCESS; |
963 break; |
956 break; |
964 default: |
957 default: |
965 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
958 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
966 break; |
959 break; |
967 } |
960 } |
968 } |
961 } |
969 else |
962 else |
970 { |
963 { |
971 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
964 ret=XA_RESULT_FEATURE_UNSUPPORTED; |
972 } |
965 } |
973 break; |
966 break; |
974 default: /*switch (containertype)*/ |
967 default: /*switch (containertype)*/ |
975 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
968 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
976 break; |
969 break; |
977 } |
970 } |
978 break; |
971 break; |
979 } |
972 } |
980 default: /*switch (format)*/ |
973 default: /*switch (format)*/ |
981 ret = XA_RESULT_CONTENT_UNSUPPORTED; |
974 ret = XA_RESULT_CONTENT_UNSUPPORTED; |
982 break; |
975 break; |
983 } |
976 } |
984 } |
977 } |
985 if( ret!=XA_RESULT_SUCCESS ) |
978 } |
986 { |
979 if( ret!=XA_RESULT_SUCCESS ) |
987 DEBUG_ERR("cannot accommodate given codec & datasink pair!!!"); |
980 { |
988 } |
981 DEBUG_ERR("cannot accommodate given codec & datasink pair!!!"); |
989 DEBUG_API("<-XAMediaRecorderAdapt_CheckCodec"); |
982 } |
990 return ret; |
983 DEBUG_API("<-XAMediaRecorderAdapt_CheckCodec"); |
991 } |
984 return ret; |
|
985 } |
|
986 |
992 /* |
987 /* |
993 * XAresult XAMediaRecorderAdapt_ChangeEncoders( XAMediaRecorderAdaptationCtx* mCtx ); |
988 * XAresult XAMediaRecorderAdapt_ChangeEncoders( XAMediaRecorderAdaptationCtx* mCtx ); |
994 * re-create encodebin based on new encoder settings |
989 * re-create encodebin based on new encoder settings |
995 */ |
990 */ |
996 XAresult XAMediaRecorderAdapt_ChangeEncoders( XAMediaRecorderAdaptationCtx* mCtx ) |
991 XAresult XAMediaRecorderAdapt_ChangeEncoders( XAMediaRecorderAdaptationCtx* mCtx ) |
997 { |
992 { |
998 XAresult ret = XA_RESULT_SUCCESS; |
993 XAresult ret = XA_RESULT_SUCCESS; |
999 GstElement *encoderelement = NULL; |
994 GstElement *encoderelement = NULL; |
1000 XAAdaptationGstCtx* bCtx = &(mCtx->baseObj); |
995 XAAdaptationGstCtx* bCtx = &(mCtx->baseObj); |
1001 |
996 |
1002 DEBUG_API("->XAMediaRecorderAdapt_ChangeEncoders"); |
997 DEBUG_API("->XAMediaRecorderAdapt_ChangeEncoders"); |
1003 /* check state */ |
998 /* check state */ |
1004 if(GST_STATE(mCtx->baseObj.bin)<GST_STATE_PLAYING) |
999 if(GST_STATE(mCtx->baseObj.bin)<GST_STATE_PLAYING) |
1005 { |
1000 { |
1006 GstElement* newBin = XAMediaRecorderAdapt_CreateEncodeBin(mCtx); |
1001 GstElement* newBin = XAMediaRecorderAdapt_CreateEncodeBin(mCtx); |
1007 if(newBin) |
1002 if(newBin) |
1008 { /* replace old bin with new */ |
1003 { /* replace old bin with new */ |
1009 GstStateChangeReturn gret; |
1004 GstStateChangeReturn gret; |
1010 GstPad *asink=NULL, *linkedasrc=NULL; |
1005 GstPad *asink=NULL, *linkedasrc=NULL; |
1011 GstPad *vsink=NULL, *linkedvsrc=NULL; |
1006 GstPad *vsink=NULL, *linkedvsrc=NULL; |
1012 GstPad *src=NULL, *linkedsink=NULL; |
1007 GstPad *src=NULL, *linkedsink=NULL; |
1013 GstPad *moSrc=NULL, *moSink=NULL; |
1008 GstPad *moSrc=NULL, *moSink=NULL; |
1020 gret = gst_element_set_state( GST_ELEMENT(bCtx->bin), bCtx->binWantedState); |
1015 gret = gst_element_set_state( GST_ELEMENT(bCtx->bin), bCtx->binWantedState); |
1021 gret = gst_element_get_state( GST_ELEMENT(bCtx->bin), NULL, NULL, XA_ADAPT_ASYNC_TIMEOUT_SHORT_NSEC); |
1016 gret = gst_element_get_state( GST_ELEMENT(bCtx->bin), NULL, NULL, XA_ADAPT_ASYNC_TIMEOUT_SHORT_NSEC); |
1022 |
1017 |
1023 /*set new stream settings*/ |
1018 /*set new stream settings*/ |
1024 if( mCtx->videofilter ) |
1019 if( mCtx->videofilter ) |
1025 { |
1020 { |
1026 encSrcCaps = gst_caps_new_simple("video/x-raw-yuv", |
1021 encSrcCaps = gst_caps_new_simple("video/x-raw-yuv", |
1027 "format", GST_TYPE_FOURCC,GST_MAKE_FOURCC('I','4','2','0'), |
1022 "format", GST_TYPE_FOURCC,GST_MAKE_FOURCC('I','4','2','0'), |
1028 "width", G_TYPE_INT, mCtx->videoEncSettings.width, |
1023 "width", G_TYPE_INT, mCtx->videoEncSettings.width, |
1029 "height", G_TYPE_INT, mCtx->videoEncSettings.height, |
1024 "height", G_TYPE_INT, mCtx->videoEncSettings.height, |
1030 "framerate", GST_TYPE_FRACTION, mCtx->videoEncSettings.frameRate, 1, |
1025 "framerate", GST_TYPE_FRACTION, mCtx->videoEncSettings.frameRate, 1, |
1031 NULL); |
1026 NULL); |
1032 DEBUG_INFO_A1("new video encoder config from settings: %s",gst_caps_to_string(encSrcCaps)); |
1027 DEBUG_INFO_A1("new video encoder config from settings: %s",gst_caps_to_string(encSrcCaps)); |
1033 g_object_set( G_OBJECT(mCtx->videofilter), "caps",encSrcCaps,NULL); |
1028 g_object_set( G_OBJECT(mCtx->videofilter), "caps",encSrcCaps,NULL); |
1034 gst_caps_unref(encSrcCaps); |
1029 gst_caps_unref(encSrcCaps); |
1035 } |
1030 } |
1036 if(!mCtx ->audiofilter) |
1031 if(!mCtx ->audiofilter) |
1037 { |
1032 { |
1038 //creating caps filter |
1033 //creating caps filter |
1039 mCtx->audiofilter = gst_element_factory_make("capsfilter", "audiofilter"); |
1034 mCtx->audiofilter = gst_element_factory_make("capsfilter", "audiofilter"); |
1040 if ( mCtx->audiofilter ) |
1035 if ( mCtx->audiofilter ) |
1041 { |
1036 { |
1042 gst_bin_add(GST_BIN(bCtx->bin), mCtx->audiofilter); |
1037 gst_bin_add(GST_BIN(bCtx->bin), mCtx->audiofilter); |
1043 encSrcCaps = gst_caps_new_full( |
1038 encSrcCaps = gst_caps_new_full( |
1044 gst_structure_new("audio/x-raw-int", |
1039 gst_structure_new("audio/x-raw-int", |
1045 "channels", G_TYPE_INT, mCtx->audioEncSettings.channelsOut, |
1040 "channels", G_TYPE_INT, mCtx->audioEncSettings.channelsOut, |
1046 "rate", G_TYPE_INT, (mCtx->audioEncSettings.sampleRate / 1000), |
1041 "rate", G_TYPE_INT, (mCtx->audioEncSettings.sampleRate / 1000), |
1047 "depth", G_TYPE_INT, mCtx->audioEncSettings.bitsPerSample, |
1042 "depth", G_TYPE_INT, mCtx->audioEncSettings.bitsPerSample, |
1048 "signed",G_TYPE_BOOLEAN, TRUE, |
1043 "signed",G_TYPE_BOOLEAN, TRUE, |
1049 "endianness",G_TYPE_INT, mCtx->audioEncSettings.blockAlignment, |
1044 "endianness",G_TYPE_INT, mCtx->audioEncSettings.blockAlignment, |
1050 NULL), |
1045 NULL), |
1051 gst_structure_new("audio/amr", |
1046 gst_structure_new("audio/amr", |
1052 "signed",G_TYPE_BOOLEAN, TRUE, |
1047 "signed",G_TYPE_BOOLEAN, TRUE, |
1053 "endianness",G_TYPE_INT, mCtx->audioEncSettings.blockAlignment, |
1048 "endianness",G_TYPE_INT, mCtx->audioEncSettings.blockAlignment, |
1054 "depth", G_TYPE_INT, mCtx->audioEncSettings.bitsPerSample, |
1049 "depth", G_TYPE_INT, mCtx->audioEncSettings.bitsPerSample, |
1055 "rate", G_TYPE_INT, (mCtx->audioEncSettings.sampleRate / 1000), |
1050 "rate", G_TYPE_INT, (mCtx->audioEncSettings.sampleRate / 1000), |
1056 "channels", G_TYPE_INT, mCtx->audioEncSettings.channelsOut, |
1051 "channels", G_TYPE_INT, mCtx->audioEncSettings.channelsOut, |
1057 NULL), |
1052 NULL), |
1058 gst_structure_new("audio/x-raw-float", |
1053 gst_structure_new("audio/x-raw-float", |
1059 "channels", G_TYPE_INT, mCtx->audioEncSettings.channelsOut, |
1054 "channels", G_TYPE_INT, mCtx->audioEncSettings.channelsOut, |
1060 "width", G_TYPE_INT, mCtx->audioEncSettings.bitsPerSample, |
1055 "width", G_TYPE_INT, mCtx->audioEncSettings.bitsPerSample, |
1061 "rate", G_TYPE_INT , mCtx->audioEncSettings.sampleRate / 1000, |
1056 "rate", G_TYPE_INT , mCtx->audioEncSettings.sampleRate / 1000, |
1062 NULL), |
1057 NULL), |
1063 NULL); |
1058 NULL); |
1064 DEBUG_INFO_A1("new audio encoder config from settings: %s",gst_caps_to_string(encSrcCaps)); |
1059 DEBUG_INFO_A1("new audio encoder config from settings: %s",gst_caps_to_string(encSrcCaps)); |
1065 g_object_set( G_OBJECT(mCtx->audiofilter), "caps",encSrcCaps,NULL); |
1060 g_object_set( G_OBJECT(mCtx->audiofilter), "caps",encSrcCaps,NULL); |
1066 |
1061 |
1067 gst_caps_unref(encSrcCaps); |
1062 gst_caps_unref(encSrcCaps); |
1068 |
1063 } |
1069 }else |
1064 else |
1070 { |
1065 { |
1071 DEBUG_ERR("cannot create caps filter"); |
1066 DEBUG_ERR("cannot create caps filter"); |
1072 return XA_RESULT_INTERNAL_ERROR; |
1067 return XA_RESULT_INTERNAL_ERROR; |
1073 } |
1068 } |
1074 |
1069 } |
1075 } |
|
1076 |
1070 |
1077 if(mCtx->isobjvsrc) |
1071 if(mCtx->isobjvsrc) |
1078 { |
1072 { |
1079 moSrc = gst_element_get_static_pad(mCtx->videosource,"MRObjSrc"); |
1073 moSrc = gst_element_get_static_pad(mCtx->videosource,"MRObjSrc"); |
1080 moSink = gst_pad_get_peer(moSrc); |
1074 moSink = gst_pad_get_peer(moSrc); |
1081 if(moSink) |
1075 if(moSink) |
1082 { |
1076 { |
1083 gst_pad_unlink(moSrc,moSink); |
1077 gst_pad_unlink(moSrc,moSink); |
1084 } |
1078 } |
1085 moSrc = gst_element_get_static_pad(mCtx->videosource,"mediaobjectsrc"); |
|
1086 encSrcCaps = gst_caps_new_simple("video/x-raw-yuv", |
1079 encSrcCaps = gst_caps_new_simple("video/x-raw-yuv", |
1087 "format", GST_TYPE_FOURCC,GST_MAKE_FOURCC('I','4','2','0'), |
1080 "format", GST_TYPE_FOURCC,GST_MAKE_FOURCC('I','4','2','0'), |
1088 "framerate", GST_TYPE_FRACTION, mCtx->videoEncSettings.frameRate, 1, |
1081 "framerate", GST_TYPE_FRACTION, mCtx->videoEncSettings.frameRate, 1, |
1089 NULL); |
1082 NULL); |
1090 DEBUG_INFO_A1("new camera encoding filter: %s",gst_caps_to_string(encSrcCaps)); |
1083 DEBUG_INFO_A1("new camera encoding filter: %s",gst_caps_to_string(encSrcCaps)); |
1091 g_object_set( G_OBJECT(mCtx->videosource), "filter-caps",encSrcCaps,NULL); |
1084 g_object_set( G_OBJECT(mCtx->videosource), "filter-caps",encSrcCaps,NULL); |
1092 gst_caps_unref(encSrcCaps); |
1085 gst_caps_unref(encSrcCaps); |
1093 } |
1086 } |
1094 |
1087 |
1095 DEBUG_INFO("Unlink and remove old encodebin"); |
1088 DEBUG_INFO("Unlink and remove old encodebin"); |
1096 asink = gst_element_get_static_pad(mCtx->codecbin,"sink"); |
1089 asink = gst_element_get_static_pad(mCtx->codecbin,"sink"); |
1097 if(asink) |
1090 if(asink) |
1098 { |
1091 { |
1099 linkedasrc = gst_pad_get_peer(asink); |
1092 linkedasrc = gst_pad_get_peer(asink); |
1100 if(linkedasrc) |
1093 if(linkedasrc) |
1101 { |
1094 { |
1102 gst_pad_unlink(linkedasrc,asink); |
1095 gst_pad_unlink(linkedasrc,asink); |
1103 } |
1096 } |
1104 } |
1097 } |
1105 vsink = gst_element_get_static_pad(mCtx->codecbin,"v_sink"); |
1098 vsink = gst_element_get_static_pad(mCtx->codecbin,"v_sink"); |
1106 if(vsink) |
1099 if(vsink) |
1107 { |
1100 { |
1108 linkedvsrc = gst_pad_get_peer(vsink); |
1101 linkedvsrc = gst_pad_get_peer(vsink); |
1109 if(linkedvsrc) |
1102 if(linkedvsrc) |
1110 { |
1103 { |
1111 gst_pad_unlink(linkedvsrc,vsink); |
1104 gst_pad_unlink(linkedvsrc,vsink); |
1112 } |
1105 } |
1113 } |
1106 } |
1114 src = gst_element_get_static_pad(mCtx->codecbin,"src"); |
1107 src = gst_element_get_static_pad(mCtx->codecbin,"src"); |
1115 if(src) |
1108 if(src) |
1116 { |
1109 { |
1117 linkedsink = gst_pad_get_peer(src); |
1110 linkedsink = gst_pad_get_peer(src); |
1118 if(linkedsink) |
1111 if(linkedsink) |
1119 { |
1112 { |
1120 gst_pad_unlink(src,linkedsink); |
1113 gst_pad_unlink(src,linkedsink); |
1121 } |
1114 } |
1122 } |
1115 } |
1123 |
1116 |
1124 gst_element_set_state( GST_ELEMENT(mCtx->codecbin), GST_STATE_NULL ); |
1117 gst_element_set_state( GST_ELEMENT(mCtx->codecbin), GST_STATE_NULL ); |
1125 gst_element_get_state( GST_ELEMENT(mCtx->codecbin),NULL,NULL,1000 ); |
1118 gst_element_get_state( GST_ELEMENT(mCtx->codecbin),NULL,NULL,1000 ); |
1126 gst_bin_remove( GST_BIN(bCtx->bin), mCtx->codecbin ); |
1119 gst_bin_remove( GST_BIN(bCtx->bin), mCtx->codecbin ); |
1127 /*reset filesink too*/ |
1120 /*reset filesink too*/ |
1134 gst_bin_add(GST_BIN(bCtx->bin), mCtx->codecbin); |
1127 gst_bin_add(GST_BIN(bCtx->bin), mCtx->codecbin); |
1135 asink = gst_element_get_static_pad(mCtx->codecbin,"sink"); |
1128 asink = gst_element_get_static_pad(mCtx->codecbin,"sink"); |
1136 afiltsink = gst_element_get_static_pad(mCtx->audiofilter,"sink"); |
1129 afiltsink = gst_element_get_static_pad(mCtx->audiofilter,"sink"); |
1137 afiltsrc = gst_element_get_static_pad(mCtx->audiofilter,"src"); |
1130 afiltsrc = gst_element_get_static_pad(mCtx->audiofilter,"src"); |
1138 if(linkedasrc && afiltsink) |
1131 if(linkedasrc && afiltsink) |
1139 { |
1132 { |
1140 if(gst_pad_link(linkedasrc , afiltsink ) != GST_PAD_LINK_OK) |
1133 if(gst_pad_link(linkedasrc , afiltsink ) != GST_PAD_LINK_OK) |
1141 { |
1134 { |
1142 DEBUG_ERR("Could not link audiosource to audiofilter!!"); |
1135 DEBUG_ERR("Could not link audiosource to audiofilter!!"); |
1143 return XA_RESULT_INTERNAL_ERROR; |
1136 return XA_RESULT_INTERNAL_ERROR; |
1144 } |
1137 } |
1145 } |
1138 } |
1146 if(asink && afiltsrc) |
1139 if(asink && afiltsrc) |
1147 { |
1140 { |
1148 if(gst_pad_link(afiltsrc , asink) != GST_PAD_LINK_OK) |
1141 if(gst_pad_link(afiltsrc , asink) != GST_PAD_LINK_OK) |
1149 { |
1142 { |
1150 DEBUG_ERR("Could not link audiosource to audiofilter!!"); |
1143 DEBUG_ERR("Could not link audiosource to audiofilter!!"); |
1151 return XA_RESULT_INTERNAL_ERROR; |
1144 return XA_RESULT_INTERNAL_ERROR; |
1152 } |
1145 } |
1153 } |
1146 } |
1154 vsink = gst_element_get_static_pad(mCtx->codecbin,"v_sink"); |
1147 vsink = gst_element_get_static_pad(mCtx->codecbin,"v_sink"); |
1155 if(vsink && linkedvsrc) |
1148 if(vsink && linkedvsrc) |
1156 { |
1149 { |
1157 if(gst_pad_link(linkedvsrc,vsink) != GST_PAD_LINK_OK) |
1150 if(gst_pad_link(linkedvsrc,vsink) != GST_PAD_LINK_OK) |
1158 { |
1151 { |
1159 DEBUG_ERR("Could not link linkedvsrc to vsink!!"); |
1152 DEBUG_ERR("Could not link linkedvsrc to vsink!!"); |
1160 return XA_RESULT_INTERNAL_ERROR; |
1153 return XA_RESULT_INTERNAL_ERROR; |
1161 } |
1154 } |
1162 } |
1155 } |
1163 src = gst_element_get_static_pad(mCtx->codecbin,"src"); |
1156 src = gst_element_get_static_pad(mCtx->codecbin,"src"); |
1164 if(src && linkedsink) |
1157 if(src && linkedsink) |
1165 { |
1158 { |
1166 if(gst_pad_link(src,linkedsink) != GST_PAD_LINK_OK) |
1159 if(gst_pad_link(src,linkedsink) != GST_PAD_LINK_OK) |
1167 { |
1160 { |
1168 DEBUG_ERR("Could not link codecbin src pad to linkedsink!!"); |
1161 DEBUG_ERR("Could not link codecbin src pad to linkedsink!!"); |
1169 return XA_RESULT_INTERNAL_ERROR; |
1162 return XA_RESULT_INTERNAL_ERROR; |
1170 } |
1163 } |
1171 } |
1164 } |
1172 |
1165 |
1173 if(mCtx->isobjvsrc) |
1166 if(mCtx->isobjvsrc) |
1174 { |
1167 { |
1175 moSrc = gst_element_get_static_pad(mCtx->videosource,"MRObjSrc"); |
1168 moSrc = gst_element_get_static_pad(mCtx->videosource,"MRObjSrc"); |
1176 if(moSink&&moSrc) |
1169 if(moSink&&moSrc) |
|
1170 { |
|
1171 if(gst_pad_link(moSrc,moSink) != GST_PAD_LINK_OK) |
1177 { |
1172 { |
1178 if(gst_pad_link(moSrc,moSink) != GST_PAD_LINK_OK) |
1173 DEBUG_ERR("Could not link codecbin src pad to linkedsink!!"); |
1179 { |
1174 return XA_RESULT_INTERNAL_ERROR; |
1180 DEBUG_ERR("Could not link codecbin src pad to linkedsink!!"); |
|
1181 return XA_RESULT_INTERNAL_ERROR; |
|
1182 } |
|
1183 } |
1175 } |
1184 } |
1176 } |
1185 |
1177 } |
1186 |
1178 |
|
1179 |
1187 //setting the Bitrate and other properties for elements |
1180 //setting the Bitrate and other properties for elements |
1188 if(mCtx->audioEncSettings.encoderId == XA_AUDIOCODEC_AAC) |
1181 if(mCtx->audioEncSettings.encoderId == XA_AUDIOCODEC_AAC) |
1189 { |
1182 { |
1190 encoderelement = gst_bin_get_by_name((GstBin*)mCtx->codecbin, "audioenc") ; |
1183 encoderelement = gst_bin_get_by_name((GstBin*)mCtx->codecbin, "audioenc") ; |
1191 if(encoderelement){ |
1184 if(encoderelement) |
1192 g_object_set(G_OBJECT(encoderelement),"bitrate" , mCtx->audioEncSettings.bitRate , NULL ); |
1185 { |
1193 g_object_set(G_OBJECT(encoderelement),"profile", mCtx->audioEncSettings.levelSetting , NULL ); |
1186 g_object_set(G_OBJECT(encoderelement),"bitrate" , mCtx->audioEncSettings.bitRate , NULL ); |
1194 g_object_set(G_OBJECT(encoderelement),"output-format", mCtx->audioEncSettings.streamFormat , NULL ); |
1187 g_object_set(G_OBJECT(encoderelement),"profile", mCtx->audioEncSettings.levelSetting , NULL ); |
1195 gst_object_unref (encoderelement); |
1188 g_object_set(G_OBJECT(encoderelement),"output-format", mCtx->audioEncSettings.streamFormat , NULL ); |
1196 }else |
1189 gst_object_unref (encoderelement); |
1197 DEBUG_ERR("Encoder Element not found for AAC"); |
1190 } |
1198 } |
1191 else |
1199 else if(mCtx->audioEncSettings.encoderId == XA_AUDIOCODEC_AMR) |
1192 { |
1200 { |
1193 DEBUG_ERR("Encoder Element not found for AAC"); |
1201 g_object_set(G_OBJECT(mCtx->audiosource),"speechbitrate", mCtx->audioEncSettings.bitRate , NULL ); |
1194 } |
1202 } |
1195 } |
1203 else |
1196 else if(mCtx->audioEncSettings.encoderId == XA_AUDIOCODEC_AMR) |
1204 { |
1197 { |
1205 DEBUG_INFO("No properties for PCM or Wav") |
1198 g_object_set(G_OBJECT(mCtx->audiosource),"speechbitrate", mCtx->audioEncSettings.bitRate , NULL ); |
1206 } |
1199 } |
1207 |
1200 else |
|
1201 { |
|
1202 DEBUG_INFO("No properties for PCM or Wav") |
|
1203 } |
|
1204 |
1208 /*re-roll*/ |
1205 /*re-roll*/ |
1209 DEBUG_INFO("Reroll pipeline"); |
1206 DEBUG_INFO("Reroll pipeline"); |
1210 bCtx->binWantedState = GST_STATE_PAUSED; |
1207 bCtx->binWantedState = GST_STATE_PAUSED; |
1211 gret = gst_element_set_state( GST_ELEMENT(bCtx->bin), bCtx->binWantedState); |
1208 gret = gst_element_set_state( GST_ELEMENT(bCtx->bin), bCtx->binWantedState); |
1212 if( gret == GST_STATE_CHANGE_ASYNC ) |
1209 if( gret == GST_STATE_CHANGE_ASYNC ) |
1213 { |
1210 { |
1214 DEBUG_INFO("Wait for reroll"); |
1211 DEBUG_INFO("Wait for reroll"); |
1215 XAAdaptationGst_StartAsyncWait(bCtx); |
1212 XAAdaptationGst_StartAsyncWait(bCtx); |
1216 } |
1213 } |
1217 else if( gret == GST_STATE_CHANGE_FAILURE ) |
1214 else if( gret == GST_STATE_CHANGE_FAILURE ) |
1218 { |
1215 { |
1219 DEBUG_ERR("reroll FAILED"); |
1216 DEBUG_ERR("reroll FAILED"); |
1220 ret = XA_RESULT_INTERNAL_ERROR; |
1217 ret = XA_RESULT_INTERNAL_ERROR; |
1221 } |
1218 } |
1222 bCtx->waitingasyncop = XA_BOOLEAN_FALSE; |
1219 bCtx->waitingasyncop = XA_BOOLEAN_FALSE; |
1223 DEBUG_INFO_A1("Pipeline in state %s",gst_element_state_get_name(GST_STATE(bCtx->bin))); |
1220 DEBUG_INFO_A1("Pipeline in state %s",gst_element_state_get_name(GST_STATE(bCtx->bin))); |
1224 } |
1221 } |
1225 else |
1222 else |
1226 { |
1223 { |
1227 /* could not support wanted encoders */ |
1224 /* could not support wanted encoders */ |
1228 DEBUG_ERR("Failed to create encodebin with new settings, using old one!"); |
1225 DEBUG_ERR("Failed to create encodebin with new settings, using old one!"); |
1229 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
1226 ret = XA_RESULT_FEATURE_UNSUPPORTED; |
1230 } |
1227 } |
1231 } |
1228 } |
1232 else |
1229 else |
1233 { /* n/a while playing */ |
1230 { /* n/a while playing */ |
1234 DEBUG_ERR("Cannot change encoder when recording ongoing!"); |
1231 DEBUG_ERR("Cannot change encoder when recording ongoing!"); |
1235 ret = XA_RESULT_PRECONDITIONS_VIOLATED; |
1232 ret = XA_RESULT_PRECONDITIONS_VIOLATED; |
1236 } |
1233 } |
1237 DEBUG_API("<-XAMediaRecorderAdapt_ChangeEncoders"); |
1234 DEBUG_API("<-XAMediaRecorderAdapt_ChangeEncoders"); |
1238 return ret; |
1235 return ret; |
1239 } |
1236 } |
1240 |
1237 |
1241 /** |
1238 /** |
1242 * GstElement* XAMediaRecorderAdapt_CreateEncodeBin( XAMediaRecorderAdaptationCtx* ctx ) |
1239 * GstElement* XAMediaRecorderAdapt_CreateEncodeBin( XAMediaRecorderAdaptationCtx* ctx ) |
1243 * @return GstElement* - pointer to created bin element |
1240 * @return GstElement* - pointer to created bin element |
1244 * Decription: Create encoder/muxer element based on given format and encoder settings |
1241 * Decription: Create encoder/muxer element based on given format and encoder settings |
1245 */ |
1242 */ |
1246 GstElement* XAMediaRecorderAdapt_CreateEncodeBin( XAMediaRecorderAdaptationCtx* ctx ) |
1243 GstElement* XAMediaRecorderAdapt_CreateEncodeBin( XAMediaRecorderAdaptationCtx* ctx ) |
1247 { |
1244 { |
1248 XAresult ret = XA_RESULT_SUCCESS; |
1245 XAresult ret = XA_RESULT_SUCCESS; |
1249 GstElement *audioenc = NULL, *videoenc=NULL, *mux=NULL; |
1246 GstElement *audioenc = NULL, *videoenc=NULL, *mux=NULL; |
1250 GstElement *codecbin = gst_bin_new( "mrcodecbin" ); |
1247 GstElement *codecbin = gst_bin_new( "mrcodecbin" ); |
1251 GstPad *ghostsrc = NULL, *ghostaudiosink = NULL, *ghostvideosink = NULL; |
1248 GstPad *ghostsrc = NULL, *ghostaudiosink = NULL, *ghostvideosink = NULL; |
1252 XAuint32 format; |
1249 XAuint32 format; |
1253 XACapabilities temp; |
1250 XACapabilities temp; |
1254 |
1251 |
1255 DEBUG_API("->XAMediaRecorderAdapt_CreateEncodeBin"); |
1252 DEBUG_API("->XAMediaRecorderAdapt_CreateEncodeBin"); |
1256 if(ctx->recModes & XA_RECMODE_STREAM) |
1253 if(ctx->recModes & XA_RECMODE_STREAM) |
1257 { |
1254 { |
1258 if(ctx->xaSink && ctx->xaSink->pFormat) |
1255 if(ctx->xaSink && ctx->xaSink->pFormat) |
1259 { |
1256 { |
1260 format = *(XAuint32*)(ctx->xaSink->pFormat); |
1257 format = *(XAuint32*)(ctx->xaSink->pFormat); |
1261 switch ( format ) |
1258 switch ( format ) |
1262 { |
1259 { |
1263 case XA_DATAFORMAT_PCM: |
1260 case XA_DATAFORMAT_PCM: |
1264 DEBUG_INFO("XA_DATAFORMAT_PCM"); |
1261 DEBUG_INFO("XA_DATAFORMAT_PCM"); |
1265 { |
1262 { |
1266 XADataFormat_PCM* pcm = ((XADataFormat_PCM*)ctx->xaSink->pFormat); |
1263 XADataFormat_PCM* pcm = ((XADataFormat_PCM*)ctx->xaSink->pFormat); |
1267 if(!ctx->xaAudioSource) |
1264 if(!ctx->xaAudioSource) |
1268 { |
1265 { |
1269 DEBUG_ERR("Unsupported dataformat for given data sources"); |
1266 DEBUG_ERR("Unsupported dataformat for given data sources"); |
1270 return NULL; |
1267 return NULL; |
1271 } |
1268 } |
1272 /* no need for codec, just pass data on */ |
1269 /* no need for codec, just pass data on */ |
1273 mux = gst_element_factory_make("identity", "mux"); |
1270 mux = gst_element_factory_make("identity", "mux"); |
1274 gst_bin_add(GST_BIN(codecbin), mux); |
1271 gst_bin_add(GST_BIN(codecbin), mux); |
1275 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1272 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1276 ghostaudiosink = gst_element_get_static_pad(mux,"sink"); |
1273 ghostaudiosink = gst_element_get_static_pad(mux,"sink"); |
1277 /*set usable audio settings from the sink structure*/ |
1274 /*set usable audio settings from the sink structure*/ |
1278 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_PCM; |
1275 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_PCM; |
1279 ctx->audioEncSettings.channelsOut = pcm->numChannels; |
1276 ctx->audioEncSettings.channelsOut = pcm->numChannels; |
1280 ctx->audioEncSettings.bitsPerSample = pcm->bitsPerSample; |
1277 ctx->audioEncSettings.bitsPerSample = pcm->bitsPerSample; |
1281 } |
1278 } |
1282 break; |
1279 break; |
1283 |
1280 |
1284 case XA_DATAFORMAT_RAWIMAGE: |
1281 case XA_DATAFORMAT_RAWIMAGE: |
1285 DEBUG_INFO("XA_DATAFORMAT_RAWIMAGE"); |
1282 DEBUG_INFO("XA_DATAFORMAT_RAWIMAGE"); |
1286 { |
1283 { |
1287 XADataFormat_RawImage* img = ((XADataFormat_RawImage*)ctx->xaSink->pFormat); |
1284 XADataFormat_RawImage* img = ((XADataFormat_RawImage*)ctx->xaSink->pFormat); |
1288 if(!ctx->xaVideoSource) |
1285 if(!ctx->xaVideoSource) |
1289 { |
1286 { |
1290 DEBUG_ERR("Unsupported dataformat for given data sources"); |
1287 DEBUG_ERR("Unsupported dataformat for given data sources"); |
1291 return NULL; |
1288 return NULL; |
1292 } |
1289 } |
1293 /* no need for codec, just pass data on */ |
1290 /* no need for codec, just pass data on */ |
1294 mux = gst_element_factory_make("identity", "mux"); |
1291 mux = gst_element_factory_make("identity", "mux"); |
1295 gst_bin_add(GST_BIN(codecbin), mux); |
1292 gst_bin_add(GST_BIN(codecbin), mux); |
1296 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1293 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1297 ghostvideosink = gst_element_get_static_pad(mux,"sink"); |
1294 ghostvideosink = gst_element_get_static_pad(mux,"sink"); |
1298 /*set needed image settings from the sink structure*/ |
1295 /*set needed image settings from the sink structure*/ |
1299 ctx->imageEncSettings.encoderId = XA_IMAGECODEC_RAW; |
1296 ctx->imageEncSettings.encoderId = XA_IMAGECODEC_RAW; |
1300 ctx->imageEncSettings.width = img->width; |
1297 ctx->imageEncSettings.width = img->width; |
1301 ctx->imageEncSettings.height = img->height; |
1298 ctx->imageEncSettings.height = img->height; |
1302 ctx->imageEncSettings.colorFormat = img->colorFormat; |
1299 ctx->imageEncSettings.colorFormat = img->colorFormat; |
1303 } |
1300 } |
1304 break; |
1301 break; |
1305 |
1302 |
1306 case XA_DATAFORMAT_MIME: |
1303 case XA_DATAFORMAT_MIME: |
1307 DEBUG_INFO("XA_DATAFORMAT_MIME "); |
1304 DEBUG_INFO("XA_DATAFORMAT_MIME "); |
1308 { |
1305 { |
1309 XADataFormat_MIME* mime = ((XADataFormat_MIME*)ctx->xaSink->pFormat); |
1306 XADataFormat_MIME* mime = ((XADataFormat_MIME*)ctx->xaSink->pFormat); |
1310 DEBUG_INFO_A1("mime->containerType:%u",(int)mime->containerType); |
1307 DEBUG_INFO_A1("mime->containerType:%u",(int)mime->containerType); |
1311 DEBUG_INFO_A1("mime->mimeType:%s",mime->mimeType); |
1308 DEBUG_INFO_A1("mime->mimeType:%s",mime->mimeType); |
1312 switch ( mime->containerType ) |
1309 switch ( mime->containerType ) |
1313 { |
1310 { |
1314 case XA_CONTAINERTYPE_AVI: |
1311 case XA_CONTAINERTYPE_AVI: |
1315 DEBUG_INFO("XA_CONTAINERTYPE_AVI"); |
1312 DEBUG_INFO("XA_CONTAINERTYPE_AVI"); |
1316 mux = gst_element_factory_make("avimux", "mux"); |
1313 mux = gst_element_factory_make("avimux", "mux"); |
1317 if(mux) |
1314 if(mux) |
1318 { |
1315 { |
1319 if (gst_bin_add(GST_BIN(codecbin), mux)) |
1316 if (gst_bin_add(GST_BIN(codecbin), mux)) |
1320 { |
1317 { |
1321 DEBUG_INFO("Added mux to codecbin"); |
1318 DEBUG_INFO("Added mux to codecbin"); |
1322 } |
1319 } |
1323 else |
1320 else |
1324 { |
1321 { |
1325 DEBUG_ERR("Could not add mux to codecbin"); |
1322 DEBUG_ERR("Could not add mux to codecbin"); |
1326 return NULL; |
1323 return NULL; |
1327 } |
1324 } |
1328 /*use this as linkpoint*/ |
1325 /*use this as linkpoint*/ |
1329 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1326 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1330 } |
1327 } |
1331 /* Add and link audio/video codecs */ |
1328 /* Add and link audio/video codecs */ |
1332 /*set video defaults*/ |
1329 /*set video defaults*/ |
1333 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1330 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1334 ctx->videoEncSettings.encoderId = XA_ADAPTID_MOTIONJPEG; |
1331 ctx->videoEncSettings.encoderId = XA_ADAPTID_MOTIONJPEG; |
1335 if(ctx->xaVideoSource) |
1332 if(ctx->xaVideoSource) |
1336 { |
1333 { |
1337 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
1334 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
|
1335 { |
|
1336 if(temp.adaptId) |
1338 { |
1337 { |
1339 if(temp.adaptId) |
|
1340 { |
|
1341 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1338 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1342 } |
|
1343 } |
1339 } |
|
1340 } |
1344 if(videoenc) |
1341 if(videoenc) |
1345 { |
1342 { |
1346 gst_bin_add(GST_BIN(codecbin), videoenc); |
1343 gst_bin_add(GST_BIN(codecbin), videoenc); |
1347 if(!gst_element_link(videoenc, mux)) |
1344 if(!gst_element_link(videoenc, mux)) |
1348 { |
1345 { |
1349 DEBUG_ERR("Could not link videoenc to mux!!"); |
1346 DEBUG_ERR("Could not link videoenc to mux!!"); |
1350 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1347 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1351 return NULL; |
1348 return NULL; |
1352 } |
1349 } |
1353 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1350 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1354 } |
1351 } |
1355 else |
1352 else |
1356 { |
1353 { |
1357 /*no video codec but video source = raw video case, request video pad directly from mux*/ |
1354 /*no video codec but video source = raw video case, request video pad directly from mux*/ |
1358 ghostvideosink = gst_element_get_request_pad(mux,"video_%d"); |
1355 ghostvideosink = gst_element_get_request_pad(mux,"video_%d"); |
1359 } |
1356 } |
1360 } |
1357 } |
1361 /*set audio defaults*/ |
1358 /*set audio defaults*/ |
1362 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1359 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1363 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_PCM; |
1360 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_PCM; |
1364 if(ctx->xaAudioSource) |
1361 if(ctx->xaAudioSource) |
1365 { |
1362 { |
1366 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_AUDIO), ctx->audioEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
1363 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_AUDIO), ctx->audioEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
|
1364 { |
|
1365 if(temp.adaptId) |
1367 { |
1366 { |
1368 if(temp.adaptId) |
|
1369 { |
|
1370 audioenc = gst_element_factory_make((char*)temp.adaptId, "audioenc"); |
1367 audioenc = gst_element_factory_make((char*)temp.adaptId, "audioenc"); |
1371 } |
|
1372 } |
1368 } |
|
1369 } |
1373 if(audioenc) |
1370 if(audioenc) |
1374 { |
1371 { |
1375 gst_bin_add(GST_BIN(codecbin), audioenc); |
1372 gst_bin_add(GST_BIN(codecbin), audioenc); |
1376 if(!gst_element_link(audioenc, mux)) |
1373 if(!gst_element_link(audioenc, mux)) |
1377 { |
1374 { |
1378 DEBUG_ERR("Could not link audioenc to mux!!"); |
1375 DEBUG_ERR("Could not link audioenc to mux!!"); |
1379 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1376 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1380 return NULL; |
1377 return NULL; |
1381 } |
1378 } |
1382 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1379 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1383 } |
1380 } |
1384 else |
1381 else |
1385 { |
1382 { |
1386 /*no audio codec but audio source = PCM case, explicity request audio pad*/ |
1383 /*no audio codec but audio source = PCM case, explicity request audio pad*/ |
1387 ghostaudiosink = gst_element_get_request_pad(mux,"audio_%d"); |
1384 ghostaudiosink = gst_element_get_request_pad(mux,"audio_%d"); |
1388 } |
1385 } |
1389 } |
1386 } |
1390 break; |
1387 break; |
1391 |
1388 |
1392 case XA_CONTAINERTYPE_WAV: |
1389 case XA_CONTAINERTYPE_WAV: |
1393 DEBUG_INFO("XA_CONTAINERTYPE_WAV"); |
1390 DEBUG_INFO("XA_CONTAINERTYPE_WAV"); |
1394 audioenc = gst_element_factory_make("wavenc", "audioenc"); |
1391 audioenc = gst_element_factory_make("wavenc", "audioenc"); |
1395 if(audioenc) |
1392 if(audioenc) |
1396 { |
1393 { |
1397 if (gst_bin_add(GST_BIN(codecbin), audioenc)) |
1394 if (gst_bin_add(GST_BIN(codecbin), audioenc)) |
1398 { |
1395 { |
1399 DEBUG_INFO("added audioenc to codecbin"); |
1396 DEBUG_INFO("added audioenc to codecbin"); |
1400 } |
1397 } |
1401 else |
1398 else |
1402 { |
1399 { |
1403 DEBUG_ERR("Could not add audioenc to codecbin"); |
1400 DEBUG_ERR("Could not add audioenc to codecbin"); |
1404 return NULL; |
1401 return NULL; |
1405 } |
1402 } |
1406 /*use this as linkpoint*/ |
1403 /*use this as linkpoint*/ |
1407 ghostsrc = gst_element_get_static_pad(audioenc,"src"); |
1404 ghostsrc = gst_element_get_static_pad(audioenc,"src"); |
1408 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1405 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1409 if ( ghostsrc == NULL || ghostaudiosink == NULL) |
1406 if ( ghostsrc == NULL || ghostaudiosink == NULL) |
1410 { |
1407 { |
1411 DEBUG_ERR("Could not get src or sink ghoset element(s)"); |
1408 DEBUG_ERR("Could not get src or sink ghoset element(s)"); |
1412 return NULL; |
1409 return NULL; |
1413 } |
1410 } |
1414 } |
1411 } |
1415 /* no other codecs needed */ |
1412 /* no other codecs needed */ |
1416 break; |
1413 break; |
1417 case XA_CONTAINERTYPE_JPG: |
1414 case XA_CONTAINERTYPE_JPG: |
1418 /*motion jpeg*/ |
1415 /*motion jpeg*/ |
1419 DEBUG_INFO("XA_CONTAINERTYPE_JPG"); |
1416 DEBUG_INFO("XA_CONTAINERTYPE_JPG"); |
1420 /*set defaults*/ |
1417 /*set defaults*/ |
1421 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1418 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1422 ctx->videoEncSettings.encoderId = XA_ADAPTID_MOTIONJPEG; |
1419 ctx->videoEncSettings.encoderId = XA_ADAPTID_MOTIONJPEG; |
1423 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
1420 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
1424 { |
1421 { |
1425 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1422 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1426 } |
1423 } |
1427 if(videoenc) |
1424 if(videoenc) |
1428 { |
1425 { |
1429 gst_bin_add(GST_BIN(codecbin), videoenc); |
1426 gst_bin_add(GST_BIN(codecbin), videoenc); |
1430 /*use this as linkpoint*/ |
1427 /*use this as linkpoint*/ |
1431 ghostsrc = gst_element_get_static_pad(videoenc,"src"); |
1428 ghostsrc = gst_element_get_static_pad(videoenc,"src"); |
1432 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1429 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1433 } |
1430 } |
1434 /* no other codecs needed */ |
1431 /* no other codecs needed */ |
1435 break; |
1432 break; |
1436 case XA_CONTAINERTYPE_RAW: |
1433 case XA_CONTAINERTYPE_RAW: |
1437 DEBUG_INFO("XA_CONTAINERTYPE_RAW"); |
1434 DEBUG_INFO("XA_CONTAINERTYPE_RAW"); |
1438 /* no need for codec, just pass data on */ |
1435 /* no need for codec, just pass data on */ |
1439 if(strncmp((char *)mime->mimeType, "video", 5) == 0 && ctx->xaVideoSource) |
1436 if(strncmp((char *)mime->mimeType, "video", 5) == 0 && ctx->xaVideoSource) |
1440 { |
1437 { |
1441 mux = gst_element_factory_make("identity", "mux"); |
1438 mux = gst_element_factory_make("identity", "mux"); |
1442 gst_bin_add(GST_BIN(codecbin), mux); |
1439 gst_bin_add(GST_BIN(codecbin), mux); |
1443 ghostvideosink = gst_element_get_static_pad(mux,"sink"); |
1440 ghostvideosink = gst_element_get_static_pad(mux,"sink"); |
1444 } |
1441 } |
1445 else if (strncmp((char *)mime->mimeType, "audio", 5) == 0 && ctx->xaAudioSource) |
1442 else if (strncmp((char *)mime->mimeType, "audio", 5) == 0 && ctx->xaAudioSource) |
1446 { |
1443 { |
1447 mux = gst_element_factory_make("identity", "mux"); |
1444 mux = gst_element_factory_make("identity", "mux"); |
1448 gst_bin_add(GST_BIN(codecbin), mux); |
1445 gst_bin_add(GST_BIN(codecbin), mux); |
1449 ghostaudiosink = gst_element_get_static_pad(mux,"sink"); |
1446 ghostaudiosink = gst_element_get_static_pad(mux,"sink"); |
1450 } |
1447 } |
1451 else |
1448 else |
1452 { |
1449 { |
1453 ret = XA_RESULT_CONTENT_UNSUPPORTED; |
1450 ret = XA_RESULT_CONTENT_UNSUPPORTED; |
1454 DEBUG_ERR("Content mismatch with given sources!!!") |
1451 DEBUG_ERR("Content mismatch with given sources!!!") |
1455 } |
1452 } |
1456 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1453 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1457 break; |
1454 break; |
1458 case XA_CONTAINERTYPE_UNSPECIFIED: |
1455 case XA_CONTAINERTYPE_UNSPECIFIED: |
1459 DEBUG_INFO("No support for requested encoder...try to select encoder from mime string"); |
1456 DEBUG_INFO("No support for requested encoder...try to select encoder from mime string"); |
1460 if(strstr( (char *) mime->mimeType, "/ogg") != 0) |
1457 if(strstr( (char *) mime->mimeType, "/ogg") != 0) |
1461 { |
1458 { |
1462 DEBUG_INFO("XA_CONTAINERTYPE_UNSPECIFIED - mimetype ogg detected"); |
1459 DEBUG_INFO("XA_CONTAINERTYPE_UNSPECIFIED - mimetype ogg detected"); |
1463 mux = gst_element_factory_make("oggmux", "mux"); |
1460 mux = gst_element_factory_make("oggmux", "mux"); |
1464 if(mux) |
1461 if(mux) |
1465 { |
1462 { |
1466 gst_bin_add(GST_BIN(codecbin), mux); |
1463 gst_bin_add(GST_BIN(codecbin), mux); |
1467 /*use this as linkpoint*/ |
1464 /*use this as linkpoint*/ |
1468 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1465 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1469 /*set defaults*/ |
1466 /*set defaults*/ |
1470 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1467 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1471 { |
1468 { |
1472 ctx->audioEncSettings.encoderId = XA_ADAPTID_VORBIS; |
1469 ctx->audioEncSettings.encoderId = XA_ADAPTID_VORBIS; |
1473 ctx->audioEncSettings.bitsPerSample=32; |
1470 ctx->audioEncSettings.bitsPerSample=32; |
|
1471 } |
|
1472 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
|
1473 { |
|
1474 ctx->videoEncSettings.encoderId = XA_ADAPTID_THEORA; |
|
1475 } |
|
1476 if(ctx->xaAudioSource) |
|
1477 { |
|
1478 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_AUDIO), ctx->audioEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
|
1479 { |
|
1480 audioenc = gst_element_factory_make((char*)temp.adaptId, "audioenc"); |
1474 } |
1481 } |
1475 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1482 if(audioenc) |
1476 { |
1483 { |
1477 ctx->videoEncSettings.encoderId = XA_ADAPTID_THEORA; |
|
1478 } |
|
1479 if(ctx->xaAudioSource) |
|
1480 { |
|
1481 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_AUDIO), ctx->audioEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
|
1482 { |
|
1483 audioenc = gst_element_factory_make((char*)temp.adaptId, "audioenc"); |
|
1484 } |
|
1485 if(audioenc) |
|
1486 { |
|
1487 gst_bin_add(GST_BIN(codecbin), audioenc); |
1484 gst_bin_add(GST_BIN(codecbin), audioenc); |
1488 if(!gst_element_link(audioenc, mux)) |
1485 if(!gst_element_link(audioenc, mux)) |
1489 { |
1486 { |
1490 DEBUG_ERR("Could not link audioenc to mux!!"); |
1487 DEBUG_ERR("Could not link audioenc to mux!!"); |
1491 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1488 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1492 return NULL; |
1489 return NULL; |
1493 } |
1490 } |
1494 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1491 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1495 } |
|
1496 } |
1492 } |
|
1493 } |
1497 if(strncmp((char *)mime->mimeType, "video", 5) == 0 && ctx->xaVideoSource) |
1494 if(strncmp((char *)mime->mimeType, "video", 5) == 0 && ctx->xaVideoSource) |
|
1495 { |
|
1496 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
1498 { |
1497 { |
1499 if(XACapabilitiesMgr_GetCapsById(NULL, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
|
1500 { |
|
1501 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1498 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1502 } |
1499 } |
1503 if(videoenc) |
1500 if(videoenc) |
1504 { |
1501 { |
1505 gst_bin_add(GST_BIN(codecbin), videoenc); |
1502 gst_bin_add(GST_BIN(codecbin), videoenc); |
1506 if(!gst_element_link(videoenc, mux)) |
1503 if(!gst_element_link(videoenc, mux)) |
1507 { |
1504 { |
1508 DEBUG_ERR("Could not link videoenc to mux!!"); |
1505 DEBUG_ERR("Could not link videoenc to mux!!"); |
1509 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1506 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1510 return NULL; |
1507 return NULL; |
1511 } |
1508 } |
1512 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1509 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1513 } |
|
1514 } |
1510 } |
1515 } |
1511 } |
1516 } |
1512 } |
|
1513 } |
1517 else |
1514 else |
1518 { |
1515 { |
1519 DEBUG_INFO("No support for requested mime/container type."); |
1516 DEBUG_INFO("No support for requested mime/container type."); |
1520 ret = XA_RESULT_CONTENT_UNSUPPORTED; |
1517 ret = XA_RESULT_CONTENT_UNSUPPORTED; |
1521 } |
1518 } |
1522 break; |
1519 break; |
1523 case XA_CONTAINERTYPE_MOBILE_DLS: |
1520 case XA_CONTAINERTYPE_MOBILE_DLS: |
1524 case XA_CONTAINERTYPE_MP4: |
1521 case XA_CONTAINERTYPE_MP4: |
1525 DEBUG_INFO("XA_CONTAINERTYPE_MP4"); |
1522 DEBUG_INFO("XA_CONTAINERTYPE_MP4"); |
1526 mux = gst_element_factory_make("mp4mux", "mp4mux"); |
1523 mux = gst_element_factory_make("mp4mux", "mp4mux"); |
1527 if(mux) |
1524 if(mux) |
1528 { |
1525 { |
1529 if (gst_bin_add(GST_BIN(codecbin), mux)) |
1526 if (gst_bin_add(GST_BIN(codecbin), mux)) |
1530 { |
1527 { |
1531 DEBUG_INFO("Added mux to codecbin"); |
1528 DEBUG_INFO("Added mux to codecbin"); |
1532 } |
1529 } |
1533 else |
1530 else |
1534 { |
1531 { |
1535 DEBUG_ERR("Could not add mux to codecbin"); |
1532 DEBUG_ERR("Could not add mux to codecbin"); |
1536 return NULL; |
1533 return NULL; |
1537 } |
1534 } |
1538 /*use this as linkpoint*/ |
1535 /*use this as linkpoint*/ |
1539 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1536 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1540 } |
1537 } |
1541 /* Add and link audio/video codecs */ |
1538 /* Add and link audio/video codecs */ |
1542 /*set video defaults*/ |
1539 /*set video defaults*/ |
1543 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1540 if(ctx->videoEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1544 ctx->videoEncSettings.encoderId = XA_ADAPTID_MOTIONJPEG; |
1541 ctx->videoEncSettings.encoderId = XA_ADAPTID_MOTIONJPEG; |
1545 if(ctx->xaVideoSource) |
1542 if(ctx->xaVideoSource) |
1546 { |
1543 { |
1547 if(XACapabilitiesMgr_GetCapsById(ctx->baseObj.baseObj.capslist, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
1544 if(XACapabilitiesMgr_GetCapsById(ctx->baseObj.baseObj.capslist, (XACapsType)(XACAP_ENCODER|XACAP_VIDEO), ctx->videoEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
|
1545 { |
|
1546 if(temp.adaptId) |
1548 { |
1547 { |
1549 if(temp.adaptId) |
|
1550 { |
|
1551 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1548 videoenc = gst_element_factory_make((char*)temp.adaptId, "videoenc"); |
1552 } |
|
1553 } |
1549 } |
|
1550 } |
1554 if(videoenc) |
1551 if(videoenc) |
1555 { |
1552 { |
1556 gst_bin_add(GST_BIN(codecbin), videoenc); |
1553 gst_bin_add(GST_BIN(codecbin), videoenc); |
1557 if(!gst_element_link(videoenc, mux)) |
1554 if(!gst_element_link(videoenc, mux)) |
1558 { |
1555 { |
1559 DEBUG_ERR("Could not link videoenc to mux!!"); |
1556 DEBUG_ERR("Could not link videoenc to mux!!"); |
1560 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1557 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1561 return NULL; |
1558 return NULL; |
1562 } |
1559 } |
1563 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1560 ghostvideosink = gst_element_get_static_pad(videoenc,"sink"); |
1564 } |
1561 } |
1565 else |
1562 else |
1566 { |
1563 { |
1567 /*no video codec but video source = raw video case, request video pad directly from mux*/ |
1564 /*no video codec but video source = raw video case, request video pad directly from mux*/ |
1568 ghostvideosink = gst_element_get_request_pad(mux,"video_%d"); |
1565 ghostvideosink = gst_element_get_request_pad(mux,"video_%d"); |
1569 } |
1566 } |
1570 } |
1567 } |
1571 /*set audio defaults*/ |
1568 /*set audio defaults*/ |
1572 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1569 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1573 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_AAC; |
1570 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_AAC; |
1574 if(ctx->xaAudioSource) |
1571 if(ctx->xaAudioSource) |
1575 { |
1572 { |
1576 if(XACapabilitiesMgr_GetCapsById(ctx->baseObj.baseObj.capslist, (XACapsType)(XACAP_ENCODER|XACAP_AUDIO), ctx->audioEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
1573 if(XACapabilitiesMgr_GetCapsById(ctx->baseObj.baseObj.capslist, (XACapsType)(XACAP_ENCODER|XACAP_AUDIO), ctx->audioEncSettings.encoderId, &temp) == XA_RESULT_SUCCESS) |
|
1574 { |
|
1575 if(temp.adaptId) |
1577 { |
1576 { |
1578 if(temp.adaptId) |
|
1579 { |
|
1580 audioenc = gst_element_factory_make((char*)temp.adaptId, "audioenc"); |
1577 audioenc = gst_element_factory_make((char*)temp.adaptId, "audioenc"); |
1581 } |
|
1582 } |
1578 } |
|
1579 } |
1583 if(audioenc) |
1580 if(audioenc) |
1584 { |
1581 { |
1585 // GstCaps* caps = gst_caps_new_simple((const char*)mime->mimeType, |
1582 // GstCaps* caps = gst_caps_new_simple((const char*)mime->mimeType, |
1586 // "mpegversion", G_TYPE_INT, 4, |
1583 // "mpegversion", G_TYPE_INT, 4, |
1587 // "channels", G_TYPE_INT, 1, |
1584 // "channels", G_TYPE_INT, 1, |
1588 // "rate", G_TYPE_INT, 16000, |
1585 // "rate", G_TYPE_INT, 16000, |
1589 // NULL); |
1586 // NULL); |
1590 gst_bin_add(GST_BIN(codecbin), audioenc); |
1587 gst_bin_add(GST_BIN(codecbin), audioenc); |
1591 //if(!gst_element_link_filtered(audioenc, mux,caps)) |
1588 //if(!gst_element_link_filtered(audioenc, mux,caps)) |
1592 if(!gst_element_link(audioenc, mux)) |
1589 if(!gst_element_link(audioenc, mux)) |
1593 { |
1590 { |
1594 DEBUG_ERR("Could not link audioenc to mux!!"); |
1591 DEBUG_ERR("Could not link audioenc to mux!!"); |
1595 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1592 DEBUG_API("<-XAMediaRecorderAdapt_CreateEncodeBin"); |
1596 return NULL; |
1593 return NULL; |
1597 } |
1594 } |
1598 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1595 ghostaudiosink = gst_element_get_static_pad(audioenc,"sink"); |
1599 } |
1596 } |
1600 else |
1597 else |
1601 { |
1598 { |
1602 /*no audio codec but audio source = PCM case, explicity request audio pad*/ |
1599 /*no audio codec but audio source = PCM case, explicity request audio pad*/ |
1603 ghostaudiosink = gst_element_get_request_pad(mux,"audio_%d"); |
1600 ghostaudiosink = gst_element_get_request_pad(mux,"audio_%d"); |
1604 } |
1601 } |
1605 } |
1602 } |
1606 break; |
1603 break; |
1607 case XA_CONTAINERTYPE_AMR: |
1604 case XA_CONTAINERTYPE_AMR: |
1608 DEBUG_INFO("XA_CONTAINERTYPE_AMR"); |
1605 DEBUG_INFO("XA_CONTAINERTYPE_AMR"); |
1609 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1606 if(ctx->audioEncSettings.encoderId == XA_ADAPTID_UNINITED) |
1610 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_AMR; |
1607 ctx->audioEncSettings.encoderId = XA_AUDIOCODEC_AMR; |
1611 mux = gst_element_factory_make("amrmux", "mux"); |
1608 mux = gst_element_factory_make("amrmux", "mux"); |
1612 if(mux) |
1609 if(mux) |
|
1610 { |
|
1611 if (gst_bin_add(GST_BIN(codecbin), mux)) |
1613 { |
1612 { |
1614 if (gst_bin_add(GST_BIN(codecbin), mux)) |
|
1615 { |
|
1616 DEBUG_INFO("Added mux to codecbin"); |
1613 DEBUG_INFO("Added mux to codecbin"); |
1617 /*Setting the buffer size on src since amr generates |
1614 /*Setting the buffer size on src since amr generates |
1618 * small amounts of data */ |
1615 * small amounts of data */ |
1619 g_object_set (G_OBJECT (ctx->audiosource), |
1616 g_object_set (G_OBJECT (ctx->audiosource), |
1620 "blocksize", 1280, |
1617 "blocksize", 1280, |
1621 NULL); |
1618 NULL); |
1622 } |
1619 } |
1623 else |
1620 else |
1624 { |
1621 { |
1625 DEBUG_ERR("Could not add mux to codecbin"); |
1622 DEBUG_ERR("Could not add mux to codecbin"); |
1626 return NULL; |
1623 return NULL; |
1627 } |
1624 } |
1628 /*use this as linkpoint*/ |
1625 /*use this as linkpoint*/ |
1629 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1626 ghostsrc = gst_element_get_static_pad(mux,"src"); |
1630 } |
1627 } |
1631 /*set audio defaults*/ |
1628 /*set audio defaults*/ |
1632 if(ctx->xaAudioSource) |
1629 if(ctx->xaAudioSource) |
1633 { |
1630 { |
1634 /*no audio codec but audio source = PCM case, explicity request audio pad*/ |
1631 /*no audio codec but audio source = PCM case, explicity request audio pad*/ |
1635 ghostaudiosink = gst_element_get_static_pad(mux,"sink"); |
1632 ghostaudiosink = gst_element_get_static_pad(mux,"sink"); |
1636 } |
1633 } |
1637 break; |
1634 break; |
1638 case XA_CONTAINERTYPE_3GPP: |
1635 case XA_CONTAINERTYPE_3GPP: |
1639 case XA_CONTAINERTYPE_BMP: |
1636 case XA_CONTAINERTYPE_BMP: |
1640 case XA_CONTAINERTYPE_ASF: |
1637 case XA_CONTAINERTYPE_ASF: |
1641 case XA_CONTAINERTYPE_M4A: |
1638 case XA_CONTAINERTYPE_M4A: |
1642 case XA_CONTAINERTYPE_MP3: |
1639 case XA_CONTAINERTYPE_MP3: |