From 3b0af8df9eb82b69bf90f7151629ec77097c041f Mon Sep 17 00:00:00 2001 From: Stefan Sauer Date: Mon, 2 Apr 2012 22:09:07 +0200 Subject: [PATCH] toc: port to 0.11 --- gst/gstevent.c | 2 +- gst/gstmessage.c | 4 ++-- gst/gstquery.c | 17 +++++++++++------ gst/gsttoc.c | 16 ++++++++-------- gst/gsttoc.h | 1 + tests/check/gst/gsttoc.c | 4 ---- tests/check/gst/gsttocsetter.c | 21 +++------------------ 7 files changed, 26 insertions(+), 39 deletions(-) diff --git a/gst/gstevent.c b/gst/gstevent.c index ae535221bd..e922360020 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -1690,7 +1690,7 @@ gst_event_new_toc_select (const gchar * uid) GST_CAT_INFO (GST_CAT_EVENT, "creating toc select event for UID: %s", uid); - structure = gst_structure_id_new (GST_QUARK (EVENT_TOC_SELECT), + structure = gst_structure_new_id (GST_QUARK (EVENT_TOC_SELECT), GST_QUARK (UID), G_TYPE_STRING, uid, NULL); return gst_event_new_custom (GST_EVENT_TOC_SELECT, structure); diff --git a/gst/gstmessage.c b/gst/gstmessage.c index 5c1e50a56b..f99a3de7c0 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -2225,8 +2225,8 @@ gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated) g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC); g_return_if_fail (toc != NULL); - *toc = _gst_toc_from_structure (message->structure); + *toc = _gst_toc_from_structure (GST_MESSAGE_STRUCTURE (message)); if (updated != NULL) - *updated = _gst_toc_structure_get_updated (message->structure); + *updated = _gst_toc_structure_get_updated (GST_MESSAGE_STRUCTURE (message)); } diff --git a/gst/gstquery.c b/gst/gstquery.c index 8e755cf5f4..ec3f841b84 100644 --- a/gst/gstquery.c +++ b/gst/gstquery.c @@ -2335,8 +2335,10 @@ GstQuery * gst_query_new_toc (void) { GstQuery *query; + GstStructure *structure; - query = gst_query_new (GST_QUERY_TOC, NULL); + structure = gst_structure_new_id_empty (GST_QUARK (QUERY_TOC)); + query = gst_query_new_custom (GST_QUERY_TOC, structure); return query; } @@ -2354,6 +2356,7 @@ void gst_query_set_toc (GstQuery * query, GstToc * toc, const gchar * extend_uid) { GstStructure *structure; + GstStructure *old_structure; g_return_if_fail (query != NULL); g_return_if_fail (GST_QUERY_TYPE (query) == GST_QUERY_TOC); @@ -2364,15 +2367,17 @@ gst_query_set_toc (GstQuery * query, GstToc * toc, const gchar * extend_uid) g_return_if_fail (structure != NULL); /* that shouldn't be happen in normal usage */ - if (query->structure != NULL) - gst_structure_free (query->structure); + old_structure = GST_QUERY_STRUCTURE (query); + if (old_structure) { + gst_structure_set_parent_refcount (old_structure, NULL); + gst_structure_free (old_structure); + } if (extend_uid != NULL) _gst_toc_structure_set_extend_uid (structure, extend_uid); - query->structure = structure; - gst_structure_set_parent_refcount (query->structure, - &(query->mini_object.refcount)); + gst_structure_set_parent_refcount (structure, &(query->mini_object.refcount)); + GST_QUERY_STRUCTURE (query) = structure; } /** diff --git a/gst/gsttoc.c b/gst/gsttoc.c index 7753ae34c2..fa2ecde234 100644 --- a/gst/gsttoc.c +++ b/gst/gsttoc.c @@ -170,8 +170,8 @@ gst_toc_new (void) GstToc *toc; toc = g_slice_new0 (GstToc); - toc->tags = gst_tag_list_new (); - toc->info = gst_structure_id_empty_new (gst_toc_fields[GST_TOC_INFONAME]); + toc->tags = gst_tag_list_new_empty (); + toc->info = gst_structure_new_id_empty (gst_toc_fields[GST_TOC_INFONAME]); return toc; } @@ -197,8 +197,8 @@ gst_toc_entry_new (GstTocEntryType type, const gchar * uid) entry = g_slice_new0 (GstTocEntry); entry->uid = g_strdup (uid); entry->type = type; - entry->tags = gst_tag_list_new (); - entry->info = gst_structure_id_empty_new (gst_toc_fields[GST_TOC_INFONAME]); + entry->tags = gst_tag_list_new_empty (); + entry->info = gst_structure_new_id_empty (gst_toc_fields[GST_TOC_INFONAME]); return entry; } @@ -227,7 +227,7 @@ gst_toc_entry_new_with_pad (GstTocEntryType type, const gchar * uid, entry = g_slice_new0 (GstTocEntry); entry->uid = g_strdup (uid); entry->type = type; - entry->tags = gst_tag_list_new (); + entry->tags = gst_tag_list_new_empty (); if (pad != NULL && GST_IS_PAD (pad)) entry->pads = g_list_append (entry->pads, gst_object_ref (pad)); @@ -306,7 +306,7 @@ gst_toc_structure_new (GstTagList * tags, GstStructure * info) GstStructure *ret; GValue val = { 0 }; - ret = gst_structure_id_empty_new (gst_toc_fields[GST_TOC_TOC]); + ret = gst_structure_new_id_empty (gst_toc_fields[GST_TOC_TOC]); if (tags != NULL) { g_value_init (&val, GST_TYPE_STRUCTURE); @@ -332,7 +332,7 @@ gst_toc_entry_structure_new (GstTocEntryType type, const gchar * uid, GValue val = { 0 }; GstStructure *ret; - ret = gst_structure_id_empty_new (gst_toc_fields[GST_TOC_ENTRY]); + ret = gst_structure_new_id_empty (gst_toc_fields[GST_TOC_ENTRY]); gst_structure_id_set (ret, gst_toc_fields[GST_TOC_TYPE], GST_TYPE_TOC_ENTRY_TYPE, type, NULL); @@ -884,7 +884,7 @@ gst_toc_entry_set_start_stop (GstTocEntry * entry, gint64 start, gint64 stop) } if (structure == NULL) - structure = gst_structure_id_empty_new (gst_toc_fields[GST_TOC_TIMENAME]); + structure = gst_structure_new_id_empty (gst_toc_fields[GST_TOC_TIMENAME]); gst_structure_id_set (structure, gst_toc_fields[GST_TOC_TIME_START], G_TYPE_INT64, start, gst_toc_fields[GST_TOC_TIME_STOP], G_TYPE_INT64, diff --git a/gst/gsttoc.h b/gst/gsttoc.h index a817efecfe..a1a7b8cf2f 100644 --- a/gst/gsttoc.h +++ b/gst/gsttoc.h @@ -23,6 +23,7 @@ #define __GST_TOC_H__ #include +#include #include #include diff --git a/tests/check/gst/gsttoc.c b/tests/check/gst/gsttoc.c index ee0b429615..a0c52b71cf 100644 --- a/tests/check/gst/gsttoc.c +++ b/tests/check/gst/gsttoc.c @@ -249,7 +249,6 @@ GST_START_TEST (test_serializing) /* check TOC event handling */ event = gst_event_new_toc (toc, TRUE); fail_if (event == NULL); - fail_if (event->structure == NULL); fail_unless (event->type == GST_EVENT_TOC); ASSERT_MINI_OBJECT_REFCOUNT (GST_MINI_OBJECT (event), "GstEvent", 1); @@ -265,7 +264,6 @@ GST_START_TEST (test_serializing) /* check TOC message handling */ message = gst_message_new_toc (NULL, toc, TRUE); fail_if (message == NULL); - fail_if (event->structure == NULL); fail_unless (message->type == GST_MESSAGE_TOC); ASSERT_MINI_OBJECT_REFCOUNT (GST_MINI_OBJECT (message), "GstMessage", 1); @@ -280,7 +278,6 @@ GST_START_TEST (test_serializing) /* check TOC select event handling */ event = gst_event_new_toc_select (TEST_UID); fail_if (event == NULL); - fail_if (event->structure == NULL); fail_unless (event->type == GST_EVENT_TOC_SELECT); ASSERT_MINI_OBJECT_REFCOUNT (GST_MINI_OBJECT (event), "GstEvent", 1); @@ -293,7 +290,6 @@ GST_START_TEST (test_serializing) query = gst_query_new_toc (); fail_if (query == NULL); gst_query_set_toc (query, toc, TEST_UID); - fail_if (query->structure == NULL); fail_unless (query->type == GST_QUERY_TOC); ASSERT_MINI_OBJECT_REFCOUNT (GST_MINI_OBJECT (query), "GstQuery", 1); diff --git a/tests/check/gst/gsttocsetter.c b/tests/check/gst/gsttocsetter.c index 7b44171a60..34e589a4c6 100644 --- a/tests/check/gst/gsttocsetter.c +++ b/tests/check/gst/gsttocsetter.c @@ -114,24 +114,9 @@ typedef GstElement GstDummyEnc; typedef GstElementClass GstDummyEncClass; -static void gst_dummy_enc_add_interfaces (GType enc_type); - GType gst_dummy_enc_get_type (void); -GST_BOILERPLATE_FULL (GstDummyEnc, gst_dummy_enc, GstElement, - GST_TYPE_ELEMENT, gst_dummy_enc_add_interfaces); - -static void -gst_dummy_enc_add_interfaces (GType enc_type) -{ - static const GInterfaceInfo toc_setter_info = { NULL, NULL, NULL }; - - g_type_add_interface_static (enc_type, GST_TYPE_TOC_SETTER, &toc_setter_info); -} - -static void -gst_dummy_enc_base_init (gpointer g_class) -{ -} +G_DEFINE_TYPE_WITH_CODE (GstDummyEnc, gst_dummy_enc, + GST_TYPE_ELEMENT, G_IMPLEMENT_INTERFACE (GST_TYPE_TOC_SETTER, NULL)); static void gst_dummy_enc_class_init (GstDummyEncClass * klass) @@ -139,7 +124,7 @@ gst_dummy_enc_class_init (GstDummyEncClass * klass) } static void -gst_dummy_enc_init (GstDummyEnc * enc, GstDummyEncClass * klass) +gst_dummy_enc_init (GstDummyEnc * enc) { }