flutter-webrtc / dart-sip-ua

A dart-lang version of the SIP UA stack.
MIT License
330 stars 255 forks source link

Need to implement conference call with this plugin #189

Open Kunjainam opened 3 years ago

Kunjainam commented 3 years ago

We want to implement add call and conference in our app Currently we are using this plugin for audio call with SIP protocol using this plugin. now we going to integrate conference call but not able to find any way or method related to add new call in current running call.

We want to solution of conference call in this plugin if any have implement this type feature in app or any one know about solution then help us.

If anyone know alternative of this plugin for SIP call with call transfer, call conference and call recording then let us know we have already implement calling part only call conference remaining

we have already review entire lib classes but not find any method related to conference call. so i request please add this feature in this plugin. it's very important feature for us.

cloudwebrtc commented 3 years ago

I think this is not in the scope of this plugin. The current sip protocol is only used for invite sessions. It is a one-to-one model. To implement a conference call, there are three options

  1. You need an IP-PBX that supports conferences, such as Asterisk/FreeSWITCH. You can mix the voice on the server and send it to every SIP client participating in the conference.

  2. Add a client-side mixer patch to flutter-webrtc, and forward all calls to a sip client for mixing and sending

  3. The most imaginative solution, use dart-sip-ua to connect to the b2bua example in go-sip-ua, and enable ion-sfu in b2bua, and use webrtc to connect to the SFU server solutions, in ion-sfu Forward multiple audio tracks. This solution is not only suitable for audio conferences, you can also create more modern video conferences using this plug-in.

Kunjainam commented 3 years ago

Hello, Thank you so much for quick response and The dart-sip-ua library this is very much useful, And I appreciate that.

Actually we have implement this in our app but in this we can not connect conference call and transfer call and call recording functionalities so we need your help.

In this 3rd option that you have provide In b2bua example in go sip us how to implement this in my app because I don't know where to put it whether in back-end or server or how can implement this in dart in flutter go-sip-ua is used in go Language so can you brief me about this because we are doing in dart so tell me something about this go-sip-ua. And currently we Are working in sip-ua library and in this library how to implement this in my app. So how can I do conference call using this library.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

MuharremCetin commented 2 years ago

I found the solution using the js_bindings library. The library's MediaStream.getTracks() method throws a type error. I solved this problem using js_util interop.

JsAudioContext.dart:

import 'dart:convert';
import 'package:flutter_webrtc/flutter_webrtc.dart' as webrtc;
import 'package:dart_webrtc/src/media_stream_track_impl.dart' as track_impl;
import 'package:js_bindings/js_bindings.dart' as js_bindings;
import 'package:universal_html/html.dart' as html;
import 'dart:js_util' as js_util;

class JsAudioContext {
  js_bindings.AudioContext? audioContext;
  js_bindings.MediaStreamAudioDestinationNode? destinationNode;
  JsAudioContext() {
    audioContext = js_bindings.AudioContext();
  }

  void createMediaStreamDestination() {
    destinationNode = audioContext?.createMediaStreamDestination();
  }

  void connect(webrtc.MediaStreamTrack? trackWeb) {
    track_impl.MediaStreamTrackWeb mediaStreamTrackWeb =
        trackWeb as track_impl.MediaStreamTrackWeb;
    html.MediaStreamTrack htmlTrack = mediaStreamTrackWeb.jsTrack;
    var sourceStream = audioContext?.createMediaStreamSource(
        js_bindings.MediaStream([htmlTrack as js_bindings.MediaStreamTrack]));
    sourceStream?.connect(destinationNode!);
  }

  webrtc.MediaStreamTrack getMixedTrack() {
    List<dynamic> outputTrack =
        js_util.callMethod(destinationNode!.stream, 'getTracks', []);

    webrtc.MediaStreamTrack rtcTrack = track_impl.MediaStreamTrackWeb(
        outputTrack.toList()[0] as html.MediaStreamTrack);
    return rtcTrack;
  }
}

sip_call_event_service.dart:

@override
  Future startConference(List<SipCallData> activeCallList) async {
    List<webrtc.MediaStreamTrack> receivedTracks = <webrtc.MediaStreamTrack>[];

    for (var item in activeCallList) {
      Call? call = sipuaHelper!.findCall(item.id!);
      var receives = await call!.peerConnection!.getReceivers();
      for (var element in receives) {
        receivedTracks.add(element.track!);
      }
    }

    JsAudioContext jsAudioContext = JsAudioContext();

    for (var item in activeCallList) {
      Call? call = sipuaHelper!.findCall(item.id!);
      jsAudioContext.createMediaStreamDestination();

      var receivers = await call!.peerConnection!.getReceivers();
      for (var receiver in receivers) {
        for (var track in receivedTracks) {
          if (receiver.track!.id != track.id) {
            jsAudioContext.connect(track);
          }
        }
      }

      var senders = await call.peerConnection!.getSenders();
      for (var sender in senders) {
        jsAudioContext.connect(sender.track);
      }

      await senders.first.replaceTrack(jsAudioContext.getMixedTrack());
    }
  }
krunaladit commented 1 year ago

@MuharremCetin js_binding is only for web any solution for mobile app for android & iOS?

alaayousf commented 11 months ago

Has anyone been able to find a solution to this problem? I have been searching for a long time. Please help

dmagic99 commented 2 months ago

Hey @alaayousf Did you find any solution?

dmagic99 commented 2 months ago

Hey @Kunjainam Did you find any solution?