void test_is_writable() { GstBuffer *buffer; GstMiniObject *mobj; xmlfile = "gstminiobject_test_is_writable"; std_log(LOG_FILENAME_LINE, "Test Started test_is_writable"); buffer = gst_buffer_new_and_alloc (4); mobj = GST_MINI_OBJECT (buffer); fail_unless (gst_mini_object_is_writable (mobj), "A buffer with one ref should be writable"); GST_MINI_OBJECT_FLAG_SET (mobj, GST_MINI_OBJECT_FLAG_READONLY); fail_if (gst_mini_object_is_writable (mobj), "A buffer with READONLY set should not be writable"); GST_MINI_OBJECT_FLAG_UNSET (mobj, GST_MINI_OBJECT_FLAG_READONLY); fail_unless (gst_mini_object_is_writable (mobj), "A buffer with one ref and READONLY not set should be writable"); fail_if (gst_mini_object_ref (mobj) == NULL, "Could not ref the mobj"); fail_if (gst_mini_object_is_writable (mobj), "A buffer with two refs should not be writable"); std_log(LOG_FILENAME_LINE, "Test Successful"); create_xml(0); }
/** * gst_toc_append_entry: * @toc: A #GstToc instance * @entry: (transfer full): A #GstTocEntry * * Appends the #GstTocEntry @entry to @toc. */ void gst_toc_append_entry (GstToc * toc, GstTocEntry * entry) { g_return_if_fail (toc != NULL); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (toc))); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (entry))); g_return_if_fail (entry->toc == NULL); g_return_if_fail (entry->parent == NULL); toc->entries = g_list_append (toc->entries, entry); entry->toc = toc; GST_LOG ("appended %s entry with uid %s to toc %p", gst_toc_entry_type_get_nick (entry->type), entry->uid, toc); gst_toc_dump (toc); }
/** * gst_rtsp_token_writable_structure: * @token: The #GstRTSPToken. * * Get a writable version of the structure. * * Returns: (transfer none): The structure of the token. The structure is still * owned by the token, which means that you should not free it and that the * pointer becomes invalid when you free the token. This function checks if * @token is writable and will never return %NULL. * * MT safe. */ GstStructure * gst_rtsp_token_writable_structure (GstRTSPToken * token) { g_return_val_if_fail (GST_IS_RTSP_TOKEN (token), NULL); g_return_val_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (token)), NULL); return GST_RTSP_TOKEN_STRUCTURE (token); }
/** * gst_toc_entry_append_sub_entry: * @entry: A #GstTocEntry instance * @subentry: (transfer full): A #GstTocEntry * * Appends the #GstTocEntry @subentry to @entry. */ void gst_toc_entry_append_sub_entry (GstTocEntry * entry, GstTocEntry * subentry) { g_return_if_fail (entry != NULL); g_return_if_fail (subentry != NULL); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (entry))); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (subentry))); g_return_if_fail (subentry->toc == NULL); g_return_if_fail (subentry->parent == NULL); entry->subentries = g_list_append (entry->subentries, subentry); subentry->toc = entry->toc; subentry->parent = entry; GST_LOG ("appended %s subentry with uid %s to entry %s", gst_toc_entry_type_get_nick (subentry->type), subentry->uid, entry->uid); }
/** * gst_toc_entry_set_tags: * @entry: A #GstTocEntry instance * @tags: (allow-none) (transfer full): A #GstTagList or %NULL * * Set a #GstTagList with tags for the complete @entry. */ void gst_toc_entry_set_tags (GstTocEntry * entry, GstTagList * tags) { g_return_if_fail (entry != NULL); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (entry))); if (entry->tags) gst_tag_list_unref (entry->tags); entry->tags = tags; }
/** * gst_toc_set_tags: * @toc: A #GstToc instance * @tags: (allow-none) (transfer full): A #GstTagList or %NULL * * Set a #GstTagList with tags for the complete @toc. */ void gst_toc_set_tags (GstToc * toc, GstTagList * tags) { g_return_if_fail (toc != NULL); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (toc))); if (toc->tags) gst_tag_list_unref (toc->tags); toc->tags = tags; }
/** * gst_toc_merge_tags: * @toc: A #GstToc instance * @tags: (allow-none): A #GstTagList or %NULL * @mode: A #GstTagMergeMode * * Merge @tags into the existing tags of @toc using @mode. */ void gst_toc_merge_tags (GstToc * toc, GstTagList * tags, GstTagMergeMode mode) { g_return_if_fail (toc != NULL); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (toc))); if (!toc->tags) { toc->tags = gst_tag_list_ref (tags); } else { GstTagList *tmp = gst_tag_list_merge (toc->tags, tags, mode); gst_tag_list_unref (toc->tags); toc->tags = tmp; } }
/** * gst_toc_entry_merge_tags: * @entry: A #GstTocEntry instance * @tags: (allow-none): A #GstTagList or %NULL * @mode: A #GstTagMergeMode * * Merge @tags into the existing tags of @entry using @mode. */ void gst_toc_entry_merge_tags (GstTocEntry * entry, GstTagList * tags, GstTagMergeMode mode) { g_return_if_fail (entry != NULL); g_return_if_fail (gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (entry))); if (!entry->tags) { entry->tags = gst_tag_list_ref (tags); } else { GstTagList *tmp = gst_tag_list_merge (entry->tags, tags, mode); gst_tag_list_unref (entry->tags); entry->tags = tmp; } }
/** * gst_mini_object_make_writable: * @mini_object: the mini-object to make writable * * Checks if a mini-object is writable. If not, a writable copy is made and * returned. This gives away the reference to the original mini object, * and returns a reference to the new object. * * MT safe * * Returns: a mini-object (possibly the same pointer) that is writable. */ GstMiniObject * gst_mini_object_make_writable (GstMiniObject * mini_object) { GstMiniObject *ret; g_return_val_if_fail (mini_object != NULL, NULL); if (gst_mini_object_is_writable (mini_object)) { ret = mini_object; } else { GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy %s miniobject", g_type_name (G_TYPE_FROM_INSTANCE (mini_object))); ret = gst_mini_object_copy (mini_object); gst_mini_object_unref (mini_object); } return ret; }
/** * gst_mini_object_make_writable: * @mini_object: (transfer full): the mini-object to make writable * * Checks if a mini-object is writable. If not, a writable copy is made and * returned. This gives away the reference to the original mini object, * and returns a reference to the new object. * * MT safe * * Returns: (transfer full): a mini-object (possibly the same pointer) that * is writable. */ GstMiniObject * gst_mini_object_make_writable (GstMiniObject * mini_object) { GstMiniObject *ret; g_return_val_if_fail (mini_object != NULL, NULL); if (gst_mini_object_is_writable (mini_object)) { ret = mini_object; } else { ret = gst_mini_object_copy (mini_object); GST_CAT_DEBUG (GST_CAT_PERFORMANCE, "copy %s miniobject %p -> %p", g_type_name (GST_MINI_OBJECT_TYPE (mini_object)), mini_object, ret); gst_mini_object_unref (mini_object); } return ret; }
bool MiniObject::isWritable() const { return gst_mini_object_is_writable(object<GstMiniObject>()); }