gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
/* GStreamer SSA subtitle parser
|
|
|
|
* Copyright (c) 2006 Tim-Philipp Müller <tim centricular net>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Super-primitive SSA parser - we just want the text and ignore
|
|
|
|
* everything else like styles and timing codes etc. for now */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2006-04-29 01:24:31 +00:00
|
|
|
#include <stdlib.h> /* atoi() */
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gstssaparse.h"
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (ssa_parse_debug);
|
|
|
|
#define GST_CAT_DEFAULT ssa_parse_debug
|
|
|
|
|
|
|
|
static GstStaticPadTemplate sink_templ = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS ("application/x-ssa; application/x-ass")
|
|
|
|
);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-09-02 01:41:34 +00:00
|
|
|
GST_STATIC_CAPS ("text/x-raw, format=pango-markup")
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
);
|
|
|
|
|
2011-04-19 09:35:53 +00:00
|
|
|
#define gst_ssa_parse_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstSsaParse, gst_ssa_parse, GST_TYPE_ELEMENT);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
2006-07-11 12:03:25 +00:00
|
|
|
static GstStateChangeReturn gst_ssa_parse_change_state (GstElement *
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
element, GstStateChange transition);
|
2006-07-11 12:03:25 +00:00
|
|
|
static gboolean gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps);
|
2011-11-17 11:48:25 +00:00
|
|
|
static gboolean gst_ssa_parse_src_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
|
|
|
static gboolean gst_ssa_parse_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
|
|
|
static GstFlowReturn gst_ssa_parse_chain (GstPad * sinkpad, GstObject * parent,
|
|
|
|
GstBuffer * buf);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ssa_parse_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
GstSsaParse *parse = GST_SSA_PARSE (object);
|
|
|
|
|
|
|
|
g_free (parse->ini);
|
|
|
|
parse->ini = NULL;
|
|
|
|
|
|
|
|
GST_CALL_PARENT (G_OBJECT_CLASS, dispose, (object));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-19 09:35:53 +00:00
|
|
|
gst_ssa_parse_init (GstSsaParse * parse)
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
{
|
|
|
|
parse->sinkpad = gst_pad_new_from_static_template (&sink_templ, "sink");
|
|
|
|
gst_pad_set_chain_function (parse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_ssa_parse_chain));
|
|
|
|
gst_pad_set_event_function (parse->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_ssa_parse_sink_event));
|
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad);
|
|
|
|
|
|
|
|
parse->srcpad = gst_pad_new_from_static_template (&src_templ, "src");
|
|
|
|
gst_pad_set_event_function (parse->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_ssa_parse_src_event));
|
|
|
|
gst_element_add_pad (GST_ELEMENT (parse), parse->srcpad);
|
|
|
|
gst_pad_use_fixed_caps (parse->srcpad);
|
|
|
|
|
|
|
|
parse->ini = NULL;
|
|
|
|
parse->framed = FALSE;
|
2009-06-11 21:32:28 +00:00
|
|
|
parse->send_tags = FALSE;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_ssa_parse_class_init (GstSsaParseClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2009-10-28 00:59:35 +00:00
|
|
|
object_class->dispose = gst_ssa_parse_dispose;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
2016-03-03 07:46:24 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_templ);
|
|
|
|
gst_element_class_add_static_pad_template (element_class, &src_templ);
|
2012-04-09 23:45:16 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class,
|
2011-04-19 09:35:53 +00:00
|
|
|
"SSA Subtitle Parser", "Codec/Parser/Subtitle",
|
|
|
|
"Parses SSA subtitle streams",
|
|
|
|
"Tim-Philipp Müller <tim centricular net>");
|
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (ssa_parse_debug, "ssaparse", 0,
|
|
|
|
"SSA subtitle parser");
|
|
|
|
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
element_class->change_state = GST_DEBUG_FUNCPTR (gst_ssa_parse_change_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-17 11:48:25 +00:00
|
|
|
gst_ssa_parse_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
{
|
2011-11-17 11:48:25 +00:00
|
|
|
return gst_pad_event_default (pad, parent, event);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-17 11:48:25 +00:00
|
|
|
gst_ssa_parse_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
{
|
2011-06-07 08:58:27 +00:00
|
|
|
gboolean res;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_CAPS:
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
|
|
|
|
|
|
|
gst_event_parse_caps (event, &caps);
|
|
|
|
res = gst_ssa_parse_setcaps (pad, caps);
|
|
|
|
gst_event_unref (event);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2011-11-17 11:48:25 +00:00
|
|
|
res = gst_pad_event_default (pad, parent, event);
|
2011-06-07 08:58:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return res;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
|
|
|
|
{
|
|
|
|
GstSsaParse *parse = GST_SSA_PARSE (GST_PAD_PARENT (sinkpad));
|
2012-02-17 13:37:36 +00:00
|
|
|
GstCaps *outcaps;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
const GValue *val;
|
|
|
|
GstStructure *s;
|
2006-10-10 12:49:03 +00:00
|
|
|
const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
|
2012-12-17 00:59:57 +00:00
|
|
|
const gchar *end;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
GstBuffer *priv;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
|
|
|
gchar *ptr;
|
2012-12-17 00:59:57 +00:00
|
|
|
gsize left, bad_offset;
|
2012-02-17 13:37:36 +00:00
|
|
|
gboolean ret;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
|
|
|
s = gst_caps_get_structure (caps, 0);
|
|
|
|
val = gst_structure_get_value (s, "codec_data");
|
|
|
|
if (val == NULL) {
|
|
|
|
parse->framed = FALSE;
|
|
|
|
GST_ERROR ("Only SSA subtitles embedded in containers are supported");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
parse->framed = TRUE;
|
2009-06-11 21:32:28 +00:00
|
|
|
parse->send_tags = TRUE;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
2011-02-23 14:46:56 +00:00
|
|
|
priv = (GstBuffer *) g_value_get_boxed (val);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
g_return_val_if_fail (priv != NULL, FALSE);
|
|
|
|
|
|
|
|
gst_buffer_ref (priv);
|
|
|
|
|
2017-07-24 07:53:17 +00:00
|
|
|
if (!gst_buffer_map (priv, &map, GST_MAP_READ)) {
|
|
|
|
gst_buffer_unref (priv);
|
2012-12-17 00:59:57 +00:00
|
|
|
return FALSE;
|
2017-07-24 07:53:17 +00:00
|
|
|
}
|
2012-12-17 00:59:57 +00:00
|
|
|
|
|
|
|
GST_MEMDUMP_OBJECT (parse, "init section", map.data, map.size);
|
2011-03-27 14:35:28 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
ptr = (gchar *) map.data;
|
|
|
|
left = map.size;
|
2011-03-27 14:35:28 +00:00
|
|
|
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
/* skip UTF-8 BOM */
|
2011-03-27 14:35:28 +00:00
|
|
|
if (left >= 3 && memcmp (ptr, bom_utf8, 3) == 0) {
|
|
|
|
ptr += 3;
|
|
|
|
left -= 3;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
if (!strstr (ptr, "[Script Info]"))
|
|
|
|
goto invalid_init;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
2012-12-17 00:59:57 +00:00
|
|
|
if (!g_utf8_validate (ptr, left, &end)) {
|
|
|
|
bad_offset = (gsize) (end - ptr);
|
|
|
|
GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8. Problem at "
|
|
|
|
"byte offset %" G_GSIZE_FORMAT, bad_offset);
|
|
|
|
/* continue with valid UTF-8 data */
|
|
|
|
left = bad_offset;
|
|
|
|
}
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
|
|
|
/* FIXME: parse initial section */
|
2016-12-01 17:57:47 +00:00
|
|
|
if (parse->ini)
|
|
|
|
g_free (parse->ini);
|
2011-03-27 14:35:28 +00:00
|
|
|
parse->ini = g_strndup (ptr, left);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
GST_LOG_OBJECT (parse, "Init section:\n%s", parse->ini);
|
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (priv, &map);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
gst_buffer_unref (priv);
|
|
|
|
|
2012-09-02 01:41:34 +00:00
|
|
|
outcaps = gst_caps_new_simple ("text/x-raw",
|
|
|
|
"format", G_TYPE_STRING, "pango-markup", NULL);
|
|
|
|
|
2012-02-17 13:37:36 +00:00
|
|
|
ret = gst_pad_set_caps (parse->srcpad, outcaps);
|
|
|
|
gst_caps_unref (outcaps);
|
|
|
|
|
|
|
|
return ret;
|
2012-01-20 15:11:54 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
invalid_init:
|
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (parse, "Invalid Init section - no Script Info header");
|
|
|
|
gst_buffer_unmap (priv, &map);
|
|
|
|
gst_buffer_unref (priv);
|
|
|
|
return FALSE;
|
|
|
|
}
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_ssa_parse_remove_override_codes (GstSsaParse * parse, gchar * txt)
|
|
|
|
{
|
|
|
|
gchar *t, *end;
|
|
|
|
gboolean removed_any = FALSE;
|
|
|
|
|
|
|
|
while ((t = strchr (txt, '{'))) {
|
|
|
|
end = strchr (txt, '}');
|
|
|
|
if (end == NULL) {
|
|
|
|
GST_WARNING_OBJECT (parse, "Missing { for style override code");
|
|
|
|
return removed_any;
|
|
|
|
}
|
|
|
|
/* move terminating NUL character forward as well */
|
2013-11-21 15:19:47 +00:00
|
|
|
memmove (t, end + 1, strlen (end + 1) + 1);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
removed_any = TRUE;
|
|
|
|
}
|
|
|
|
|
2007-08-29 12:16:46 +00:00
|
|
|
/* these may occur outside of curly brackets. We don't handle the different
|
|
|
|
* wrapping modes yet, so just remove these markers from the text for now */
|
|
|
|
while ((t = strstr (txt, "\\n"))) {
|
|
|
|
t[0] = ' ';
|
|
|
|
t[1] = '\n';
|
|
|
|
}
|
|
|
|
while ((t = strstr (txt, "\\N"))) {
|
|
|
|
t[0] = ' ';
|
|
|
|
t[1] = '\n';
|
|
|
|
}
|
|
|
|
while ((t = strstr (txt, "\\h"))) {
|
|
|
|
t[0] = ' ';
|
|
|
|
t[1] = ' ';
|
|
|
|
}
|
|
|
|
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
return removed_any;
|
|
|
|
}
|
|
|
|
|
2007-12-29 19:23:59 +00:00
|
|
|
/**
|
|
|
|
* gst_ssa_parse_push_line:
|
|
|
|
* @parse: caller element
|
|
|
|
* @txt: text to push
|
|
|
|
* @start: timestamp for the buffer
|
|
|
|
* @duration: duration for the buffer
|
|
|
|
*
|
|
|
|
* Parse the text in a buffer with the given properties and
|
|
|
|
* push it to the srcpad of the @parse element
|
|
|
|
*
|
|
|
|
* Returns: result of the push of the created buffer
|
|
|
|
*/
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
static GstFlowReturn
|
2007-12-29 19:23:59 +00:00
|
|
|
gst_ssa_parse_push_line (GstSsaParse * parse, gchar * txt,
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
GstClockTime start, GstClockTime duration)
|
|
|
|
{
|
|
|
|
GstFlowReturn ret;
|
|
|
|
GstBuffer *buf;
|
|
|
|
gchar *t, *escaped;
|
|
|
|
gint num, i, len;
|
|
|
|
|
|
|
|
num = atoi (txt);
|
|
|
|
GST_LOG_OBJECT (parse, "Parsing line #%d at %" GST_TIME_FORMAT,
|
|
|
|
num, GST_TIME_ARGS (start));
|
|
|
|
|
|
|
|
/* skip all non-text fields before the actual text */
|
|
|
|
t = txt;
|
|
|
|
for (i = 0; i < 8; ++i) {
|
|
|
|
t = strchr (t, ',');
|
|
|
|
if (t == NULL)
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
++t;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (parse, "Text : %s", t);
|
|
|
|
|
|
|
|
if (gst_ssa_parse_remove_override_codes (parse, t)) {
|
|
|
|
GST_LOG_OBJECT (parse, "Clean: %s", t);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we claim to output pango markup, so we must escape the
|
|
|
|
* text even if we don't actually use any pango markup yet */
|
|
|
|
escaped = g_markup_printf_escaped ("%s", t);
|
|
|
|
|
|
|
|
len = strlen (escaped);
|
2006-07-11 12:03:25 +00:00
|
|
|
|
|
|
|
/* allocate enough for a terminating NUL, but don't include it in buf size */
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
buf = gst_buffer_new_and_alloc (len + 1);
|
2011-03-27 14:35:28 +00:00
|
|
|
gst_buffer_fill (buf, 0, escaped, len + 1);
|
|
|
|
gst_buffer_set_size (buf, len);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
g_free (escaped);
|
|
|
|
|
|
|
|
GST_BUFFER_TIMESTAMP (buf) = start;
|
|
|
|
GST_BUFFER_DURATION (buf) = duration;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (parse, "Pushing buffer with timestamp %" GST_TIME_FORMAT
|
|
|
|
" and duration %" GST_TIME_FORMAT, GST_TIME_ARGS (start),
|
|
|
|
GST_TIME_ARGS (duration));
|
|
|
|
|
|
|
|
ret = gst_pad_push (parse->srcpad, buf);
|
|
|
|
|
|
|
|
if (ret != GST_FLOW_OK) {
|
2007-12-29 19:23:59 +00:00
|
|
|
GST_DEBUG_OBJECT (parse, "Push of text '%s' returned flow %s", txt,
|
|
|
|
gst_flow_get_name (ret));
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
2011-11-17 11:48:25 +00:00
|
|
|
gst_ssa_parse_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * buf)
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
{
|
|
|
|
GstFlowReturn ret;
|
2011-11-17 11:48:25 +00:00
|
|
|
GstSsaParse *parse = GST_SSA_PARSE (parent);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
GstClockTime ts;
|
|
|
|
gchar *txt;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
2007-08-29 12:16:46 +00:00
|
|
|
if (G_UNLIKELY (!parse->framed))
|
|
|
|
goto not_framed;
|
|
|
|
|
2009-06-11 21:32:28 +00:00
|
|
|
if (G_UNLIKELY (parse->send_tags)) {
|
|
|
|
GstTagList *tags;
|
|
|
|
|
2011-10-30 11:09:10 +00:00
|
|
|
tags = gst_tag_list_new_empty ();
|
2009-06-11 21:32:28 +00:00
|
|
|
gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_SUBTITLE_CODEC,
|
|
|
|
"SubStation Alpha", NULL);
|
2012-07-27 21:59:31 +00:00
|
|
|
gst_pad_push_event (parse->srcpad, gst_event_new_tag (tags));
|
2009-06-11 21:32:28 +00:00
|
|
|
parse->send_tags = FALSE;
|
|
|
|
}
|
|
|
|
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
/* make double-sure it's 0-terminated and all */
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
|
|
|
txt = g_strndup ((gchar *) map.data, map.size);
|
|
|
|
gst_buffer_unmap (buf, &map);
|
2011-03-27 14:35:28 +00:00
|
|
|
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
if (txt == NULL)
|
2009-06-23 10:40:56 +00:00
|
|
|
goto empty_text;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
|
|
|
ts = GST_BUFFER_TIMESTAMP (buf);
|
2007-12-29 19:23:59 +00:00
|
|
|
ret = gst_ssa_parse_push_line (parse, txt, ts, GST_BUFFER_DURATION (buf));
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
|
2007-12-29 20:55:39 +00:00
|
|
|
if (ret != GST_FLOW_OK && GST_CLOCK_TIME_IS_VALID (ts)) {
|
2011-05-16 11:48:11 +00:00
|
|
|
GstSegment segment;
|
|
|
|
|
2007-12-29 20:55:39 +00:00
|
|
|
/* just advance time without sending anything */
|
2011-05-16 11:48:11 +00:00
|
|
|
gst_segment_init (&segment, GST_FORMAT_TIME);
|
|
|
|
segment.start = ts;
|
|
|
|
segment.time = ts;
|
|
|
|
gst_pad_push_event (parse->srcpad, gst_event_new_segment (&segment));
|
2007-12-29 20:55:39 +00:00
|
|
|
ret = GST_FLOW_OK;
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
2009-06-23 10:40:56 +00:00
|
|
|
gst_buffer_unref (buf);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
g_free (txt);
|
|
|
|
|
|
|
|
return ret;
|
2007-08-29 12:16:46 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
not_framed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (parse, STREAM, FORMAT, (NULL),
|
|
|
|
("Only SSA subtitles embedded in containers are supported"));
|
2009-06-23 10:40:56 +00:00
|
|
|
gst_buffer_unref (buf);
|
2007-08-29 12:16:46 +00:00
|
|
|
return GST_FLOW_NOT_NEGOTIATED;
|
|
|
|
}
|
2009-06-23 10:40:56 +00:00
|
|
|
empty_text:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_WARNING (parse, STREAM, FORMAT, (NULL),
|
|
|
|
("Received empty subtitle"));
|
|
|
|
gst_buffer_unref (buf);
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
}
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_ssa_parse_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
|
|
|
|
GstSsaParse *parse = GST_SSA_PARSE (element);
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-04-19 09:35:53 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
gst/subparse/: Add very basic parser for SSA subtitle streams (as often found in matroska files).
Original commit message from CVS:
* gst/subparse/Makefile.am:
* gst/subparse/gstssaparse.c: (gst_ssa_parse_base_init),
(gst_ssa_parse_dispose), (gst_ssa_parse_init),
(gst_ssa_parse_class_init), (gst_ssa_parse_src_event),
(gst_ssa_parse_sink_event), (gst_ssa_parse_setcaps),
(gst_ssa_parse_remove_override_codes), (gst_ssa_parse_parse_line),
(gst_ssa_parse_chain), (gst_ssa_parse_change_state):
* gst/subparse/gstssaparse.h:
* gst/subparse/gstsubparse.c: (plugin_init):
Add very basic parser for SSA subtitle streams (as often
found in matroska files).
2006-02-19 14:16:16 +00:00
|
|
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
g_free (parse->ini);
|
|
|
|
parse->ini = NULL;
|
|
|
|
parse->framed = FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|