summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2009-02-22 17:16:47 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2009-02-22 17:16:47 +0000
commit8477bdb496b505f9c72a29b7506114593447c9fd (patch)
treef4f6377940fcaf1dabe36b835b8ad2bdf615a41a /legacy/emotion/src/modules/gstreamer
parent31a7c3c0d24a3e45f419183862ad1899bb487313 (diff)
gstreamer v4l support to emotion
This patch adds gstreamer v4l support to emotion. If you got a webcam it can be tested by doing: emotion_test -gstreamer v4l:// This will use the first video device /dev/video0. If you do not have a webcam, you can also try it using the Virtual Video driver By: Lars Munch <lars@segv.dk> SVN revision: 39147
Diffstat (limited to 'legacy/emotion/src/modules/gstreamer')
-rw-r--r--legacy/emotion/src/modules/gstreamer/Makefile.am5
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c11
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.h1
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_v4l.c87
4 files changed, 102 insertions, 2 deletions
diff --git a/legacy/emotion/src/modules/gstreamer/Makefile.am b/legacy/emotion/src/modules/gstreamer/Makefile.am
index f3519afcaa..6aee2e3fb3 100644
--- a/legacy/emotion/src/modules/gstreamer/Makefile.am
+++ b/legacy/emotion/src/modules/gstreamer/Makefile.am
@@ -24,10 +24,11 @@ emotion_gstreamer_pipeline.h \
24emotion_gstreamer_pipeline_cdda.c \ 24emotion_gstreamer_pipeline_cdda.c \
25emotion_gstreamer_pipeline_dvd.c \ 25emotion_gstreamer_pipeline_dvd.c \
26emotion_gstreamer_pipeline_file.c \ 26emotion_gstreamer_pipeline_file.c \
27emotion_gstreamer_pipeline_uri.c 27emotion_gstreamer_pipeline_uri.c \
28emotion_gstreamer_pipeline_v4l.c
28gstreamer_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ @GST_LIBS@ $(top_builddir)/src/lib/libemotion.la 29gstreamer_la_LIBADD = @EVAS_LIBS@ @ECORE_LIBS@ @GST_LIBS@ $(top_builddir)/src/lib/libemotion.la
29gstreamer_la_LDFLAGS = -module -avoid-version 30gstreamer_la_LDFLAGS = -module -avoid-version
30gstreamer_la_LIBTOOLFLAGS = --tag=disable-static 31gstreamer_la_LIBTOOLFLAGS = --tag=disable-static
31gstreamer_la_DEPENDENCIES = $(top_builddir)/config.h 32gstreamer_la_DEPENDENCIES = $(top_builddir)/config.h
32 33
33endif \ No newline at end of file 34endif
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
index b76eb25bab..1516bd357f 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer.c
@@ -390,6 +390,17 @@ em_file_open(const char *file,
390 return 0; 390 return 0;
391 } 391 }
392 } 392 }
393 /* v4l */
394 else if (strstr(file, "v4l://"))
395 {
396 fprintf(stderr, "[Emotion] [gst] build V4L pipeline\n");
397 if (!(emotion_pipeline_v4l_build(ev, file)))
398 {
399 fprintf(stderr, "[Emotion] [gst] error while building V4L pipeline\n");
400 gst_object_unref(ev->pipeline);
401 return 0;
402 }
403 }
393 /* Normal media file */ 404 /* Normal media file */
394 else 405 else
395 { 406 {
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.h b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.h
index 2e8a703294..3a8b849523 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.h
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.h
@@ -14,6 +14,7 @@ int emotion_pipeline_cdda_build (void *video, const char * device, uns
14int emotion_pipeline_file_build (void *video, const char *file); 14int emotion_pipeline_file_build (void *video, const char *file);
15int emotion_pipeline_uri_build (void *video, const char *uri); 15int emotion_pipeline_uri_build (void *video, const char *uri);
16int emotion_pipeline_dvd_build (void *video, const char *device); 16int emotion_pipeline_dvd_build (void *video, const char *device);
17int emotion_pipeline_v4l_build (void *video, const char *device);
17int emotion_pipeline_cdda_track_count_get (void *video); 18int emotion_pipeline_cdda_track_count_get (void *video);
18 19
19GstElement *emotion_audio_sink_create (Emotion_Gstreamer_Video *ev, int index); 20GstElement *emotion_audio_sink_create (Emotion_Gstreamer_Video *ev, int index);
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_v4l.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_v4l.c
new file mode 100644
index 0000000000..c978773561
--- /dev/null
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_v4l.c
@@ -0,0 +1,87 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#include "emotion_gstreamer.h"
5#include "emotion_gstreamer_pipeline.h"
6
7int
8emotion_pipeline_v4l_build(void *video, const char *device)
9{
10 GstElement *v4l2src, *cspace, *queue, *sink;
11 Emotion_Video_Sink *vsink;
12 GstCaps *caps;
13 Emotion_Gstreamer_Video *ev;
14 char dev[128];
15 int devno;
16
17 ev = (Emotion_Gstreamer_Video *)video;
18 if (!ev) return 0;
19
20 v4l2src = gst_element_factory_make("v4l2src", "v4l2src");
21 cspace = gst_element_factory_make("ffmpegcolorspace", "cspace");
22 queue = gst_element_factory_make("queue", "queue");
23 sink = gst_element_factory_make("fakesink", "sink");
24
25 if ((!v4l2src) || (!cspace) || (!queue) || (!sink))
26 goto failure;
27
28 if (sscanf(device, "v4l://%d", &devno) != 1)
29 devno = 0;
30
31 snprintf(dev, sizeof(dev), "/dev/video%d", devno);
32 g_object_set (v4l2src, "device", dev, NULL);
33
34 gst_bin_add_many(GST_BIN(ev->pipeline), v4l2src, cspace, queue, sink, NULL);
35
36 caps = gst_caps_new_simple("video/x-raw-yuv",
37 "width", G_TYPE_INT, 320,
38 "height", G_TYPE_INT, 240,
39 NULL);
40 if (!gst_element_link_filtered(v4l2src, cspace, caps))
41 {
42 gst_caps_unref(caps);
43 goto failure;
44 }
45 gst_caps_unref(caps);
46
47 caps = gst_caps_new_simple("video/x-raw-rgb",
48 "bpp", G_TYPE_INT, 32,
49 "width", G_TYPE_INT, 320,
50 "height", G_TYPE_INT, 240,
51 NULL);
52 if (!gst_element_link_filtered(cspace, queue, caps))
53 {
54 gst_caps_unref(caps);
55 goto failure;
56 }
57 gst_caps_unref(caps);
58
59 gst_element_link(queue, sink);
60
61 vsink = emotion_video_sink_new(ev);
62 if(!vsink) goto failure;
63 vsink->sink = sink;
64 vsink->width=320;
65 vsink->height=240;
66 vsink->fourcc = GST_MAKE_FOURCC ('A', 'R', 'G', 'B');
67
68 g_object_set(G_OBJECT(vsink->sink), "sync", FALSE, NULL);
69 g_object_set(G_OBJECT(vsink->sink), "signal-handoffs", TRUE, NULL);
70 g_signal_connect(G_OBJECT(vsink->sink),
71 "handoff",
72 G_CALLBACK(cb_handoff), ev);
73
74 return 1;
75
76failure:
77 if(v4l2src)
78 gst_object_unref(v4l2src);
79 if(cspace)
80 gst_object_unref(cspace);
81 if(queue)
82 gst_object_unref(queue);
83 if(sink)
84 gst_object_unref(sink);
85
86 return 0;
87}