tools: device-monitor: Add support for modified devices

This commit is contained in:
Thibault Saunier 2019-01-30 10:49:37 -03:00 committed by Olivier Crête
parent 3152cbb46e
commit 78431e7887

View file

@ -160,7 +160,7 @@ print_structure_field (GQuark field_id, const GValue * value,
} }
static void static void
device_added (GstDevice * device) print_device (GstDevice * device, gboolean modified)
{ {
gchar *device_class, *str, *name; gchar *device_class, *str, *name;
GstCaps *caps; GstCaps *caps;
@ -175,7 +175,7 @@ device_added (GstDevice * device)
device_class = gst_device_get_device_class (device); device_class = gst_device_get_device_class (device);
props = gst_device_get_properties (device); props = gst_device_get_properties (device);
g_print ("\nDevice found:\n\n"); g_print ("\nDevice %s:\n\n", modified ? "modified" : "found");
g_print ("\tname : %s\n", name); g_print ("\tname : %s\n", name);
g_print ("\tclass : %s\n", device_class); g_print ("\tclass : %s\n", device_class);
for (i = 0; i < size; ++i) { for (i = 0; i < size; ++i) {
@ -226,7 +226,7 @@ bus_msg_handler (GstBus * bus, GstMessage * msg, gpointer user_data)
switch (GST_MESSAGE_TYPE (msg)) { switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_DEVICE_ADDED: case GST_MESSAGE_DEVICE_ADDED:
gst_message_parse_device_added (msg, &device); gst_message_parse_device_added (msg, &device);
device_added (device); print_device (device, FALSE);
gst_object_unref (device); gst_object_unref (device);
break; break;
case GST_MESSAGE_DEVICE_REMOVED: case GST_MESSAGE_DEVICE_REMOVED:
@ -234,6 +234,11 @@ bus_msg_handler (GstBus * bus, GstMessage * msg, gpointer user_data)
device_removed (device); device_removed (device);
gst_object_unref (device); gst_object_unref (device);
break; break;
case GST_MESSAGE_DEVICE_CHANGED:
gst_message_parse_device_changed (msg, &device, NULL);
print_device (device, TRUE);
gst_object_unref (device);
break;
default: default:
g_print ("%s message\n", GST_MESSAGE_TYPE_NAME (msg)); g_print ("%s message\n", GST_MESSAGE_TYPE_NAME (msg));
break; break;
@ -344,7 +349,7 @@ main (int argc, char **argv)
while (devices != NULL) { while (devices != NULL) {
GstDevice *device = devices->data; GstDevice *device = devices->data;
device_added (device); print_device (device, FALSE);
gst_object_unref (device); gst_object_unref (device);
devices = g_list_delete_link (devices, devices); devices = g_list_delete_link (devices, devices);
} }