summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-25 15:21:45 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2016-07-25 15:21:45 +0900
commit287c543ea3622c0929b2f9f1fb93414623e515d6 (patch)
treed78bf8f0be367b3950bc9c8581ea282d2a15bdb7
parent892c126cf47d02724d4ce2d6e3e972ab6363eae3 (diff)
efl - when evas generic loaders merged the gst loader was missed. fix
this fixes the missing gst loader from generic loaders.
-rw-r--r--configure.ac5
-rw-r--r--src/Makefile_Evas.am96
-rw-r--r--src/generic/.gitignore1
-rw-r--r--src/generic/evas/gst/main.c292
-rw-r--r--src/generic/evas/gst/main_0_10.c278
5 files changed, 671 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index bf4148167e..4e269193d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1729,7 +1729,10 @@ fi
1729if test "${want_gstreamer}" = "yes"; then 1729if test "${want_gstreamer}" = "yes"; then
1730 PKG_CHECK_MODULES([GSTREAMER], [gstreamer-0.10]) 1730 PKG_CHECK_MODULES([GSTREAMER], [gstreamer-0.10])
1731fi 1731fi
1732AM_CONDITIONAL([HAVE_GSTREAMER], [test "${want_gstreamer}" = "yes" -o "${want_gstreamer1}" = "yes"]) 1732
1733AM_CONDITIONAL([HAVE_GSTREAMER], [test "x${want_gstreamer}" = "xyes" -o "x${want_gstreamer1}" = "xyes"])
1734AM_CONDITIONAL([HAVE_GSTREAMER0], [test "x${want_gstreamer}" = "xyes"])
1735AM_CONDITIONAL([HAVE_GSTREAMER1], [test "x${want_gstreamer1}" = "xyes"])
1733 1736
1734EFL_EVAL_PKGS([ECORE]) 1737EFL_EVAL_PKGS([ECORE])
1735 1738
diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 01310c0ab2..1f07e7ec33 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -2572,3 +2572,99 @@ mkdir -p $(DESTDIR)$(libdir)/evas/utils; \
2572ln -sf evas_image_loader.xcf $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.xcf.gz; 2572ln -sf evas_image_loader.xcf $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.xcf.gz;
2573 2573
2574endif 2574endif
2575
2576
2577EXTRA_DIST2 += \
2578 generic/evas/gst/main_0_10.c \
2579 generic/evas/gst/main.c
2580
2581if HAVE_GSTREAMER
2582EFL_INSTALL_EXEC_HOOK += \
2583mkdir -p $(DESTDIR)$(libdir)/evas/utils; \
2584ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.264; \
2585ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.3g2; \
2586ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.3gp; \
2587ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.3gp2; \
2588ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.3gpp; \
2589ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.3gpp2; \
2590ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.3p2; \
2591ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.asf; \
2592ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.avi; \
2593ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.bdm; \
2594ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.bdmv; \
2595ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.clpi; \
2596ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.cpi; \
2597ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.dv; \
2598ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.fla; \
2599ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.flv; \
2600ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.m1v; \
2601ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.m2t; \
2602ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.m2v; \
2603ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.m4v; \
2604ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mkv; \
2605ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mov; \
2606ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mp2; \
2607ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mp2ts; \
2608ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mp4; \
2609ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mpe; \
2610ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mpeg; \
2611ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mpg; \
2612ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mpl; \
2613ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mpls; \
2614ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mts; \
2615ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.mxf; \
2616ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.nut; \
2617ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.nuv; \
2618ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.ogg; \
2619ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.ogm; \
2620ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.ogv; \
2621ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.qt; \
2622ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.rm; \
2623ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.rmj; \
2624ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.rmm; \
2625ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.rms; \
2626ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.rmx; \
2627ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.rmvb; \
2628ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.rv; \
2629ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.swf; \
2630ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.ts; \
2631ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.webm; \
2632ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.weba; \
2633ln -sf evas_image_loader.gst $(DESTDIR)$(libdir)/evas/utils/evas_image_loader.wmv;
2634endif
2635
2636if HAVE_GSTREAMER0
2637evasgenericloaders_PROGRAMS += generic/evas/gst/evas_image_loader.gst
2638generic_evas_gst_evas_image_loader_gst_SOURCES = \
2639 generic/evas/gst/main_0_10.c \
2640 generic/evas/common/shmfile.c \
2641 generic/evas/common/timeout.c
2642generic_evas_gst_evas_image_loader_gst_CFLAGS = \
2643 -I$(top_srcdir)/src/lib/efl \
2644 -I$(top_builddir)/src/lib/efl \
2645 -I$(top_srcdir)/src/lib/eina \
2646 -I$(top_builddir)/src/lib/eina \
2647 -I$(top_srcdir)/src/generic/evas/common \
2648 @EMOTION_MODULE_GSTREAMER_CFLAGS@
2649generic_evas_gst_evas_image_loader_gst_LDADD = \
2650 @USE_EINA_LIBS@ @SHM_LIBS@ -lm @EMOTION_MODULE_GSTREAMER_LIBS@
2651generic_evas_gst_evas_image_loader_gst_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
2652endif
2653
2654if HAVE_GSTREAMER1
2655evasgenericloaders_PROGRAMS += generic/evas/gst/evas_image_loader.gst
2656generic_evas_gst_evas_image_loader_gst_SOURCES = \
2657 generic/evas/gst/main.c \
2658 generic/evas/common/shmfile.c \
2659 generic/evas/common/timeout.c
2660generic_evas_gst_evas_image_loader_gst_CFLAGS = \
2661 -I$(top_srcdir)/src/lib/efl \
2662 -I$(top_builddir)/src/lib/efl \
2663 -I$(top_srcdir)/src/lib/eina \
2664 -I$(top_builddir)/src/lib/eina \
2665 -I$(top_srcdir)/src/generic/evas/common \
2666 @EMOTION_MODULE_GSTREAMER1_CFLAGS@
2667generic_evas_gst_evas_image_loader_gst_LDADD = \
2668 @USE_EINA_LIBS@ @SHM_LIBS@ -lm @EMOTION_MODULE_GSTREAMER1_LIBS@
2669generic_evas_gst_evas_image_loader_gst_DEPENDENCIES = @USE_EINA_INTERNAL_LIBS@
2670endif
diff --git a/src/generic/.gitignore b/src/generic/.gitignore
index 19891172cb..498f89de87 100644
--- a/src/generic/.gitignore
+++ b/src/generic/.gitignore
@@ -4,3 +4,4 @@
4/evas/raw/evas_image_loader.raw 4/evas/raw/evas_image_loader.raw
5/evas/xcf/evas_image_loader.xcf 5/evas/xcf/evas_image_loader.xcf
6/evas/svg/evas_image_loader.svg 6/evas/svg/evas_image_loader.svg
7/evas/gst/evas_image_loader.gst
diff --git a/src/generic/evas/gst/main.c b/src/generic/evas/gst/main.c
new file mode 100644
index 0000000000..d9e6fa786c
--- /dev/null
+++ b/src/generic/evas/gst/main.c
@@ -0,0 +1,292 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <sys/mman.h>
6#include <fcntl.h>
7#include <unistd.h>
8
9#include <gst/gst.h>
10
11#include <Eina.h>
12
13#include "shmfile.h"
14#include "timeout.h"
15
16#define DATA32 unsigned int
17
18//#define GST_DBG
19
20#ifdef GST_DBG
21#define D(fmt, args...) fprintf(stderr, fmt, ## args)
22#else
23#define D(fmt, args...)
24#endif
25
26#ifdef WORDS_BIGENDIAN
27# define CAPS "video/x-raw,format=ARGB"
28#else
29# define CAPS "video/x-raw,format=BGRA"
30#endif
31
32static GstElement *pipeline = NULL;
33static GstElement *sink = NULL;
34static gint64 duration = -1;
35
36int width = 0;
37int height = 0;
38void *data = NULL;
39
40
41static Eina_Bool
42_gst_init(const char *filename)
43{
44 GstPad *pad;
45 GstCaps *caps;
46 GstStructure *structure;
47 gchar *descr;
48 gchar *uri;
49 GError *error = NULL;
50 GstFormat format;
51 GstStateChangeReturn ret;
52// int vidstr = 0;
53
54 if (!filename || !*filename)
55 return EINA_FALSE;
56
57 if (!gst_init_check(NULL, NULL, &error))
58 return EINA_FALSE;
59
60 if ((*filename == '/') || (*filename == '~'))
61 {
62 uri = g_filename_to_uri(filename, NULL, NULL);
63 if (!uri)
64 {
65 D("could not create new uri from %s", filename);
66 goto unref_pipeline;
67 }
68 }
69 else
70 uri = strdup(filename);
71
72 D("Setting file %s\n", uri);
73
74 descr = g_strdup_printf("uridecodebin uri=%s ! typefind ! videoconvert ! "
75 " appsink name=sink caps=\"" CAPS "\"", uri);
76 pipeline = gst_parse_launch(descr, &error);
77 free(uri);
78
79 if (error != NULL)
80 {
81 D("could not construct pipeline: %s\n", error->message);
82 g_error_free (error);
83 goto gst_shutdown;
84 }
85/* needs gst 1.0+
86 * also only works on playbin objects!!! this is a uridecodebin!
87 g_object_get(G_OBJECT(pipeline),
88 "n-video", &vidstr,
89 NULL);
90 if (vidstr <= 0)
91 {
92 D("no video stream\n");
93 goto gst_shutdown;
94 }
95*/
96 sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
97
98 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
99 switch (ret)
100 {
101 case GST_STATE_CHANGE_FAILURE:
102 D("failed to play the file\n");
103 goto unref_pipeline;
104 case GST_STATE_CHANGE_NO_PREROLL:
105 D("live sources not supported yet\n");
106 goto unref_pipeline;
107 default:
108 break;
109 }
110
111 ret = gst_element_get_state((pipeline), NULL, NULL, GST_CLOCK_TIME_NONE);
112 if (ret == GST_STATE_CHANGE_FAILURE)
113 {
114 D("could not complete pause\n");
115 goto unref_pipeline;
116 }
117
118 format = GST_FORMAT_TIME;
119 gst_element_query_duration (pipeline, format, &duration);
120 if (duration == -1)
121 {
122 fprintf(stderr, "duration fetch err\n");
123 D("could not retrieve the duration, set it to 1s\n");
124 duration = 1 * GST_SECOND;
125 }
126
127 pad = gst_element_get_static_pad(sink, "sink");
128 if (!pad)
129 {
130 D("could not retrieve the sink pad\n");
131 goto unref_pipeline;
132 }
133
134 caps = gst_pad_get_current_caps(pad);
135 if (!caps)
136 goto unref_pad;
137
138 structure = gst_caps_get_structure(caps, 0);
139
140 if (!gst_structure_get_int(structure, "width", &width))
141 goto unref_caps;
142 if (!gst_structure_get_int(structure, "height", &height))
143 goto unref_caps;
144
145 gst_caps_unref(caps);
146 gst_object_unref(pad);
147
148 return EINA_TRUE;
149
150 unref_caps:
151 gst_caps_unref(caps);
152 unref_pad:
153 gst_object_unref(pad);
154 unref_pipeline:
155 gst_element_set_state (pipeline, GST_STATE_NULL);
156 gst_object_unref(pipeline);
157 gst_shutdown:
158 gst_deinit();
159
160 return EINA_FALSE;
161}
162
163static void
164_gst_shutdown()
165{
166 gst_element_set_state (pipeline, GST_STATE_NULL);
167 gst_object_unref(pipeline);
168 gst_deinit();
169}
170
171static void
172_gst_load_image(int size_w EINA_UNUSED, int size_h EINA_UNUSED, double pos)
173{
174 GstBuffer *buffer;
175 GstMapInfo info;
176 GstSample *sample;
177
178 D("load image\n");
179 if (pos >= 0.0)
180 gst_element_seek_simple(pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
181 pos);
182 else
183 gst_element_seek_simple(pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
184 duration / 2);
185 g_signal_emit_by_name(sink, "pull-preroll", &sample, NULL);
186
187 shm_alloc(width * height * sizeof(DATA32));
188 if (!shm_addr) return;
189 data = shm_addr;
190
191 buffer = gst_sample_get_buffer (sample);
192 gst_buffer_map (buffer, &info, GST_MAP_READ);
193 D("load image: %p %d\n", info.data, info.size);
194
195 memcpy(data, info.data, info.size);
196
197 gst_buffer_unmap(buffer, &info);
198}
199
200int
201main(int argc, char **argv)
202{
203 char *file, *p;
204 int i, numonly;
205 int size_w = 0, size_h = 0;
206 int head_only = 0;
207 long long pos = -1.0;
208
209 if (argc < 2) return -1;
210 // file is ALWAYS first arg, other options come after
211 file = argv[1];
212 for (i = 2; i < argc; i++)
213 {
214 if (!strcmp(argv[i], "-head"))
215 // asked to only load header, not body/data
216 head_only = 1;
217 else if (!strcmp(argv[i], "-key"))
218 {
219 i++;
220 numonly = 1;
221 for (p = argv[i]; *p; p++)
222 {
223 if ((*p < '0') || (*p > '9'))
224 {
225 numonly = 0;
226 break;
227 }
228 }
229 if (numonly) pos = atoll(argv[i]) * 1000000;
230 i++;
231 }
232 else if (!strcmp(argv[i], "-opt-scale-down-by"))
233 { // not used by ps loader
234 i++;
235 // int scale_down = atoi(argv[i]);
236 }
237 else if (!strcmp(argv[i], "-opt-dpi"))
238 {
239 i++;
240 }
241 else if (!strcmp(argv[i], "-opt-size"))
242 { // not used by ps loader
243 i++;
244 size_w = atoi(argv[i]);
245 i++;
246 size_h = atoi(argv[i]);
247 }
248 }
249
250 timeout_init(10);
251
252 D("_gst_init_file\n");
253
254 if (!_gst_init(file))
255 return -1;
256 D("_gst_init done\n");
257
258 if ((pos >= 0) && (pos > duration)) return -1;
259
260 if (!head_only)
261 {
262 _gst_load_image(size_w, size_h, pos);
263 }
264
265 D("size...: %ix%i\n", width, height);
266 D("alpha..: 0\n");
267
268 printf("size %i %i\n", width, height);
269 printf("alpha 0\n");
270
271 if (!head_only)
272 {
273 if (shm_fd >= 0)
274 {
275 printf("shmfile %s\n", shmfile);
276 }
277 else
278 {
279 // could also to "tmpfile %s\n" like shmfile but just
280 // a mmaped tmp file on the system
281 printf("data\n");
282 fwrite(data, width * height * sizeof(DATA32), 1, stdout);
283 }
284 shm_free();
285 }
286 else
287 printf("done\n");
288
289 _gst_shutdown();
290 fflush(stdout);
291 return 0;
292}
diff --git a/src/generic/evas/gst/main_0_10.c b/src/generic/evas/gst/main_0_10.c
new file mode 100644
index 0000000000..3e0c02b823
--- /dev/null
+++ b/src/generic/evas/gst/main_0_10.c
@@ -0,0 +1,278 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <sys/mman.h>
6#include <fcntl.h>
7#include <unistd.h>
8
9#include <gst/gst.h>
10
11#include <Eina.h>
12
13#include "shmfile.h"
14#include "timeout.h"
15
16#define DATA32 unsigned int
17
18//#define GST_DBG
19
20#ifdef GST_DBG
21#define D(fmt, args...) fprintf(stderr, fmt, ## args)
22#else
23#define D(fmt, args...)
24#endif
25
26#define CAPS "video/x-raw-rgb,bpp=(int)32,depth=(int)32,endianness=(int)4321,red_mask=(int)0x0000ff00, green_mask=(int)0x00ff0000, blue_mask=(int)0xff000000"
27
28static GstElement *pipeline = NULL;
29static GstElement *sink = NULL;
30static gint64 duration = -1;
31
32int width = 0;
33int height = 0;
34void *data = NULL;
35
36
37static Eina_Bool
38_gst_init(const char *filename)
39{
40 GstPad *pad;
41 GstCaps *caps;
42 GstStructure *structure;
43 gchar *descr;
44 gchar *uri;
45 GError *error = NULL;
46 GstFormat format;
47 GstStateChangeReturn ret;
48// int vidstr = 0;
49
50 if (!filename || !*filename)
51 return EINA_FALSE;
52
53 if (!gst_init_check(NULL, NULL, &error))
54 return EINA_FALSE;
55
56 if ((*filename == '/') || (*filename == '~'))
57 {
58 uri = g_filename_to_uri(filename, NULL, NULL);
59 if (!uri)
60 {
61 D("could not create new uri from %s", filename);
62 goto unref_pipeline;
63 }
64 }
65 else
66 uri = strdup(filename);
67
68 D("Setting file %s\n", uri);
69
70 descr = g_strdup_printf("uridecodebin uri=%s ! typefind ! ffmpegcolorspace ! "
71 " appsink name=sink caps=\"" CAPS "\"", uri);
72 pipeline = gst_parse_launch(descr, &error);
73 free(uri);
74
75 if (error != NULL)
76 {
77 D("could not construct pipeline: %s\n", error->message);
78 g_error_free (error);
79 goto gst_shutdown;
80 }
81/* needs gst 1.0+
82 * also only works on playbin objects!!! this is a uridecodebin!
83 g_object_get(G_OBJECT(pipeline),
84 "n-video", &vidstr,
85 NULL);
86 if (vidstr <= 0)
87 {
88 D("no video stream\n");
89 goto gst_shutdown;
90 }
91*/
92 sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
93
94 ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
95 switch (ret)
96 {
97 case GST_STATE_CHANGE_FAILURE:
98 D("failed to play the file\n");
99 goto unref_pipeline;
100 case GST_STATE_CHANGE_NO_PREROLL:
101 D("live sources not supported yet\n");
102 goto unref_pipeline;
103 default:
104 break;
105 }
106
107 ret = gst_element_get_state((pipeline), NULL, NULL, GST_CLOCK_TIME_NONE);
108 if (ret == GST_STATE_CHANGE_FAILURE)
109 {
110 D("could not complete pause\n");
111 goto unref_pipeline;
112 }
113
114 format = GST_FORMAT_TIME;
115 gst_element_query_duration (pipeline, &format, &duration);
116 if (duration == -1)
117 {
118 D("could not retrieve the duration, set it to 1s\n");
119 duration = 1 * GST_SECOND;
120 }
121
122 pad = gst_element_get_static_pad(sink, "sink");
123 if (!pad)
124 {
125 D("could not retrieve the sink pad\n");
126 goto unref_pipeline;
127 }
128
129 caps = gst_pad_get_negotiated_caps(pad);
130 if (!caps)
131 goto unref_pad;
132
133 structure = gst_caps_get_structure(caps, 0);
134
135 if (!gst_structure_get_int(structure, "width", &width))
136 goto unref_caps;
137 if (!gst_structure_get_int(structure, "height", &height))
138 goto unref_caps;
139
140 gst_caps_unref(caps);
141 gst_object_unref(pad);
142
143 return EINA_TRUE;
144
145 unref_caps:
146 gst_caps_unref(caps);
147 unref_pad:
148 gst_object_unref(pad);
149 unref_pipeline:
150 gst_element_set_state (pipeline, GST_STATE_NULL);
151 gst_object_unref(pipeline);
152 gst_shutdown:
153 gst_deinit();
154
155 return EINA_FALSE;
156}
157
158static void
159_gst_shutdown()
160{
161 gst_element_set_state (pipeline, GST_STATE_NULL);
162 gst_object_unref(pipeline);
163 gst_deinit();
164}
165
166static void
167_gst_load_image(int size_w EINA_UNUSED, int size_h EINA_UNUSED, double pos)
168{
169 GstBuffer *buffer;
170
171 D("load image\n");
172 if (pos >= 0.0)
173 gst_element_seek_simple(pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
174 pos * 1000000000.0);
175 else
176 gst_element_seek_simple(pipeline, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
177 duration / 2);
178 g_signal_emit_by_name(sink, "pull-preroll", &buffer, NULL);
179 D("load image : %p %d\n", GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
180
181 shm_alloc(width * height * sizeof(DATA32));
182 if (!shm_addr) return;
183 data = shm_addr;
184
185 memcpy(data, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
186}
187
188int
189main(int argc, char **argv)
190{
191 char *file, *p;
192 int i, numonly;
193 int size_w = 0, size_h = 0;
194 int head_only = 0;
195 long long pos = -1.0;
196
197 if (argc < 2) return -1;
198 // file is ALWAYS first arg, other options come after
199 file = argv[1];
200 for (i = 2; i < argc; i++)
201 {
202 if (!strcmp(argv[i], "-head"))
203 // asked to only load header, not body/data
204 head_only = 1;
205 else if (!strcmp(argv[i], "-key"))
206 {
207 i++;
208 numonly = 1;
209 for (p = argv[i]; *p; p++)
210 {
211 if ((!*p < '0') || (*p > 9))
212 {
213 numonly = 0;
214 break;
215 }
216 }
217 if (numonly) pos = (double)(atoll(argv[i])) / 1000.0;
218 i++;
219 }
220 else if (!strcmp(argv[i], "-opt-scale-down-by"))
221 { // not used by ps loader
222 i++;
223 // int scale_down = atoi(argv[i]);
224 }
225 else if (!strcmp(argv[i], "-opt-dpi"))
226 {
227 i++;
228 }
229 else if (!strcmp(argv[i], "-opt-size"))
230 { // not used by ps loader
231 i++;
232 size_w = atoi(argv[i]);
233 i++;
234 size_h = atoi(argv[i]);
235 }
236 }
237
238 timeout_init(10);
239
240 D("_gst_init_file\n");
241
242 if (!_gst_init(file))
243 return -1;
244 D("_gst_init done\n");
245
246 if (!head_only)
247 {
248 _gst_load_image(size_w, size_h, pos);
249 }
250
251 D("size...: %ix%i\n", width, height);
252 D("alpha..: 0\n");
253
254 printf("size %i %i\n", width, height);
255 printf("alpha 0\n");
256
257 if (!head_only)
258 {
259 if (shm_fd >= 0)
260 {
261 printf("shmfile %s\n", shmfile);
262 }
263 else
264 {
265 // could also to "tmpfile %s\n" like shmfile but just
266 // a mmaped tmp file on the system
267 printf("data\n");
268 fwrite(data, width * height * sizeof(DATA32), 1, stdout);
269 }
270 shm_free();
271 }
272 else
273 printf("done\n");
274
275 _gst_shutdown();
276 fflush(stdout);
277 return 0;
278}