/* Print a tag in a human-readable format (name: value) */ void print_tag_foreach (const GstTagList *tags, const gchar *tag, gpointer user_data) { GValue val = { 0 }; gchar *str; gint depth = GPOINTER_TO_INT (user_data); gst_tag_list_copy_value (&val, tags, tag); if (G_VALUE_HOLDS_STRING (&val)) str = g_value_dup_string (&val); else str = gst_value_serialize (&val); g_print ("%*s%s: %s\n", 2 * depth, " ", gst_tag_get_nick (tag), str); g_free (str); g_value_unset (&val); }
static void print_tag (const GstTagList * list, const gchar * tag, gpointer unused) { gint i, count; count = gst_tag_list_get_tag_size (list, tag); for (i = 0; i < count; i++) { gchar *str; if (gst_tag_get_type (tag) == G_TYPE_STRING) { if (!gst_tag_list_get_string_index (list, tag, i, &str)) g_assert_not_reached (); } else if (gst_tag_get_type (tag) == GST_TYPE_BUFFER) { GstBuffer *img; img = gst_value_get_buffer (gst_tag_list_get_value_index (list, tag, i)); if (img) { gchar *caps_str; caps_str = GST_BUFFER_CAPS (img) ? gst_caps_to_string (GST_BUFFER_CAPS (img)) : g_strdup ("unknown"); str = g_strdup_printf ("buffer of %u bytes, type: %s", GST_BUFFER_SIZE (img), caps_str); g_free (caps_str); } else { str = g_strdup ("NULL buffer"); } } else { str = g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i)); } if (i == 0) { g_print ("%16s: %s\n", gst_tag_get_nick (tag), str); } else { g_print ("%16s: %s\n", "", str); } g_free (str); } }
static void print_tag_foreach (const GstTagList * tags, const gchar * tag, gpointer user_data) { GValue val = { 0, }; gchar *str; guint depth = GPOINTER_TO_UINT (user_data); if (!gst_tag_list_copy_value (&val, tags, tag)) return; if (G_VALUE_HOLDS_STRING (&val)) { str = g_value_dup_string (&val); } else if (G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE) { GstSample *sample = gst_value_get_sample (&val); GstBuffer *img = gst_sample_get_buffer (sample); GstCaps *caps = gst_sample_get_caps (sample); if (img) { if (caps) { gchar *caps_str; caps_str = gst_caps_to_string (caps); str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes, " "type: %s", gst_buffer_get_size (img), caps_str); g_free (caps_str); } else { str = g_strdup_printf ("buffer of %" G_GSIZE_FORMAT " bytes", gst_buffer_get_size (img)); } } else { str = g_strdup ("NULL buffer"); } } else { str = gst_value_serialize (&val); } g_print ("%*s%s: %s\n", 2 * depth, " ", gst_tag_get_nick (tag), str); g_free (str); g_value_unset (&val); }
static gboolean print_tag_each (GQuark field_id, const GValue * value, gpointer user_data) { gint tab = GPOINTER_TO_INT (user_data); gchar *ser; if (G_VALUE_HOLDS_STRING (value)) ser = g_value_dup_string (value); else if (GST_VALUE_HOLDS_BUFFER (value)) { GstBuffer *buf = gst_value_get_buffer (value); ser = g_strdup_printf ("<GstBuffer [%d bytes]>", GST_BUFFER_SIZE (buf)); } else ser = gst_value_serialize (value); g_print ("%*s%s: %s\n", tab, " ", gst_tag_get_nick (g_quark_to_string (field_id)), ser); g_free (ser); return TRUE; }
static void send_tag (const GstTagList * list, const gchar * tag, gpointer data) { InsanityGstPipelineTest *ptest = INSANITY_GST_PIPELINE_TEST (data); gint i, count; GValue string_value = { 0 }; char label[48]; count = gst_tag_list_get_tag_size (list, tag); g_value_init (&string_value, G_TYPE_STRING); ptest->priv->tag_count++; for (i = 0; i < count; i++) { gchar *str; if (gst_tag_get_type (tag) == G_TYPE_STRING) { if (!gst_tag_list_get_string_index (list, tag, i, &str)) g_assert_not_reached (); } else if (gst_tag_get_type (tag) == GST_TYPE_SAMPLE) { GstSample *img; img = gst_value_get_sample (gst_tag_list_get_value_index (list, tag, i)); if (img) { GstBuffer *buffer; GstCaps *caps; gchar *caps_str; buffer = gst_sample_get_buffer (img); caps = gst_sample_get_caps (img); caps_str = caps ? gst_caps_to_string (caps) : g_strdup ("unknown"); str = g_strdup_printf ("sample of %" G_GSIZE_FORMAT " bytes, type: %s", gst_buffer_get_size (buffer), caps_str); g_free (caps_str); } else { str = g_strdup ("NULL sample"); } } else if (gst_tag_get_type (tag) == GST_TYPE_DATE_TIME) { GstDateTime *dt = NULL; gst_tag_list_get_date_time_index (list, tag, i, &dt); str = gst_date_time_to_iso8601_string (dt); gst_date_time_unref (dt); } else { str = g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i)); } if (i == 0) { g_value_set_string (&string_value, gst_tag_get_nick (tag)); snprintf (label, sizeof (label), "tags.%u.id", ptest->priv->tag_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); } g_value_set_string (&string_value, str); if (count > 1) snprintf (label, sizeof (label), "tags.%u.value.%u", ptest->priv->tag_count, i); else snprintf (label, sizeof (label), "tags.%u.value", ptest->priv->tag_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); g_free (str); } }
static void tag_iterate (const GstTagList *list, const char *tag, GFileInfo *info) { const char *tag_key; char *attribute = NULL; tag_key = NULL; if (strcmp (tag, "container-format") == 0) { tag_key = "general::format"; } else if (strcmp (tag, "bitrate") == 0) { tag_key = "audio-video::general::bitrate"; } else if (strcmp (tag, "encoder") == 0) { tag_key = "audio-video::general::encoder"; } else if (strcmp (tag, "title") == 0) { tag_key = "general::title"; } else if (strcmp (tag, "artist") == 0) { tag_key = "audio-video::general::artist"; } else if (strcmp (tag, "album") == 0) { tag_key = "audio-video::general::album"; } else if (strcmp (tag, "audio-codec") == 0) { tag_key = "audio-video::audio::codec"; } else if (strcmp (tag, "video-codec") == 0) { tag_key = "audio-video::video::codec"; } if (tag_key == NULL) { GthMetadataInfo *metadata_info; attribute = g_strconcat ("audio-video::other::", tag, NULL); metadata_info = gth_main_get_metadata_info (attribute); if (metadata_info == NULL) { GthMetadataInfo *info; info = g_new0 (GthMetadataInfo, 1); info->id = attribute; info->display_name = gst_tag_get_nick (tag); info->category = "audio-video::other"; info->sort_order = 500; info->flags = GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW; metadata_info = gth_main_register_metadata_info (info); g_free (info); } tag_key = attribute; } add_metadata_from_tag (info, list, tag, tag_key); g_free (attribute); }
/* * Class method: get_nick(tag) * tag: the name of the tag. * * Returns: the human-readable name of this tag. */ static VALUE rg_s_get_nick (G_GNUC_UNUSED VALUE self, VALUE tag) { return CSTR2RVAL (gst_tag_get_nick (RVAL2CSTR (tag))); }
/* * Class method: get_nick(tag) * tag: the name of the tag. * * Returns: the human-readable name of this tag. */ static VALUE rb_gst_tag_get_nick (VALUE self, VALUE tag) { return CSTR2RVAL (gst_tag_get_nick (RVAL2CSTR (tag))); }