ant-media / Ant-Media-Server

Ant Media Server is a live streaming engine software that provides adaptive, ultra low latency streaming by using WebRTC technology with ~0.5 seconds latency. Ant Media Server is auto-scalable and it can run on-premise or on-cloud.
https://antmedia.io
Other
4.28k stars 631 forks source link

Ant media SDK "@antmedia/webrtc_adaptor": "^2.6.4" Unable to show Bitrate and avg bitrate while streaming and viewing live streaming #5765

Open yogeshJain0727 opened 1 year ago

yogeshJain0727 commented 1 year ago

Short description

I want to show the average incoming bitrate and current incoming bitrate of the current live streaming. For this, I am calling the averageIncomingBitrate() and currentIncomingBitrate() functions. However, I am getting a "this.webrtcAdaptor.currentIncomingBitrate is not a function" error in our Angular (version 14) Web Applications. Can you please help me demonstrate how to call this function? Additionally, I am not receiving the "info == 'updated_stats'" response in the callback of initWebrtc. (Ant media SDK "@antmedia/webrtc_adaptor": "^2.6.4").

Environment

Steps to reproduce

  1. calling the averageIncomingBitrate() and currentIncomingBitrate() functions. 2.receiving the "info == 'updated_stats'".

Expected behavior

When using the averageIncomingBitrate() and currentIncomingBitrate() functions, we can obtain information about the average bitrate, current bitrate, and lost packets.

Actual behavior

When using the averageIncomingBitrate() and currentIncomingBitrate() functions, I encountered an error message stating "this.webrtcAdaptor.currentIncomingBitrate is not a function."

Ask your questions on Ant Media Github Discussions

timantmedia commented 11 months ago

@yogeshJain0727 you need to make sure to call the webRTCAdaptor.enableStats(obj.streamId); method to enable stats. Here is an example of where it is enabled on the play.html page.

https://github.com/ant-media/StreamApp/blob/d4355797acb2bc6f637463307de2aa7eb9d3a7f3/src/main/webapp/player.html#L329

Then the updated_stats callback will start and from there you can fetch the obj.averageIncomingBitrate and obj.currentIncomingBitrate.

https://github.com/ant-media/StreamApp/blob/d4355797acb2bc6f637463307de2aa7eb9d3a7f3/src/main/webapp/player.html#L388

Let us know if this still doesn't work for you, then you can provide a code sample and we can take a look.

yogeshJain0727 commented 11 months ago

@timantmedia, thank you for responding to us. This works for me.