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); }
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; }
static gboolean gst_a2dp_sink_init_dynamic_elements(GstA2dpSink *self, GstCaps *caps) { GstStructure *structure; GstEvent *event; GstPad *capsfilterpad; gboolean crc; gchar *mode = NULL; structure = gst_caps_get_structure(caps, 0); /* before everything we need to remove fakesink */ gst_a2dp_sink_remove_fakesink(self); /* 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_a2dp_sink_init_avdtp_sink(self)) 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); capsfilterpad = gst_ghost_pad_get_target(self->ghostpad); gst_pad_send_event(capsfilterpad, event); self->taglist = NULL; g_free(mode); } if (!gst_avdtp_sink_set_device_caps(self->sink, caps)) return FALSE; g_object_set(G_OBJECT(self->rtp), "mtu", gst_avdtp_sink_get_link_mtu(self->sink), NULL); /* we forward our new segment here if we have one */ if (self->newseg_event) { gst_pad_send_event(GST_BASE_RTP_PAYLOAD_SINKPAD(self->rtp), self->newseg_event); self->newseg_event = NULL; } return TRUE; }
static void add_metadata_from_tag (GFileInfo *info, const GstTagList *list, const char *tag, const char *tag_key) { GType tag_type; tag_type = gst_tag_get_type (tag); if (tag_type == G_TYPE_BOOLEAN) { gboolean ret; if (gst_tag_list_get_boolean (list, tag, &ret)) { if (ret) add_metadata (info, tag_key, g_strdup ("TRUE"), NULL); else add_metadata (info, tag_key, g_strdup ("FALSE"), NULL); } } if (tag_type == G_TYPE_STRING) { char *ret = NULL; if (gst_tag_list_get_string (list, tag, &ret)) add_metadata (info, tag_key, ret, NULL); } if (tag_type == G_TYPE_UCHAR) { guint ret = 0; if (gst_tag_list_get_uint (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%u", ret), NULL); } if (tag_type == G_TYPE_CHAR) { int ret = 0; if (gst_tag_list_get_int (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%d", ret), NULL); } if (tag_type == G_TYPE_UINT) { guint ret = 0; if (gst_tag_list_get_uint (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%u", ret), NULL); } if (tag_type == G_TYPE_INT) { gint ret = 0; if (gst_tag_list_get_int (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%d", ret), NULL); } if (tag_type == G_TYPE_ULONG) { guint64 ret = 0; if (gst_tag_list_get_uint64 (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%" G_GUINT64_FORMAT, ret), NULL); } if (tag_type == G_TYPE_LONG) { gint64 ret = 0; if (gst_tag_list_get_int64 (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%" G_GINT64_FORMAT, ret), NULL); } if (tag_type == G_TYPE_INT64) { gint64 ret = 0; if (gst_tag_list_get_int64 (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%" G_GINT64_FORMAT, ret), NULL); } if (tag_type == G_TYPE_UINT64) { guint64 ret = 0; if (gst_tag_list_get_uint64 (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%" G_GUINT64_FORMAT, ret), NULL); } if (tag_type == G_TYPE_DOUBLE) { gdouble ret = 0; if (gst_tag_list_get_double (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%f", ret), NULL); } if (tag_type == G_TYPE_FLOAT) { gfloat ret = 0; if (gst_tag_list_get_float (list, tag, &ret)) add_metadata (info, tag_key, g_strdup_printf ("%f", ret), NULL); } if (tag_type == G_TYPE_DATE) { GDate *ret = NULL; if (gst_tag_list_get_date (list, tag, &ret)) { if (ret != NULL) { char buf[128]; char *raw; char *formatted; g_date_strftime (buf, 10, "%F %T", ret); raw = g_strdup (buf); g_date_strftime (buf, 10, "%x %X", ret); formatted = g_strdup (buf); add_metadata (info, tag_key, raw, formatted); } g_free (ret); } } }