Put session participant on hold


I would like to get advice how to implement a possibility to put media streams on hold temporarily.

Example - we have a 1 to 1 session with video and audio between Participant A and Participant B.
Participant A gets “incoming call” event, and would like to stop sharing his audio/video with B as well as stop temporarily any incoming audio/video from B, and start 1 on 1 session with new Participant C. When a session with Participant C is finished he gets back to a session with Participant A.

Is that possible to implement on current Pro version? What are the ways to do that? Have two separate sessions for A - B and A - C participants simultaneously? Manage all of them within a single session by removing streams?

Any advice is much appreciated.


Clearly the way to go here is having 2 different OpenVidu Sessions: A-B and A-C.
You must decide how to manage the lifecycle of both sessions, and how to deal with is the management of the Publishing/Subscribing of Streams.

You could have an A-B session, and when the A-C session is required, destroy A-B (in the eyes of OpenVidu, of course. Possibly your app should enter a “waiting” state for B while he waits for the return of A). Create a new OpenVIdu Session A-C, connect both users and publish/subscribe their streams. When A-C is over, then a new A-B session should be created. Same in appearance as the first A-B, but as an OpenVidu entity it will actually be the third session of this flow.

Or, you can have only 2 Sessions (A-B and A-C), without destroying A-B at any moment. But then you must properly handle the publishing/unpublishing of the media stream. Session A-B should enter a “background” state when A-C comes into play. This can be done unpublishing and publishing the Publisher object, or muting/unmuting for a faster response. But of course in any case your app should handle the appearance and layout to let the user know that the “active” session is A-C and that A-B is in “background” mode, waiting to be resumed at some point.

Does all of this make sense? You have different possibilities, and depending on your specific use case and applications behavior one will be probably a little better than the others.


Hi Pablo, thank you for detailed response.

Yes, that’s totally makes sense.
I thought to go with the second approach, unpublish a publisher on session A-B and publish on A-C, and when a user is ready to get back to A-B do it in reverse.
What was not clear to me if that’s okay to move a publisher between sessions in that manner.
But from your response I assume that’s fine and I could go that way. Please let me know if i’m wrong.
And I’m curious - can a publisher be published in two sessions simultaneously?


You should not publish the same Publisher object in two different sessions at the same time.
You can probably unpublish → publish the same Publisher object from one Session to another (this must be tested in your application to see if it is possible). If you notice any problems, you can always publish a different Publisher per Session without a problem.

Got it. I will try to implement some basic PoC app based on your ideas. If I get stuck I return with more questions :slight_smile:

Thank you very much for help!

1 Like