-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: dom testing config and initial mpd parsing scaffold (#2)
- Loading branch information
1 parent
11e0d45
commit 47fe2f5
Showing
9 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[test] | ||
preload = "./happydom.ts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { GlobalRegistrator } from "@happy-dom/global-registrator"; | ||
|
||
GlobalRegistrator.register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
export const testString = `<?xml version="1.0" encoding="UTF-8"?><MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" maxSubsegmentDuration="PT5.0S" mediaPresentationDuration="PT9M57S" minBufferTime="PT5.0S" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011,http://xmlns.sony.net/metadata/mpeg/dash/profile/senvu/2012" type="static" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"> | ||
<Period duration="PT9M57S" id="P1"> | ||
<!-- Adaptation Set for main audio --> | ||
<AdaptationSet audioSamplingRate="48000" codecs="mp4a.40.5" contentType="audio" group="2" id="2" lang="en" mimeType="audio/mp4" subsegmentAlignment="true" subsegmentStartsWithSAP="1"> | ||
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/> | ||
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/> | ||
<Representation bandwidth="64000" id="2_1"> | ||
<BaseURL>DASH_vodaudio_Track5.m4a</BaseURL> | ||
</Representation> | ||
</AdaptationSet> | ||
<!-- Adaptation Set for video --> | ||
<AdaptationSet codecs="avc1.4D401E" contentType="video" frameRate="24000/1001" group="1" id="1" maxBandwidth="1609728" maxHeight="480" maxWidth="854" maximumSAPPeriod="5.0" mimeType="video/mp4" minBandwidth="452608" minHeight="480" minWidth="854" par="16:9" sar="1:1" subsegmentAlignment="true" subsegmentStartsWithSAP="1"> | ||
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/> | ||
<Representation bandwidth="1005568" height="480" id="1_1" mediaStreamStructureId="1" width="854"> | ||
<BaseURL>DASH_vodvideo_Track2.m4v</BaseURL> | ||
</Representation> | ||
<Representation bandwidth="1609728" height="480" id="1_2" mediaStreamStructureId="1" width="854"> | ||
<BaseURL>DASH_vodvideo_Track1.m4v</BaseURL> | ||
</Representation> | ||
<Representation bandwidth="704512" height="480" id="1_3" mediaStreamStructureId="1" width="854"> | ||
<BaseURL>DASH_vodvideo_Track3.m4v</BaseURL> | ||
</Representation> | ||
<Representation bandwidth="452608" height="480" id="1_4" mediaStreamStructureId="1" width="854"> | ||
<BaseURL>DASH_vodvideo_Track4.m4v</BaseURL> | ||
</Representation> | ||
</AdaptationSet> | ||
</Period> | ||
</MPD>`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
export default function () { | ||
return 'hello from dash-parser'; | ||
} | ||
export { default as parse } from './parse.ts'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ParsedManifest } from "./types/parsedManifest"; | ||
import { testString } from "./examples/mpd"; | ||
|
||
/** | ||
* Parses a MPD manifest file. | ||
* | ||
* @param playlist The URL of the mpd manifest to be parsed. | ||
*/ | ||
export default function parse(playlist: string): ParsedManifest { | ||
const parsedManifest: ParsedManifest = { | ||
segments: [], | ||
custom: {} | ||
}; | ||
|
||
// TODO: implement parsing. | ||
var doc = new DOMParser().parseFromString(testString, 'text/xml'); | ||
|
||
return parsedManifest; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface ParsedManifest { | ||
// TODO: There will be more fields here | ||
segments: Array<unknown>; | ||
custom: unknown; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import parse from '@/dash-parser/parse'; | ||
import { testString } from '@/dash-parser/examples/mpd'; | ||
import { describe, it, expect } from 'bun:test'; | ||
|
||
describe('dash-parser spec', () => { | ||
it('mock spec', () => { | ||
expect(true).toBe(true); | ||
// TODO: create valid tests | ||
it('testString should give us JSON', () => { | ||
const parsed = parse(testString); | ||
expect(parsed.segments.length).toBe(0); | ||
}); | ||
}); |