context->codec_priv, context->codec_priv_size);
}
+#if 0
static void
gst_matroska_mux_write_chapter_title (const gchar * title, GstEbmlWrite * ebml)
{
}
uid = gst_matroska_mux_create_uid ();
- gst_toc_entry_get_start_stop (entry, &start, &stop);
+ gst_toc_entry_get_start_stop_times (entry, &start, &stop);
master_chapteratom =
gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_CHAPTERATOM);
GList *cur;
GstTocEntry *subentry;
- cur = entry->subentries;
+ cur = gst_toc_entry_get_sub_entries (entry);
while (cur != NULL) {
subentry = cur->data;
gst_matroska_mux_write_chapter (mux, entry, subentry, ebml, master_chapters,
if (G_LIKELY (master_edition != 0))
gst_ebml_write_master_finish (ebml, master_edition);
}
+#endif
/**
* gst_matroska_mux_start:
GstClockTime duration = 0;
guint32 segment_uid[4];
GTimeVal time = { 0, 0 };
+#if 0
GstToc *toc;
+#endif
/* if not streaming, check if downstream is seekable */
if (!mux->streamable) {
}
gst_ebml_write_master_finish (ebml, master);
+ /* FIXME: Check if we get a TOC that is supported by Matroska
+ * and clean up the code below */
+#if 0
/* chapters */
toc = gst_toc_setter_get_toc (GST_TOC_SETTER (mux));
if (toc != NULL && !mux->streamable) {
if (toc_entry->type != GST_TOC_ENTRY_TYPE_EDITION) {
toc_entry = gst_toc_entry_new (GST_TOC_ENTRY_TYPE_EDITION, "");
- gst_toc_entry_set_start_stop (toc_entry, -1, -1);
+ gst_toc_entry_set_start_stop_times (toc_entry, -1, -1);
/* aggregate all chapters without root edition */
- cur = toc->entries;
+ cur = gst_toc_get_entries (toc);
while (cur != NULL) {
toc_entry->subentries =
g_list_prepend (toc_entry->subentries, cur->data);
cur = cur->next;
}
- gst_toc_entry_get_start_stop (((GstTocEntry *) toc_entry->subentries->
- data), &start, NULL);
+ gst_toc_entry_get_start_stop_times (((GstTocEntry *)
+ toc_entry->subentries->data), &start, NULL);
toc_entry->subentries = g_list_reverse (toc_entry->subentries);
- gst_toc_entry_get_start_stop (((GstTocEntry *) toc_entry->subentries->
- data), NULL, &stop);
- gst_toc_entry_set_start_stop (toc_entry, start, stop);
+ gst_toc_entry_get_start_stop_times (((GstTocEntry *)
+ toc_entry->subentries->data), NULL, &stop);
+ gst_toc_entry_set_start_stop_times (toc_entry, start, stop);
to_write = g_list_append (to_write, toc_entry);
} else {
g_list_free (to_write);
}
}
+#endif
/* lastly, flush the cache */
gst_ebml_write_flush_cache (ebml, FALSE, 0);
+#if 0
if (toc != NULL)
gst_toc_unref (toc);
+#endif
}
static void
}
}
+#if 0
static void
gst_matroska_mux_write_toc_entry_tags (GstMatroskaMux * mux,
const GstTocEntry * entry, guint64 * master_tags)
cur = cur->next;
}
}
+#endif
/**
* gst_matroska_mux_finish:
if ((tags != NULL && !gst_tag_list_is_empty (tags))
|| gst_toc_setter_get_toc (GST_TOC_SETTER (mux)) != NULL) {
guint64 master_tags = 0, master_tag;
- GList *cur;
+#if 0
const GstToc *toc;
+#endif
GST_DEBUG_OBJECT (mux, "Writing tags");
+#if 0
toc = gst_toc_setter_get_toc (GST_TOC_SETTER (mux));
+#endif
if (tags != NULL) {
/* TODO: maybe limit via the TARGETS id by looking at the source pad */
if (tags != NULL)
gst_tag_list_foreach (tags, gst_matroska_mux_write_simple_tag, ebml);
+#if 0
if (toc != NULL)
gst_tag_list_foreach (toc->tags, gst_matroska_mux_write_simple_tag,
ebml);
+#endif
gst_ebml_write_master_finish (ebml, master_tag);
}
-
+#if 0
if (toc != NULL) {
cur = toc->entries;
while (cur != NULL) {
cur = cur->next;
}
}
+#endif
if (master_tags != 0)
gst_ebml_write_master_finish (ebml, master_tags);
guint64 tgt;
GArray *targets;
GList *cur;
+ GstTagList *etags;
targets =
- (entry->type ==
+ (gst_toc_entry_get_entry_type (entry) ==
GST_TOC_ENTRY_TYPE_EDITION) ? edition_targets : chapter_targtes;
+ etags = gst_tag_list_new_empty ();
+
for (i = 0; i < targets->len; ++i) {
tgt = g_array_index (targets, guint64, i);
if (tgt == 0)
- gst_tag_list_insert (entry->tags, tags, GST_TAG_MERGE_APPEND);
+ gst_tag_list_insert (etags, tags, GST_TAG_MERGE_APPEND);
else {
uid = g_strdup_printf ("%" G_GUINT64_FORMAT, tgt);
- if (g_strcmp0 (entry->uid, uid) == 0)
- gst_tag_list_insert (entry->tags, tags, GST_TAG_MERGE_APPEND);
+ if (g_strcmp0 (gst_toc_entry_get_uid (entry), uid) == 0)
+ gst_tag_list_insert (etags, tags, GST_TAG_MERGE_APPEND);
g_free (uid);
}
}
- cur = entry->subentries;
+ gst_toc_entry_merge_tags (entry, etags, GST_TAG_MERGE_APPEND);
+
+ cur = gst_toc_entry_get_sub_entries (entry);
while (cur != NULL) {
gst_matroska_read_common_parse_toc_tag (cur->data, edition_targets,
chapter_targtes, tags);
{
GstTocEntry *cur_info, *prev_info, *next_info;
GList *cur_list, *prev_list, *next_list;
- gchar *iter_digit;
- gint i = 0;
gint64 cur_start, prev_start, stop;
cur_list = toc_entries;
while (cur_list != NULL) {
- ++i;
cur_info = cur_list->data;
- iter_digit = g_strdup_printf ("%d", i);
-
- switch (cur_info->type) {
+ switch (gst_toc_entry_get_entry_type (cur_info)) {
case GST_TOC_ENTRY_TYPE_ANGLE:
case GST_TOC_ENTRY_TYPE_VERSION:
case GST_TOC_ENTRY_TYPE_EDITION:
/* in Matroska terms edition has duration of full track */
- gst_toc_entry_set_start_stop (cur_info, 0, max);
+ gst_toc_entry_set_start_stop_times (cur_info, 0, max);
- if (cur_info->uid == NULL)
- cur_info->uid =
- g_strconcat (parent_uid, "/", GST_MATROSKA_TOC_UID_EDITION,
- iter_digit, NULL);
-
- gst_matroska_read_common_postprocess_toc_entries (cur_info->subentries,
- max, cur_info->uid);
+ gst_matroska_read_common_postprocess_toc_entries
+ (gst_toc_entry_get_sub_entries (cur_info), max,
+ gst_toc_entry_get_uid (cur_info));
break;
case GST_TOC_ENTRY_TYPE_TITLE:
else
next_info = NULL;
- if (cur_info->uid == NULL)
- cur_info->uid =
- g_strconcat (parent_uid, "/", GST_MATROSKA_TOC_UID_CHAPTER,
- iter_digit, NULL);
-
/* updated stop time in previous chapter and it's subchapters */
if (prev_info != NULL) {
- gst_toc_entry_get_start_stop (prev_info, &prev_start, &stop);
- gst_toc_entry_get_start_stop (cur_info, &cur_start, &stop);
+ gst_toc_entry_get_start_stop_times (prev_info, &prev_start, &stop);
+ gst_toc_entry_get_start_stop_times (cur_info, &cur_start, &stop);
stop = cur_start;
- gst_toc_entry_set_start_stop (prev_info, prev_start, stop);
+ gst_toc_entry_set_start_stop_times (prev_info, prev_start, stop);
gst_matroska_read_common_postprocess_toc_entries
- (prev_info->subentries, cur_start, prev_info->uid);
+ (gst_toc_entry_get_sub_entries (prev_info), cur_start,
+ gst_toc_entry_get_uid (prev_info));
}
/* updated stop time in current chapter and it's subchapters */
if (next_info == NULL) {
- gst_toc_entry_get_start_stop (cur_info, &cur_start, &stop);
+ gst_toc_entry_get_start_stop_times (cur_info, &cur_start, &stop);
if (stop == -1) {
stop = max;
- gst_toc_entry_set_start_stop (cur_info, cur_start, stop);
+ gst_toc_entry_set_start_stop_times (cur_info, cur_start, stop);
}
gst_matroska_read_common_postprocess_toc_entries
- (cur_info->subentries, stop, cur_info->uid);
+ (gst_toc_entry_get_sub_entries (cur_info), stop,
+ gst_toc_entry_get_uid (cur_info));
}
break;
case GST_TOC_ENTRY_TYPE_INVALID:
break;
}
cur_list = cur_list->next;
- g_free (iter_digit);
}
}
static GstFlowReturn
gst_matroska_read_common_parse_chapter_element (GstMatroskaReadCommon * common,
- GstEbmlRead * ebml, GstTocEntry * toc_entry)
+ GstEbmlRead * ebml, GList ** subentries)
{
guint32 id;
guint64 start_time = -1, stop_time = -1;
guint64 is_hidden = 0, is_enabled = 1, uid = 0;
GstFlowReturn ret = GST_FLOW_OK;
GstTocEntry *chapter_info;
- GstTagList *titles;
+ GstTagList *tags;
+ gchar *uid_str;
+ GList *subsubentries = NULL, *l;
DEBUG_ELEMENT_START (common, ebml, "ChaptersElement");
return ret;
}
- titles = gst_tag_list_new_empty ();
- chapter_info = gst_toc_entry_new (GST_TOC_ENTRY_TYPE_CHAPTER,
- GST_MATROSKA_TOC_UID_EMPTY);
+ tags = gst_tag_list_new_empty ();
while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) {
if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK)
case GST_MATROSKA_ID_CHAPTERATOM:
ret =
gst_matroska_read_common_parse_chapter_element (common, ebml,
- chapter_info);
+ &subsubentries);
break;
case GST_MATROSKA_ID_CHAPTERDISPLAY:
ret =
- gst_matroska_read_common_parse_chapter_titles (common, ebml,
- titles);
+ gst_matroska_read_common_parse_chapter_titles (common, ebml, tags);
break;
case GST_MATROSKA_ID_CHAPTERFLAGHIDDEN:
}
}
- gst_toc_entry_set_start_stop (chapter_info, start_time, stop_time);
+ if (uid == 0)
+ uid = (((guint64) g_random_int ()) << 32) | g_random_int ();
+ uid_str = g_strdup_printf ("%" G_GUINT64_FORMAT, uid);
+ chapter_info = gst_toc_entry_new (GST_TOC_ENTRY_TYPE_CHAPTER, uid_str);
+ g_free (uid_str);
- DEBUG_ELEMENT_STOP (common, ebml, "ChaptersElement", ret);
+ gst_toc_entry_set_tags (chapter_info, tags);
+ gst_toc_entry_set_start_stop_times (chapter_info, start_time, stop_time);
- g_free (chapter_info->uid);
+ for (l = subsubentries; l; l = l->next)
+ gst_toc_entry_append_sub_entry (chapter_info, l->data);
+ g_list_free (subsubentries);
- if (uid != 0)
- chapter_info->uid = g_strdup_printf ("%" G_GUINT64_FORMAT, uid);
- else
- chapter_info->uid = NULL;
+ DEBUG_ELEMENT_STOP (common, ebml, "ChaptersElement", ret);
/* start time is mandatory and has no default value,
* so we should skip chapters without it */
if (is_hidden == 0 && is_enabled > 0 &&
start_time != -1 && ret == GST_FLOW_OK) {
- if (!gst_tag_list_is_empty (titles))
- gst_tag_list_insert (chapter_info->tags, titles, GST_TAG_MERGE_APPEND);
-
- toc_entry->subentries = g_list_append (toc_entry->subentries, chapter_info);
+ *subentries = g_list_append (*subentries, chapter_info);
} else
gst_toc_entry_unref (chapter_info);
- gst_tag_list_free (titles);
return ret;
}
guint64 is_hidden = 0, uid = 0;
GstFlowReturn ret = GST_FLOW_OK;
GstTocEntry *edition_info;
+ GList *subentries = NULL, *l;
+ gchar *uid_str;
DEBUG_ELEMENT_START (common, ebml, "ChaptersEdition");
return ret;
}
- edition_info = gst_toc_entry_new (GST_TOC_ENTRY_TYPE_EDITION,
- GST_MATROSKA_TOC_UID_EMPTY);
-
- gst_toc_entry_set_start_stop (edition_info, -1, -1);
-
while (ret == GST_FLOW_OK && gst_ebml_read_has_remaining (ebml, 1, TRUE)) {
if ((ret = gst_ebml_peek_id (ebml, &id)) != GST_FLOW_OK)
break;
case GST_MATROSKA_ID_CHAPTERATOM:
ret =
gst_matroska_read_common_parse_chapter_element (common, ebml,
- edition_info);
+ &subentries);
break;
case GST_MATROSKA_ID_EDITIONFLAGHIDDEN:
DEBUG_ELEMENT_STOP (common, ebml, "ChaptersEdition", ret);
- g_free (edition_info->uid);
+ if (uid == 0)
+ uid = (((guint64) g_random_int ()) << 32) | g_random_int ();
+ uid_str = g_strdup_printf ("%" G_GUINT64_FORMAT, uid);
+ edition_info = gst_toc_entry_new (GST_TOC_ENTRY_TYPE_EDITION, uid_str);
+ gst_toc_entry_set_start_stop_times (edition_info, -1, -1);
+ g_free (uid_str);
- if (uid != 0)
- edition_info->uid = g_strdup_printf ("%" G_GUINT64_FORMAT, uid);
- else
- edition_info->uid = NULL;
+ for (l = subentries; l; l = l->next)
+ gst_toc_entry_append_sub_entry (edition_info, l->data);
- if (is_hidden == 0 && edition_info->subentries != NULL && ret == GST_FLOW_OK)
- toc->entries = g_list_prepend (toc->entries, edition_info);
+ if (is_hidden == 0 && subentries != NULL && ret == GST_FLOW_OK)
+ gst_toc_append_entry (toc, edition_info);
else {
GST_DEBUG_OBJECT (common,
"Skipping empty or hidden edition in the chapters TOC");
}
}
- if (toc->entries != NULL) {
- toc->entries = g_list_reverse (toc->entries);
- gst_matroska_read_common_postprocess_toc_entries (toc->entries,
+ if (gst_toc_get_entries (toc) != NULL) {
+ gst_matroska_read_common_postprocess_toc_entries (gst_toc_get_entries (toc),
common->segment.duration, "");
common->toc = toc;
GST_WARNING_OBJECT (common,
"Found chapter/edition specific tag, but TOC doesn't present");
else {
- cur = common->toc->entries;
+ cur = gst_toc_get_entries (common->toc);
while (cur != NULL) {
gst_matroska_read_common_parse_toc_tag (cur->data, edition_targets,
chapter_targets, taglist);