summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2012-03-15 17:10:18 +0000
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2012-03-16 11:27:17 +0000
commit9ebacafc6ad8deb3be29f1972bd209fbb0c4c4ce (patch)
tree81173fce5b02277c8c2d256a8181601324d70dfe
parentf8cf7bf9738210dfdbf639fad1bd28566304f488 (diff)
downloadgstreamer-plugins-bad-9ebacafc6ad8deb3be29f1972bd209fbb0c4c4ce.tar.gz
rsndvdsrc: post a message with title number and durations
https://bugzilla.gnome.org/show_bug.cgi?id=672165
-rw-r--r--ext/resindvd/resindvdsrc.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/ext/resindvd/resindvdsrc.c b/ext/resindvd/resindvdsrc.c
index 76139aa52..98473694b 100644
--- a/ext/resindvd/resindvdsrc.c
+++ b/ext/resindvd/resindvdsrc.c
@@ -2427,6 +2427,53 @@ rsn_dvdsrc_src_event (GstBaseSrc * basesrc, GstEvent * event)
return res;
}
+static void
+rsn_dvdsrc_post_title_info (GstElement * element)
+{
+ resinDvdSrc *src = RESINDVDSRC (element);
+ GstMessage *message;
+ GstStructure *s;
+ int32_t n, ntitles;
+ int res;
+ GValue array = { 0 };
+
+ res = dvdnav_get_number_of_titles (src->dvdnav, &ntitles);
+ if (res != DVDNAV_STATUS_OK) {
+ GST_WARNING_OBJECT (src, "Failed to get number of titles: %d", res);
+ return;
+ }
+
+ g_value_init (&array, GST_TYPE_ARRAY);
+
+ s = gst_structure_new ("application/x-gst-dvd", "event",
+ G_TYPE_STRING, "dvd-title-info", NULL);
+
+ for (n = 0; n < ntitles; ++n) {
+ uint64_t *times, duration;
+ uint32_t nchapters;
+ GValue item = { 0 };
+
+ g_value_init (&item, G_TYPE_UINT64);
+
+ nchapters =
+ dvdnav_describe_title_chapters (src->dvdnav, n, &times, &duration);
+ if (nchapters == 0) {
+ GST_WARNING_OBJECT (src, "Failed to get title %d info", n);
+ g_value_set_uint64 (&item, GST_CLOCK_TIME_NONE);
+ } else {
+ g_value_set_uint64 (&item, gst_util_uint64_scale (duration, GST_SECOND,
+ 90000));
+ }
+ gst_value_array_append_value (&array, &item);
+ g_value_unset (&item);
+ }
+ gst_structure_set_value (s, "title-durations", &array);
+ g_value_unset (&array);
+
+ message = gst_message_new_element (GST_OBJECT (src), s);
+ gst_element_post_message (GST_ELEMENT_CAST (src), message);
+}
+
static GstStateChangeReturn
rsn_dvdsrc_change_state (GstElement * element, GstStateChange transition)
{
@@ -2463,6 +2510,9 @@ rsn_dvdsrc_change_state (GstElement * element, GstStateChange transition)
rsn_dvdsrc_check_nav_blocks (src);
g_mutex_unlock (src->dvd_lock);
break;
+ case GST_STATE_CHANGE_READY_TO_PAUSED:
+ rsn_dvdsrc_post_title_info (element);
+ break;
default:
break;
}