summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer/emotion_sink.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-07-05 12:40:56 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-07-05 12:40:56 +0000
commit8f38e5e4e62391e5649bbfe970c3d15ef3705a0b (patch)
tree64c0a83cfe49e6b3c2debc30fbc276b5d98adca1 /legacy/emotion/src/modules/gstreamer/emotion_sink.c
parent1c08b5899eaac1b10a8e7bf5fdb592449ef107a9 (diff)
emotion: let work around embedded device limitation.
NOTE: I am going to accept more of this work around. So if you preferred device doesn't come with a proper nice implementation of gstreamer, let's start working around in emotion :'( SVN revision: 73340
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_sink.c79
1 files changed, 71 insertions, 8 deletions
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_sink.c b/legacy/emotion/src/modules/gstreamer/emotion_sink.c
index 85739bd360..6fe26f80af 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_sink.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_sink.c
@@ -895,7 +895,7 @@ _block_pad_unlink_cb(GstPad *pad, gboolean blocked, gpointer user_data)
895 Emotion_Gstreamer_Video *ev = user_data; 895 Emotion_Gstreamer_Video *ev = user_data;
896 GstEvent *gev; 896 GstEvent *gev;
897 897
898 gst_pad_unlink(ev->teepad, ev->xvpad); 898 gst_pad_unlink(ev->xvteepad, ev->xvpad);
899 gev = gst_event_new_eos(); 899 gev = gst_event_new_eos();
900 gst_pad_send_event(ev->xvpad, gev); 900 gst_pad_send_event(ev->xvpad, gev);
901 gst_pad_set_blocked_async(pad, FALSE, _block_pad_unlink_cb, NULL); 901 gst_pad_set_blocked_async(pad, FALSE, _block_pad_unlink_cb, NULL);
@@ -909,7 +909,7 @@ _block_pad_link_cb(GstPad *pad, gboolean blocked, gpointer user_data)
909 { 909 {
910 Emotion_Gstreamer_Video *ev = user_data; 910 Emotion_Gstreamer_Video *ev = user_data;
911 911
912 gst_pad_link(ev->teepad, ev->xvpad); 912 gst_pad_link(ev->xvteepad, ev->xvpad);
913 if (ev->play) 913 if (ev->play)
914 gst_element_set_state(ev->xvsink, GST_STATE_PLAYING); 914 gst_element_set_state(ev->xvsink, GST_STATE_PLAYING);
915 else 915 else
@@ -928,7 +928,7 @@ _video_show(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface *s
928 fprintf(stderr, "show xv\n"); 928 fprintf(stderr, "show xv\n");
929 ecore_x_window_show(ev->win); 929 ecore_x_window_show(ev->win);
930#endif 930#endif
931 /* gst_pad_set_blocked_async(ev->teepad, TRUE, _block_pad_link_cb, ev); */ 931 /* gst_pad_set_blocked_async(ev->xvteepad, TRUE, _block_pad_link_cb, ev); */
932} 932}
933 933
934static void 934static void
@@ -940,7 +940,7 @@ _video_hide(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface *s
940 fprintf(stderr, "hide xv\n"); 940 fprintf(stderr, "hide xv\n");
941 ecore_x_window_hide(ev->win); 941 ecore_x_window_hide(ev->win);
942#endif 942#endif
943 /* gst_pad_set_blocked_async(ev->teepad, TRUE, _block_pad_unlink_cb, ev); */ 943 /* gst_pad_set_blocked_async(ev->xvteepad, TRUE, _block_pad_unlink_cb, ev); */
944} 944}
945 945
946static void 946static void
@@ -957,6 +957,67 @@ _video_update_pixels(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_S
957 evas_video_sink_main_render(send); 957 evas_video_sink_main_render(send);
958} 958}
959 959
960static void
961_image_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
962{
963 Emotion_Gstreamer_Video *ev = data;
964 Evas_Coord width, height;
965 int image_area, src_area;
966 double ratio;
967
968 evas_object_geometry_get(obj, NULL, NULL, &width, &height);
969 image_area = width * height;
970 src_area = ev->src_width * ev->src_height;
971 ratio = (double)image_area / (double)src_area;
972
973 // when an image is much smaller than original video size,
974 // add fimcconvert element to the pipeline
975 if (ratio < 0.8 && !ev->priority && !ev->convert)
976 {
977 GstElementFactory *cfactory = NULL;
978
979 cfactory = gst_element_factory_find("fimcconvert");
980 if (cfactory)
981 {
982 GstElement *convert = NULL;
983
984 convert = gst_element_factory_create(cfactory, NULL);
985 if (convert)
986 {
987 GstElement *queue = NULL;
988 GstPad *pad, *teepad;
989
990 queue = gst_bin_get_by_name(GST_BIN(ev->sink), "equeue");
991 gst_element_unlink(ev->tee, queue);
992 gst_element_release_request_pad(ev->tee, ev->eteepad);
993 gst_object_unref(ev->eteepad);
994
995 gst_bin_add(GST_BIN(ev->sink), convert);
996 gst_element_link_many(ev->tee, convert, queue, NULL);
997 pad = gst_element_get_pad(convert, "sink");
998 teepad = gst_element_get_request_pad(ev->tee, "src%d");
999 gst_pad_link(teepad, pad);
1000 gst_object_unref(pad);
1001
1002 g_object_set(G_OBJECT(convert), "src-width", width, NULL);
1003 g_object_set(G_OBJECT(convert), "src-height", height, NULL);
1004 g_object_set(G_OBJECT(convert), "qos", TRUE, NULL);
1005 gst_element_sync_state_with_parent(convert);
1006
1007 ev->eteepad = teepad;
1008 ev->convert = convert;
1009 }
1010 }
1011 }
1012 // TODO: when an image is resized(e.g rotation), set size again to fimcconvert
1013 // TODO: fimcconvert has an issue about resetting
1014 //else if (ev->convert)
1015 // {
1016 // g_object_set(G_OBJECT(ev->convert), "src-width", w, NULL);
1017 // g_object_set(G_OBJECT(ev->convert), "src-height", h, NULL);
1018 // }
1019}
1020
960GstElement * 1021GstElement *
961gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev, 1022gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
962 Evas_Object *o, 1023 Evas_Object *o,
@@ -1115,9 +1176,10 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
1115 g_object_set(G_OBJECT(esink), "ev", ev, NULL); 1176 g_object_set(G_OBJECT(esink), "ev", ev, NULL);
1116 1177
1117 evas_object_image_pixels_get_callback_set(obj, NULL, NULL); 1178 evas_object_image_pixels_get_callback_set(obj, NULL, NULL);
1179 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _image_resize, ev);
1118 1180
1119 /* We need queue to force each video sink to be in its own thread */ 1181 /* We need queue to force each video sink to be in its own thread */
1120 queue = gst_element_factory_make("queue", NULL); 1182 queue = gst_element_factory_make("queue", "equeue");
1121 if (!queue) 1183 if (!queue)
1122 { 1184 {
1123 ERR("Unable to create 'queue' GstElement."); 1185 ERR("Unable to create 'queue' GstElement.");
@@ -1132,13 +1194,14 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
1132 teepad = gst_element_get_request_pad(tee, "src%d"); 1194 teepad = gst_element_get_request_pad(tee, "src%d");
1133 gst_pad_link(teepad, pad); 1195 gst_pad_link(teepad, pad);
1134 gst_object_unref(pad); 1196 gst_object_unref(pad);
1135 gst_object_unref(teepad); 1197
1198 ev->eteepad = teepad;
1136 1199
1137 if (xvsink) 1200 if (xvsink)
1138 { 1201 {
1139 GstElement *fakeeos; 1202 GstElement *fakeeos;
1140 1203
1141 queue = gst_element_factory_make("queue", NULL); 1204 queue = gst_element_factory_make("queue", "xvqueue");
1142 fakeeos = GST_ELEMENT(GST_BIN(g_object_new(GST_TYPE_FAKEEOS_BIN, "name", "eosbin", NULL))); 1205 fakeeos = GST_ELEMENT(GST_BIN(g_object_new(GST_TYPE_FAKEEOS_BIN, "name", "eosbin", NULL)));
1143 if (queue && fakeeos) 1206 if (queue && fakeeos)
1144 { 1207 {
@@ -1157,7 +1220,7 @@ gstreamer_video_sink_new(Emotion_Gstreamer_Video *ev,
1157 1220
1158 xvsink = fakeeos; 1221 xvsink = fakeeos;
1159 1222
1160 ev->teepad = teepad; 1223 ev->xvteepad = teepad;
1161 ev->xvpad = pad; 1224 ev->xvpad = pad;
1162 } 1225 }
1163 else 1226 else