omnitalk_sdk 1.1.30 copy "omnitalk_sdk: ^1.1.30" to clipboard
omnitalk_sdk: ^1.1.30 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.

Sample code #

To see full sample code visit https://github.com/omnistory-labs/omnitalk.flutter.demo or https://omnitalk.io/docs/flutter/quick-start for documents.

how to run sample code
There are two kinds of samples.

API Test Sample

and

Simple 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.

  1. download the sample
  2. open it in VSC(recommended) and run flutter pub get
  3. 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
  • 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
  • setAudioMute
  • setVideoMute
  • setAudioInput
  • setAudioOutput
  • setVideoDevice
  • audio call
  • video call
  • video conference

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 #

  1. Visit omnitalk.io
  2. Sign up for an Omnitalk account
  3. Create service card to get service id and service key
  • You can get a one-hour test key.
Test Key

2. Import omnitalk_sdk in your app #

Add following lines to pubspec.yaml under dependencies

dependencies:
    omnitalk_sdk: ^1.1.30
    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
resolution width * height QVGA 320 * 240 VGA 640 * 480 SD 720 * 480 HD 1280 * 720 FHD 1920 * 1080 2k 2560 * 1440 4k 1840 * 2160

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

🛠️ suspending

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

7) Audio/Video input/output

Pass the device id as an argument to controll audio input/output or video input. For video you need the session id you're in active. You can get the device list using getDevice() APi.

var devices = await omnitalk.getDeviceList();
device list example
{
  audioinput:
  {
  0: {deviceId: 0, label: bottom},
  1: {deviceId: 2, label: back}},

  audiooutput:
  {
  0: {deviceId: speaker, label: Speakerphone},
  1: {deviceId: earpiece, label: Earpiece}},

  videoinput:
  {
  0: {deviceId: 0, label: Camera 0, Facing back, Orientation 90},
  1: {deviceId: 1, label: Camera 1, Facing front, Orientation 270},
  2: {deviceId: 2, label: Camera 2, Facing back, Orientation 90},
  3: {deviceId: 3, label: Camera 3, Facing front, Orientation 270}
  }
}


  _onSetAudioInput() async {
    isAudioBack
        ? await omnitalk.setAudioInput('2')
        : await omnitalk.setAudioInput('0');
    isAudioBack = !isAudioBack;
    print('isAudioBack : $isAudioBack');
  }

  _onSetAudioOutput() async {
    isEarpiece
        ? await omnitalk.setAudioOutput('speaker')
        : await omnitalk.setAudioOutput('earpiece');
    isEarpiece = !isEarpiece;
    print('is earpiece on : $isEarpiece');
  }

  _onSwtichCamera() async {
    isCameraSwitched
        ? await omnitalk.setVideoDevice(sessionId, '1')
        : await omnitalk.setVideoDevice(sessionId, '0');
    isCameraSwitched = !isCameraSwitched;
  }


8) Audio/Video Call

Use offerCall() or answerCall() API to develop voice call or video call. Pass the localAudio and callee arguments to get audio connection. For video call you just need two renderers. For detailed usage and document visit omnitalk.io

 _onOfferCall() async {
    await omnitalk.offercall(
        room_type: "audiocall",
        callee: callee,
        record: false,
        localAudio: localAudio);
    ringtoneOn = true;
    await _onRingtone();
  }
_onAnswerCall() async {
    await omnitalk.answerCall(
        room_id: roomId,
        room_type: roomType,
        publish_idx: publishIdx,
        localRenderer: localVideo,
        remoteRenderer: remoteVideo);
    }

Feedback #

If you have any issues or suggestions, visit our github repo and create an issue.

Additional information #

For more information, visit omnitalk.io

2
likes
110
pub points
19%
popularity

Publisher

verified publisheromnitalk.io

simple and easy flutter sdk for real time communication using WebRTC

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_webrtc, logging, permission_handler, web_socket_channel

More

Packages that depend on omnitalk_sdk