What could you do with the data?
These are just a few examples.
- For your chat application, show a list of all the current conference participants.
- Overlay participant nicknames on their video windows.
- Add mute/unmute indicators.
- Highlight the video element of the current speaker.
When Bob joins the ConfBridge he receives the ConfbridgeWelcome event:
In the ConfbridgeWelcome event, the "channels" arrays contains all of the channels currently in the bridge, including Bob himself. In this case, Alice was already in the conference when Bob joined.
The ConfbridgeJoin event is sent to all other participants when someone joins the conference. In this case Bob is joining the conference. If the "echo_events" option is enabled, Bob can also receive his join message when he joins.
Since this is an event related to a specific participant, the "channels" array just has Bob's channel in it.
Most of the other ConfBridge events have the same contents. They are ConfbridgeJoin, ConfbridgeLeave, ConfbridgeRecord, ConfbridgeStopRecord, ConfbridgeMute, ConfbridgeUnmute, ConfbridgeWelcome. If your bridge has the "talk_detection_events" option set to "yes", participants will also receive ConfbridgeTalking events containing a "talking_status" indicator in place of the "muted" parameter appearing in most of the other events.
If you are familiar with the ConfBridge AMI events, you will notice that the ConfbridgeStart and ConfbridgeEnd events are missing. That is because they do not make much sense in this context. At the time they are generated, there are no participants to receive them.
Getting events sent to your web application
Start by adding a few parameters to your user and bridge profiles in confbridge.conf:
Of course, your configuration will be different but those are the parameters that need to be set.
In the browser
You use the same mechanism as shown in Conference Participant Messaging. The only difference will be that the message Content-Type will be "application/x-asterisk-confbridge-event+json". The message bodies will be JSON events as shown above.
Putting it all together
One of the possible uses for the events mentioned above was overlaying a participant's nickname on their video window. Here is a hint on how you could do that.
If you look at the events you will notice that every channel specifies an "id" field which is the Asterisk channel's unique id. When you receive ConfbridgeJoin or ConfbridgeWelcome events, save the event in a hashmap keyed by that id. When you receive a new video stream, which you can intercept by adding an "sdp" handler to your JsSip RTCSession, look at the sdp and look for the "a:label" and "a:msid" attributes in each video stream. The "a:label" will be the participant's channel id as specified in the events and the "a:msid" will be available in the video element WebRTC creates. Now, just create another hashmap that cross references the two and when you draw your video elements, you can grab the msid from it and then get the corresponding participant from the hashmaps.