summaryrefslogtreecommitdiff
path: root/ext/ttml
diff options
context:
space:
mode:
authorChris Bass <floobleflam@gmail.com>2017-03-21 14:11:42 +0000
committerSebastian Dröge <sebastian@centricular.com>2017-04-09 10:42:08 +0300
commitaec8406fd778ec109b9726b550028fe0b90a35e6 (patch)
tree9962ca3db2b3aad5711a8fb1acac3700ee376b2d /ext/ttml
parent9f0a06245b36c25bc127efe035ab4d8426ddd6fd (diff)
downloadgstreamer-plugins-bad-aec8406fd778ec109b9726b550028fe0b90a35e6.tar.gz
ttmlrender: extend UnifiedBlock type
Include a reference to the GstSubtitleStyleSet of the represented block and a string containing the concatenated text from all elements. https://bugzilla.gnome.org/show_bug.cgi?id=780402
Diffstat (limited to 'ext/ttml')
-rw-r--r--ext/ttml/gstttmlrender.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/ext/ttml/gstttmlrender.c b/ext/ttml/gstttmlrender.c
index 26b130c68..d8e5f4798 100644
--- a/ext/ttml/gstttmlrender.c
+++ b/ext/ttml/gstttmlrender.c
@@ -1258,19 +1258,27 @@ gst_ttml_render_unified_element_free (UnifiedElement * unified_element)
typedef struct
{
GPtrArray *unified_elements;
+ GstSubtitleStyleSet *style_set;
+ gchar *joined_text;
} UnifiedBlock;
static void
gst_ttml_render_unified_block_free (UnifiedBlock * unified_block)
{
+ if (!unified_block)
+ return;
+
+ gst_subtitle_style_set_unref (unified_block->style_set);
g_ptr_array_unref (unified_block->unified_elements);
+ g_free (unified_block->joined_text);
g_slice_free (UnifiedBlock, unified_block);
}
static UnifiedElement *
-gst_ttml_render_unified_block_get_element (UnifiedBlock * block, guint index)
+gst_ttml_render_unified_block_get_element (const UnifiedBlock * block,
+ guint index)
{
if (index >= block->unified_elements->len)
return NULL;
@@ -1318,18 +1326,27 @@ gst_ttml_render_handle_whitespace (UnifiedBlock * block)
static UnifiedBlock *
gst_ttml_render_unify_block (const GstSubtitleBlock * block, GstBuffer * buf)
{
- guint i;
UnifiedBlock *ret = g_slice_new0 (UnifiedBlock);
+ guint i;
+
ret->unified_elements = g_ptr_array_new_with_free_func ((GDestroyNotify)
gst_ttml_render_unified_element_free);
+ ret->style_set = gst_subtitle_style_set_ref (block->style_set);
+ ret->joined_text = g_strdup ("");
for (i = 0; i < gst_subtitle_block_get_element_count (block); ++i) {
+ gchar *text;
UnifiedElement *ue = g_slice_new0 (UnifiedElement);
+
ue->element = gst_subtitle_block_get_element (block, i);
ue->text =
gst_ttml_render_get_text_from_buffer (buf, ue->element->text_index);
g_ptr_array_add (ret->unified_elements, ue);
+ text = g_strjoin (NULL, ret->joined_text, ue->text, NULL);
+ g_free (ret->joined_text);
+ ret->joined_text = text;
}
+
return ret;
}