QUANTEEC integration with Nice People At Work
Nice People At Work's Video Analytics (Youbora) is a video QoS and QoE measurement software solution helping video platforms and video providers identify how to improve video streaming quality with comprehensive and customizable dashboards of streaming quality metrics to instantly see the health of their video. QUANTEEC can be integrated with NPAW's Video Analytics to add P2P metrics to your existing dashboard. Hence, all of your QoS analytics are available in one place.
Integrate with NPAW web SDK by using the instances of Youbora and QUANTEEC
First of all, install NPAW's Video Analytics SDK with the appropriate video player adapter in your project. Information is available here.
If the object Youbora is publicly available in the web page "window" object, all you have to do is declare your Youbora plugin before initializing QUANTEEC. Then, set the Youbora adapter after initializing QUANTEEC.
// If window.youbora is defined
// 1 - Initialize the Youbora plugin.
window.plugin = new youbora.Plugin({ accountCode: 'accountTest' });
// 2 - Initialize the video player. This step depends on the video player you are using. For this example, we use a player called "Player".
var player = new Player();
// 3 - Initialize QUANTEEC.
var quanteecPlayer = new Quanteec(quanteecConfig, player);
// 4 - Set the adapter for the player "Player" to your Youbora plugin.
plugin.setAdapter(new youbora.adapters.PlayerAdapter(player))
If the Youbora object is not publicly available in the webpage window object, you need to pass it to QUANTEEC using the function "extendYouboraAdapters".
// If window.youbora is undefined
// 1 - Initialize the Youbora plugin.
window.plugin = new youbora.Plugin({ accountCode: 'accountTest' });
// 2 - Initialize the video player. This step depends on the video player you are using. For this example, we use a player called "Player".
var player = new Player();
// 3 - Initialize QUANTEEC.
var quanteecPlayer = new Quanteec(quanteecConfig, player);
// 4 - Pass the Youbora object to QUANTEEC in order to link P2P-related metrics
quanteecPlayer.extendYouboraAdapters(youbora);
// 5 - Set the adapter for the player "Player" to your Youbora plugin.
plugin.setAdapter(new youbora.adapters.PlayerAdapter(player));
Full example with the player hls.js :
- Without npm
- With npm
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<!-- Import QUANTEEC plugin for hls.js -->
<script src="https://files.quanteec.com/quanteec/latest/quanteec-hlsjs.min.js"></script>
<!-- Import NPAW's Youbora -->
<script src="http://smartplugin.youbora.com/v6/js/adapters/hlsjs/6.7.0/sp.min.js"></script>
</head>
<body>
<video id="videoplayer" width="854" height="480" controls></video>
<script>
document.addEventListener("DOMContentLoaded", function () {
var videoSource = "https://example.com/videoSource.m3u8";
// Initialize Youbora plugin
var youboraPlugin = new youbora.Plugin({ accountCode: '<your-youbora-accountCode>' });
// Adjust QUANTEEC configuration
var quanteecConfig = {
quanteecKey: "<your-quanteec-key>",
videoID: "<enter-your-custom-videoID>" // [Optional but recommended] String --> specific name to identify a video. Useful if the videosource url contains a token which is different for every user. By default: the videoSource value is used.
};
var videoPlayer = document.getElementById("videoplayer");
var hlsPlayer = new Hls();
// Link QUANTEEC to hls.js right *after* the creation of the hls.js player instance
var quanteecPlayer = new Quanteec(quanteecConfig, hlsPlayer);
// Initialize the adapter after the creation of the QUANTEEC instance
youboraPlugin.setAdapter(new youbora.adapters.Hlsjs(hlsPlayer));
hlsPlayer.loadSource(videoSource);
hlsPlayer.attachMedia(videoPlayer);
hlsPlayer.on(Hls.Events.MANIFEST_PARSED, function() {
videoPlayer.play();
});
});
</script>
</body>
</html>
npm install --save hls.js youboralib youbora-adapter-hlsjs
var Hls = require('hls.js');
var Quanteec = require('@quanteec/quanteec-hlsjs.min.js');
var youbora = require('youboralib');
require('youbora-adapter-hlsjs');
var videoSource = "https://example.com/videoSource.m3u8";
// Initialize Youbora plugin
var youboraPlugin = new youbora.Plugin({ accountCode: '<your-youbora-accountCode>' });
// Adjust QUANTEEC configuration
var quanteecConfig = {
quanteecKey: "<your-quanteec-key>",
videoID: "<enter-your-custom-videoID>" // [Optional but recommended] String --> specific name to identify a video. Useful if the videosource url contains a token which is different for every user. By default: the videoSource value is used.
};
var videoPlayer = document.getElementById("videoplayer");
var hlsPlayer = new Hls();
// Link QUANTEEC to hls.js right *after* the creation of the hls.js player instance
var quanteecPlayer = new Quanteec(quanteecConfig, hlsPlayer);
// Pass the Youbora object to QUANTEEC in order to link P2P-related metrics
quanteecPlayer.extendYouboraAdapters(youbora);
// Initialize the adapter after the creation of the QUANTEEC instance
youboraPlugin.setAdapter(new youbora.adapters.Hlsjs(hlsPlayer));
hlsPlayer.loadSource(videoSource);
hlsPlayer.attachMedia(videoPlayer);
hlsPlayer.on(Hls.Events.MANIFEST_PARSED, function() {
videoPlayer.play();
});
Integrate with NPAW web SDK by using the global QUANTEEC object
This feature is available since version 1.0.1.
When accessing the Youbora object after the instanciation of the QUANTEEC Plugin and before the instanciation of the Youbora Adapter, the global QUANTEEC object can be used. The static and global function QuanteecYouboraAdapter() should be called at the creation of the adapter.
var youboraPlugin = new youbora.Plugin({ accountCode: '<your-youbora-accountCode>' });
let yourCustomAdapter = ... // Create your adapter here
yourCustomAdapter.extend(Quanteec.QuanteecYouboraAdapter());
youboraPlugin.setAdapter(YourCustomAdapter);
The function QuanteecYouboraAdapter() extends the adapter and overwrites the functions getCdnTraffic(), getP2PTraffic(), getUploadTraffic(), and getIsP2PEnabled(). The functions are calling a global object accessible in the global variable window. Once created, the QUANTEEC Plugins will register in this global object and the Youbora Adapter will be able to get the P2P-related data.
Integrate with NPAW Exoplayer SDK
First of all, install NPAW in your project. Information is available here.
In order to integrate with QUANTEEC, it is necessary to create a custom Youbora Adapter extending Exoplayer2Adapter in order to transfer P2P-related metrics by using the QuanteecCore API. The adapter should be:
- Kotlin
- Java
open class Exoplayer2QuanteecAdapter(val quanteecCore: QuanteecCore, player: ExoPlayer) :
Exoplayer2Adapter(player) {
override fun getP2PTraffic(): Long? { return (quanteecCore.dataPeer as Number).toLong() }
override fun getCdnTraffic(): Long? { return (quanteecCore.dataCDN as Number).toLong() }
override fun getIsP2PEnabled(): Boolean { return quanteecCore.factory.generalSettings.isP2pActivated }
override fun getUploadTraffic(): Long? { return (quanteecCore.dataSent as Number).toLong() }
}
public class Exoplayer2QuanteecAdapter extends Exoplayer2Adapter {
private final QuanteecCore quanteecCore;
public Exoplayer2QuanteecAdapter(QuanteecCore quanteecCore, ExoPlayer player) {
super(player);
this.quanteecCore = quanteecCore;
}
@Override
public Long getP2PTraffic() {return ((Number) this.quanteecCore.getDataPeer()).longValue();}
@Override
public Long getCdnTraffic() {return ((Number) this.quanteecCore.getDataCDN()).longValue();}
@Override
public boolean getIsP2PEnabled() {return this.quanteecCore.getFactory().getGeneralSettings().isP2pActivated();}
@Override
public Long getUploadTraffic() {return ((Number) this.quanteecCore.getDataSent()).longValue();}
}
Then, it is necessary to set this adapter to the Youbora plugin after the creation of the QuanteecCore object.
- Kotlin
- Java
val adapter = Exoplayer2QuanteecAdapter(quanteecCore, mExoPlayer)
youboraPlugin.adapter = adapter
Exoplayer2QuanteecAdapter adapter = new Exoplayer2QuanteecAdapter(quanteecCore, mExoPlayer);
youboraPlugin.setAdapter(adapter);
Full example:
- Kotlin
- Java
open class Exoplayer2QuanteecAdapter(val quanteecCore: QuanteecCore, player: ExoPlayer) :
Exoplayer2Adapter(player) {
override fun getP2PTraffic(): Long? { return (quanteecCore.dataPeer as Number).toLong() }
override fun getCdnTraffic(): Long? { return (quanteecCore.dataCDN as Number).toLong() }
override fun getIsP2PEnabled(): Boolean { return quanteecCore.factory.generalSettings.isP2pActivated }
override fun getUploadTraffic(): Long? { return (quanteecCore.dataSent as Number).toLong() }
}
YouboraLog.setDebugLevel(YouboraLog.Level.VERBOSE);
val youboraOptions = Options()
youboraOptions.accountCode = "<your-youbora-accountCode>"
val youboraPlugin = Plugin(youboraOptions, context)
youboraPlugin.activity = activity // Android variable "activity"
val quanteecConfig = QuanteecConfig("<enter-your-custom-videoID>", "<your-quanteec-key>");
val quanteecCore = QuanteecExoCore(context, quanteecConfig);
val quanteecDataSourceFactory = QuanteecBaseDataSource.Factory(quanteecCore);
val quanteecBandwidthMeters = QuanteecBandwidthMeters.Builder(context).build();
val mExoPlayer = remember(mContext) {
ExoPlayer.Builder(mContext).setMediaSourceFactory(DefaultMediaSourceFactory(mContext).setDataSourceFactory(quanteecDataSourceFactory)
).setBandwidthMeter(quanteecBandwidthMeters
).build().apply {
val mediaItem = MediaItem.Builder(
).setUri(Uri.parse("your-video-url")
).build()
setMediaItem(mediaItem)
playWhenReady = true
}
}
quanteecCore.setPlayer(mExoPlayer);
val adapter = Exoplayer2QuanteecAdapter(quanteecCore, mExoPlayer)
youboraPlugin.adapter = adapter
mExoPlayer.prepare();
public class Exoplayer2QuanteecAdapter extends Exoplayer2Adapter {
private final QuanteecCore quanteecCore;
public Exoplayer2QuanteecAdapter(QuanteecCore quanteecCore, ExoPlayer player) {
super(player);
this.quanteecCore = quanteecCore;
}
@Override
public Long getP2PTraffic() {return ((Number) this.quanteecCore.getDataPeer()).longValue();}
@Override
public Long getCdnTraffic() {return ((Number) this.quanteecCore.getDataCDN()).longValue();}
@Override
public boolean getIsP2PEnabled() {return this.quanteecCore.getFactory().getGeneralSettings().isP2pActivated();}
@Override
public Long getUploadTraffic() {return ((Number) this.quanteecCore.getDataSent()).longValue();}
}
YouboraLog.setDebugLevel(YouboraLog.Level.VERBOSE);
Options youboraOptions = new Options();
youboraOptions.setAccountCode("<your-youbora-accountCode>");
Plugin youboraPlugin = new Plugin(youboraOptions, /*context = */ context);
youboraPlugin.setActivity(/*activity = */ activity);
QuanteecConfig quanteecConfig = new QuanteecConfig("<enter-your-custom-videoID>", "<your-quanteec-key>");
QuanteecCore quanteecCore = new QuanteecExoCore(/* context= */ context, quanteecConfig);
QuanteecBaseDataSource.Factory quanteecDataSourceFactory = QuanteecBaseDataSource.Factory(quanteecCore);
QuanteecBandwidthMeters quanteecBandwidthMeters = new QuanteecBandwidthMeters()
ExoPlayer.Builder playerBuilder =
new ExoPlayer.Builder(/*context=*/ context)
.setMediaSourceFactory(
new DefaultMediaSourceFactory(/* context= */ context).
setDataSourceFactory(quanteecBaseDataSourceFactory)
).setBandwidthMeter(quanteecBandwidthMeters);
ExoPlayer mExoPlayer = playerBuilder.build()
quanteecCore.setPlayer(mExoPlayer);
Exoplayer2QuanteecAdapter adapter = new Exoplayer2QuanteecAdapter(quanteecCore, mExoPlayer);
youboraPlugin.setAdapter(adapter);
mExoPlayer.prepare()