Any example on decoupling Janus use from janus.js?

1,305 views
Skip to first unread message

RoyN

unread,
Jun 2, 2015, 3:12:00 PM6/2/15
to meetech...@googlegroups.com
Hi Guys,

I'm making some tests and I'd like to use the REST API to control janus, and have my webapp be solely a "dumb" client...  BAsically my app will do all the communication and session management with janus, etc, between peers, and I want to expose the least bit possible to the "end client" be it in browser, or other client.

However, I'm having some challenge in "extracting" the correct flow from janus.js and the examples.  I've been following http://janus.conf.meetecho.com/docs/rest.html and studying it at length, but still all my attempts of splitting the "control" and the "viewer/player" screens are failing... I'm trying to do it on echotest and others and I seem to have problems... Whenever I detach the ajax polling from the "player" it doesnt attach media...

The docs go up to a certain point, but I'm not really understanding what call/return message is responsible for establishing media, for example... and what function I should pass that into?  I'm roughly in the area of onlocalstream / onremotestream in terms of the plugin, since that is where the html element is really being created, but I'm not really being able to trace the HTTP request from the API that is generateing the payload for the RTC?

I would like to know if there are any examples or pointers that I can look at that have integrated Janus with either a "simplified" janus.js or some other webrtc framework, and is taking care of signalling elsewhere.

What frameworks (if any) would be a good starting point to try? peerjs? rtc.io? simplewebrtc? would any of these be a suitable way of acting as "janus clients"?  If I do all of the "session initiation/control" from HTTP Rest, I assume I should be able to mimic the functionality using one of these?

I'd appreciate pointers abt how to configure these, as I'm unsure what part of the Janus payload would need to be "forwarded" on to the webrtc framework?  Another option is if anyone has a "stripped down" janus for doing only media client side?  Which wouldnt initiate anything else?  Or if there is some function I can call on janus.js based on something obtained from the Janus HTTP api to just do the media part?

I hope I'm not too confusing :)

Lorenzo Miniero

unread,
Jun 3, 2015, 4:43:28 AM6/3/15
to meetech...@googlegroups.com, rnasserc...@gmail.com
What you want to achieve is perfectly in line with what Janus can do, and as a matter of fact that's what we've been doing in several projects where the Janus API needed to be wrapped behind a different client-server communication.

That said, I never tried using existing frameworks with the Janus API, so I can't help you there. If they allow you to take the SDPs and trickle candidates you have and do whatever you want with them (i.e., send them to Janus through its API) then they should work.

Not sure what you mean by "detach the ajax polling". As the docs say, the usage pattern for the API is usually like follows:
  1. you create a Janus session ("create");
  2. you create a handle in that session, attaching to a plugin ("attach")
  3. you exchange messages with the plugin ("message" to send messages, "event" originated by Janus for responses/notifications), involving a WebRTC negotiation when needed (a "jsep" offer/answer is part of the messages above).
Of course you might have more handles within the same session, and when wrapping the Janus API on the server side you might even think of having a single session that manages all handles, even those related to different users, but that's beyond the scope of that simple steps dscription. The important concept is that if you're using HTTP to interact with Janus, a long poll is needed to receive responses/notifications. Without that, you'll never be informed about success/failure of asynchronous requests in a session, or of incoming events.

If the docs don't make this easier to grasp, I suggest just capturing the messaging of one of the demos, e.g., the echo test one, to see what the demo sends and what Janus replies back and how.

Lorenzo

Lorenzo Miniero

unread,
Jun 3, 2015, 4:44:30 AM6/3/15
to meetech...@googlegroups.com, lmin...@gmail.com, rnasserc...@gmail.com
As a side note, you might refer to https://github.com/rtc-io/rtc-janus as an example of a node.js server wrapping the Janus API. Not sure how updated it is but it should work.

L.

RoyN

unread,
Jun 3, 2015, 6:16:06 AM6/3/15
to meetech...@googlegroups.com

Hi Lorenzo,


Yes, the examples make that part clear and I have asked our programmer to look at the janus-rtc project and also the message on here giving more details… It seems like the “janus part” is OK…


The trouble is obtaining the “command” to start showing or sending media, and how to do that in the browser.  janu.js wraps all of that in the middle of its logic, which is the approach we are trying to disect, but its been time consuming.  I was looking to wheter anyone had a clearer example of where in the polling cycle the “media must be started” (by issuing RTC commands on the browser, I suppose - and this is where janus.js and other frameworks have done a lot of work abstracting differences in browsers, for example), etc…


The janu signaling part is “ok” as far as I know… the sending/receiving media in the browser itself, RTC peer connection, etc, is where we are a bit stuck.


Further, I assume you guys are swamped, but please do let me know if we can continue the discussion we were having by e-mail… we are going forward very slowly on janus for only internal testing on 1 project, and will probably be deploying a paas solution in the interim, until we can conclude the idea we had sent you by e-mail.   I got all the approvals so just waiting for your timing to fit with us :)


thanks again!

RoyN

unread,
Jun 3, 2015, 6:55:10 AM6/3/15
to meetech...@googlegroups.com
Just as some further detail, I remember you mentioned that this is usually yhe most common use case... when users "wrap" janus around an existing app, using janus signaling between their app and janus, and media betwen janus & client browser /rtc consumer.  We are having issue, however, determining what exactly is "janus signaling" (get session, attach plugin, plugin messages like create room, etc) and what is "media/rtc" messages that need to be passed on to RTC methods on the browser (such as MediaStream, RTCPeerConnection, RTCDataConnection, etc or some abstraction of these under a layer or framework - even if it were janus.js or a "simplifed 'player-only-janus.js')...  I'm unsure how to call these methods, and I assume that the arguments to these methods need to come from some call/ajas/socket message being received from the janus API...

This exact flow is a bit unclear...

I'm asking the guys to try a bit further with rtc-janus, which I understand is doing the "janus-signaling" (or what I call the "controller") part from wtihin node.js as opposed to from within the browser, but I havent seen them had progress with getting the media out *yet*... so I'm looking for help from others who have been down the road basically...

Reverse engineering the janus.js process is ongoing but I thikn my guys are struggling around some concepts still...despite being great at lower level infrastructure webrtc is still new to the team I had to put on this :(

PS: **we are eager for your schedule to free up a bit at meetecho! LOL! just kidding! the product and support is great!** (please dont take offense at the joke)

Benjamin Trent

unread,
Jun 3, 2015, 1:19:02 PM6/3/15
to meetech...@googlegroups.com
I have written a rudimentary wrapper in C#(does JUST enough for my purposes Janus-Sharp) and am currently working on an Java Android wrapper that interfaces with LibJingle but it is still in the early stages so I have not posted anything yet.(Using janus for WebRTC signal startup, teardown with an Android client).

The WebRTC logic is essentially talking against your plugin, saying that you want to start the media portion, sending your SDP offer, janus responding, your endpoint reacting in kind and then robert's your father's brother. 

RoyN

unread,
Jun 3, 2015, 3:44:25 PM6/3/15
to meetech...@googlegroups.com
Thzanks a lot Benjamin!

I had looked at Janus sharp a bit but didnt really look too deep, since I dont know lots of C# :p

I'll look a bit more again see if I can get the jjist... I imagine C# goes up to the point where you must initiate the RTC commands, so I should be able to trace the calls more easily...

thanks
Reply all
Reply to author
Forward
0 new messages