bandwidth questions

SLM

Member
In some instances, the viewer of a stream gets the javascript event trigger STREAM_STATUS.NOT_ENOUGH_BANDWIDTH
I know this relates to the webrtc_cc2_bitrate_overuse_event_threshold setting in flashphoner.properties. This is now set on 0.1.

1. What I don't get is why the stream.getNetworkBandwidth() is sometimes 0. These events are logged to the server and if there temporarily is no connection at all no client to server logging can be done at all at that time.

2. Also, it seems that you can only read stream.getNetworkBandwidth() when a NOT_ENOUGH_BANDWIDTH occurs. Is that correct? Why can't you read this value/function or the stream.getRemoteBitrate() value on a STREAM_STATUS.PLAYING event?

3. Next, what should be the course of action when such a STREAM_STATUS.NOT_ENOUGH_BANDWIDTH event occurs? Should I lower the bitrate (of the player not the publisher) immediately? Can I do that while the stream is still playing or is it done by flashphoner.js automatically?

4. Why is there a huge difference in the values of stream.getRemoteBitrate() during these bandwidth events ? Is it because flashphoner automatically lowers the bitrate after such an event? We see values ranging from 250 to 2500 and the webrtc_cc_min_bitrate was set on 500000 so it should be 500 at minimum.

5. On the domain/:8081/?action=stat url we can see some cpu load stats etc. The last 2 values are always zero:
global_bandwidth_in
global_bandwidth_out
Why is that, is there a setting somewhere to change that? And is this value a total value, current value or average?
 

Max

Administrator
Staff member
Hello.
1. What I don't get is why the stream.getNetworkBandwidth() is sometimes 0.
This function call works only for streams that is playing, not publishing.
3. Next, what should be the course of action when such a STREAM_STATUS.NOT_ENOUGH_BANDWIDTH event occurs? Should I lower the bitrate (of the player not the publisher) immediately? Can I do that while the stream is still playing or is it done by flashphoner.js automatically?
NOT_ENOUGH_BANDWIDTH event means that there is not enough bandwidth to publish or play the stream. Bandwidth requirements depends not only on bitrate, but also on stream resolution, framerate and GOP. For WebRTC streams, a browser can automatically change bitrate or resolution if bandwidth is not enough, we can only limit bitrate on browser side in this case (in Chrome browser only), and we can do it before publishsing stream, but not on the fly.
4. Why is there a huge difference in the values of stream.getRemoteBitrate() during these bandwidth events ? Is it because flashphoner automatically lowers the bitrate after such an event? We see values ranging from 250 to 2500 and the webrtc_cc_min_bitrate was set on 500000 so it should be 500 at minimum.
It is not server, it is browser who rules bitrate when stream is published. On server side we can only recommend to browser to hold bitrate in certain limits. To limit bitrate on browser side you can set SDP parametes as described here, it work for Chrome browser only.
2. Also, it seems that you can only read stream.getNetworkBandwidth() when a NOT_ENOUGH_BANDWIDTH occurs. Is that correct? Why can't you read this value/function or the stream.getRemoteBitrate() value on a STREAM_STATUS.PLAYING event?
5. On the domain/:8081/?action=stat url we can see some cpu load stats etc. The last 2 values are always zero:
global_bandwidth_in
global_bandwidth_out
We will check these issues (WCS-1688) and let you know when find something.
 

SLM

Member
Hello.
This function call works only for streams that is playing, not publishing.
I was referring to playing streams. We get 0 values quite a lot. Perhaps it is a rounding issue (because the value is divided by 1000 then rounded), I will check.

It is not server, it is browser who rules bitrate when stream is published. On server side we can only recommend to browser to hold bitrate in certain limits. To limit bitrate on browser side you can set SDP parametes as described here, it work for Chrome browser only.
Does constraints: {audio: {bitrate: xx}, video: {minBitrate: yyyy, maxBitrate: zzzz} only work for publishing?

We will check these issues (WCS-1688) and let you know when find something.
Thanks
 

Max

Administrator
Staff member
Does constraints: {audio: {bitrate: xx}, video: {minBitrate: yyyy, maxBitrate: zzzz} only work for publishing?
Yes. You can set default bitrate for playback with constraints { video: {bitrate: aaa} }, but bitrate can be dropped if there is not enough bandwidth.
 

Max

Administrator
Staff member
The functions getNetworkBandwidth(), getRemoteBitrate() is obsoleted. You can use stream.getStats() function to obtain WebRTC statistics as shown here, it is avalable both for publishing and playback.
NOT_ENOUGH_BANDWIDTH is mostly informational message, it shows that packets loss to all packets ratio is more than webrtc_cc2_bitrate_overuse_event_threshold, so we cannot affect stream parameters when playing it. You can set webrtc_cc2_bitrate_overuse_event_threshold to more than 0.1.
If you set default bitrate on players side, it automatically enables stream transcoding on server, that consumes more system resources.
global_bandwidth values is always 0 because this statistics is disabled by default. You can enable it with setting
Code:
global_bandwidth_check_enabled=true
But it will use C library that can be incompatible with your servers system.
 

SLM

Member
Yes. You can set default bitrate for playback with constraints { video: {bitrate: aaa} }, but bitrate can be dropped if there is not enough bandwidth.
Thank you

The functions getNetworkBandwidth(), getRemoteBitrate() is obsoleted. You can use stream.getStats() function to obtain WebRTC statistics as shown here, it is avalable both for publishing and playback.
I don't see a current bandwidth or current bitrate variable/function in this new function. How to get the same info with the new function? And is it compatible with WCS 5.0.2971 ?

global_bandwidth values is always 0 because this statistics is disabled by default. You can enable it with setting
Code:
global_bandwidth_check_enabled=true
But it will use C library that can be incompatible with your servers system.
It's on a CentOS Linux server. Does this adversely affect system performance?
 

Max

Administrator
Staff member
Hello.
I don't see a current bandwidth or current bitrate variable/function in this new function. How to get the same info with the new function?
The object that getStats() passes to your callback function, contains at least the following fields for inbound (played) stream:
Code:
bytesReceived: 250099
firCount: 0
fractionLost: 0
framesDecoded: 43
nackCount: 0
packetsLost: 0
packetsReceived: 209
pliCount: 0
qpSum: 1115
ssrc: 1599065267
timestamp: 1545362490161
type: "inbound-rtp"
You can calculate:
- a current bandwith for inbound stream as packetsLost to packetsReceived ratio;
- a current bitrate for inbound stream as bytesReceived divided to seconds count from playback start;
And is it compatible with WCS 5.0.2971 ?
It is WebSDK function, and you already have it with this version (but you have no getStats() example, because it was added in later WebSDK build).
You can update WCS to latest 5.0.3530, and WebSDK will be updated together, or update WebSDK only from this page.
 

SLM

Member
You can calculate:
- a current bandwith for inbound stream as packetsLost to packetsReceived ratio;
- a current bitrate for inbound stream as bytesReceived divided to seconds count from playback start;

It is WebSDK function, and you already have it with this version (but you have no getStats() example, because it was added in later WebSDK build).
You can update WCS to latest 5.0.3530, and WebSDK will be updated together, or update WebSDK only from this page.
Thank you for your help.
 
Top