DashManifestParser extends DefaultHandler implements ParsingLoadable.Parser<DashManifest> { protected static int parseCea708AccessibilityChannel( List<Descriptor> accessibilityDescriptors) { for (int i = 0; i < accessibilityDescriptors.size(); i++) { Descriptor descriptor = accessibilityDescriptors.get(i); if ("urn:scte:dash:cc:cea-708:2015".equals(descriptor.schemeIdUri) && descriptor.value != null) { Matcher accessibilityValueMatcher = CEA_708_ACCESSIBILITY_PATTERN.matcher(descriptor.value); if (accessibilityValueMatcher.matches()) { return Integer.parseInt(accessibilityValueMatcher.group(1)); } else { Log.w(TAG, "Unable to parse CEA-708 service block number from: " + descriptor.value); } } } return Format.NO_VALUE; } DashManifestParser(); @Override DashManifest parse(Uri uri, InputStream inputStream); static void maybeSkipTag(XmlPullParser xpp);  }
@Test public void parseCea708AccessibilityChannel() { assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("1=lang:eng"))) .isEqualTo(1); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("2=lang:eng"))) .isEqualTo(2); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("3=lang:eng"))) .isEqualTo(3); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("62=lang:eng"))) .isEqualTo(62); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("63=lang:eng"))) .isEqualTo(63); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors(null))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors(""))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("0=lang:eng"))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("64=lang:eng"))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea708AccessibilityChannel( buildCea708AccessibilityDescriptors("Wrong format"))) .isEqualTo(Format.NO_VALUE); }