From: <tp...@fr...> - 2006-02-14 15:00:48
|
CVS Root: /cvs/gstreamer Module: gst-plugins-ugly Changes by: tpm Date: Tue Feb 14 2006 06:57:30 PST Log message: * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_init), (gst_dvd_read_src_class_init), (gst_dvd_read_src_start), (gst_dvd_read_src_stop), (gst_dvd_read_src_goto_title), (gst_dvd_read_src_set_property), (gst_dvd_read_src_get_property), (gst_dvd_read_src_uri_get_uri), (gst_dvd_read_src_uri_set_uri): * ext/dvdread/dvdreadsrc.h: Let's try to play the title the user set via the URI handler or via properties instead of always playing the first title. Also, Also, count title/chapter/angle number in URI and properties from 1 rather than 0. Modified files: . : ChangeLog ext/dvdread : dvdreadsrc.c dvdreadsrc.h Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-ugly/ChangeLog.diff?r1=1.1952&r2=1.1953 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-ugly/ext/dvdread/dvdreadsrc.c.diff?r1=1.30&r2=1.31 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-ugly/ext/dvdread/dvdreadsrc.h.diff?r1=1.8&r2=1.9 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-ugly/ChangeLog,v retrieving revision 1.1952 retrieving revision 1.1953 diff -u -d -r1.1952 -r1.1953 --- ChangeLog 13 Feb 2006 14:09:25 -0000 1.1952 +++ ChangeLog 14 Feb 2006 14:57:17 -0000 1.1953 @@ -1,3 +1,16 @@ +2006-02-14 Tim-Philipp Müller <tim at centricular dot net> + + * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_init), + (gst_dvd_read_src_class_init), (gst_dvd_read_src_start), + (gst_dvd_read_src_stop), (gst_dvd_read_src_goto_title), + (gst_dvd_read_src_set_property), (gst_dvd_read_src_get_property), + (gst_dvd_read_src_uri_get_uri), (gst_dvd_read_src_uri_set_uri): + * ext/dvdread/dvdreadsrc.h: + Let's try to play the title the user set via the URI handler or + via properties instead of always playing the first title. Also, + Also, count title/chapter/angle number in URI and properties + from 1 rather than 0. 2006-02-13 Tim-Philipp Müller <tim at centricular dot net> * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_class_init), Index: dvdreadsrc.c RCS file: /cvs/gstreamer/gst-plugins-ugly/ext/dvdread/dvdreadsrc.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- dvdreadsrc.c 13 Feb 2006 14:09:26 -0000 1.30 +++ dvdreadsrc.c 14 Feb 2006 14:57:18 -0000 1.31 @@ -125,9 +125,9 @@ src->new_seek = TRUE; src->new_cell = TRUE; src->change_cell = FALSE; - src->title = 0; - src->chapter = 0; - src->angle = 0; + src->uri_title = 1; + src->uri_chapter = 1; + src->uri_angle = 1; src->seek_pend = FALSE; src->flush_pend = FALSE; @@ -152,13 +152,13 @@ "DVD device location", NULL, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_TITLE, g_param_spec_int ("title", "title", "title", - 0, 999, 0, G_PARAM_READWRITE)); + 1, 999, 1, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHAPTER, g_param_spec_int ("chapter", "chapter", "chapter", g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ANGLE, g_param_spec_int ("angle", "angle", "angle", gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_dvd_read_src_start); gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_dvd_read_src_stop); @@ -198,8 +198,23 @@ src->tt_srpt = src->vmg_file->tt_srpt; - src->seek_pend_fmt = title_format; - src->seek_pend = TRUE; + src->title = src->uri_title - 1; + src->chapter = src->uri_chapter - 1; + src->angle = src->uri_angle - 1; + if (!gst_dvd_read_src_goto_title (src, src->title, src->angle)) { + GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, + (_("Could not open DVD title %d"), src->uri_title), (NULL)); + return FALSE; + } + if (!gst_dvd_read_src_goto_chapter (src, src->chapter)) { + GST_ERROR_OBJECT (src, "Failed to go to chapter %d of DVD title %d", + src->uri_chapter, src->uri_title); + src->new_seek = FALSE; + src->change_cell = TRUE; return TRUE; } @@ -242,6 +257,8 @@ src->pending_clut_event = NULL; } + GST_LOG_OBJECT (src, "closed DVD"); @@ -352,7 +369,7 @@ if (title < 0 || title >= num_titles) { GST_WARNING_OBJECT (src, "Invalid title %d (only %d available)", title, num_titles); - title = CLAMP (title, 0, num_titles - 1); src->num_chapters = src->tt_srpt->title[title].nr_of_ptts; @@ -446,7 +463,7 @@ src->title_lang_event_pending = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s); - return 0; + return TRUE; /* FIXME: double-check this function, compare against original */ @@ -694,12 +711,14 @@ const GValue * value, GParamSpec * pspec) { GstDvdReadSrc *src = GST_DVD_READ_SRC (object); + gboolean started; GST_OBJECT_LOCK (src); + started = GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_STARTED); switch (prop_id) { case ARG_DEVICE:{ - if (!GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_STARTED)) { + if (!started) { g_warning ("%s: property '%s' needs to be set before the device is " "opened", GST_ELEMENT_NAME (src), pspec->name); break;; @@ -715,15 +734,24 @@ break; } case ARG_TITLE: - src->title = g_value_get_int (value); - src->new_seek = TRUE; + src->uri_title = g_value_get_int (value); + if (started) { + src->title = src->uri_title - 1; + src->new_seek = TRUE; + } case ARG_CHAPTER: - src->chapter = g_value_get_int (value); + src->uri_chapter = g_value_get_int (value); + src->chapter = src->uri_chapter - 1; case ARG_ANGLE: - src->angle = g_value_get_int (value); + src->uri_angle = g_value_get_int (value); + src->angle = src->uri_angle - 1; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -746,13 +774,13 @@ g_value_set_string (value, src->location); - g_value_set_int (value, src->title); + g_value_set_int (value, src->uri_title); - g_value_set_int (value, src->chapter); + g_value_set_int (value, src->uri_chapter); - g_value_set_int (value, src->angle); + g_value_set_int (value, src->uri_angle); @@ -1167,9 +1195,13 @@ GstDvdReadSrc *src = GST_DVD_READ_SRC (handler); + GST_OBJECT_LOCK (src); g_free (src->last_uri); - src->last_uri = - g_strdup_printf ("dvd://%d,%d,%d", src->title, src->chapter, src->angle); + src->last_uri = g_strdup_printf ("dvd://%d,%d,%d", src->uri_title, + src->uri_chapter, src->uri_angle); + GST_OBJECT_UNLOCK (src); return src->last_uri; @@ -1201,6 +1233,12 @@ if (!location) return ret; + GST_OBJECT_LOCK (src); + src->uri_title = 1; + src->uri_chapter = 1; + src->uri_angle = 1; strcur = strs = g_strsplit (location, ",", 0); while (strcur && *strcur) { gint val; @@ -1208,21 +1246,21 @@ if (!sscanf (*strcur, "%d", &val)) break; + if (val <= 0) { + g_warning ("Invalid value %d in URI '%s'. Must be 1 or greater", + val, location); + break; switch (pos) { case 0: - if (val != src->title) { - src->title = val; - src->new_seek = TRUE; - } + src->uri_title = val; break; case 1: - if (val != src->chapter) { - src->chapter = val; + src->uri_chapter = val; case 2: - src->angle = val; + src->uri_angle = val; } @@ -1230,6 +1268,15 @@ pos++; + if (pos > 0 && GST_OBJECT_FLAG_IS_SET (src, GST_BASE_SRC_STARTED)) { + src->title = src->uri_title - 1; + src->chapter = src->uri_chapter - 1; + src->angle = src->uri_angle - 1; + src->new_seek = TRUE; + } + GST_OBJECT_UNLOCK (src); g_strfreev (strs); g_free (location); Index: dvdreadsrc.h RCS file: /cvs/gstreamer/gst-plugins-ugly/ext/dvdread/dvdreadsrc.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- dvdreadsrc.h 9 Feb 2006 17:27:57 -0000 1.8 +++ dvdreadsrc.h 14 Feb 2006 14:57:18 -0000 1.9 @@ -52,7 +52,14 @@ gboolean new_cell; - gint title, chapter, angle; + gint uri_title; /* set via the URI handler or properties, */ + gint uri_chapter; /* otherwise not touched; these values */ + gint uri_angle; /* start from 1 */ + gint title; /* current position while open, set to the */ + gint chapter; /* URI-set values in ::start(). these */ + gint angle; /* values start from 0 */ gint start_cell, last_cell, cur_cell; gint cur_pack; gint next_cell; |