3

I want to use Kurento primarily as a WebRTC to RTP gateway and for some of the filters. In the browser, I am using the browser's native WebRTC API.

I want to create a WebRTCEndpoint (as that term is used in Kurento) in my Node application server and connect it to a RTPEndpoint (as that term is used in Kurento) via a Kurento pipeline. I know that this is trival in Kurento but my question is, is it possible to do so by only using Kurento-client.js in the app server but WITHOUT USING Kurento-utils.js in the browser? THere are many reasons that I want to do this, one of them is that I have my own signalling and there are other issues where I need direct control over the low-level WebRTC API in the browser, something that kurento-utils.js does not allow me to do.

I also believe that to be tied to ws for signalling without having a fallback is not an ideal design, if indeed that is what Kurento is enforcing.

Sunny
  • 9,245
  • 10
  • 49
  • 79

1 Answers1

2

Sure! Kurento-utils-js is just an RTCPeerConnection wrapper, to manage the video tags, buffering ICE candidates, mangling of SDPs in case of PlanB or UnifiedPlan and a couple more things. The library does not have any ties with a special signaling: The callbacks from the methods that you would put the signaling in, are the same for both RTCPeerConnection and WebRtcPeer objects. For instance, this is how you would, create a WebRtcPeer, and how you would send an SDP offer generated by it

var options = {
    onicecandidate : onIceCandidate,
    localVideo : localMedia,
    remoteVideo : remoteMedia
}

var webRtcPeer = new kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv(options, function(error) {
    if (error) return console.error(error)
    webRtcPeer.generateOffer(function (error, sdpOffer) {
        if (error) return console.error(error)
        sendMessageToServerApp("sdpOfferMessage", sdpOffer)
    })
})

sendMessageToServerApp is something that you need to implement.

You can also access the wrapped object. Assuming you have a webRtcPeer object from the library, you can get the RTCPeerConnection with the property webRtcPeer.peerConnection.

The purpose of using websockets is to support events going from the media server to the proxy elements defined in your server app. Though you can go with things like long polling and other tricks, it is not likely that you are going to deploy your server app and your KMS in environments where you would need them, as you should have full control of that part. The suggestion is to have the signaling port of the media server only available to your server application.

For having a fallback mechanism between client and server app, I'd suggest SockJS for instance. We've used that in the past and it works fine.

igracia
  • 3,543
  • 1
  • 18
  • 23
  • Thanks. So, as long as I get my ICE candidates and SDP offers from the browser to the app server **through any means,** I can still use the API in Kurento-client.js. Is that correct? On a related question, am I correct in observing that Kurento can process an SDP offer and generate an SDP answer but cannot generate an offer and be the initiator of a WebRTC call? The SDP offer in that case would be pretty long, encompassing all media handling capabilities of Kurento? – Sunny May 04 '16 at 20:10
  • 1
    @Sam Yap, that's right. Kurento-utils-js is a convenience library. Kurento can work as both offerer and offeree, and can work with both Vanilla and Trickle ICE. I've expanded the answer to include more info about signaling and the library. – igracia May 04 '16 at 20:22
  • Thanks a LOT! Doubt cleared but the browser code shown may confuse others. **The use of Kurento-utils.js in the browser is what I want to avoid as stated in the title of my question.** If kurento-utils.js can be used in any Nodejs application outside the browser, then an offer can be generated **outside the browser.** Can I, was the 2nd question? I think there is no webRTCEndpoint.createOffer in Kurento-client.js? I want to avoid using Kurento-utils.js in the browser as we have our own JS wrapper library for WebRTC and other app-specific API. We use socket.io for signalling. – Sunny May 05 '16 at 06:34
  • At this time, all I want to do is to have a WebRTCendpoint "connect" to a RTPendpoint. I thought of using Gstreamer directly but think that Kurento will save me a lot of work and because we will be using the OpenCV filters too, Kurento's use will be justified. We are also planning to offer training courses in Kurento based upon our experience. Need to really understand Kurento for that -:) – Sunny May 05 '16 at 06:38
  • 1
    @Sam kurento-utils-js was created to work in the browser, with the `RTCPeerConnection` is wrapped in there, just as you created your own browser JS wrapper library. Kurento's WebRtcEndpoint offers the `generateOffer` method. I think there's code in github from other users, that's doing exactly that. – igracia May 05 '16 at 08:17
  • Thanks. VERY CLEAR NOW. I am sure that I will have other questions as I go along but will post separate questions for the same. – Sunny May 05 '16 at 08:38