@torrent-tv/proxy 2.73.1 → 2.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +1447 -1437
  2. package/CLAUDE.md +165 -160
  3. package/docs/container-architecture.md +192 -184
  4. package/package.json +1 -1
  5. package/routes/api/subtitles/get.js +205 -205
  6. package/services/container/Container.js +354 -135
  7. package/services/container/MatroskaContainer.js +1155 -516
  8. package/services/container/Mp4Container.js +858 -392
  9. package/services/container/SubtitleFileContainer.js +323 -261
  10. package/services/controllers/SubtitleController.js +128 -127
  11. package/services/delivery-probe.js +64 -6
  12. package/services/hls-session-manager.js +32 -35
  13. package/services/language-detect.js +174 -228
  14. package/services/playback-planner.js +747 -747
  15. package/services/produced-index.js +300 -0
  16. package/services/torrent-worker/subtitle-cues.js +582 -633
  17. package/services/tracks/TextSubtitleTrack.js +287 -47
  18. package/services/tracks/index.js +14 -14
  19. package/test/delivery-probe.test.js +67 -0
  20. package/test/matroska-blocks.test.js +0 -0
  21. package/test/mp4-subtitles.test.js +173 -127
  22. package/test/produced-index.test.js +188 -0
  23. package/test/subtitle-cue-framing.test.js +200 -202
  24. package/test/subtitle-cue-walk.test.js +369 -0
  25. package/test/subtitle-defaults.test.js +97 -97
  26. package/test/subtitle-language.test.js +252 -252
  27. package/test/subtitle-track-numbering.test.js +370 -370
  28. package/services/container-index/matroska-blocks.js +0 -202
  29. package/services/container-index/matroska-subtitles.js +0 -372
  30. package/services/container-index/mp4-subtitles.js +0 -404
  31. package/services/subtitle-convert.js +0 -144
  32. package/services/subtitle-defaults.js +0 -157
  33. package/services/tracks/subtitle-markup.js +0 -104
