Playing with Event Handlers: a practical example

2,549 views
Skip to first unread message

Lorenzo Miniero

unread,
Dec 22, 2016, 12:23:41 PM12/22/16
to meetecho-janus
Hi all,

following up on the announcement I made a couple of weeks ago:

as a slightly early Christmas gift to you all I just wrote a blog post that tries to make Event Handlers clearer to understand and use:
http://www.meetecho.com/blog/event-handlers-a-practical-example/

It's written in the same spirit as the blog post I already published on the Admin API (http://www.meetecho.com/blog/understanding-the-janus-admin-api/), and also includes a very simple demo you can use to play with these events yourself. You'll learn how to enable the Event Handlers in Janus, how you can intercept these events in an application, and how to have this application save them to a DB so that you can then query it to know what happened (or is happening). Hopefully this will give you more context and ideas on how to use this new feature in even more creative ways to build monitoring/troubleshooting tools for Janus.

Feedback welcome, and Happy Holidays to you all!
Lorenzo

Mirko Brankovic

unread,
Dec 23, 2016, 5:27:18 AM12/23/16
to meetecho-janus
Great work, thanks :)

--
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janus+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
Mirko

Mirko Brankovic

unread,
Jan 5, 2017, 11:17:10 AM1/5/17
to meetecho-janus
Hi Lorenzo,

Can this be used to detect audio level of handles, for example, to know who is curently speaking to display that element on client side.

So for example, I got a simple server node app to get events:

  { type: 32,
    timestamp: 1483632724015774,
    session_id: 2351334289808005,
    handle_id: 1736352222727007,
    event: 
     { media: 'audio',
       base: 48000,
       lsr: 0,
       lost: 0,
       'lost-by-remote': 0,
       'jitter-local': 0,
       'jitter-remote': 1,
       'packets-received': 0,
       'packets-sent': 8517,
       'bytes-received': 0,
       'bytes-sent': 251252,
       'nacks-received': 0,
       'nacks-sent': 0 } } ]

 so if packets-sent increase a lot, can that be a trigger that user is talking or the audio level doesn't matter to number of packets sent?

I'm not sure how to detect the active speaker... If yuou have any suggestions, ... thanks,
Mirko

Lorenzo Miniero

unread,
Jan 5, 2017, 11:22:09 AM1/5/17
to meetecho-janus
Packets sent and received don't depend on who's talking. The same number of packets will be involved also to do silence. Audio levels would need to be forwarded as different events from the plugin you're using. We recently added support for the audio-level RTP extension to a couple of plugins, so that's where you may want to start, e.g., intercepting those for every incoming packet, and shooting an event on a regular basis, e.g., every 500ms. Whether this event should be sent (only) through the event handlers, or to participants as well, is up to you.

L.

Mirko Brankovic

unread,
Jan 5, 2017, 11:53:31 AM1/5/17
to Lorenzo Miniero, meetecho-janus
Ok i guessed the silence won't be suppressed.
There are examples like:
That will mesure the audio level on getUserMedia but seems to me a bit heavy maybe, maybe not.
I read that audio-level sdp flag was introduced by Chrome, so flaging rtp.
So for example, in videoroom plugin , i could catch packets flagged by that and make a buffer to count them, and lets say if user is talking for 2-3 seconds and if ptime is default 20ms, I can acumulate 100-150 packets and then fiire event and empty the buffer.

Maybe something like that .... :)
The tricky part is how to get packets that are flagged, and of course other browsers might not support that audio-level. By the way is that this one:
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level

Lorenzo Miniero

unread,
Jan 5, 2017, 12:05:04 PM1/5/17
to meetecho-janus, lmin...@gmail.com
We made that quite easy, actually...
Just call that method in the plugin's incoming_rtp.

L.

Lorenzo Miniero

unread,
Jan 5, 2017, 12:05:57 PM1/5/17
to meetecho-janus, lmin...@gmail.com
That said, yes, of course audio-level support must be negotiated. You can check the configuration of VideoRoom and AudioBridge (among others) to see how they do that.

L.

Mirko Brankovic

unread,
Jan 6, 2017, 7:18:53 AM1/6/17
to meetecho-janus
Oh great, really easy, all i need to do is to see how you triggered events from plugin once I accumulate enough packets that method returns 0 (finds flagged).

Thanks for pointers.

Mirko Brankovic

