Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 34 additions & 18 deletions .github/workflows/test.yml → .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Integrate
on:
push:
branches:
Expand All @@ -9,7 +9,13 @@ on:
permissions:
contents: read
jobs:
test:
lint:
runs-on: ubuntu-latest
name: Lint
steps:
- uses: holepunchto/actions/node-base@v1
- run: npm run lint
prebuild:
strategy:
matrix:
include:
Expand Down Expand Up @@ -61,15 +67,10 @@ jobs:
platform: win32
arch: arm64
runs-on: ${{ matrix.os }}
name: ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }}
name: Build / ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- run: |
sudo apt update
sudo apt install -y nasm
- uses: holepunchto/actions/bare-base@v1
- run: sudo apt install -y nasm
if: ${{ matrix.platform == 'linux' || matrix.platform == 'android' }}
- run: pip3 install meson
if: ${{ matrix.platform == 'linux' || matrix.platform == 'android' }}
Expand All @@ -84,12 +85,27 @@ jobs:
env:
PATH: C:\tools\msys64\usr\bin
if: ${{ matrix.platform == 'win32' }}
- run: npm install -g bare-runtime bare-make
- run: npm install
- run: bare-make generate --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} --debug ${{ matrix.flags }}
- run: bare-make build
- run: bare-make install
- uses: holepunchto/actions/compile-prebuilds@v1
with:
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
tags: ${{ matrix.tags}}
flags: --debug ${{ matrix.flags }}
upload: true
test:
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
- os: macos-latest
platform: darwin
- os: windows-latest
platform: win32
runs-on: ${{ matrix.os }}
needs: prebuild
name: Test / ${{ matrix.platform }}
steps:
- uses: holepunchto/actions/bare-base@v1
- uses: holepunchto/actions/download-prebuilds@v1
- run: npm test
if: ${{ matrix.platform == 'linux' || (matrix.platform == 'darwin' && matrix.arch == 'arm64') || (matrix.platform == 'win32' && matrix.arch == 'x64') }}
- run: npm run example
if: ${{ matrix.platform == 'linux' || (matrix.platform == 'darwin' && matrix.arch == 'arm64') || (matrix.platform == 'win32' && matrix.arch == 'x64') }}
48 changes: 10 additions & 38 deletions .github/workflows/prebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,47 +56,19 @@ jobs:
platform: win32
arch: arm64
runs-on: ${{ matrix.os }}
name: ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }}
name: Build / ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: holepunchto/actions/bare-base@v1
- uses: holepunchto/actions/compile-prebuilds@v1
with:
node-version: lts/*
- run: |
sudo apt update
sudo apt install -y nasm
if: ${{ matrix.platform == 'linux' || matrix.platform == 'android' }}
- run: pip3 install meson
if: ${{ matrix.platform == 'linux' || matrix.platform == 'android' }}
- run: brew install meson nasm llvm@20
if: ${{ matrix.platform == 'darwin' || matrix.platform == 'ios' }}
- run: choco upgrade llvm
if: ${{ matrix.platform == 'win32' }}
- run: choco install --ignore-package-exit-codes meson nasm msys2
if: ${{ matrix.platform == 'win32' }}
- run: pacman --noconfirm -S git make ninja pkgconf nasm
shell: C:\tools\msys64\usr\bin\bash.exe -e {0}
env:
PATH: C:\tools\msys64\usr\bin
if: ${{ matrix.platform == 'win32' }}
- run: npm install -g bare-runtime bare-make
- run: npm install
- run: bare-make generate --platform ${{ matrix.platform }} --arch ${{ matrix.arch }} ${{ matrix.flags }}
- run: bare-make build
- run: bare-make install
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }}
path: prebuilds/*
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
tags: ${{ matrix.tags}}
flags: ${{ matrix.flags }}
upload: true
merge:
runs-on: ubuntu-latest
needs: prebuild
name: Merge
steps:
- uses: actions/download-artifact@v4
with:
path: prebuilds
merge-multiple: true
- uses: actions/upload-artifact@v4
with:
name: prebuilds
path: prebuilds
- uses: holepunchto/actions/merge-prebuilds@v1
96 changes: 96 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Publish
on:
push:
tags:
- v*
permissions:
id-token: write
contents: write
jobs:
prebuild:
strategy:
matrix:
include:
- os: ubuntu-22.04
platform: linux
arch: x64
- os: ubuntu-22.04-arm
platform: linux
arch: arm64
- os: ubuntu-24.04
platform: android
arch: x64
flags: -D ANDROID_STL=c++_shared
- os: ubuntu-24.04
platform: android
arch: ia32
flags: -D ANDROID_STL=c++_shared
- os: ubuntu-24.04
platform: android
arch: arm64
flags: -D ANDROID_STL=c++_shared
- os: ubuntu-24.04
platform: android
arch: arm
flags: -D ANDROID_STL=c++_shared
- os: macos-15
platform: darwin
arch: x64
- os: macos-15
platform: darwin
arch: arm64
- os: macos-15
platform: ios
arch: arm64
- os: macos-15
platform: ios
arch: arm64
tags: -simulator
flags: --simulator
- os: macos-15
platform: ios
arch: x64
tags: -simulator
flags: --simulator
- os: windows-2022
platform: win32
arch: x64
- os: windows-2022
platform: win32
arch: arm64
runs-on: ${{ matrix.os }}
name: Build / ${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.tags }}
steps:
- uses: holepunchto/actions/bare-base@v1
- run: sudo apt install -y nasm
if: ${{ matrix.platform == 'linux' || matrix.platform == 'android' }}
- run: pip3 install meson
if: ${{ matrix.platform == 'linux' || matrix.platform == 'android' }}
- run: brew install meson nasm llvm@20
if: ${{ matrix.platform == 'darwin' || matrix.platform == 'ios' }}
- run: choco upgrade llvm
if: ${{ matrix.platform == 'win32' }}
- run: choco install --ignore-package-exit-codes meson nasm msys2
if: ${{ matrix.platform == 'win32' }}
- run: pacman --noconfirm -S git make ninja pkgconf nasm
shell: C:\tools\msys64\usr\bin\bash.exe -e {0}
env:
PATH: C:\tools\msys64\usr\bin
if: ${{ matrix.platform == 'win32' }}
- uses: holepunchto/actions/compile-prebuilds@v1
with:
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
tags: ${{ matrix.tags}}
flags: ${{ matrix.flags }}
upload: true
publish:
runs-on: ubuntu-latest
environment:
name: npm
needs: prebuild
name: Publish
steps:
- uses: holepunchto/actions/node-base@v1
- uses: holepunchto/actions/download-prebuilds@v1
- uses: holepunchto/actions/publish@v1
1 change: 1 addition & 0 deletions lib/format-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ switch (Bare.platform) {
}

exports.InputFormatContext = class FFmpegInputFormatContext extends FFmpegFormatContext {
// eslint-disable-next-line
constructor(io, options, url = defaultURL) {
if (io instanceof IOContext) {
super(io)
Expand Down
4 changes: 2 additions & 2 deletions lib/hw-device-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module.exports = class HWDeviceContext {
}
}

static from(handle) {
if (handle == null) return null
static from(handle = null) {
if (handle === null) return null
return new HWDeviceContext(null, undefined, handle)
}

Expand Down
4 changes: 2 additions & 2 deletions lib/hw-frames-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ module.exports = class HWFramesContext {
)
}

static from(handle) {
if (handle == null) return null
static from(handle = null) {
if (handle === null) return null
return new HWFramesContext(null, null, null, null, null, handle)
}

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
],
"addon": true,
"scripts": {
"test": "prettier . --check && bare test.js",
"format": "prettier . --write && clang-format -i binding.cc",
"example": "bare ./examples/index.js"
"format": "prettier --write . && lunte --fix",
"lint": "prettier --check . && lunte",
"test": "brittle-bare --coverage test.js"
},
"repository": {
"type": "git",
Expand All @@ -37,6 +37,7 @@
"cmake-bare": "^1.1.2",
"cmake-harden": "^1.0.2",
"cmake-ports": "^1.6.3",
"lunte": "^1.8.0",
"prettier": "^3.3.3",
"prettier-config-holepunch": "^2.0.0"
}
Expand Down
14 changes: 7 additions & 7 deletions test/codec-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ test('codec context should return false when buffer is full', (t) => {
const frame = fakeFrame()

t.plan(1)
while (codecCtx.sendFrame(frame)) {} // Make the internal buffer full
while (codecCtx.sendFrame(frame)); // Make the internal buffer full
t.ok(true)
})

Expand All @@ -103,7 +103,7 @@ test('codec context should expose a receivePacket method', (t) => {
setDefaultOptions(codecCtx)
codecCtx.open(getEncoderOptions())
const frame = fakeFrame()
while (codecCtx.sendFrame(frame)) {} // Make the internal buffer full
while (codecCtx.sendFrame(frame)); // Make the internal buffer full

const packet = new ffmpeg.Packet()
t.ok(codecCtx.receivePacket(packet))
Expand Down Expand Up @@ -186,15 +186,15 @@ test('CodecContext should expose a getFormat callback setter', (t) => {
using codecCtx = new ffmpeg.CodecContext(ffmpeg.Codec.OPUS.decoder)

t.execution(() => {
codecCtx.getFormat = function getFormat() {}
codecCtx.getFormat = function () {}
})
})

test('CodecContext getFormat callback should expose context as an CodecContext instance', (t) => {
const { decodeOnce, decoder } = setupDecoder()

t.plan(1)
decoder.getFormat = function getFormat(context, pixelFormats) {
decoder.getFormat = function (context, pixelFormats) {
t.ok(context instanceof ffmpeg.CodecContext)
const pixelFormat = pixelFormats.find((fmt) => fmt === ffmpeg.constants.pixelFormats.YUV420P)
return pixelFormat && ffmpeg.constants.pixelFormats.NONE
Expand All @@ -206,7 +206,7 @@ test('CodecContext getFormat callback should expose context as an CodecContext i
test('pixelFormat should have been changed after negociation', (t) => {
const { decodeOnce, decoder } = setupDecoder()

decoder.getFormat = function getFormat(_context, pixelFormats) {
decoder.getFormat = function (context, pixelFormats) {
const pixelFormat = pixelFormats.find((fmt) => fmt === ffmpeg.constants.pixelFormats.YUV420P)
return pixelFormat && ffmpeg.constants.pixelFormats.NONE
}
Expand All @@ -219,7 +219,7 @@ test('CodecContext getFormat callback should expose pixelFormats as an Array', (
const { decodeOnce, decoder } = setupDecoder()

t.plan(1)
decoder.getFormat = function getFormat(_context, pixelFormats) {
decoder.getFormat = function (context, pixelFormats) {
t.ok(Array.isArray(pixelFormats))
const pixelFormat = pixelFormats.find((fmt) => fmt === ffmpeg.constants.pixelFormats.YUV420P)
return pixelFormat && ffmpeg.constants.pixelFormats.NONE
Expand Down Expand Up @@ -403,7 +403,7 @@ function setupDecoder() {
let newPixelFormat

while (format.readFrame(packet)) {
if (packet.streamIndex != stream.index) continue
if (packet.streamIndex !== stream.index) continue

decoder.open()
newPixelFormat = decoder.pixelFormat
Expand Down
8 changes: 4 additions & 4 deletions test/codec-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ test('CodecParameters class should expose a extraData setter', (t) => {
const buf = Buffer.from('test')
codecParam.extraData = buf

t.ok(codecParam.extraData[0] == 't'.charCodeAt(0))
t.ok(codecParam.extraData[1] == 'e'.charCodeAt(0))
t.ok(codecParam.extraData[2] == 's'.charCodeAt(0))
t.ok(codecParam.extraData[3] == 't'.charCodeAt(0))
t.ok(codecParam.extraData[0] === 't'.charCodeAt(0))
t.ok(codecParam.extraData[1] === 'e'.charCodeAt(0))
t.ok(codecParam.extraData[2] === 's'.charCodeAt(0))
t.ok(codecParam.extraData[3] === 't'.charCodeAt(0))
})

test('CodecParameters class should expose bitRate getter', (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function decodeVideo(video) {
decoder.open()
decoder.sendPacket(packet)

while (decoder.receiveFrame(frame)) {}
while (decoder.receiveFrame(frame));

if (stream.codecParameters.type === constants.mediaTypes.VIDEO) {
result.video.push(packet.data)
Expand Down
4 changes: 2 additions & 2 deletions test/dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test('it should expose an entries method', (t) => {
dict.set('foo', 'bar')
dict.set('boo', 'baz')

let entries = dict.entries()
const entries = dict.entries()

t.alike(entries.at(0), ['foo', 'bar'])
t.alike(entries.at(1), ['boo', 'baz'])
Expand All @@ -57,7 +57,7 @@ test('it should expose an iterator', (t) => {
dict.set('foo', 'bar')
dict.set('boo', 'baz')

let result = []
const result = []
for (const [key, value] of dict) result.push({ key, value })

t.is(result.at(0).key, 'foo')
Expand Down
2 changes: 1 addition & 1 deletion test/io-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ function runStreams(io) {
decoder.open()
decoder.sendPacket(packet)

while (decoder.receiveFrame(new ffmpeg.Frame())) {}
while (decoder.receiveFrame(new ffmpeg.Frame()));

if (mediaType === mediaTypes.VIDEO) {
video.push(packet.data)
Expand Down
Loading
Loading