From e591dcd64cfd672f380fbce0602457c9d4e08993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 10 Aug 2009 13:21:09 +0100 Subject: spc: fix typo in Makefile.am and build the right plugin (spc not gme) --- ext/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext') diff --git a/ext/Makefile.am b/ext/Makefile.am index 31dd00a4..da5085e4 100644 --- a/ext/Makefile.am +++ b/ext/Makefile.am @@ -307,7 +307,7 @@ SOUNDTOUCH_DIR= endif if USE_SPC -SPC_DIR=gme +SPC_DIR=spc else SPC_DIR= endif -- cgit v1.2.1 From 20a4c32a0b981a1498dc5e2beddb4b52144359c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 11 Aug 2009 12:42:28 +0100 Subject: kateenc: error out if category has not been set and check for obviously wrong values --- ext/kate/gstkateenc.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 3 deletions(-) (limited to 'ext') diff --git a/ext/kate/gstkateenc.c b/ext/kate/gstkateenc.c index 42333509..d4e8835b 100644 --- a/ext/kate/gstkateenc.c +++ b/ext/kate/gstkateenc.c @@ -62,14 +62,18 @@ * * This encodes a DVD SPU track to a Kate stream: * - * gst-launch dvdreadsrc ! dvddemux ! dvdsubparse ! kateenc ! oggmux ! filesink location=test.ogg + * gst-launch dvdreadsrc ! dvddemux ! dvdsubparse ! kateenc category=spu-subtitles ! oggmux ! filesink location=test.ogg * * * */ -/* FIXME: should we automatically pick up the language code from the - * upstream event tags if none was set via the property? */ +/* FIXME: + * - should we automatically pick up the language code from the + * upstream event tags if none was set via the property? + * - turn category property into an enum (freestyle text property in + * combination with supposedly strictly defined known values that + * aren't even particularly human-readable is just not very nice)? */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -131,6 +135,7 @@ static void gst_kate_enc_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static void gst_kate_enc_dispose (GObject * object); +static gboolean gst_kate_enc_setcaps (GstPad * pad, GstCaps * caps); static GstFlowReturn gst_kate_enc_chain (GstPad * pad, GstBuffer * buf); static GstStateChangeReturn gst_kate_enc_change_state (GstElement * element, GstStateChange transition); @@ -246,6 +251,8 @@ gst_kate_enc_init (GstKateEnc * ke, GstKateEncClass * gclass) GST_DEBUG_FUNCPTR (gst_kate_enc_chain)); gst_pad_set_event_function (ke->sinkpad, GST_DEBUG_FUNCPTR (gst_kate_enc_sink_event)); + gst_pad_set_setcaps_function (ke->sinkpad, + GST_DEBUG_FUNCPTR (gst_kate_enc_setcaps)); gst_element_add_pad (GST_ELEMENT (ke), ke->sinkpad); ke->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); @@ -514,6 +521,47 @@ gst_kate_enc_set_metadata (GstKateEnc * ke) } } +static gboolean +gst_kate_enc_setcaps (GstPad * pad, GstCaps * caps) +{ + GstKateEnc *ke; + + ke = GST_KATE_ENC (GST_PAD_PARENT (pad)); + + GST_LOG_OBJECT (ke, "input caps: %" GST_PTR_FORMAT, caps); + + /* One day we could try to automatically set the category based on the + * input format, assuming that the input is subtitles. Currently that + * doesn't work yet though, because we send the header packets already from + * the sink event handler when receiving the newsegment event, so before + * the first buffer (might be tricky to change too, given that there could + * be no data at the beginning for a long time). So for now we just try to + * make sure people didn't set the category to something obviously wrong. */ + if (ke->category != NULL) { + GstStructure *s = gst_caps_get_structure (caps, 0); + + if (gst_structure_has_name (s, "text/plain") || + gst_structure_has_name (s, "text/x-pango-markup")) { + if (strcmp (ke->category, "K-SPU") == 0 || + strcmp (ke->category, "spu-subtitles") == 0) { + GST_ELEMENT_WARNING (ke, LIBRARY, SETTINGS, (NULL), + ("Category set to '%s', but input is text-based.", ke->category)); + } + } else if (gst_structure_has_name (s, "video/x-dvd-subpicture")) { + if (strcmp (ke->category, "SUB") == 0 || + strcmp (ke->category, "subtitles") == 0) { + GST_ELEMENT_WARNING (ke, LIBRARY, SETTINGS, (NULL), + ("Category set to '%s', but input is subpictures.", ke->category)); + } + } else { + GST_ERROR_OBJECT (ke, "unexpected input caps %" GST_PTR_FORMAT, caps); + return FALSE; + } + } + + return TRUE; +} + static gboolean gst_kate_enc_is_simple_subtitle_category (GstKateEnc * ke, const char *category) { @@ -541,6 +589,14 @@ gst_kate_enc_send_headers (GstKateEnc * ke) GstCaps *caps; GList *headers = NULL, *item; + if (G_UNLIKELY (ke->category == NULL || *ke->category == '\0')) { + /* The error code is a bit of a lie, but seems most appropriate. */ + GST_ELEMENT_ERROR (ke, LIBRARY, SETTINGS, (NULL), + ("The 'category' property must be set. For subtitles, set it to " + "either 'SUB' (text subtitles) or 'K-SPU' (dvd-style subtitles)")); + return GST_FLOW_ERROR; + } + gst_kate_enc_set_metadata (ke); /* encode headers and store them in a list */ -- cgit v1.2.1