Commit bafdd53b by microkatz Committed by Tianyi Feng

Merge pull request #487 from vishnuchilakala:allow_unsigned_int_for_adaptation_set_id

PiperOrigin-RevId: 544601945
(cherry picked from commit 6b3d3cd756a0dcd83cc2551078949f8427da27ed)
parent c033263d
...@@ -20,7 +20,6 @@ import static java.lang.annotation.ElementType.TYPE_USE; ...@@ -20,7 +20,6 @@ import static java.lang.annotation.ElementType.TYPE_USE;
import android.util.Pair; import android.util.Pair;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.SparseIntArray;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
...@@ -57,6 +56,7 @@ import com.google.android.exoplayer2.upstream.LoaderErrorThrower; ...@@ -57,6 +56,7 @@ import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.common.collect.Maps;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import java.io.IOException; import java.io.IOException;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
...@@ -65,6 +65,7 @@ import java.lang.annotation.RetentionPolicy; ...@@ -65,6 +65,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
...@@ -558,7 +559,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -558,7 +559,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
*/ */
private static int[][] getGroupedAdaptationSetIndices(List<AdaptationSet> adaptationSets) { private static int[][] getGroupedAdaptationSetIndices(List<AdaptationSet> adaptationSets) {
int adaptationSetCount = adaptationSets.size(); int adaptationSetCount = adaptationSets.size();
SparseIntArray adaptationSetIdToIndex = new SparseIntArray(adaptationSetCount); HashMap<Long, Integer> adaptationSetIdToIndex =
Maps.newHashMapWithExpectedSize(adaptationSetCount);
List<List<Integer>> adaptationSetGroupedIndices = new ArrayList<>(adaptationSetCount); List<List<Integer>> adaptationSetGroupedIndices = new ArrayList<>(adaptationSetCount);
SparseArray<List<Integer>> adaptationSetIndexToGroupedIndices = SparseArray<List<Integer>> adaptationSetIndexToGroupedIndices =
new SparseArray<>(adaptationSetCount); new SparseArray<>(adaptationSetCount);
...@@ -586,10 +588,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -586,10 +588,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
trickPlayProperty = findTrickPlayProperty(adaptationSet.supplementalProperties); trickPlayProperty = findTrickPlayProperty(adaptationSet.supplementalProperties);
} }
if (trickPlayProperty != null) { if (trickPlayProperty != null) {
int mainAdaptationSetId = Integer.parseInt(trickPlayProperty.value); long mainAdaptationSetId = Long.parseLong(trickPlayProperty.value);
int mainAdaptationSetIndex = @Nullable Integer mainAdaptationSetIndex = adaptationSetIdToIndex.get(mainAdaptationSetId);
adaptationSetIdToIndex.get(mainAdaptationSetId, /* valueIfKeyNotFound= */ -1); if (mainAdaptationSetIndex != null) {
if (mainAdaptationSetIndex != -1) {
mergedGroupIndex = mainAdaptationSetIndex; mergedGroupIndex = mainAdaptationSetIndex;
} }
} }
...@@ -603,11 +604,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -603,11 +604,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if (adaptationSetSwitchingProperty != null) { if (adaptationSetSwitchingProperty != null) {
String[] otherAdaptationSetIds = Util.split(adaptationSetSwitchingProperty.value, ","); String[] otherAdaptationSetIds = Util.split(adaptationSetSwitchingProperty.value, ",");
for (String adaptationSetId : otherAdaptationSetIds) { for (String adaptationSetId : otherAdaptationSetIds) {
int otherAdaptationSetId = @Nullable
adaptationSetIdToIndex.get( Integer otherAdaptationSetIndex =
Integer.parseInt(adaptationSetId), /* valueIfKeyNotFound= */ -1); adaptationSetIdToIndex.get(Long.parseLong(adaptationSetId));
if (otherAdaptationSetId != -1) { if (otherAdaptationSetIndex != null) {
mergedGroupIndex = min(mergedGroupIndex, otherAdaptationSetId); mergedGroupIndex = min(mergedGroupIndex, otherAdaptationSetIndex);
} }
} }
} }
...@@ -691,7 +692,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ...@@ -691,7 +692,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
AdaptationSet firstAdaptationSet = adaptationSets.get(adaptationSetIndices[0]); AdaptationSet firstAdaptationSet = adaptationSets.get(adaptationSetIndices[0]);
String trackGroupId = String trackGroupId =
firstAdaptationSet.id != AdaptationSet.ID_UNSET firstAdaptationSet.id != AdaptationSet.ID_UNSET
? Integer.toString(firstAdaptationSet.id) ? Long.toString(firstAdaptationSet.id)
: ("unset:" + i); : ("unset:" + i);
int primaryTrackGroupIndex = trackGroupCount++; int primaryTrackGroupIndex = trackGroupCount++;
int eventMessageTrackGroupIndex = int eventMessageTrackGroupIndex =
......
...@@ -31,13 +31,13 @@ import java.util.List; ...@@ -31,13 +31,13 @@ import java.util.List;
public class AdaptationSet { public class AdaptationSet {
/** Value of {@link #id} indicating no value is set.= */ /** Value of {@link #id} indicating no value is set.= */
public static final int ID_UNSET = -1; public static final long ID_UNSET = -1;
/** /**
* A non-negative identifier for the adaptation set that's unique in the scope of its containing * 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. * period, or {@link #ID_UNSET} if not specified.
*/ */
public final int id; public final long id;
/** The {@link C.TrackType track type} of the adaptation set. */ /** The {@link C.TrackType track type} of the adaptation set. */
public final @C.TrackType int type; public final @C.TrackType int type;
...@@ -64,7 +64,7 @@ public class AdaptationSet { ...@@ -64,7 +64,7 @@ public class AdaptationSet {
* @param supplementalProperties Supplemental properties in the adaptation set. * @param supplementalProperties Supplemental properties in the adaptation set.
*/ */
public AdaptationSet( public AdaptationSet(
int id, long id,
@C.TrackType int type, @C.TrackType int type,
List<Representation> representations, List<Representation> representations,
List<Descriptor> accessibilityDescriptors, List<Descriptor> accessibilityDescriptors,
......
...@@ -399,7 +399,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -399,7 +399,7 @@ public class DashManifestParser extends DefaultHandler
long timeShiftBufferDepthMs, long timeShiftBufferDepthMs,
boolean dvbProfileDeclared) boolean dvbProfileDeclared)
throws XmlPullParserException, IOException { throws XmlPullParserException, IOException {
int id = parseInt(xpp, "id", AdaptationSet.ID_UNSET); long id = parseLong(xpp, "id", AdaptationSet.ID_UNSET);
@C.TrackType int contentType = parseContentType(xpp); @C.TrackType int contentType = parseContentType(xpp);
String mimeType = xpp.getAttributeValue(null, "mimeType"); String mimeType = xpp.getAttributeValue(null, "mimeType");
...@@ -538,7 +538,7 @@ public class DashManifestParser extends DefaultHandler ...@@ -538,7 +538,7 @@ public class DashManifestParser extends DefaultHandler
} }
protected AdaptationSet buildAdaptationSet( protected AdaptationSet buildAdaptationSet(
int id, long id,
@C.TrackType int contentType, @C.TrackType int contentType,
List<Representation> representations, List<Representation> representations,
List<Descriptor> accessibilityDescriptors, List<Descriptor> accessibilityDescriptors,
......
...@@ -80,13 +80,14 @@ public final class DashMediaPeriodTest { ...@@ -80,13 +80,14 @@ public final class DashMediaPeriodTest {
TrackGroupArray expectedTrackGroups = TrackGroupArray expectedTrackGroups =
new TrackGroupArray( new TrackGroupArray(
new TrackGroup( new TrackGroup(
/* id= */ "0", /* id= */ "3000000000",
adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(0).format,
adaptationSets.get(0).representations.get(1).format, adaptationSets.get(0).representations.get(1).format,
adaptationSets.get(2).representations.get(0).format, adaptationSets.get(2).representations.get(0).format,
adaptationSets.get(2).representations.get(1).format, adaptationSets.get(2).representations.get(1).format,
adaptationSets.get(3).representations.get(0).format), adaptationSets.get(3).representations.get(0).format),
new TrackGroup(/* id= */ "3", adaptationSets.get(1).representations.get(0).format)); new TrackGroup(
/* id= */ "3000000003", adaptationSets.get(1).representations.get(0).format));
MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups); MediaPeriodAsserts.assertTrackGroups(dashMediaPeriod, expectedTrackGroups);
} }
...@@ -102,12 +103,12 @@ public final class DashMediaPeriodTest { ...@@ -102,12 +103,12 @@ public final class DashMediaPeriodTest {
TrackGroupArray expectedTrackGroups = TrackGroupArray expectedTrackGroups =
new TrackGroupArray( new TrackGroupArray(
new TrackGroup( new TrackGroup(
/* id= */ "0", /* id= */ "3000000000",
adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(0).format,
adaptationSets.get(0).representations.get(1).format, adaptationSets.get(0).representations.get(1).format,
adaptationSets.get(1).representations.get(0).format), adaptationSets.get(1).representations.get(0).format),
new TrackGroup( new TrackGroup(
/* id= */ "2", /* id= */ "3000000002",
adaptationSets.get(2).representations.get(0).format, adaptationSets.get(2).representations.get(0).format,
adaptationSets.get(2).representations.get(1).format, adaptationSets.get(2).representations.get(1).format,
adaptationSets.get(3).representations.get(0).format)); adaptationSets.get(3).representations.get(0).format));
...@@ -127,7 +128,7 @@ public final class DashMediaPeriodTest { ...@@ -127,7 +128,7 @@ public final class DashMediaPeriodTest {
TrackGroupArray expectedTrackGroups = TrackGroupArray expectedTrackGroups =
new TrackGroupArray( new TrackGroupArray(
new TrackGroup( new TrackGroup(
/* id= */ "0", /* id= */ "3000000000",
adaptationSets.get(0).representations.get(0).format, adaptationSets.get(0).representations.get(0).format,
adaptationSets.get(0).representations.get(1).format, adaptationSets.get(0).representations.get(1).format,
adaptationSets.get(1).representations.get(0).format, adaptationSets.get(1).representations.get(0).format,
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MPD availabilityStartTime="2014-06-19T23:07:42" type="dynamic"> <MPD availabilityStartTime="2014-06-19T23:07:42" type="dynamic">
<Period start="PT7462826.784S" id="0"> <Period start="PT7462826.784S" id="0">
<AdaptationSet id="0" mimeType="video/mp4"> <AdaptationSet id="3000000000" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="http://dashif.org/guidelines/trickmode" schemeIdUri="http://dashif.org/guidelines/trickmode"
value="1"/> value="3000000001"/>
<Representation id="0" bandwidth="0" codecs="avc1.42c01f"/> <Representation id="0" bandwidth="0" codecs="avc1.42c01f"/>
<Representation id="1" bandwidth="1" codecs="avc1.42c01f"/> <Representation id="1" bandwidth="1" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="1" mimeType="video/mp4"> <AdaptationSet id="3000000001" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016"
value="2"/> value="3000000002"/>
<Representation id="11" bandwidth="100" codecs="avc1.42c01f"/> <Representation id="11" bandwidth="100" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="2" mimeType="video/mp4"> <AdaptationSet id="3000000002" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016"
value="1"/> value="3000000001"/>
<Representation id="21" bandwidth="200" codecs="avc1.42c01f"/> <Representation id="21" bandwidth="200" codecs="avc1.42c01f"/>
<Representation id="22" bandwidth="201" codecs="avc1.42c01f"/> <Representation id="22" bandwidth="201" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="3" mimeType="video/mp4"> <AdaptationSet id="3000000003" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="http://dashif.org/guidelines/trickmode" schemeIdUri="http://dashif.org/guidelines/trickmode"
value="2"/> value="3000000002"/>
<Representation id="31" bandwidth="300" codecs="avc1.42c01f"/> <Representation id="31" bandwidth="300" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
</Period> </Period>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MPD availabilityStartTime="2014-06-19T23:07:42" type="dynamic"> <MPD availabilityStartTime="2014-06-19T23:07:42" type="dynamic">
<Period start="PT7462826.784S" id="0"> <Period start="PT7462826.784S" id="0">
<AdaptationSet id="0" mimeType="video/mp4"> <AdaptationSet id="3000000000" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016"
value="1,2"/> value="3000000001,3000000002"/>
<Representation id="1" bandwidth="0" codecs="avc1.42c01f"/> <Representation id="1" bandwidth="0" codecs="avc1.42c01f"/>
<Representation id="2" bandwidth="1" codecs="avc1.42c01f"/> <Representation id="2" bandwidth="1" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="3" mimeType="video/mp4"> <AdaptationSet id="3000000003" mimeType="video/mp4">
<Representation id="31" bandwidth="300" codecs="avc1.42c01f"/> <Representation id="31" bandwidth="300" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="2" mimeType="video/mp4"> <AdaptationSet id="3000000002" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016"
value="0,1"/> value="3000000000,3000000001"/>
<Representation id="21" bandwidth="200" codecs="avc1.42c01f"/> <Representation id="21" bandwidth="200" codecs="avc1.42c01f"/>
<Representation id="21" bandwidth="201" codecs="avc1.42c01f"/> <Representation id="21" bandwidth="201" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="1" mimeType="video/mp4"> <AdaptationSet id="3000000001" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016" schemeIdUri="urn:mpeg:dash:adaptation-set-switching:2016"
value="0,2"/> value="3000000000,3000000002"/>
<Representation id="11" bandwidth="100" codecs="avc1.42c01f"/> <Representation id="11" bandwidth="100" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
</Period> </Period>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<MPD availabilityStartTime="2014-06-19T23:07:42" type="dynamic"> <MPD availabilityStartTime="2014-06-19T23:07:42" type="dynamic">
<Period start="PT7462826.784S" id="0"> <Period start="PT7462826.784S" id="0">
<AdaptationSet id="0" mimeType="video/mp4"> <AdaptationSet id="3000000000" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="http://dashif.org/guidelines/trickmode" schemeIdUri="http://dashif.org/guidelines/trickmode"
value="1"/> value="3000000001"/>
<Representation id="0" bandwidth="0" codecs="avc1.42c01f"/> <Representation id="0" bandwidth="0" codecs="avc1.42c01f"/>
<Representation id="1" bandwidth="1" codecs="avc1.42c01f"/> <Representation id="1" bandwidth="1" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="1" mimeType="video/mp4"> <AdaptationSet id="3000000001" mimeType="video/mp4">
<Representation id="11" bandwidth="100" codecs="avc1.42c01f"/> <Representation id="11" bandwidth="100" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="2" mimeType="video/mp4"> <AdaptationSet id="3000000002" mimeType="video/mp4">
<Representation id="21" bandwidth="200" codecs="avc1.42c01f"/> <Representation id="21" bandwidth="200" codecs="avc1.42c01f"/>
<Representation id="22" bandwidth="201" codecs="avc1.42c01f"/> <Representation id="22" bandwidth="201" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="3" mimeType="video/mp4"> <AdaptationSet id="3000000003" mimeType="video/mp4">
<SupplementalProperty <SupplementalProperty
schemeIdUri="http://dashif.org/guidelines/trickmode" schemeIdUri="http://dashif.org/guidelines/trickmode"
value="2"/> value="3000000002"/>
<Representation id="31" bandwidth="300" codecs="avc1.42c01f"/> <Representation id="31" bandwidth="300" codecs="avc1.42c01f"/>
</AdaptationSet> </AdaptationSet>
</Period> </Period>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
type="static" type="static"
mediaPresentationDuration="PT904S"> mediaPresentationDuration="PT904S">
<Period id="1" duration="PT904S" start="PT0S"> <Period id="1" duration="PT904S" start="PT0S">
<AdaptationSet id="0" mimeType="video/mp4" contentType="video" segmentAlignment="true" startWithSAP="1"> <AdaptationSet id="3000000000" mimeType="video/mp4" contentType="video" segmentAlignment="true" startWithSAP="1">
<Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/> <Role schemeIdUri="urn:mpeg:dash:role:2011" value="main"/>
<SegmentTemplate presentationTimeOffset="0" media="video_$Time$_$Bandwidth$.m4s" timescale="1000" > <SegmentTemplate presentationTimeOffset="0" media="video_$Time$_$Bandwidth$.m4s" timescale="1000" >
<SegmentTimeline> <SegmentTimeline>
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<Representation id="3" codecs="avc1.42c00c" width="400" height="224" frameRate="25/2" bandwidth="250000"/> <Representation id="3" codecs="avc1.42c00c" width="400" height="224" frameRate="25/2" bandwidth="250000"/>
<Representation id="4" codecs="avc1.42c00b" width="400" height="224" frameRate="5" bandwidth="50000"/> <Representation id="4" codecs="avc1.42c00b" width="400" height="224" frameRate="5" bandwidth="50000"/>
</AdaptationSet> </AdaptationSet>
<AdaptationSet id="1" lang="fr" mimeType="audio/mp4" contentType="audio" codecs="mp4a.40.2" segmentAlignment="true" startWithSAP="1"> <AdaptationSet id="3000000001" lang="fr" mimeType="audio/mp4" contentType="audio" codecs="mp4a.40.2" segmentAlignment="true" startWithSAP="1">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="2"/> <AudioChannelConfiguration schemeIdUri="urn:mpeg:mpegB:cicp:ChannelConfiguration" value="2"/>
<SegmentTemplate presentationTimeOffset="0" media="audio_$Time$_$Bandwidth$.m4s" timescale="1000" > <SegmentTemplate presentationTimeOffset="0" media="audio_$Time$_$Bandwidth$.m4s" timescale="1000" >
<SegmentTimeline> <SegmentTimeline>
......
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