static void
try_fetch_from_amazon (NemoPreviewCoverArtFetcher *self)
{
  NemoPreviewCoverArtFetcherPrivate *priv = NEMO_PREVIEW_COVER_ART_FETCHER_GET_PRIVATE (self);
  gchar *artist = NULL;
  gchar *album = NULL;

  gst_tag_list_get_string (priv->taglist,
                           GST_TAG_ARTIST, &artist);
  gst_tag_list_get_string (priv->taglist,
                           GST_TAG_ALBUM, &album);

  if (artist == NULL &&
      album == NULL) {
    /* don't even try */
    return;
  }

  nemo_preview_cover_art_fetcher_get_uri_for_track_async
    (self, artist, album,
     amazon_cover_uri_async_ready_cb, NULL);

  g_free (artist);
  g_free (album);
}
Exemplo n.º 2
0
static void 
cb_gst_found_tag (GObject *pipeline, GstElement *source, GstTagList *tags, GAPMetaData *md)
{
	gboolean retval;
	glong duration;
	char *temp = NULL;

	retval = gst_tag_list_get_long (tags, GST_TAG_DURATION, &duration);
	if (retval)
	{
		md->duration = duration/(1000*1000*1000);
		g_printf ("Duration found: %d\n", md->duration);
	}

	retval = gst_tag_list_get_string (tags, GST_TAG_TITLE, &temp);
	if (retval)
	{
		g_printf ("Title found: %s\n", temp);
		md->title = g_strdup (temp);
	}
	temp = NULL;
	retval = gst_tag_list_get_string (tags, GST_TAG_ARTIST, &temp);
	if (retval)
	{
		g_printf ("Artist found: %s\n", temp);
		md->artist = g_strdup (temp);
	}
	
}
Exemplo n.º 3
0
//定义消息处理函数,
static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) {
	GMainLoop *loop = (GMainLoop *) data;//这个是主循环的指针,在接受EOS消息时退出循环
	switch (GST_MESSAGE_TYPE(msg)) {
	case GST_MESSAGE_EOS:
		g_print("End of stream\n");
		g_main_loop_quit(loop);
		break;
	case GST_MESSAGE_ERROR: {
		gchar *debug;
		GError *error;

		gst_message_parse_error(msg, &error, &debug);
		g_free(debug);
		g_printerr("ERROR:%s\n", error->message);
		g_error_free(error);
		g_main_loop_quit(loop);
		break;
	}
	case GST_MESSAGE_TAG: {
		GstTagList *tags;
		gchar *title = "";
		gchar *artist = "";
		gst_message_parse_tag(msg, &tags);
		if (gst_tag_list_get_string(tags, GST_TAG_TITLE, &title)
			 && gst_tag_list_get_string(tags, GST_TAG_ARTIST, &artist)) {
			puts(title); puts(artist);
		}
		gst_tag_list_free(tags);
		break;
	}
	default:
		break;
	}
	return TRUE;
}
Exemplo n.º 4
0
static void
pragha_backend_parse_message_tag (PraghaBackend *backend, GstMessage *message)
{
	PraghaBackendPrivate *priv = backend->priv;
	GstTagList *tag_list;
	gchar *str = NULL;
	gint changed = 0;

	CDEBUG(DBG_BACKEND, "Parse message tag");

	gst_message_parse_tag(message, &tag_list);

	save_embedded_art (backend, tag_list);

	if (pragha_musicobject_get_source (priv->mobj) != FILE_HTTP)
		goto out;

	if (gst_tag_list_get_string(tag_list, GST_TAG_TITLE, &str))
	{
		changed |= TAG_TITLE_CHANGED;
		pragha_musicobject_set_title(priv->mobj, str);
		g_free(str);
	}
	if (gst_tag_list_get_string(tag_list, GST_TAG_ARTIST, &str))
	{
		changed |= TAG_ARTIST_CHANGED;
		pragha_musicobject_set_artist(priv->mobj, str);
		g_free(str);
	}

	g_signal_emit (backend, signals[SIGNAL_TAGS_CHANGED], 0, changed);

out:
	gst_tag_list_free(tag_list);
}
Exemplo n.º 5
0
// A C-style function to handle GST tag data:
static void linHandleTag(
  const GstTagList *list,
  const gchar *tag,
  gpointer linGstObjectPtr)
{
  LinVideoDisplayForm *myForm = 
    static_cast<LinVideoDisplayForm *>(linGstObjectPtr);

  gchar *value;

//  if (tag == GST_TAG_TITLE)
  if (strcmp(tag, GST_TAG_TITLE) == 0)
  {
    gst_tag_list_get_string(list, tag, &value);
    myForm->setTitle(QString(value));
    g_free(value);
  }
  else if (strcmp(tag, GST_TAG_ARTIST) == 0)
  {
    gst_tag_list_get_string(list, tag, &value);
    myForm->setArtist(QString(value));
    g_free(value);
  }
  else if (strcmp(tag, GST_TAG_ALBUM) == 0)
  {
    gst_tag_list_get_string(list, tag, &value);
    myForm->setAlbum(QString(value));
    g_free(value);
  }
}
Exemplo n.º 6
0
static void
play_cycle_track_selection (GstPlay * play, GstPlayTrackType track_type)
{
  const gchar *prop_cur, *prop_n, *prop_get, *name;
  gint cur = -1, n = -1;

  switch (track_type) {
    case GST_PLAY_TRACK_TYPE_AUDIO:
      prop_get = "get-audio-tags";
      prop_cur = "current-audio";
      prop_n = "n-audio";
      name = "audio";
      break;
    case GST_PLAY_TRACK_TYPE_VIDEO:
      prop_get = "get-video-tags";
      prop_cur = "current-video";
      prop_n = "n-video";
      name = "video";
      break;
    case GST_PLAY_TRACK_TYPE_SUBTITLE:
      prop_get = "get-text-tags";
      prop_cur = "current-text";
      prop_n = "n-text";
      name = "subtitle";
      break;
    default:
      return;
  }

  g_object_get (play->playbin, prop_cur, &cur, prop_n, &n, NULL);

  if (n < 1) {
    g_print ("No %s tracks.\n", name);
  } else if (n == 1) {
    g_print ("No other %s tracks to switch to.\n", name);
  } else {
    gchar *lcode = NULL, *lname = NULL;
    const gchar *lang = NULL;
    GstTagList *tags = NULL;

    cur = (cur + 1) % n;
    g_signal_emit_by_name (play->playbin, prop_get, cur, &tags);
    if (tags != NULL) {
      if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lcode))
        lang = gst_tag_get_language_name (lcode);
      else if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_NAME, &lname))
        lang = lname;
      gst_tag_list_unref (tags);
    }
    if (lang != NULL)
      g_print ("Switching to %s track %d of %d (%s).\n", name, cur + 1, n,
          lang);
    else
      g_print ("Switching to %s track %d of %d.\n", name, cur + 1, n);
    g_object_set (play->playbin, prop_cur, cur, NULL);
    g_free (lcode);
    g_free (lname);
  }
}
Exemplo n.º 7
0
static void
set_shout_metadata (const GstTagList * list, const gchar * tag,
    gpointer user_data)
{
  GstShout2send *shout2send = (GstShout2send *) user_data;
  char **shout_metadata = &(shout2send->songmetadata);
  char **song_artist = &(shout2send->songartist);
  char **song_title = &(shout2send->songtitle);

  gchar *value;

  GST_DEBUG ("tag: %s being added", tag);
  if (strcmp (tag, GST_TAG_ARTIST) == 0) {
    if (gst_tag_get_type (tag) == G_TYPE_STRING) {
      if (!gst_tag_list_get_string (list, tag, &value)) {
        GST_DEBUG ("Error reading \"%s\" tag value", tag);
        return;
      }

      if (*song_artist != NULL)
        g_free (*song_artist);

      *song_artist = g_strdup (value);
    }
  } else if (strcmp (tag, GST_TAG_TITLE) == 0) {
    if (gst_tag_get_type (tag) == G_TYPE_STRING) {
      if (!gst_tag_list_get_string (list, tag, &value)) {
        GST_DEBUG ("Error reading \"%s\" tag value", tag);
        return;
      }

      if (*song_title != NULL)
        g_free (*song_title);

      *song_title = g_strdup (value);
    }
  }

  if (*shout_metadata != NULL)
    g_free (*shout_metadata);


  if (*song_title && *song_artist) {
    *shout_metadata = g_strdup_printf ("%s - %s", *song_artist, *song_title);
  } else if (*song_title && *song_artist == NULL) {
    *shout_metadata = g_strdup_printf ("Unknown - %s", *song_title);
  } else if (*song_title == NULL && *song_artist) {
    *shout_metadata = g_strdup_printf ("%s - Unknown", *song_artist);
  } else {
    *shout_metadata = g_strdup_printf ("Unknown - Unknown");
  }

  GST_LOG ("shout metadata is now: %s", *shout_metadata);
}
Exemplo n.º 8
0
/* Callback function invoked when a message arrives on the playback
 * pipeline's bus. */
