summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_v4l.c
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/emotion_gstreamer_pipeline_v4l.c
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 '')
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_v4l.c87
1 files changed, 87 insertions, 0 deletions
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}