2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
4 #include "emotion_gstreamer.h"
5 #include "emotion_gstreamer_pipeline.h"
8 static Emotion_Audio_Sink *_emotion_audio_sink_new (Emotion_Gstreamer_Video *ev);
9 static void _emotion_audio_sink_free (Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink);
12 emotion_pipeline_cdda_build(void *video, const char * device, unsigned int track)
14 GstElement *cdiocddasrc;
15 Emotion_Video_Sink *vsink;
16 Emotion_Audio_Sink *asink;
17 Emotion_Gstreamer_Video *ev;
18 /* GstFormat format; */
19 /* gint64 tracks_count; */
21 ev = (Emotion_Gstreamer_Video *)video;
24 cdiocddasrc = gst_element_factory_make("cdiocddasrc", "src");
27 g_print("cdiocddasrc element missing. Install it.\n");
28 goto failure_cdiocddasrc;
32 g_object_set(G_OBJECT(cdiocddasrc), "device", device, NULL);
34 g_object_set(G_OBJECT(cdiocddasrc), "track", track, NULL);
36 asink = _emotion_audio_sink_new(ev);
38 goto failure_emotion_sink;
40 asink->sink = emotion_audio_sink_create(ev, 1);
42 goto failure_gstreamer_sink;
44 gst_bin_add_many((GST_BIN(ev->pipeline)), cdiocddasrc, asink->sink, NULL);
46 if (!gst_element_link(cdiocddasrc, asink->sink))
49 vsink = emotion_visualization_sink_create(ev, asink);
50 if (!vsink) goto failure_link;
52 if (!emotion_pipeline_pause(ev->pipeline))
53 goto failure_gstreamer_pause;
59 GstStructure *structure;
61 /* should always be found */
62 pad = gst_element_get_pad(cdiocddasrc, "src");
64 caps = gst_pad_get_caps(pad);
65 structure = gst_caps_get_structure(GST_CAPS(caps), 0);
67 gst_structure_get_int(structure, "channels", &asink->channels);
68 gst_structure_get_int(structure, "rate", &asink->samplerate);
72 query = gst_query_new_duration(GST_FORMAT_TIME);
73 if (gst_pad_query(pad, query))
77 gst_query_parse_duration(query, NULL, &time);
78 asink->length_time = (double)time / (double)GST_SECOND;
79 vsink->length_time = asink->length_time;
81 gst_query_unref(query);
82 gst_object_unref(GST_OBJECT(pad));
87 failure_gstreamer_pause:
88 emotion_video_sink_free(ev, vsink);
90 gst_bin_remove(GST_BIN(ev->pipeline), asink->sink);
91 failure_gstreamer_sink:
92 _emotion_audio_sink_free(ev, asink);
94 gst_bin_remove(GST_BIN(ev->pipeline), cdiocddasrc);
100 static Emotion_Audio_Sink *
101 _emotion_audio_sink_new(Emotion_Gstreamer_Video *ev)
103 Emotion_Audio_Sink *asink;
105 if (!ev) return NULL;
107 asink = (Emotion_Audio_Sink *)malloc(sizeof(Emotion_Audio_Sink));
108 if (!asink) return NULL;
110 ev->audio_sinks = eina_list_append(ev->audio_sinks, asink);
111 if (!eina_list_data_find(ev->audio_sinks, asink))
120 _emotion_audio_sink_free(Emotion_Gstreamer_Video *ev, Emotion_Audio_Sink *asink)
122 if (!ev || !asink) return;
124 ev->audio_sinks = eina_list_remove(ev->audio_sinks, asink);