Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit a403a88

Browse files
authored
chore!: combine into single media-stream-library package (#1085)
Moves the overlay, player, and streams modules into the media-stream-library package, but as separate exports. This simplifies package management and moves the two smaller related packages into the main package. Improves to the way releases work: - Always have the package version changed when any changes are made to the source, and add a verification for this (housekeeping job). - Release using a workflow trigger, takes the package as it is and creates both a GitHub release and publishes to NPM, using the version already contained in the source. - Keep the minified bundle that includes the dependencies outside of the dist folder (thereby excluding it from the NPM package). Since that bundle is only needed outside of a package system, and then we don't need to export it separately. BREAKING CHANGES: - `media-overlay-library` and `media-stream-player` packages are no longer provided, they are now available from `media-stream-library/overlay` and `media-stream-library/player` respectively. - The format of the minified bundles is changed from IIFE to ES module, since this now has baseline support across all modern browsers. Together these changes allow for simple release flow, where we can just pick latest main for releases, where the correct version is already part of source control.
1 parent c32f8bb commit a403a88

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+431
-1338
lines changed

.github/workflows/publish.yml

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
# Publishes a GitHub release and NPM package for
2-
# any tag that is pushed to the repository.
3-
# Tags should be generated automatically by
4-
# manually running the "release" workflow.
1+
# Publishes a GitHub release and NPM package for the provided package.
2+
# Tags are generated automatically on release.
3+
# The release/publish steps can be skipped (in case of a re-release attempt).
54
name: Publish
65

76
on:
8-
push:
9-
branches:
10-
- main
11-
- 13-stable
7+
workflow_dispatch:
8+
inputs:
9+
gh-release:
10+
description: 'Create a github release?'
11+
required: true
12+
type: boolean
13+
default: true
14+
npm-publish:
15+
description: 'Publish to NPM?'
16+
required: true
17+
type: boolean
18+
default: true
1219

1320
jobs:
1421
publish:
15-
if: ${{ startsWith(github.event.head_commit.message, 'release:') }}
1622
runs-on: ubuntu-latest
1723
steps:
1824
- uses: extractions/setup-just@v1
1925
- uses: actions/checkout@v4
2026

2127
- name: Extract version number
2228
id: vars
23-
run: echo ::set-output name=version::v$(jq -r .version package.json)
29+
run: |
30+
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT
2431
2532
- name: Setup node
2633
uses: actions/setup-node@v4
@@ -36,54 +43,25 @@ jobs:
3643
just install
3744
just build
3845
39-
- name: Release
46+
- name: Create GitHub release
47+
if: ${{ inputs.gh-release }}
4048
id: release
41-
uses: actions/create-release@v1
4249
env:
4350
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # provided by Actions
44-
with:
45-
tag_name: ${{ steps.vars.outputs.version }}
46-
release_name: Release ${{ steps.vars.outputs.version }}
47-
body_path: CHANGELOG.md
48-
draft: false
49-
prerelease: false
50-
51-
- name: Upload media-stream-library
52-
uses: actions/upload-release-asset@v1.0.1
53-
env:
54-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55-
with:
56-
upload_url: ${{ steps.release.outputs.upload_url }}
57-
asset_path: streams/dist/media-stream-library.min.js
58-
asset_name: media-stream-library.min.js
59-
asset_content_type: application/javascript
60-
61-
- name: Upload media-stream-player
62-
uses: actions/upload-release-asset@v1.0.1
63-
env:
64-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
with:
66-
upload_url: ${{ steps.release.outputs.upload_url }}
67-
asset_path: player/dist/media-stream-player.min.js
68-
asset_name: media-stream-player.min.js
69-
asset_content_type: application/javascript
70-
71-
- name: Upload media-overlay-library
72-
uses: actions/upload-release-asset@v1.0.1
73-
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
with:
76-
upload_url: ${{ steps.release.outputs.upload_url }}
77-
asset_path: overlay/dist/media-overlay-library.min.js
78-
asset_name: media-overlay-library.min.js
79-
asset_content_type: application/javascript
51+
run: |
52+
yarn pack
53+
gh release create v${{ steps.vars.outputs.version }} \
54+
--target ${{ github.ref }} \
55+
-F CHANGELOG.md \
56+
-t "Release v${{ steps.vars.outputs.version }}" \
57+
package.tgz overlay/*.min.js* player/*.min.js* streams/*.min.js*
8058
81-
- name: Deploy NPM packages
59+
- name: Deploy to NPM registry
8260
env:
8361
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
8462
run: |
85-
if [[ $GITHUB_REF =~ alpha|beta ]]; then
86-
yarn workspaces foreach --no-private npm publish --tag next
63+
if [[ "${{ steps.vars.output.version }}" =~ alpha|beta ]]; then
64+
yarn npm publish --tag next
8765
else
88-
yarn workspaces foreach --no-private npm publish --tag latest
66+
yarn npm publish --tag latest
8967
fi

.github/workflows/verify.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,36 @@ jobs:
109109
run: just build
110110
- name: Test basic video functionality
111111
run: scripts/ci-video-test.sh edge
112+
113+
housekeeping:
114+
runs-on: ubuntu-latest
115+
steps:
116+
- name: Checkout repository
117+
uses: actions/checkout@v4
118+
119+
- name: Checkout repository@main
120+
uses: actions/checkout@v4
121+
with:
122+
ref: main
123+
path: __ref-main
124+
125+
- name: Check if package.json version was updated
126+
run: |
127+
this_version=$(jq -r '.version' package.json)
128+
if [[ "$this_version" == "null" ]]; then
129+
continue
130+
fi
131+
if [[ ! -f "__ref-main/package.json" ]]; then
132+
main_version=""
133+
else
134+
main_version=$(jq -r '.version' __ref-main/package.json)
135+
fi
136+
if [[ "$main_version" == "$this_version" ]]; then
137+
echo "::error:: package.json version ($main_version) was not updated"
138+
exit 1
139+
elif ! grep -q "^## $this_version" CHANGELOG.md; then
140+
echo "::error:: CHANGELOG.md was not updated with latest version"
141+
exit 1
142+
else
143+
echo "::notice:: package.json updated: $main_version => $this_version"
144+
fi

.gitignore

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# Logs
22
*.log
33

4-
# Coverage directory (tests with coverage)
4+
# Build/Test
5+
*.min.js*
56
build/
67
coverage/
7-
8-
# Bundles
98
dist/
10-
tsconfig.tsbuildinfo
11-
*.min.js*
9+
*.tsbuildinfo
1210

1311
# Cypress
1412
cypress/videos/

CHANGELOG.md

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,19 @@
1-
## [13.2.0](https://github.com/AxisCommunications/media-stream-library-js/compare/db30d3bda424de8011f46ed5f2d7c79fb8ad69e4..0ff93c1f6edead9ff7fccc5eac21e87b2600e964) (2025-01-07T16:48:02.968Z)
2-
3-
### 🚧 Maintenance
4-
5-
- **deps**: bump the dependencies group across 1 directory with 3 updates (#1000) ([6997451](https://github.com/AxisCommunications/media-stream-library-js/commit/6997451619516e8311efbe37cce7073534a0b149))
6-
- **deps-dev**: bump c8 from 9.1.0 to 10.1.2 (#995) ([b7db610](https://github.com/AxisCommunications/media-stream-library-js/commit/b7db6100dfa535bc0d28598398385db521c29ba2))
7-
- **deps-dev**: bump the dev-dependencies group across 1 directory with 8 updates (#1006) ([6e07315](https://github.com/AxisCommunications/media-stream-library-js/commit/6e073153aa747beacf3623fc9abbb02ea06ca865))
8-
- **deps-dev**: bump the dev-dependencies group across 1 directory with 15 updates (#989) ([76017bb](https://github.com/AxisCommunications/media-stream-library-js/commit/76017bbff22dfcd3dbdc8551ae448176907ba9fe))
9-
- **deps**: bump ws from 8.16.0 to 8.17.1 in the npm_and_yarn group (#981) ([49eaa51](https://github.com/AxisCommunications/media-stream-library-js/commit/49eaa5190ae8469e36556ff971c51549ef018a6c))
10-
- **deps-dev**: bump the dev-dependencies group with 5 updates (#938) ([6351e77](https://github.com/AxisCommunications/media-stream-library-js/commit/6351e77108e62e1898a0f3ddf4f6f1ef7a4e0e6b))
11-
- update code owners (#934) ([c5db120](https://github.com/AxisCommunications/media-stream-library-js/commit/c5db12049fc2179e294a015628c908ffed4769f6))
12-
- **deps**: upgrade to Node.js v20 (#933) ([18c26c4](https://github.com/AxisCommunications/media-stream-library-js/commit/18c26c4ebbc28333ba369da6ff5a08606eae8441))
13-
- **deps**: upgrade minor/patch (#932) ([2c2d7a3](https://github.com/AxisCommunications/media-stream-library-js/commit/2c2d7a338c47293ad352a14f0b10b94035cc6e0f))
14-
- **deps-dev**: bump jsdom from 23.2.0 to 24.0.0 (#931) ([f8939c9](https://github.com/AxisCommunications/media-stream-library-js/commit/f8939c9ed55b7e648f605ab55913f23e8a53c760))
15-
- **deps-dev**: bump the dev-dependencies group with 10 updates (#930) ([c07bfa4](https://github.com/AxisCommunications/media-stream-library-js/commit/c07bfa4b839066b5fb7f4f0bf538b06f37bce180))
16-
- allow hoisting to the root level ([49c266f](https://github.com/AxisCommunications/media-stream-library-js/commit/49c266fc0d8a366103e10c54a513a6d1e23729ef))
17-
- update workflows ([f461338](https://github.com/AxisCommunications/media-stream-library-js/commit/f461338abc899ff5cf052046f0facbfc43771fd8))
18-
- remove eslint-disable comments ([59f0613](https://github.com/AxisCommunications/media-stream-library-js/commit/59f06132ad3d77126f97b7356a6f021bc5104674))
19-
- satisfy biome checks ([4e9e041](https://github.com/AxisCommunications/media-stream-library-js/commit/4e9e0410c484465badcd579d0c559325894750a1))
20-
- biome import sorting ([0210ee1](https://github.com/AxisCommunications/media-stream-library-js/commit/0210ee17f3976f0b1f066e53e5250606bd0bd91d))
21-
- biome formatting ([51318dc](https://github.com/AxisCommunications/media-stream-library-js/commit/51318dc52d5576920f97abbe6600ad7259eb62f6))
22-
- use yarn and replace dprint/eslint with biome ([00abee0](https://github.com/AxisCommunications/media-stream-library-js/commit/00abee002c293f0f811fee171013ce5633a33509))
23-
- remove git LFS ([5c48be4](https://github.com/AxisCommunications/media-stream-library-js/commit/5c48be4bda7a12f4c430208d0162e88f6971368f))
24-
- **deps-dev**: bump the dev-dependencies group with 11 updates (#914) ([8488fae](https://github.com/AxisCommunications/media-stream-library-js/commit/8488fae4b74aa714432996b13fd30c8db05db390))
25-
- **deps-dev**: bump jsdom from 22.1.0 to 23.2.0 (#892) ([9f230db](https://github.com/AxisCommunications/media-stream-library-js/commit/9f230db4ce70ef4da727d442ce6a313ccbc71075))
26-
- **deps-dev**: bump follow-redirects from 1.15.3 to 1.15.5 (#889) ([c4f72ea](https://github.com/AxisCommunications/media-stream-library-js/commit/c4f72ea8c32a73955549d8f34e7486794d597b43))
27-
- **deps-dev**: bump c8 from 8.0.1 to 9.1.0 (#890) ([63e08ac](https://github.com/AxisCommunications/media-stream-library-js/commit/63e08ac687720edd50d78d5df93c73b6b3a4f7ee))
28-
- **deps-dev**: bump stylelint from 15.11.0 to 16.1.0 (#891) ([f4efbe7](https://github.com/AxisCommunications/media-stream-library-js/commit/f4efbe7198423768c131be18a2d34c148a48b852))
29-
- support merge queues (#893) ([d263395](https://github.com/AxisCommunications/media-stream-library-js/commit/d26339547d42f68c1297af4653c2966169c21322))
30-
31-
### 📝 Documentation
32-
33-
- add quick install steps for example (#1029) ([998d5e2](https://github.com/AxisCommunications/media-stream-library-js/commit/998d5e2b3c22711d91c566f949d52ad2ca503fcc))
34-
35-
### 🐛 Bug fixes
36-
37-
- replace npm with yarn for upgrades/releases ([0ff93c1](https://github.com/AxisCommunications/media-stream-library-js/commit/0ff93c1f6edead9ff7fccc5eac21e87b2600e964))
38-
- force negative frame durations to zero (#769) ([e6773e7](https://github.com/AxisCommunications/media-stream-library-js/commit/e6773e7ccccec782e655af4dab5c79e51eb67e45))
39-
40-
### 🧪 Test
41-
42-
- add build verification for Node.js v22 (#1028) ([06968d7](https://github.com/AxisCommunications/media-stream-library-js/commit/06968d7be1d540ae357ba187a1c333465c70217d))
1+
## 14.0.0-beta.0
2+
3+
- Switched to workflow-based releases with version as part of source.
4+
This means that each PR has to have an update of the package.json version
5+
number and update the CHANGELOG.md file.
6+
- **BREAKING**: Move `player` and `overlay` packages into the `media-stream-library` package.
7+
These can be imported as `media-stream-library/player` and `media-stream-library/overlay`.
8+
- **BREAKING**: Only export ES modules (including minified bundles with external dependencies).
9+
- **BREAKING**: Replaced Node.js Buffer with Uint8Array.
10+
- **BREAKING**: Replaced Node.js Stream module with Web Streams API.
11+
Components and pipelines are redesigned completely, check the source
12+
and examples for details on how to migrate.
13+
- **BREAKING**: Replaced `debug` package with internal log module.
14+
Set `msl-streams-debug`, `msl-player-debug`, and `msl-overlay-debug`
15+
`localStorage` keys to `"true"` instead for logging.
16+
- **BREAKING**: Removed CommonJS support and separation of Node.js
17+
and Browser exports.
18+
- Added AAC test audio to the default RTSP H.264 test video.
19+

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License
22

3-
Copyright (c) 2018-2023 Axis Communications AB
3+
Copyright (c) 2018-2025 Axis Communications AB
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,89 @@
1-
# Media streams and overlay
1+
# Media Stream Library JS
22

3-
This repository hosts 3 different libraries used for playback
4-
of video streams and enabling simpler SVG overlays.
3+
[![CI][ci-image]][ci-url]
4+
[![NPM][npm-image]][npm-url]
5+
6+
[ci-image]: https://github.com/AxisCommunications/media-stream-library-js/actions/workflows/verify.yml/badge.svg?branch=main
7+
[ci-url]: https://github.com/AxisCommunications/media-stream-library-js/actions/workflows/verify.yml
8+
[npm-image]: https://img.shields.io/npm/v/media-stream-library.svg
9+
[npm-url]: https://www.npmjs.com/package/media-stream-library
10+
11+
## Installation
12+
13+
Make sure you have Node installed on your machine.
14+
Then, to install the library:
15+
16+
```sh
17+
npm install media-stream-library
18+
```
19+
20+
or
21+
22+
```sh
23+
yarn add media-stream-library
24+
```
25+
26+
## Usage
27+
28+
- [streams](streams/README.md)
29+
- [player](player/README.md)
30+
- [overlay](overlay/README.md)
31+
32+
## Contributing
533

634
For development, you'll need a local installation of [Node.js](https://nodejs.org/),
735
and [yarn](https://v3.yarnpkg.com/) to install dependencies.
836
To run commands, you need [just](https://just.systems/), which can be installed using
937
[prebuilt binaries](https://just.systems/man/en/chapter_5.html#pre-built-binaries) or
1038
[yarn](https://just.systems/man/en/chapter_8.html#nodejs-installation), e.g.
1139
`yarn global add just-install`.
40+
41+
Please read our [contributing guidelines](CONTRIBUTING.md) before making pull
42+
requests.
43+
44+
## FAQ
45+
46+
**Will it work with this library if it works with VLC?**
47+
48+
Not necessarily. We only support a particular subset of the protocol useful for
49+
basic streaming from IP cameras. With RTSP that is H.264+AAC or JPEG, and only
50+
some simple profiles/levels are supported. For MP4, it depends entirely on your
51+
browser if the media can be played.
52+
53+
**Do I need to use RTSP for live (or low-latency) video?**
54+
55+
Since this library only supports RTSP through some form of TCP connection, it's
56+
going to have similar latency as streaming MP4 over HTTP. For true low-latency
57+
real-time usage, you should either use a stand-alone player that can handle RTP over UDP,
58+
or use WebRTC in the browser.
59+
60+
You should expect in-browser latency of several frames. When using Firefox, you
61+
might need to set the duration of the MediaSource to `0` to force live behaviour
62+
with lower latency (see one of the browser examples).
63+
The exact latency is controlled by the browser itself, and the data inside the
64+
media stream can affect this (e.g. if audio is present or not).
65+
66+
**Does this library support audio?**
67+
68+
Yes, yes it does. With a few caveats though.
69+
70+
- Make sure your AXIS camera actually supports audio
71+
- Make sure the audio is enabled on the camera.
72+
- It only works with H.264 and only after user interaction with the volume slider
73+
74+
**How do I autoplay video?**
75+
76+
Browsers will only allow to autoplay a video if it's muted. If the video is
77+
not muted, then it will only play if the `play` method was called from inside
78+
a handler of a user-initiated event. Note that different browsers can have
79+
different behaviours. Read https://developer.chrome.com/blog/autoplay for more
80+
details.
81+
82+
## Acknowledgements
83+
84+
The icons used are from https://github.com/google/material-design-icons/, which
85+
are available under the Apache 2.0 license, more information can be found on:
86+
http://google.github.io/material-design-icons
87+
88+
The spinner is from https://github.com/SamHerbert/SVG-Loaders, available under
89+
the MIT license.

changeset.md

Lines changed: 0 additions & 6 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)