static gboolean
bus_callback (GstBus *bus, GstMessage *message, gpointer data)
{
  switch (GST_MESSAGE_TYPE (message)) {
    case GST_MESSAGE_ERROR: {
      /* An error has occurred.
       * A real application would probably need to handle this more
       * intelligently than just quitting. */
      GError *err;
      gchar *debug;

      gst_message_parse_error(message, &err, &debug);
      g_print("Error: %s\n", err->message);
      g_error_free(err);
      g_free(debug);

      gtk_main_quit();
      break;
    }
  
    case GST_MESSAGE_EOS:
      /* The pipeline has reached the end of the stream. */
      g_print("End of stream\n");
      stop_playback();
      gui_status_update(STATE_STOP);
      break;

    case GST_MESSAGE_TAG: {
      /* The stream discovered new tags. */
      GstTagList *tags;
      gchar *title  = "";
      gchar *artist = "";
      /* Extract from the message the GstTagList.
       * This generates a copy, so we must remember to free it.*/
      gst_message_parse_tag(message, &tags);
      /* Extract the title and artist tags - if they exist */
      if (gst_tag_list_get_string(tags, GST_TAG_TITLE, &title)
	  && gst_tag_list_get_string(tags, GST_TAG_ARTIST, &artist))
	gui_update_metadata(title, artist);
      /* Free the tag list */
      gst_tag_list_free(tags);
      break;
    }

    default:
      /* Another message occurred which we are not interested in handling. */
      break;
  }

  /* We have handled this message, so indicate that it should be removed from
   * the queue.*/
  return TRUE;
}
Exemplo n.º 9
0
static gboolean bus_watch_handler(GstBus *bus, GstMessage *msg, gpointer data)
{
	struct ausrc_st *st = data;
	GMainLoop *loop = st->loop;
	GstTagList *tag_list;
	gchar *title;
	GError *err;
	gchar *d;

	(void)bus;

	switch (GST_MESSAGE_TYPE(msg)) {

	case GST_MESSAGE_EOS:
		/* XXX decrementing repeat count? */

		/* Re-start stream */
		if (st->run) {
			gst_element_set_state(st->pipeline, GST_STATE_NULL);
			gst_element_set_state(st->pipeline, GST_STATE_PLAYING);
		}
		else {
			g_main_loop_quit(loop);
		}
		break;

	case GST_MESSAGE_ERROR:
		gst_message_parse_error(msg, &err, &d);

		warning("gst: Error: %d(%m) message=\"%s\"\n", err->code,
			err->code, err->message);
		warning("gst: Debug: %s\n", d);

		g_free(d);

		/* Call error handler */
		if (st->errh)
			st->errh(err->code, err->message, st->arg);

		g_error_free(err);

		st->run = false;
		g_main_loop_quit(loop);
		break;

	case GST_MESSAGE_TAG:
		gst_message_parse_tag(msg, &tag_list);

		if (gst_tag_list_get_string(tag_list, GST_TAG_TITLE, &title)) {
			info("gst: title: %s\n", title);
			g_free(title);
		}
		break;

	default:
		break;
	}

	return TRUE;
}
Exemplo n.º 10
0
static void
set_language (SnraClient * client)
{
  gint num_audio, cur_audio, i;

  g_object_get (client->player, "n-audio", &num_audio, "current-audio",
      &cur_audio, NULL);

  for (i = 0; i < num_audio; i++) {
    GstTagList *tags;
    gchar *str = NULL;
    gboolean found = FALSE;

    g_signal_emit_by_name (client->player, "get-audio-tags", i, &tags);
    if (!tags)
      continue;

    if (gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &str))
      found = g_str_equal (client->language, str);

    gst_tag_list_free (tags);
    g_free (str);

    if (found) {
      g_object_set (client->player, "current-audio", i, NULL);
      break;
    }
  }
}
Exemplo n.º 11
0
static gboolean
gst_wavenc_parse_labl (GstWavEnc * wavenc, guint32 id, GstTocEntry * entry)
{
  gchar *tag;
  GstTagList *tags;
  GstWavEncLabl *labl;

  g_return_val_if_fail (entry != NULL, FALSE);

  tags = gst_toc_entry_get_tags (entry);
  if (!tags) {
    GST_INFO_OBJECT (wavenc, "no tags for entry: %d", id);
    return FALSE;
  }
  if (!gst_tag_list_get_string (tags, GST_TAG_TITLE, &tag)) {
    GST_INFO_OBJECT (wavenc, "no title tag for entry: %d", id);
    return FALSE;
  }

  labl = g_new (GstWavEncLabl, 1);
  memcpy (labl->chunk_id, "labl", 4);
  labl->chunk_data_size = 4 + strlen (tag) + 1;
  labl->cue_point_id = id;
  labl->text = tag;

  GST_DEBUG_OBJECT (wavenc, "got labl: '%s'", tag);

  wavenc->labls = g_list_append (wavenc->labls, labl);

  return TRUE;
}
Exemplo n.º 12
0
static gboolean
gst_wavenc_parse_note (GstWavEnc * wavenc, guint32 id, GstTocEntry * entry)
{
  gchar *tag;
  GstTagList *tags;
  GstWavEncNote *note;

  g_return_val_if_fail (entry != NULL, FALSE);
  tags = gst_toc_entry_get_tags (entry);
  if (!tags) {
    GST_INFO_OBJECT (wavenc, "no tags for entry: %d", id);
    return FALSE;
  }
  if (!gst_tag_list_get_string (tags, GST_TAG_COMMENT, &tag)) {
    GST_INFO_OBJECT (wavenc, "no comment tag for entry: %d", id);
    return FALSE;
  }

  note = g_new (GstWavEncNote, 1);
  memcpy (note->chunk_id, "note", 4);
  note->chunk_data_size = 4 + strlen (tag) + 1;
  note->cue_point_id = id;
  note->text = tag;

  GST_DEBUG_OBJECT (wavenc, "got note: '%s'", tag);

  wavenc->notes = g_list_append (wavenc->notes, note);

  return TRUE;
}
Exemplo n.º 13
0
static gboolean
gst_vdp_sink_event (GstBaseSink * sink, GstEvent * event)
{
  VdpSink *vdp_sink = GST_VDP_SINK (sink);

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_TAG:{
      GstTagList *l;
      gchar *title = NULL;

      gst_event_parse_tag (event, &l);
      gst_tag_list_get_string (l, GST_TAG_TITLE, &title);

      if (title) {
        GST_DEBUG_OBJECT (vdp_sink, "got tags, title='%s'", title);
        gst_vdp_sink_window_set_title (vdp_sink, vdp_sink->window, title);

        g_free (title);
      }
      break;
    }
    default:
      break;
  }
  if (GST_BASE_SINK_CLASS (parent_class)->event)
    return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
  else
    return TRUE;
}
Exemplo n.º 14
0
P_INVOKE gchar *
bp_get_subtitle_description (BansheePlayer *player, int i)
{
    gchar *code = NULL;
    gchar *desc = NULL;
    GstTagList *tags = NULL;

    g_return_val_if_fail (IS_BANSHEE_PLAYER (player), NULL);

    g_signal_emit_by_name (G_OBJECT (player->playbin), "get-text-tags", i, &tags);
    if (G_LIKELY(tags)) {
        gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &code);
        gst_tag_list_free (tags);

        g_return_val_if_fail (code != NULL, NULL);

        // ISO 639-2 undetermined language
        if (strcmp ((const gchar *)code, "und") == 0) {
            g_free (code);
            return NULL;
        }
        bp_debug ("[subtitle]: iso 639-2 subtitle code %s", code);
        desc = (gchar *) gst_tag_get_language_name ((const gchar *)&code);
        bp_debug ("[subtitle]: subtitle language: %s", desc);

        g_free (code);
    }
    return desc;
}
Exemplo n.º 15
0
static void gst_avdtp_sink_tag(const GstTagList *taglist,
			const gchar *tag, gpointer user_data)
{
	gboolean crc;
	gchar *channel_mode = NULL;
	GstAvdtpSink *self = GST_AVDTP_SINK(user_data);

	if (strcmp(tag, "has-crc") == 0) {

		if (!gst_tag_list_get_boolean(taglist, tag, &crc)) {
			GST_WARNING_OBJECT(self, "failed to get crc tag");
			return;
		}

		gst_avdtp_sink_set_crc(self, crc);

	} else if (strcmp(tag, "channel-mode") == 0) {

		if (!gst_tag_list_get_string(taglist, tag, &channel_mode)) {
			GST_WARNING_OBJECT(self,
				"failed to get channel-mode tag");
			return;
		}

		self->channel_mode = gst_avdtp_sink_get_channel_mode(
					channel_mode);
		if (self->channel_mode == -1)
			GST_WARNING_OBJECT(self, "Received invalid channel "
					"mode: %s", channel_mode);
		g_free(channel_mode);

	} else
		GST_DEBUG_OBJECT(self, "received unused tag: %s", tag);
}
Exemplo n.º 16
0
static void
CHECK_TOC (GstToc * toc_t)
{
  GstTocEntry *entry_t, *subentry_t;
  GstTagList *tags;
  GList *entries, *subentries, *subsubentries;
  gchar *tag_t;

  /* dump TOC */
  gst_toc_dump (toc_t);

  /* check TOC */
  tags = gst_toc_get_tags (toc_t);
  fail_unless (tags != NULL);
  fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &tag_t));
  fail_unless_equals_string (tag_t, TOC_TAG);
  g_free (tag_t);

  entries = gst_toc_get_entries (toc_t);
  fail_unless_equals_int (g_list_length (entries), 2);

  /* check edition1 */
  entry_t = g_list_nth_data (entries, 0);
  fail_if (entry_t == NULL);
  subentries = gst_toc_entry_get_sub_entries (entry_t);
  fail_unless_equals_int (g_list_length (subentries), 2);
  CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED1);
  /* check chapter1 */
  subentry_t = g_list_nth_data (subentries, 0);
  fail_if (subentry_t == NULL);
  subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
  fail_unless_equals_int (g_list_length (subsubentries), 0);
  CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH1);
  /* check chapter2 */
  subentry_t = g_list_nth_data (subentries, 1);
  fail_if (subentry_t == NULL);
  subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
  fail_unless_equals_int (g_list_length (subsubentries), 0);
  CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH2);

  /* check edition2 */
  entry_t = g_list_nth_data (entries, 1);
  fail_if (entry_t == NULL);
  CHECK_TOC_ENTRY (entry_t, GST_TOC_ENTRY_TYPE_EDITION, ENTRY_ED2);
  subentries = gst_toc_entry_get_sub_entries (entry_t);
  fail_unless_equals_int (g_list_length (subentries), 1);
  /* check chapter3 */
  subentry_t = g_list_nth_data (subentries, 0);
  fail_if (subentry_t == NULL);
  CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_CH3);
  subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
  fail_unless_equals_int (g_list_length (subsubentries), 1);
  /* check subchapter1 */
  subentry_t = g_list_nth_data (subsubentries, 0);
  fail_if (subentry_t == NULL);
  CHECK_TOC_ENTRY (subentry_t, GST_TOC_ENTRY_TYPE_CHAPTER, ENTRY_SUB1);
  subsubentries = gst_toc_entry_get_sub_entries (subentry_t);
  fail_unless_equals_int (g_list_length (subsubentries), 0);
}
Exemplo n.º 17
0
static void
check_wcop (const GstTagList * tags, const gchar * file)
{
  gchar *copyright = NULL;
  gchar *uri = NULL;

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_LICENSE_URI, &uri));
  fail_unless (uri != NULL);
  fail_unless_equals_string (uri,
      "http://creativecommons.org/licenses/by/3.0/");
  g_free (uri);

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_COPYRIGHT, &copyright));
  fail_unless (copyright != NULL);
  fail_unless_equals_string (copyright,
      " Steadman. Licensed to the public under http://creativecommons.org/licenses/by/3.0/ verify at http://test.com");
  g_free (copyright);
}
Exemplo n.º 18
0
bool TrackPrivateBaseGStreamer::getTag(GstTagList* tags, const gchar* tagName, StringType& value)
{
    GUniqueOutPtr<gchar> tagValue;
    if (gst_tag_list_get_string(tags, tagName, &tagValue.outPtr())) {
        INFO_MEDIA_MESSAGE("Track %d got %s %s.", m_index, tagName, tagValue.get());
        value = tagValue.get();
        return true;
    }
    return false;
}
Exemplo n.º 19
0
static void
check_unsync_v24 (const GstTagList * tags, const gchar * file)
{
  const GValue *val;
  GstSample *sample;
  GstBuffer *buf;
  gchar *album = NULL;
  gchar *title = NULL;
  gchar *artist = NULL;
  GstMapInfo map;

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &title));
  fail_unless (title != NULL);
  fail_unless_equals_string (title, "Starlight");
  g_free (title);

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &album));
  fail_unless (album != NULL);
  fail_unless_equals_string (album, "L'albumRockVol.4 CD1");
  g_free (album);

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &artist));
  fail_unless (artist != NULL);
  fail_unless_equals_string (artist, "Muse");
  g_free (artist);

  val = gst_tag_list_get_value_index (tags, GST_TAG_IMAGE, 0);
  fail_unless (val != NULL);
  fail_unless (GST_VALUE_HOLDS_SAMPLE (val));
  sample = gst_value_get_sample (val);
  fail_unless (sample != NULL);
  fail_unless (gst_sample_get_caps (sample) != NULL);
  buf = gst_sample_get_buffer (sample);
  fail_unless (buf != NULL);
  gst_buffer_map (buf, &map, GST_MAP_READ);
  fail_unless_equals_int (map.size, 38022);
  /* check for jpeg start/end markers */
  fail_unless_equals_int (map.data[0], 0xff);
  fail_unless_equals_int (map.data[1], 0xd8);
  fail_unless_equals_int (map.data[38020], 0xff);
  fail_unless_equals_int (map.data[38021], 0xd9);
  gst_buffer_unmap (buf, &map);
}
Exemplo n.º 20
0
void track_from_tag(const GstTagList* tag, Track* track)
{
  gchar* value = 0;
  
  if (gst_tag_list_get_string(tag, GST_TAG_TITLE, &value)){
    track->title = value;
    g_free(value);
  }
  
  if (gst_tag_list_get_string(tag, GST_TAG_ARTIST, &value)){
    track->artist = value;
    g_free(value);
  }
  
  if (gst_tag_list_get_string(tag, GST_TAG_ALBUM, &value)){
    track->album = value;
    g_free(value);
  }
}
Exemplo n.º 21
0
/**
 * Pipeline callback for when tags are found.
 * @param list
 * @param tag
 * @param user_data
 */
