Set Track Settings (Video/Audio)
Sometimes it is required to customize local peer's Audio & Video track settings while creating instances of 100ms SDK.
These settings are optional parameters and are meant to be passed in the
HMSSDK function as the
hmsTrackSetting parameter which is an
Set audio track settings
For the audio track, we have following settings:
Property to enable Hardware echo cancellation. By default, it's set to
true if the device supports it.
Please note that on some devices the hardware wrongly reports the HW echo canceler to be present whereas it does not work
In such cases, the application needs to set this to
false, so that SW echo canceler is picked up
This setting uses the phone's Acoustic echo Cancellation instead of relying on the SDK's software-based implementation.
Property to configure audio nodes for audio sharing.(iOS Only) More info about this can be found here
Property to set the initial state of the audio track i.e Mute/Unmute. More info about this can be found here
We can create HMSAudioTrackSetting with these properties:
//To join with muted audio HMSAudioTrackSetting audioTrackSetting = HMSAudioTrackSetting( useHardwareAcousticEchoCanceler: true, trackInitialState: HMSTrackInitState.MUTED);
Set video track settings
For the video track, we can set the following properties:
Property specifies which camera to open while joining. It can be toggled later on. The default value is
The SDK intelligently downscales the resolution when publisher's bandwidth is flaky or is CPU bound. This results in a low resolution for the viewers. But if the viewers are persistent they want the highest resolution at all times, then this setting comes in handy.
The default value is set as
Property to set the initial state of the video track i.e Mute/Unmute. More info about this can be found here
This can be used when a lot of videos are rendered at a single time. It is known that the hardware decoder on certain phones doesn't tend to work well with large grids.
This may cause an adverse effect like the phone heating up, use this flag only when required. The default value is set as
We can create HMSVideoTrackSetting with these properties:
//To join the room with muted video but with a back camera HMSVideoTrackSetting videoTrackSetting = HMSVideoTrackSetting( cameraFacing: HMSCameraFacing.BACK, trackInitialState:HMSTrackInitState.MUTED, forceSoftwareDecoder: true);
Passing track settings in HMSSDK constructor
Here's a sample implementation of adding track settings while initializing 100ms SDK -
HMSAudioTrackSetting audioTrackSetting = HMSAudioTrackSetting( useHardwareAcousticEchoCanceler: false, trackInitialState: HMSTrackInitState.UNMUTED ); HMSVideoTrackSetting videoTrackSetting = HMSVideoTrackSetting( cameraFacing: HMSCameraFacing.FRONT, trackInitialState: HMSTrackInitState.UNMUTED ); HMSTrackSetting trackSetting = HMSTrackSetting( audioTrackSetting: audioTrackSetting, videoTrackSetting: videoTrackSetting ); HMSSDK hmsSDK = HMSSDK(hmsTrackSetting: trackSetting);
We can fetch the track Setting using the method after the build method is called as follows -
HMSTrackSetting trackSetting = hmsSDK.getTrackSettings();