Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish the audio and video input ports via Avahi #219

Closed
wants to merge 6 commits into from

Conversation

jhenstridge
Copy link

I had a go at implementing https://github.com/timvideos/gst-switch/issues/194. This branch adds the Avahi client libraries as a dependency, but the resulting binaries should still run if the Avahi service isn't running (it will just fail to publish the service).

It publishes two services of the types _gstswitch-video._tcp and _gstswitch-audio._tcp that match the two listening ports. Each service has two TXT records attached:

  • txtvers - a version number for the TXT metadata, in case it ever needs to be changed incompatibly.
  • caps - the string version of the GstCaps expected for data sent to this port.

This should be enough for a smart capture client to notice when the server appears on the network, and what format data to send. It could also automatically reconnect if the server changes IP address.

By default the server will use the name gst-switch, but this can be changed using the --service-name command line option. If there are name conflicts, it will use Avahi's standard name conflict resolution method.

The code is based on the example from the Avahi documentation:

http://git.0pointer.net/avahi.git/tree/examples/client-publish-service.c

As an example, here is the avahi-browse output watching the audio service when I start and kill the server:

$ avahi-browse -r _gstswitch-audio._tcp
+   eth0 IPv6 gst-switch                                    _gstswitch-audio._tcp local
+   eth0 IPv4 gst-switch                                    _gstswitch-audio._tcp local
=   eth0 IPv6 gst-switch                                    _gstswitch-audio._tcp local
   hostname = [scruffy.local]
   address = [fe80::6ef0:49ff:feed:eadd]
   port = [4000]
   txt = ["caps=audio/x-raw, rate=48000, channels=2, format=S16LE, layout=interleaved" "txtvers=1"]
=   eth0 IPv4 gst-switch                                    _gstswitch-audio._tcp local
   hostname = [scruffy.local]
   address = [192.168.0.12]
   port = [4000]
   txt = ["caps=audio/x-raw, rate=48000, channels=2, format=S16LE, layout=interleaved" "txtvers=1"]
-   eth0 IPv6 gst-switch                                    _gstswitch-audio._tcp local
-   eth0 IPv4 gst-switch                                    _gstswitch-audio._tcp local

@mithro
Copy link
Member

mithro commented Oct 18, 2015

Thanks for the patch! I'm going to try and make time to look at it ASAP. Work on gst-switch is currently slow because we are mainly concentrating on our open capture hardware project http://HDMI2USB.tv (because our new board is available).

@jhenstridge Do you use IRC? If so I'd highly recommend coming and hanging out on our IRC channel at irc://irc.freenode.net/#timvideos (or via webchat at http://webchat.freenode.net/?channels=#timvideos).

@mithro
Copy link
Member

mithro commented Oct 18, 2015

Can you think of any way to make a reliable test for this?

@jhenstridge
Copy link
Author

I suppose it might be possible to test this using python3-dbusmock to provide a fake version of Avahi for the server to register with. I can't think of a good way to test against a real avahi-daemon in a CI environment.

It doesn't look like dbusmock ships with any templates for Avahi, so this might have to wait for next weekend.

@mithro mithro closed this Mar 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants