0.23.3 • Published 4 months ago

@skylineos/clsp-player v0.23.3

Weekly downloads
12
License
MIT
Repository
github
Last release
4 months ago

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.

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

CLSP Streams

The highest h.264 keyframe/iframe segment frequency this player currently supports is 2 per second (this is different from frames per second).

URL Structure

The network protocol is handled by specifying the following URI format:

[clsp protocol] :// [sfs-host] : [port-number-of-web-socket] / [stream-name]

  • clsp protocol: clsp or clsps
  • sfs-host: the host (or ip address) of the Skyline SFS
  • port-number-of-web-socket: optional, @see Default Port
  • stream-name: the stream name as defined on the Skyline SFS

Example stream url:

clsp://sfs.somecity.com/CityFeedVideo0652

Note that many Skyline SFS production LTS deployments use a default port of 9001. To accomodate for this, you do not necessarilly need to append the port 9001 to every clsp url. You can use the utility method utils.setDefaultStreamPort, which is documented below.

Tokenization

Control stream access via jwt tokens.

JWT

The JWT authorization method provides authorization as well as stream access time.

clsps://[sfs-host]:[port-number-of-web-socket]/[stream-name]
  ?token=[jwt-token]
  • sfs-host: the host (or ip address) of the Skyline SFS
  • port-number-of-web-socket: required, @see Default Port
  • stream-name: the stream name as defined on the Skyline SFS
  • token: contains a jwt token with the expiration claim, signed by the shared secret

The token is created by the stream manager. A shared secret exists between the stream manager and Skyline SFS(s) You will need to work with Skyline to configure and use jwt token support.

Default Port

protocol / SFS version>= v5.2.0< v5.2.0
clsp809001
clsps443443

Note that many Skyline SFS production LTS deployments use a default port of 9001. To accomodate for this, you do not necessarilly need to append the port 9001 to every clsp url. You can use the utility method utils.setDefaultStreamPort, which is documented below.

Installation

Via Yarn

yarn add @skylineos/clsp-player

Via NPM

Note that installation /use via yarn is recommended as it is what we use for development, testing, and dependency management.

npm i @skylineos/clsp-player

Use

via <script> tag

NOTE: See demos/single-player/ and demos/advanced-dist/ for full examples.

A CLSP object is attached to window, which contains the classes and utils you need to create players.

<head> Tag

<head>
  <!-- load CLSP Player styles -->
  <link
    rel="stylesheet"
    href="/path/to/dist/clsp-player.css"
  >
<head>

<script> Tag

<!-- load CLSP Player in `head` or `body` -->
<script src="/path/to/dist/clsp-player.min.js"></script>

<!-- use CLSP Player at end of `body` -->
<script>
  var videoElementId = 'my-video';
  var urls = [
    'clsps://bd-demo-sfs1.skyvdn.com/testpattern',
    'clsps://bd-demo-sfs1.skyvdn.com/testpattern',
  ];

  // If you are using a Skyline SFS that uses a default CLSP stream port that
  // isn't `80` (e.g. SFS < v5.2.0), you may set the window-level default port
  // for `clsp` streams:
  window.CLSP.utils.setDefaultStreamPort('clsp', 9001);

  // Construct the player collection
  var iovCollection = window.CLSP.IovCollection.asSingleton();

  // Instantiate the iov instance for the target video element
  var iov = iovCollection.create({
    videoElementId: videoElementId,
  })

  // play a CLSP stream with the iov instance
  iov.changeSrc(urls[0])
    .then(/*..*/)
    .catch(/*..*/);
</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-player-container clsp-container-fit">
    <video id="my-video"></video>
  </div>
</div>

via import or require

NOTE: See demos/single-player/ and demos/advanced-src/ for full examples.

JS

import {
  IovCollection,
  utils,
} from '@skylineos/clsp-player';

const videoElementId = 'my-video';
const urls = [
  'clsps://bd-demo-sfs1.skyvdn.com/testpattern',
  'clsps://bd-demo-sfs1.skyvdn.com/testpattern',
];

try {
  // If you are using a Skyline SFS that uses a default CLSP stream port that
  // isn't `80` (e.g. SFS < v5.2.0), you may set the window-level default port
  // for `clsp` streams:
  utils.setDefaultStreamPort('clsp', 9001);

  // Construct the player collection
  const iovCollection = IovCollection.asSingleton();

  // Instantiate the iov instance for the target video element
  const iov = iovCollection.create({ videoElementId });

  // play a CLSP stream with the iov instance
  await iov.changeSrc(urls[0]);
}
catch (error) {
  // do something with the error
  console.error(error);
}

Styles (SASS)

@import '/path/to/node_modules/@skylineos/clsp-player/dist/clsp-player.css';
// or import it from src
@import '/path/to/node_modules/@skylineos/clsp-player/src/styles/clsp-player.scss';

<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.

<!-- The outer container used for your styling -->
<div class="video-container">
  <!-- The inner container used by CLSP for styling and other operations -->
  <div class="clsp-player-container clsp-container-fit">
    <video id="my-video"></video>
  </div>
</div>

Known Issues

Videos appear to have a low framerate

During testing, we have encountered an issue where a large number of CLSP streams ( > 30 ) played on a single page in Chrome can appear choppy or to have a low framerate. This same test / demo works without issue on other machines, or in Firefox.

The underlying symptom appears to be a large number ( > 50 ) of Style recalcs / sec as reported by the Chrome Performance Monitor. This high number has only been observed in Chrome with specific video cards and with hardware acceleration enabled (which is the default setting).

This appears to be a bug in the Chrome browser, and there are anecdotal reports of this behavior online starting from early 2019, but no official bug report that we are aware of.

At the moment, the only known workarounds are to disable hardware acceleration in Chrome's settings, try using the Firefox browser, or try using a different video card.

0.23.3

4 months ago

0.23.2

5 months ago

0.20.2

9 months ago

0.23.1

2 years ago

0.23.1-1

2 years ago

0.23.0-2

2 years ago

0.23.1-2

2 years ago

0.23.0-1

2 years ago

0.23.0

2 years ago

0.22.1

2 years ago

0.22.1-1

3 years ago

0.22.0

4 years ago

0.22.0-10

4 years ago

0.22.0-9

4 years ago

0.22.0-8

4 years ago

0.22.0-7

4 years ago

0.22.0-6

4 years ago

0.22.0-5

4 years ago

0.22.0-2

4 years ago

0.22.0-3

4 years ago

0.22.0-4

4 years ago

0.21.1

4 years ago

0.21.0

4 years ago

0.21.0-1

4 years ago

0.20.1

4 years ago

0.20.1-1

4 years ago

0.20.0

4 years ago

0.19.0

4 years ago

0.19.0-3

4 years ago

0.19.0-2

4 years ago

0.19.0-1

4 years ago

0.18.0

4 years ago

0.18.0-4

4 years ago

0.18.0-3

4 years ago

0.18.0-2

4 years ago