How to Display the Album Art of audio file while song plays

HIMANSHU AGARWAL himanshu.mit.cs at gmail.com
Wed Jul 25 02:56:16 PDT 2012


This is the code and i am able to get only buffer of image but hoe to
display it I am not able to get around it...............please help me out
on this



#include <gst/gst.h>


GstElement *pipe, *dec, *sink, *src;

static void
print_one_tag (const GstTagList * list, const gchar * tag, gpointer
user_data)
{
 if(!strcmp(tag,"image")) {
   guint i;
   const GValue *val;
   g_printf("Image Detected");
   i=gst_tag_list_get_tag_size(list,tag);
   g_printf("\n%d",i);
   val = gst_tag_list_get_value_index(list, tag, 0);
   g_printf("\n%s",GST_BUFFER_DATA (gst_value_get_buffer (val)));
 }
}

static void
on_new_pad (GstElement * dec, GstPad * pad, GstElement * fakesink)
{
  GstPad *sinkpad;

  sinkpad = gst_element_get_static_pad (fakesink, "sink");
  if (!gst_pad_is_linked (sinkpad)) {
    if (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK)
      g_error ("Failed to link pads!");
  }
  gst_object_unref (sinkpad);
}

int
main (int argc, char ** argv)
{
  GstMessage *msg;

  gst_init (&argc, &argv);

  pipe = gst_pipeline_new ("pipeline");

  dec = gst_element_factory_make ("decodebin2", NULL);
  src = gst_element_factory_make ("filesrc",NULL);
  g_object_set (src, "location", argv[1], NULL);
  gst_bin_add (GST_BIN (pipe), dec);
  gst_bin_add (GST_BIN (pipe), src);
  gst_element_link(src,dec);
  sink = gst_element_factory_make ("alsasink", NULL);
  gst_bin_add (GST_BIN (pipe), sink);

  g_signal_connect (dec, "pad-added", G_CALLBACK (on_new_pad), sink);

  gst_element_set_state (pipe, GST_STATE_PLAYING);

  while (TRUE) {
    GstTagList *tags = NULL;

    msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipe),
        GST_CLOCK_TIME_NONE,
        GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_TAG | GST_MESSAGE_ERROR);

    if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_TAG) /* error or async_done */
      break;

    gst_message_parse_tag (msg, &tags);

    g_print ("Got tags from element %s:\n", GST_OBJECT_NAME (msg->src));
    gst_tag_list_foreach (tags, print_one_tag, NULL);
    g_print ("\n");
    gst_tag_list_free (tags);

    gst_message_unref (msg);
  };

  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR)
    g_error ("Got error");

  gst_message_unref (msg);
  gst_element_set_state (pipe, GST_STATE_NULL);
  gst_object_unref (pipe);
  return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20120725/518ecb3b/attachment.html>


More information about the gstreamer-devel mailing list