hl2ss icon indicating copy to clipboard operation
hl2ss copied to clipboard

[Feature Request] HL2SS as a client and not the server

Open andreclerigo opened this issue 6 months ago • 13 comments

It would be great to have a way to make this library work the other way around. Instead of connecting to the HoloLens to get the sensor stream data, it would also be great to have the HoloLens send its stream to an external device (e.g., a server with a public IP).

This would be much better in terms of security and would help decouple the AR headset from services that use the data from these sensors. Would that change be easy to develop? I am available to collaborate on this feature.

andreclerigo avatar Jun 18 '25 08:06 andreclerigo

Hi. I added some example code to make the hl2ss app start the connection to the PC: https://github.com/jdibenes/hl2ss/tree/client_test The app tries to connect to the PC every second, and streaming starts when the PC runs the server script (viewer/server_pv.py). Is this what you're asking for?

jdibenes avatar Jun 18 '25 17:06 jdibenes

To test this, where can I define the IP/Domain of the PC that the HoloLens tries to connect to?

andreclerigo avatar Jun 18 '25 17:06 andreclerigo

https://github.com/jdibenes/hl2ss/blob/20a9efd4a6a07fc355ac02a826c0a7faa1fb112a/hl2ss/hl2ss/server_channel.cpp#L7-L8

jdibenes avatar Jun 18 '25 17:06 jdibenes

Awesome, I'll give it a go next Friday and then leave some feedback

andreclerigo avatar Jun 18 '25 17:06 andreclerigo

Just tested it and it worked very well! It would be great to have these two modes of functionality for all sensors.

Currently, I am looking for something that would work to get the microphone stream. Would that be something easy you could develop?

andreclerigo avatar Jun 20 '25 13:06 andreclerigo

The example should work for all streams. For the microphone, for example, try running client_stream_microphone.py with host set to None.

jdibenes avatar Jun 20 '25 15:06 jdibenes

Ok that's great, and what would be the steps for me to load this custom version of the hl2ss plugin into Unity?

andreclerigo avatar Jun 20 '25 15:06 andreclerigo

Build the plugin and copy it to the plugins folder (Assets/Plugins/WSA).

jdibenes avatar Jun 20 '25 16:06 jdibenes

Would it be possible to have the server's IP in a config file? This would remove a lot of the unnecessary compilation of hl2ss and subsequent applications that use hl2ss, if I want to use a different server

andreclerigo avatar Jun 24 '25 09:06 andreclerigo

I've also tried to put the plugin into a Unity application, but it doesn't seem to work. Any idea why?

EDIT: fixed it by going into the Unity Inspector, selecting the file, and setting: SDK = UWP and CPU = ARM64

andreclerigo avatar Jun 24 '25 10:06 andreclerigo

Sorry for information dumping, but I think this might be helpful. I am trying to get both hl2ss client and server modes working at the same time. I have put both .dll files into my project: the one from the release, and the one I've built via the client_test branch, named hl2ss.dll and hl2ss-client.dll, respectively. The client_stream_microphone.py seems to work as expected, but the client_stream_pv.py doesn't work either with host set to None or the IP of the headset.

andreclerigo avatar Jun 24 '25 12:06 andreclerigo

Server IP and other settings can now be loaded from a file. Create a file named hl2ss.txt and:

  • Put the server IP in the first line.
  • Put 0/1 in the second line to enable/disable the app's server socket.
  • Put 0/1 in the third line to disable/enable the app's client socket.
  • The fourth line is the time in ms between connection attempts to the PC.

Examples

hl2ss in server mode (default):

192.168.1.3
0
0
1000

hl2ss in server / client modes:

192.168.1.3
0
1
1000

hl2ss in client mode:

192.168.1.3
1
1
1000

Then, upload hl2ss.txt to the HoloLens: Device Portal > System > File explorer > LocalAppData > hl2ss > LocalState.

I have not tested this in Unity + plugin yet.

jdibenes avatar Jun 25 '25 05:06 jdibenes

Just gave it a quick try on the HL2SS app and as a plugin. Seems to work as expected!

andreclerigo avatar Jun 25 '25 14:06 andreclerigo