mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
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
This commit is contained in:
parent
9f0a06245b
commit
aec8406fd7
1 changed files with 19 additions and 2 deletions
|
@ -1258,19 +1258,27 @@ gst_ttml_render_unified_element_free (UnifiedElement * unified_element)
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GPtrArray *unified_elements;
|
GPtrArray *unified_elements;
|
||||||
|
GstSubtitleStyleSet *style_set;
|
||||||
|
gchar *joined_text;
|
||||||
} UnifiedBlock;
|
} UnifiedBlock;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_ttml_render_unified_block_free (UnifiedBlock * unified_block)
|
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_ptr_array_unref (unified_block->unified_elements);
|
||||||
|
g_free (unified_block->joined_text);
|
||||||
g_slice_free (UnifiedBlock, unified_block);
|
g_slice_free (UnifiedBlock, unified_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static UnifiedElement *
|
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)
|
if (index >= block->unified_elements->len)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1318,18 +1326,27 @@ gst_ttml_render_handle_whitespace (UnifiedBlock * block)
|
||||||
static UnifiedBlock *
|
static UnifiedBlock *
|
||||||
gst_ttml_render_unify_block (const GstSubtitleBlock * block, GstBuffer * buf)
|
gst_ttml_render_unify_block (const GstSubtitleBlock * block, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
guint i;
|
|
||||||
UnifiedBlock *ret = g_slice_new0 (UnifiedBlock);
|
UnifiedBlock *ret = g_slice_new0 (UnifiedBlock);
|
||||||
|
guint i;
|
||||||
|
|
||||||
ret->unified_elements = g_ptr_array_new_with_free_func ((GDestroyNotify)
|
ret->unified_elements = g_ptr_array_new_with_free_func ((GDestroyNotify)
|
||||||
gst_ttml_render_unified_element_free);
|
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) {
|
for (i = 0; i < gst_subtitle_block_get_element_count (block); ++i) {
|
||||||
|
gchar *text;
|
||||||
UnifiedElement *ue = g_slice_new0 (UnifiedElement);
|
UnifiedElement *ue = g_slice_new0 (UnifiedElement);
|
||||||
|
|
||||||
ue->element = gst_subtitle_block_get_element (block, i);
|
ue->element = gst_subtitle_block_get_element (block, i);
|
||||||
ue->text =
|
ue->text =
|
||||||
gst_ttml_render_get_text_from_buffer (buf, ue->element->text_index);
|
gst_ttml_render_get_text_from_buffer (buf, ue->element->text_index);
|
||||||
g_ptr_array_add (ret->unified_elements, ue);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue