From 62e9ba35b50d6f6cc7ec356c6ab449130d802959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 25 Apr 2006 12:17:02 +0000 Subject: [PATCH] ext/dvdnav/dvdnavsrc.c: Fix name of custom event (use same as dvdreadsrc). Original commit message from CVS: * ext/dvdnav/dvdnavsrc.c: (gst_dvd_nav_src_push_titlelang_event): Fix name of custom event (use same as dvdreadsrc). * gst/dvdsub/gstdvdsubdec.c: (gst_dvd_sub_dec_chain), (gst_dvd_sub_dec_sink_event), (gst_dvd_sub_dec_handle_dvd_event): Fix event parsing (the event name is in the structure, not the name of the structure itself); also fix indentation after boilerplate macro. --- ChangeLog | 11 +++++ ext/dvdnav/dvdnavsrc.c | 2 +- gst/dvdsub/gstdvdsubdec.c | 97 ++++++++++++++++++++++----------------- 3 files changed, 68 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecd89bb03f..c299325efd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-04-25 Tim-Philipp Müller + + * ext/dvdnav/dvdnavsrc.c: (gst_dvd_nav_src_push_titlelang_event): + Fix name of custom event (use same as dvdreadsrc). + + * gst/dvdsub/gstdvdsubdec.c: (gst_dvd_sub_dec_chain), + (gst_dvd_sub_dec_sink_event), (gst_dvd_sub_dec_handle_dvd_event): + Fix event parsing (the event name is in the structure, not the + name of the structure itself); also fix indentation after + boilerplate macro. + 2006-04-23 Tim-Philipp Müller * ext/mad/gstid3tag.c: (plugin_init): diff --git a/ext/dvdnav/dvdnavsrc.c b/ext/dvdnav/dvdnavsrc.c index 7405f87fe2..38b52356cb 100644 --- a/ext/dvdnav/dvdnavsrc.c +++ b/ext/dvdnav/dvdnavsrc.c @@ -1183,7 +1183,7 @@ gst_dvd_nav_src_push_titlelang_event (GstDvdNavSrc * src) /* build event */ - s = gst_structure_new ("application/x-gst-event", + s = gst_structure_new ("application/x-gst-dvd", "event", G_TYPE_STRING, "dvd-lang-codes", NULL); e = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM, s); diff --git a/gst/dvdsub/gstdvdsubdec.c b/gst/dvdsub/gstdvdsubdec.c index 6eefed8f0b..2d39e3ac27 100644 --- a/gst/dvdsub/gstdvdsubdec.c +++ b/gst/dvdsub/gstdvdsubdec.c @@ -27,32 +27,28 @@ #include "gstdvdsubdec.h" #include -GST_BOILERPLATE (GstDvdSubDec, gst_dvd_sub_dec, GstElement, GST_TYPE_ELEMENT) +GST_BOILERPLATE (GstDvdSubDec, gst_dvd_sub_dec, GstElement, GST_TYPE_ELEMENT); - static gboolean gst_dvd_sub_dec_src_event (GstPad * srcpad, - GstEvent * event); - static GstFlowReturn gst_dvd_sub_dec_chain (GstPad * pad, GstBuffer * buf); +static gboolean gst_dvd_sub_dec_src_event (GstPad * srcpad, GstEvent * event); +static GstFlowReturn gst_dvd_sub_dec_chain (GstPad * pad, GstBuffer * buf); - static gboolean gst_dvd_sub_dec_handle_dvd_event (GstDvdSubDec * dec, - GstEvent * event); - static void gst_dvd_sub_dec_finalize (GObject * gobject); - static void gst_setup_palette (GstDvdSubDec * dec); - static void gst_dvd_sub_dec_merge_title (GstDvdSubDec * dec, - GstBuffer * buf); - static GstClockTime gst_dvd_sub_dec_get_event_delay (GstDvdSubDec * dec); - static gboolean gst_dvd_sub_dec_sink_event (GstPad * pad, +static gboolean gst_dvd_sub_dec_handle_dvd_event (GstDvdSubDec * dec, GstEvent * event); +static void gst_dvd_sub_dec_finalize (GObject * gobject); +static void gst_setup_palette (GstDvdSubDec * dec); +static void gst_dvd_sub_dec_merge_title (GstDvdSubDec * dec, GstBuffer * buf); +static GstClockTime gst_dvd_sub_dec_get_event_delay (GstDvdSubDec * dec); +static gboolean gst_dvd_sub_dec_sink_event (GstPad * pad, GstEvent * event); - static GstFlowReturn gst_send_subtitle_frame (GstDvdSubDec * dec, +static GstFlowReturn gst_send_subtitle_frame (GstDvdSubDec * dec, GstClockTime end_ts); - static GstElementDetails gst_dvd_sub_dec_details = { - "DVD subtitle Decoder", - "Codec/Decoder/Video", - "Decodes DVD subtitles into AYUV video frames", - "Wim Taymans , " - "Jan Schmidt " - }; +static const GstElementDetails gst_dvd_sub_dec_details = +GST_ELEMENT_DETAILS ("DVD subtitle Decoder", + "Codec/Decoder/Video", + "Decodes DVD subtitles into AYUV video frames", + "Wim Taymans , " + "Jan Schmidt "); static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, @@ -742,7 +738,7 @@ gst_dvd_sub_dec_chain (GstPad * pad, GstBuffer * buf) GST_TIME_FORMAT ", dur %" G_GINT64_FORMAT, GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_BUFFER_DURATION (buf)); - if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_TIMESTAMP (buf))) { + if (GST_BUFFER_TIMESTAMP_IS_VALID (buf)) { if (!GST_CLOCK_TIME_IS_VALID (dec->next_ts)) { dec->next_ts = GST_BUFFER_TIMESTAMP (buf); } @@ -806,26 +802,27 @@ gst_dvd_sub_dec_sink_event (GstPad * pad, GstEvent * event) GstDvdSubDec *dec = GST_DVD_SUB_DEC (gst_pad_get_parent (pad)); gboolean ret = FALSE; - GST_LOG_OBJECT (dec, "Handling %s event", GST_EVENT_TYPE_NAME (event)); + GST_LOG_OBJECT (dec, "%s event", GST_EVENT_TYPE_NAME (event)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_CUSTOM_DOWNSTREAM:{ GstClockTime ts = GST_EVENT_TIMESTAMP (event); - GST_LOG_OBJECT (dec, "DVD event on subtitle pad with timestamp %llu", - GST_EVENT_TIMESTAMP (event)); + if (event->structure != NULL && + gst_structure_has_name (event->structure, "application/x-gst-dvd")) { - if (GST_CLOCK_TIME_IS_VALID (ts)) - gst_dvd_sub_dec_advance_time (dec, ts); + if (GST_CLOCK_TIME_IS_VALID (ts)) + gst_dvd_sub_dec_advance_time (dec, ts); - if (!gst_dvd_sub_dec_handle_dvd_event (dec, event)) { - ret = gst_pad_event_default (pad, event); - break; + if (gst_dvd_sub_dec_handle_dvd_event (dec, event)) { + /* gst_dvd_sub_dec_advance_time (dec, dec->next_ts + GST_SECOND / 30.0); */ + gst_event_unref (event); + ret = TRUE; + break; + } } - // gst_dvd_sub_dec_advance_time (dec, dec->next_ts + GST_SECOND / 30.0); - gst_event_unref (event); - ret = TRUE; + ret = gst_pad_event_default (pad, event); break; } case GST_EVENT_NEWSEGMENT:{ @@ -900,10 +897,22 @@ static gboolean gst_dvd_sub_dec_handle_dvd_event (GstDvdSubDec * dec, GstEvent * event) { GstStructure *structure; + const gchar *event_name; structure = (GstStructure *) gst_event_get_structure (event); - if (gst_structure_has_name (structure, "dvd-spu-highlight")) { + if (structure == NULL) + goto not_handled; + + event_name = gst_structure_get_string (structure, "event"); + + GST_LOG_OBJECT (dec, "DVD event %s with timestamp %lld on sub pad", + GST_STR_NULL (event_name), GST_EVENT_TIMESTAMP (event)); + + if (event_name == NULL) + goto not_handled; + + if (strcmp (event_name, "dvd-spu-highlight") == 0) { gint button; gint palette, sx, sy, ex, ey; gint i; @@ -933,13 +942,13 @@ gst_dvd_sub_dec_handle_dvd_event (GstDvdSubDec * dec, GstEvent * event) gst_setup_palette (dec); dec->buf_dirty = TRUE; - } else if (gst_structure_has_name (structure, "dvd-spu-clut-change")) { + } else if (strcmp (event_name, "dvd-spu-clut-change") == 0) { /* Take a copy of the colour table */ gchar name[16]; int i; gint value; - GST_LOG_OBJECT (dec, "New colour table recieved"); + GST_LOG_OBJECT (dec, "New colour table received"); for (i = 0; i < 16; i++) { g_snprintf (name, sizeof (name), "clut%02d", i); if (!gst_structure_get_int (structure, name, &value)) { @@ -953,23 +962,29 @@ gst_dvd_sub_dec_handle_dvd_event (GstDvdSubDec * dec, GstEvent * event) gst_setup_palette (dec); dec->buf_dirty = TRUE; - } else if (gst_structure_has_name (structure, "dvd-spu-stream-change") - || gst_structure_has_name (structure, "dvd-spu-reset-highlight")) { + } else if (strcmp (event_name, "dvd-spu-stream-change") == 0 + || strcmp (event_name, "dvd-spu-reset-highlight") == 0) { /* Turn off forced highlight display */ dec->current_button = 0; GST_LOG_OBJECT (dec, "Clearing button state"); dec->buf_dirty = TRUE; - } else if (gst_structure_has_name (structure, "dvd-spu-still-frame")) { + } else if (strcmp (event_name, "dvd-spu-still-frame") == 0) { /* Handle a still frame */ GST_LOG_OBJECT (dec, "Received still frame notification"); } else { + goto not_handled; + } + + return TRUE; + +not_handled: + { /* Ignore all other unknown events */ - GST_LOG_OBJECT (dec, "Ignoring other custom event %s", - gst_structure_get_name (structure)); + GST_LOG_OBJECT (dec, "Ignoring other custom event %" GST_PTR_FORMAT, + structure); return FALSE; } - return TRUE; } static gboolean