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

Multiple groups of synced videos sharing same network #115

Open
demmaone opened this issue Aug 9, 2021 · 2 comments
Open

Multiple groups of synced videos sharing same network #115

demmaone opened this issue Aug 9, 2021 · 2 comments

Comments

@demmaone
Copy link

demmaone commented Aug 9, 2021

Hello, I've been using omxplayer-sync for a while with great results.
Now I have to make 6 o 7 groups of players but they have to be in the same network sharing the same switch. Should I play with the port (currently 1666) or should I try to force the slaves to look for an specific master IP? (I don't know what the bind do here: ccb139d).
Any help would be great, meanwhile I'll keep trying.
Thanks in advance.

@barlaensdoonn
Copy link

This is an interesting question, and i'm curious what others have to say about it - i'm no networking expert, and i don't know if this can be solved with the call to bind that you linked to.

In an ideal world you would have each group on its own isolated network, any troubleshooting would benefit from this setup... but you seem to be limited to a single network, so let's proceed under that constraint.

The OMXPlayerSync class uses UDP sockets to broadcast messages to all hosts on the network. This configuration can be seen in the init_socket (socket.SOCK_DGRAM is UDP) and the master-specific socket_enable_broadcast methods.

A simple approach I've successfully used in the past to single out a specific server on the network from a pool of servers listening for UDP broadcast messages is to prepend the message with a string - like a hostname - that the servers parse and then decide if they should act on it or not. This would work the same for groups of servers too. For example in send_position_local, you would change the message being sent to include a string that specifies a group, let's say 'groupA':

self.sock.send(("{}%{}%{}".format('groupA', str(self.position_local), self.filename)).encode('utf-8'))

Then in read_position_master you'd add some logic to determine if the message is meant for the particular server that is parsing the message. This means both the sender and receiver would need to know which group they are in... you'd probably want to add an option to the OptionParser to declare this group value as a command line argument when calling omxplayer-sync. More code changes are likely needed to get this working properly, but that's a theoretical starting point.


The thing that most interested me about your question is if it's possible to have multiple clients sending UDP broadcast messages to all available hosts on the same port on the same network. I have never tried this, but it seems like it may be possible by using the SO_REUSEPORT socket option, which you can most likely set in the call to setsockopt.

Reference for how that socket option works:
https://stackoverflow.com/questions/14388706/how-do-so-reuseaddr-and-so-reuseport-differ

@magdesign
Copy link
Collaborator

Does the socket method work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants