mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
ttmlparse: Replace repeated warning code with a function.
Encapsulates in a function the code that warns of an illegally positioned element, rather than repeating the same code multiple times. Also frees a string allocated by ttml_get_element_type_string, which was previously being leaked. https://bugzilla.gnome.org/show_bug.cgi?id=781725
This commit is contained in:
parent
8b19cccfc5
commit
81157e5168
1 changed files with 14 additions and 12 deletions
|
@ -1538,6 +1538,16 @@ ttml_blend_colors (GstSubtitleColor color1, GstSubtitleColor color2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
ttml_warn_of_mispositioned_element (TtmlElement * element)
|
||||||
|
{
|
||||||
|
gchar *type = ttml_get_element_type_string (element);
|
||||||
|
GST_CAT_WARNING (ttmlparse_debug, "Ignoring illegally positioned %s element.",
|
||||||
|
type);
|
||||||
|
g_free (type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Create the subtitle region and its child blocks and elements for @tree,
|
/* Create the subtitle region and its child blocks and elements for @tree,
|
||||||
* inserting element text in @buf. Ownership of created region is transferred
|
* inserting element text in @buf. Ownership of created region is transferred
|
||||||
* to caller. */
|
* to caller. */
|
||||||
|
@ -1572,9 +1582,7 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
|
|
||||||
element = node->data;
|
element = node->data;
|
||||||
if (element->type != TTML_ELEMENT_TYPE_DIV) {
|
if (element->type != TTML_ELEMENT_TYPE_DIV) {
|
||||||
GST_CAT_WARNING (ttmlparse_debug,
|
ttml_warn_of_mispositioned_element (element);
|
||||||
"Ignoring %s child of body element: only a div is allowed here.",
|
|
||||||
ttml_get_element_type_string (element));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
div_color =
|
div_color =
|
||||||
|
@ -1590,9 +1598,7 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
|
|
||||||
element = p_node->data;
|
element = p_node->data;
|
||||||
if (element->type != TTML_ELEMENT_TYPE_P) {
|
if (element->type != TTML_ELEMENT_TYPE_P) {
|
||||||
GST_CAT_WARNING (ttmlparse_debug,
|
ttml_warn_of_mispositioned_element (element);
|
||||||
"Ignoring %s child of div element: only a p is allowed here.",
|
|
||||||
ttml_get_element_type_string (element));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p_color =
|
p_color =
|
||||||
|
@ -1624,15 +1630,11 @@ ttml_create_subtitle_region (GNode * tree, GstBuffer * buf, guint cellres_x,
|
||||||
|| element->type == TTML_ELEMENT_TYPE_ANON_SPAN) {
|
|| element->type == TTML_ELEMENT_TYPE_ANON_SPAN) {
|
||||||
ttml_add_element (block, element, buf, cellres_x, cellres_y);
|
ttml_add_element (block, element, buf, cellres_x, cellres_y);
|
||||||
} else {
|
} else {
|
||||||
GST_CAT_WARNING (ttmlparse_debug,
|
ttml_warn_of_mispositioned_element (element);
|
||||||
"Ignoring illegally positioned %s element.",
|
|
||||||
ttml_get_element_type_string (element));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GST_CAT_WARNING (ttmlparse_debug,
|
ttml_warn_of_mispositioned_element (element);
|
||||||
"Ignoring illegally positioned %s element.",
|
|
||||||
ttml_get_element_type_string (element));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue