mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 07:47:17 +00:00
gst/subparse/samiparse.c: Only output characters inside the "sync" elements. There could be other elements like "styl...
Original commit message from CVS: Patch by: Young-Ho Cha <ganadist at chollian dot net> * gst/subparse/samiparse.c: (handle_start_sync), (start_sami_element), (end_sami_element), (characters_sami), (sami_context_reset): Only output characters inside the "sync" elements. There could be other elements like "style" that have some content but should not be printed. Fixes bug #467911.
This commit is contained in:
parent
1275eda108
commit
76e3ffb61c
2 changed files with 28 additions and 10 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2008-05-05 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
Patch by: Young-Ho Cha <ganadist at chollian dot net>
|
||||
|
||||
* gst/subparse/samiparse.c: (handle_start_sync),
|
||||
(start_sami_element), (end_sami_element), (characters_sami),
|
||||
(sami_context_reset):
|
||||
Only output characters inside the "sync" elements. There could be
|
||||
other elements like "style" that have some content but should
|
||||
not be printed. Fixes bug #467911.
|
||||
|
||||
2008-05-05 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* gst/playback/gstplaybasebin.c: (set_audio_mute),
|
||||
|
|
|
@ -47,8 +47,8 @@ struct _GstSamiContext
|
|||
* and _context_pop_state(). */
|
||||
htmlParserCtxtPtr htmlctxt; /* html parser context */
|
||||
gboolean has_result; /* set when ready to push out result */
|
||||
gboolean in_title; /* flag to avoid appending the title content
|
||||
* to buf */
|
||||
gboolean in_sync; /* flag to avoid appending anything except the
|
||||
* content of the sync elements to buf */
|
||||
guint64 time1; /* previous start attribute in sync tag */
|
||||
guint64 time2; /* current start attribute in sync tag */
|
||||
};
|
||||
|
@ -131,6 +131,14 @@ handle_start_sync (GstSamiContext * sctx, const xmlChar ** atts)
|
|||
if (!value)
|
||||
continue;
|
||||
if (!xmlStrncmp ((const xmlChar *) "start", key, 5)) {
|
||||
/* FIXME: this is not correct. According to[0] the start parameter
|
||||
* specifies the time when the text should be shown and not the time
|
||||
* when the text should be hidden again.
|
||||
* This essentially means that we have to look at the next sync element
|
||||
* before pushing one buffer and push the last buffer with -1
|
||||
* as duration after the body element is closed.
|
||||
* [0] http://msdn.microsoft.com/en-us/library/ms971327.aspx
|
||||
*/
|
||||
sctx->time1 = sctx->time2;
|
||||
sctx->time2 = atoi ((const char *) value) * GST_MSECOND;
|
||||
sctx->has_result = TRUE;
|
||||
|
@ -210,10 +218,9 @@ start_sami_element (void *ctx, const xmlChar * name, const xmlChar ** atts)
|
|||
{
|
||||
GstSamiContext *sctx = (GstSamiContext *) ctx;
|
||||
|
||||
if (!xmlStrncmp ((const xmlChar *) "title", name, 5)) {
|
||||
sctx->in_title = TRUE;
|
||||
} else if (!xmlStrncmp ((const xmlChar *) "sync", name, 4)) {
|
||||
if (!xmlStrncmp ((const xmlChar *) "sync", name, 4)) {
|
||||
handle_start_sync (sctx, atts);
|
||||
sctx->in_sync = TRUE;
|
||||
} else if (!xmlStrncmp ((const xmlChar *) "font", name, 4)) {
|
||||
handle_start_font (sctx, atts);
|
||||
} else if (!xmlStrncmp ((const xmlChar *) "ruby", name, 4)) {
|
||||
|
@ -239,8 +246,8 @@ end_sami_element (void *ctx, const xmlChar * name)
|
|||
{
|
||||
GstSamiContext *sctx = (GstSamiContext *) ctx;
|
||||
|
||||
if (!xmlStrncmp ((const xmlChar *) "title", name, 5)) {
|
||||
sctx->in_title = FALSE;
|
||||
if (!xmlStrncmp ((const xmlChar *) "sync", name, 4)) {
|
||||
sctx->in_sync = FALSE;
|
||||
} else if (!xmlStrncmp ((const xmlChar *) "font", name, 4)) {
|
||||
sami_context_pop_state (sctx, SPAN_TAG);
|
||||
} else if (!xmlStrncmp ((const xmlChar *) "ruby", name, 4)) {
|
||||
|
@ -256,8 +263,8 @@ characters_sami (void *ctx, const xmlChar * ch, int len)
|
|||
GstSamiContext *sctx = (GstSamiContext *) ctx;
|
||||
gchar *escaped;
|
||||
|
||||
/* skip title */
|
||||
if (sctx->in_title)
|
||||
/* Skip everything except content of the sync elements */
|
||||
if (!sctx->in_sync)
|
||||
return;
|
||||
|
||||
escaped = g_markup_escape_text ((const gchar *) ch, len);
|
||||
|
@ -361,7 +368,7 @@ sami_context_reset (ParserState * state)
|
|||
g_string_truncate (context->resultbuf, 0);
|
||||
g_string_truncate (context->state, 0);
|
||||
context->has_result = FALSE;
|
||||
context->in_title = FALSE;
|
||||
context->in_sync = FALSE;
|
||||
context->time1 = 0;
|
||||
context->time2 = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue