dasha 2.2.2 → 2.2.5

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 (2) hide show
  1. package/lib/manifest.js +11 -11
  2. package/package.json +1 -1
package/lib/manifest.js CHANGED
@@ -21,7 +21,7 @@ class Manifest {
21
21
  getVideoTrack(height) {
22
22
  const isVideoAdaptationSet = (adaptationSet) =>
23
23
  adaptationSet.contentType === CONTENT_TYPE.video ||
24
- adaptationSet.mimeType === 'video/mp4' ||
24
+ adaptationSet.mimeType?.includes('video') ||
25
25
  adaptationSet.maxWidth ||
26
26
  adaptationSet.maxHeight;
27
27
  const adaptationSets = this.periods
@@ -49,22 +49,22 @@ class Manifest {
49
49
  }
50
50
 
51
51
  getAudioTracks(languages) {
52
- const isAudioAdaptationSet = (adaptationSet) =>
52
+ const filterAudio = (adaptationSet) =>
53
53
  (adaptationSet.contentType === CONTENT_TYPE.audio ||
54
- adaptationSet.mimeType === 'audio/mp4') &&
54
+ adaptationSet.mimeType?.includes('audio') ||
55
+ adaptationSet.representations.some((r) => r.mimeType?.includes('audio'))) &&
55
56
  !adaptationSet.maxWidth;
57
+ const filterLanguages = (adaptationSet) =>
58
+ languages ? languages.some((lang) => adaptationSet.lang.includes(lang)) : true;
56
59
  const adaptationSets = this.periods
57
60
  .map((p) => p.adaptationSets)
58
61
  .flat(1)
59
- .filter(isAudioAdaptationSet);
60
-
61
- const representations = adaptationSets.map((a) => a.representations).flat(2);
62
- const matches = representations.filter((r) => languages?.some((lang) => r.lang.includes(lang)));
63
- const selectedRepresentations = matches?.length ? matches : representations;
62
+ .filter(filterAudio)
63
+ .filter(filterLanguages);
64
64
 
65
65
  const tracks = [];
66
- for (const representation of selectedRepresentations) {
67
- const adaptationSet = adaptationSets.find((a) => a.representations.includes(representation));
66
+ for (const adaptationSet of adaptationSets) {
67
+ const representation = this.findBestRepresentation(adaptationSet.representations);
68
68
  const track = {
69
69
  id: tracks.length,
70
70
  type: CONTENT_TYPE.audio,
@@ -86,7 +86,7 @@ class Manifest {
86
86
  getSubtitleTracks(languages) {
87
87
  const isSubtitleAdaptationSet = (adaptationSet) =>
88
88
  (adaptationSet.contentType === CONTENT_TYPE.text ||
89
- adaptationSet.mimeType.includes('text')) &&
89
+ adaptationSet.mimeType?.includes('text')) &&
90
90
  !adaptationSet.maxWidth;
91
91
  const adaptationSets = this.periods
92
92
  .map((p) => p.adaptationSets)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dasha",
3
- "version": "2.2.2",
3
+ "version": "2.2.5",
4
4
  "author": "Vitaliy Gashkov <vitnore@gmail.com>",
5
5
  "description": "Simple MPEG-DASH MPD parser",
6
6
  "license": "Apache-2.0",