-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding support for segments in Period and Representation. #19
Changes from 3 commits
be6b06f
d5e4cbd
a7877d5
59e4b48
705b713
90c0595
bd9d668
984c176
425eaf9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { parseDuration } from './utils/time'; | |
import { findChildren, getContent } from './utils/xml'; | ||
import resolveUrl from './utils/resolveUrl'; | ||
import errors from './errors'; | ||
import merge from 'deepmerge'; | ||
|
||
/** | ||
* Builds a list of urls that is the product of the reference urls and BaseURL values | ||
|
@@ -131,14 +132,16 @@ export const getSegmentInformation = (adaptationSet) => { | |
* Callback map function | ||
*/ | ||
export const inheritBaseUrls = | ||
(adaptationSetAttributes, adaptationSetBaseUrls, segmentInfo) => (representation) => { | ||
(adaptationSetAttributes, adaptationSetBaseUrls, periodAdaptationSetInfo) => (representation) => { | ||
const repBaseUrlElements = findChildren(representation, 'BaseURL'); | ||
const repBaseUrls = buildBaseUrls(adaptationSetBaseUrls, repBaseUrlElements); | ||
const attributes = shallowMerge(adaptationSetAttributes, getAttributes(representation)); | ||
const segmentInfoFromRepresenation = getSegmentInformation(representation); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should call this |
||
const segmentRepresentationInfo = merge(periodAdaptationSetInfo, segmentInfoFromRepresenation); | ||
|
||
return repBaseUrls.map(baseUrl => { | ||
return { | ||
segmentInfo, | ||
segmentInfo: segmentRepresentationInfo, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could just do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure I will make that change |
||
attributes: shallowMerge(attributes, { baseUrl }) | ||
}; | ||
}); | ||
|
@@ -167,7 +170,7 @@ export const inheritBaseUrls = | |
* Callback map function | ||
*/ | ||
export const toRepresentations = | ||
(periodAttributes, periodBaseUrls) => (adaptationSet) => { | ||
(periodAttributes, periodBaseUrls, periodInfo) => (adaptationSet) => { | ||
const adaptationSetAttributes = getAttributes(adaptationSet); | ||
const adaptationSetBaseUrls = buildBaseUrls(periodBaseUrls, | ||
findChildren(adaptationSet, 'BaseURL')); | ||
|
@@ -178,9 +181,10 @@ export const toRepresentations = | |
roleAttributes); | ||
const segmentInfo = getSegmentInformation(adaptationSet); | ||
const representations = findChildren(adaptationSet, 'Representation'); | ||
const periodAdaptationSetInfo = merge(periodInfo, segmentInfo); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should call this |
||
|
||
return flatten( | ||
representations.map(inheritBaseUrls(attrs, adaptationSetBaseUrls, segmentInfo))); | ||
representations.map(inheritBaseUrls(attrs, adaptationSetBaseUrls, periodAdaptationSetInfo))); | ||
}; | ||
|
||
/** | ||
|
@@ -210,10 +214,12 @@ export const toRepresentations = | |
*/ | ||
export const toAdaptationSets = (mpdAttributes, mpdBaseUrls) => (period, periodIndex) => { | ||
const periodBaseUrls = buildBaseUrls(mpdBaseUrls, findChildren(period, 'BaseURL')); | ||
const periodAttributes = shallowMerge({ periodIndex }, mpdAttributes); | ||
const periodAtt = getAttributes(period); | ||
const periodAttributes = shallowMerge(periodAtt, { periodIndex }, mpdAttributes); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets switch the order of the arguments here to be |
||
const adaptationSets = findChildren(period, 'AdaptationSet'); | ||
const periodInfo = getSegmentInformation(period); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should call this |
||
|
||
return flatten(adaptationSets.map(toRepresentations(periodAttributes, periodBaseUrls))); | ||
return flatten(adaptationSets.map(toRepresentations(periodAttributes, periodBaseUrls, periodInfo))); | ||
}; | ||
|
||
/** | ||
|
@@ -243,4 +249,3 @@ export const inheritAttributes = (mpd, manifestUri = '') => { | |
|
||
return flatten(periods.map(toAdaptationSets(mpdAttributes, mpdBaseUrls))); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,27 +2,25 @@ import { shallowMerge } from './utils/object'; | |
import { segmentsFromTemplate } from './segment/segmentTemplate'; | ||
import { segmentsFromList } from './segment/segmentList'; | ||
import { segmentsFromBase } from './segment/segmentBase'; | ||
|
||
// import merge from 'deepmerge'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. leftover comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont forget to remove this comment |
||
export const generateSegments = (segmentInfo, attributes) => { | ||
if (segmentInfo.template) { | ||
return segmentsFromTemplate( | ||
shallowMerge(segmentInfo.template, attributes), | ||
segmentInfo.timeline | ||
if (segmentInfo.list) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was there a specific reasoning for switching the order of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just checking for the SegmentList output. |
||
return segmentsFromList( | ||
shallowMerge(attributes, segmentInfo.list), segmentInfo.timeline | ||
); | ||
} | ||
|
||
if (segmentInfo.base) { | ||
return segmentsFromBase(shallowMerge(segmentInfo.base, attributes)); | ||
return segmentsFromBase(shallowMerge(attributes, segmentInfo.base)); | ||
} | ||
|
||
if (segmentInfo.list) { | ||
return segmentsFromList( | ||
shallowMerge(segmentInfo.list, attributes), segmentInfo.timeline | ||
if (segmentInfo.template) { | ||
return segmentsFromTemplate( | ||
shallowMerge(attributes, segmentInfo.template), | ||
segmentInfo.timeline | ||
); | ||
} | ||
}; | ||
|
||
export const toPlaylists = representations => { | ||
export const toPlaylists = (representations) => { | ||
return representations.map(({ attributes, segmentInfo }) => { | ||
const segments = generateSegments(segmentInfo, attributes); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should update the
shallowMerge
function to be adeepMerge
and remove this dependencyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think that we should make
video.js
a dependency so that we can usevideojs.mergeOptions
? Its excessive to make that whole project a dependency just for a merge, but as long as this is being used in another project that is using videojs, rollup or other bundlers should be able to handle and remove the redundancy? I'm not sure what best practices are for this case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building with
video.js
'smergeOptions
it seems like the rollup did not remove the unnecessary code and mpd-parser.js shot up to 680KB. I think it would be better to write a simple deep merge function instead.