mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-05 16:06:55 +08:00
add watching bus ability
This commit is contained in:
@@ -38,6 +38,31 @@ func runPipeline(loop *glib.MainLoop) error {
|
||||
// os.Exit(2)
|
||||
// }
|
||||
|
||||
fmt.Println("Getting device provider bus")
|
||||
bus := provider.GetBus()
|
||||
fmt.Println("Got device provider bus", bus)
|
||||
|
||||
bus.AddWatch(func(msg *gst.Message) bool {
|
||||
switch msg.Type() {
|
||||
case gst.MessageDeviceAdded:
|
||||
message := msg.ParseDeviceAdded().GetDisplayName()
|
||||
fmt.Println("Added: ", message)
|
||||
case gst.MessageDeviceRemoved:
|
||||
message := msg.ParseDeviceRemoved().GetDisplayName()
|
||||
fmt.Println("Removed: ", message)
|
||||
default:
|
||||
// All messages implement a Stringer. However, this is
|
||||
// typically an expensive thing to do and should be avoided.
|
||||
fmt.Println("Type: ", msg.Type())
|
||||
fmt.Println("Message: ", msg)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
fmt.Println("Starting device monitor")
|
||||
provider.Start()
|
||||
fmt.Println("Started device monitor")
|
||||
|
||||
fmt.Println("listing devices from provider")
|
||||
devices := provider.GetDevices()
|
||||
for i, v := range devices {
|
||||
|
Reference in New Issue
Block a user