Working with Streams
Streams allow users to communicate in real time using audio, video, and desktop sharing inside Stream Rooms.
Each Context can contain any number of Stream Rooms identified by streamRoomId.
Before working with Streams, follow our Getting Started Guide. It will show you how to set up your project to work with PrivMX Bridge. Sample code on this page is based on the initial assumptions.
Working with Streams
When working with Streams, you will use StreamApi, which provides methods used to manage Stream Rooms and real-time media streams
Let's modify the program from the First App chapter to connect to PrivMX Bridge server, create a Stream Room, and publish a Stream in it.
CMakeLists.txt
main.cpp
Creating Stream Rooms
Use createStreamRoom(...) to create a room with selected users, managers, and metadata.
Hint: You can assign any data to private and public meta fields (e.g. the Stream Room's name), as long as it is serialized and can be given as the core::Buffer.
Listing and Reading Stream Rooms
Use listStreamRooms(...) for paged room listing and getStreamRoom(...) to fetch a single room.
As a result you will receive an object:
Getting a single Stream Room:
Updating and Deleting Stream Rooms
To update a Stream Room you must always provide a full list of parameters.
The updateStreamRoom(...) method needs all the parameters as in the createStreamRoom(...) method and a few more. If you want to update one of the parameters – provide it in a new modified form. If, on the other hand, you want to leave the parameter unchanged – provide it as it was before.
To delete a Stream Room, use the deleteStreamRoom(...) method.
Devices and Track Sources
The API lets you inspect local capture sources using:
getAudioDevices()getVideoDevices()getDesktopDevices(...)
Joining a Room and Publishing a Stream
Join the room before creating local streams or subscribing to remote ones. Then create a stream handle, add tracks, and publish it.
If you add or remove tracks after publishing, call updateStream(...).
To stop publishing entirely, call removeStream(...).
Receiving Remote Streams
Use listStreams(...) to inspect currently published Streams and createSubscriberStream(...) to subscribe to selected ones.
Incoming media reaches your application through an OnTrackInterface implementation registered with addRemoteStreamListener(...).
To react to room and stream changes, continue with Stream Events.
We use cookies on our website. We use them to ensure proper functioning of the site and, if you agree, for purposes such as analytics, marketing, and targeting ads.