How to extract only a certain tag from the stream?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to extract only a certain tag from the stream?

phngcv
Hello everybody,

I am trying to write a music manager using GTK+ and GStreamer. I would like to be able to extract some certain tags and apply it to the GtkTreeView in my software. However, I am not sure how to extract only a certain amount of tags from a stream. I know that I need to use gst_tag_list_foreach() to specify the GstForEachFunction for each tag, but I just need to display to the users some tags, like title, artist, name, not all the tags that are available. Here is part of my GstForEachFunction:

void insert_tag_on_tree(const GstTagList *list, const gchar *tag, gpointer user_data) {
  gchar *str = NULL;
  GtkTreeView *tree_view = NULL;
  GtkListStore *list_store = NULL;
  
  if (gst_tag_get_type(tag) == G_TYPE_STRING) {
    if (tag == (gchar*) "artist") {
      gst_tag_list_get_string_index(list, tag, 0, &str);
      g_print("%s : %20s\n", tag, str);
    }
  }
}

So in this GstForEachFunc I compare the tag's name to "artist" and if its name is "artist", I will print it out. However, I could not get this function to work. Any idea on how to extract only a certain amount of tags from a stream?

Thank you for reading my message! I hope you guys have a good weekend!


Best regards,

Phong Cao

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to extract only a certain tag from the stream?

Edward Hervey-2
On Sat, 2011-06-11 at 18:12 -0400, Phong Cao wrote:

>
>     if (tag == (gchar*) "artist") {

  And what if the pointer contained in tag isn't the same as the local
pointer for (gchar*) "artist" ? This is basic pointer

  And that check is useless anyway, you can directly do ...

    if (gst_tag_list_get_string_index(list, GST_TAG_ARTIST, 0, &str)) {
      g_print("%s : %20s\n", GST_TAG_ARTIST, str);
      /* Do something with str */
      g_free (str);
    }

    ... without the need to call gst_tag_list_foreach(). If there's no
GST_TAG_ARTIST in that list it will return FALSE, and if there's one it
will return the first occurence.

     Edward

>
>
>
>
> Best regards,
>
>
> Phong Cao
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

--
Edward Hervey  --  Collabora Multimedia
Project Manager              Co-Founder

_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel