static int _cdda_pipeline_build (void *video, const char * device, unsigned int track);
static int _file_pipeline_build (void *video, const char *file);
+static int _cdda_track_count_get(void *video);
+
/* Interface */
static unsigned char em_init (Evas_Object *obj,
ev = (Emotion_Gstreamer_Video *)video;
if (!ev) return NULL;
- done = 0;
+ done = FALSE;
bus = gst_element_get_bus (ev->pipeline);
if (!bus) return NULL;
switch (meta) {
case META_TRACK_TITLE:
gst_tag_list_get_string (new_tags, GST_TAG_TITLE, &str);
- if (str) {
- gst_message_unref (message);
- goto success;
- }
+ if (str) done = TRUE;
break;
case META_TRACK_ARTIST:
gst_tag_list_get_string (new_tags, GST_TAG_ARTIST, &str);
- if (str) {
- gst_message_unref (message);
- goto success;
- }
+ if (str) done = TRUE;
break;
case META_TRACK_GENRE:
gst_tag_list_get_string (new_tags, GST_TAG_GENRE, &str);
- if (str) {
- gst_message_unref (message);
- goto success;
- }
+ if (str) done = TRUE;
break;
case META_TRACK_COMMENT:
gst_tag_list_get_string (new_tags, GST_TAG_COMMENT, &str);
- if (str) {
- gst_message_unref (message);
- goto success;
- }
+ if (str) done = TRUE;
break;
case META_TRACK_ALBUM:
gst_tag_list_get_string (new_tags, GST_TAG_ALBUM, &str);
- if (str) {
- gst_message_unref (message);
- goto success;
- }
+ if (str) done = TRUE;
break;
case META_TRACK_YEAR: {
const GValue *date;
date = gst_tag_list_get_value_index (new_tags, GST_TAG_DATE, 0);
if (date)
str = g_strdup_value_contents (date);
- if (str) {
- gst_message_unref (message);
- goto success;
- }
+ if (str) done = TRUE;
break;
}
case META_TRACK_DISCID:
#ifdef GST_TAG_CDDA_CDDB_DISCID
gst_tag_list_get_string (new_tags, GST_TAG_CDDA_CDDB_DISCID, &str);
#endif
- if (str) {
- gst_message_unref (message);
- goto success;
- }
+ if (str) done = TRUE;
break;
}
+ break;
}
default:
break;
gst_message_unref (message);
}
- success:
gst_object_unref (GST_OBJECT (bus));
return str;
if (device)
g_object_set (G_OBJECT (cdiocddasrc), "device", device, NULL);
-/* format = gst_format_get_by_nick ("track"); */
-/* gst_element_query_duration (cdiocddasrc, &format, &tracks_count); */
-/* g_print ("tracks count %lld\n", tracks_count); */
-/* if (track > tracks_count) */
-/* track = tracks_count; */
g_object_set (G_OBJECT (cdiocddasrc), "track", track, NULL);
asink = _emotion_audio_sink_new (ev);
goto failure_gstreamer_pause;
{
+ gint tracks_count;
+ tracks_count = _cdda_track_count_get(ev);
+ g_print ("Tracks count : %d\n", tracks_count);
+ }
+
+ {
GstQuery *query;
GstPad *pad;
GstCaps *caps;
failure_gstreamer_pause:
failure_link:
+ gst_element_set_state (ev->pipeline, GST_STATE_NULL);
gst_bin_remove (GST_BIN (ev->pipeline), filesrc);
gst_bin_remove (GST_BIN (ev->pipeline), decodebin);
failure_decodebin:
}
return 1;
}
+
+static int
+_cdda_track_count_get(void *video)
+{
+ Emotion_Gstreamer_Video *ev;
+ GstBus *bus;
+ guint tracks_count = 0;
+ gboolean done;
+
+ ev = (Emotion_Gstreamer_Video *)video;
+ if (!ev) return tracks_count;
+
+ done = FALSE;
+ bus = gst_element_get_bus (ev->pipeline);
+ if (!bus) return tracks_count;
+
+ while (!done) {
+ GstMessage *message;
+
+ message = gst_bus_pop (bus);
+ if (message == NULL)
+ /* All messages read, we're done */
+ break;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_TAG: {
+ GstTagList *tags;
+
+ gst_message_parse_tag (message, &tags);
+
+ gst_tag_list_get_uint (tags, GST_TAG_TRACK_COUNT, &tracks_count);
+ if (tracks_count) done = TRUE;
+ break;
+ }
+ case GST_MESSAGE_ERROR:
+ default:
+ break;
+ }
+ gst_message_unref (message);
+ }
+
+ gst_object_unref (GST_OBJECT (bus));
+
+ return tracks_count;
+}