omnitalk_sdk 0.1.16
omnitalk_sdk: ^0.1.16 copied to clipboard
simple and easy flutter sdk for real time communication using WebRTC
Omnitalk SDK #
Flutter package for real-time communication, based on WebRTC. Simple & Easy.
![](https://github.com/omnistory-labs/flutter.library/blob/main/img/example_3.jpg?raw=true)
![](https://github.com/omnistory-labs/flutter.library/blob/main/img/chattingroom.jpg?raw=true)
Sample code #
To see full sample code visit https://github.com/omnistory-labs/flutter.library or https://omnitalk.io/docs/flutter/quick-start for documents.
how to run sample code
API Test Sample
andSimple Video Conference App
One is for testing api functionalities, consisting of buttons for each api and four of users' video images. The other is simple video conference app you can download and use it right away.
- download the sample
- open it in VSC(recommended) and run
flutter pub get
- replace the service id, service key argument with active ones in lib>screen>video_conference.dart
- You can get a 1-hour test key for free
![](https://github.com/omnistory-labs/flutter.library/blob/main/img/api_test_sample.jpg?raw=true)
![](https://github.com/omnistory-labs/flutter.library/blob/main/img/example_2.jpg?raw=true)
![](https://github.com/omnistory-labs/flutter.library/blob/main/img/example_3.jpg?raw=true)
-
If you want to use the code in your app, make sure these below. The sample codes we provide already have set them and you don't need further job.
- minimum sdk version
android>app>build.gradle
compileSdkVersion is 33, minSdkVersion 21
- device permission
- android>app>src>main>AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
- ios>Runner>info.plist
<key>NSCameraUsageDescription</key> <string>$(PRODUCT_NAME) Camera Usage!</string> <key>NSMicrophoneUsageDescription</key> <string>$(PRODUCT_NAME) Microphone Usage!</string>
Features #
- create session
- create room
- join room
- publish
- subscribe
- get room list
- get participants list
- dataChannel
- setAudioMute
- setVideoMute
Pre-Requisite #
- flutter_webrtc ^0.9.24
- This sdk is developed under Flutter 3.7.6, Dart 2.19.3
- omnitalk service id, service key
- compatible library version 21+
Getting started #
0. Set your minimum sdk requirements #
Go to android>app>build.gradle in your working directory.
// compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 33
// minSdkVersion flutter.minSdkVersion
minSdkVersion 21
1. Omnitalk Service ID, Key #
- Visit omnitalk.io
- Sign up for an Omnitalk account
- Create service card to get service id and service key
- You can get a one-hour test key.
Test Key
![](https://github.com/omnistory-labs/flutter.library/blob/main/img/test_key.png?raw=true)
2. Import omnitalk_sdk in your app #
Add following lines to pubspec.yaml
under dependencies
dependencies:
omnitalk_sdk: ^0.1.16
flutter_webrtc ^0.9.24
or you can add it by running code below in terminal.
flutter pub add omnitalk_sdk
3. Initialize Omnitalk instance with your service id and key #
final Omnitalk omnitalk;
omnitalk = Omnitalk(service id, service key)
4. Get your RTCVideoRenderer #
Omnitalk supports 32 users at the same time.
Declare renderers and pass them as an argument to publish() for local video or to subscribe() for remote video according to its use.
Usage #
To establish a real time video conference using Omnitalk's platform (with plans to introduce features such as audio calls, conferences, and more), the following methods may be useful.
1) create session
Argument 'user_id' is optional. If you don't put user_id, omnitalk will give you a random id.
session = await omnitalk.createSession(user_id);
2) create room & join the room
Make a room and join the room. You can get a room list first before making a room. You can also pass a room subject, room secret if you want.
roomObj = await omnitalk.createRoom(subject: roomSubject);
roomId = roomObj?["room_id"];
await omnitalk.joinRoom(room_id: roomId);
3) publish
By publishing you start broadcasting. Pass the RTCVideoRenderer localrenderer and add it to your UI widget. You can also set resolution in publishing. Default resolution is 'HD'. Full description is below.
publishIdx = await omnitalk.publish(
localRenderer: localVideo,
callType: "videocall", record: false,
resolution: 'FHD');
//in your widget
Container(
color: Colors.grey,
height: 200,
width: 160,
child: displayOn ? RTCVideoView(localVideo) : null,
),
resolution descriptions
4) subscribe
To subscribe other broadcasting, you need a publish index. You can get publish_index by listening to 'BROADCASTING_EVENT' from the Omnitalk signaling server. Or you can get participants' list before you subscribe one.
var partiResult = await omnitalk.partiList(roomId);
for (var parti in partiResult) {
int pubIdx = parti["publish_idx"];
partiList.add(pubIdx);
}
for (int i = 0; i < partiList.length; i++) {
int pubidx = partiList[i];
await omnitalk.subscribe(
publishIdx: pubidx, remoteRenderer: remoteVideos[i]);
setState(() {
flags[i] = true;
count++;
});
}
5) dataChannel
To make a chatting room, create a room with room_type = "dataroom". Omnitalk server streams messages, which you can simply get by listening to the event. You can see a chatting example, API reference and its usage in omnitalk.io
await omnitalk.createRoom(room_type: "dataroom", secret: secret);
omnitalk.onDataMessage = (event) async {
switch (event["textroom"]) {
case "join":
onDataRoomJoin(event["username"]);
getParticipants(event);
break;
case "message":
setState(() {
onMessageReceived(event);
});
break;
}
}
6) setAudio/Video mute Pass the boolean toggle value as an argument to mute/ unmute the audio. To pause or play video use setVideoMute(). It only controls video images not sound. If you want to mute both image and sound, call both methods.
bool toggle = true;
_onSetAudioMute() async {
await omnitalk.setAudioMute(toggle);
toggle = !toggle;
}
bool toggle = true;
_onSetVideoMute() async {
await omnitalk.setVideoMute(toggle);
toggle = !toggle;
}
Feedback #
If you have any issues or suggestions, visit our github repo and create an issue.
Additional information #
For more information, visit omnitalk.io