The WebRTC Meeting Sample is a video meeting application built on WebRTC 2.0. The host runs the application, guests join from a browser or from another application with a link, the host composes the guests into one program output, and every participant receives it. To learn the API itself, start with the Quick Start.
The sample comes with both SDKs in C# and VB.NET, in Samples WebRTC\<language>\WebRTC 2.0\WebRTC Meeting Sample (shortcut WebRTC Meeting Sample 2.0 C# x64). This article describes the C# version; the VB.NET version is simpler, see below.
Run a meeting
- Optionally, on the Host tab choose the video and audio sources, click START HOST and ADD TO PGM to be in the program yourself.
- In the Session panel click START. The sample creates the channel.
- Click JOIN LINK to copy the link for guests. A guest opens it in a browser, allows the camera and the microphone, and appears on the Guests tab.
- WATCH LINK copies the link for viewers, who only watch the program.
What the host can do
| Area | Functions |
|---|---|
| Program output (PGM) | The guests in the program are mixed into one picture that is sent to everybody. Layouts: AUTO, 1x1, 2x2, 3x3, 1x3, 1x5, 1x7, 1x9. In AUTO the active speaker is shown large and the others in a row below. AUTO PGM adds new guests to the program, up to nine. Guests can also be dragged into the program. |
| Guests | A thumbnail and the connection type of every guest (local, stun, prflx, or relay for a TURN server). MUTE removes the guest's sound from the program and from the audio the other guests receive, PIN keeps the guest in its place, REMOVE disconnects the guest. A guest with the camera off is shown as a placeholder with the name. |
| Viewers | The participants that only watch. |
| Session Recording | Records the program output to an MP4 file. |
| Stats, Events / Logs | WebRTC statistics and session events. |
Settings
| Setting | Default | How to change it |
|---|---|---|
| Signaling server | https://meet.medialooks.com:443 |
The constant DefaultSignalingServer in MainWindow.xaml.cs (rebuild the sample). |
| Channel URL | <server>/Meeting/<computer name> |
The environment variable MEETING_ROOM sets another name. |
| Video encoder of the program | gpu_h264 |
Environment variable MEETING_VIDEO_ENCODER, for example cpu_h264. |
| Video bitrate of the program | 4M |
Environment variable MEETING_VIDEO_BITRATE. |
| Additional channel properties |
venc_srt_props::g=25 with gpu_h264
|
Environment variable MEETING_ENCODER_PROPS, name=value pairs separated by ;. |
The default server is for tests. For your own server see Signaling server WebRTC 2.0 usage.
How it works
The sample creates one channel and is its Host. Every guest sends its camera and microphone to the channel. The sample receives each guest, mixes them into one program frame and sends that single frame to all participants. A guest therefore receives one picture, not one stream per guest.
The channel is created with mix-minus on, so every guest gets an audio return without its own voice:
_connect.Channel_Create(_channelUrl, "", "", null, out var channel);
Channel = (MCChannelClass)channel;
Channel.PropsSet("video_encoder", videoEncoder);
Channel.PropsSet("video_bitrate", videoBitrate);
Channel.PropsSet("mix_minus.enabled", "true");
Channel.PropsSet("mix_minus.src_channels", "all");
Channel.PropsSet("mix_minus.delay_msec", "300");
Channel.PropsSet("mix_minus.audio.level_msec", "300");
Channel.PropsSet("mix_minus.level_db", "-10");
The line with mix_minus.enabled switches mix-minus on. For the other properties see the optional settings of mix-minus.
Before the program frame is sent, the sample mutes its audio. A participant therefore hears the audio of the other connected guests, mixed by the SDK, also of guests that are not in the program. The audio of the program, including the microphone of the host, goes into the recording but not to the participants.
A guest is muted in the returns of the other guests through a property of its connection, and removed with ChannelDisconnect:
Channel.PropsSet($"connected[{peerId}]::mix_minus.level_db", muted ? "-121" : "0");
Channel.ChannelDisconnect(peerId, "removed by host");
The connection type shown for a guest is read from the statistics: connected[i]::webrtc_stat[<peer id>]::ice.type.
Source files
| File | Content |
|---|---|
MeetingSession.cs |
The WebRTC part: creates the channel, sends the program, receives the guests, lists guests and viewers, mutes and removes a guest. |
PgmMixer.cs, PgmLayoutPreset.cs
|
The layouts and the composition of the program frame. The MFormats version composes the frames itself, the MPlatform version uses the MMixer object. |
PeerFrameBuffer.cs (MFormats version) |
A small queue of the received frames of every guest, so that the mixer takes frames at its own rate. |
VideoStub.cs |
The placeholder of a guest without a picture. |
MainWindow.xaml(.cs) |
The window: host sources, guest and viewer lists, layouts, active speaker, recording, statistics. |
VB.NET version
The VB.NET version has the same panels, links, recording and mix-minus, with these differences:
- The default signaling server is
https://videosdk.medialooks.com:8080(constantDefaultSignalingServer), and theMEETING_environment variables are not read. - AUTO chooses one of the layouts 1x3 to 1x9 by the number of guests.
- MUTE removes the guest's sound from the program, but not from the audio returns of the other guests.
- It does not show the connection type or a camera-off placeholder.
Next
Still have questions?
Tell us what didn’t work or what you’d like clarified.