summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer
diff options
context:
space:
mode:
authordoursse <doursse>2008-05-15 16:52:04 +0000
committerdoursse <doursse@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>2008-05-15 16:52:04 +0000
commitcaea856117d54e4b2c46113ce42d62b15c9b3c26 (patch)
treedbd997b5a799b420c90c7b7827a1ef64437385a5 /legacy/emotion/src/modules/gstreamer
parente5d9afb26f49c0e849663b24555f36e13b1916e3 (diff)
* reorganize the way the gstreamer pipeline is built. Fix some usages
of emotion_object_file_set() * move the "frame_decode" evas event to _emotion_frame_new() a,d replace it in _emotion_video_pos_update() by "position_update" * fix a mem leak in the gstreamer backend and in the smart object SVN revision: 34581
Diffstat (limited to 'legacy/emotion/src/modules/gstreamer')
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c133
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c2
2 files changed, 54 insertions, 81 deletions
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
index f524fb439e..944613fff2 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
@@ -237,7 +237,7 @@ em_init(Evas_Object *obj,
237 if (!emotion_video) 237 if (!emotion_video)
238 return 0; 238 return 0;
239 239
240 printf ("Init gstreamer...\n"); 240 fprintf (stderr, "[Emotion] [gst] Init\n");
241 241
242 ev = calloc(1, sizeof(Emotion_Gstreamer_Video)); 242 ev = calloc(1, sizeof(Emotion_Gstreamer_Video));
243 if (!ev) return 0; 243 if (!ev) return 0;
@@ -249,14 +249,6 @@ em_init(Evas_Object *obj,
249 if (!gst_init_check (NULL, NULL, &error)) 249 if (!gst_init_check (NULL, NULL, &error))
250 goto failure_gstreamer; 250 goto failure_gstreamer;
251 251
252 ev->pipeline = gst_pipeline_new ("pipeline");
253 if (!ev->pipeline)
254 goto failure_pipeline;
255
256 ev->eos_bus = gst_pipeline_get_bus (GST_PIPELINE (ev->pipeline));
257 if (!ev->eos_bus)
258 goto failure_bus;
259
260 /* We allocate the sinks lists */ 252 /* We allocate the sinks lists */
261 ev->video_sinks = ecore_list_new (); 253 ev->video_sinks = ecore_list_new ();
262 if (!ev->video_sinks) 254 if (!ev->video_sinks)
@@ -297,12 +289,6 @@ em_init(Evas_Object *obj,
297 failure_audio_sinks: 289 failure_audio_sinks:
298 ecore_list_destroy (ev->video_sinks); 290 ecore_list_destroy (ev->video_sinks);
299 failure_video_sinks: 291 failure_video_sinks:
300 gst_object_unref (GST_OBJECT (ev->eos_bus));
301 failure_bus:
302 /* this call is not really necessary */
303 gst_element_set_state (ev->pipeline, GST_STATE_NULL);
304 gst_object_unref (GST_OBJECT (ev->pipeline));
305 failure_pipeline:
306 failure_gstreamer: 292 failure_gstreamer:
307 free (ev); 293 free (ev);
308 294
@@ -318,19 +304,18 @@ em_shutdown(void *video)
318 if (!ev) 304 if (!ev)
319 return 0; 305 return 0;
320 306
321 gst_element_set_state (ev->pipeline, GST_STATE_NULL); 307 fprintf(stderr, "[Emotion] [gst] shutdown\n");
322 gst_object_unref (GST_OBJECT (ev->pipeline));
323 gst_object_unref (GST_OBJECT (ev->eos_bus));
324 308
325 ecore_list_destroy (ev->video_sinks); 309 ecore_main_fd_handler_del(ev->fd_ev_handler);
326 ecore_list_destroy (ev->audio_sinks); 310
311 close(ev->fd_ev_write);
312 close(ev->fd_ev_read);
327 313
328 /* FIXME: and the evas object ? */ 314 /* FIXME: and the evas object ? */
329 if (ev->obj_data) free(ev->obj_data); 315 if (ev->obj_data) free(ev->obj_data);
330 316
331 ecore_main_fd_handler_del(ev->fd_ev_handler); 317 ecore_list_destroy (ev->video_sinks);
332 close(ev->fd_ev_write); 318 ecore_list_destroy (ev->audio_sinks);
333 close(ev->fd_ev_read);
334 319
335 free(ev); 320 free(ev);
336 321
@@ -346,6 +331,19 @@ em_file_open(const char *file,
346 331
347 ev = (Emotion_Gstreamer_Video *)video; 332 ev = (Emotion_Gstreamer_Video *)video;
348 333
334 fprintf(stderr, "[Emotion] [gst] open\n");
335
336 ev->pipeline = gst_pipeline_new ("pipeline");
337 if (!ev->pipeline)
338 return 0;
339
340 ev->eos_bus = gst_pipeline_get_bus (GST_PIPELINE (ev->pipeline));
341 if (!ev->eos_bus)
342 {
343 gst_object_unref(ev->pipeline);
344 return 0;
345 }
346
349 /* Evas Object */ 347 /* Evas Object */
350 ev->obj = obj; 348 ev->obj = obj;
351 349
@@ -370,6 +368,7 @@ em_file_open(const char *file,
370 fprintf (stderr, "[Emotion] [gst] build CD Audio pipeline\n"); 368 fprintf (stderr, "[Emotion] [gst] build CD Audio pipeline\n");
371 if (!(emotion_pipeline_cdda_build (ev, device, track))) { 369 if (!(emotion_pipeline_cdda_build (ev, device, track))) {
372 fprintf (stderr, "[Emotion] [gst] error while building CD Audio pipeline\n"); 370 fprintf (stderr, "[Emotion] [gst] error while building CD Audio pipeline\n");
371 gst_object_unref(ev->pipeline);
373 return 0; 372 return 0;
374 } 373 }
375 } 374 }
@@ -379,6 +378,7 @@ em_file_open(const char *file,
379 fprintf (stderr, "[Emotion] [gst] build DVD pipeline \n"); 378 fprintf (stderr, "[Emotion] [gst] build DVD pipeline \n");
380 if (!(emotion_pipeline_dvd_build (ev, NULL))) { 379 if (!(emotion_pipeline_dvd_build (ev, NULL))) {
381 fprintf (stderr, "[Emotion] [gst] error while building DVD pipeline\n"); 380 fprintf (stderr, "[Emotion] [gst] error while building DVD pipeline\n");
381 gst_object_unref(ev->pipeline);
382 return 0; 382 return 0;
383 } 383 }
384 } 384 }
@@ -387,6 +387,7 @@ em_file_open(const char *file,
387 fprintf (stderr, "[Emotion] [gst] build URI pipeline \n"); 387 fprintf (stderr, "[Emotion] [gst] build URI pipeline \n");
388 if (!(emotion_pipeline_uri_build (ev, file))) { 388 if (!(emotion_pipeline_uri_build (ev, file))) {
389 fprintf (stderr, "[Emotion] [gst] error while building URI pipeline\n"); 389 fprintf (stderr, "[Emotion] [gst] error while building URI pipeline\n");
390 gst_object_unref(ev->pipeline);
390 return 0; 391 return 0;
391 } 392 }
392 } 393 }
@@ -401,6 +402,7 @@ em_file_open(const char *file,
401 fprintf (stderr, "[Emotion] [gst] build file pipeline \n"); 402 fprintf (stderr, "[Emotion] [gst] build file pipeline \n");
402 if (!(emotion_pipeline_file_build (ev, filename))) { 403 if (!(emotion_pipeline_file_build (ev, filename))) {
403 fprintf (stderr, "[Emotion] [gst] error while building File pipeline\n"); 404 fprintf (stderr, "[Emotion] [gst] error while building File pipeline\n");
405 gst_object_unref(ev->pipeline);
404 return 0; 406 return 0;
405 } 407 }
406 } 408 }
@@ -414,20 +416,20 @@ em_file_open(const char *file,
414 416
415 vsink = (Emotion_Video_Sink *)ecore_list_first_goto (ev->video_sinks); 417 vsink = (Emotion_Video_Sink *)ecore_list_first_goto (ev->video_sinks);
416 if (vsink) { 418 if (vsink) {
417 g_print ("video : \n"); 419 fprintf (stderr, "video : \n");
418 g_print (" size : %dx%d\n", vsink->width, vsink->height); 420 fprintf (stderr, " size : %dx%d\n", vsink->width, vsink->height);
419 g_print (" fps : %d/%d\n", vsink->fps_num, vsink->fps_den); 421 fprintf (stderr, " fps : %d/%d\n", vsink->fps_num, vsink->fps_den);
420 g_print (" fourcc : %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (vsink->fourcc)); 422 fprintf (stderr, " fourcc : %" GST_FOURCC_FORMAT "\n", GST_FOURCC_ARGS (vsink->fourcc));
421 g_print (" length : %" GST_TIME_FORMAT "\n\n", 423 fprintf (stderr, " length : %" GST_TIME_FORMAT "\n\n",
422 GST_TIME_ARGS ((guint64)(vsink->length_time * GST_SECOND))); 424 GST_TIME_ARGS ((guint64)(vsink->length_time * GST_SECOND)));
423 } 425 }
424 426
425 asink = (Emotion_Audio_Sink *)ecore_list_first_goto (ev->audio_sinks); 427 asink = (Emotion_Audio_Sink *)ecore_list_first_goto (ev->audio_sinks);
426 if (asink) { 428 if (asink) {
427 g_print ("audio : \n"); 429 fprintf (stderr, "audio : \n");
428 g_print (" chan : %d\n", asink->channels); 430 fprintf (stderr, " chan : %d\n", asink->channels);
429 g_print (" rate : %d\n", asink->samplerate); 431 fprintf (stderr, " rate : %d\n", asink->samplerate);
430 g_print (" length : %" GST_TIME_FORMAT "\n\n", 432 fprintf (stderr, " length : %" GST_TIME_FORMAT "\n\n",
431 GST_TIME_ARGS ((guint64)(asink->length_time * GST_SECOND))); 433 GST_TIME_ARGS ((guint64)(asink->length_time * GST_SECOND)));
432 } 434 }
433 } 435 }
@@ -447,51 +449,6 @@ em_file_close(void *video)
447 if (!ev) 449 if (!ev)
448 return; 450 return;
449 451
450 printf("EX pause end...\n");
451 if (!emotion_object_play_get(ev->obj))
452 {
453 printf(" ... unpause\n");
454 emotion_pipeline_pause (ev->pipeline);
455 }
456
457 printf("EX stop\n");
458 gst_element_set_state (ev->pipeline, GST_STATE_READY);
459
460 /* we remove all the elements in the pipeline */
461 iter = gst_bin_iterate_elements (GST_BIN (ev->pipeline));
462 done = FALSE;
463 while (!done) {
464 switch (gst_iterator_next (iter, &data)) {
465 case GST_ITERATOR_OK: {
466 GstElement *element;
467
468 element = GST_ELEMENT (data);
469 if (element) {
470 gst_bin_remove (GST_BIN (ev->pipeline), element);
471 }
472 break;
473 }
474 case GST_ITERATOR_RESYNC: {
475 GstElement *element;
476
477 element = GST_ELEMENT (data);
478 if (element) {
479 gst_bin_remove (GST_BIN (ev->pipeline), element);
480 }
481 gst_iterator_resync (iter);
482 break;
483 }
484 case GST_ITERATOR_ERROR:
485 printf("error iter\n");
486 done = TRUE;
487 break;
488 case GST_ITERATOR_DONE:
489 done = TRUE;
490 break;
491 }
492 }
493 gst_iterator_free (iter);
494
495 /* we clear the sink lists */ 452 /* we clear the sink lists */
496 ecore_list_clear (ev->video_sinks); 453 ecore_list_clear (ev->video_sinks);
497 ecore_list_clear (ev->audio_sinks); 454 ecore_list_clear (ev->audio_sinks);
@@ -501,6 +458,18 @@ em_file_close(void *video)
501 ecore_timer_del (ev->eos_timer); 458 ecore_timer_del (ev->eos_timer);
502 ev->eos_timer = NULL; 459 ev->eos_timer = NULL;
503 } 460 }
461
462 if (ev->eos_bus)
463 {
464 gst_object_unref (GST_OBJECT (ev->eos_bus));
465 ev->eos_bus = NULL;
466 }
467 if (ev->pipeline)
468 {
469 gst_element_set_state (ev->pipeline, GST_STATE_NULL);
470 gst_object_unref(ev->pipeline);
471 ev->pipeline = NULL;
472 }
504} 473}
505 474
506static void 475static void
@@ -509,6 +478,7 @@ em_play(void *video,
509{ 478{
510 Emotion_Gstreamer_Video *ev; 479 Emotion_Gstreamer_Video *ev;
511 480
481 fprintf(stderr, "[Emotion] [gst] play %p\n", ev->pipeline);
512 ev = (Emotion_Gstreamer_Video *)video; 482 ev = (Emotion_Gstreamer_Video *)video;
513 gst_element_set_state (ev->pipeline, GST_STATE_PLAYING); 483 gst_element_set_state (ev->pipeline, GST_STATE_PLAYING);
514 ev->play = 1; 484 ev->play = 1;
@@ -524,14 +494,15 @@ em_stop(void *video)
524 494
525 ev = (Emotion_Gstreamer_Video *)video; 495 ev = (Emotion_Gstreamer_Video *)video;
526 496
527 gst_element_set_state (ev->pipeline, GST_STATE_PAUSED);
528 ev->play = 0;
529
530 /* shutdown eos */ 497 /* shutdown eos */
531 if (ev->eos_timer) { 498 if (ev->eos_timer) {
532 ecore_timer_del (ev->eos_timer); 499 ecore_timer_del (ev->eos_timer);
533 ev->eos_timer = NULL; 500 ev->eos_timer = NULL;
534 } 501 }
502
503/* fprintf(stderr, "[Emotion] [gst] stop\n"); */
504 gst_element_set_state (ev->pipeline, GST_STATE_PAUSED);
505 ev->play = 0;
535} 506}
536 507
537static void 508static void
@@ -1299,7 +1270,7 @@ _em_fd_ev_active(void *data, Ecore_Fd_Handler *fdh)
1299 buffer = buf[1]; 1270 buffer = buf[1];
1300 _emotion_frame_new(ev->obj); 1271 _emotion_frame_new(ev->obj);
1301 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr); 1272 vsink = (Emotion_Video_Sink *)ecore_list_index_goto (ev->video_sinks, ev->video_sink_nbr);
1302 _emotion_video_pos_update(ev->obj, ev->position, vsink->length_time); 1273 if (vsink) _emotion_video_pos_update(ev->obj, ev->position, vsink->length_time);
1303 } 1274 }
1304 } 1275 }
1305 return 1; 1276 return 1;
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
index 92431ec64d..bb277e48c0 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
@@ -122,6 +122,8 @@ file_new_decoded_pad_cb (GstElement *decodebin,
122 gst_pad_link(new_pad, audiopad); 122 gst_pad_link(new_pad, audiopad);
123 gst_element_set_state (asink->sink, GST_STATE_PAUSED); 123 gst_element_set_state (asink->sink, GST_STATE_PAUSED);
124 } 124 }
125
126 free(str);
125} 127}
126 128
127Emotion_Video_Sink * 129Emotion_Video_Sink *