Web SDK "NOT_ENOUGH_BANDWIDTH" not fire.

jhong

New Member
Hello,
I need to display alert message to user when user connection is slow/lag, i follow the demo player.js from github but still not receive NOT_ENOUGH_BANDWIDTH event, please help. Below is my code:

Code:
var options = {
        name: streamName,
        display: remoteVideo,
        flashShowFullScreenButton: true
    };
    if (resolution_for_wsplayer) {
        options.playWidth = resolution_for_wsplayer.playWidth;
        options.playHeight = resolution_for_wsplayer.playHeight;
    } else if (resolution) {
        options.playWidth = resolution.split("x")[0];
        options.playHeight = resolution.split("x")[1];
    }
    stream = session.createStream(options).on(STREAM_STATUS.PENDING, function(stream) {
        var video = document.getElementById(stream.id());
        if (!video.hasListeners) {
            video.hasListeners = true;
            video.addEventListener('playing', function () {
                $("#preloader").hide();
            });
            video.addEventListener('resize', function (event) {
                var streamResolution = stream.videoResolution();
                if (Object.keys(streamResolution).length === 0) {
                    resizeVideo(event.target);
                } else {
                    // Change aspect ratio to prevent video stretching
                    var ratio = streamResolution.width / streamResolution.height;
                    var newHeight = Math.floor(options.playWidth / ratio);
                    resizeVideo(event.target, options.playWidth, newHeight);
                }
            });
        }
    }).on(STREAM_STATUS.PLAYING, function (stream) {
        setStatus(stream.status());
        onStarted(stream);
    }).on(STREAM_STATUS.STOPPED, function () {
        setStatus(STREAM_STATUS.STOPPED);
        onStopped();
    }).on(STREAM_STATUS.FAILED, function () {
        setStatus(STREAM_STATUS.FAILED);
        onStopped();
    }).on(STREAM_STATUS.NOT_ENOUGH_BANDWIDTH, function (stream) {
// alert added here
        console.log("Not enough bandwidth, consider using lower video resolution or bitrate. Bandwidth " + (Math.round(stream.getNetworkBandwidth() / 1000)) + " bitrate " + (Math.round(stream.getRemoteBitrate() / 1000)));
    });
    stream.play();
 

Max

Administrator
Staff member
Hello
The NOT_ENOUGH_BANDWIDTH event is raised when you have 5% and more packet lost on the playback stream.
Test
1. Use a network tool generating packet lost.
2. Configure UDP download lost to 6%
3. Play a stream over WebRTC.
Expected results
1. You should see NOT_ENOUGH_BANDWIDTH in WCS_HOME/logs/flashphoner_manager.log
2. You should see NOT_ENOUGH_BANDWIDTH in Web SDK layer
 

Sean Tee

New Member
3. Play a stream over WebRTC.
How about play with mediaproviders = [MSE,WSPlayer]?
Tool
1. Google Chrome
2. Net Limiter ( limit speed only )
 

Max

Administrator
Staff member
MSE and WSPlayer work over TCP. These providers do not fire the NOT_ENOUGH_BANDWIDTH event.
Only WebRTC media provider can fire the event.
 

Sean Tee

New Member
MSE and WSPlayer work over TCP. These providers do not fire the NOT_ENOUGH_BANDWIDTH event.
Only WebRTC media provider can fire the event.
No Wonder, Btw anyway to detect lag/latency while using MSE/WSPlayer?
Unable to use WebRTC, because of some security issue, we don't open UDP port
Thanks!
 

Max

Administrator
Staff member
Hello
Code:
No Wonder, Btw anyway to detect lag/latency while using MSE/WSPlayer?
MSE and WSPlayer are TCP based technologies.
You can't target latency if you are on TCP. Latency can float depending on network circumstances.
Unable to use WebRTC, because of some security issue, we don't open UDP port
You can use WebRTC over TLS port 443 or another selected port.
To get this working you have to install TURN relay server
https://flashphoner.com/docs/wcs5/w...nd_testing-firewall_traversal-turn_server.htm
Here you can see example how WebRTC works over TCP and single port 443
https://wcs5-eu.flashphoner.com/cli...l-streaming/firewall-traversal-streaming.html
It may help with latency but it is TCP again (TLS is TCP), so you won't get guaranteed latency in such a case too.
 

Sean Tee

New Member
Hi Max,
Thanks for advice, any idea on client side which able to detect packet loss rather than rely on server side.
Example like bitrate changed callback or every input data code level entry point?
2. also is there any option to have something like drop frame, i mean always play latest scene although lag
 

Max

Administrator
Staff member
Thanks for advice, any idea on client side which able to detect packet loss rather than rely on server side.
TCP does not have packet lost.
All packets are reliably delivered in TCP and you can't impact it. Player has to wait until all packets are received in order.
Example like bitrate changed callback or every input data code level entry point?
Currently we don't have such notifications on TCP sessions (WSPlayer, MSE).
also is there any option to have something like drop frame, i mean always play latest scene although lag
You can try to get png snapshots from the stream https://flashphoner.com/creating-a-preview-snapshots-thumbnails-of-a-webrtc-video-stream-in-png/
It will return last decoded frame with a lag for decoding time.
 
Top