pulse: add properties to GstDevice

Add the extra properties we get from pulse to the GstDevice we expose
with the device monitor
This commit is contained in:
Wim Taymans 2015-07-15 18:23:05 +02:00
parent 1c00801585
commit 0421d40d9c
3 changed files with 35 additions and 5 deletions

View file

@ -40,7 +40,7 @@ GST_DEBUG_CATEGORY_EXTERN (pulse_debug);
static GstDevice *gst_pulse_device_new (guint id,
const gchar * device_name, GstCaps * caps, const gchar * internal_name,
GstPulseDeviceType type);
GstPulseDeviceType type, GstStructure * properties);
G_DEFINE_TYPE (GstPulseDeviceProvider, gst_pulse_device_provider,
GST_TYPE_DEVICE_PROVIDER);
@ -189,6 +189,7 @@ static GstDevice *
new_source (const pa_source_info * info)
{
GstCaps *caps;
GstStructure *props;
guint i;
caps = gst_caps_new_empty ();
@ -196,14 +197,17 @@ new_source (const pa_source_info * info)
for (i = 0; i < info->n_formats; i++)
gst_caps_append (caps, gst_pulse_format_info_to_caps (info->formats[i]));
props = gst_pulse_make_structure (info->proplist);
return gst_pulse_device_new (info->index, info->description,
caps, info->name, GST_PULSE_DEVICE_TYPE_SOURCE);
caps, info->name, GST_PULSE_DEVICE_TYPE_SOURCE, props);
}
static GstDevice *
new_sink (const pa_sink_info * info)
{
GstCaps *caps;
GstStructure *props;
guint i;
caps = gst_caps_new_empty ();
@ -211,8 +215,10 @@ new_sink (const pa_sink_info * info)
for (i = 0; i < info->n_formats; i++)
gst_caps_append (caps, gst_pulse_format_info_to_caps (info->formats[i]));
props = gst_pulse_make_structure (info->proplist);
return gst_pulse_device_new (info->index, info->description,
caps, info->name, GST_PULSE_DEVICE_TYPE_SINK);
caps, info->name, GST_PULSE_DEVICE_TYPE_SINK, props);
}
static void
@ -603,7 +609,8 @@ gst_pulse_device_reconfigure_element (GstDevice * device, GstElement * element)
static GstDevice *
gst_pulse_device_new (guint device_index, const gchar * device_name,
GstCaps * caps, const gchar * internal_name, GstPulseDeviceType type)
GstCaps * caps, const gchar * internal_name, GstPulseDeviceType type,
GstStructure * props)
{
GstPulseDevice *gstdev;
const gchar *element = NULL;
@ -631,7 +638,7 @@ gst_pulse_device_new (guint device_index, const gchar * device_name,
gstdev = g_object_new (GST_TYPE_PULSE_DEVICE,
"display-name", device_name, "caps", caps, "device-class", klass,
"internal-name", internal_name, NULL);
"internal-name", internal_name, "properties", props, NULL);
gstdev->type = type;
gstdev->device_index = device_index;

View file

@ -376,6 +376,28 @@ gst_pulse_make_proplist (const GstStructure * properties)
return proplist;
}
GstStructure *
gst_pulse_make_structure (pa_proplist * properties)
{
GstStructure *str;
void *state = NULL;
str = gst_structure_new_empty ("pulse-proplist");
while (TRUE) {
const char *key, *val;
key = pa_proplist_iterate (properties, &state);
if (key == NULL)
break;
val = pa_proplist_gets (properties, key);
gst_structure_set (str, key, G_TYPE_STRING, val, NULL);
}
return str;
}
static gboolean
gst_pulse_format_info_int_prop_to_value (pa_format_info * format,
const char *key, GValue * value)

View file

@ -87,6 +87,7 @@ GstAudioRingBufferSpec *gst_pulse_channel_map_to_gst (const pa_channel_map * map
void gst_pulse_cvolume_from_linear (pa_cvolume *v, unsigned channels, gdouble volume);
pa_proplist *gst_pulse_make_proplist (const GstStructure *properties);
GstStructure *gst_pulse_make_structure (pa_proplist *properties);
GstCaps * gst_pulse_format_info_to_caps (pa_format_info * format);