Closed S4iR0X closed 3 years ago
Unfortunately, this lib does not support datachannels at the moment.
This means, no createDataChannel
is called automatically at the client side (Browser).
However, in your case calling pc.createDataChannel('JanusDataChannel');
might be enough (after getting the PeerConnection from the plugin). But I haven't tested that yet.
Thanks for your answer :)
It worked like you suggested:
session.attachPlugin("janus.plugin.streaming").then(function (plugin) {
plugin.watch(streamId).then(function (response) {
let pc = plugin.getPeerConnection();
let dataChannel = pc.createDataChannel("JanusDataChannel");
dataChannel.onmessage = function (event) {
console.log(event.data);
};
});
plugin.on("pc:track:remote", function (event) {
if (videoRef.current !== null)
videoRef.current.srcObject = event.streams[0]; // getting called
});
});
However I get the message twice, but thats another problem, probably not related to this tool..
That's great to hear. Thanks for letting us know 👍
Hey Guys, I need some help. I want to send a video stream with data channel over a LAN network to multiple clients.
For this I am using a very basic code template and the video stream is working, but i get no data over the data channel. I added an event listener to the ondatachannel (see code below)
With the janus default demo I get data over the data channel. So my janus instance/config is hopefully not the problem. Inside the streamingtest.js there is a streaming.createAnswer() option of: media: { audioSend: false, videoSend: false, data: true }
Do I miss this data: true maybe in the code below and how can i add this? I added it inside the watch() function but it has no effect.
I am new to Janus / WebRTC and currently somehow lost without concrete examples so I would really appreciate your help. Thanks alot!!