flutterjanus/flutter_janus_client

VideoRoomPlugin with dataChannel

Opened this issue · 9 comments

Hi,
I am trying to configure a dataChannel in the VideoRoomPlugin but when I send a message I get nothing in the data stream.

I see, this was expected, i need to test it and will get back to you accordingly

Hi Shivansh,
To better explain the problem.
In my room there is a subscriber who has already created a channel and I want to listen to it.
I did so:

   videoRoom.webRTCHandle!.peerConnection!.onDataChannel = (channel) {
            log("LISTEN CHANNNEL: ${channel.label} ");
            channel.onBufferedAmountLow = (currentAmount) {
              log(currentAmount.toString(), name: "onBufferedAmountLow");
            };

      channel.onBufferedAmountChange = (currentAmount, changedAmount) {
        log(currentAmount.toString(), name: "onBufferedAmountChange");
        log(changedAmount.toString(), name: "onBufferedAmountChange");
      };

      channel.onMessage = (data) {
        log(data.text, name: "onMessage");
      };

      channel.onDataChannelState = (state) {
        log(state.name, name: "onDataChannelState");
      };

      channel.stateChangeStream.listen((state) {
        log(state.name, name: "stateChangeStream");
      });

      channel.messageStream.listen((message) {
        log(message.text, name: "messageStream");
      });
    };

Is it correct to listen to the channel in this way?

Nope this will not work because there is no data channel created on peerconnection object on webrtc handle
You need to call initDataChannel to create data channel with supported label
So check this out

Future<void> initDataChannel({RTCDataChannelInit? rtcDataChannelInit}) async {

Try calling initDataChannel then directly access peerconnection object for data channel callback although i would advise you to use helper streams to listen to events rather that directly accessing webrtcHandle?.peerconnection it is there for custom functionality only.
Try this and i believe it should work for you if it doesn't i will add data channel support in one of examples to illustrate how to use data channel with other media streams.
You can also look at setup method of textroom plugin which shows the use of initDataChannel method

Hi Shivansh,
could you write an example? we can't get it to work.
Thank you

check videocall example i have updated with datachannel illustration similar to videocall demo

edea8f8
i hope it helps you

Closing because of no activity you can request to reopen if you still think there are some issues.

Hi @shivanshtalwar ,
I followed your VideoCall example but I still don't get any message in the stream.
I used initDataChannel and verified that the channel has been created and is open.
I also verified that sending the message works. I put a log inside the sendData function and it is executed correctly.

I call plugin.data?.listen in joinRoom, when data is VideoRoomConfigured.
But I don't get any message.

if (data is VideoRoomConfigured) {
        log("VideoRoomConfigured", name: "configured log flavio");
        print('typed event with jsep' + event.jsep.toString());
        await plugin.handleRemoteJsep(event.jsep);

        plugin.data?.listen((message) async {
          log(message.text, name: "Message received");
        });
      }

Can you help me? Thanks

Thank you

I have update for you, i tried setting up data channel with video room, i was able to establish data channel open connection but couldn't send anything through, till the time i investigate it further i would suggest to use textroom plugin along with videoroom plugin which seems more scalable setup to me.

Hi @shivanshtalwar0,
Thank you!
Looking forward to your update.