From 70ceffb790292508d8b94bb3a675c96135eeeb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 13 Jun 2008 19:14:41 +0000 Subject: [PATCH] gst/matroska/: Use gst_value_serialize() and gst_value_deserialize() for transforming tags from some GType to a strin... Original commit message from CVS: * gst/matroska/matroska-demux.c: (gst_matroska_demux_parse_metadata_id_simple_tag): * gst/matroska/matroska-mux.c: (gst_matroska_mux_write_simple_tag), (gst_matroska_mux_write_data): Use gst_value_serialize() and gst_value_deserialize() for transforming tags from some GType to a string and the other way around. The default transformations in GLib don't include transformations from string to number types. --- ChangeLog | 11 +++++++++++ gst/matroska/matroska-demux.c | 11 ++++------- gst/matroska/matroska-mux.c | 12 ++++++------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f1b33c1b7..77cd4e2ed6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-06-13 Sebastian Dröge + + * gst/matroska/matroska-demux.c: + (gst_matroska_demux_parse_metadata_id_simple_tag): + * gst/matroska/matroska-mux.c: (gst_matroska_mux_write_simple_tag), + (gst_matroska_mux_write_data): + Use gst_value_serialize() and gst_value_deserialize() for transforming + tags from some GType to a string and the other way around. The default + transformations in GLib don't include transformations from string to + number types. + 2008-06-13 Sebastian Dröge * gst/matroska/matroska-demux.c: (gst_matroska_demux_reset), diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c index 66a4938c7d..d8765ad306 100644 --- a/gst/matroska/matroska-demux.c +++ b/gst/matroska/matroska-demux.c @@ -2255,21 +2255,18 @@ gst_matroska_demux_parse_metadata_id_simple_tag (GstMatroskaDemux * demux, const gchar *tagname_mkv = tag_conv[i].matroska_tagname; if (strcmp (tagname_mkv, tag) == 0) { - GValue src = { 0, }; GValue dest = { 0, }; GType dest_type = gst_tag_get_type (tagname_gst); - g_value_init (&src, G_TYPE_STRING); - g_value_set_string (&src, value); g_value_init (&dest, dest_type); - if (g_value_transform (&src, &dest)) { + if (gst_value_deserialize (&dest, value)) { gst_tag_list_add_values (*p_taglist, GST_TAG_MERGE_APPEND, tagname_gst, &dest, NULL); } else { - GST_WARNING_OBJECT (demux, "Can't transform tag '%s' with" - "value '%s' to target type", tag, value); + GST_WARNING_OBJECT (demux, "Can't transform tag '%s' with " + "value '%s' to target type '%s'", tag, value, + g_type_name (dest_type)); } - g_value_unset (&src); g_value_unset (&dest); break; } diff --git a/gst/matroska/matroska-mux.c b/gst/matroska/matroska-mux.c index 1c83b5ae1a..58d42ae997 100644 --- a/gst/matroska/matroska-mux.c +++ b/gst/matroska/matroska-mux.c @@ -1546,24 +1546,21 @@ gst_matroska_mux_write_simple_tag (const GstTagList * list, const gchar * tag, if (strcmp (tagname_gst, tag) == 0) { GValue src = { 0, }; - GValue dest = { 0, }; + gchar *dest; if (!gst_tag_list_copy_value (&src, list, tag)) break; - g_value_init (&dest, G_TYPE_STRING); - if (g_value_transform (&src, &dest)) { + if ((dest = gst_value_serialize (&src))) { simpletag_master = gst_ebml_write_master_start (ebml, GST_MATROSKA_ID_SIMPLETAG); gst_ebml_write_ascii (ebml, GST_MATROSKA_ID_TAGNAME, tagname_mkv); - gst_ebml_write_utf8 (ebml, GST_MATROSKA_ID_TAGSTRING, - g_value_get_string (&dest)); + gst_ebml_write_utf8 (ebml, GST_MATROSKA_ID_TAGSTRING, dest); gst_ebml_write_master_finish (ebml, simpletag_master); } else { GST_WARNING ("Can't transform tag '%s' to string", tagname_mkv); } g_value_unset (&src); - g_value_unset (&dest); break; } } @@ -1953,6 +1950,9 @@ gst_matroska_mux_write_data (GstMatroskaMux * mux, GstMatroskaPad * collect_pad) * one for each keyframe or each second (for all-keyframe * streams), only the *first* video track. But that'll come later... */ + /* TODO: index is useful for every track, should contain the number of + * the block in the cluster which contains the timestamp + */ if (is_video_keyframe) { GstMatroskaIndex *idx;