Publisher Max Bitrate
This topic includes details on setting the maximum video bitrate using the Vonage Video Windows client SDK:
For an overview of the publisher maximum bitrate API, see this topic.
Setting and retrieving a preset
The VideoBitratePreset enum includes preset values:
DefaultBwSaverExtraBwSaverCustom
See Video bitrate presets for details on these presets.
To retrieve the currently configured video bitrate preset for a given publisher, access the Publisher.VideoBitratePreset property:
var preset = publisher.VideoBitratePreset;
if (preset == VideoBitratePreset.BwSaver)
{
Console.WriteLine("The publisher is using the BW_SAVER preset.");
}
To set a preset, set the Publisher.VideoBitratePreset property to a value from theVideoBitratePreset enum. Do not use the Custom value.
Example:
publisher.VideoBitratePreset = VideoBitratePreset.BwSaver;
Console.WriteLine("Bitrate preset successfully set to BW_SAVER.");
Setting and retrieving a raw bitrate value
If the predefined presets are not suitable, you can manually set a custom raw bitrate value.
To get the current maximum video bitrate (in bits per second), access the Publisher.MaxVideoBitrate property. If no custom value is set, it is set to 0.
Example:
int maxBitrate = publisher.MaxVideoBitrate;
Console.WriteLine($"Current max video bitrate: {maxBitrate} bps");
To set a custom maximum bitrate (instead of a preset), assign a value (between 5,000 and 10,000,000) to the MaxVideoBitrate property.
Example:
int newBitrate = 300000; // 300 kbps
publisher.MaxVideoBitrate = newBitrate;
Console.WriteLine($"Successfully set max video bitrate to {newBitrate} bps.");
See Setting raw bitrate values for more details.
Special cases
Setting the raw bitrate value to 0 removes any previously set bitrate limitation, reverting to the default behavior.
int zeroBitrate = 0; // no limitations
int newBitrate = 300000;
publisher.MaxVideoBitrate = newBitrate;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == newBitrate);
publisher.MaxVideoBitrate = zeroBitrate;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == zeroBitrate);
Setting a custom bitrate causes the VideoBitratePreset property to be set to VideoBitratePreset.Custom:
publisher.MaxVideoBitrate = 1000000; // 1 Mbps
System.Diagnostics.Debug.Assert(publisher.VideoBitratePreset == VideoBitratePreset.Custom);
publisher.MaxVideoBitrate = 0;
System.Diagnostics.Debug.Assert(publisher.VideoBitratePreset == VideoBitratePreset.Default);
The MaxVideoBitrate property returns 0 when the publisher is using a preset:
publisher.VideoBitratePreset = VideoBitratePreset.BwSaver;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 0);
publisher.VideoBitratePreset = VideoBitratePreset.ExtraBwSaver;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 0);
publisher.MaxVideoBitrate = 200000;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 200000);
publisher.VideoBitratePreset = VideoBitratePreset.Default;
System.Diagnostics.Debug.Assert(publisher.MaxVideoBitrate == 0);