This topic includes details on using Publisher Max Bitrate in the Vonage Video iOS client SDK:
For an overview of the publisher maximum bitrate API, see this topic.
The OTVideoBitratePreset enum includes preset values:
OTVideoBitratePresetDefaultOTVideoBitratePresetBwSaverOTVideoBitratePresetExtraBwSaverOTVideoBitratePresetCustomSee Video bitrate presets for details on these presets.
To retrieve the currently configured video bitrate preset for a given publisher, set the OTPublisherKit.videoBitratePreset property:
OTVideoBitratePreset retrievedBitratePreset = publisher.videoBitratePreset;
NSLog(@"The video bitrate preset is: %ld", (long)retrievedBitratePreset);
To set a preset, assign a value to the videoBitratePreset property. This property accepts one of the values from the OTVideoBitratePreset
enum, except for OTVideoBitratePresetCustom.
Example:
publisher.videoBitratePreset = OTVideoBitratePresetBwSaver;
If the predefined presets are not suitable, you can manually set a custom raw bitrate value.
To get the maximum video bitrate currently set for a publisher, check the OTPublisherKit.maxVideoBitrate property. This is set to the maximum bitrate (in bits per second). If no custom value is set, the property is set to 0.
Example:
int retrievedMaxVideoBitrate = publisher.maxVideoBitrate;
NSLog(@"The maximum video bitrate is: %d kbps", retrievedMaxVideoBitrate);
To use a custom maximum bitrate value (instead of a preset), set the OTPublisherKit.maxVideoBitrate property. This property accepts values between 5,000 and 10,000,000 (in bits per second).
Example:
publisher.maxVideoBitrate = 300000; // 300 kbps
See Setting raw bitrate values for more details.
Setting the raw bitrate value to 0 removes any previously set bitrate limitation, reverting to the default behavior.
publisher.maxVideoBitrate = 300000; // Set the maximum video bitrate to 300 kbps
NSLog(@"Max video bitrate set successfully to: %d", publisher.maxVideoBitrate);
publisher.maxVideoBitrate = 0; // Reset the maximum video bitrate to the default behavior
NSLog(@"Max video bitrate reset to default: %d", publisher.maxVideoBitrate);
After setting a custom bitrate, the videoBitratePreset property is set to OTVideoBitratePresetCustom.
publisher.maxVideoBitrate = 1000000; // Set a custom bitrate to 1 Mbps
if (publisher.videoBitratePreset == OTVideoBitratePresetCustom) {
NSLog(@"Video bitrate preset set to CUSTOM.");
}
publisher.maxVideoBitrate = 0; // Reset bitrate to default
if (publisher.videoBitratePreset == OTVideoBitratePresetDefault) {
NSLog(@"Video bitrate preset reset to DEFAULT.");
}
The publisher.maxVideoBitrate property is set to 0 when the publisher is using a preset.
NSLog(@"Default bitrate: %d", publisher.maxVideoBitrate); // Default should be 0
publisher.videoBitratePreset = OTVideoBitratePresetBwSaver;
NSLog(@"Bitrate for BW_SAVER preset: %d", publisher.maxVideoBitrate); // Should be 0
publisher.videoBitratePreset = OTVideoBitratePresetExtraBwSaver;
NSLog(@"Bitrate for EXTRA_BW_SAVER preset: %d", publisher.maxVideoBitrate); // Should be 0
publisher.maxVideoBitrate = 200000; // Set a custom bitrate
NSLog(@"Custom bitrate: %d", publisher.maxVideoBitrate);
publisher.videoBitratePreset = OTVideoBitratePresetDefault; // Reset to default preset
NSLog(@"Bitrate after reset to DEFAULT preset: %d", publisher.maxVideoBitrate); // Should be 0