*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include "_stdint.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
#include <string.h>
#include <errno.h>
static void gst_dvd_read_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstEvent *gst_dvd_read_src_make_clut_change_event (GstDvdReadSrc * src,
- const guint * clut);
+ const guint32 * clut);
static gboolean gst_dvd_read_src_get_size (GstDvdReadSrc * src, gint64 * size);
static gboolean gst_dvd_read_src_do_seek (GstBaseSrc * src, GstSegment * s);
static gint64 gst_dvd_read_src_convert_timecode (dvd_time_t * time);
static void gst_dvd_read_src_uri_handler_init (gpointer g_iface,
gpointer iface_data);
+static gboolean dvdread_element_init (GstPlugin * plugin);
#define gst_dvd_read_src_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstDvdReadSrc, gst_dvd_read_src, GST_TYPE_PUSH_SRC,
G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
gst_dvd_read_src_uri_handler_init));
+GST_ELEMENT_REGISTER_DEFINE_CUSTOM (dvdreadsrc, dvdread_element_init);
static void
gst_dvd_read_src_finalize (GObject * object)
static void
gst_dvd_read_src_init (GstDvdReadSrc * src)
{
+ GstCaps *src_caps = gst_static_pad_template_get_caps (&srctemplate);
src->dvd = NULL;
src->vts_file = NULL;
src->vmg_file = NULL;
src->dvd_title = NULL;
src->location = g_strdup ("/dev/dvd");
+ src->first_seek = TRUE;
src->new_seek = TRUE;
src->new_cell = TRUE;
src->change_cell = FALSE;
src->pending_clut_event = NULL;
gst_pad_use_fixed_caps (GST_BASE_SRC_PAD (src));
- gst_pad_set_caps (GST_BASE_SRC_PAD (src),
- gst_static_pad_template_get_caps (&srctemplate));
+ gst_pad_set_caps (GST_BASE_SRC_PAD (src), src_caps);
+ gst_caps_unref (src_caps);
}
static gboolean
g_param_spec_int ("angle", "angle", "angle",
1, 999, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&srctemplate));
+ gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
gst_element_class_set_static_metadata (gstelement_class, "DVD Source",
"Source/File/DVD",
src->new_seek = FALSE;
src->change_cell = TRUE;
+ src->first_seek = TRUE;
+
return TRUE;
/* ERRORS */
*p_first_cell = pgc->program_map[pgn - 1] - 1;
+ /* last cell is used as a 'up to boundary', not 'up to and including',
+ * i.e. it is the first cell not included in the chapter range */
if (chapter == (src->num_chapters - 1)) {
- *p_last_cell = pgc->nr_of_cells - 1;
+ *p_last_cell = pgc->nr_of_cells;
} else {
pgn_next_ch = src->vts_ptt_srpt->title[src->ttn - 1].ptt[chapter + 1].pgn;
*p_last_cell = pgc->program_map[pgn_next_ch - 1] - 1;
gst_dvd_read_src_goto_chapter (GstDvdReadSrc * src, gint chapter)
{
gint i;
+ const guint8 *palette;
/* make sure the chapter number is valid for this title */
if (chapter < 0 || chapter >= src->num_chapters) {
if (src->pending_clut_event)
gst_event_unref (src->pending_clut_event);
+ /* Work around GCC 9 compiler warning here about taking address of packed
+ * member, which may result in an unaligned pointer access */
+ palette = (const guint8 *) src->cur_pgc->palette;
src->pending_clut_event =
- gst_dvd_read_src_make_clut_change_event (src, src->cur_pgc->palette);
+ gst_dvd_read_src_make_clut_change_event (src, (const guint32 *) palette);
return TRUE;
}
t = g_strdup_printf ("audio-%d-format", i);
gst_structure_set (s, t, G_TYPE_INT, (int) a->audio_format, NULL);
g_free (t);
+ t = g_strdup_printf ("audio-%d-stream", i);
+ gst_structure_set (s, t, G_TYPE_INT, (int) i, NULL);
+ g_free (t);
if (a->lang_type) {
t = g_strdup_printf ("audio-%d-language", i);
}
if (u->type) {
- t = g_strdup_printf ("subtitle-%d-language", sid);
+ t = g_strdup_printf ("subpicture-%d-language", i);
lang_code[0] = (u->lang_code >> 8) & 0xff;
lang_code[1] = u->lang_code & 0xff;
gst_structure_set (s, t, G_TYPE_STRING, lang_code, NULL);
g_free (t);
+ t = g_strdup_printf ("subpicture-%d-stream", i);
+ gst_structure_set (s, t, G_TYPE_INT, (int) sid, NULL);
+ g_free (t);
+ t = g_strdup_printf ("subpicture-%d-format", i);
+ gst_structure_set (s, t, G_TYPE_INT, (int) 0, NULL);
+ g_free (t);
} else {
lang_code[0] = '\0';
}
for (j = 0; j < src->vts_tmapt->tmap[i].nr_of_entries; j++) {
guint64 time;
- time = src->vts_tmapt->tmap[i].tmu * (j + 1) * GST_SECOND;
+ time = (guint64) src->vts_tmapt->tmap[i].tmu * (j + 1) * GST_SECOND;
GST_LOG_OBJECT (src, "Time: %" GST_TIME_FORMAT " VOBU "
"Sector: 0x%08x %s", GST_TIME_ARGS (time),
src->vts_tmapt->tmap[i].map_ent[j] & 0x7fffffff,
for (i = 0; i < src->vts_tmapt->nr_of_tmaps; ++i) {
for (j = 0; j < src->vts_tmapt->tmap[i].nr_of_entries; ++j) {
if ((src->vts_tmapt->tmap[i].map_ent[j] & 0x7fffffff) == sector)
- return src->vts_tmapt->tmap[i].tmu * (j + 1) * GST_SECOND;
+ return (guint64) src->vts_tmapt->tmap[i].tmu * (j + 1) * GST_SECOND;
}
}
if (src->vts_tmapt == NULL || src->vts_tmapt->nr_of_tmaps < src->ttn)
return -1;
- sector = 0;
+ sector = src->vts_tmapt->tmap[src->ttn - 1].map_ent[0] & 0x7fffffff;
+
for (j = 0; j < src->vts_tmapt->tmap[src->ttn - 1].nr_of_entries; ++j) {
GstClockTime entry_time;
- entry_time = src->vts_tmapt->tmap[src->ttn - 1].tmu * (j + 1) * GST_SECOND;
+ entry_time =
+ (guint64) src->vts_tmapt->tmap[src->ttn - 1].tmu * (j + 1) * GST_SECOND;
if (entry_time <= ts) {
sector = src->vts_tmapt->tmap[src->ttn - 1].map_ent[j] & 0x7fffffff;
}
if (started) {
g_warning ("%s: property '%s' needs to be set before the device is "
"opened", GST_ELEMENT_NAME (src), pspec->name);
- break;;
+ break;
}
g_free (src->location);
if (g_value_get_string (value) == NULL) {
src->location = g_strdup ("/dev/dvd");
} else {
- src->location = g_strdup (g_value_get_string (value));
+ src->location = g_value_dup_string (value);
}
break;
}
GST_DEBUG_OBJECT (src, "Seeking to %s: %12" G_GINT64_FORMAT,
gst_format_get_name (s->format), s->position);
+ /* Ignore the first seek to 0, as it breaks starting playback
+ * from another chapter by seeking back to sector 0 */
+ if (src->first_seek && s->format == GST_FORMAT_BYTES && s->start == 0) {
+ src->first_seek = FALSE;
+ return TRUE;
+ }
+
if (s->format == sector_format || s->format == GST_FORMAT_BYTES
|| s->format == GST_FORMAT_TIME) {
guint old;
static GstEvent *
gst_dvd_read_src_make_clut_change_event (GstDvdReadSrc * src,
- const guint * clut)
+ const guint32 * clut)
{
GstStructure *structure;
gchar name[16];
}
/* Create the DVD event and put the structure into it. */
- return gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, structure);
+ return gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, structure);
}
static gint64
gst_dvd_read_src_do_duration_query (GstDvdReadSrc * src, GstQuery * query)
{
GstFormat format;
- gint64 val;
+ gint64 val = 0;
gst_query_parse_duration (query, &format, NULL);
gint first = src->cur_pgc->cell_playback[cur].first_sector;
gint last = src->cur_pgc->cell_playback[cur].last_sector;
GST_DEBUG_OBJECT (src, "Cell %d sector bounds: %d %d", cur, first, last);
+ cur = next;
+ if (src->cur_pgc->cell_playback[cur].block_type == BLOCK_TYPE_ANGLE_BLOCK)
+ cur += angle;
+ next = gst_dvd_read_src_get_next_cell (src, src->cur_pgc, cur);
/* seeking to 0 should end up at first chapter in any case */
if ((seek_to >= first && seek_to <= last) || (seek_to == 0 && i == 0)) {
GST_DEBUG_OBJECT (src, "Seek target found in chapter %d", i);
chapter = i;
goto done;
}
- cur = next;
- if (src->cur_pgc->cell_playback[cur].block_type == BLOCK_TYPE_ANGLE_BLOCK)
- cur += angle;
- next = gst_dvd_read_src_get_next_cell (src, src->cur_pgc, cur);
}
}
}
static gboolean
-plugin_init (GstPlugin * plugin)
+dvdread_element_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (gstgst_dvd_read_src_debug, "dvdreadsrc", 0,
"DVD reader element based on dvdreadsrc");
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
+ return gst_element_register (plugin, "dvdreadsrc", GST_RANK_NONE,
+ GST_TYPE_DVD_READ_SRC);
+}
- if (!gst_element_register (plugin, "dvdreadsrc", GST_RANK_NONE,
- GST_TYPE_DVD_READ_SRC)) {
- return FALSE;
- }
-
- return TRUE;
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ return GST_ELEMENT_REGISTER (dvdreadsrc, plugin);
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,