Skyline CLSP Player
An html5 CLSP video player. CLSP is a proprietary near-real-time video streaming protocol only available via Skyline's SFS solutions.
The highest h.264 keyframe/iframe segment frequency this player currently supports is 2 per second (this is different from frames per second).
Table of Contents
Supported Browsers
Desktop
- Google Chrome 53+
- Mozilla Firefox 70+
- Microsoft Edge 80+ (Chromium-based)
All other desktop browsers are currently not supported.
Mobile
@todo
URL Structure
The network protocol is handled by specifying the following URI format:
[clsp protocol] :// [sfs-ip-address] : [port-number-of-web-socket] / [stream-name]
clsp protocol
: clsp or clspssfs-ip-address
: the ip address is that of the SFSport-number-of-web-socket
: the port is not necessary unless it is something other than 80 or 443stream-name
: the stream name as defined on the SFS
Example stream url:
clsp://172.28.12.57:9001/FairfaxVideo0520
Tokenization
With the latest version of the CLSP Player, you are able to control stream access with two diferent token methods.
Hash
The MD5 hash authentication method provides authentication as well as stream access time.
[clsp protocol]-hash://[sfs-ip-address]:[port-number-of-web-socket]/[stream-name]?start=[time-epoch-seconds]&end=[time-epoch-seconds]&token=[hash-token]
The token is created by appending a shared secret to the url. That new string is used to create an MD5 hash. The shared secret must first be set up on the SFS and the stream-requesting application.
NOTE: When using the Hash method of authentication, the [port-number-of-web-socket]
is a REQUIRED parameter.
In order to play a video stream that has Hash authentication enabed, there are 3 query parameters you need to pass along with your URL. Here is the structure of a clsp/clsps hash enabled url.
clsps-hash://<host>[:port]/stream?start={epoch_seconds}&end={epoch_seconds}&token={hashed_url}
clsp-hash://<host>[:port]/stream?start={epoch_seconds}&end={epoch_seconds}&token={hashed_url}
start
: contains the earliest time you want the stream to become available.end
: contains the latest time you want the stream to become available.token
: contains the entire url sans token, md5 + secret
Installation
Via Yarn
yarn add @babel/polyfill @skylineos/clsp-player
Via NPM
npm i @babel/polyfill @skylineos/clsp-player
Using with dist
assets
NOTE: See demos/simple-dist/
and demos/advanced-dist/
for full examples.
NOTE: @babel/polyfill
MUST be sourced/included prior to the CLSP Player.
<head>
Tag
<head>
<link
rel="stylesheet"
href="/path/to/dist/clsp-player.css"
>
<script
type="text/javascript"
src="//cdn.jsdelivr.net/npm/@babel/polyfill@7.8.7/dist/polyfill.min.js"
></script>
<head>
<script>
Tag
<script src="/path/to/dist/clsp-player.min.js"></script>
<script>
var videoElementId = 'my-video';
window.clspUtils.setDefaultStreamPort('clsp', 9001);
var iovCollection = window.IovCollection.asSingleton();
iovCollection.create(videoElementId)
.then(function (iov) {
iov.changeSrc('clsp://172.28.12.57:9001/FairfaxVideo0520');
})
.catch(function (error) {
});
var tour = window.TourController.factory(
window.IovCollection.asSingleton(),
videoElementId,
{
intervalDuration: 10,
},
);
tour.addUrls([
'clsp://172.28.12.57:9001/FairfaxVideo0520',
'clsp://172.28.12.57:9001/FairfaxVideo0420',
]);
tour.start();
</script>
<video>
tag
We recommend wrapping the video
tag in a container element (e.g. div
) that the CLSP Player can mutate as needed. The CLSP Player needs to perform some actions on the video
element as well as its container.
Note that for clsp
streams, the src
tag must have a type
attribute with a value of video/mp4; codecs='avc1.42E01E'
.
This tells the browser exactly what codec to use to decode and play the video. H.264 baseline 3.0 is a least common denominator codec supported on all browsers (according to the MSE development page).
<div class="video-container">
<div class="clsp-container-fit">
<video
id="my-video"
muted
playsinline
>
<source
src="clsp://172.28.12.57:9001/FairfaxVideo0520"
type="video/mp4; codecs='avc1.42E01E'"
/>
</video>
</div>
</div>
Using with src
assets
NOTE: See demos/simple-src/
and demos/advanced-src/
for full examples.
NOTE: @babel/polyfill
MUST be sourced/included prior to the CLSP Player.
JS
import '@babel/polyfill';
import clspUtils from '~root/src/js/utils/utils';
import IovCollection from '~root/src/js/iov/IovCollection';
import TourController from '~root/src/js/iov/TourController';
const videoElementId = 'my-video';
const urls = [
'clsp://172.28.12.57:9001/FairfaxVideo0520',
'clsp://172.28.12.57:9001/FairfaxVideo0420',
];
clspUtils.setDefaultStreamPort('clsp', 9001);
const iovCollection = IovCollection.asSingleton();
const iov = await iovCollection.create(videoElementId);
iov.changeSrc(urls[0]);
const tour = TourController.factory(
IovCollection.asSingleton(),
videoElementId,
{
intervalDuration: 10,
},
);
tour.addUrls(urls);
tour.start();
Styles (SASS)
@import '/path/to/node_modules/@skylineos/clsp-player/src/styles/clsp-player.scss';
Webpack
Create a specific module rule for the CLSP Player in your common webpack config. This is necessary since the CLSP Player source uses modern ES6+ features and webpack will ignore files in node_modules by default.
The following peer dependencies are required to build via webpack:
@babel/polyfill
@babel/core
babel-loader
@babel/preset-env
@babel/plugin-transform-typeof-symbol
@babel/plugin-syntax-dynamic-import
@babel/plugin-proposal-object-rest-spread
@babel/plugin-proposal-class-properties
- webpack SASS toolchain if using SASS src files. See
webpack.common.js
for an example.
Sample webpack config:
{
module: {
rules: [
{
test: /.*clsp-player\/(src|demos).*\.js$/,
loader: 'babel-loader?cacheDirectory=true',
options: {
presets: [
[
'@babel/preset-env',
{
exclude: [
'@babel/plugin-transform-typeof-symbol',
],
},
],
],
plugins: [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-proposal-class-properties',
],
},
},
],
},
}