Syphon / Syphon-Framework

Syphon is a Mac OS X technology to allow applications to share video and still images with one another in realtime, instantly.
Other
456 stars 79 forks source link

New : open access to SyphonServerConnectionManager and Syphon global … #49

Closed mto-anomes closed 4 years ago

mto-anomes commented 5 years ago

Hi,

I've been working on a Syphon plugin for Unity and got forced to alter the Syphon framework to make it work properly with the Unity OpenGL context. I thought maybe there's a better way to handle this kind of situations.

This PR gives to developpers the possibility to create new types of Syphon Servers (for Metal, for specific OpenGL contexts, for custom shaders... you name it !) without having to change the framework in any way. It permits to extend the framework with add-ons instead of having to dig inside the framework and make breaking changes.

To do so, this PR gives access to the SyphonServerConnectionManager header and important global variables from SyphonPrivate, so the developper can have access to all the elements needed to handle syphon notifications and server options.

I created a new SyphonConstants class to give access to SyphonPrivate elements (extern/static variables, preprocessors variables) easily without introducing any breaking change to the current code.

I purposely did not add the new headers to the Syphon.h, as this is an advanced feature that could confuse the average user.

Tell me what you think Best, Maxime

bangnoise commented 5 years ago

Interesting idea - I had wondered about this problem. As long as it doesn't break any of the actual work of sharing (ie as long as it correctly interacts with unmodified framework clients) I'm in favour of this idea in principal.

Why do you add the SyphonConstants class? Why not just expose the constants themselves?

Although it would require more dramatic refactoring, it might make sense to add a base class to SyphonServer which would handle creating and resizing the IOSurface and broadcast, and one could make a custom server by subclassing this base class (it would also allow use of an IOSurface of ones own). This sort of change will be necessary for incorporating Metal support in the framework anyway.

I'm going to leave this open and think about it as we consider changes for Metal support - it ties in too closely with that to treat it in isolation.

Don't modify anything now but in future it would be helpful if you could isolate changes which are purely refactoring (such as moving member variables inside the implementation of SyphonServerConnectionManager) into at minimum separate commits or at best separate PRs - it makes it easier to review and quickly incorporate useful refactoring and focus on the important changes.

Thanks!

bangnoise commented 5 years ago

Also it would be interesting to know the original issue you hit with Unity - we'd hoped SyphonServer worked happily with any host GL context, so it would be useful to know if not - open a separate issue for that if you can.

mto-anomes commented 5 years ago

Hi, thanks for your feedback, I highly appreciate it.

I decided to create the SyphonConstants class for two reasons :

I agree with your point on the need of a more "dramatic" refactoring. If I may add, it would be awesome to make the base code of Syphon completely agnostic of the graphic engine.

For the issues I ran into with Unity, without going into too much details it has to do with the handling of alpha channels and sRGB framebuffers provided by Unity. I'll open an issue when we're further ahead in development and if it makes sense to do it.

I hear your request for smaller and more granular PRs and will work on it shortly.

bangnoise commented 4 years ago

Closing this PR in favour of ongoing work in the subclassing branch, which should solve the problem in a more useful way.