Flutter Waterbus SDK
Flutter plugin of Waterbus. Build video call or online meeting application with SFU model. Supports iOS, Android. ExampleApp
Feature | Subscribe/Publish | Screen Sharing | Picture in Picture | Virtual Background | Beauty Filters | End to End Encryption |
---|---|---|---|---|---|---|
Android | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
iOS | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
Web | 🟢 | 🟢 | 🟢 | 🟢 | 🟡 | 🟢 |
MacOS | 🟢 | 🟢 | 🔴 | 🟢 | 🟢 | 🟢 |
Linux | 🟢 | 🟢 | 🔴 | 🟡 | 🟢 | 🟢 |
Windows | 🟢 | 🟢 | 🔴 | 🟡 | 🟢 | 🟢 |
🟢 = Available
🟡 = Coming soon (Work in progress)
đź”´ = Not currently available (Possibly in the future)
Install Rust via rustup.
Add the dependency from command-line
$ flutter pub add waterbus_sdk
The command above will add this to the pubspec.yaml
file in your project (you can do this manually):
dependencies:
waterbus_sdk: ^1.3.15
Ensure the following permission is present in your Android Manifest file, located in <project root>/android/app/src/main/AndroidManifest.xml
:
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
If you need to use a Bluetooth device, please add:
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
The Flutter project template adds it, so it may already be there.
Also you will need to set your build settings to Java 8, because official WebRTC jar now uses static methods in EglBase
interface. Just add this to your app level build.gradle
:
android {
//...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Add the following entry to your Info.plist file, located in <project root>/ios/Runner/Info.plist
:
<key>NSCameraUsageDescription</key>
<string>$(PRODUCT_NAME) Camera Usage!</string>
<key>NSMicrophoneUsageDescription</key>
<string>$(PRODUCT_NAME) Microphone Usage!</string>
This entry allows your app to access camera and microphone.
The WebRTC.xframework compiled after the m104 release no longer supports iOS arm devices, so need to add the config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
to your ios/Podfile in your project
ios/Podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
# Workaround for https://github.com/flutter/flutter/issues/64502
config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES' # <= this line
end
end
end
Before using any feature, initialize the SDK with server and encryption config:
import 'package:waterbus_sdk/waterbus_sdk.dart';
void main() async {
final config = SdkConfig(
serverConfig: ServerConfig(
url: "https://services.waterbus.tech",
suffixUrl: "/busapi/v3/",
),
messageEncryptionKey: 'your-secret-message-key',
webrtcE2eeKey: 'your-e2ee-key',
);
await WaterbusSdk.instance.initialize(config: config);
}
Create a new session using a token:
final Result<User> result = await WaterbusSdk.instance.createToken(
AuthPayload(fullName: "Waterbus", externalId: "unique-id"),
);
await WaterbusSdk.instance.renewToken();
Delete token for disconnect websocket and prepare for create new token
await WaterbusSdk.instance.deleteToken();
final profile = await WaterbusSdk.instance.getProfile();
await WaterbusSdk.instance.updateProfile(user: updatedUser);
await WaterbusSdk.instance.updateUsername(username: "new_username");
final RoomParams params = RoomParams(
room: Room(title: 'Daily Meeting'),
password: '123123',
userId: 'user-id',
);
final result = await WaterbusSdk.instance.createRoom(params: params);
final JoinRoomParams params = JoinRoomParams(
roomId: 'room-id',
password: 123123',
userId: 'user-id',
);
final Result<Room> result = await WaterbusSdk.instance.joinRoom(params: params);
await WaterbusSdk.instance.leaveRoom();
await WaterbusSdk.instance.prepareMedia();
await WaterbusSdk.instance.toggleVideo();
await WaterbusSdk.instance.toggleAudio();
await WaterbusSdk.instance.switchCamera();
await WaterbusSdk.instance.startScreenSharing();
// Stop
await WaterbusSdk.instance.stopScreenSharing();
WaterbusSdk.instance.toggleRaiseHand();
await WaterbusSdk.instance.enableVirtualBackground(
backgroundImage: yourImageBytes,
thresholdConfidence: 0.7,
);
// Disable:
await WaterbusSdk.instance.disableVirtualBackground();
Get supported codecs
final codecs = await WaterbusSdk.instance.getSupportedVideoCodecs();
Picture-in-Picture
await WaterbusSdk.instance.setPictureInPictureEnabled(
textureId: 'your_texture_id',
enabled: true,
);
Contributions are welcome! Please feel free to submit a pull request or open an issue if you encounter any problems or have suggestions for improvements.
If you have any questions or suggestions related to this application, please contact me via email: [email protected].
Apache License 2.0