Commit c01c2c34 by olly Committed by Oliver Woodman

Store full accessibility descriptors in parsed DASH manifest

Issue: #2362

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145402640
parent 4efdd14c
...@@ -213,7 +213,7 @@ public class OfflineLicenseHelperTest extends InstrumentationTestCase { ...@@ -213,7 +213,7 @@ public class OfflineLicenseHelperTest extends InstrumentationTestCase {
} }
private static AdaptationSet newAdaptationSets(Representation... representations) { private static AdaptationSet newAdaptationSets(Representation... representations) {
return new AdaptationSet(0, C.TRACK_TYPE_VIDEO, Arrays.asList(representations)); return new AdaptationSet(0, C.TRACK_TYPE_VIDEO, Arrays.asList(representations), null);
} }
private static Representation newRepresentations(DrmInitData drmInitData) { private static Representation newRepresentations(DrmInitData drmInitData) {
......
...@@ -20,6 +20,8 @@ import android.test.InstrumentationTestCase; ...@@ -20,6 +20,8 @@ import android.test.InstrumentationTestCase;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.testutil.TestUtil; import com.google.android.exoplayer2.testutil.TestUtil;
import java.io.IOException; import java.io.IOException;
import java.util.Collections;
import java.util.List;
/** /**
* Unit tests for {@link DashManifestParser}. * Unit tests for {@link DashManifestParser}.
...@@ -70,34 +72,57 @@ public class DashManifestParserTest extends InstrumentationTestCase { ...@@ -70,34 +72,57 @@ public class DashManifestParserTest extends InstrumentationTestCase {
} }
public void testParseCea608AccessibilityChannel() { public void testParseCea608AccessibilityChannel() {
assertEquals(1, DashManifestParser.parseCea608AccessibilityChannel("CC1=eng")); assertEquals(1, DashManifestParser.parseCea608AccessibilityChannel(
assertEquals(2, DashManifestParser.parseCea608AccessibilityChannel("CC2=eng")); buildCea608AccessibilityDescriptors("CC1=eng")));
assertEquals(3, DashManifestParser.parseCea608AccessibilityChannel("CC3=eng")); assertEquals(2, DashManifestParser.parseCea608AccessibilityChannel(
assertEquals(4, DashManifestParser.parseCea608AccessibilityChannel("CC4=eng")); buildCea608AccessibilityDescriptors("CC2=eng")));
assertEquals(3, DashManifestParser.parseCea608AccessibilityChannel(
buildCea608AccessibilityDescriptors("CC3=eng")));
assertEquals(4, DashManifestParser.parseCea608AccessibilityChannel(
buildCea608AccessibilityDescriptors("CC4=eng")));
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel(null)); assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel(
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel("")); buildCea608AccessibilityDescriptors(null)));
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel("CC0=eng")); assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel(
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel("CC5=eng")); buildCea608AccessibilityDescriptors("")));
assertEquals(Format.NO_VALUE, assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel(
DashManifestParser.parseCea608AccessibilityChannel("Wrong format")); buildCea608AccessibilityDescriptors("CC0=eng")));
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel(
buildCea608AccessibilityDescriptors("CC5=eng")));
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea608AccessibilityChannel(
buildCea608AccessibilityDescriptors("Wrong format")));
} }
public void testParseCea708AccessibilityChannel() { public void testParseCea708AccessibilityChannel() {
assertEquals(1, DashManifestParser.parseCea708AccessibilityChannel("1=lang:eng")); assertEquals(1, DashManifestParser.parseCea708AccessibilityChannel(
assertEquals(2, DashManifestParser.parseCea708AccessibilityChannel("2=lang:eng")); buildCea708AccessibilityDescriptors("1=lang:eng")));
assertEquals(3, DashManifestParser.parseCea708AccessibilityChannel("3=lang:eng")); assertEquals(2, DashManifestParser.parseCea708AccessibilityChannel(
assertEquals(62, DashManifestParser.parseCea708AccessibilityChannel("62=lang:eng")); buildCea708AccessibilityDescriptors("2=lang:eng")));
assertEquals(63, DashManifestParser.parseCea708AccessibilityChannel("63=lang:eng")); assertEquals(3, DashManifestParser.parseCea708AccessibilityChannel(
buildCea708AccessibilityDescriptors("3=lang:eng")));
assertEquals(62, DashManifestParser.parseCea708AccessibilityChannel(
buildCea708AccessibilityDescriptors("62=lang:eng")));
assertEquals(63, DashManifestParser.parseCea708AccessibilityChannel(
buildCea708AccessibilityDescriptors("63=lang:eng")));
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea708AccessibilityChannel(null)); assertEquals(Format.NO_VALUE, DashManifestParser.parseCea708AccessibilityChannel(
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea708AccessibilityChannel("")); buildCea708AccessibilityDescriptors(null)));
assertEquals(Format.NO_VALUE, assertEquals(Format.NO_VALUE, DashManifestParser.parseCea708AccessibilityChannel(
DashManifestParser.parseCea708AccessibilityChannel("0=lang:eng")); buildCea708AccessibilityDescriptors("")));
assertEquals(Format.NO_VALUE, assertEquals(Format.NO_VALUE, DashManifestParser.parseCea708AccessibilityChannel(
DashManifestParser.parseCea708AccessibilityChannel("64=lang:eng")); buildCea708AccessibilityDescriptors("0=lang:eng")));
assertEquals(Format.NO_VALUE, assertEquals(Format.NO_VALUE, DashManifestParser.parseCea708AccessibilityChannel(
DashManifestParser.parseCea708AccessibilityChannel("Wrong format")); buildCea708AccessibilityDescriptors("64=lang:eng")));
assertEquals(Format.NO_VALUE, DashManifestParser.parseCea708AccessibilityChannel(
buildCea708AccessibilityDescriptors("Wrong format")));
}
private static List<SchemeValuePair> buildCea608AccessibilityDescriptors(String value) {
return Collections.singletonList(new SchemeValuePair("urn:scte:dash:cc:cea-608:2015", value));
}
private static List<SchemeValuePair> buildCea708AccessibilityDescriptors(String value) {
return Collections.singletonList(new SchemeValuePair("urn:scte:dash:cc:cea-708:2015", value));
} }
} }
...@@ -46,16 +46,26 @@ public class AdaptationSet { ...@@ -46,16 +46,26 @@ public class AdaptationSet {
public final List<Representation> representations; public final List<Representation> representations;
/** /**
* The accessibility descriptors in the adaptation set.
*/
public final List<SchemeValuePair> accessibilityDescriptors;
/**
* @param id A non-negative identifier for the adaptation set that's unique in the scope of its * @param id A non-negative identifier for the adaptation set that's unique in the scope of its
* containing period, or {@link #ID_UNSET} if not specified. * containing period, or {@link #ID_UNSET} if not specified.
* @param type The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C} * @param type The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C}
* {@code TRACK_TYPE_*} constants. * {@code TRACK_TYPE_*} constants.
* @param representations The {@link Representation}s in the adaptation set. * @param representations The {@link Representation}s in the adaptation set.
* @param accessibilityDescriptors The accessibility descriptors in the adaptation set.
*/ */
public AdaptationSet(int id, int type, List<Representation> representations) { public AdaptationSet(int id, int type, List<Representation> representations,
List<SchemeValuePair> accessibilityDescriptors) {
this.id = id; this.id = id;
this.type = type; this.type = type;
this.representations = Collections.unmodifiableList(representations); this.representations = Collections.unmodifiableList(representations);
this.accessibilityDescriptors = accessibilityDescriptors == null
? Collections.<SchemeValuePair>emptyList()
: Collections.unmodifiableList(accessibilityDescriptors);
} }
} }
...@@ -63,9 +63,9 @@ public abstract class Representation { ...@@ -63,9 +63,9 @@ public abstract class Representation {
*/ */
public final long presentationTimeOffsetUs; public final long presentationTimeOffsetUs;
/** /**
* The {@link InbandEventStream}s in the representation. Never null, but may be empty. * The in-band event streams in the representation. Never null, but may be empty.
*/ */
public final List<InbandEventStream> inbandEventStreams; public final List<SchemeValuePair> inbandEventStreams;
private final RangedUri initializationUri; private final RangedUri initializationUri;
...@@ -92,11 +92,11 @@ public abstract class Representation { ...@@ -92,11 +92,11 @@ public abstract class Representation {
* @param format The format of the representation. * @param format The format of the representation.
* @param baseUrl The base URL. * @param baseUrl The base URL.
* @param segmentBase A segment base element for the representation. * @param segmentBase A segment base element for the representation.
* @param inbandEventStreams The {@link InbandEventStream}s in the representation. May be null. * @param inbandEventStreams The in-band event streams in the representation. May be null.
* @return The constructed instance. * @return The constructed instance.
*/ */
public static Representation newInstance(String contentId, long revisionId, Format format, public static Representation newInstance(String contentId, long revisionId, Format format,
String baseUrl, SegmentBase segmentBase, List<InbandEventStream> inbandEventStreams) { String baseUrl, SegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams) {
return newInstance(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams, return newInstance(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams,
null); null);
} }
...@@ -109,13 +109,13 @@ public abstract class Representation { ...@@ -109,13 +109,13 @@ public abstract class Representation {
* @param format The format of the representation. * @param format The format of the representation.
* @param baseUrl The base URL of the representation. * @param baseUrl The base URL of the representation.
* @param segmentBase A segment base element for the representation. * @param segmentBase A segment base element for the representation.
* @param inbandEventStreams The {@link InbandEventStream}s in the representation. May be null. * @param inbandEventStreams The in-band event streams in the representation. May be null.
* @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null. This * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null. This
* parameter is ignored if {@code segmentBase} consists of multiple segments. * parameter is ignored if {@code segmentBase} consists of multiple segments.
* @return The constructed instance. * @return The constructed instance.
*/ */
public static Representation newInstance(String contentId, long revisionId, Format format, public static Representation newInstance(String contentId, long revisionId, Format format,
String baseUrl, SegmentBase segmentBase, List<InbandEventStream> inbandEventStreams, String baseUrl, SegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams,
String customCacheKey) { String customCacheKey) {
if (segmentBase instanceof SingleSegmentBase) { if (segmentBase instanceof SingleSegmentBase) {
return new SingleSegmentRepresentation(contentId, revisionId, format, baseUrl, return new SingleSegmentRepresentation(contentId, revisionId, format, baseUrl,
...@@ -130,13 +130,13 @@ public abstract class Representation { ...@@ -130,13 +130,13 @@ public abstract class Representation {
} }
private Representation(String contentId, long revisionId, Format format, String baseUrl, private Representation(String contentId, long revisionId, Format format, String baseUrl,
SegmentBase segmentBase, List<InbandEventStream> inbandEventStreams) { SegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams) {
this.contentId = contentId; this.contentId = contentId;
this.revisionId = revisionId; this.revisionId = revisionId;
this.format = format; this.format = format;
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
this.inbandEventStreams = inbandEventStreams == null this.inbandEventStreams = inbandEventStreams == null
? Collections.<InbandEventStream>emptyList() ? Collections.<SchemeValuePair>emptyList()
: Collections.unmodifiableList(inbandEventStreams); : Collections.unmodifiableList(inbandEventStreams);
initializationUri = segmentBase.getInitialization(this); initializationUri = segmentBase.getInitialization(this);
presentationTimeOffsetUs = segmentBase.getPresentationTimeOffsetUs(); presentationTimeOffsetUs = segmentBase.getPresentationTimeOffsetUs();
...@@ -195,13 +195,13 @@ public abstract class Representation { ...@@ -195,13 +195,13 @@ public abstract class Representation {
* @param initializationEnd The offset of the last byte of initialization data. * @param initializationEnd The offset of the last byte of initialization data.
* @param indexStart The offset of the first byte of index data. * @param indexStart The offset of the first byte of index data.
* @param indexEnd The offset of the last byte of index data. * @param indexEnd The offset of the last byte of index data.
* @param inbandEventStreams The {@link InbandEventStream}s in the representation. May be null. * @param inbandEventStreams The in-band event streams in the representation. May be null.
* @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null. * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
* @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown. * @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
*/ */
public static SingleSegmentRepresentation newInstance(String contentId, long revisionId, public static SingleSegmentRepresentation newInstance(String contentId, long revisionId,
Format format, String uri, long initializationStart, long initializationEnd, Format format, String uri, long initializationStart, long initializationEnd,
long indexStart, long indexEnd, List<InbandEventStream> inbandEventStreams, long indexStart, long indexEnd, List<SchemeValuePair> inbandEventStreams,
String customCacheKey, long contentLength) { String customCacheKey, long contentLength) {
RangedUri rangedUri = new RangedUri(null, initializationStart, RangedUri rangedUri = new RangedUri(null, initializationStart,
initializationEnd - initializationStart + 1); initializationEnd - initializationStart + 1);
...@@ -217,12 +217,12 @@ public abstract class Representation { ...@@ -217,12 +217,12 @@ public abstract class Representation {
* @param format The format of the representation. * @param format The format of the representation.
* @param baseUrl The base URL of the representation. * @param baseUrl The base URL of the representation.
* @param segmentBase The segment base underlying the representation. * @param segmentBase The segment base underlying the representation.
* @param inbandEventStreams The {@link InbandEventStream}s in the representation. May be null. * @param inbandEventStreams The in-band event streams in the representation. May be null.
* @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null. * @param customCacheKey A custom value to be returned from {@link #getCacheKey()}, or null.
* @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown. * @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
*/ */
public SingleSegmentRepresentation(String contentId, long revisionId, Format format, public SingleSegmentRepresentation(String contentId, long revisionId, Format format,
String baseUrl, SingleSegmentBase segmentBase, List<InbandEventStream> inbandEventStreams, String baseUrl, SingleSegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams,
String customCacheKey, long contentLength) { String customCacheKey, long contentLength) {
super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams); super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams);
this.uri = Uri.parse(baseUrl); this.uri = Uri.parse(baseUrl);
...@@ -267,10 +267,10 @@ public abstract class Representation { ...@@ -267,10 +267,10 @@ public abstract class Representation {
* @param format The format of the representation. * @param format The format of the representation.
* @param baseUrl The base URL of the representation. * @param baseUrl The base URL of the representation.
* @param segmentBase The segment base underlying the representation. * @param segmentBase The segment base underlying the representation.
* @param inbandEventStreams The {@link InbandEventStream}s in the representation. May be null. * @param inbandEventStreams The in-band event streams in the representation. May be null.
*/ */
public MultiSegmentRepresentation(String contentId, long revisionId, Format format, public MultiSegmentRepresentation(String contentId, long revisionId, Format format,
String baseUrl, MultiSegmentBase segmentBase, List<InbandEventStream> inbandEventStreams) { String baseUrl, MultiSegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams) {
super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams); super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams);
this.segmentBase = segmentBase; this.segmentBase = segmentBase;
} }
......
...@@ -18,14 +18,14 @@ package com.google.android.exoplayer2.source.dash.manifest; ...@@ -18,14 +18,14 @@ package com.google.android.exoplayer2.source.dash.manifest;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
/** /**
* Represents a DASH in-band event stream. * A pair consisting of a scheme ID and value.
*/ */
public class InbandEventStream { public class SchemeValuePair {
public final String schemeIdUri; public final String schemeIdUri;
public final String value; public final String value;
public InbandEventStream(String schemeIdUri, String value) { public SchemeValuePair(String schemeIdUri, String value) {
this.schemeIdUri = schemeIdUri; this.schemeIdUri = schemeIdUri;
this.value = value; this.value = value;
} }
...@@ -38,7 +38,7 @@ public class InbandEventStream { ...@@ -38,7 +38,7 @@ public class InbandEventStream {
if (obj == null || getClass() != obj.getClass()) { if (obj == null || getClass() != obj.getClass()) {
return false; return false;
} }
InbandEventStream other = (InbandEventStream) obj; SchemeValuePair other = (SchemeValuePair) obj;
return Util.areEqual(schemeIdUri, other.schemeIdUri) && Util.areEqual(value, other.value); return Util.areEqual(schemeIdUri, other.schemeIdUri) && Util.areEqual(value, other.value);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment