Skip to content

Commit

Permalink
Merge pull request #6 from THEOplayer/cmcd
Browse files Browse the repository at this point in the history
cmcd
  • Loading branch information
georgechoustoulakis authored Mar 6, 2024
2 parents d3acbaf + 4591080 commit 57ab883
Show file tree
Hide file tree
Showing 27 changed files with 1,591 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .changeset/happy-beans-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
1 change: 1 addition & 0 deletions .idea/web-connectors.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions cmcd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# These are some examples of commonly ignored file patterns.
# You should customize this list as applicable to your project.
# Learn more about .gitignore:
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore

# Node artifact files
node_modules/
lib/
dist/

# JetBrains IDE
.idea/

# Unit test reports
TEST*.xml

# Generated by MacOS
.DS_Store

# Generated by Windows
Thumbs.db

# THEOplayer build and TypeScript definitions
local/
7 changes: 7 additions & 0 deletions cmcd/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @theoplayer/cmcd-connector-web

## 1.0.0

### ✨ Features

- Initial release
21 changes: 21 additions & 0 deletions cmcd/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 THEO Technologies NV

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
88 changes: 88 additions & 0 deletions cmcd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# cmcd-connector-web

A connector between a THEOplayer instance and a Common Media Client Data (CMCD) server for the THEOplayer
HTML5/Tizen/webOS SDK. This implementation supports CMCD data as defined in CTA-5004, published in September 2020.

## Prerequisites
In order to use this connector, a [THEOplayer](https://www.npmjs.com/package/theoplayer) build with a valid license is required. You can use your existing THEOplayer HTML5 SDK license or request yours via [THEOportal](https://portal.theoplayer.com/).

## Installation

Install using your favorite package manager for Node (such as `npm` or `yarn`):

### Install via npm

```bash
npm install @theoplayer/cmcd-connector-web
```

### Install via yarn

```bash
yarn add @theoplayer/cmcd-connector-web
```

## Usage

First you need to add the CMCD connector to your app :

* Add as a regular script

```html
<script type="text/javascript" src="path/to/cmcd-connector.umd.js"></script>
<script type="text/javascript">
const player = new THEOplayer.Player(element, playerConfiguration);
const connector = THEOplayerCMCDConnector.createCMCDConnector(player);
</script>
```

* Add as an ES2015 module

```html
<script type="module">
import { createCMCDConnector } from "path/to/cmcd-connector.esm.js";
const player = new THEOplayer.Player(element, playerConfiguration);
const connector = createCMCDConnector(player);
</script>
```

By default, the data is sent via query arguments, but you can configure the transmission mode before creating the CMCD connector. For example, to transmit via HTTP headers:

* regular script

```html
<script type="text/javascript" src="path/to/cmcd-connector.umd.js"></script>
<script>
const player = new THEOplayer.Player(element, playerConfiguration);
const configuration = {
transmissionMode: THEOplayerCMCDConnector.TransmissionMode.HTTP_HEADER
}
const connector = THEOplayerCMCDConnector.createCMCDConnector(player, configuration);
</script>
```

* ES2015 module

```html
<script type="module">
import { createCMCDConnector, TransmissionMode } from "path/to/cmcd-connector.esm.js";
const player = new THEOplayer.Player(element, playerConfiguration);
const configuration = {
transmissionMode: TransmissionMode.HTTP_HEADER
}
const connector = createCMCDConnector(player, configuration);
</script>
```

The connector will be automatically destroyed upon destruction of the provided player. When changing the player source and a content ID is
being passed in, this is to be reset through `reconfigure()` as it will not be cleared automatically.

## Remarks
Note that when native playback is being used, either through THEOplayer's configuration, or due to absence of MSE/EME
APIs, the JSON Object transmission mode should be used.

Currently, all standardized reserved keys are reported, except:

- Object duration (`d`)
- Next object request (`nor`)
- Next range request (`nrr`)
4 changes: 4 additions & 0 deletions cmcd/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
preset: "ts-jest",
testEnvironment: "node"
};
43 changes: 43 additions & 0 deletions cmcd/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@theoplayer/cmcd-connector-web",
"version": "1.0.0",
"description": "A connector implementing CMCD support for web.",
"main": "dist/cmcd-connector.umd.js",
"repository": {
"type": "git",
"url": "git+https://github.com/THEOplayer/web-connectors.git",
"directory": "cmcd"
},
"homepage": "https://theoplayer.com/",
"module": "dist/cmcd-connector.esm.js",
"types": "dist/cmcd-connector.d.ts",
"exports": {
".": {
"types": "./dist/cmcd-connector.d.ts",
"import": "./dist/cmcd-connector.esm.js",
"require": "./dist/cmcd-connector.umd.js"
},
"./dist/*": "./dist/*",
"./package": "./package.json",
"./package.json": "./package.json"
},
"scripts": {
"clean": "rimraf lib dist",
"bundle": "rollup -c rollup.config.mjs",
"build": "npm run clean && npm run bundle",
"serve": "http-server",
"test": "jest"
},
"author": "THEO Technologies NV",
"license": "MIT",
"files": [
"dist/",
"CHANGELOG.md",
"README.md",
"LICENSE.md",
"package.json"
],
"peerDependencies": {
"theoplayer": "^5.0.0 || ^6.0.0"
}
}
13 changes: 13 additions & 0 deletions cmcd/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import fs from "node:fs";
import {getSharedBuildConfiguration} from "../tools/build.mjs";

const {version} = JSON.parse(fs.readFileSync("./package.json", "utf8"));

const fileName = "cmcd-connector";
const globalName = "THEOplayerCMCDConnector"
const banner = `
/**
* THEOplayer CMCD Connector v${version}
*/`.trim();

export default getSharedBuildConfiguration(fileName, globalName, banner);
Loading

0 comments on commit 57ab883

Please sign in to comment.