For AI agents: see the complete documentation index at /llms.txt.
Integrate an extension
Updated
Integrate extensions from Extensions Marketplace directly into your app.
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart.
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Download the extension
In the extension detail page, click Download, then unzip the extension in a local directory.
-
Install the extension in your project
- Android Archive file (
.aar)
-
Save the extension
.aarfile to/app/libsin your project. -
In
/Gradle Scripts/build.gradle(Module: <ProjectName> app), add the following line underdependencies:implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
- Shared Library (
.so)
Save the
.sofile to the following paths in your project:-
/app/src/main/jniLibs/arm64-v8a -
/app/src/main/jniLibs/armeabi-v7a
- Android Archive file (
You are now ready to integrate the extension in your app.
Integrate the extension into your project
The watermark extension adds a watermark on video streamed to your local client. This section shows you how to implement the watermark extension in your Agora project:
-
Import the necessary classes
-
Download the watermark extension and follow the steps for
.aarfiles in setup. -
In
app/src/main/java/com.example.<projectname>/MainActivity:- Add the following lines to import the Android classes used by the extension:
import org.json.JSONException; import org.json.JSONObject;import org.json.JSONException import org.json.JSONObject- Add the following lines to import the Agora classes used by the extension:
// ExtensionManager is used to pass in basic info about the extension import io.agora.extension.ExtensionManager; import io.agora.rtc2.IMediaExtensionObserver;// ExtensionManager is used to pass in basic info about the extension import io.agora.extension.ExtensionManager import io.agora.rtc2.IMediaExtensionObserver
-
-
Add the extension and register the event handler
In
setupVideoSDKEngine, add the following code beforeagoraEngine = RtcEngine.create(config);:config.addExtension(ExtensionManager.EXTENSION_NAME); // Register IMediaExtensionObserver to receive events from the extension. config.mExtensionObserver = new IMediaExtensionObserver() { @Override public void onEvent(String vendor, String extension, String key, String value) { // Add callback handling logics for extension events. showMessage("Extension: " + extension + " Key: " + key + " Value:" + value); } @Override public void onStarted(String provider, String extension) { showMessage("Extension started"); } @Override public void onStopped(String provider, String extension) { showMessage("Extension stopped"); } @Override public void onError(String provider, String extension, int error, String message) { showMessage(message); } };config.addExtension(ExtensionManager.EXTENSION_NAME) // Register IMediaExtensionObserver to receive events from the extension. config.mExtensionObserver = object : IMediaExtensionObserver { override fun onEvent(vendor: String, extension: String, key: String, value: String) { // Add callback handling logics for extension events. showMessage("Extension: $extension Key: $key Value: $value") } override fun onStarted(provider: String, extension: String) { showMessage("Extension started") } override fun onStopped(provider: String, extension: String) { showMessage("Extension stopped") } override fun onError(provider: String, extension: String, error: Int, message: String) { showMessage(message) } } -
Enable the extension
Call
enableExtensionto enable the extension. To enable multiple extensions, callenableExtensionas many times. The sequence of enabling multiple extensions determines the order of these extensions in the transmission pipeline. For example, if you enable extension A before extension B, extension A processes data from the SDK before extension B.In
setupVideoSDKEngine, add the following code beforeagoraEngine = RtcEngine.create(config);:agoraEngine.enableExtension(ExtensionManager.EXTENSION_VENDOR_NAME, ExtensionManager.EXTENSION_VIDEO_FILTER_NAME, true);agoraEngine.enableExtension( ExtensionManager.EXTENSION_VENDOR_NAME, ExtensionManager.EXTENSION_VIDEO_FILTER_NAME, true ) -
Set extension properties
In the
joinChannel(View view)method, add the following code afteragoraEngine.joinChannel:JSONObject o = new JSONObject(); try { // Pass in the key-value pairs defined by the extension provider to configure the feature you want to use. o.put("plugin.watermark.wmStr", "Agora"); o.put("plugin.watermark.wmEffectEnabled", true); // Call setExtensionProperty to use the watermark feature. agoraEngine.setExtensionProperty(ExtensionManager.EXTENSION_VENDOR_NAME, ExtensionManager.EXTENSION_VIDEO_FILTER_NAME, "key", o.toString()); } catch (JSONException e) { e.printStackTrace(); }val o = JSONObject() try { // Pass in the key-value pairs defined by the extension provider to configure the feature you want to use. o.put("plugin.watermark.wmStr", "Agora") o.put("plugin.watermark.wmEffectEnabled", true) // Call setExtensionProperty to use the watermark feature. agoraEngine.setExtensionProperty( ExtensionManager.EXTENSION_VENDOR_NAME, ExtensionManager.EXTENSION_VIDEO_FILTER_NAME, "key", o.toString() ) } catch (e: JSONException) { e.printStackTrace() }
Test your implementation
To ensure that you have integrated the extension in your app:
-
Connect the Android device to the computer.
-
Click
Run appon your Android Studio. A moment later you will see the project installed on your device. -
When the app launches, you can see yourself and the watermark
Agoraon the local view.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
API reference
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart.
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Download the extension
In the extension detail page, click Download, then unzip the extension in a local directory.
-
Install the extension in your project
-
Save the extension
.frameworkor.xcframworkfiles to your project folder. -
In Xcode, open your project and select your target. Go to General > Frameworks, Libraries, and Embedded Content.
-
Click + > Add Other… > Add Files and select the
.frameworkor.xcframworkfiles you saved earlier.
-
You are now ready to integrate the extension in your app.
Integrate the extension into your project
To use an extension in your Agora project:
-
The implementation procedure varies according to extensions. Each extension vendor provides their own implementation guides, which is validated by Agora before the official release of the extension.
-
To implement the extension in your project, go to the detail page of the extension on Agora Console, click Implementation guides, and follow the steps on the page.
Test your implementation
To ensure that you have integrated the extension in your app:
-
Connect a device to the computer.
-
In Xcode, Click
Run. A moment later you will see the project installed on your device. -
Connect to a channel and test your effect.
Agora provides an open-source sample project SimpleFilter on GitHub for your reference.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart.
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Download the extension
In the extension detail page, click Download, then unzip the extension in a local directory.
-
Install the extension in your project
-
Save the extension
.frameworkor.xcframworkfiles to your project folder. -
In Xcode, open your project and select your target. Go to General > Frameworks, Libraries, and Embedded Content.
-
Click + > Add Other… > Add Files and select the
.frameworkor.xcframworkfiles you saved earlier.
-
You are now ready to integrate the extension in your app.
Integrate the extension into your project
To use an extension in your Agora project:
-
The implementation procedure varies according to extensions. Each extension vendor provides their own implementation guides, which is validated by Agora before the official release of the extension.
-
To implement the extension in your project, go to the detail page of the extension on Agora Console, click Implementation guides, and follow the steps on the page.
Test your implementation
To ensure that you have integrated the extension in your app:
-
In Xcode, Click
Run. A moment later you will see the project installed on your device. -
Connect to a channel and test your effect.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart.
-
Physical media input devices, such as a camera and a microphone.
-
A JavaScript package manager such as npm.
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Download the extension
In the extension detail page, click Download, you are taken to the npm page for the extension.
-
Install the extension in your project
-
In the extension npm page, copy the Install command.
-
In the root of your project, install the extension package. For example, for AI Noise Suppression:
npm i agora-extension-ai-denoiser
-
You are now ready to integrate the extension in your app.
Integrate the extension into your project
To use an extension in your Agora project:
-
The implementation procedure varies according to extensions. Each extension vendor provides their own implementation guides, which is validated by Agora before the official release of the extension.
-
To implement the extension in your project, go to the detail page of the extension on Extensions Marketplace, click Implementation guides, and follow the steps on the page.
To learn how to use a Web extension, see AI Noise Suppression.
Test your implementation
To ensure that you have integrated the extension in your app:
-
Generate a temporary token in Agora Console.
-
In your browser, navigate to the Agora web demo and update App ID, Channel, and Token with the values for your temporary token, then click Join.
-
In main.js, update
appID,channelandtokenwith your values. -
Start the dev server
Execute the following command in the terminal:
npm run devUse the URL displayed in the terminal to open the app in your browser.
-
Try out the extension that you have integrated.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
API reference
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Same setup as the Voice SDK quickstart prerequisites for Voice Calling.
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Download the extension
In the extension detail page, click Download, then unzip the extension in a local directory.
-
Install the extension in your project
Add the extension
.dllto your project.
You are now ready to integrate the extension in your app.
Integrate the extension into your project
Integrating an extension into your project involves a few important steps to ensure seamless interaction between the extension and Agora Video SDK. Each of these steps plays a crucial role to ensure that the extension works correctly and efficiently within your Agora project:
-
Define variables to integrate an extension with Agora Video SDK
In
AgoraImplementationDlg.h, add the following declarations to theCAgoraImplementationDlgclass beforesetupVideoSDKEngine();:// File path to the dynamic library (.dll file on Windows) that contains the implementation of the extension provider. const char* extensionLibrarayPath = "<extension dynamic library path and name>"; // For example : "/ library / libagora_segmentation_extension.dll" const char * extensionProvider = "<extension library path and name>"; // For example : "agora.io"; const char* extensionName = "<extension name>"; // For example : "libagora_segmentation_extension.dll"; // The key is a string that identifies a specific property of the extension, // and value is the new value for that property. // What these keys are and what values they can take is entirely up to the extension. // For example, an extension might have a property that controls the quality of a video stream, with a key named "videoQuality". // To set this property to "high", you would call setExtensionProperty() with "videoQuality" as the key and "high" as the value. const char* extensionKey = "<name of the extension property you want to set>"; const char* extensionValue = "<new value of the property>"; // When using methods that take a MEDIA_SOURCE_TYPE parameter, you would specify the value that corresponds to the type of media source // you want the method to operate on. For example, if you want to use the second camera to capture video, set this parameter to "SECONDARY_CAMERA_SOURCE". // The default value is UNKNOWN_MEDIA_SOURCE. agora::media::MEDIA_SOURCE_TYPE extensionMediaType = agora::media::UNKNOWN_MEDIA_SOURCE; // insert the media souce type as per your context -
Register extension callbacks to the
IRtcEngineEventHandlerevent handler-
In
AgoraImplementationDlg.h, add the following declarations to theAgoraEventHandlerclass afteronLeaveChannel:virtual void onExtensionEvent(const char* provider, const char* extension, const char* key, const char* value)override; virtual void onExtensionStopped(const char* provider, const char* extension)override; virtual void onExtensionStarted(const char* provider, const char* extension)override; virtual void onExtensionError(const char* provider, const char* extension, int error, const char* errorMessage)override; -
Define these callbacks in
AgoraImplementationDlg.cpp:// Extension Callbacks void AgoraEventHandler::onExtensionEvent(const char* provider, const char* extension, const char* key, const char* value) { // Handle the event CString extension_provider(provider); CString extension_name(extension); CString extension_key(key); CString extension_value(value); CString message; message.Format(_T("Extension Provider: %s\nExtension Name: %s\nKey: %s\nValue: %s\n is enabled to run."), extension_provider, extension_name); AfxMessageBox(message); } void AgoraEventHandler::onExtensionStopped(const char* provider, const char* extension) { AfxMessageBox(L"Extension stopped."); } void AgoraEventHandler::onExtensionStarted(const char* provider, const char* extension) { AfxMessageBox(Extension started); } void AgoraEventHandler::onExtensionError(const char* provider, const char* extension, int error, const char* errorMessage) { // Handle the error event CString error_message(errorMessage); CString message; message.Format(_T("Error: %s\n with error code %d"), error_message, error); AfxMessageBox(message); }
-
-
Enable the extension and set the extension properties
To use the extension you downloaded in your app:
- Load the extension.
- Register the extension.
- Enable the extension.
- Set the extension property.
To accomplish these tasks, do the following:
-
In
AgoraImplementationDlg.h, declaresetupMarketExtension()beforesetupVideoSDKEngine();:// Function to load, register and enable the extension. Here you also set the extension propertties for your specific extension void setupMarketExtension(IRtcEngine* agoraEngine); -
In
AgoraImplementationDlg.cpp, put the following in thesetupVideoSDKEnginefunction just after initializing Agora EngineagoraEngine->initialize(context);:
// Integrate extension to the Agora SDK. setupMarketExtension(agoraEngine);-
Define
setupMarketExtension():void CAgoraImplementationDlg::setupMarketExtension(IRtcEngine* agoraEngine) { // Load the extension with the file path to the dynamic library (.dll file on Windows) and a boolean flag 'unload_after_use' is true here mean // unload the dynamic library after it has been used. agoraEngine->loadExtensionProvider(extensionLibrarayPath,true); // Register the extension agoraEngine->registerExtension(extensionProvider, extensionName, extensionMediaType); // Enable the extension agoraEngine->enableExtension(extensionProvider, extensionName, true, extensionMediaType); // Set Extension property. The extension key and extension value would be specific to the extension you are using. // This function is used to set the value of a specific property of an extension agoraEngine->setExtensionProperty(extensionProvider, extensionName, extensionKey, extensionValue, extensionMediaType); }
-
Disable the extension before closing the application
You must unload and disable all extensions before the app closes. As you set
unload_after_usetotrueinloadExtensionProvider(), the extension dynamic link library unloads automatically after it has been used. You disable the extension to prevent any potential memory leaks or unanticipated effects. To do this, put the following inOnClose()beforeagoraEngine->release();:// Disable extension by making 'eanbled' flag as false . agoraEngine->enableExtension(extensionProvider, extensionName, false);
Test your implementation
To ensure that you have integrated the extension in your app:
-
Generate a temporary token in Agora Console .
-
In your browser, navigate to the Agora web demo and update App ID, Channel, and Token with the values for your temporary token, then click Join.
-
In
CAgoraImplementationDlg.h, updateappId,channelNameandtokenwith the values for your temporary token. -
Set the values for variables and properties in the framework code for your extension in use.
-
In Visual Studio, click Local Windows Debugger. A moment later you see the project running on your development device.
If this is the first time you run the project, you need to grant microphone and camera access to your app.
-
Experience the features of your new extension.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
API reference
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
- An Agora account and project.
- A computer with Internet access. Ensure that no firewall is blocking your network communication.
- Physical media input devices, such as a camera and a microphone.
- A JavaScript package manager such as npm.
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
You are now ready to integrate the extension in your app.
Integrate the extension into your project
This section shows you how to implement the video filter extension in your app:
-
Add the required variables
To integrate the extension, in
preload.js, add the following variables to declarations:var path = "agora_segmentation_extension"; var provider = "agora_video_filters_segmentation"; var extension = "portrait_segmentation"; var enableExtension = false; -
Implement the logic to load and enable the extension
To load the extension in your app, call
loadExtensionProviderand pass the extension path. To enable the extension, callenableExtensionand pass the provider name and extension name. To implement this workflow, inpreload.js, add the following method beforewindow.onload = () =>:function enableExtension() { if (!path) { console.log('path is invalid'); return; } if (!provider) { console.log('provider is invalid'); return; } if (!extension) { console.log('extension is invalid'); return; } agoraEngine.loadExtensionProvider(path); agoraEngine.enableExtension(provider, extension, enableExtension); }; -
Implement the logic to disable the extension
To disable the extension, call
enableExtensionand pass theprovider,extension, andenableExtensionvariables as parameters. TheenableExtensionvariable is set tofalseto disable the extension. To implement this logic, inpreload.js, add the following method beforewindow.onload = () =>:function disableExtension() { agoraEngine.enableExtension(provider, extension, enableExtension); }; -
Setup an event listener to enable and disable the extension with a button
When the user presses Enable Extension, your app loads and starts the extension with a call to the
enableExtensionmethod. When the user presses the button again, your app disables the extension with a call to thedisableExtensionmethod. To implement this workflow, inpreload.js, add the following method beforedocument.getElementById("leave").onclick = async function ():document.getElementById("extension").onclick = async function () { enableExtension = !enableExtension; if(isExtension) { enableExtension(); document.getElementById("extension").innerHTML = "Disable Extension"; } { disableExtension(); document.getElementById("extension").innerHTML = "Enable Extension"; } } -
Implement the required callbacks to manage the extension
Video SDK provides the following callbacks to manage an extension:
onExtensionStarted: Occurs when the extension is enabled.onExtensionError: Occurs when the extension runs incorrectly.onExtensionStopped: Occurs when the extension is disabled.onExtensionEvent: The event callback of the extension.
To implement these callbacks, in
preload.js, add the following callbacks beforeonUserJoined:onExtensionError:( provider, extName, error, msg) => { console.log("Error :" + error, "Error detail :" + msg); }, onExtensionEvent:( provider, extName, key, value) => { }, onExtensionStarted:(provider, extName) => { }, onExtensionStopped:(provider, extName) => { }
Test your implementation
To ensure that you have integrated the extension in your app:
-
In preload.js, update
appID,channelandtokenwith your values. -
Run the app
Execute the following command in the terminal:
npm startYou see your app opens a window named Get started with Voice Calling.
-
Press Enable Extension. Your app start using the Agora video filter extension.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
API reference
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart.
-
Flutter 2.0.0 or higher
-
Dart 2.15.1 or higher
-
Android Studio, IntelliJ, VS Code, or any other IDE that supports Flutter, see Set up an editor.
-
If your target platform is iOS:
- Xcode on macOS (latest version recommended)
- A physical iOS device
- iOS version 12.0 or later
-
If your target platform is Android:
- Android Studio on macOS or Windows (latest version recommended)
- An Android emulator or a physical Android device.
-
If you are developing a desktop application for Windows, macOS or Linux, make sure your development device meets the Flutter desktop development requirements.
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Open your Flutter project
Load the SDK quickstart Voice Calling project you created previously.
-
Get the extension
Visit the Agora Extensions Marketplace and follow the procedure to download and install the desired extension.
You are now ready to integrate the extension in your app.
Integrate the extension into your project
This section presents the framework code you add to your Flutter project to integrate an extension.
-
Load the extension provider
You call
loadExtensionProviderduring Agora Engine initialization to specify the extension library path. To do this, add the following code to thesetupVideoSDKEnginemethod after you initialize the engine withagoraEngine.initialize:agoraEngine.loadExtensionProvider("<extensionLibraryPath>"); -
Enable the extension
To enable the extension, add the following code to the
setupVideoSDKEnginemethod beforeawait agoraEngine.enableVideo();:// Extensions marketplace hosts both third-party extensions as well as those developed by Agora. To use an Agora extensions, you do not need to call addExtension or enableExtension. agoraEngine.enableExtension( provider: "<The name of the extension provider>", extension: "<extensionName>", type: MediaSourceType.unknownMediaSource, enable: true );If the extension uses the second camera to capture video, set the type parameter to
secondaryCameraSource.To enable multiple extensions, call
enableExtensionfor each extension. The calls toenableExtensiondetermines the order of each extension in the transmission pipeline. For example, if you enable extension A before extension B, extension A processes data from Video SDK before extension B. -
Set extension properties
To customize the extension for your particular app, set suitable values for the extension properties. Refer to the extension documentation for a list of available property names and allowable values. To set a property, add the following code to the
setupVideoSDKEnginemethod afteragoraEngine.enableExtension:agoraEngine.setExtensionProperty( provider: "<providerName>", extension: "<extensionName>", key: "<keyName>", value: "<keyValue>");
Test your implementation
To ensure that you have integrated the extension in your app:
-
Set the variables and properties in the framework code to values suitable for your chosen extension.
-
In your IDE, open
/lib/main.dartand updateappId,channelNameandtokenwith the values from Agora Console. -
Connect a test device to your development device.
-
In your IDE, click Run app or execute the
flutter runcommand in the terminal. A moment later, you see the project installed on your device.If this is the first time you run the app, grant camera and microphone permissions.
-
Join the same channel from another test device or the Agora web demo.
-
Experience the features of your new extension.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
API reference
Extensions are add-ons designed to rapidly extend the functionality of your app. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your app. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart.
- React Native 0.60 or later. For more information, see Setting up the development environment.
- Node 10 or later
- For iOS
- A machine running macOS
- Xcode 10 or later
- CocoaPods
- A physical or virtual mobile device running iOS 9.0 or later. If you use React Native 0.63 or later, ensure your iOS version is 10.0 or later.
- For Android
- A machine running macOS, Windows, or Linux
- Java Development Kit (JDK) 11 or later
- Android Studio
- A physical or virtual mobile device running Android 5.0 or later
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Open your React-native project
Load the SDK quickstart Voice Calling project you created previously.
-
Get the extension
Visit the Agora Extensions Marketplace and follow the procedure to download and install the desired extension.
You are now ready to integrate the extension in your app.
Integrate the extension into your project
This section presents the framework code you add to your React Native project to integrate an extension.
Implement the user interface
You can use a switch to enable and disable the extension you wish to integrate. To do this, follow these steps:
-
Import the necessary modules
Add the following import from
react-nativebeforeText,:Switch, -
Render the switch
Add the following code in the return statement, after
Leave </Text>:<Switch onValueChange={() => { if (enable_extension) { disableExtension(); setEnableExtension(false); } else { enableExtension(); setEnableExtension(true); } }} />
Integrate the extension
-
Declarations for the extension
You can create constants for the extension provider and extension name that you need to integrate.
const extprovider = 'agora_segmentation'; const extension = 'PortraitSegmentation';You also need a state variable to keep track of the status of your extension. Inside
App, add the following code along with the other declarations:const [enable_extension, setEnableExtension] = useState(false); -
Enable the extension
You call
enableExtensionto enable your extension. To do this using theswitch, add the following code after theleavefunction:const enableExtension = () => { if (Platform.OS === 'android') { agoraEngineRef.current?.loadExtensionProvider(`${extprovider}_extension`); } agoraEngineRef.current?.enableExtension(extprovider, extension, true); setEnableExtension(true); }; -
Disable the extension
You call
disableExtensionto disable your extension. To do this using theswitch, add the following code after theenableExtensionfunction:const disableExtension = () => { agoraEngineRef.current?.enableExtension(extprovider, extension, false); setEnableExtension(false); }; -
Add the necessary callbacks
To get notified of important events, add the following callbacks to
agoraEngine.registerEventHandler({:onExtensionErrored: ( provider: string, extName: string, error: number, msg: string, ) => { console.log( 'onExtensionErrored', 'provider', provider, 'extName', extName, 'error', error, 'msg', msg, ); }, onExtensionEvent: ( provider: string, extName: string, key: string, value: string, ) => { console.log( 'onExtensionEvent', 'provider', provider, 'extName', extName, 'key', key, 'value', value, ); }, onExtensionStarted: (provider: string, extName: string) => { console.log( 'onExtensionStarted', 'provider', provider, 'extName', extName, ); setEnableExtension(true); }, onExtensionStopped: (provider: string, extName: string) => { console.log( 'onExtensionStopped', 'provider', provider, 'extName', extName, ); setEnableExtension(false); },
Test your implementation
To ensure that you have integrated the extension in your app:
-
Run your app:
- Android
- Enable Developer options on your Android device, and then connect it to your computer using a USB cable.
- Run
npx react-native run-androidin the project root directory.
- iOS:
- Run your app with Xcode.
If this is the first time you run the project, you need to grant microphone and camera access to your app.
-
Join the same channel from another test device or the Agora web demo.
-
Experience the features of your new extension.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
Extensions are add-ons designed to rapidly extend the functionality of your game. Extensions Marketplace is home to extensions that make your app more fun. Extensions provide features such as Audio effects and voice changing, Face filters and background removal, and Live transcription and captioning.
In the Agora Extensions Marketplace:
- Vendors create and publish extensions to provide functionality such as audio and video processing.
- App developers use extensions to quickly implement fun and interactive functionality.
This page shows you how to integrate an extension from Agora Extensions Marketplace into your game. There can be specific guidance for each extension.
Understand the tech
An extension accesses voice and video data when it is captured from the user's local device, modifies it, then plays the updated data to local and remote video channels.
Extension call workflow
A typical transmission pipeline consists of a chain of procedures, including capture, pre-processing, encoding, transmitting, decoding, post-processing, and play. Audio or video extensions are inserted into either the pre-processing or post-processing procedure, in order to modify the voice or video data in the transmission pipeline.
Prerequisites
To test the code used in this page you need to have:
-
A computer with Internet access. Ensure that no firewall is blocking your network communication.
-
Implemented the SDK quickstart
- Unity Hub
- Unity Editor 2017.X LTS or higher
- Microsoft Visual Studio 2017 or higher
Project setup
In order to integrate an extension into your project:
-
Activate an extension
- Log in to Agora Console.
- In the left navigation panel, click Extension Marketplace, then click the extension you want to activate.
You are now on the extension detail page.
-
Select a pricing plan and click Buy and Activate.
-
If you have already created an Agora project:
The Projects section appears and lists all of your projects.
-
If you have not created an Agora project:
Create a new project, the project appears in the Projects section.
-
-
Under Projects on the extension detail page, find the project in which you want to use the extension, then turn on the switch in the Action column.
-
Get the apiKey and apiSecret for the extension
If required for the extension, to get the extension apiKey and apiSecret, in the Projects extension detail page, click View in the Secret column.
-
Open your Unity project
Load the SDK quickstart Voice Calling project you created previously.
-
Get the extension
Visit the Agora Extensions Marketplace and follow the procedure to download and install the desired extension.
You are now ready to integrate the extension in your game.
Integrate the extension into your project
This section presents the framework code you add to your Unity project to integrate an extension.
-
Load the extension provider
You call
loadExtensionProviderduring Agora Engine initialization to specify the extension library path. To do this, add the following code to theSetupVideoSDKEnginemethod after you initialize the engine withRtcEngine.Initialize:RtcEngine.LoadExtensionProvider("<extensionLibraryPath>"); -
Enable the extension
To enable the extension, add the following code to the
Joinmethod beforeRtcEngine.EnableVideo();:RtcEngine.EnableExtension( provider: "<The name of the extension provider>", extension: "<extensionName>", enable: true, type: MEDIA_SOURCE_TYPE.UNKNOWN_MEDIA_SOURCE );Extensions marketplace hosts both third-party extensions as well as those developed by Agora. To use an Agora extension, you do not need to call EnableExtension.
To enable multiple extensions, call
EnableExtensionfor each extension. The calls toEnableExtensiondetermines the order of each extension in the transmission pipeline. For example, if you enable extension A before extension B, Video SDK processes data from extension A before extension B. -
Set extension properties
To customize the extension for your particular game, set suitable values for the extension properties. Refer to the extension documentation for a list of available property names and allowable values. To set a property, add the following code to the
Joinmethod afterRtcEngine.EnableExtension:RtcEngine.SetExtensionProperty( provider: "<providerName>", extension: "<extensionName>", key: "<keyName>", value: "<keyValue>" );
Test your implementation
To ensure that you have integrated the extension in your game:
-
Set the variables and properties in the project code to values suitable for your chosen extension.
-
Generate a temporary token in Agora Console.
-
In your browser, navigate to the Agora web demo and update App ID, Channel, and Token with the values for your temporary token, then click Join.
-
In Unity Editor, in
Assets/Agora-RTC-Plugin/Agora-Unity-RTC-SDK/Code/JoinChannelVideo.cs, update_appID,_channelName, and_tokenwith the values for your temporary token. -
In Unity Editor, click Play. A moment later you see the game installed on your device.
-
Experience the features of your new extension.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
