[Bug 794481] New: Callbacks from gstreamer's device monitor do not seem to work

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Mon Mar 19 09:50:31 UTC 2018


https://bugzilla.gnome.org/show_bug.cgi?id=794481

            Bug ID: 794481
           Summary: Callbacks from gstreamer's device monitor do not seem
                    to work
    Classification: Platform
           Product: GStreamer
           Version: unspecified
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gstreamer (core)
          Assignee: gstreamer-bugs at lists.freedesktop.org
          Reporter: rion4ik at gmail.com
        QA Contact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---

Hi

I just tried the example code from
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstDeviceMonitor.html

and forged a small application to test the callbacks.

#include <gst/gst.h>
#include <glib.h>

static gboolean
my_bus_func (GstBus * bus, GstMessage * message, gpointer user_data)
{
   GstDevice *device;
   gchar *name;

   switch (GST_MESSAGE_TYPE (message)) {
     case GST_MESSAGE_DEVICE_ADDED:
       gst_message_parse_device_added (message, &device);
       name = gst_device_get_display_name (device);
       g_print("Device added: %s\n", name);
       g_free (name);
       gst_object_unref (device);
       break;
     case GST_MESSAGE_DEVICE_REMOVED:
       gst_message_parse_device_removed (message, &device);
       name = gst_device_get_display_name (device);
       g_print("Device removed: %s\n", name);
       g_free (name);
       gst_object_unref (device);
       break;
     default:
       break;
   }

   return G_SOURCE_CONTINUE;
}

GstDeviceMonitor *
setup_raw_video_source_device_monitor (void) {
   GstDeviceMonitor *monitor;
   GstBus *bus;
   GstCaps *caps;

   monitor = gst_device_monitor_new ();

   bus = gst_device_monitor_get_bus (monitor);
   gst_bus_add_watch (bus, my_bus_func, NULL);
   gst_object_unref (bus);

   gst_device_monitor_add_filter (monitor, "Audio/Sink", NULL);
    gst_device_monitor_add_filter (monitor, "Audio/Source", NULL);

   caps = gst_caps_new_empty_simple ("video/x-raw");
   gst_device_monitor_add_filter (monitor, "Video/Source", caps);
   gst_caps_unref (caps);

   gst_device_monitor_start (monitor);

   return monitor;
}

int main(int argc, char **argv)
{
    gst_init(&argc, &argv);
    GMainContext *mainContext = g_main_context_new();
    GMainLoop *mainLoop = g_main_loop_new(mainContext, FALSE);

    setup_raw_video_source_device_monitor();

    g_main_loop_run(mainLoop);
}


I compiled it like this
gcc test.c $(pkg-config --cflags glib-2.0) $(pkg-config --cflags gstreamer-1.0)
$(pkg-config --libs glib-2.0) $(pkg-config --libs gstreamer-1.0)

But after start it just prints nothing. I tried to attach and detach audio usb
devices but nothing. 
If instead of monitoring I try gst_device_monitor_get_devices(), it returns
correct list with my devices.

It's Gentoo Linux system here and gstreamer 1.12.4

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list