DashManifestParser extends DefaultHandler implements ParsingLoadable.Parser<DashManifest> { protected static int parseCea608AccessibilityChannel( List<Descriptor> accessibilityDescriptors) { for (int i = 0; i < accessibilityDescriptors.size(); i++) { Descriptor descriptor = accessibilityDescriptors.get(i); if ("urn:scte:dash:cc:cea-608:2015".equals(descriptor.schemeIdUri) && descriptor.value != null) { Matcher accessibilityValueMatcher = CEA_608_ACCESSIBILITY_PATTERN.matcher(descriptor.value); if (accessibilityValueMatcher.matches()) { return Integer.parseInt(accessibilityValueMatcher.group(1)); } else { Log.w(TAG, "Unable to parse CEA-608 channel number from: " + descriptor.value); } } } return Format.NO_VALUE; } DashManifestParser(); @Override DashManifest parse(Uri uri, InputStream inputStream); static void maybeSkipTag(XmlPullParser xpp);  }
@Test public void parseCea608AccessibilityChannel() { assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors("CC1=eng"))) .isEqualTo(1); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors("CC2=eng"))) .isEqualTo(2); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors("CC3=eng"))) .isEqualTo(3); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors("CC4=eng"))) .isEqualTo(4); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors(null))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors(""))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors("CC0=eng"))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors("CC5=eng"))) .isEqualTo(Format.NO_VALUE); assertThat( DashManifestParser.parseCea608AccessibilityChannel( buildCea608AccessibilityDescriptors("Wrong format"))) .isEqualTo(Format.NO_VALUE); }