Second WebSocket for custom messaging to build a lobby for conference #6009
Replies: 46 comments 9 replies
-
Hi @timantmedia, I think it'll be much more easier to do that with another streaming application because it's a specific scenario. The base streaming application creates another endpoint in the application here -> You can define another class such as @ServerEndpoint(value="/websocket/conference", configurator=AMSEndpointConfigurator.class)
public class WebSocketConferenceHandler {
.... Let me know if it makes sense. Cheers |
Beta Was this translation helpful? Give feedback.
-
I was the requester for this. I will see what I can do with that. I would have to create a bean reference back to the webrtc app so I can notify publish start/stop of the stream also. With Red5 based application this means the app needs to be extended to capture the publish start/stop callbacks. If I can instead listen to stream publish / unpublish server events like with Wowza, and the stream is linked to the "room" as the scope/instance. I can notify the specific room in the list. So my connection to publish to would be
The published stream object would have a scope of room1scope. That notifies via this second custom websocket app the websocket sessions connected to the room in the list room1scope. In the default "conference" scenario using "joinRoom", to store the participant name and title, that is used to be shown for all participats I have to encode it as the stream name, then decode it. There is other information stored like a profile image when camera is disabled, a property when camera is disabled to notify to display the profile image instead. Another reason for the custom websocket is to signal others when somebody toggles their camera on/off or changes their device input from no camera to camera. It will toggle the profile picture in the player and video on and off. So a server side managed list of participants in the room can store custom data separately is better. For my other server implementations I have some custom example node servers to handle websocket messages but would be good to keep it contained in Ant Media Server.
If there is special server events for publishing available that would be good to know. So I dont have to try and extend the WebRTCAppEE to get to them. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry this possibly won't be needed I may be able to send custom commands over the data channel. However when trying to send metadata with the publisher like title and profile image. It doesn't show up in the stream list the metadata is empty. Metadata might work better in the joinRoom command. It might be easier to create a second websocket managing room lists while also implementing the multitrack feature. But for the conference studio method streams cant be played immediately, host has to choose who gets added to the room. The "default" conference solution will work for the host only, the streams are automatically added to a lobby area underneath.
|
Beta Was this translation helpful? Give feedback.
-
It looks like the stream information metaData is not set. Using the mulitrack demo the metaData is empty on the roomInformation message.
So the metadata set with the publish method is not available.
|
Beta Was this translation helpful? Give feedback.
-
Hi @danrossi , |
Beta Was this translation helpful? Give feedback.
-
Hi @danrossi , You can get the meta Data information directly from the broadcast object in the conference.
Once you call this function server will send websocket message that contained broadcast object which will look some thing like below and it will contain metaData infromation.
Broadcast object returned by server which contains metaData information |
Beta Was this translation helpful? Give feedback.
-
calling getBroadcastObject for every stream in the room streamList doesn't get a message returned. It's metaData for each stream in the roomInformation streamList property. Set when publishing. Updating metadata using updateStreamMetaData doesn't work either. That would be useful to update information for each participant. Metadata for the room would be nice also found in roomInformation. There is room specific information that needs to be stored. I may need the second websocket so I can store and update properties including properties for the room. And not sure if this multitrack feature will work out because. As every participant will get all the stream tracks rather than the ones host choose to be added. Unless there is a command to add streams as tracks to the main track after publishing. So dont publish to the maintrack and host chooses after to add as a track and it will show up for people. Maybe I can make them republish to the maintrack with a datachannel command to be "added to room" |
Beta Was this translation helpful? Give feedback.
-
definitely any getBroadcastInfo command. Doesn't return anything. |
Beta Was this translation helpful? Give feedback.
-
Which version of Ant Media Are you using Right now ?? |
Beta Was this translation helpful? Give feedback.
-
The build I have is Enterprise Edition 2.7.0 20231031_0626 |
Beta Was this translation helpful? Give feedback.
-
this command doesn't return any message either. getVideoTrackAssignments |
Beta Was this translation helpful? Give feedback.
-
@danrossi , |
Beta Was this translation helpful? Give feedback.
-
Im not in your timezone. So updating and obtaining metadata properties for each stream and room is not working now hence its empty ? and calls to get broadcast info and update metadata are now not working ? This would be a reason for another websocket. |
Beta Was this translation helpful? Give feedback.
-
Hi @danrossi , |
Beta Was this translation helpful? Give feedback.
-
Hi @danrossi , |
Beta Was this translation helpful? Give feedback.
-
Using the updated metadata features I have it working again including data channels for host signal to pin a participant. I can also update metadata on the room maintrack stream and other participants can get room configurations from the maintrack metadata. Before playing the maintrack, I have to collect info of all current subtracks so I have the info gathered already. For new subtracks is very complicated how it needs to work. When a track is added I have to collect the broadcast info async, but tracks keep being added within that while collecting info. I have to keep adding tracks to the stream while collecting info with a few states to block it running further, then continue async after info is collected. In this time both tracks are added and I add a player which shows the title collected from "getBroadcastInfo" My last issue is to somehow allow host to choose which tracks get added to the room that is part of the studio feature. Adding and removing streams from the room from a lobby area. So the only way I can see it work is force the participant to republish to a different maintrack. And one maintrack is for the "lobby" area.
Get broadcast info looks like this to be resolved after obtaining the subtrack info. So alot of promises required.
The subtrack info method
Main track info to collect the room config set by the host.
|
Beta Was this translation helpful? Give feedback.
-
You can possibly close this. However Im trying to implement my feature where host chooses which tracks get added to the room. And only host gets all the tracks / streams into a lobby area. What does the |
Beta Was this translation helpful? Give feedback.
-
@danrossi you can take this approach , Every one will publish there streams to Ant Media Server two different tracks and you can use the below apis to add the Tracks to the room or remove them from the room.let me know if this approach works for you.
https://antmedia.io/rest/#/BroadcastRestService/addSubTrack https://antmedia.io/rest/#/BroadcastRestService/removeSubTrack |
Beta Was this translation helpful? Give feedback.
-
ok I understand. So there is no websocket api for this and I have to connect api calls with an api key instead. So the maintrack is a secondary main track other participants play instead. And host plays two maintracks. One is to add everyone to the lobby, another one for the room. |
Beta Was this translation helpful? Give feedback.
-
Yes you are right you can use this approach please let me know if I should close this. |
Beta Was this translation helpful? Give feedback.
-
update: I have to create the room stream main track with the api before adding subtracks to it. It works adding / removing. They appear for the participant then get removed. While host is still subscribing to the tracks in the lobby stream. For host I make it mirror the streams from the lobby streams instead of resubscribing.
|
Beta Was this translation helpful? Give feedback.
-
If I add a streamid as a subtrack to the second room maintrack stream. When stopping publishing its still a subtrack of the lobby maintrack publishing to. It says it's still broadcasting also but no stream is broadcasting. When added to the second main room track and stopping publishing. The subtracks for the lobby maintrack stream keep appending so don't clear. If I have to remove the track from the second maintrack stream aswell as the lobby maintrack stream publishing to before unpublishing it might be better in a websocket. To not have to configure api tokens for every participant page. Trying to call to delete the subtrack in the lobby mainstream, its still trailing as a subtrack because I had added it to the room main track. Calling to stop publish should be removing them as subtracks. They keep appending if republish happens and doesnt clear.
The only way to stop it appending trailing subtracks that are not publishing. Is to remove from one maintrack and add to another. But then I lose the streams from the lobby maintrack. |
Beta Was this translation helpful? Give feedback.
-
There is no track remove event only a "play_finished" event for the maintrack when the only publish to that main track stops. It requires attempting to replay the main track to get further tracks. |
Beta Was this translation helpful? Give feedback.
-
I have an issue also where host can't determine if something is published directly to the room main track unless it also subscribes to the room main track not just the lobby track. So publishing their own stream, publishing the GPU merger stream, subscribing to two main tracks. A websocket message of anyone joining the room, and publishing to that room might help hence the need for the second websocket. I tried sending a data channel message from the screen share publishing to the main room track, but host's own peer connection can't receive a message. Messages only turn up for the subscribed streams. My feature makes screen shares publish to a seperate stream and shows up seperate. |
Beta Was this translation helpful? Give feedback.
-
I'm sorry for all the effort required. I have a working integration. Only there is a few bugs I found detailed above detecting a publisher has ended. If they are the only track in the lobby maintrack there is no track close event. Then there is the lingering stream ids in the lobby main track if they were previously added/removed from the room maintrack. There seems to be a delay for garbage collection on the main tracks ? |
Beta Was this translation helpful? Give feedback.
-
@danrossi , Can you please describe the exact step by step reproduce scenario so that I can reproduce this on my end. |
Beta Was this translation helpful? Give feedback.
-
if you are still considering to go with new web socket instead of using meta data approach please take a look at this example you can implement something like this for a new web socket connection. You can implement ApplicationContextAware, IStreamListener class and implement the below function which will be called if any one join leave the room so you can keep track of it , take a look at this for sample.
So you can implement the above methods and keep track of everyone. |
Beta Was this translation helpful? Give feedback.
-
It doesn't look like it's needed thanks to the metadata fixes. I have someone needing to test it out but their server version is 2.7.0.20231031_0626 which server can I tell them to get the changes ? I've emailed support my integration into videojs its a working package of demos. What I found is when there is only one publish to a main track there is no onremovetrack event dispatched. The main track subscribed to it goes immediately to play_finished. The publishers go to a lobby main track host subscribes to. I have to dispatch a player removal there. I have to trigger to resubscribe to the main track from there or I won't get new tracks. When I make an api call to add/remove subtracks to the second "room main track" which is what other participants see which host manually chooses which ones to add to the room main track. They linger and appended to the lobby main track's broadcastobject subTrackStreamIds property. I have to reboot the server to clear those. It's only when streamid's are trying to be added as subtracks of the second main track. I think these are bugs ? |
Beta Was this translation helpful? Give feedback.
-
any idea how to advise somebody how to get the metadata changes. Has it been released or do I tell them to ask for a snapshot ? Those two problems do I need to file a bug report ? |
Beta Was this translation helpful? Give feedback.
-
@danrossi , Can you please try this way create a broadcast with the name of the lobby and roomtrack using the rest api https://antmedia.io/rest/#/BroadcastRestService/createBroadcast |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
The only way to send messages to a conference host is through the data channel, but they need to be connected through a peer connection before the data channel can send any messages.
Whats needed is another WebSocket to send messages to a conference host without the need to connect.
E.g. It could be a separate endpoint a module can use to listen for messages separate from WebRTC. ie
wss://ant-media-server:5445/LiveApp/websocket/conference?room=room1
Describe the solution you'd like
The customer has implemented something similar in Wowza streaming engine and this is the functionality that he'd like in Ant Media Server:
Here is the wowza backend I built I modelled it from the Kurento demo . And I have a demo nodejs one for millicast although they support data channel so might be able to use data channel like Ant if it works.
From the customer
In the server-side solution.
publish start
event method makes a call to the websocket module, the host is notified only, and the host starts subscribing to the stream and is added to a lobby. When a user stops publishing astop
event method in the server notifies the websocket module and sends a websocket message to clients to stop subscribing.add to room
. This is a websocket signal for the server to notify other participants to subscribe to the stream in the room.Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
Beta Was this translation helpful? Give feedback.
All reactions