various complicated half finished attempts at getting play right
[sparrow.git] / app.h
blobbe192bf1975247f465e1fcfcc8e1c632361f6ec2
2 #define PIPELINE_TEST 0
4 #ifndef UNUSED
5 #define UNUSED __attribute__ ((unused))
6 #else
7 #warning UNUSED is set
8 #endif
10 #define WIDTH 320
11 #define HEIGHT 240
13 #define COMMON_CAPS \
14 "framerate", GST_TYPE_FRACTION, 30, 1, \
15 "width", G_TYPE_INT, WIDTH, \
16 "height", G_TYPE_INT, HEIGHT, \
17 NULL
19 const gchar *PLUGIN_DIR = "/home/douglas/sparrow";
21 const guchar *SPARROW_XML = (guchar *)"/home/douglas/sparrow/sparrow.xml";
23 #if PIPELINE_TEST
25 static inline GstPipeline *
26 make_pipeline(GstElement *sink){
27 GstPipeline *pipeline = GST_PIPELINE(gst_pipeline_new (NULL));
28 GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
29 //GstElement *warp = gst_element_factory_make ("warptv", NULL);
30 //GstElement *colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
32 gst_bin_add_many(GST_BIN (pipeline),
33 src,
34 //warp,
35 //colorspace,
36 sink, NULL);
37 gst_element_link_many(src,
38 //warp,
39 //colorspace,
40 sink, NULL);
41 return pipeline;
44 #else
46 static inline GstPipeline *
47 make_pipeline(GstElement *sink){
48 GstPipeline *pipeline = GST_PIPELINE(gst_pipeline_new("sparow_pipeline"));
49 GstElement *src = gst_element_factory_make("v4l2src", NULL);
50 //GstElement *src = gst_element_factory_make("videotestsrc", NULL);
51 GstElement *caps1 = gst_element_factory_make("capsfilter", "caps1");
52 GstElement *cs = gst_element_factory_make("ffmpegcolorspace", NULL);
53 GstElement *sparrow = gst_element_factory_make("sparrow", NULL);
54 GstElement *caps2 = gst_element_factory_make("capsfilter", "caps1");
55 GstElement *cs2 = gst_element_factory_make("ffmpegcolorspace", NULL);
57 g_object_set(G_OBJECT(caps1), "caps",
58 gst_caps_new_simple ("video/x-raw-yuv",
59 "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
60 COMMON_CAPS), NULL);
62 g_object_set(G_OBJECT(caps2), "caps",
63 gst_caps_new_simple ("video/x-raw-rgb",
64 COMMON_CAPS), NULL);
67 g_object_set(G_OBJECT(sparrow),
68 "timer", TRUE,
69 "debug", FALSE,
70 "rngseed", 1,
71 "colour", 1,
72 //"reload", "dumpfiles/gtk.dump",
73 //"save", "dumpfiles/gtk.dump",
74 NULL);
76 gst_bin_add_many (GST_BIN(pipeline), src,
77 caps1,
78 cs,
79 sparrow,
80 caps2,
81 cs2,
82 sink,
83 NULL);
84 gst_element_link_many(src,
85 caps1,
86 cs,
87 sparrow,
88 caps2,
89 cs2,
90 sink,
91 NULL);
92 return pipeline;
97 static inline void
98 post_tee_pipeline(GstPipeline *pipeline, GstElement *tee, GstPad *pad, GstElement *sink,
99 int rngseed, int colour, int timer, int debug){
100 GstElement *queue = gst_element_factory_make ("queue", NULL);
101 GstElement *sparrow = gst_element_factory_make("sparrow", NULL);
102 GstElement *caps_posteriori = gst_element_factory_make("capsfilter", NULL);
103 GstElement *cs_posteriori = gst_element_factory_make("ffmpegcolorspace", NULL);
104 //GstPad *qpad = gst_element_get_compatible_pad(queue, pad, NULL);
106 g_object_set(G_OBJECT(caps_posteriori), "caps",
107 gst_caps_new_simple ("video/x-raw-rgb",
108 COMMON_CAPS), NULL);
110 g_object_set(G_OBJECT(sparrow),
111 "timer", timer,
112 "debug", debug,
113 "rngseed", rngseed,
114 "colour", colour,
115 //"reload", "dumpfiles/gtk.dump",
116 //"save", "dumpfiles/gtk.dump",
117 NULL);
119 gst_bin_add_many (GST_BIN(pipeline),
120 queue,
121 sparrow,
122 caps_posteriori,
123 cs_posteriori,
124 sink,
125 NULL);
127 //gst_pad_link(pad, qpad);
129 gst_element_link_many(tee,
130 queue,
131 sparrow,
132 caps_posteriori,
133 cs_posteriori,
134 sink,
135 NULL);
139 gst-launch-0.10 --gst-plugin-path=. --gst-debug=sparrow:5 v4l2src ! ffmpegcolorspace ! tee name=vid2 \
140 ! queue ! sparrow ! 'video/x-raw-rgb,width=320,height=240,framerate=25/1' ! ximagesink \
141 vid2. ! queue ! sparrow ! 'video/x-raw-rgb,width=320,height=240,framerate=25/1' ! ximagesink
144 static inline GstPipeline *
145 make_dual_pipeline(GstElement *sink1, GstElement *sink2)
147 GstPipeline *pipeline = GST_PIPELINE(gst_pipeline_new("sparow_pipeline"));
148 //GstElement *src = gst_element_factory_make("v4l2src", NULL);
149 GstElement *src = gst_element_factory_make("videotestsrc", NULL);
150 GstElement *caps_priori = gst_element_factory_make("capsfilter", NULL);
151 GstElement *cs_priori = gst_element_factory_make("ffmpegcolorspace", NULL);
152 GstElement *caps_interiori = gst_element_factory_make("capsfilter", NULL);
153 GstElement *tee = gst_element_factory_make ("tee", NULL);
155 g_object_set(G_OBJECT(caps_priori), "caps",
156 gst_caps_new_simple ("video/x-raw-yuv",
157 "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
158 COMMON_CAPS), NULL);
160 g_object_set(G_OBJECT(caps_interiori), "caps",
161 gst_caps_new_simple ("video/x-raw-rgb",
162 COMMON_CAPS), NULL);
164 gst_bin_add_many(GST_BIN(pipeline),
165 src,
166 caps_priori,
167 cs_priori,
168 caps_interiori,
169 tee,
170 NULL);
172 gst_element_link_many(src,
173 caps_priori,
174 cs_priori,
175 //caps_interiori,
176 tee,
177 NULL);
179 GstPad *pad1; //= gst_element_get_request_pad (tee, "src%d");
180 GstPad *pad2; //= gst_element_get_request_pad (tee, "src%d");
182 post_tee_pipeline(pipeline, tee, pad1, sink1,
183 1, 1, 1, 0);
184 post_tee_pipeline(pipeline, tee, pad2, sink2,
185 2, 2, 0, 0);
188 return pipeline;
191 pad = gst_element_get_static_pad (aqueue, "sink");
192 rpad = gst_element_get_request_pad (tee, "src%d");
193 gst_pad_link (rpad, pad);
194 gst_object_unref (rpad);
195 gst_object_unref (pad);
196 gst_element_link_pads (aqueue, "src", asink, "sink");
198 pad = gst_element_get_static_pad (vqueue, "sink");
199 rpad = gst_element_get_request_pad (tee, "src%d");
200 gst_pad_link (rpad, pad);
201 gst_object_unref (rpad);
202 gst_object_unref (pad);
204 pad = gst_element_get_static_pad (tee, "sink");
205 gst_element_add_pad (element, gst_ghost_pad_new ("sink", pad));
206 gst_object_unref (pad);
227 #endif