unread,
Jan 13, 2017, 5:21:35 AM1/13/17
to meetecho-janus
Hi,
I experienced janus crash when there is no POST backend listening for events, so on every event I get this:
[Fri Jan 13 11:00:57 2017] [ERR] [events/janus_sampleevh.c:janus_sampleevh_handler:573] Couldn't relay event to the backend: Couldn't connect to server

But crash happens when I use VideoCall example and on register of user I get janus down message back.
Now I tried with gdb to get core file and some more info what happens, but I failed. Replication is easy but I need to learn how to use gdb properly, so styding (https://janus.conf.meetecho.com/docs/debug.html)

As soon as I get more I will come back.

Lorenzo Miniero

unread,
Jan 13, 2017, 5:28:55 AM1/13/17
to meetecho-janus
Thanks, that would help! cacheworks also experienced something similar in his tests:


so figuring out what causes this issue when the HTTP backend goes away would be helpful. It doesn't seem to happen to me, but I haven't done any intensive test in that direction yet.

Lorenzo
Message has been deleted

Mirko Brankovic

unread,
Jan 13, 2017, 1:31:38 PM1/13/17
to meetecho-janus
I'm probably doing something wrong.

I started it like this":
So i'm passing an empty file as core file and it is not recognized as core file, which is a problem.
But then when I 'Start' videocall plugin before registration i'm watshing janus process status and I see it stopped but on gdb there is no SIGTERM caught.

Can you tell me what i'm going wrong?

Thanks,
mirko 
L.
L.
Great work, thanks :)

To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Mirko

--
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Mirko

--
You received this message because you are subscribed to the Google Groups "meetecho-janus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards,
Mirko

Lorenzo Miniero

unread,
Jan 13, 2017, 1:56:59 PM1/13/17
to meetecho-janus
You've configured Janus to run as a daemon. This means that the process you're debugging is closed and exits as soon as the daemon (Janus itself) is started as a different process. Try launching Janus in foreground instead, or wait for it to crash and generate a core dump you can open in gdb later on.

L.

Mirko Brankovic

unread,
Jan 13, 2017, 4:18:22 PM1/13/17
to meetecho-janus
Great, thanks for tip Lorenzo,

Here is the gist:

Now I don't see anything useful with my eyes, except for the func where it crashed :D

VideoCall was only one I could reproduce it with, but I only used videoroom so not sure if it is plug-in related.

Regards,
Mirko

Mirko Brankovic

unread,
Jan 13, 2017, 4:23:10 PM1/13/17
to meetecho-janus

Lorenzo Miniero

unread,
Jan 13, 2017, 4:45:05 PM1/13/17
to Mirko Brankovic, meetecho-janus
Thanks, I'll have a look when I get back to the office. 

L.

To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janus+unsubscribe@googlegroups.com.

Lorenzo Miniero

unread,
Jan 20, 2017, 1:31:41 PM1/20/17
to meetecho-janus, mirkobr...@gmail.com
Just finished writing an addition to the blog post I linked before, which deals with correlation of Janus events:


Lorenzo

globalik slivov

unread,
May 19, 2018, 7:43:04 AM5/19/18
to meetecho-janus
It would be nice to have an example not in zip archive but on the github repo.
Via what the events are broadcasted? Via http from client side?
Is it possible to broadcast all events to the phunix transport directly?

Lorenzo Miniero

unread,
May 21, 2018, 4:53:23 AM5/21/18
to meetecho-janus
There are several presentations out there where I explain what event handlers, how they work and how you can use the events, one of them being FOSDEM 2017 that you can find in the FAQ: https://janus.conf.meetecho.com/docs/FAQ#videos
There's one from a couple of weeks ago that you may be interested in as well:

phom...@gmail.com

unread,
Jun 14, 2018, 3:35:53 AM6/14/18
to meetech...@googlegroups.com

Lorenzo, those videos make me hungry for more.  I'm assuming the Janus sipcapture work isn't published yet.  I do see some janus configuration values over there though: https://github.com/sipcapture/hepipe.js

I'd love to get my greedy paws onto more!

Thanks, Paul

--

Lorenzo Miniero

unread,
Jun 14, 2018, 4:33:37 AM6/14/18
to meetecho-janus
Not sure what you mean by SIP capture. We have been pushing SIP messages we handle via event handlers since day one. The project you mention is Homer, which is one of the tools that can receive events and process them:


L.
To unsubscribe from this group and stop receiving emails from it, send an email to meetecho-janus+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages