Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Doc update (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
littlespex authored Nov 7, 2021
1 parent fffb91a commit 062d982
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
37 changes: 19 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ npm i cmcd.js
```

## Usage
The top level `Cmcd` object contains references to all the CMCD data properties. Properties that are not filled out, or have `null` or `undefined` values, will not be serialized.
All CMCD properties are optional. Properties that are with nullish values will not be serialized.

```typescript
import {
Expand All @@ -18,22 +18,23 @@ import {
toHeaders,
toJson,
toQuery
} from 'cmcd-ts';

const data = new Cmcd();
data.sid = '9f7f349b-baba-43d7-bbe7-b0dc8a65af0d';
data.sf = CmcdStreamingFormat.DASH;
data.st = CmcdStreamType.VOD;
data.su = false;
data.mtp = 10000;
data.bs = true;
data.br = 200;
data.ot = CmcdObjectType.MANIFEST;
} from 'cmcd.js';

const data: Cmcd = {
cid: '9f7f349b-baba-43d7-bbe7-b0dc8a65af0d',
sf: CmcdStreamingFormat.DASH,
st: CmcdStreamType.VOD,
su: false,
mtp: 10000,
bs: true,
br: 200,
ot: CmcdObjectType.MANIFEST,
};

const query = toQuery(data);
console.log(query);
/*
'CMCD=br%3D200%2Cbs%2Cmtp%3D10000%2Cot%3Dm%2Csf%3Dd%2Csid%3D%229f7f349b-baba-43d7-bbe7-b0dc8a65af0d%22%2Cst%3Dv'
'CMCD=br%3D200%2Cbs%2Cmtp%3D10000%2Cot%3Dm%2Csf%3Dd%2Ccid%3D%229f7f349b-baba-43d7-bbe7-b0dc8a65af0d%22%2Cst%3Dv'
*/

const headers = toHeaders(data);
Expand All @@ -42,21 +43,21 @@ console.log(headers);
{
'cmcd-request': 'mtp=10000',
'cmcd-object': 'br=200,ot=m',
'cmcd-session': 'sf=d,sid="9f7f349b-baba-43d7-bbe7-b0dc8a65af0d",st=v',
'cmcd-session': 'sf=d,cid="9f7f349b-baba-43d7-bbe7-b0dc8a65af0d",st=v',
'cmcd-status': 'bs',
}
*/

const json = toJson(data);
console.log(json);
/*
'{"mtp":10000,"su":false,"br":200,"ot":"m","sf":"d","sid":"9f7f349b-baba-43d7-bbe7-b0dc8a65af0d","st":"v","bs":true}'
'{"mtp":10000,"su":false,"br":200,"ot":"m","sf":"d","cid":"9f7f349b-baba-43d7-bbe7-b0dc8a65af0d","st":"v","bs":true}'
*/
```

## API Docs
https://littlespex.github.io/cmcd.js/

## References
- Spec: https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf
- Overview: https://www.youtube.com/watch?v=sWuQ3RZ6R5w&list=PLVztGGxiGfIhBmyFhixteZKJvWC3KlaSf&index=5

## Docs
https://littlespex.github.io/cmcd.js/
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cmcd.js",
"version": "0.5.0",
"description": "CMCD (Common Media Client Data) Library with Typescript definitions",
"version": "0.5.1",
"description": "CMCD (Common Media Client Data) library with Typescript definitions",
"main": "dist/cmcd.min.js",
"types": "dist/types/index.d.ts",
"type": "module",
Expand Down

0 comments on commit 062d982

Please sign in to comment.