The DingRTC SDK offers virtual background and background blur features. This topic describes how to use these features and demonstrates their effects.
Feature overview
The DingRTC SDK offers virtual background and background blur features in versions 3.3 and later. This feature separates a user's portrait from the background. A virtual background replaces the real background with a custom image, while background blur blurs the user's real surroundings. Virtual backgrounds are useful in scenarios such as online meetings, online education, and live streaming. This helps protect user privacy and prevents cluttered backgrounds from distracting viewers.
Effects

Usage
You can use the enableVirtualBackground method to enable or disable the virtual background feature.
/**
* @ingroup OC_DingRtcEngineVideo
* @since 3.3
* @brief Enables or disables the virtual background.
* @private
* @param enable Specifies whether to enable the feature.
* @param options The virtual background parameters.
* @return
* - 0: Success.
* - A non-zero value: Failure.
*/
- (int)enableVirtualBackground:(BOOL)enable withOption:(DingRtcVirtualBackgroundOptions *)options;Name | Type | Description |
enable | BOOL | YES: Enables the feature. NO: Disables the feature. The default value is NO. |
options | DingRtcVirtualBackgroundOptions | The virtual background parameters. |
In the virtual background options, set mode to DingRtcVirtualBackgroundBlur to enable background blur. To replace the background with an image, set mode to DingRtcVirtualBackgroundReplace and specify the path of the background image for bgFilePath.
/**
* @brief Video virtual background options.
*/
__attribute__((visibility("default"))) @interface DingRtcVirtualBackgroundOptions : NSObject
/** The virtual background mode. */
@property (nonatomic, assign) DingRtcVirtualBackgroundMode mode;
/** The path of the background file. */
@property (nonatomic, strong) NSString * _Nonnull bgFilePath;
@end/**
* @brief Video virtual background modes.
*/
typedef NS_ENUM(NSInteger, DingRtcVirtualBackgroundMode) {
/** Background blur. */
DingRtcVirtualBackgroundBlur = 0,
/** Background replacement. */
DingRtcVirtualBackgroundReplace = 1,
};