Conversation
Currently, DashMediaPeriod only takes into account as CEA-608 accessibility tags as embedded closed captions tracks CEA-608. CEA-708 closed captions format is parsed when is present on its own AdaptationSet, but not when is embedded as an accessibility tag in a video AdaptaticonSet. Embedded CEA-708 support is added by parsing accessibility tags like the example below: <Accessibility schemeIdUri="urn:scte:dash:cc:cea-708:2015" value="1=lang:eng;2=lang:deu"/> <Accessibility schemeIdUri="urn:scte:dash:cc:cea-708:2015" value="1=lang:eng;2=lang:eng,war:1,er:1"/> so it creates a new CEA-708 track for accessibility tags with schemeIdUri = urn:scte:dash:cc:cea-708:2015 and extract accessibilityChannel and language from value attribute. Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
@googlebot I signed it! |
|
I'm not sure why the CLA check is unhappy. Marking with the |
|
A Googler has manually verified that the CLAs look good. (Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.) ℹ️ Googlers: Go here for more info. |
ojw28
left a comment
There was a problem hiding this comment.
Please take a look at the comments. Thanks!
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
Show resolved
Hide resolved
| } | ||
|
|
||
| private static Format[] getCea608TrackFormats( | ||
| private static Format[] getClosedCaptionsTrackFormats( |
There was a problem hiding this comment.
The use of the enum through this code is IMO making it quite a bit harder to read than it needs to be. Can't you just do something like (warning, untested):
private static Format[] getClosedCaptionTrackFormats(
List<AdaptationSet> adaptationSets, int[] adaptationSetIndices) {
for (int i : adaptationSetIndices) {
AdaptationSet adaptationSet = adaptationSets.get(i);
List<Descriptor> descriptors = adaptationSets.get(i).accessibilityDescriptors;
for (int j = 0; j < descriptors.size(); j++) {
Descriptor descriptor = descriptors.get(j);
if ("urn:scte:dash:cc:cea-608:2015".equals(descriptor.schemeIdUri)) {
Format cea608Format =
new Format.Builder()
.setSampleMimeType(MimeTypes.APPLICATION_CEA608)
.setId(adaptationSet.id + ":cea608")
.build();
return parseClosedCaptionDescriptor(
descriptor, CEA608_SERVICE_DESCRIPTOR_REGEX, cea608Format);
} else if ("urn:scte:dash:cc:cea-708:2015".equals(descriptor.schemeIdUri)) {
Format cea708Format =
new Format.Builder()
.setSampleMimeType(MimeTypes.APPLICATION_CEA708)
.setId(adaptationSet.id + ":cea708")
.build();
return parseClosedCaptionDescriptor(
descriptor, CEA708_SERVICE_DESCRIPTOR_REGEX, cea708Format);
}
}
}
return new Format[0];
}
private static Format[] parseClosedCaptionDescriptor(
Descriptor descriptor, Pattern serviceDescriptorRegex, Format baseFormat) {
@Nullable String value = descriptor.value;
if (value == null) {
// There are embedded closed caption tracks, but service information is not declared.
return new Format[] {baseFormat};
}
String[] services = Util.split(value, ";");
Format[] formats = new Format[services.length];
for (int i = 0; i < services.length; i++) {
Matcher matcher = serviceDescriptorRegex.matcher(services[i]);
if (!matcher.matches()) {
// If we can't parse service information for all services, assume a single track.
return new Format[] {baseFormat};
}
int accessibilityChannel = Integer.parseInt(matcher.group(1));
formats[i] =
baseFormat
.buildUpon()
.setId(baseFormat.id + ":" + accessibilityChannel)
.setAccessibilityChannel(accessibilityChannel)
.setLanguage(matcher.group(2))
.build();
}
return formats;
}
and get rid of the enum and all the little helper methods.
| return formats; | ||
| } | ||
| for (Descriptor descriptor : descriptors) { | ||
| return parseClosedCaptionsDescriptor(adaptationSet.id, descriptor); |
There was a problem hiding this comment.
Might be irrelevant if you can go with my proposal above, but this shouldn't return if parsedClosedCaptionsDescriptor returned null. Else parsing will fail if there's a descriptor for something other than 608/708 before the descriptor you're looking for.
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
This comment has been minimized.
This comment has been minimized.
This is the rename-only part of #7370 PiperOrigin-RevId: 312057896
|
I'm not sure why it's not been picked up, but this was merged in 3db703a. Thanks! |
Currently, DashMediaPeriod only takes into account as CEA-608 accessibility tags as embedded closed captions tracks CEA-608. CEA-708 closed captions format is parsed when is present on its own AdaptationSet, but not when is embedded as an accessibility tag in a video AdaptationSet.
Embedded CEA-708 support is added by parsing accessibility tags like the example below:
Creates a new CEA-708 track for accessibility tags with schemeIdUri
urn:scte:dash:cc:cea-708:2015and extract accessibilityChannel and language from value attribute.