-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for non-standard DASH label attribute #811
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -957,11 +957,14 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) { | |
var language = | ||
shaka.util.LanguageUtils.normalize(elem.getAttribute('lang') || 'und'); | ||
|
||
var label = | ||
shaka.util.LanguageUtils.normalize(elem.getAttribute('label') || 'und'); | ||
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 don't think it makes sense to pass the label through language tools or default to the language code 'und'. Label, as I understand it from @erankor's explanation, is a free-form string and may reasonably be missing (null). |
||
|
||
// Parse Representations into Streams. | ||
var representations = XmlUtils.findChildren(elem, 'Representation'); | ||
var streams = representations | ||
.map(this.parseRepresentation_.bind( | ||
this, context, contentProtection, kind, language, main)) | ||
this, context, contentProtection, kind, language, label, main)) | ||
.filter(function(s) { return !!s; }); | ||
|
||
if (streams.length == 0) { | ||
|
@@ -1018,6 +1021,7 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) { | |
* @param {shaka.dash.ContentProtection.Context} contentProtection | ||
* @param {(string|undefined)} kind | ||
* @param {string} language | ||
* @param {string} label | ||
* @param {boolean} isPrimary | ||
* @param {!Element} node | ||
* @return {?shakaExtern.Stream} The Stream, or null when there is a | ||
|
@@ -1026,7 +1030,7 @@ shaka.dash.DashParser.prototype.parseAdaptationSet_ = function(context, elem) { | |
* @private | ||
*/ | ||
shaka.dash.DashParser.prototype.parseRepresentation_ = function( | ||
context, contentProtection, kind, language, isPrimary, node) { | ||
context, contentProtection, kind, language, label, isPrimary, node) { | ||
var XmlUtils = shaka.util.XmlUtils; | ||
var ContentType = shaka.util.ManifestParserUtils.ContentType; | ||
|
||
|
@@ -1105,6 +1109,7 @@ shaka.dash.DashParser.prototype.parseRepresentation_ = function( | |
encrypted: contentProtection.drmInfos.length > 0, | ||
keyId: keyId, | ||
language: language, | ||
label: label, | ||
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. Please add this new field to the definition of the |
||
type: context.adaptationSet.contentType, | ||
primary: isPrimary, | ||
trickModeVideo: null, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,6 +233,9 @@ shaka.util.StreamUtils.getVariantTracks = | |
if (variant.audio) { | ||
if (codecs != '') codecs += ', '; | ||
codecs += variant.audio.codecs; | ||
if (variant.audio.label) { | ||
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. This "if" is unnecessary. Just set label = variant.audio.label. |
||
variant.label = variant.audio.label; | ||
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. It doesn't make sense to push it from variant.audio ( Instead, though, I recommend just storing the label in a local var. I don't see any good reason to push it up to the variant. |
||
} | ||
} | ||
|
||
var audioCodec = variant.audio ? variant.audio.codecs : null; | ||
|
@@ -251,6 +254,7 @@ shaka.util.StreamUtils.getVariantTracks = | |
type: 'variant', | ||
bandwidth: variant.bandwidth, | ||
language: variant.language, | ||
label: variant.label, | ||
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. Please add this new field to the definition of the |
||
kind: kind || null, | ||
width: variant.video ? variant.video.width : null, | ||
height: variant.video ? variant.video.height : null, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,7 @@ describe('DashParser Manifest', function() { | |
' <Representation bandwidth="50" width="576" height="432" />', | ||
' </AdaptationSet>', | ||
' <AdaptationSet mimeType="text/vtt"', | ||
' lang="es">', | ||
' lang="es" label="spanish">', | ||
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. Thank you for updating the tests! |
||
' <Role value="caption" />', | ||
' <Role value="main" />', | ||
' <Representation bandwidth="100" />', | ||
|
@@ -176,6 +176,7 @@ describe('DashParser Manifest', function() { | |
.primary() | ||
.addTextStream(jasmine.any(Number)) | ||
.language('es') | ||
.label('spanish') | ||
.primary() | ||
.anySegmentFunctions() | ||
.anyInitSegment() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,18 @@ shaka.test.ManifestGenerator.prototype.language = function(language) { | |
}; | ||
|
||
|
||
/** | ||
* Sets the label of the language of the most recent variant or text stream. | ||
* | ||
* @param {string} label | ||
* @return {!shaka.test.ManifestGenerator} | ||
*/ | ||
shaka.test.ManifestGenerator.prototype.label = function(label) { | ||
this.currentStreamOrVariant_().label = label; | ||
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. Please use currentStream_() instead, since this attribute should only live at the stream level. |
||
return this; | ||
}; | ||
|
||
|
||
/** | ||
* Sets that the most recent variant or text stream is primary. | ||
* | ||
|
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.
There are two things wrong with this part:
For example, if you have two tracks of the same language, as @erankor suggested is common for this feature, you would have these tracks:
But the only language in the language list will be "en". With what you've written, your language options in HTML would wind up as:
While the variant tracks would still both show "language: en" with no differentiation.
I think the method you really want to modify here is
shakaDemo.updateTrackOptions_
, specifically theformatters
callbacks.