From: cedric Date: Wed, 25 Feb 2009 10:44:13 +0000 (+0000) Subject: * emotion/src/modules/gstreamer: Move from Ecore_List to Eina_List. X-Git-Tag: submit/2.0alpha-wayland/20121127.222018~355 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=00025c2db26a4ec124a5b740f8d030356da866f4;p=profile%2Fivi%2Femotion.git * emotion/src/modules/gstreamer: Move from Ecore_List to Eina_List. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/emotion@39195 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/modules/gstreamer/emotion_gstreamer.c b/src/modules/gstreamer/emotion_gstreamer.c index 1516bd3..888b202 100644 --- a/src/modules/gstreamer/emotion_gstreamer.c +++ b/src/modules/gstreamer/emotion_gstreamer.c @@ -4,6 +4,8 @@ #include #include +#include + #include "Emotion.h" #include "emotion_private.h" #include "emotion_gstreamer.h" @@ -238,6 +240,8 @@ em_init(Evas_Object *obj, Emotion_Module_Options *opt) { Emotion_Gstreamer_Video *ev; + Emotion_Audio_Sink *asink; + Emotion_Video_Sink *vsink; GError *error; int fds[2]; @@ -255,14 +259,10 @@ em_init(Evas_Object *obj, goto failure_gstreamer; /* We allocate the sinks lists */ - ev->video_sinks = ecore_list_new(); if (!ev->video_sinks) goto failure_video_sinks; - ecore_list_free_cb_set(ev->video_sinks, ECORE_FREE_CB(free)); - ev->audio_sinks = ecore_list_new(); if (!ev->audio_sinks) goto failure_audio_sinks; - ecore_list_free_cb_set(ev->audio_sinks, ECORE_FREE_CB(free)); *emotion_video = ev; @@ -281,9 +281,11 @@ em_init(Evas_Object *obj, return 1; failure_pipe: - ecore_list_destroy(ev->audio_sinks); + EINA_LIST_FREE(ev->audio_sinks, asink) + free(asink); failure_audio_sinks: - ecore_list_destroy(ev->video_sinks); + EINA_LIST_FREE(ev->video_sinks, vsink) + free(vsink); failure_video_sinks: failure_gstreamer: free(ev); @@ -295,6 +297,8 @@ static int em_shutdown(void *video) { Emotion_Gstreamer_Video *ev; + Emotion_Audio_Sink *asink; + Emotion_Video_Sink *vsink; ev = (Emotion_Gstreamer_Video *)video; if (!ev) @@ -305,8 +309,10 @@ em_shutdown(void *video) /* FIXME: and the evas object ? */ if (ev->obj_data) free(ev->obj_data); - ecore_list_destroy(ev->video_sinks); - ecore_list_destroy(ev->audio_sinks); + EINA_LIST_FREE(ev->audio_sinks, asink) + free(asink); + EINA_LIST_FREE(ev->video_sinks, vsink) + free(vsink); free(ev); @@ -426,7 +432,7 @@ em_file_open(const char *file, Emotion_Video_Sink *vsink; Emotion_Audio_Sink *asink; - vsink = (Emotion_Video_Sink *)ecore_list_first_goto(ev->video_sinks); + vsink = (Emotion_Video_Sink *)eina_list_data_get(ev->video_sinks); if (vsink) { fprintf(stderr, "video : \n"); @@ -437,7 +443,7 @@ em_file_open(const char *file, GST_TIME_ARGS((guint64)(vsink->length_time * GST_SECOND))); } - asink = (Emotion_Audio_Sink *)ecore_list_first_goto(ev->audio_sinks); + asink = (Emotion_Audio_Sink *)eina_list_data_get(ev->audio_sinks); if (asink) { fprintf(stderr, "audio : \n"); @@ -463,14 +469,18 @@ static void em_file_close(void *video) { Emotion_Gstreamer_Video *ev; + Emotion_Audio_Sink *asink; + Emotion_Video_Sink *vsink; ev = (Emotion_Gstreamer_Video *)video; if (!ev) return; /* we clear the sink lists */ - ecore_list_clear(ev->video_sinks); - ecore_list_clear(ev->audio_sinks); + EINA_LIST_FREE(ev->audio_sinks, asink) + free(asink); + EINA_LIST_FREE(ev->video_sinks, vsink) + free(vsink); /* shutdown eos */ if (ev->eos_timer) @@ -541,7 +551,7 @@ em_size_get(void *video, ev = (Emotion_Gstreamer_Video *)video; - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); if (vsink) { if (width) *width = vsink->width; @@ -564,8 +574,8 @@ em_pos_set(void *video, ev = (Emotion_Gstreamer_Video *)video; - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); - asink = (Emotion_Audio_Sink *)ecore_list_index_goto(ev->video_sinks, ev->audio_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); + asink = (Emotion_Audio_Sink *)eina_list_nth(ev->video_sinks, ev->audio_sink_nbr); if (vsink) { @@ -593,6 +603,7 @@ em_len_get(void *video) Emotion_Gstreamer_Video *ev; Emotion_Video_Sink *vsink; Emotion_Audio_Sink *asink; + Eina_List *l; GstFormat fmt; gint64 val; gboolean ret; @@ -616,13 +627,13 @@ em_len_get(void *video) return val / 1000000000.0; fallback: - ecore_list_first_goto(ev->audio_sinks); - while ((asink = ecore_list_next(ev->audio_sinks)) != NULL) + fputs("Gstreamer reported no length, try existing sinks...\n", stderr); + + EINA_LIST_FOREACH(ev->audio_sinks, l, asink) if (asink->length_time >= 0) return asink->length_time; - ecore_list_first_goto(ev->video_sinks); - while ((vsink = ecore_list_next(ev->video_sinks)) != NULL) + EINA_LIST_FOREACH(ev->video_sinks, l, vsink) if (vsink->length_time >= 0) return vsink->length_time; @@ -637,7 +648,7 @@ em_fps_num_get(void *video) ev = (Emotion_Gstreamer_Video *)video; - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); if (vsink) return vsink->fps_num; @@ -652,7 +663,7 @@ em_fps_den_get(void *video) ev = (Emotion_Gstreamer_Video *)video; - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); if (vsink) return vsink->fps_den; @@ -667,7 +678,7 @@ em_fps_get(void *video) ev = (Emotion_Gstreamer_Video *)video; - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); if (vsink) return (double)vsink->fps_num / (double)vsink->fps_den; @@ -759,7 +770,7 @@ em_video_handled(void *video) ev = (Emotion_Gstreamer_Video *)video; - if (ecore_list_empty_is(ev->video_sinks)) + if (!eina_list_count(ev->video_sinks)) return 0; return 1; @@ -772,7 +783,7 @@ em_audio_handled(void *video) ev = (Emotion_Gstreamer_Video *)video; - if (ecore_list_empty_is(ev->audio_sinks)) + if (!eina_list_count(ev->audio_sinks)) return 0; return 1; @@ -804,7 +815,7 @@ em_format_get(void *video) ev = (Emotion_Gstreamer_Video *)video; - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); if (vsink) { switch (vsink->fourcc) @@ -832,7 +843,7 @@ em_video_data_size_get(void *video, int *w, int *h) ev = (Emotion_Gstreamer_Video *)video; - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); if (vsink) { *w = vsink->width; @@ -938,7 +949,7 @@ em_video_channel_count(void *video) ev = (Emotion_Gstreamer_Video *)video; - return ecore_list_count(ev->video_sinks); + return eina_list_count(ev->video_sinks); } static void @@ -1004,7 +1015,7 @@ em_audio_channel_count(void *video) ev = (Emotion_Gstreamer_Video *)video; - return ecore_list_count(ev->audio_sinks); + return eina_list_count(ev->audio_sinks); } static void @@ -1230,7 +1241,7 @@ static const char * em_meta_get(void *video, int meta) { Emotion_Gstreamer_Video *ev; - const char *str; + const char *str = NULL; ev = (Emotion_Gstreamer_Video *)video; @@ -1432,7 +1443,7 @@ _em_buffer_read(void *data, void *buf, unsigned int nbyte) ev = (Emotion_Gstreamer_Video *)data; buffer = *((GstBuffer **)buf); _emotion_frame_new(ev->obj); - vsink = (Emotion_Video_Sink *)ecore_list_index_goto(ev->video_sinks, ev->video_sink_nbr); + vsink = (Emotion_Video_Sink *)eina_list_nth(ev->video_sinks, ev->video_sink_nbr); if (vsink) _emotion_video_pos_update(ev->obj, ev->position, vsink->length_time); } diff --git a/src/modules/gstreamer/emotion_gstreamer.h b/src/modules/gstreamer/emotion_gstreamer.h index 39845a2..3581430 100644 --- a/src/modules/gstreamer/emotion_gstreamer.h +++ b/src/modules/gstreamer/emotion_gstreamer.h @@ -66,8 +66,8 @@ struct _Emotion_Gstreamer_Video Ecore_Timer *eos_timer; /* Sinks */ - Ecore_List *video_sinks; - Ecore_List *audio_sinks; + Eina_List *video_sinks; + Eina_List *audio_sinks; int video_sink_nbr; int audio_sink_nbr; diff --git a/src/modules/gstreamer/emotion_gstreamer_pipeline.c b/src/modules/gstreamer/emotion_gstreamer_pipeline.c index 5fcd742..e8f5bbf 100644 --- a/src/modules/gstreamer/emotion_gstreamer_pipeline.c +++ b/src/modules/gstreamer/emotion_gstreamer_pipeline.c @@ -58,7 +58,7 @@ cb_handoff(GstElement *fakesrc, else { Emotion_Audio_Sink *asink; - asink = (Emotion_Audio_Sink *)ecore_list_index_goto(ev->audio_sinks, ev->audio_sink_nbr); + asink = (Emotion_Audio_Sink *)eina_list_nth(ev->audio_sinks, ev->audio_sink_nbr); _emotion_video_pos_update(ev->obj, ev->position, asink->length_time); } @@ -82,6 +82,7 @@ file_new_decoded_pad_cb(GstElement *decodebin, Emotion_Gstreamer_Video *ev; GstCaps *caps; gchar *str; + unsigned int index; ev = (Emotion_Gstreamer_Video *)user_data; caps = gst_pad_get_caps(new_pad); @@ -95,7 +96,8 @@ file_new_decoded_pad_cb(GstElement *decodebin, vsink = (Emotion_Video_Sink *)calloc(1, sizeof(Emotion_Video_Sink)); if (!vsink) return; - if (!ecore_list_append(ev->video_sinks, vsink)) + ev->video_sinks = eina_list_append(ev->video_sinks, vsink); + if (!eina_list_data_find(ev->video_sinks, vsink)) { free(vsink); return; @@ -108,7 +110,7 @@ file_new_decoded_pad_cb(GstElement *decodebin, videopad = gst_element_get_pad(queue, "sink"); gst_pad_link(new_pad, videopad); gst_object_unref(videopad); - if (ecore_list_count(ev->video_sinks) == 1) + if (eina_list_count(ev->video_sinks) == 1) { ev->ratio = (double)vsink->width / (double)vsink->height; } @@ -123,13 +125,16 @@ file_new_decoded_pad_cb(GstElement *decodebin, asink = (Emotion_Audio_Sink *)calloc(1, sizeof(Emotion_Audio_Sink)); if (!asink) return; - if (!ecore_list_append(ev->audio_sinks, asink)) + ev->audio_sinks = eina_list_append(ev->audio_sinks, asink); + if (!eina_list_data_find(ev->audio_sinks, asink)) { free(asink); return; } - asink->sink = emotion_audio_sink_create(ev, ecore_list_index(ev->audio_sinks)); + for (index = 0; asink != eina_list_nth(ev->audio_sinks, index); index++) + ; + asink->sink = emotion_audio_sink_create(ev, index); gst_bin_add(GST_BIN(ev->pipeline), asink->sink); audiopad = gst_element_get_pad(asink->sink, "sink"); gst_pad_link(new_pad, audiopad); @@ -149,7 +154,8 @@ emotion_video_sink_new(Emotion_Gstreamer_Video *ev) vsink = (Emotion_Video_Sink *)calloc(1, sizeof(Emotion_Video_Sink)); if (!vsink) return NULL; - if (!ecore_list_append(ev->video_sinks, vsink)) + ev->video_sinks = eina_list_append(ev->video_sinks, vsink); + if (!eina_list_data_find(ev->video_sinks, vsink)) { free(vsink); return NULL; @@ -162,11 +168,8 @@ emotion_video_sink_free(Emotion_Gstreamer_Video *ev, Emotion_Video_Sink *vsink) { if (!ev || !vsink) return; - if (ecore_list_goto(ev->video_sinks, vsink)) - { - ecore_list_remove(ev->video_sinks); + ev->video_sinks = eina_list_remove(ev->video_sinks, vsink); free(vsink); - } } Emotion_Video_Sink * @@ -470,10 +473,12 @@ void emotion_streams_sinks_get(Emotion_Gstreamer_Video *ev, GstElement *decoder) { GstIterator *it; + Eina_List *alist; + Eina_List *vlist; gpointer data; - ecore_list_first_goto(ev->video_sinks); - ecore_list_first_goto(ev->audio_sinks); + alist = ev->audio_sinks; + vlist = ev->video_sinks; it = gst_element_iterate_src_pads(decoder); while (gst_iterator_next(it, &data) == GST_ITERATOR_OK) @@ -493,7 +498,8 @@ emotion_streams_sinks_get(Emotion_Gstreamer_Video *ev, GstElement *decoder) { Emotion_Video_Sink *vsink; - vsink = (Emotion_Video_Sink *)ecore_list_next(ev->video_sinks); + vsink = (Emotion_Video_Sink *)eina_list_data_get(vlist); + vlist = eina_list_next(vlist); emotion_video_sink_fill(vsink, pad, caps); } @@ -501,15 +507,17 @@ emotion_streams_sinks_get(Emotion_Gstreamer_Video *ev, GstElement *decoder) else if (g_str_has_prefix(str, "audio/")) { Emotion_Audio_Sink *asink; - gint index; + unsigned int index; - asink = (Emotion_Audio_Sink *)ecore_list_next(ev->audio_sinks); + asink = (Emotion_Audio_Sink *)eina_list_data_get(alist); + alist = eina_list_next(alist); emotion_audio_sink_fill(asink, pad, caps); - index = ecore_list_index(ev->audio_sinks); + for (index = 0; asink != eina_list_nth(ev->audio_sinks, index) ; index++) + ; - if (ecore_list_count(ev->video_sinks) == 0) + if (eina_list_count(ev->video_sinks) == 0) { if (index == 1) { diff --git a/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c b/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c index 5083f29..655252a 100644 --- a/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c +++ b/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c @@ -107,7 +107,8 @@ _emotion_audio_sink_new(Emotion_Gstreamer_Video *ev) asink = (Emotion_Audio_Sink *)malloc(sizeof(Emotion_Audio_Sink)); if (!asink) return NULL; - if (!ecore_list_append(ev->audio_sinks, asink)) + ev->audio_sinks = eina_list_append(ev->audio_sinks, asink); + if (!eina_list_data_find(ev->audio_sinks, asink)) { free(asink); return NULL; @@ -120,9 +121,6 @@ _emotion_audio_sink_free(Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink) { if (!ev || !asink) return; - if (ecore_list_goto(ev->audio_sinks, asink)) - { - ecore_list_remove(ev->audio_sinks); + ev->audio_sinks = eina_list_remove(ev->audio_sinks, asink); free(asink); - } } diff --git a/src/modules/gstreamer/emotion_gstreamer_pipeline_dvd.c b/src/modules/gstreamer/emotion_gstreamer_pipeline_dvd.c index 2292707..ea8a6f2 100644 --- a/src/modules/gstreamer/emotion_gstreamer_pipeline_dvd.c +++ b/src/modules/gstreamer/emotion_gstreamer_pipeline_dvd.c @@ -21,6 +21,8 @@ emotion_pipeline_dvd_build(void *video, const char *device) GstElement *dvdreadsrc; GstElement *dvddemux; Emotion_Gstreamer_Video *ev; + Eina_List *alist; + Eina_List *vlist; ev = (Emotion_Gstreamer_Video *)video; if (!ev) return 0; @@ -53,8 +55,8 @@ emotion_pipeline_dvd_build(void *video, const char *device) no_more_pads = 0; /* We get the informations of streams */ - ecore_list_first_goto(ev->video_sinks); - ecore_list_first_goto(ev->audio_sinks); + alist = ev->audio_sinks; + vlist = ev->video_sinks; { GstIterator *it; @@ -79,7 +81,8 @@ emotion_pipeline_dvd_build(void *video, const char *device) GstPad *sink_pad; GstCaps *sink_caps; - vsink = (Emotion_Video_Sink *)ecore_list_next(ev->video_sinks); + vsink = (Emotion_Video_Sink *)eina_list_data_get(vlist); + vlist = eina_list_next(vlist); sink_pad = gst_element_get_pad(gst_bin_get_by_name(GST_BIN(ev->pipeline), "mpeg2dec"), "src"); sink_caps = gst_pad_get_caps(sink_pad); str = gst_caps_to_string(sink_caps); @@ -97,7 +100,7 @@ emotion_pipeline_dvd_build(void *video, const char *device) GstPad *sink_pad; GstCaps *sink_caps; - asink = (Emotion_Audio_Sink *)ecore_list_next(ev->audio_sinks); + asink = (Emotion_Audio_Sink *)eina_list_data_get(alist); sink_pad = gst_element_get_pad(gst_bin_get_by_name(GST_BIN(ev->pipeline), "a52dec"), "src"); sink_caps = gst_pad_get_caps(sink_pad); @@ -115,7 +118,7 @@ emotion_pipeline_dvd_build(void *video, const char *device) { Emotion_Video_Sink *vsink; - vsink = (Emotion_Video_Sink *)ecore_list_first_goto(ev->video_sinks); + vsink = (Emotion_Video_Sink *)eina_list_data_get(ev->video_sinks); if (vsink && vsink->sink) { g_object_set(G_OBJECT(vsink->sink), "sync", TRUE, NULL); @@ -161,7 +164,8 @@ dvd_pad_added_cb(GstElement *dvddemuxer, vsink = (Emotion_Video_Sink *)malloc(sizeof(Emotion_Video_Sink)); if (!vsink) return; - if (!ecore_list_append(ev->video_sinks, vsink)) + ev->video_sinks = eina_list_append(ev->video_sinks, vsink); + if (!eina_list_data_find(ev->video_sinks, vsink)) { free(vsink); return; @@ -176,7 +180,7 @@ dvd_pad_added_cb(GstElement *dvddemuxer, videopad = gst_element_get_pad(queue, "sink"); gst_pad_link(GST_PAD(new_pad), videopad); gst_object_unref(videopad); - if (ecore_list_count(ev->video_sinks) == 1) + if (eina_list_count(ev->video_sinks) == 1) { ev->ratio = (double)vsink->width / (double)vsink->height; } @@ -198,7 +202,8 @@ dvd_pad_added_cb(GstElement *dvddemuxer, asink = (Emotion_Audio_Sink *)malloc(sizeof(Emotion_Audio_Sink)); if (!asink) return; - if (!ecore_list_append(ev->audio_sinks, asink)) + ev->audio_sinks = eina_list_append(ev->audio_sinks, asink); + if (!eina_list_data_find(ev->audio_sinks, asink)) { free(asink); return; diff --git a/src/modules/gstreamer/emotion_gstreamer_pipeline_file.c b/src/modules/gstreamer/emotion_gstreamer_pipeline_file.c index 393855d..4c90575 100644 --- a/src/modules/gstreamer/emotion_gstreamer_pipeline_file.c +++ b/src/modules/gstreamer/emotion_gstreamer_pipeline_file.c @@ -39,7 +39,7 @@ emotion_pipeline_file_build(void *video, const char *file) { Emotion_Video_Sink *vsink; - vsink = (Emotion_Video_Sink *)ecore_list_first_goto(ev->video_sinks); + vsink = (Emotion_Video_Sink *)eina_list_data_get(ev->video_sinks); if (vsink && vsink->sink) { g_object_set(G_OBJECT(vsink->sink), "sync", TRUE, NULL); diff --git a/src/modules/gstreamer/emotion_gstreamer_pipeline_uri.c b/src/modules/gstreamer/emotion_gstreamer_pipeline_uri.c index d6a1c00..4f3bf6e 100644 --- a/src/modules/gstreamer/emotion_gstreamer_pipeline_uri.c +++ b/src/modules/gstreamer/emotion_gstreamer_pipeline_uri.c @@ -41,7 +41,7 @@ emotion_pipeline_uri_build(void *video, const char *uri) { Emotion_Video_Sink *vsink; - vsink = (Emotion_Video_Sink *)ecore_list_first_goto(ev->video_sinks); + vsink = (Emotion_Video_Sink *)eina_list_data_get(ev->video_sinks); if (vsink && vsink->sink) { g_object_set(G_OBJECT(vsink->sink), "sync", TRUE, NULL);