Commit 9737046e by olly Committed by Oliver Woodman

Parse SupplementalProperty elements in DASH adaptation sets

This will be used to merge adaptation sets that are marked for
seamless switching into single TrackGroups in DashMediaSource.

Issue: #2431

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157209358
parent 5092efe3
......@@ -62,7 +62,7 @@ public final class DashUtilTest extends TestCase {
}
private static AdaptationSet newAdaptationSets(Representation... representations) {
return new AdaptationSet(0, C.TRACK_TYPE_VIDEO, Arrays.asList(representations), null);
return new AdaptationSet(0, C.TRACK_TYPE_VIDEO, Arrays.asList(representations), null, null);
}
private static Representation newRepresentations(DrmInitData drmInitData) {
......
......@@ -115,12 +115,12 @@ public class DashManifestParserTest extends InstrumentationTestCase {
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<Descriptor> buildCea608AccessibilityDescriptors(String value) {
return Collections.singletonList(new Descriptor("urn:scte:dash:cc:cea-608:2015", value, null));
}
private static List<SchemeValuePair> buildCea708AccessibilityDescriptors(String value) {
return Collections.singletonList(new SchemeValuePair("urn:scte:dash:cc:cea-708:2015", value));
private static List<Descriptor> buildCea708AccessibilityDescriptors(String value) {
return Collections.singletonList(new Descriptor("urn:scte:dash:cc:cea-708:2015", value, null));
}
}
......@@ -30,8 +30,6 @@ import junit.framework.TestCase;
public class DashManifestTest extends TestCase {
private static final UtcTimingElement DUMMY_UTC_TIMING = new UtcTimingElement("", "");
private static final List<SchemeValuePair> DUMMY_ACCESSIBILITY_DESCRIPTORS =
Collections.emptyList();
private static final SingleSegmentBase DUMMY_SEGMENT_BASE = new SingleSegmentBase();
private static final Format DUMMY_FORMAT = Format.createSampleFormat("", "", 0);
......@@ -190,8 +188,7 @@ public class DashManifestTest extends TestCase {
}
private static AdaptationSet newAdaptationSet(int seed, Representation... representations) {
return new AdaptationSet(++seed, ++seed, Arrays.asList(representations),
DUMMY_ACCESSIBILITY_DESCRIPTORS);
return new AdaptationSet(++seed, ++seed, Arrays.asList(representations), null, null);
}
}
......@@ -30,8 +30,8 @@ import com.google.android.exoplayer2.source.chunk.ChunkSampleStream;
import com.google.android.exoplayer2.source.chunk.ChunkSampleStream.EmbeddedSampleStream;
import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet;
import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
import com.google.android.exoplayer2.source.dash.manifest.Descriptor;
import com.google.android.exoplayer2.source.dash.manifest.Representation;
import com.google.android.exoplayer2.source.dash.manifest.SchemeValuePair;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
......@@ -319,9 +319,9 @@ import java.util.List;
}
private static boolean hasCea608Track(AdaptationSet adaptationSet) {
List<SchemeValuePair> descriptors = adaptationSet.accessibilityDescriptors;
List<Descriptor> descriptors = adaptationSet.accessibilityDescriptors;
for (int i = 0; i < descriptors.size(); i++) {
SchemeValuePair descriptor = descriptors.get(i);
Descriptor descriptor = descriptors.get(i);
if ("urn:scte:dash:cc:cea-608:2015".equals(descriptor.schemeIdUri)) {
return true;
}
......
......@@ -41,31 +41,40 @@ public class AdaptationSet {
public final int type;
/**
* The {@link Representation}s in the adaptation set.
* {@link Representation}s in the adaptation set.
*/
public final List<Representation> representations;
/**
* The accessibility descriptors in the adaptation set.
* Accessibility descriptors in the adaptation set.
*/
public final List<SchemeValuePair> accessibilityDescriptors;
public final List<Descriptor> accessibilityDescriptors;
/**
* Supplemental properties in the adaptation set.
*/
public final List<Descriptor> supplementalProperties;
/**
* @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.
* @param type The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C}
* {@code TRACK_TYPE_*} constants.
* @param representations The {@link Representation}s in the adaptation set.
* @param accessibilityDescriptors The accessibility descriptors in the adaptation set.
* @param representations {@link Representation}s in the adaptation set.
* @param accessibilityDescriptors Accessibility descriptors in the adaptation set.
* @param supplementalProperties Supplemental properties in the adaptation set.
*/
public AdaptationSet(int id, int type, List<Representation> representations,
List<SchemeValuePair> accessibilityDescriptors) {
List<Descriptor> accessibilityDescriptors, List<Descriptor> supplementalProperties) {
this.id = id;
this.type = type;
this.representations = Collections.unmodifiableList(representations);
this.accessibilityDescriptors = accessibilityDescriptors == null
? Collections.<SchemeValuePair>emptyList()
? Collections.<Descriptor>emptyList()
: Collections.unmodifiableList(accessibilityDescriptors);
this.supplementalProperties = supplementalProperties == null
? Collections.<Descriptor>emptyList()
: Collections.unmodifiableList(supplementalProperties);
}
}
......@@ -134,7 +134,8 @@ public class DashManifest {
} while(key.periodIndex == periodIndex && key.adaptationSetIndex == adaptationSetIndex);
copyAdaptationSets.add(new AdaptationSet(adaptationSet.id, adaptationSet.type,
copyRepresentations, adaptationSet.accessibilityDescriptors));
copyRepresentations, adaptationSet.accessibilityDescriptors,
adaptationSet.supplementalProperties));
} while(key.periodIndex == periodIndex);
// Add back the last key which doesn't belong to the period being processed
keys.addFirst(key);
......
......@@ -15,19 +15,37 @@
*/
package com.google.android.exoplayer2.source.dash.manifest;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.google.android.exoplayer2.util.Util;
/**
* A pair consisting of a scheme ID and value.
* A descriptor, as defined by ISO 23009-1, 2nd edition, 5.8.2.
*/
public class SchemeValuePair {
public final class Descriptor {
public final String schemeIdUri;
public final String value;
/**
* The scheme URI.
*/
@NonNull public final String schemeIdUri;
/**
* The value, or null.
*/
@Nullable public final String value;
/**
* The identifier, or null.
*/
@Nullable public final String id;
public SchemeValuePair(String schemeIdUri, String value) {
/**
* @param schemeIdUri The scheme URI.
* @param value The value, or null.
* @param id The identifier, or null.
*/
public Descriptor(@NonNull String schemeIdUri, @Nullable String value, @Nullable String id) {
this.schemeIdUri = schemeIdUri;
this.value = value;
this.id = id;
}
@Override
......@@ -38,14 +56,17 @@ public class SchemeValuePair {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
SchemeValuePair other = (SchemeValuePair) obj;
return Util.areEqual(schemeIdUri, other.schemeIdUri) && Util.areEqual(value, other.value);
Descriptor other = (Descriptor) obj;
return Util.areEqual(schemeIdUri, other.schemeIdUri) && Util.areEqual(value, other.value)
&& Util.areEqual(id, other.id);
}
@Override
public int hashCode() {
return 31 * (schemeIdUri != null ? schemeIdUri.hashCode() : 0)
+ (value != null ? value.hashCode() : 0);
int result = (schemeIdUri != null ? schemeIdUri.hashCode() : 0);
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (id != null ? id.hashCode() : 0);
return result;
}
}
......@@ -65,7 +65,7 @@ public abstract class Representation {
/**
* The in-band event streams in the representation. Never null, but may be empty.
*/
public final List<SchemeValuePair> inbandEventStreams;
public final List<Descriptor> inbandEventStreams;
private final RangedUri initializationUri;
......@@ -96,7 +96,7 @@ public abstract class Representation {
* @return The constructed instance.
*/
public static Representation newInstance(String contentId, long revisionId, Format format,
String baseUrl, SegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams) {
String baseUrl, SegmentBase segmentBase, List<Descriptor> inbandEventStreams) {
return newInstance(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams,
null);
}
......@@ -115,7 +115,7 @@ public abstract class Representation {
* @return The constructed instance.
*/
public static Representation newInstance(String contentId, long revisionId, Format format,
String baseUrl, SegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams,
String baseUrl, SegmentBase segmentBase, List<Descriptor> inbandEventStreams,
String customCacheKey) {
if (segmentBase instanceof SingleSegmentBase) {
return new SingleSegmentRepresentation(contentId, revisionId, format, baseUrl,
......@@ -130,13 +130,12 @@ public abstract class Representation {
}
private Representation(String contentId, long revisionId, Format format, String baseUrl,
SegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams) {
SegmentBase segmentBase, List<Descriptor> inbandEventStreams) {
this.contentId = contentId;
this.revisionId = revisionId;
this.format = format;
this.baseUrl = baseUrl;
this.inbandEventStreams = inbandEventStreams == null
? Collections.<SchemeValuePair>emptyList()
this.inbandEventStreams = inbandEventStreams == null ? Collections.<Descriptor>emptyList()
: Collections.unmodifiableList(inbandEventStreams);
initializationUri = segmentBase.getInitialization(this);
presentationTimeOffsetUs = segmentBase.getPresentationTimeOffsetUs();
......@@ -201,8 +200,8 @@ public abstract class Representation {
*/
public static SingleSegmentRepresentation newInstance(String contentId, long revisionId,
Format format, String uri, long initializationStart, long initializationEnd,
long indexStart, long indexEnd, List<SchemeValuePair> inbandEventStreams,
String customCacheKey, long contentLength) {
long indexStart, long indexEnd, List<Descriptor> inbandEventStreams, String customCacheKey,
long contentLength) {
RangedUri rangedUri = new RangedUri(null, initializationStart,
initializationEnd - initializationStart + 1);
SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, indexStart,
......@@ -222,7 +221,7 @@ public abstract class Representation {
* @param contentLength The content length, or {@link C#LENGTH_UNSET} if unknown.
*/
public SingleSegmentRepresentation(String contentId, long revisionId, Format format,
String baseUrl, SingleSegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams,
String baseUrl, SingleSegmentBase segmentBase, List<Descriptor> inbandEventStreams,
String customCacheKey, long contentLength) {
super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams);
this.uri = Uri.parse(baseUrl);
......@@ -270,7 +269,7 @@ public abstract class Representation {
* @param inbandEventStreams The in-band event streams in the representation. May be null.
*/
public MultiSegmentRepresentation(String contentId, long revisionId, Format format,
String baseUrl, MultiSegmentBase segmentBase, List<SchemeValuePair> inbandEventStreams) {
String baseUrl, MultiSegmentBase segmentBase, List<Descriptor> inbandEventStreams) {
super(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams);
this.segmentBase = segmentBase;
}
......
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