From 1875564b65d589b86c80417dfb553c31eef142f0 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Wed, 3 Sep 2008 10:12:04 +0000 Subject: [PATCH] Rework last change, so that we build subparse, but just disable the sami parse functionality, if we're configured to ... Original commit message from CVS: * configure.ac: * gst/subparse/Makefile.am: * gst/subparse/gstsubparse.c: * gst/subparse/samiparse.c: * tests/check/elements/subparse.c: Rework last change, so that we build subparse, but just disable the sami parse functionality, if we're configured to not use xml. In the tests only the sami test is disabled now. --- ChangeLog | 11 +++++++++++ configure.ac | 4 +--- gst/subparse/Makefile.am | 9 +++++++-- gst/subparse/gstsubparse.c | 26 +++++++++++++++++++++----- gst/subparse/samiparse.c | 31 ------------------------------- tests/check/elements/subparse.c | 4 ++++ 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7b9d0dd5f9..65705c3f13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-09-03 Stefan Kost + + * configure.ac: + * gst/subparse/Makefile.am: + * gst/subparse/gstsubparse.c: + * gst/subparse/samiparse.c: + * tests/check/elements/subparse.c: + Rework last change, so that we build subparse, but just disable the + sami parse functionality, if we're configured to not use xml. In the + tests only the sami test is disabled now. + 2008-09-02 Stefan Kost * configure.ac: diff --git a/configure.ac b/configure.ac index 11e7f96fda..2493d4aa76 100644 --- a/configure.ac +++ b/configure.ac @@ -307,9 +307,7 @@ AG_GST_CHECK_PLUGIN(volume) dnl check for gstreamer core features (subsystems) GST_CONFIGPATH=`$PKG_CONFIG --variable=includedir gstreamer-0.10`"/gst/gstconfig.h" AG_GST_PARSE_SUBSYSTEM_DISABLES($GST_CONFIGPATH) -if test $GST_DISABLE_XML = "1"; then - AG_GST_DISABLE_PLUGIN(subparse) -fi +AM_CONDITIONAL(USE_XML, test $GST_DISABLE_XML != "1") dnl disable plug-ins that require libxml2's HTML support if it is not available if test "x$HAVE_LIBXML_HTML" != "xyes"; then diff --git a/gst/subparse/Makefile.am b/gst/subparse/Makefile.am index 0093548699..18e091ac35 100644 --- a/gst/subparse/Makefile.am +++ b/gst/subparse/Makefile.am @@ -1,12 +1,17 @@ plugin_LTLIBRARIES = libgstsubparse.la +if USE_XML +SAMIPARSE_SOURCES = samiparse.c samiparse.h +else +SAMIPARSE_SOURCES = +endif + libgstsubparse_la_SOURCES = \ gstssaparse.c \ gstssaparse.h \ gstsubparse.c \ gstsubparse.h \ - samiparse.c \ - samiparse.h \ + $(SAMIPARSE_SOURCES) \ tmplayerparse.c \ tmplayerparse.h \ mpl2parse.c \ diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index 87a7c9c807..6dc25bc396 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -146,7 +146,9 @@ gst_sub_parse_dispose (GObject * object) g_string_free (subparse->textbuf, TRUE); subparse->textbuf = NULL; } +#ifndef GST_DISABLE_XML sami_context_deinit (&subparse->state); +#endif GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); } @@ -882,9 +884,11 @@ parser_state_dispose (ParserState * state) g_string_free (state->buf, TRUE); state->buf = NULL; } +#ifndef GST_DISABLE_XML if (state->user_data) { sami_context_reset (state); } +#endif } /* @@ -931,11 +935,13 @@ gst_sub_parse_data_format_autodetect (gchar * match_str) GST_LOG ("MPSub (time based) format detected"); return GST_SUB_PARSE_FORMAT_MPSUB; } +#ifndef GST_DISABLE_XML if (strstr (match_str, "") != NULL || strstr (match_str, "") != NULL) { GST_LOG ("SAMI (time based) format detected"); return GST_SUB_PARSE_FORMAT_SAMI; } +#endif /* we're boldly assuming the first subtitle appears within the first hour */ if (sscanf (match_str, "0:%02u:%02u:", &n1, &n2) == 2 || sscanf (match_str, "0:%02u:%02u=", &n1, &n2) == 2 || @@ -986,10 +992,12 @@ gst_sub_parse_format_autodetect (GstSubParse * self) case GST_SUB_PARSE_FORMAT_MPSUB: self->parse_line = parse_mpsub; return gst_caps_new_simple ("text/plain", NULL); +#ifndef GST_DISABLE_XML case GST_SUB_PARSE_FORMAT_SAMI: self->parse_line = parse_sami; sami_context_init (&self->state); return gst_caps_new_simple ("text/x-pango-markup", NULL); +#endif case GST_SUB_PARSE_FORMAT_TMPLAYER: self->parse_line = parse_tmplayer; self->state.max_duration = 5 * GST_SECOND; @@ -1027,7 +1035,9 @@ feed_textbuf (GstSubParse * self, GstBuffer * buf) /* flush the parser state */ parser_state_init (&self->state); g_string_truncate (self->textbuf, 0); +#ifndef GST_DISABLE_XML sami_context_reset (&self->state); +#endif /* we could set a flag to make sure that the next buffer we push out also * has the DISCONT flag set, but there's no point really given that it's * subtitles which are discontinuous by nature. */ @@ -1272,16 +1282,20 @@ gst_sub_parse_change_state (GstElement * element, GstStateChange transition) * also, give different subtitle formats really different types */ static GstStaticCaps mpl2_caps = GST_STATIC_CAPS ("application/x-subtitle-mpl2"); +#define SUB_CAPS (gst_static_caps_get (&sub_caps)) + static GstStaticCaps tmp_caps = GST_STATIC_CAPS ("application/x-subtitle-tmplayer"); -static GstStaticCaps smi_caps = GST_STATIC_CAPS ("application/x-subtitle-sami"); -static GstStaticCaps sub_caps = GST_STATIC_CAPS ("application/x-subtitle"); - -#define SUB_CAPS (gst_static_caps_get (&sub_caps)) -#define SAMI_CAPS (gst_static_caps_get (&smi_caps)) #define TMP_CAPS (gst_static_caps_get (&tmp_caps)) + +static GstStaticCaps sub_caps = GST_STATIC_CAPS ("application/x-subtitle"); #define MPL2_CAPS (gst_static_caps_get (&mpl2_caps)) +#ifndef GST_DISABLE_XML +static GstStaticCaps smi_caps = GST_STATIC_CAPS ("application/x-subtitle-sami"); +#define SAMI_CAPS (gst_static_caps_get (&smi_caps)) +#endif + static void gst_subparse_type_find (GstTypeFind * tf, gpointer private) { @@ -1311,10 +1325,12 @@ gst_subparse_type_find (GstTypeFind * tf, gpointer private) GST_DEBUG ("MPSub format detected"); caps = SUB_CAPS; break; +#ifndef GST_DISABLE_XML case GST_SUB_PARSE_FORMAT_SAMI: GST_DEBUG ("SAMI (time-based) format detected"); caps = SAMI_CAPS; break; +#endif case GST_SUB_PARSE_FORMAT_TMPLAYER: GST_DEBUG ("TMPlayer (time based) format detected"); caps = TMP_CAPS; diff --git a/gst/subparse/samiparse.c b/gst/subparse/samiparse.c index 1cceeaac48..dbf069d2e3 100644 --- a/gst/subparse/samiparse.c +++ b/gst/subparse/samiparse.c @@ -19,8 +19,6 @@ #include "samiparse.h" -/* FIXME: use Makefile stuff */ -#ifndef GST_DISABLE_XML #include #include @@ -466,32 +464,3 @@ parse_sami (ParserState * state, const gchar * line) } return NULL; } - -#else /* GST_DISABLE_XML */ - -gchar * -parse_sami (ParserState * state, const gchar * line) -{ - /* our template caps should not include sami in this case */ - g_assert_not_reached (); -} - -void -sami_context_init (ParserState * state) -{ - return; -} - -void -sami_context_deinit (ParserState * state) -{ - return; -} - -void -sami_context_reset (ParserState * state) -{ - return; -} - -#endif /* GST_DISABLE_XML */ diff --git a/tests/check/elements/subparse.c b/tests/check/elements/subparse.c index c5127b7b54..8cb02f4022 100644 --- a/tests/check/elements/subparse.c +++ b/tests/check/elements/subparse.c @@ -583,6 +583,7 @@ GST_START_TEST (test_subviewer2) GST_END_TEST; +#ifndef GST_DISABLE_XML GST_START_TEST (test_sami) { SubParseInputChunk sami_input[] = { @@ -618,6 +619,7 @@ GST_START_TEST (test_sami) } GST_END_TEST; +#endif /* TODO: * - add/modify tests so that lines aren't dogfed to the parsers in complete @@ -646,7 +648,9 @@ subparse_suite (void) tcase_add_test (tc_chain, test_mpl2); tcase_add_test (tc_chain, test_subviewer); tcase_add_test (tc_chain, test_subviewer2); +#ifndef GST_DISABLE_XML tcase_add_test (tc_chain, test_sami); +#endif return s; }