gst_ttml_render_rendered_image_free (blocks_image);
}
- GST_CAT_DEBUG (ttmlrender_debug, "Height of rendered region: %u",
- region_image->height);
-
- ret = gst_ttml_render_compose_overlay (region_image);
- gst_ttml_render_rendered_image_free (region_image);
+ if (region_image) {
+ GST_CAT_DEBUG (ttmlrender_debug, "Height of rendered region: %u",
+ region_image->height);
+ ret = gst_ttml_render_compose_overlay (region_image);
+ gst_ttml_render_rendered_image_free (region_image);
+ }
return ret;
}
}
subtitle_meta = gst_buffer_get_subtitle_meta (render->text_buffer);
- g_assert (subtitle_meta != NULL);
-
- for (i = 0; i < subtitle_meta->regions->len; ++i) {
- GstVideoOverlayComposition *composition;
- region = g_ptr_array_index (subtitle_meta->regions, i);
- g_assert (region != NULL);
- composition = gst_ttml_render_render_text_region (render, region,
- render->text_buffer);
- if (composition) {
- render->compositions = g_list_append (render->compositions,
- composition);
+ if (!subtitle_meta) {
+ GST_CAT_WARNING (ttmlrender_debug, "Failed to get subtitle meta.");
+ } else {
+ for (i = 0; i < subtitle_meta->regions->len; ++i) {
+ GstVideoOverlayComposition *composition;
+ region = g_ptr_array_index (subtitle_meta->regions, i);
+ composition = gst_ttml_render_render_text_region (render, region,
+ render->text_buffer);
+ if (composition) {
+ render->compositions = g_list_append (render->compositions,
+ composition);
+ }
}
}
render->need_render = FALSE;
TtmlElement *element;
GNode *node;
- element = tree->data;
- g_assert (element->type == TTML_ELEMENT_TYPE_REGION);
-
+ element = tree->data; /* Region element */
region_style = gst_subtitle_style_set_new ();
ttml_update_style_set (region_style, element->style_set, cellres_x,
cellres_y);
if (!node)
return region;
- g_assert (node->next == NULL);
- element = node->data;
- g_assert (element->type == TTML_ELEMENT_TYPE_BODY);
+ element = node->data; /* Body element */
block_color =
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
"backgroundColor"));
GstSubtitleColor div_color;
element = node->data;
- g_assert (element->type == TTML_ELEMENT_TYPE_DIV);
+ if (element->type != TTML_ELEMENT_TYPE_DIV) {
+ GST_CAT_WARNING (ttmlparse_debug,
+ "Ignoring %s child of body element: only a div is allowed here.",
+ ttml_get_element_type_string (element));
+ continue;
+ }
div_color =
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
"backgroundColor"));
GstSubtitleColor p_color;
element = p_node->data;
- g_assert (element->type == TTML_ELEMENT_TYPE_P);
+ if (element->type != TTML_ELEMENT_TYPE_P) {
+ GST_CAT_WARNING (ttmlparse_debug,
+ "Ignoring %s child of div element: only a p is allowed here.",
+ ttml_get_element_type_string (element));
+ continue;
+ }
p_color =
ttml_parse_colorstring (ttml_style_set_get_attr (element->style_set,
"backgroundColor"));
cellres_y);
block_style->background_color = block_color;
block = gst_subtitle_block_new (block_style);
- g_assert (block != NULL);
for (content_node = p_node->children; content_node;
content_node = content_node->next) {
|| element->type == TTML_ELEMENT_TYPE_ANON_SPAN) {
ttml_add_element (block, element, buf, cellres_x, cellres_y);
} else {
- GST_CAT_ERROR (ttmlparse_debug,
- "Element type not allowed at this level of document.");
+ GST_CAT_WARNING (ttmlparse_debug,
+ "Ignoring illegally positioned %s element.",
+ ttml_get_element_type_string (element));
}
}
} else {
- GST_CAT_ERROR (ttmlparse_debug,
- "Element type not allowed at this level of document.");
+ GST_CAT_WARNING (ttmlparse_debug,
+ "Ignoring illegally positioned %s element.",
+ ttml_get_element_type_string (element));
}
}
gst_subtitle_region_add_block (region, block);
GST_CAT_DEBUG (ttmlparse_debug,
- "Added block to region; there are now %u blocks" " in the region.",
+ "Added block to region; there are now %u blocks in the region.",
gst_subtitle_region_get_block_count (region));
}
}
region = ttml_create_subtitle_region (tree, scene->buf, cellres_x,
cellres_y);
- g_ptr_array_add (regions, region);
+ if (region)
+ g_ptr_array_add (regions, region);
}
gst_buffer_add_subtitle_meta (scene->buf, regions);