summaryrefslogtreecommitdiff
path: root/legacy/emotion/src/modules/gstreamer
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2008-07-06 09:52:21 +0000
committerSebastian Dransfeld <sd@tango.flipp.net>2008-07-06 09:52:21 +0000
commitec19c6f7007ba54ecfe922514104ab217d0eae81 (patch)
tree7cf4ed71237a6cd069db8683fdb84e6b58c1a538 /legacy/emotion/src/modules/gstreamer
parent10bac60aa1e04aa3c6ed0db040241c51e0a41651 (diff)
formatting
SVN revision: 35011
Diffstat (limited to 'legacy/emotion/src/modules/gstreamer')
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c810
-rw-r--r--legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c125
2 files changed, 484 insertions, 451 deletions
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
index 40dabdd5c7..4499a86c63 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline.c
@@ -10,181 +10,194 @@
10 10
11 11
12gboolean 12gboolean
13emotion_pipeline_pause (GstElement *pipeline) 13emotion_pipeline_pause(GstElement *pipeline)
14{ 14{
15 GstStateChangeReturn res; 15 GstStateChangeReturn res;
16 16
17 res = gst_element_set_state ((pipeline), GST_STATE_PAUSED); 17 res = gst_element_set_state((pipeline), GST_STATE_PAUSED);
18 if (res == GST_STATE_CHANGE_FAILURE) { 18 if (res == GST_STATE_CHANGE_FAILURE)
19 g_print ("Emotion-Gstreamer ERROR: could not pause\n"); 19 {
20 return 0; 20 g_print("Emotion-Gstreamer ERROR: could not pause\n");
21 } 21 return 0;
22 }
22 23
23 res = gst_element_get_state ((pipeline), NULL, NULL, GST_CLOCK_TIME_NONE); 24 res = gst_element_get_state((pipeline), NULL, NULL, GST_CLOCK_TIME_NONE);
24 if (res != GST_STATE_CHANGE_SUCCESS) { 25 if (res != GST_STATE_CHANGE_SUCCESS)
25 g_print ("Emotion-Gstreamer ERROR: could not complete pause\n"); 26 {
26 return 0; 27 g_print("Emotion-Gstreamer ERROR: could not complete pause\n");
27 } 28 return 0;
29 }
28 30
29 return 1; 31 return 1;
30} 32}
31 33
32/* Send the video frame to the evas object */ 34/* Send the video frame to the evas object */
33void 35void
34cb_handoff (GstElement *fakesrc, 36cb_handoff(GstElement *fakesrc,
35 GstBuffer *buffer, 37 GstBuffer *buffer,
36 GstPad *pad, 38 GstPad *pad,
37 gpointer user_data) 39 gpointer user_data)
38{ 40{
39 GstQuery *query; 41 GstQuery *query;
40 void *buf[2]; 42 void *buf[2];
41 43
42 Emotion_Gstreamer_Video *ev = ( Emotion_Gstreamer_Video *) user_data; 44 Emotion_Gstreamer_Video *ev = (Emotion_Gstreamer_Video *)user_data;
43 if (!ev) 45 if (!ev)
44 return; 46 return;
45 47
46 if (!ev->video_mute) { 48 if (!ev->video_mute)
47 if (!ev->obj_data) 49 {
48 ev->obj_data = (void*) malloc (GST_BUFFER_SIZE(buffer) * sizeof(void)); 50 if (!ev->obj_data)
49 51 ev->obj_data = malloc(GST_BUFFER_SIZE(buffer) * sizeof(void));
50 memcpy ( ev->obj_data, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer)); 52
51 buf[0] = GST_BUFFER_DATA(buffer); 53 memcpy(ev->obj_data, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer));
52 buf[1] = buffer; 54 buf[0] = GST_BUFFER_DATA(buffer);
53 write(ev->fd_ev_write, buf, sizeof(buf)); 55 buf[1] = buffer;
54 } 56 write(ev->fd_ev_write, buf, sizeof(buf));
55 else { 57 }
56 Emotion_Audio_Sink *asink; 58 else
57 asink = (Emotion_Audio_Sink *)ecore_list_index_goto (ev->audio_sinks, ev->audio_sink_nbr); 59 {
58 _emotion_video_pos_update(ev->obj, ev->position, asink->length_time); 60 Emotion_Audio_Sink *asink;
59 } 61 asink = (Emotion_Audio_Sink *)ecore_list_index_goto(ev->audio_sinks, ev->audio_sink_nbr);
60 62 _emotion_video_pos_update(ev->obj, ev->position, asink->length_time);
61 query = gst_query_new_position (GST_FORMAT_TIME); 63 }
62 if (gst_pad_query (gst_pad_get_peer (pad), query)) { 64
63 gint64 position; 65 query = gst_query_new_position(GST_FORMAT_TIME);
64 66 if (gst_pad_query(gst_pad_get_peer(pad), query))
65 gst_query_parse_position (query, NULL, &position); 67 {
66 ev->position = (double)position / (double)GST_SECOND; 68 gint64 position;
67 } 69
68 gst_query_unref (query); 70 gst_query_parse_position(query, NULL, &position);
71 ev->position = (double)position / (double)GST_SECOND;
72 }
73 gst_query_unref(query);
69} 74}
70 75
71void 76void
72file_new_decoded_pad_cb (GstElement *decodebin, 77file_new_decoded_pad_cb(GstElement *decodebin,
73 GstPad *new_pad, 78 GstPad *new_pad,
74 gboolean last, 79 gboolean last,
75 gpointer user_data) 80 gpointer user_data)
76{ 81{
77 Emotion_Gstreamer_Video *ev; 82 Emotion_Gstreamer_Video *ev;
78 GstCaps *caps; 83 GstCaps *caps;
79 gchar *str; 84 gchar *str;
80 85
81 ev = (Emotion_Gstreamer_Video *)user_data; 86 ev = (Emotion_Gstreamer_Video *)user_data;
82 caps = gst_pad_get_caps (new_pad); 87 caps = gst_pad_get_caps(new_pad);
83 str = gst_caps_to_string (caps); 88 str = gst_caps_to_string(caps);
84 /* video stream */ 89 /* video stream */
85 if (g_str_has_prefix (str, "video/")) { 90 if (g_str_has_prefix(str, "video/"))
86 Emotion_Video_Sink *vsink; 91 {
87 GstElement *queue; 92 Emotion_Video_Sink *vsink;
88 GstPad *videopad; 93 GstElement *queue;
89 94 GstPad *videopad;
90 vsink = (Emotion_Video_Sink *)malloc (sizeof (Emotion_Video_Sink)); 95
91 if (!vsink) return; 96 vsink = (Emotion_Video_Sink *)malloc(sizeof(Emotion_Video_Sink));
92 if (!ecore_list_append (ev->video_sinks, vsink)) { 97 if (!vsink) return;
93 free(vsink); 98 if (!ecore_list_append(ev->video_sinks, vsink))
94 return; 99 {
95 } 100 free(vsink);
96 101 return;
97 queue = gst_element_factory_make ("queue", NULL); 102 }
98 vsink->sink = gst_element_factory_make ("fakesink", "videosink"); 103
99 gst_bin_add_many (GST_BIN (ev->pipeline), queue, vsink->sink, NULL); 104 queue = gst_element_factory_make("queue", NULL);
100 gst_element_link (queue, vsink->sink); 105 vsink->sink = gst_element_factory_make("fakesink", "videosink");
101 videopad = gst_element_get_pad (queue, "sink"); 106 gst_bin_add_many(GST_BIN(ev->pipeline), queue, vsink->sink, NULL);
102 gst_pad_link (new_pad, videopad); 107 gst_element_link(queue, vsink->sink);
103 gst_object_unref (videopad); 108 videopad = gst_element_get_pad(queue, "sink");
104 if (ecore_list_count(ev->video_sinks) == 1) { 109 gst_pad_link(new_pad, videopad);
105 ev->ratio = (double)vsink->width / (double)vsink->height; 110 gst_object_unref(videopad);
106 } 111 if (ecore_list_count(ev->video_sinks) == 1)
107 gst_element_set_state (queue, GST_STATE_PAUSED); 112 {
108 gst_element_set_state (vsink->sink, GST_STATE_PAUSED); 113 ev->ratio = (double)vsink->width / (double)vsink->height;
109 } 114 }
115 gst_element_set_state(queue, GST_STATE_PAUSED);
116 gst_element_set_state(vsink->sink, GST_STATE_PAUSED);
117 }
110 /* audio stream */ 118 /* audio stream */
111 else if (g_str_has_prefix (str, "audio/")) { 119 else if (g_str_has_prefix(str, "audio/"))
112 Emotion_Audio_Sink *asink; 120 {
113 GstPad *audiopad; 121 Emotion_Audio_Sink *asink;
114 122 GstPad *audiopad;
115 asink = (Emotion_Audio_Sink *)malloc (sizeof (Emotion_Audio_Sink)); 123
116 if (!asink) return; 124 asink = (Emotion_Audio_Sink *)malloc(sizeof(Emotion_Audio_Sink));
117 if (!ecore_list_append (ev->audio_sinks, asink)) { 125 if (!asink) return;
118 free(asink); 126 if (!ecore_list_append(ev->audio_sinks, asink))
119 return; 127 {
120 } 128 free(asink);
121 129 return;
122 asink->sink = emotion_audio_sink_create (ev, ecore_list_index (ev->audio_sinks)); 130 }
123 gst_bin_add (GST_BIN (ev->pipeline), asink->sink); 131
124 audiopad = gst_element_get_pad (asink->sink, "sink"); 132 asink->sink = emotion_audio_sink_create(ev, ecore_list_index(ev->audio_sinks));
125 gst_pad_link(new_pad, audiopad); 133 gst_bin_add(GST_BIN(ev->pipeline), asink->sink);
126 gst_element_set_state (asink->sink, GST_STATE_PAUSED); 134 audiopad = gst_element_get_pad(asink->sink, "sink");
127 } 135 gst_pad_link(new_pad, audiopad);
136 gst_element_set_state(asink->sink, GST_STATE_PAUSED);
137 }
128 138
129 free(str); 139 free(str);
130} 140}
131 141
132Emotion_Video_Sink * 142Emotion_Video_Sink *
133emotion_video_sink_new (Emotion_Gstreamer_Video *ev) 143emotion_video_sink_new(Emotion_Gstreamer_Video *ev)
134{ 144{
135 Emotion_Video_Sink *vsink; 145 Emotion_Video_Sink *vsink;
136 146
137 if (!ev) return NULL; 147 if (!ev) return NULL;
138 148
139 vsink = (Emotion_Video_Sink *)malloc (sizeof (Emotion_Video_Sink)); 149 vsink = (Emotion_Video_Sink *)malloc(sizeof(Emotion_Video_Sink));
140 if (!vsink) return NULL; 150 if (!vsink) return NULL;
141 151
142 if (!ecore_list_append (ev->video_sinks, vsink)) { 152 if (!ecore_list_append(ev->video_sinks, vsink))
143 free (vsink); 153 {
144 return NULL; 154 free(vsink);
145 } 155 return NULL;
156 }
146 return vsink; 157 return vsink;
147} 158}
148 159
149void 160void
150emotion_video_sink_free (Emotion_Gstreamer_Video *ev, Emotion_Video_Sink *vsink) 161emotion_video_sink_free(Emotion_Gstreamer_Video *ev, Emotion_Video_Sink *vsink)
151{ 162{
152 if (!ev || !vsink) return; 163 if (!ev || !vsink) return;
153 164
154 if (ecore_list_goto (ev->video_sinks, vsink)) { 165 if (ecore_list_goto(ev->video_sinks, vsink))
155 ecore_list_remove (ev->video_sinks); 166 {
156 free (vsink); 167 ecore_list_remove(ev->video_sinks);
157 } 168 free(vsink);
169 }
158} 170}
159 171
160Emotion_Video_Sink * 172Emotion_Video_Sink *
161emotion_visualization_sink_create (Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink) 173emotion_visualization_sink_create(Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink)
162{ 174{
163 Emotion_Video_Sink *vsink; 175 Emotion_Video_Sink *vsink;
164 176
165 if (!ev) return NULL; 177 if (!ev) return NULL;
166 178
167 vsink = emotion_video_sink_new (ev); 179 vsink = emotion_video_sink_new(ev);
168 if (!vsink) return NULL; 180 if (!vsink) return NULL;
169 181
170 vsink->sink = gst_bin_get_by_name (GST_BIN (asink->sink), "vissink1"); 182 vsink->sink = gst_bin_get_by_name(GST_BIN(asink->sink), "vissink1");
171 if (!vsink->sink) { 183 if (!vsink->sink)
172 emotion_video_sink_free (ev, vsink); 184 {
173 return NULL; 185 emotion_video_sink_free(ev, vsink);
174 } 186 return NULL;
187 }
175 vsink->width = 320; 188 vsink->width = 320;
176 vsink->height = 200; 189 vsink->height = 200;
177 ev->ratio = (double)vsink->width / (double)vsink->height; 190 ev->ratio = (double)vsink->width / (double)vsink->height;
178 vsink->fps_num = 25; 191 vsink->fps_num = 25;
179 vsink->fps_den = 1; 192 vsink->fps_den = 1;
180 vsink->fourcc = GST_MAKE_FOURCC ('A','R','G','B'); 193 vsink->fourcc = GST_MAKE_FOURCC('A', 'R', 'G', 'B');
181 vsink->length_time = asink->length_time; 194 vsink->length_time = asink->length_time;
182 195
183 g_object_set (G_OBJECT (vsink->sink), "sync", TRUE, NULL); 196 g_object_set(G_OBJECT(vsink->sink), "sync", TRUE, NULL);
184 g_object_set (G_OBJECT (vsink->sink), "signal-handoffs", TRUE, NULL); 197 g_object_set(G_OBJECT(vsink->sink), "signal-handoffs", TRUE, NULL);
185 g_signal_connect (G_OBJECT (vsink->sink), 198 g_signal_connect(G_OBJECT(vsink->sink),
186 "handoff", 199 "handoff",
187 G_CALLBACK (cb_handoff), ev); 200 G_CALLBACK(cb_handoff), ev);
188 return vsink; 201 return vsink;
189} 202}
190 203
@@ -200,41 +213,44 @@ emotion_pipeline_cdda_track_count_get(void *video)
200 if (!ev) return tracks_count; 213 if (!ev) return tracks_count;
201 214
202 done = FALSE; 215 done = FALSE;
203 bus = gst_element_get_bus (ev->pipeline); 216 bus = gst_element_get_bus(ev->pipeline);
204 if (!bus) return tracks_count; 217 if (!bus) return tracks_count;
205 218
206 while (!done) { 219 while (!done)
207 GstMessage *message; 220 {
208 221 GstMessage *message;
209 message = gst_bus_pop (bus); 222
210 if (message == NULL) 223 message = gst_bus_pop(bus);
211 /* All messages read, we're done */ 224 if (message == NULL)
212 break; 225 /* All messages read, we're done */
213 226 break;
214 switch (GST_MESSAGE_TYPE (message)) { 227
215 case GST_MESSAGE_TAG: { 228 switch (GST_MESSAGE_TYPE(message))
216 GstTagList *tags; 229 {
217 230 case GST_MESSAGE_TAG:
218 gst_message_parse_tag (message, &tags); 231 {
219 232 GstTagList *tags;
220 gst_tag_list_get_uint (tags, GST_TAG_TRACK_COUNT, &tracks_count); 233
221 if (tracks_count) done = TRUE; 234 gst_message_parse_tag(message, &tags);
222 break; 235
223 } 236 gst_tag_list_get_uint(tags, GST_TAG_TRACK_COUNT, &tracks_count);
224 case GST_MESSAGE_ERROR: 237 if (tracks_count) done = TRUE;
225 default: 238 break;
226 break; 239 }
227 } 240 case GST_MESSAGE_ERROR:
228 gst_message_unref (message); 241 default:
229 } 242 break;
243 }
244 gst_message_unref(message);
245 }
230 246
231 gst_object_unref (GST_OBJECT (bus)); 247 gst_object_unref(GST_OBJECT(bus));
232 248
233 return tracks_count; 249 return tracks_count;
234} 250}
235 251
236GstElement * 252GstElement *
237emotion_audio_sink_create (Emotion_Gstreamer_Video *ev, int index) 253emotion_audio_sink_create(Emotion_Gstreamer_Video *ev, int index)
238{ 254{
239 gchar buf[128]; 255 gchar buf[128];
240 GstElement *bin; 256 GstElement *bin;
@@ -245,302 +261,316 @@ emotion_audio_sink_create (Emotion_Gstreamer_Video *ev, int index)
245 GstPad *binpad; 261 GstPad *binpad;
246 262
247 /* audio sink */ 263 /* audio sink */
248 bin = gst_bin_new (NULL); 264 bin = gst_bin_new(NULL);
249 if (!bin) return NULL; 265 if (!bin) return NULL;
250 266
251 g_snprintf (buf, 128, "tee%d", index); 267 g_snprintf(buf, 128, "tee%d", index);
252 tee = gst_element_factory_make ("tee", buf); 268 tee = gst_element_factory_make("tee", buf);
253 269
254 /* audio part */ 270 /* audio part */
255 { 271 {
256 GstElement *queue; 272 GstElement *queue;
257 GstElement *conv; 273 GstElement *conv;
258 GstElement *resample; 274 GstElement *resample;
259 GstElement *volume; 275 GstElement *volume;
260 GstElement *sink; 276 GstElement *sink;
261 GstPad *audiopad; 277 GstPad *audiopad;
262 double vol; 278 double vol;
263 279
264 audiobin = gst_bin_new (NULL); 280 audiobin = gst_bin_new(NULL);
265 281
266 queue = gst_element_factory_make ("queue", NULL); 282 queue = gst_element_factory_make("queue", NULL);
267 conv = gst_element_factory_make ("audioconvert", NULL); 283 conv = gst_element_factory_make("audioconvert", NULL);
268 resample = gst_element_factory_make ("audioresample", NULL); 284 resample = gst_element_factory_make("audioresample", NULL);
269 volume = gst_element_factory_make ("volume", "volume"); 285 volume = gst_element_factory_make("volume", "volume");
270 g_object_get (G_OBJECT (volume), "volume", &vol, NULL); 286 g_object_get(G_OBJECT(volume), "volume", &vol, NULL);
271 ev->volume = vol / 10.0; 287 ev->volume = vol / 10.0;
272 288
273 if (index == 1) 289 if (index == 1)
274 sink = gst_element_factory_make ("autoaudiosink", NULL); 290 sink = gst_element_factory_make("autoaudiosink", NULL);
275 else 291 else
276 sink = gst_element_factory_make ("fakesink", NULL); 292 sink = gst_element_factory_make("fakesink", NULL);
277 293
278 gst_bin_add_many (GST_BIN (audiobin), 294 gst_bin_add_many(GST_BIN(audiobin),
279 queue, conv, resample, volume, sink, NULL); 295 queue, conv, resample, volume, sink, NULL);
280 gst_element_link_many (queue, conv, resample, volume, sink, NULL); 296 gst_element_link_many(queue, conv, resample, volume, sink, NULL);
281 297
282 audiopad = gst_element_get_pad (queue, "sink"); 298 audiopad = gst_element_get_pad(queue, "sink");
283 gst_element_add_pad (audiobin, gst_ghost_pad_new ("sink", audiopad)); 299 gst_element_add_pad(audiobin, gst_ghost_pad_new("sink", audiopad));
284 gst_object_unref (audiopad); 300 gst_object_unref(audiopad);
285 } 301 }
286 302
287 /* visualisation part */ 303 /* visualisation part */
288 { 304 {
289 GstElement *vis = NULL; 305 GstElement *vis = NULL;
290 char *vis_name; 306 char *vis_name;
291 307
292 switch (ev->vis) { 308 switch (ev->vis)
293 case EMOTION_VIS_GOOM: 309 {
294 vis_name = "goom"; 310 case EMOTION_VIS_GOOM:
295 break; 311 vis_name = "goom";
296 case EMOTION_VIS_LIBVISUAL_BUMPSCOPE: 312 break;
297 vis_name = "libvisual_bumpscope"; 313 case EMOTION_VIS_LIBVISUAL_BUMPSCOPE:
298 break; 314 vis_name = "libvisual_bumpscope";
299 case EMOTION_VIS_LIBVISUAL_CORONA: 315 break;
300 vis_name = "libvisual_corona"; 316 case EMOTION_VIS_LIBVISUAL_CORONA:
301 break; 317 vis_name = "libvisual_corona";
302 case EMOTION_VIS_LIBVISUAL_DANCING_PARTICLES: 318 break;
303 vis_name = "libvisual_dancingparticles"; 319 case EMOTION_VIS_LIBVISUAL_DANCING_PARTICLES:
304 break; 320 vis_name = "libvisual_dancingparticles";
305 case EMOTION_VIS_LIBVISUAL_GDKPIXBUF: 321 break;
306 vis_name = "libvisual_gdkpixbuf"; 322 case EMOTION_VIS_LIBVISUAL_GDKPIXBUF:
307 break; 323 vis_name = "libvisual_gdkpixbuf";
308 case EMOTION_VIS_LIBVISUAL_G_FORCE: 324 break;
309 vis_name = "libvisual_G-Force"; 325 case EMOTION_VIS_LIBVISUAL_G_FORCE:
310 break; 326 vis_name = "libvisual_G-Force";
311 case EMOTION_VIS_LIBVISUAL_GOOM: 327 break;
312 vis_name = "libvisual_goom"; 328 case EMOTION_VIS_LIBVISUAL_GOOM:
313 break; 329 vis_name = "libvisual_goom";
314 case EMOTION_VIS_LIBVISUAL_INFINITE: 330 break;
315 vis_name = "libvisual_infinite"; 331 case EMOTION_VIS_LIBVISUAL_INFINITE:
316 break; 332 vis_name = "libvisual_infinite";
317 case EMOTION_VIS_LIBVISUAL_JAKDAW: 333 break;
318 vis_name = "libvisual_jakdaw"; 334 case EMOTION_VIS_LIBVISUAL_JAKDAW:
319 break; 335 vis_name = "libvisual_jakdaw";
320 case EMOTION_VIS_LIBVISUAL_JESS: 336 break;
321 vis_name = "libvisual_jess"; 337 case EMOTION_VIS_LIBVISUAL_JESS:
322 break; 338 vis_name = "libvisual_jess";
323 case EMOTION_VIS_LIBVISUAL_LV_ANALYSER: 339 break;
324 vis_name = "libvisual_lv_analyzer"; 340 case EMOTION_VIS_LIBVISUAL_LV_ANALYSER:
325 break; 341 vis_name = "libvisual_lv_analyzer";
326 case EMOTION_VIS_LIBVISUAL_LV_FLOWER: 342 break;
327 vis_name = "libvisual_lv_flower"; 343 case EMOTION_VIS_LIBVISUAL_LV_FLOWER:
328 break; 344 vis_name = "libvisual_lv_flower";
329 case EMOTION_VIS_LIBVISUAL_LV_GLTEST: 345 break;
330 vis_name = "libvisual_lv_gltest"; 346 case EMOTION_VIS_LIBVISUAL_LV_GLTEST:
331 break; 347 vis_name = "libvisual_lv_gltest";
332 case EMOTION_VIS_LIBVISUAL_LV_SCOPE: 348 break;
333 vis_name = "libvisual_lv_scope"; 349 case EMOTION_VIS_LIBVISUAL_LV_SCOPE:
334 break; 350 vis_name = "libvisual_lv_scope";
335 case EMOTION_VIS_LIBVISUAL_MADSPIN: 351 break;
336 vis_name = "libvisual_madspin"; 352 case EMOTION_VIS_LIBVISUAL_MADSPIN:
337 break; 353 vis_name = "libvisual_madspin";
338 case EMOTION_VIS_LIBVISUAL_NEBULUS: 354 break;
339 vis_name = "libvisual_nebulus"; 355 case EMOTION_VIS_LIBVISUAL_NEBULUS:
340 break; 356 vis_name = "libvisual_nebulus";
341 case EMOTION_VIS_LIBVISUAL_OINKSIE: 357 break;
342 vis_name = "libvisual_oinksie"; 358 case EMOTION_VIS_LIBVISUAL_OINKSIE:
343 break; 359 vis_name = "libvisual_oinksie";
344 case EMOTION_VIS_LIBVISUAL_PLASMA: 360 break;
345 vis_name = "libvisual_plazma"; 361 case EMOTION_VIS_LIBVISUAL_PLASMA:
346 break; 362 vis_name = "libvisual_plazma";
347 default: 363 break;
348 vis_name = "goom"; 364 default:
349 break; 365 vis_name = "goom";
366 break;
367 }
368
369 g_snprintf(buf, 128, "vis%d", index);
370 if ((vis = gst_element_factory_make(vis_name, buf)))
371 {
372 GstElement *queue;
373 GstElement *conv;
374 GstElement *cspace;
375 GstElement *sink;
376 GstPad *vispad;
377 GstCaps *caps;
378
379 g_snprintf(buf, 128, "visbin%d", index);
380 visbin = gst_bin_new(buf);
381
382 queue = gst_element_factory_make("queue", NULL);
383 conv = gst_element_factory_make("audioconvert", NULL);
384 cspace = gst_element_factory_make("ffmpegcolorspace", NULL);
385 g_snprintf(buf, 128, "vissink%d", index);
386 sink = gst_element_factory_make("fakesink", buf);
387
388 gst_bin_add_many(GST_BIN(visbin),
389 queue, conv, vis, cspace, sink, NULL);
390 gst_element_link_many(queue, conv, vis, cspace, NULL);
391 caps = gst_caps_new_simple("video/x-raw-rgb",
392 "bpp", G_TYPE_INT, 32,
393 "width", G_TYPE_INT, 320,
394 "height", G_TYPE_INT, 200,
395 NULL);
396 gst_element_link_filtered(cspace, sink, caps);
397
398 vispad = gst_element_get_pad(queue, "sink");
399 gst_element_add_pad(visbin, gst_ghost_pad_new("sink", vispad));
400 gst_object_unref(vispad);
401 }
350 } 402 }
351 403
352 g_snprintf (buf, 128, "vis%d", index); 404 gst_bin_add_many(GST_BIN(bin), tee, audiobin, NULL);
353 if ((vis = gst_element_factory_make (vis_name, buf))) { 405 if (visbin)
354 GstElement *queue; 406 gst_bin_add(GST_BIN(bin), visbin);
355 GstElement *conv; 407
356 GstElement *cspace; 408 binpad = gst_element_get_pad(audiobin, "sink");
357 GstElement *sink; 409 teepad = gst_element_get_request_pad(tee, "src%d");
358 GstPad *vispad; 410 gst_pad_link(teepad, binpad);
359 GstCaps *caps; 411 gst_object_unref(teepad);
360 412 gst_object_unref(binpad);
361 g_snprintf (buf, 128, "visbin%d", index);
362 visbin = gst_bin_new (buf);
363
364 queue = gst_element_factory_make ("queue", NULL);
365 conv = gst_element_factory_make ("audioconvert", NULL);
366 cspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
367 g_snprintf (buf, 128, "vissink%d", index);
368 sink = gst_element_factory_make ("fakesink", buf);
369
370 gst_bin_add_many (GST_BIN (visbin),
371 queue, conv, vis, cspace, sink, NULL);
372 gst_element_link_many (queue, conv, vis, cspace, NULL);
373 caps = gst_caps_new_simple ("video/x-raw-rgb",
374 "bpp", G_TYPE_INT, 32,
375 "width", G_TYPE_INT, 320,
376 "height", G_TYPE_INT, 200,
377 NULL);
378 gst_element_link_filtered (cspace, sink, caps);
379
380 vispad = gst_element_get_pad (queue, "sink");
381 gst_element_add_pad (visbin, gst_ghost_pad_new ("sink", vispad));
382 gst_object_unref (vispad);
383 }
384 }
385 413
386 gst_bin_add_many (GST_BIN (bin), tee, audiobin, NULL);
387 if (visbin) 414 if (visbin)
388 gst_bin_add (GST_BIN (bin), visbin); 415 {
389 416 binpad = gst_element_get_pad(visbin, "sink");
390 binpad = gst_element_get_pad (audiobin, "sink"); 417 teepad = gst_element_get_request_pad(tee, "src%d");
391 teepad = gst_element_get_request_pad (tee, "src%d"); 418 gst_pad_link(teepad, binpad);
392 gst_pad_link (teepad, binpad); 419 gst_object_unref(teepad);
393 gst_object_unref (teepad); 420 gst_object_unref(binpad);
394 gst_object_unref (binpad); 421 }
395 422
396 if (visbin) { 423 teepad = gst_element_get_pad(tee, "sink");
397 binpad = gst_element_get_pad (visbin, "sink"); 424 gst_element_add_pad(bin, gst_ghost_pad_new("sink", teepad));
398 teepad = gst_element_get_request_pad (tee, "src%d"); 425 gst_object_unref(teepad);
399 gst_pad_link (teepad, binpad);
400 gst_object_unref (teepad);
401 gst_object_unref (binpad);
402 }
403
404 teepad = gst_element_get_pad (tee, "sink");
405 gst_element_add_pad (bin, gst_ghost_pad_new ("sink", teepad));
406 gst_object_unref (teepad);
407 426
408 return bin; 427 return bin;
409} 428}
410 429
411void 430void
412emotion_streams_sinks_get (Emotion_Gstreamer_Video *ev, GstElement *decoder) 431emotion_streams_sinks_get(Emotion_Gstreamer_Video *ev, GstElement *decoder)
413{ 432{
414 GstIterator *it; 433 GstIterator *it;
415 gpointer data; 434 gpointer data;
416 435
417 ecore_list_first_goto (ev->video_sinks); 436 ecore_list_first_goto(ev->video_sinks);
418 ecore_list_first_goto (ev->audio_sinks); 437 ecore_list_first_goto(ev->audio_sinks);
419 438
420 it = gst_element_iterate_src_pads (decoder); 439 it = gst_element_iterate_src_pads(decoder);
421 while (gst_iterator_next (it, &data) == GST_ITERATOR_OK) { 440 while (gst_iterator_next(it, &data) == GST_ITERATOR_OK)
422 GstPad *pad; 441 {
423 GstCaps *caps; 442 GstPad *pad;
424 gchar *str; 443 GstCaps *caps;
425 444 gchar *str;
426 pad = GST_PAD (data); 445
427 446 pad = GST_PAD(data);
428 caps = gst_pad_get_caps (pad); 447
429 str = gst_caps_to_string (caps); 448 caps = gst_pad_get_caps(pad);
430 g_print ("caps !! %s\n", str); 449 str = gst_caps_to_string(caps);
431 450 g_print("caps !! %s\n", str);
432 /* video stream */ 451
433 if (g_str_has_prefix (str, "video/")) { 452 /* video stream */
434 Emotion_Video_Sink *vsink; 453 if (g_str_has_prefix(str, "video/"))
435 454 {
436 vsink = (Emotion_Video_Sink *)ecore_list_next (ev->video_sinks); 455 Emotion_Video_Sink *vsink;
437 456
438 emotion_video_sink_fill (vsink, pad, caps); 457 vsink = (Emotion_Video_Sink *)ecore_list_next(ev->video_sinks);
439 } 458
440 /* audio stream */ 459 emotion_video_sink_fill(vsink, pad, caps);
441 else if (g_str_has_prefix (str, "audio/")) { 460 }
442 Emotion_Audio_Sink *asink; 461 /* audio stream */
443 gint index; 462 else if (g_str_has_prefix(str, "audio/"))
444 463 {
445 asink = (Emotion_Audio_Sink *)ecore_list_next (ev->audio_sinks); 464 Emotion_Audio_Sink *asink;
446 465 gint index;
447 emotion_audio_sink_fill (asink, pad, caps); 466
448 467 asink = (Emotion_Audio_Sink *)ecore_list_next(ev->audio_sinks);
449 index = ecore_list_index (ev->audio_sinks); 468
450 469 emotion_audio_sink_fill(asink, pad, caps);
451 if (ecore_list_count (ev->video_sinks) == 0) { 470
452 if (index == 1) { 471 index = ecore_list_index(ev->audio_sinks);
453 Emotion_Video_Sink *vsink; 472
454 473 if (ecore_list_count(ev->video_sinks) == 0)
455 vsink = emotion_visualization_sink_create (ev, asink); 474 {
456 if (!vsink) goto finalize; 475 if (index == 1)
457 } 476 {
458 } 477 Emotion_Video_Sink *vsink;
459 else { 478
460 gchar buf[128]; 479 vsink = emotion_visualization_sink_create(ev, asink);
461 GstElement *visbin; 480 if (!vsink) goto finalize;
462 481 }
463 g_snprintf (buf, 128, "visbin%d", index); 482 }
464 visbin = gst_bin_get_by_name (GST_BIN (ev->pipeline), buf); 483 else
465 if (visbin) { 484 {
466 GstPad *srcpad; 485 gchar buf[128];
467 GstPad *sinkpad; 486 GstElement *visbin;
468 487
469 sinkpad = gst_element_get_pad (visbin, "sink"); 488 g_snprintf(buf, 128, "visbin%d", index);
470 srcpad = gst_pad_get_peer (sinkpad); 489 visbin = gst_bin_get_by_name(GST_BIN(ev->pipeline), buf);
471 gst_pad_unlink (srcpad, sinkpad); 490 if (visbin)
472 491 {
473 gst_object_unref (srcpad); 492 GstPad *srcpad;
474 gst_object_unref (sinkpad); 493 GstPad *sinkpad;
475 } 494
476 } 495 sinkpad = gst_element_get_pad(visbin, "sink");
477 } 496 srcpad = gst_pad_get_peer(sinkpad);
478 finalize: 497 gst_pad_unlink(srcpad, sinkpad);
479 gst_caps_unref (caps); 498
480 g_free (str); 499 gst_object_unref(srcpad);
481 gst_object_unref (pad); 500 gst_object_unref(sinkpad);
482 } 501 }
483 gst_iterator_free (it); 502 }
503 }
504finalize:
505 gst_caps_unref(caps);
506 g_free(str);
507 gst_object_unref(pad);
508 }
509 gst_iterator_free(it);
484} 510}
485 511
486void 512void
487emotion_video_sink_fill (Emotion_Video_Sink *vsink, GstPad *pad, GstCaps *caps) 513emotion_video_sink_fill(Emotion_Video_Sink *vsink, GstPad *pad, GstCaps *caps)
488{ 514{
489 GstStructure *structure; 515 GstStructure *structure;
490 GstQuery *query; 516 GstQuery *query;
491 const GValue *val; 517 const GValue *val;
492 gchar *str; 518 gchar *str;
493 519
494 structure = gst_caps_get_structure (caps, 0); 520 structure = gst_caps_get_structure(caps, 0);
495 str = gst_caps_to_string (caps); 521 str = gst_caps_to_string(caps);
496 522
497 gst_structure_get_int (structure, "width", &vsink->width); 523 gst_structure_get_int(structure, "width", &vsink->width);
498 gst_structure_get_int (structure, "height", &vsink->height); 524 gst_structure_get_int(structure, "height", &vsink->height);
499 525
500 vsink->fps_num = 1; 526 vsink->fps_num = 1;
501 vsink->fps_den = 1; 527 vsink->fps_den = 1;
502 val = gst_structure_get_value (structure, "framerate"); 528 val = gst_structure_get_value(structure, "framerate");
503 if (val) { 529 if (val)
504 vsink->fps_num = gst_value_get_fraction_numerator (val); 530 {
505 vsink->fps_den = gst_value_get_fraction_denominator (val); 531 vsink->fps_num = gst_value_get_fraction_numerator(val);
506 } 532 vsink->fps_den = gst_value_get_fraction_denominator(val);
507 if (g_str_has_prefix(str, "video/x-raw-yuv")) { 533 }
508 val = gst_structure_get_value (structure, "format"); 534 if (g_str_has_prefix(str, "video/x-raw-yuv"))
509 vsink->fourcc = gst_value_get_fourcc (val); 535 {
510 } 536 val = gst_structure_get_value(structure, "format");
537 vsink->fourcc = gst_value_get_fourcc(val);
538 }
511 else if (g_str_has_prefix(str, "video/x-raw-rgb")) 539 else if (g_str_has_prefix(str, "video/x-raw-rgb"))
512 vsink->fourcc = GST_MAKE_FOURCC ('A','R','G','B'); 540 vsink->fourcc = GST_MAKE_FOURCC('A', 'R', 'G', 'B');
513 else 541 else
514 vsink->fourcc = 0; 542 vsink->fourcc = 0;
515 543
516 query = gst_query_new_duration (GST_FORMAT_TIME); 544 query = gst_query_new_duration(GST_FORMAT_TIME);
517 if (gst_pad_query (pad, query)) { 545 if (gst_pad_query(pad, query))
518 gint64 time; 546 {
547 gint64 time;
519 548
520 gst_query_parse_duration (query, NULL, &time); 549 gst_query_parse_duration(query, NULL, &time);
521 vsink->length_time = (double)time / (double)GST_SECOND; 550 vsink->length_time = (double)time / (double)GST_SECOND;
522 } 551 }
523 g_free (str); 552 g_free(str);
524 gst_query_unref (query); 553 gst_query_unref(query);
525} 554}
526 555
527void 556void
528emotion_audio_sink_fill (Emotion_Audio_Sink *asink, GstPad *pad, GstCaps *caps) 557emotion_audio_sink_fill(Emotion_Audio_Sink *asink, GstPad *pad, GstCaps *caps)
529{ 558{
530 GstStructure *structure; 559 GstStructure *structure;
531 GstQuery *query; 560 GstQuery *query;
532 561
533 structure = gst_caps_get_structure (caps, 0); 562 structure = gst_caps_get_structure(caps, 0);
534 563
535 gst_structure_get_int (structure, "channels", &asink->channels); 564 gst_structure_get_int(structure, "channels", &asink->channels);
536 gst_structure_get_int (structure, "rate", &asink->samplerate); 565 gst_structure_get_int(structure, "rate", &asink->samplerate);
537 566
538 query = gst_query_new_duration (GST_FORMAT_TIME); 567 query = gst_query_new_duration(GST_FORMAT_TIME);
539 if (gst_pad_query (pad, query)) { 568 if (gst_pad_query(pad, query))
540 gint64 time; 569 {
570 gint64 time;
541 571
542 gst_query_parse_duration (query, NULL, &time); 572 gst_query_parse_duration(query, NULL, &time);
543 asink->length_time = (double)time / (double)GST_SECOND; 573 asink->length_time = (double)time / (double)GST_SECOND;
544 } 574 }
545 gst_query_unref (query); 575 gst_query_unref(query);
546 } 576}
diff --git a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c
index c9ab41e2d6..5083f29ff9 100644
--- a/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c
+++ b/legacy/emotion/src/modules/gstreamer/emotion_gstreamer_pipeline_cdda.c
@@ -5,121 +5,124 @@
5#include "emotion_gstreamer_pipeline.h" 5#include "emotion_gstreamer_pipeline.h"
6 6
7 7
8static Emotion_Audio_Sink *_emotion_audio_sink_new (Emotion_Gstreamer_Video *ev); 8static Emotion_Audio_Sink *_emotion_audio_sink_new (Emotion_Gstreamer_Video *ev);
9 9static void _emotion_audio_sink_free (Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink);
10static void _emotion_audio_sink_free (Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink);
11 10
12int 11int
13emotion_pipeline_cdda_build (void *video, const char * device, unsigned int track) 12emotion_pipeline_cdda_build(void *video, const char * device, unsigned int track)
14{ 13{
15 GstElement *cdiocddasrc; 14 GstElement *cdiocddasrc;
16 Emotion_Video_Sink *vsink; 15 Emotion_Video_Sink *vsink;
17 Emotion_Audio_Sink *asink; 16 Emotion_Audio_Sink *asink;
18 Emotion_Gstreamer_Video *ev; 17 Emotion_Gstreamer_Video *ev;
19/* GstFormat format; */ 18 /* GstFormat format; */
20/* gint64 tracks_count; */ 19 /* gint64 tracks_count; */
21 20
22 ev = (Emotion_Gstreamer_Video *)video; 21 ev = (Emotion_Gstreamer_Video *)video;
23 if (!ev) return 0; 22 if (!ev) return 0;
24 23
25 cdiocddasrc = gst_element_factory_make ("cdiocddasrc", "src"); 24 cdiocddasrc = gst_element_factory_make("cdiocddasrc", "src");
26 if (!cdiocddasrc) { 25 if (!cdiocddasrc)
27 g_print ("cdiocddasrc element missing. Install it.\n"); 26 {
28 goto failure_cdiocddasrc; 27 g_print("cdiocddasrc element missing. Install it.\n");
29 } 28 goto failure_cdiocddasrc;
29 }
30 30
31 if (device) 31 if (device)
32 g_object_set (G_OBJECT (cdiocddasrc), "device", device, NULL); 32 g_object_set(G_OBJECT(cdiocddasrc), "device", device, NULL);
33 33
34 g_object_set (G_OBJECT (cdiocddasrc), "track", track, NULL); 34 g_object_set(G_OBJECT(cdiocddasrc), "track", track, NULL);
35 35
36 asink = _emotion_audio_sink_new (ev); 36 asink = _emotion_audio_sink_new(ev);
37 if (!asink) 37 if (!asink)
38 goto failure_emotion_sink; 38 goto failure_emotion_sink;
39 39
40 asink->sink = emotion_audio_sink_create (ev, 1); 40 asink->sink = emotion_audio_sink_create(ev, 1);
41 if (!asink->sink) 41 if (!asink->sink)
42 goto failure_gstreamer_sink; 42 goto failure_gstreamer_sink;
43 43
44 gst_bin_add_many((GST_BIN (ev->pipeline)), cdiocddasrc, asink->sink, NULL); 44 gst_bin_add_many((GST_BIN(ev->pipeline)), cdiocddasrc, asink->sink, NULL);
45 45
46 if (!gst_element_link (cdiocddasrc, asink->sink)) 46 if (!gst_element_link(cdiocddasrc, asink->sink))
47 goto failure_link; 47 goto failure_link;
48 48
49 vsink = emotion_visualization_sink_create (ev, asink); 49 vsink = emotion_visualization_sink_create(ev, asink);
50 if (!vsink) goto failure_link; 50 if (!vsink) goto failure_link;
51 51
52 if (!emotion_pipeline_pause (ev->pipeline)) 52 if (!emotion_pipeline_pause(ev->pipeline))
53 goto failure_gstreamer_pause; 53 goto failure_gstreamer_pause;
54 54
55 { 55 {
56 GstQuery *query; 56 GstQuery *query;
57 GstPad *pad; 57 GstPad *pad;
58 GstCaps *caps; 58 GstCaps *caps;
59 GstStructure *structure; 59 GstStructure *structure;
60 60
61 /* should always be found */ 61 /* should always be found */
62 pad = gst_element_get_pad (cdiocddasrc, "src"); 62 pad = gst_element_get_pad(cdiocddasrc, "src");
63 63
64 caps = gst_pad_get_caps (pad); 64 caps = gst_pad_get_caps(pad);
65 structure = gst_caps_get_structure (GST_CAPS (caps), 0); 65 structure = gst_caps_get_structure(GST_CAPS(caps), 0);
66 66
67 gst_structure_get_int (structure, "channels", &asink->channels); 67 gst_structure_get_int(structure, "channels", &asink->channels);
68 gst_structure_get_int (structure, "rate", &asink->samplerate); 68 gst_structure_get_int(structure, "rate", &asink->samplerate);
69 69
70 gst_caps_unref (caps); 70 gst_caps_unref(caps);
71 71
72 query = gst_query_new_duration (GST_FORMAT_TIME); 72 query = gst_query_new_duration(GST_FORMAT_TIME);
73 if (gst_pad_query (pad, query)) { 73 if (gst_pad_query(pad, query))
74 gint64 time; 74 {
75 gint64 time;
75 76
76 gst_query_parse_duration (query, NULL, &time); 77 gst_query_parse_duration(query, NULL, &time);
77 asink->length_time = (double)time / (double)GST_SECOND; 78 asink->length_time = (double)time / (double)GST_SECOND;
78 vsink->length_time = asink->length_time; 79 vsink->length_time = asink->length_time;
79 } 80 }
80 gst_query_unref (query); 81 gst_query_unref(query);
81 gst_object_unref (GST_OBJECT (pad)); 82 gst_object_unref(GST_OBJECT(pad));
82 } 83 }
83 84
84 return 1; 85 return 1;
85 86
86 failure_gstreamer_pause: 87failure_gstreamer_pause:
87 emotion_video_sink_free (ev, vsink); 88 emotion_video_sink_free(ev, vsink);
88 failure_link: 89failure_link:
89 gst_bin_remove (GST_BIN (ev->pipeline), asink->sink); 90 gst_bin_remove(GST_BIN(ev->pipeline), asink->sink);
90 failure_gstreamer_sink: 91failure_gstreamer_sink:
91 _emotion_audio_sink_free (ev, asink); 92 _emotion_audio_sink_free(ev, asink);
92 failure_emotion_sink: 93failure_emotion_sink:
93 gst_bin_remove (GST_BIN (ev->pipeline), cdiocddasrc); 94 gst_bin_remove(GST_BIN(ev->pipeline), cdiocddasrc);
94 failure_cdiocddasrc: 95failure_cdiocddasrc:
95 96
96 return 0; 97 return 0;
97} 98}
98 99
99static Emotion_Audio_Sink * 100static Emotion_Audio_Sink *
100_emotion_audio_sink_new (Emotion_Gstreamer_Video *ev) 101_emotion_audio_sink_new(Emotion_Gstreamer_Video *ev)
101{ 102{
102 Emotion_Audio_Sink *asink; 103 Emotion_Audio_Sink *asink;
103 104
104 if (!ev) return NULL; 105 if (!ev) return NULL;
105 106
106 asink = (Emotion_Audio_Sink *)malloc (sizeof (Emotion_Audio_Sink)); 107 asink = (Emotion_Audio_Sink *)malloc(sizeof(Emotion_Audio_Sink));
107 if (!asink) return NULL; 108 if (!asink) return NULL;
108 109
109 if (!ecore_list_append (ev->audio_sinks, asink)) { 110 if (!ecore_list_append(ev->audio_sinks, asink))
110 free (asink); 111 {
111 return NULL; 112 free(asink);
112 } 113 return NULL;
114 }
113 return asink; 115 return asink;
114} 116}
115 117
116static void 118static void
117_emotion_audio_sink_free (Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink) 119_emotion_audio_sink_free(Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink)
118{ 120{
119 if (!ev || !asink) return; 121 if (!ev || !asink) return;
120 122
121 if (ecore_list_goto (ev->audio_sinks, asink)) { 123 if (ecore_list_goto(ev->audio_sinks, asink))
122 ecore_list_remove (ev->audio_sinks); 124 {
123 free (asink); 125 ecore_list_remove(ev->audio_sinks);
124 } 126 free(asink);
127 }
125} 128}