diff --git a/src/manifests/utils/dashManifestUtils.test.ts b/src/manifests/utils/dashManifestUtils.test.ts
index 87c4c43..f136674 100644
--- a/src/manifests/utils/dashManifestUtils.test.ts
+++ b/src/manifests/utils/dashManifestUtils.test.ts
@@ -108,6 +108,37 @@ describe('dashManifestTools', () => {
const expected: string = builder.buildObject(DASH_JSON);
expect(proxyManifest).toEqual(expected);
});
+
+ it('should use the period baseUrl if it exists', async () => {
+ // Arrange
+ const mockManifestPath =
+ '../../testvectors/dash/dash_period_baseurl/manifest.xml';
+ const mockDashManifest = fs.readFileSync(
+ path.join(__dirname, mockManifestPath),
+ 'utf8'
+ );
+ const manifestUtils = dashManifestUtils();
+ const proxyManifest: string = manifestUtils.createProxyDASHManifest(
+ mockDashManifest,
+ new URLSearchParams(
+ 'url=https://mock.mock.com/stream/dash/period_base_url/manifest.mpd'
+ )
+ );
+ const proxyManifestPath =
+ '../../testvectors/dash/dash_period_baseurl/proxy-manifest.xml';
+ const dashFile: string = fs.readFileSync(
+ path.join(__dirname, proxyManifestPath),
+ 'utf8'
+ );
+ let DASH_JSON;
+ const parser = new xml2js.Parser();
+ const builder = new xml2js.Builder();
+ parser.parseString(dashFile, function (err, result) {
+ DASH_JSON = result;
+ });
+ const expected: string = builder.buildObject(DASH_JSON);
+ expect(proxyManifest).toEqual(expected);
+ });
});
});
diff --git a/src/manifests/utils/dashManifestUtils.ts b/src/manifests/utils/dashManifestUtils.ts
index 410842c..1d1606b 100644
--- a/src/manifests/utils/dashManifestUtils.ts
+++ b/src/manifests/utils/dashManifestUtils.ts
@@ -63,17 +63,23 @@ export default function (): DASHManifestTools {
DASH_JSON = result;
});
- let baseUrl;
+ let globalBaseUrl;
if (DASH_JSON.MPD.BaseURL) {
// There should only ever be one baseurl according to schema
- baseUrl = DASH_JSON.MPD.BaseURL[0];
- // Remove base url from manifest since we are using relative paths for proxy
+ globalBaseUrl = DASH_JSON.MPD.BaseURL[0];
}
+ // Remove base url from manifest since we are using relative paths for proxy
delete DASH_JSON.MPD.BaseURL;
let staticQueryUrl: URLSearchParams;
DASH_JSON.MPD.Period.map((period) => {
+ let baseUrl = globalBaseUrl;
+ if (period.BaseURL?.[0]) {
+ baseUrl = period.BaseURL[0];
+ // Remove base url from manifest since we are using relative paths for proxy
+ delete period.BaseURL;
+ }
period.AdaptationSet.map((adaptationSet) => {
// If there is a SegmentTemplate directly in the adaptationSet there should only be one
// But if it has no media property it is invalid and we should try the Representation instead
diff --git a/src/testvectors/dash/dash_period_baseurl/manifest.xml b/src/testvectors/dash/dash_period_baseurl/manifest.xml
new file mode 100644
index 0000000..1626154
--- /dev/null
+++ b/src/testvectors/dash/dash_period_baseurl/manifest.xml
@@ -0,0 +1,32 @@
+
+
+ http://vm2.dashif.org/livesim-dev/periods_60/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/testvectors/dash/dash_period_baseurl/proxy-manifest.xml b/src/testvectors/dash/dash_period_baseurl/proxy-manifest.xml
new file mode 100644
index 0000000..29c7c95
--- /dev/null
+++ b/src/testvectors/dash/dash_period_baseurl/proxy-manifest.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file