summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer/emotion_sink.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-10-11 08:24:31 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-10-11 08:24:31 +0000
commit2c3e27ca427dc8e06a26e756186939ebbcc0fd47 (patch)
tree93101294b7829e47107092e0d3c481beba4b7ef6 /legacy/emotion/src/modules/gstreamer/emotion_sink.c
parentc4071e30ed97132258c79a2e1c9602b777c8f428 (diff)
emotion: limit size and format based on the backend with fimc.
SVN revision: 77852
Diffstat (limited to '')
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_sink.c143
1 files changed, 106 insertions, 37 deletions
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_sink.c b/legacy/emotion/src/modules/gstreamer/emotion_sink.c
index b9e2e748b5..433d8dca50 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_sink.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_sink.c
@@ -881,8 +881,8 @@ _video_resize(void *data, Evas_Object *obj __UNUSED__, const Evas_Video_Surface
881 Emotion_Gstreamer_Video *ev = data; 881 Emotion_Gstreamer_Video *ev = data;
882 882
883 ecore_x_window_resize(ev->win, w, h); 883 ecore_x_window_resize(ev->win, w, h);
884#endif
885 fprintf(stderr, "resize: %i, %i\n", w, h); 884 fprintf(stderr, "resize: %i, %i\n", w, h);
885#endif
886} 886}
887 887
888static void 888static void
@@ -979,6 +979,13 @@ _image_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info
979 int image_area, src_area; 979 int image_area, src_area;
980 double ratio; 980 double ratio;
981 981
982 GstElementFactory *cfactory = NULL;
983 GstElement *convert = NULL, *filter = NULL, *queue = NULL;
984 GstPad *pad = NULL, *teepad = NULL;
985 GstCaps *caps = NULL;
986 Eina_List *l, *engines;
987 const char *ename, *engine = NULL;
988
982 evas_object_geometry_get(obj, NULL, NULL, &width, &height); 989 evas_object_geometry_get(obj, NULL, NULL, &width, &height);
983 image_area = width * height; 990 image_area = width * height;
984 src_area = ev->src_width * ev->src_height; 991 src_area = ev->src_width * ev->src_height;
@@ -986,50 +993,112 @@ _image_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info
986 993
987 // when an image is much smaller than original video size, 994 // when an image is much smaller than original video size,
988 // add fimcconvert element to the pipeline 995 // add fimcconvert element to the pipeline
989 if (ratio < 0.8 && !ev->priority && !ev->convert) 996 if (ratio < 0.8 && ev->stream && !ev->convert)
990 { 997 {
991 GstElementFactory *cfactory = NULL;
992
993 cfactory = gst_element_factory_find("fimcconvert"); 998 cfactory = gst_element_factory_find("fimcconvert");
994 if (cfactory) 999 if (!cfactory) return;
1000
1001 convert = gst_element_factory_create(cfactory, NULL);
1002 if (!convert) return;
1003
1004 // add capsfilter to limit size and formats based on the backend
1005 filter = gst_element_factory_make("capsfilter", "fimccapsfilter");
1006 if (!filter)
995 { 1007 {
996 GstElement *convert = NULL; 1008 gst_object_unref(convert);
1009 return;
1010 }
997 1011
998 convert = gst_element_factory_create(cfactory, NULL); 1012 engines = evas_render_method_list();
999 if (convert) 1013 EINA_LIST_FOREACH(engines, l, ename)
1014 {
1015 if (evas_render_method_lookup(ename) ==
1016 evas_output_method_get(evas_object_evas_get(obj)))
1000 { 1017 {
1001 GstElement *queue = NULL; 1018 engine = ename;
1002 GstPad *pad, *teepad; 1019 break;
1003
1004 queue = gst_bin_get_by_name(GST_BIN(ev->sink), "equeue");
1005 gst_element_unlink(ev->tee, queue);
1006 gst_element_release_request_pad(ev->tee, ev->eteepad);
1007 gst_object_unref(ev->eteepad);
1008
1009 gst_bin_add(GST_BIN(ev->sink), convert);
1010 gst_element_link_many(ev->tee, convert, queue, NULL);
1011 pad = gst_element_get_pad(convert, "sink");
1012 teepad = gst_element_get_request_pad(ev->tee, "src%d");
1013 gst_pad_link(teepad, pad);
1014 gst_object_unref(pad);
1015
1016 g_object_set(G_OBJECT(convert), "src-width", width, NULL);
1017 g_object_set(G_OBJECT(convert), "src-height", height, NULL);
1018 g_object_set(G_OBJECT(convert), "qos", TRUE, NULL);
1019 gst_element_sync_state_with_parent(convert);
1020
1021 ev->eteepad = teepad;
1022 ev->convert = convert;
1023 } 1020 }
1024 } 1021 }
1022
1023 if (strstr(engine, "software") != NULL)
1024 {
1025 caps = gst_caps_new_simple("video/x-raw-rgb",
1026 "width", G_TYPE_INT, width,
1027 "height", G_TYPE_INT, height,
1028 NULL);
1029 }
1030 else if (strstr(engine, "gl") != NULL)
1031 {
1032 caps = gst_caps_new_simple("video/x-raw-yuv",
1033 "width", G_TYPE_INT, width,
1034 "height", G_TYPE_INT, height,
1035 NULL);
1036 }
1037 g_object_set(G_OBJECT(filter), "caps", caps, NULL);
1038 gst_caps_unref(caps);
1039
1040 // add new elements to the pipeline
1041 queue = gst_bin_get_by_name(GST_BIN(ev->sink), "equeue");
1042 gst_element_unlink(ev->tee, queue);
1043 gst_element_release_request_pad(ev->tee, ev->eteepad);
1044 gst_object_unref(ev->eteepad);
1045
1046 gst_bin_add_many(GST_BIN(ev->sink), convert, filter, NULL);
1047 gst_element_link_many(ev->tee, convert, filter, queue, NULL);
1048
1049 pad = gst_element_get_pad(convert, "sink");
1050 teepad = gst_element_get_request_pad(ev->tee, "src%d");
1051 gst_pad_link(teepad, pad);
1052 gst_object_unref(pad);
1053
1054 gst_element_sync_state_with_parent(convert);
1055 gst_element_sync_state_with_parent(filter);
1056
1057 ev->eteepad = teepad;
1058 ev->convert = convert;
1059 evas_render_method_list_free(engines);
1060
1061 INF("add fimcconvert element. video size: %dx%d. emotion object size: %dx%d",
1062 ev->src_width, ev->src_height, width, height);
1063 }
1064 // set size again to the capsfilter when the image is resized
1065 else if (ev->convert)
1066 {
1067 filter = gst_bin_get_by_name(GST_BIN(ev->sink), "fimccapsfilter");
1068
1069 engines = evas_render_method_list();
1070 EINA_LIST_FOREACH(engines, l, ename)
1071 {
1072 if (evas_render_method_lookup(ename) ==
1073 evas_output_method_get(evas_object_evas_get(obj)))
1074 {
1075 engine = ename;
1076 break;
1077 }
1078 }
1079
1080 if (strstr(engine, "software") != NULL)
1081 {
1082 caps = gst_caps_new_simple("video/x-raw-rgb",
1083 "width", G_TYPE_INT, width,
1084 "height", G_TYPE_INT, height,
1085 NULL);
1086 }
1087 else if (strstr(engine, "gl") != NULL)
1088 {
1089 caps = gst_caps_new_simple("video/x-raw-yuv",
1090 "width", G_TYPE_INT, width,
1091 "height", G_TYPE_INT, height,
1092 NULL);
1093 }
1094
1095 g_object_set(G_OBJECT(filter), "caps", caps, NULL);
1096 gst_caps_unref(caps);
1097 evas_render_method_list_free(engines);
1098
1099 INF("set capsfilter size again:. video size: %dx%d. emotion object size: %dx%d",
1100 ev->src_width, ev->src_height, width, height);
1025 } 1101 }
1026 // TODO: when an image is resized(e.g rotation), set size again to fimcconvert
1027 // TODO: fimcconvert has an issue about resetting
1028 //else if (ev->convert)
1029 // {
1030 // g_object_set(G_OBJECT(ev->convert), "src-width", w, NULL);
1031 // g_object_set(G_OBJECT(ev->convert), "src-height", h, NULL);
1032 // }
1033} 1102}
1034 1103
1035GstElement * 1104GstElement *