Skip to content

Commit

Permalink
Add MatroskaJS Chapter Codec
Browse files Browse the repository at this point in the history
Rather than reinventing the wheel with a custom language, we can reuse and well-known one.

The goal of Matroska Script was to be similar to JavaScript/ECMAStrip/ActionScript.
But, in JS, integers can only use 56 bits. So not all ChapterUID (64-bit unsigned integer) can be addressed
with the current Matroska Script stable API.

Rather than adding a different GotoAndPlay that is compatible with JavaScript (using a string), we start from
scratch with ECMAScript 6th Edition (ES6).
  • Loading branch information
robUx4 committed Aug 21, 2024
1 parent 5734c38 commit d81e2b7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
26 changes: 26 additions & 0 deletions chapter_codecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ The one and only command existing for the moment is `GotoAndPlay( ChapterUID );`
same suggests, it means that, when this command is encountered, the `Matroska Player`
**SHOULD** jump to the `Chapter` specified by the UID and play it, as long as this `Chapter` exists.

## MatroskaJS

This is the case when `ChapProcessCodecID` = 2. This is a script language build for
Matroska purposes. It uses the [@!ECMAScript] 6th Edition (ES6) syntax. The commands are stored as text commands, in UTF-8.
The syntax is C like, with commands spanned on many lines, each terminating with a semicolon ";". You can also include comments
at the end of lines with "//" or comment many lines using "/* \*/". The scripts are stored
in `ChapProcessData`. For the moment `ChapProcessPrivate` is not used.

The Matroska Script contains the following commands.

### GotoAndPlay

The command is called with `GotoAndPlay( "<ChapterUID>" );`.

As the same suggests, it means that, when this command is encountered, the `Matroska Player`
**SHOULD** jump to the `Chapter` specified by the `ChapterUID` string and play it, as long as this `Chapter` exists.

### LogMsg

The command is called with `LogMsg( "A String" );`.

The `Matroska Player` **SHOULD** send the provided message to the user debugging console, if there is one.
In this example it would send "A String", without the double quotes, to the debugging console.



## DVD Menu

This is the case when `ChapProcessCodecID` = 1. Each level of a chapter corresponds
Expand Down
6 changes: 3 additions & 3 deletions rfc_backmatter_chapter_codecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
</front>
</reference>

<reference anchor="ECMAScript" target="https://262.ecma-international.org/14.0/">
<reference anchor="ECMAScript" target="https://262.ecma-international.org/6.0/">
<front>
<title>ECMA-262 14th Edition, June 2022. ECMAScript 2023 language specification</title>
<title>ECMA-262 6th Edition, June 2015. ECMAScript 2015 language specification</title>
<author>
<organization>Ecma International</organization>
</author>
<date month="June" year="2023" />
<date month="June" year="2015" />
</front>
</reference>

Expand Down

0 comments on commit d81e2b7

Please sign in to comment.