Skip to content

Commit

Permalink
Support #EXT-X-GAP at stringify() (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuu authored Jul 7, 2024
1 parent cc2963a commit 35c651e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ This section describes the structure of the object returned by `parse()` method.
| `dateRange` | `DateRange` | No | undefined | See [EXT-X-DATERANGE](https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.2.7) |
| `markers` | [`SpliceInfo`] | No | [] | SCTE-35 messages associated with this segment|
| `parts` | [`PartialSegment`] | No | [] | Partial Segments that constitute this segment |
| `gap` | boolean | No | undefined | See [EXT-X-GAP](https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-4.4.4.7) |

### `PartialSegment` (extends `Data`)
| Property | Type | Required | Default | Description |
Expand Down
3 changes: 3 additions & 0 deletions stringify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ function buildSegment(lines: LineArray, segment: Segment, lastKey: string, lastM
if (segment.discontinuity) {
lines.push(`#EXT-X-DISCONTINUITY`);
}
if (segment.gap) {
lines.push(`#EXT-X-GAP`);
}
if (segment.key) {
const line = buildKey(segment.key);
if (line !== lastKey) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const test = require("ava");
const HLS = require('../../../../..');
const utils = require("../../../../helpers/utils");
const {equalPlaylist} = require("../../../../helpers/matchers");

// https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-4.4.4.7

Expand Down Expand Up @@ -38,3 +40,17 @@ test('#EXT-X-TAG_02', t => {
#EXT-X-ENDLIST
`);
});

test('#EXT-X-TAG_03', t => {
const txt = `
#EXTM3U
#EXT-X-VERSION:8
#EXT-X-TARGETDURATION:5
#EXT-X-GAP
#EXTINF:4,
1.ts
`;
const playlist = HLS.parse(txt);
t.truthy(playlist.segments[0].gap);
equalPlaylist(t, txt, HLS.stringify(playlist));
});

0 comments on commit 35c651e

Please sign in to comment.