Skip to content

waterbustech/waterbus-flutter-sdk

Flutter Waterbus SDK

Flutter plugin of Waterbus. Build video call or online meeting application with SFU model. Supports iOS, Android. ExampleApp

GitHub issueslibwebrtcCocoapods VersionPRs Welcome

⚡ Current supported features

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)

Installation

Install Rust via rustup.

Add dependency

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

Configuration

Android

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
    }
}

iOS

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.

Note for iOS.

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

Usage

Initialization

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);
}

Authentication

Create Token

Create a new session using a token:

final Result<User> result = await WaterbusSdk.instance.createToken(
  AuthPayload(fullName: "Waterbus", externalId: "unique-id"),
);

Refresh Token

await WaterbusSdk.instance.renewToken();

Delete Token

Delete token for disconnect websocket and prepare for create new token

await WaterbusSdk.instance.deleteToken();

User Management

Get user profile

final profile = await WaterbusSdk.instance.getProfile();

Update profile

await WaterbusSdk.instance.updateProfile(user: updatedUser);

Change username

await WaterbusSdk.instance.updateUsername(username: "new_username");

Room Management

Create room

final RoomParams params = RoomParams(
  room: Room(title: 'Daily Meeting'),
  password: '123123',
  userId: 'user-id',
);

final result = await WaterbusSdk.instance.createRoom(params: params);

Join room

final JoinRoomParams params = JoinRoomParams(
  roomId: 'room-id',
  password: 123123',
  userId: 'user-id',
);

final Result<Room> result = await WaterbusSdk.instance.joinRoom(params: params);

Leave room

await WaterbusSdk.instance.leaveRoom();

Media Controls

await WaterbusSdk.instance.prepareMedia();
await WaterbusSdk.instance.toggleVideo();
await WaterbusSdk.instance.toggleAudio();
await WaterbusSdk.instance.switchCamera();

Screen sharing

await WaterbusSdk.instance.startScreenSharing();
// Stop
await WaterbusSdk.instance.stopScreenSharing();

Raise or lower hand

WaterbusSdk.instance.toggleRaiseHand();

Virtual Background

await WaterbusSdk.instance.enableVirtualBackground(
  backgroundImage: yourImageBytes,
  thresholdConfidence: 0.7,
);

// Disable:
await WaterbusSdk.instance.disableVirtualBackground();

Additional Utilities

Get supported codecs

final codecs = await WaterbusSdk.instance.getSupportedVideoCodecs();

Picture-in-Picture

await WaterbusSdk.instance.setPictureInPictureEnabled(
  textureId: 'your_texture_id',
  enabled: true,
);

Contributing

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.

Contact Information

If you have any questions or suggestions related to this application, please contact me via email: [email protected].

Reference

flutter_webrtc

License

Apache License 2.0

Contributors 3

  •  
  •  
  •  

Languages