static void insert_tags (const GstTagList * list, const gchar * tag, gpointer user_data) {

    
    gchar *title, *album, *artist;
    gchar *zErrMsg = 0; /* SQL error message */
    gchar sql[512]; /* create oversized buffer */
    
    gst_tag_list_get_string(list, "title", &title);
    gst_tag_list_get_string(list, "album", &album);
    gst_tag_list_get_string(list, "artist", &artist);

    memset(sql, '\0', sizeof(sql));
    sprintf(sql, "INSERT INTO %s VALUES (\"%s\", \"%s\", \"%s\")", TABLE, title, album, artist);
    
    if( sqlite3_exec(database, sql, NULL, NULL, &zErrMsg) != SQLITE_OK ){
            fprintf(stderr, "SQL error: %s\n", zErrMsg);
            sqlite3_free(zErrMsg);
    }
}
Exemplo n.º 22
0
static gboolean
bus_handler (GstBus * bus, GstMessage * message, gpointer data)
{
  GMainLoop *loop = (GMainLoop *) data;

  switch (message->type) {
    case GST_MESSAGE_EOS:
      g_main_loop_quit (loop);
      break;
    case GST_MESSAGE_WARNING:
    case GST_MESSAGE_ERROR:{
      GError *gerror;
      gchar *debug;

      if (message->type == GST_MESSAGE_WARNING)
        gst_message_parse_warning (message, &gerror, &debug);
      else
        gst_message_parse_error (message, &gerror, &debug);
      gst_object_default_error (GST_MESSAGE_SRC (message), gerror, debug);
      gst_message_unref (message);
      g_error_free (gerror);
      g_free (debug);
      g_main_loop_quit (loop);
      break;
    }
    case GST_MESSAGE_TAG:
    {
      GstTagList *tag_list;
      gchar *fpr, *p;

      gst_message_parse_tag (message, &tag_list);

      fail_unless (gst_tag_list_get_string (tag_list, "ofa-fingerprint", &fpr));

      p = fpr;
      while (*p) {
        fail_unless (g_ascii_isalnum (*p) || *p == '=' || *p == '+'
            || *p == '/');
        p++;
      }

      g_free (fpr);
      gst_tag_list_unref (tag_list);

      found_fingerprint = TRUE;

      g_main_loop_quit (loop);
      break;
    }
    default:
      break;
  }

  return TRUE;
}
static gboolean
sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
  GST_DEBUG_OBJECT (pad, "Got %s event %p: %" GST_PTR_FORMAT,
      GST_EVENT_TYPE_NAME (event), event, event);

  switch (GST_EVENT_TYPE (event)) {
    case GST_EVENT_EOS:
      if (loop) {
        while (!g_main_loop_is_running (loop));
      }

      have_eos = TRUE;
      if (loop)
        g_main_loop_quit (loop);
      break;
    case GST_EVENT_CAPS:
    {
      GstCaps *caps;

      gst_event_parse_caps (event, &caps);
      sink_check_caps (pad, caps);
      break;
    }
    case GST_EVENT_TAG:
    {
      int i, ret;
      gchar *buf = NULL;
      GstTagList *aiff_tags = NULL;
      const gchar *tags[][2] = {
        {"title", "Title"}, {"artist", "Artist"},
      };

      gst_event_parse_tag (event, &aiff_tags);
      fail_unless (aiff_tags != NULL);

      for (i = 0; i < sizeof (tags) / sizeof (*tags); i++) {
        buf = NULL;
        fail_unless (gst_tag_list_get_string (aiff_tags, tags[i][0], &buf));
        ret = g_strcmp0 (buf, tags[i][1]);
        g_free (buf);
        fail_unless (ret == 0);
      }

      have_tags = TRUE;
      break;
    }
    default:
      break;
  }

  gst_event_unref (event);

  return TRUE;
}
Exemplo n.º 24
0
static void internal_bus_watch_handler(struct gst_video_state *st)
{
	GstTagList *tag_list;
	gchar *title;
	GError *err;
	gchar *d;

	GstMessage *msg = gst_bus_pop(st->bus);

	if (!msg) {
		// take a nap (300ms)
		usleep(300 * 1000);
		return;
	}

	switch (GST_MESSAGE_TYPE(msg)) {

	case GST_MESSAGE_EOS:

		/* XXX decrementing repeat count? */

		/* Re-start stream */
		gst_element_set_state(st->pipeline, GST_STATE_NULL);
		gst_element_set_state(st->pipeline, GST_STATE_PLAYING);
		break;

	case GST_MESSAGE_ERROR:
		gst_message_parse_error(msg, &err, &d);

		DEBUG_WARNING("Error: %d(%m) message=%s\n", err->code,
			      err->code, err->message);
		DEBUG_WARNING("Debug: %s\n", d);

		g_free(d);
		g_error_free(err);

		st->run = FALSE;
		break;

	case GST_MESSAGE_TAG:
		gst_message_parse_tag(msg, &tag_list);

		if (gst_tag_list_get_string(tag_list, GST_TAG_TITLE, &title)) {
			DEBUG_NOTICE("Title: %s\n", title);
			g_free(title);
		}
		break;

	default:
		break;
	}

	gst_message_unref(msg);
}
Exemplo n.º 25
0
QString GstEnginePipeline::ParseTag(GstTagList* list, const char* tag) const {
  gchar* data = nullptr;
  bool success = gst_tag_list_get_string(list, tag, &data);

  QString ret;
  if (success && data) {
    ret = QString::fromUtf8(data);
    g_free(data);
  }
  return ret.trimmed();
}
Exemplo n.º 26
0
static gboolean
gst_a2dp_sink_init_dynamic_elements (GstA2dpSink * self, GstCaps * caps)
{
  GstStructure *structure;
  GstEvent *event;
  gboolean crc;
  gchar *mode = NULL;

  structure = gst_caps_get_structure (caps, 0);

  /* first, we need to create our rtp payloader */
  if (gst_structure_has_name (structure, "audio/x-sbc")) {
    GST_LOG_OBJECT (self, "sbc media received");
    if (!gst_a2dp_sink_init_rtp_sbc_element (self))
      return FALSE;
  } else if (gst_structure_has_name (structure, "audio/mpeg")) {
    GST_LOG_OBJECT (self, "mp3 media received");
    if (!gst_a2dp_sink_init_rtp_mpeg_element (self))
      return FALSE;
  } else {
    GST_ERROR_OBJECT (self, "Unexpected media type");
    return FALSE;
  }

  if (!gst_element_link (GST_ELEMENT (self->rtp), GST_ELEMENT (self->sink))) {
    GST_ERROR_OBJECT (self, "couldn't link rtpsbcpay " "to avdtpsink");
    return FALSE;
  }

  /* check if we should push the taglist FIXME should we push this?
   * we can send the tags directly if needed */
  if (self->taglist != NULL && gst_structure_has_name (structure, "audio/mpeg")) {

    event = gst_event_new_tag (self->taglist);

    /* send directly the crc */
    if (gst_tag_list_get_boolean (self->taglist, "has-crc", &crc))
      gst_avdtp_sink_set_crc (self->sink, crc);

    if (gst_tag_list_get_string (self->taglist, "channel-mode", &mode))
      gst_avdtp_sink_set_channel_mode (self->sink, mode);

    gst_pad_send_event (self->ghostpad, event);

    self->taglist = NULL;
    g_free (mode);
  }

  g_object_set (self->rtp, "mtu",
      gst_avdtp_sink_get_link_mtu (self->sink), NULL);

  return TRUE;
}
Exemplo n.º 27
0
static void
gst_wavparse_tags_foreach (const GstTagList * tags, const gchar * tag,
    gpointer data)
{
  const struct
  {
    guint32 fcc;
    const gchar *tag;
  } rifftags[] = {
    {
    GST_RIFF_INFO_IARL, GST_TAG_LOCATION}, {
    GST_RIFF_INFO_IART, GST_TAG_ARTIST}, {
    GST_RIFF_INFO_ICMT, GST_TAG_COMMENT}, {
    GST_RIFF_INFO_ICOP, GST_TAG_COPYRIGHT}, {
    GST_RIFF_INFO_ICRD, GST_TAG_DATE}, {
    GST_RIFF_INFO_IGNR, GST_TAG_GENRE}, {
    GST_RIFF_INFO_IKEY, GST_TAG_KEYWORDS}, {
    GST_RIFF_INFO_INAM, GST_TAG_TITLE}, {
    GST_RIFF_INFO_IPRD, GST_TAG_ALBUM}, {
    GST_RIFF_INFO_ISBJ, GST_TAG_ALBUM_ARTIST}, {
    GST_RIFF_INFO_ISFT, GST_TAG_ENCODER}, {
    GST_RIFF_INFO_ISRC, GST_TAG_ISRC}, {
    0, NULL}
  };
  gint n;
  gchar *str = NULL;
  GstByteWriter *bw = data;
  for (n = 0; rifftags[n].fcc != 0; n++) {
    if (!strcmp (rifftags[n].tag, tag)) {
      if (rifftags[n].fcc == GST_RIFF_INFO_ICRD) {
        GDate *date;
        /* special case for the date tag */
        if (gst_tag_list_get_date (tags, tag, &date)) {
          str =
              g_strdup_printf ("%04d:%02d:%02d", g_date_get_year (date),
              g_date_get_month (date), g_date_get_day (date));
          g_date_free (date);
        }
      } else {
        gst_tag_list_get_string (tags, tag, &str);
      }
      if (str) {
        gst_byte_writer_put_uint32_le (bw, rifftags[n].fcc);
        gst_byte_writer_put_uint32_le (bw, GST_ROUND_UP_2 (strlen (str)));
        gst_byte_writer_put_string (bw, str);
        g_free (str);
        str = NULL;
        break;
      }
    }
  }

}
Exemplo n.º 28
0
static void
check_unsync_v23 (const GstTagList * tags, const gchar * file)
{
  gchar *album = NULL;
  gchar *title = NULL;
  gchar *artist = NULL;

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_TITLE, &title));
  fail_unless (title != NULL);
  fail_unless_equals_string (title, "ARTIST");  /* sic */
  g_free (title);

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_ALBUM, &album));
  fail_unless (album != NULL);
  fail_unless_equals_string (album, "Album");
  g_free (album);

  fail_unless (gst_tag_list_get_string (tags, GST_TAG_ARTIST, &artist));
  fail_unless (artist != NULL);
  fail_unless_equals_string (artist, "藝人");
  g_free (artist);
}
Exemplo n.º 29
0
static gboolean
cb_probe (GstPad * pad, GstEvent * e, gpointer user_data)
{
  GstStreamInfo *info = user_data;

  if (GST_EVENT_TYPE (e) == GST_EVENT_TAG) {
    gchar *codec, *lang;
    GstTagList *list;

    gst_event_parse_tag (e, &list);

    if (info->type != GST_STREAM_TYPE_AUDIO &&
        gst_tag_list_get_string (list, GST_TAG_VIDEO_CODEC, &codec)) {
      g_free (info->codec);
      info->codec = codec;
      GST_LOG_OBJECT (pad, "codec = %s (video)", codec);
      g_object_notify (G_OBJECT (info), "codec");
    } else if (info->type != GST_STREAM_TYPE_VIDEO &&
        gst_tag_list_get_string (list, GST_TAG_AUDIO_CODEC, &codec)) {
      g_free (info->codec);
      info->codec = codec;
      GST_LOG_OBJECT (pad, "codec = %s (audio)", codec);
      g_object_notify (G_OBJECT (info), "codec");
    } else if (gst_tag_list_get_string (list, GST_TAG_CODEC, &codec)) {
      g_free (info->codec);
      info->codec = codec;
      GST_LOG_OBJECT (pad, "codec = %s (generic)", codec);
      g_object_notify (G_OBJECT (info), "codec");
    }
    if (gst_tag_list_get_string (list, GST_TAG_LANGUAGE_CODE, &lang)) {
      g_free (info->langcode);
      info->langcode = lang;
      GST_LOG_OBJECT (pad, "language-code = %s", lang);
      g_object_notify (G_OBJECT (info), "language-code");
    }
  }

  return TRUE;
}
void InbandTextTrackPrivateGStreamer::notifyTrackOfTagsChanged()
{
    m_tagTimerHandler = 0;
    if (!m_pad)
        return;

    String label;
    String language;
    GRefPtr<GstEvent> event;
    for (guint i = 0; (event = adoptGRef(gst_pad_get_sticky_event(m_pad.get(), GST_EVENT_TAG, i))); ++i) {
        GstTagList* tags = 0;
        gst_event_parse_tag(event.get(), &tags);
        ASSERT(tags);

        gchar* tagValue;
        if (gst_tag_list_get_string(tags, GST_TAG_TITLE, &tagValue)) {
            INFO_MEDIA_MESSAGE("Text track %d got title %s.", m_index, tagValue);
            label = tagValue;
            g_free(tagValue);
        }

        if (gst_tag_list_get_string(tags, GST_TAG_LANGUAGE_CODE, &tagValue)) {
            INFO_MEDIA_MESSAGE("Text track %d got language %s.", m_index, tagValue);
            language = tagValue;
            g_free(tagValue);
        }
    }

    if (m_label != label) {
        m_label = label;
        client()->labelChanged(this, m_label);
    }

    if (m_language != language) {
        m_language = language;
        client()->languageChanged(this, m_language);
    }
}