From fce8d696124e511c1ef248c38b1f55bf00657f17 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Sat, 27 May 2023 12:07:49 -0700 Subject: [PATCH] Check in some starter thinking around a media API in bitjs. --- .github/workflows/node.js.yml | 2 +- media/README.md | 1 + media/media.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 media/README.md create mode 100644 media/media.js diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 9052a60..5f93857 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [17.x, 18.x] + node-version: [17.x, 18.x, 19.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: diff --git a/media/README.md b/media/README.md new file mode 100644 index 0000000..300ac90 --- /dev/null +++ b/media/README.md @@ -0,0 +1 @@ +Dealing with digital media files (audio, video, images). Mostly a thought-experiment for now. diff --git a/media/media.js b/media/media.js new file mode 100644 index 0000000..d194136 --- /dev/null +++ b/media/media.js @@ -0,0 +1,35 @@ +console.warn(`This is not even an alpha-level API. Do not use.`); + +// A Container Format is a file that embeds multiple data streams into a single file. +// Examples: +// - the ZIP family (ZIP, JAR, CBZ, EPUB, ODF, OOXML) +// - the ISO-BMFF family (MP4, HEVC, AVIF, MOV/QT, etc) +// - the Matroska family (MKV, WebM) +// - the RIFF family (WAV, AVI, WebP) +// - the OGG family (OGV, OPUS) + +// The ZIP container needs special processing to determine what files are present inside it :( +// The ISO-BMFF container needs special processing because of its "compatible brands" array :( +// The Matroska container needs special processing because the sub-type can appear anywhere :( +// The OGG container needs special processing to determine what kind of streams are present :( + +/** + * @readonly + * @enum {number} + */ +export const ContainerType = { + UNKNOWN: 0, + ZIP: 1, + ISOBMFF: 100, + MATROSKA: 101, + RIFF: 102, + OGG: 103, +}; + +/** + * @param {ArrayBuffer} ab + * @returns {ContainerType} + */ +export function getContainerType(ab) { + return ContainerType.UNKNOWN; +}