@@ -1,184 +1,192 @@
1
- # Container & Track architecture
2
-
3
- Domain → Application → Interface, per RFC 9559 (Matroska) and ISO/IEC 14496-12 (MP4).
4
-
5
- ## Two axes, and what is NOT a third
6
-
7
- Everything here is placed on exactly two axes: **which container** a track lives
8
- in, and **what kind of track** it is (video / audio / subtitle). A file lying
9
- beside the video — a dub as `<name>.mka`, subtitles as `<name>.ass` — is not a
10
- third kind of anything:
11
-
12
- - a `.mka` **is** Matroska. `ContainerFactory` sniffs it, `MatroskaContainer`
13
- reads its `TrackEntry` list, and out comes an `AudioTrack` with its language,
14
- title and flags. It differs from the picture's own file only in having no
15
- video track. The same holds for `.m4a` and `Mp4Container`;
16
- - "external" is therefore not a TYPE. It is the answer to WHERE a track's bytes
17
- are, and that is torrent knowledge — which this layer must not have
18
- (`ContainerFactory`: no torrent knowledge; `ContainerOrchestrator`:
19
- transport-agnostic). The pairing of a sidecar file with a picture lives in
20
- `services/sidecar-files.js`, and the numbered list a viewer chooses from lives
21
- in `services/audio-inventory.js`. Both are pure and both are application-layer.
22
-
23
- A class called `ExternalSubtitleFile` used to sit in `tracks/` asserting the
24
- opposite. It did not extend `ContainerTrack`, duplicated four of its fields, and
25
- was imported by nothing; it was deleted rather than extended. Nothing replaced
26
- it — a subtitle file beside the video is a `TextSubtitleTrack` whose bytes are
27
- read from another file, and a raw `.srt` needs no `Container` subclass because
28
- it has no track table and no index to read: the whole file is the payload, and
29
- `SubtitleController` already reads it as such.
30
-
31
- ## Who answers what — the rule
32
-
33
- A fact the container DECLARES is read from the container. A fact only the media
34
- itself has is measured from the media, which means ffmpeg.
35
-
36
- That is the whole boundary, and it is not about speed. Speed is a consequence:
37
- this layer asks for the smallest region that holds the answer — 64 KB of header,
38
- the Cues block, a sample table — while ffmpeg cannot be asked for a bounded
39
- region at all. Its input analysis pulls megabytes before it will say anything,
40
- and over a torrent those megabytes may not exist yet. Measured 2026-09-03 on one
41
- `.mka`: this layer read its header in **8 ms**, and an ffmpeg reading the same
42
- header of the same file through the proxy's own `/stream`, in the same second,
43
- took **8121 ms** — and spent all of it waiting for a DURATION its caller did not
44
- want, because its early exit is gated on one.
45
-
46
- So ffmpeg keeps exactly three jobs, and nothing else:
47
-
48
- 1. producing media — the encode run;
49
- 2. measuring THIS MACHINE — encoder detection and its strict test, decode
50
- calibration, the contention penalty;
51
- 3. answering what the container does not declare — above all keyframe positions
52
- in a container with no index, where a packet scan is the only source. Even
53
- there the container is asked FIRST: measured, the container index gave 570
54
- keyframes in 0.8 s from two point reads of 16 KB, while a scan of the same
55
- file found 77 in 45 s and did not finish.
56
-
57
- `null` in `ContainerMediaInfo` means the container does not declare the field.
58
- That is a final answer about the container, and the point at which a caller may
59
- go to the media — not "unknown, ask again".
60
-
61
- ## Where byte access lives, and why not on a track
62
-
63
- A `ContainerTrack` is a DECLARATION. It carries no `readRange` and no file
64
- identity, and it should not: byte access is the `Container`'s, injected as
65
- `readRange(start, end)` and bound to one file.
66
-
67
- The obvious-looking improvement — hand the track a reader so it can fetch its own
68
- bytes — was reviewed on 2026-09-03 and is **not** the right shape:
69
-
70
- - for video and audio, this layer never reads the payload at all. It goes to
71
- ffmpeg by URL, where seeking and gigabytes belong. A `readRange` on a
72
- `VideoTrack` would be a capability with no consumer, inviting reads of a size
73
- this path is not built for;
74
- - tracks cross the worker boundary as PLAIN OBJECTS (`plainTrack()`), because a
75
- class instance does not survive it as a class. A back-reference to a container
76
- cannot cross either, so such a track would be able to read its own bytes only
77
- on the thread where the container is already at hand.
78
-
79
- What IS split, and is worth closing: `SubtitleTrack` carries `clusterPositions`
80
- and `samples` — byte POSITIONS — while the reading of those positions lives in
81
- `torrent-worker/subtitle-cues.js`, which builds a `readRange` of its own. Two
82
- halves of one action in two layers.
83
-
84
- The shape that closes it is `Container.readCuesOf(track)` — the container already
85
- holds `readRange`, and the series `readTracks` / `readKeyframeIndex` /
86
- `readMediaInfo` / `cueTextOf` is exactly where "ask the container" belongs.
87
-
88
- **It is not done yet, and the obstacle is real rather than effort.** The two
89
- readers want different read POLICIES over the same file: the track table fetches
90
- what is missing from the swarm (`readFetching`), while the cue walk deliberately
91
- reads only what is already downloaded (`readHeld`) so that turning subtitles on
92
- never pulls bytes the viewer is not waiting for. One container instance per file
93
- holds one `readRange`, so as things stand it cannot serve both. Resolving that —
94
- a read policy per call, or something else is the design question to answer
95
- before the move, and answering it in passing would settle it by accident.
96
-
97
- ## Layers
98
-
99
- ```mermaid
100
- flowchart TB
101
- subgraph Domain
102
- C[Container<br/>abstract<br/>RFC9559 / 14496-12]
103
- MC[MatroskaContainer]
104
- MpC[Mp4Container]
105
- AC[AviContainer]
106
- CT[ContainerTrack<br/>isEnabled/isDefault/language]
107
- VT[VideoTrack]
108
- AT[AudioTrack]
109
- ST[SubtitleTrack]
110
- TST[TextSubtitleTrack<br/>S_TEXT/UTF8 tx3g wvtt]
111
- IST[ImageSubtitleTrack<br/>PGS VobSub subp]
112
- C --> MC & MpC & AC
113
- CT --> VT & AT & ST
114
- ST --> TST & IST
115
- MC & MpC & AC -- readTracks --> CT
116
- end
117
- subgraph Application
118
- CF[ContainerFactory<br/>detect 16 bytes]
119
- CO[ContainerOrchestrator<br/>cache + getTracks/getKeyframeIndex]
120
- SO[SubtitleOrchestrator<br/>wrap subtitle-cues.js]
121
- SF[sidecar-files.js<br/>which file goes with which]
122
- AI[audio-inventory.js<br/>one flat numbering]
123
- CF --> CO
124
- CO --> SO
125
- SF --> AI
126
- CO --> AI
127
- end
128
- subgraph Interface
129
- PC[PlaybackController]
130
- SC[SubtitleController]
131
- R1[routes/api/playback-plan]
132
- R2[routes/api/subtitles]
133
- PC --> R1
134
- SC --> R2
135
- CO --> PC
136
- SO --> SC
137
- end
138
- ```
139
-
140
- ## Class responsibilities (spec-grounded)
141
-
142
- | Class | Spec section | Fields | Not responsible |
143
- |---|---|---|---|
144
- | `ContainerTrack` | RFC9559 TrackEntry common + ISO 14496-12 tkhd/mdhd/hdlr/elng | `trackNumber`, `declaredIndex`, `codecId`, `language`/`languageBcp47` (MUST rule), `name`, `isEnabled` (0xB9 / track_enabled), `isDefault`+`declaresDefault` (0x88) | Type-specific flags |
145
- | `VideoTrack` | RFC9559 Video, ISO 14496-12 tkhd width/height, stsd | `width/height/display*`, `fps`, `isHdr`, `bitDepth` | Subtitle flags |
146
- | `AudioTrack` | RFC9559 FlagOriginal 0x55AE, FlagCommentary 0x55AF, FlagVisualImpaired 0x55AC | `isOriginal/isCommentary/isVisualImpaired`, `channels/samplingFrequency` | FlagForced |
147
- | `SubtitleTrack` | RFC9559 FlagForced 0x55AA (subtitle-only), FlagHearingImpaired 0x55AB | `isForced/isHearingImpaired`, `clusterPositions`/`samples` | Video dims |
148
- | `TextSubtitleTrack` | `S_TEXT/UTF8, S_TEXT/ASS, tx3g, wvtt` | `toVtt()` convertible | Image tracks |
149
- | `sidecar-files.js` | (torrent naming) | which files of a torrent are one picture's sound and subtitles | what is inside them |
150
- | `audio-inventory.js` | RFC9559 audio flags, merged against ffmpeg's numbering | one flat number per soundtrack → `(fileIndex, 0:a:N)` | display labels |
151
- | `ImageSubtitleTrack` | `S_HDMV/PGS, S_VOBSUB, subp, clcp` | kept for `declaredIndex` alignment | Conversion |
152
- | `MatroskaContainer` | RFC9559 SeekHead, Tracks, Cues, Clusters | single Tracks walk for all types, EBML via `ebml-reader.js` | HTTP |
153
- | `Mp4Container` | ISO 14496-12 moov/trak/tkhd/mdhd/hdlr/elng/stbl | `alternate_group` grouping, packed language, `tx3g` forced bits | Torrent |
154
- | `AviContainer` | RIFF AVI idx1 | `AVIIF_KEYFRAME` keyframe times | Tracks beyond video |
155
-
156
- `VideoTrack` never carries `isForced` spec states FlagForced "Applies only to subtitles". Placing it in base would pollute video with irrelevant state.
157
-
158
- ## Orchestrators & Controllers
159
-
160
- - `ContainerFactory.create({readRange,fileSize})` — sniffs 16 bytes, returns precise `Container` subclass. No torrent knowledge.
161
- - `ContainerOrchestrator` — per-file cache (`sourceKey:fileIndex`), `getTracks()` / `getKeyframeIndex()`. Transport-agnostic.
162
- - `SubtitleOrchestrator` wraps `torrent-worker/subtitle-cues.js` (`planFor`, `cuesHeldFor`, `warmSubtitleCues`) behind `ContainerTrack` abstraction. Routes depend on this, not on worker directly.
163
- - `PlaybackController` / `SubtitleController` — thin interface adapters; `routes/api/*` delegate to them, handle HTTP headers (`X-Subtitle-Language`, `X-Subtitle-Cursor`) only.
164
-
165
- ## Legacy
166
-
167
- `services/container-index/` remains as internal detail used by `container/*`. Direct imports from routes are deprecated — use `orchestrators/` and `controllers/` instead.
168
-
169
- ## Flags matrix
170
-
171
- | Flag | Matroska ID | Applies to | Base or subclass |
172
- |---|---|---|---|
173
- | `FlagEnabled` | 0xB9 default 1 | all | `ContainerTrack` |
174
- | `FlagDefault` | 0x88 default 1 | all | `ContainerTrack` (`declaresDefault`) |
175
- | `Language` | 0x22B59C | all | `ContainerTrack` |
176
- | `LanguageBCP47` | 0x22B59D MUST | all | `ContainerTrack` |
177
- | `FlagForced` | 0x55AA | subtitle only | `SubtitleTrack` |
178
- | `FlagHearingImpaired` | 0x55AB | subtitle | `SubtitleTrack` |
179
- | `FlagVisualImpaired` | 0x55AC | audio (descriptive) + subtitle | `AudioTrack`/`SubtitleTrack` |
180
- | `FlagOriginal` | 0x55AE | audio | `AudioTrack` |
181
- | `FlagCommentary` | 0x55AF | audio | `AudioTrack` |
182
- | `track_enabled` | tkhd 0x000001 | all | `ContainerTrack` |
183
- | `alternate_group` | tkhd | audio/video alternates | `ContainerTrack.alternateGroup` |
184
- | `elng` | 14496-12 §8.4.6 | all | `ContainerTrack.languageBcp47` |
1
+ # Container & Track architecture
2
+
3
+ Domain → Application → Interface, per RFC 9559 (Matroska) and ISO/IEC 14496-12 (MP4).
4
+
5
+ ## Two axes, and what is NOT a third
6
+
7
+ Everything here is placed on exactly two axes: **which container** a track lives
8
+ in, and **what kind of track** it is (video / audio / subtitle). A file lying
9
+ beside the video — a dub as `<name>.mka`, subtitles as `<name>.ass` — is not a
10
+ third kind of anything:
11
+
12
+ - a `.mka` **is** Matroska. `ContainerFactory` sniffs it, `MatroskaContainer`
13
+ reads its `TrackEntry` list, and out comes an `AudioTrack` with its language,
14
+ title and flags. It differs from the picture's own file only in having no
15
+ video track. The same holds for `.m4a` and `Mp4Container`;
16
+ - "external" is therefore not a TYPE. It is the answer to WHERE a track's bytes
17
+ are, and that is torrent knowledge — which this layer must not have
18
+ (`ContainerFactory`: no torrent knowledge; `ContainerOrchestrator`:
19
+ transport-agnostic). The pairing of a sidecar file with a picture lives in
20
+ `services/sidecar-files.js`, and the numbered list a viewer chooses from lives
21
+ in `services/audio-inventory.js`. Both are pure and both are application-layer.
22
+
23
+ A class called `ExternalSubtitleFile` used to sit in `tracks/` asserting the
24
+ opposite. It did not extend `ContainerTrack`, duplicated four of its fields, and
25
+ was imported by nothing; it was deleted rather than extended. Nothing replaced
26
+ it — a subtitle file beside the video is a `TextSubtitleTrack` whose bytes are
27
+ read from another file, and a raw `.srt` needs no `Container` subclass because
28
+ it has no track table and no index to read: the whole file is the payload, and
29
+ `SubtitleController` already reads it as such.
30
+
31
+ ## Who answers what — the rule
32
+
33
+ A fact the container DECLARES is read from the container. A fact only the media
34
+ itself has is measured from the media, which means ffmpeg.
35
+
36
+ That is the whole boundary, and it is not about speed. Speed is a consequence:
37
+ this layer asks for the smallest region that holds the answer — 64 KB of header,
38
+ the Cues block, a sample table — while ffmpeg cannot be asked for a bounded
39
+ region at all. Its input analysis pulls megabytes before it will say anything,
40
+ and over a torrent those megabytes may not exist yet. Measured 2026-09-03 on one
41
+ `.mka`: this layer read its header in **8 ms**, and an ffmpeg reading the same
42
+ header of the same file through the proxy's own `/stream`, in the same second,
43
+ took **8121 ms** — and spent all of it waiting for a DURATION its caller did not
44
+ want, because its early exit is gated on one.
45
+
46
+ So ffmpeg keeps exactly three jobs, and nothing else:
47
+
48
+ 1. producing media — the encode run;
49
+ 2. measuring THIS MACHINE — encoder detection and its strict test, decode
50
+ calibration, the contention penalty;
51
+ 3. answering what the container does not declare — above all keyframe positions
52
+ in a container with no index, where a packet scan is the only source. Even
53
+ there the container is asked FIRST: measured, the container index gave 570
54
+ keyframes in 0.8 s from two point reads of 16 KB, while a scan of the same
55
+ file found 77 in 45 s and did not finish.
56
+
57
+ `null` in `ContainerMediaInfo` means the container does not declare the field.
58
+ That is a final answer about the container, and the point at which a caller may
59
+ go to the media — not "unknown, ask again".
60
+
61
+ ## Where byte access lives, and why not on a track
62
+
63
+ A `ContainerTrack` is a DECLARATION. It carries no `readRange` and no file
64
+ identity, and it should not: byte access is the `Container`'s, injected as
65
+ `readRange(start, end)` and bound to one file.
66
+
67
+ The obvious-looking improvement — hand the track a reader so it can fetch its own
68
+ bytes — was reviewed on 2026-09-03 and is **not** the right shape:
69
+
70
+ - for video and audio, this layer never reads the payload at all. It goes to
71
+ ffmpeg by URL, where seeking and gigabytes belong. A `readRange` on a
72
+ `VideoTrack` would be a capability with no consumer, inviting reads of a size
73
+ this path is not built for;
74
+ - tracks cross the worker boundary as PLAIN OBJECTS (`plainTrack()`), because a
75
+ class instance does not survive it as a class. A back-reference to a container
76
+ cannot cross either, so such a track would be able to read its own bytes only
77
+ on the thread where the container is already at hand.
78
+
79
+ **That split is closed.** `SubtitleTrack` carries `clusterPositions` and
80
+ `samples` — byte POSITIONS — and the reading of those positions is now the
81
+ container's: `MatroskaContainer.walkHeldClusters(plan, walked)` and
82
+ `Mp4Container.readHeldSamples(track, harvested)`, beside `readTracks`,
83
+ `readKeyframeIndex`, `readMediaInfo` and `cueTextOf`.
84
+
85
+ The obstacle was real and this is how it was answered. The two readers want
86
+ different read POLICIES over the same file: the track table fetches what is
87
+ missing from the swarm, while the cue walk deliberately reads only what is
88
+ already downloaded, so that turning subtitles on never pulls bytes the viewer is
89
+ not waiting for. A container is now built with BOTH `readRange` that fetches,
90
+ `readHeld` that does not, and `isHeld` that says whether a range can be read
91
+ without fetching so one instance per file serves both readers and the per-file
92
+ cache is kept.
93
+
94
+ What the container is NOT given is the torrent. Those three functions are the
95
+ whole of what the caller knows and the container does not, and reducing the
96
+ torrent to them is what lets the reading live where the format is specified.
97
+ `torrent-worker/subtitle-cues.js` supplies them (`containerOver`) and keeps only
98
+ what is genuinely its own: the found-order cursor a browser follows, the
99
+ per-file state, and one walk of a file at a time.
100
+
101
+ ## Layers
102
+
103
+ ```mermaid
104
+ flowchart TB
105
+ subgraph Domain
106
+ C[Container<br/>abstract<br/>RFC9559 / 14496-12]
107
+ MC[MatroskaContainer]
108
+ MpC[Mp4Container]
109
+ AC[AviContainer]
110
+ CT[ContainerTrack<br/>isEnabled/isDefault/language]
111
+ VT[VideoTrack]
112
+ AT[AudioTrack]
113
+ ST[SubtitleTrack]
114
+ TST[TextSubtitleTrack<br/>S_TEXT/UTF8 tx3g wvtt]
115
+ IST[ImageSubtitleTrack<br/>PGS VobSub subp]
116
+ C --> MC & MpC & AC
117
+ CT --> VT & AT & ST
118
+ ST --> TST & IST
119
+ MC & MpC & AC -- readTracks --> CT
120
+ end
121
+ subgraph Application
122
+ CF[ContainerFactory<br/>detect 16 bytes]
123
+ CO[ContainerOrchestrator<br/>cache + getTracks/getKeyframeIndex]
124
+ SO[SubtitleOrchestrator<br/>cursor + per-file state]
125
+ SF[sidecar-files.js<br/>which file goes with which]
126
+ AI[audio-inventory.js<br/>one flat numbering]
127
+ CF --> CO
128
+ CO --> SO
129
+ SF --> AI
130
+ CO --> AI
131
+ end
132
+ subgraph Interface
133
+ PC[PlaybackController]
134
+ SC[SubtitleController]
135
+ R1[routes/api/playback-plan]
136
+ R2[routes/api/subtitles]
137
+ PC --> R1
138
+ SC --> R2
139
+ CO --> PC
140
+ SO --> SC
141
+ end
142
+ ```
143
+
144
+ ## Class responsibilities (spec-grounded)
145
+
146
+ | Class | Spec section | Fields | Not responsible |
147
+ |---|---|---|---|
148
+ | `ContainerTrack` | RFC9559 TrackEntry common + ISO 14496-12 tkhd/mdhd/hdlr/elng | `trackNumber`, `declaredIndex`, `codecId`, `language`/`languageBcp47` (MUST rule), `name`, `isEnabled` (0xB9 / track_enabled), `isDefault`+`declaresDefault` (0x88) | Type-specific flags |
149
+ | `VideoTrack` | RFC9559 Video, ISO 14496-12 tkhd width/height, stsd | `width/height/display*`, `fps`, `isHdr`, `bitDepth` | Subtitle flags |
150
+ | `AudioTrack` | RFC9559 FlagOriginal 0x55AE, FlagCommentary 0x55AF, FlagVisualImpaired 0x55AC | `isOriginal/isCommentary/isVisualImpaired`, `channels/samplingFrequency` | FlagForced |
151
+ | `SubtitleTrack` | RFC9559 FlagForced 0x55AA (subtitle-only), FlagHearingImpaired 0x55AB | `isForced/isHearingImpaired`, `clusterPositions`/`samples` | Video dims |
152
+ | `TextSubtitleTrack` | `S_TEXT/UTF8, S_TEXT/ASS, tx3g, wvtt` | `toVtt()` convertible | Image tracks |
153
+ | `sidecar-files.js` | (torrent naming) | which files of a torrent are one picture's sound and subtitles | what is inside them |
154
+ | `audio-inventory.js` | RFC9559 audio flags, merged against ffmpeg's numbering | one flat number per soundtrack → `(fileIndex, 0:a:N)` | display labels |
155
+ | `ImageSubtitleTrack` | `S_HDMV/PGS, S_VOBSUB, subp, clcp` | kept for `declaredIndex` alignment | Conversion |
156
+ | `MatroskaContainer` | RFC9559 SeekHead, Tracks, Cues, Clusters | single Tracks walk for all types, EBML via `ebml-reader.js` | HTTP |
157
+ | `Mp4Container` | ISO 14496-12 moov/trak/tkhd/mdhd/hdlr/elng/stbl | `alternate_group` grouping, packed language, `tx3g` forced bits | Torrent |
158
+ | `AviContainer` | RIFF AVI idx1 | `AVIIF_KEYFRAME` keyframe times | Tracks beyond video |
159
+
160
+ `VideoTrack` never carries `isForced` — spec states FlagForced "Applies only to subtitles". Placing it in base would pollute video with irrelevant state.
161
+
162
+ ## Orchestrators & Controllers
163
+
164
+ - `ContainerFactory.create({readRange,fileSize})` — sniffs 16 bytes, returns precise `Container` subclass. No torrent knowledge.
165
+ - `ContainerOrchestrator` — per-file cache (`sourceKey:fileIndex`), `getTracks()` / `getKeyframeIndex()`. Transport-agnostic.
166
+ - `SubtitleOrchestrator` — wraps `torrent-worker/subtitle-cues.js` (`planFor`, `cuesHeldFor`, `warmSubtitleCues`) behind the `ContainerTrack` abstraction. Routes depend on this, not on the worker directly. The reading itself is the containers' — that module supplies the torrent's read policy and keeps the cursor.
167
+ - `PlaybackController` / `SubtitleController` thin interface adapters; `routes/api/*` delegate to them, handle HTTP headers (`X-Subtitle-Language`, `X-Subtitle-Cursor`) only.
168
+
169
+ ## Legacy
170
+
171
+ `services/container-index/` holds what is NOT specific to one media kind: EBML
172
+ element walking, and the Matroska/MP4/AVI keyframe tables. Everything a container
173
+ states about its own subtitles the track table, the Cues, the blocks in a
174
+ cluster, the sample table is in the container class itself. Direct imports from
175
+ routes are deprecated use `orchestrators/` and `controllers/` instead.
176
+
177
+ ## Flags matrix
178
+
179
+ | Flag | Matroska ID | Applies to | Base or subclass |
180
+ |---|---|---|---|
181
+ | `FlagEnabled` | 0xB9 default 1 | all | `ContainerTrack` |
182
+ | `FlagDefault` | 0x88 default 1 | all | `ContainerTrack` (`declaresDefault`) |
183
+ | `Language` | 0x22B59C | all | `ContainerTrack` |
184
+ | `LanguageBCP47` | 0x22B59D MUST | all | `ContainerTrack` |
185
+ | `FlagForced` | 0x55AA | subtitle only | `SubtitleTrack` |
186
+ | `FlagHearingImpaired` | 0x55AB | subtitle | `SubtitleTrack` |
187
+ | `FlagVisualImpaired` | 0x55AC | audio (descriptive) + subtitle | `AudioTrack`/`SubtitleTrack` |
188
+ | `FlagOriginal` | 0x55AE | audio | `AudioTrack` |
189
+ | `FlagCommentary` | 0x55AF | audio | `AudioTrack` |
190
+ | `track_enabled` | tkhd 0x000001 | all | `ContainerTrack` |
191
+ | `alternate_group` | tkhd | audio/video alternates | `ContainerTrack.alternateGroup` |
192
+ | `elng` | 14496-12 §8.4.6 | all | `ContainerTrack.languageBcp47` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torrent-tv/proxy",
3
- "version": "2.73.1",
3
+ "version": "2.74.0",
4
4
  "description": "Torrent proxy client that exposes webseed-like HTTP stream endpoint.",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {