How to get real-time updates of viewer count

363 views
Skip to first unread message

ji...@whiteroomanalytics.com

unread,
Jan 27, 2019, 11:18:10 PM1/27/19
to Ant Media Server
Say you want to show the number of people are viewing the broadcast (one-way) for every viewers.

I would imagine for the app, we track when people join and leave, then update the counter in our own database.
But from my understanding, there's no webhook action for viewer connecting to and dropping from the webRTC connection, how would we do this accurately and in real-time too?

Another alternative is to make the server to get the video summary for every X seconds, but this is incredibly inefficient.

Am I missing something?

Thanks in advance!

Selim Emre

unread,
Jan 28, 2019, 11:37:49 AM1/28/19
to Ant Media Server
Hi,
Thank you for the great question. Ant Media Server Viewers Rest Services are listed below; 

serverip/WebRTCAppEE/rest/broadcast/getWebRTCClientStats/streamId 
serverip/WebRTCAppEE/rest/broadcast/get?id=streamId 

Also you can use these Rest Services in Webhook. Please let me know if you have any problem.
Have a nice Live Video Streaming Experience with Ant Media Server :-)

Best Regards,
Selim
Message has been deleted

ji...@whiteroomanalytics.com

unread,
Jan 28, 2019, 11:45:34 AM1/28/19
to Ant Media Server
Thanks Selim, could you elaborate what you meant by using Rest Services in Webhook.
From the documentation, it seems like there are only 3 actions being recorded, but there are no actions for viewers specifically, say viewerJoinedStream, viwerLeftStream, etc.

Selim Emre

unread,
Jan 29, 2019, 6:39:07 AM1/29/19
to Ant Media Server
Hi,
I misunderstood something. Sorry for that. The webhook structure is not suitable for the viewer. Actually, you can use the rest service to view the number of views on the video periodically.

serverip/WebRTCAppEE/rest/broadcast/getWebRTCClientStats/streamId 
serverip/WebRTCAppEE/rest/broadcast/get?id=streamId 

Ibrahim cisse

unread,
Feb 15, 2019, 12:07:08 PM2/15/19
to Ant Media Server

Selim Emre

unread,
Feb 17, 2019, 11:18:35 AM2/17/19
to Ant Media Server
Hi @ibrahim,

Thank you for your question. You can access rest service in localhost. You must log in to the server for other connections.You can also delete the rest auth filter according to the below tutorial information

http://localhost:5080/LiveApp/rest/broadcast/get?id=streamId 

If you want to remove this rest filtering mechanism, please remove the below lines from webapps-> {Application} -> WEBINF -> web.xml

<filter>
    <filter-name>RestAuthenticationFiler</filter-name>
    <filter-class>io.antmedia.serverapp.pscp.filter.RestAuthenticationFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>RestAuthenticationFiler</filter-name>
    <url-pattern>/rest/*</url-pattern>
</filter-mapping>

After you remove the rest filter, you can access it with serverip.

http://serverip:5080/LiveApp/rest/broadcast/get?id=streamId 

If you have any question, please feel free to ask us.

Best Regards,
Selim
Reply all
Reply to author
Forward
0 new messages