mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Remove contentId from Representation creators/constructor
PiperOrigin-RevId: 223796377
This commit is contained in:
parent
500b1faf14
commit
f196630863
5 changed files with 57 additions and 102 deletions
|
|
@ -671,7 +671,6 @@ public class DashManifestParser extends DefaultHandler
|
||||||
ArrayList<Descriptor> inbandEventStreams = representationInfo.inbandEventStreams;
|
ArrayList<Descriptor> inbandEventStreams = representationInfo.inbandEventStreams;
|
||||||
inbandEventStreams.addAll(extraInbandEventStreams);
|
inbandEventStreams.addAll(extraInbandEventStreams);
|
||||||
return Representation.newInstance(
|
return Representation.newInstance(
|
||||||
/* contentId= */ null,
|
|
||||||
representationInfo.revisionId,
|
representationInfo.revisionId,
|
||||||
format,
|
format,
|
||||||
representationInfo.baseUrl,
|
representationInfo.baseUrl,
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,10 @@ public abstract class Representation {
|
||||||
public static final long REVISION_ID_DEFAULT = -1;
|
public static final long REVISION_ID_DEFAULT = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies the revision of the media contained within the representation. If the content can
|
* Identifies the revision of the media contained within the representation. If the media can
|
||||||
* change over time (e.g. as a result of re-encoding the media with an updated encoder), then this
|
* change over time (e.g. as a result of it being re-encoded), then this identifier can be set to
|
||||||
* identified can be set to uniquely identify the revision of the media. The timestamp at which
|
* uniquely identify the revision of the media. The timestamp at which the media was encoded is
|
||||||
* the media was encoded is often a suitable.
|
* often a suitable.
|
||||||
*/
|
*/
|
||||||
public final long revisionId;
|
public final long revisionId;
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,22 +63,20 @@ public abstract class Representation {
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance.
|
* Constructs a new instance.
|
||||||
*
|
*
|
||||||
* @param contentId Identifies the piece of content to which this representation belongs.
|
|
||||||
* @param revisionId Identifies the revision of the content.
|
* @param revisionId Identifies the revision of the content.
|
||||||
* @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.
|
||||||
* @return The constructed instance.
|
* @return The constructed instance.
|
||||||
*/
|
*/
|
||||||
public static Representation newInstance(String contentId, long revisionId, Format format,
|
public static Representation newInstance(
|
||||||
String baseUrl, SegmentBase segmentBase) {
|
long revisionId, Format format, String baseUrl, SegmentBase segmentBase) {
|
||||||
return newInstance(contentId, revisionId, format, baseUrl, segmentBase, null);
|
return newInstance(revisionId, format, baseUrl, segmentBase, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance.
|
* Constructs a new instance.
|
||||||
*
|
*
|
||||||
* @param contentId Identifies the piece of content to which this representation belongs.
|
|
||||||
* @param revisionId Identifies the revision of the content.
|
* @param revisionId Identifies the revision of the content.
|
||||||
* @param format The format of the representation.
|
* @param format The format of the representation.
|
||||||
* @param baseUrl The base URL.
|
* @param baseUrl The base URL.
|
||||||
|
|
@ -86,31 +84,43 @@ public abstract class Representation {
|
||||||
* @param inbandEventStreams The in-band event streams 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 baseUrl, SegmentBase segmentBase, List<Descriptor> inbandEventStreams) {
|
long revisionId,
|
||||||
return newInstance(contentId, revisionId, format, baseUrl, segmentBase, inbandEventStreams,
|
Format format,
|
||||||
null);
|
String baseUrl,
|
||||||
|
SegmentBase segmentBase,
|
||||||
|
List<Descriptor> inbandEventStreams) {
|
||||||
|
return newInstance(revisionId, format, baseUrl, segmentBase, inbandEventStreams, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new instance.
|
* Constructs a new instance.
|
||||||
*
|
*
|
||||||
* @param contentId Identifies the piece of content to which this representation belongs.
|
|
||||||
* @param revisionId Identifies the revision of the content.
|
* @param revisionId Identifies the revision of the content.
|
||||||
* @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 in-band event streams 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 cacheKey An optional key 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 baseUrl, SegmentBase segmentBase, List<Descriptor> inbandEventStreams,
|
long revisionId,
|
||||||
String customCacheKey) {
|
Format format,
|
||||||
|
String baseUrl,
|
||||||
|
SegmentBase segmentBase,
|
||||||
|
List<Descriptor> inbandEventStreams,
|
||||||
|
String cacheKey) {
|
||||||
if (segmentBase instanceof SingleSegmentBase) {
|
if (segmentBase instanceof SingleSegmentBase) {
|
||||||
return new SingleSegmentRepresentation(contentId, revisionId, format, baseUrl,
|
return new SingleSegmentRepresentation(
|
||||||
(SingleSegmentBase) segmentBase, inbandEventStreams, customCacheKey, C.LENGTH_UNSET);
|
revisionId,
|
||||||
|
format,
|
||||||
|
baseUrl,
|
||||||
|
(SingleSegmentBase) segmentBase,
|
||||||
|
inbandEventStreams,
|
||||||
|
cacheKey,
|
||||||
|
C.LENGTH_UNSET);
|
||||||
} else if (segmentBase instanceof MultiSegmentBase) {
|
} else if (segmentBase instanceof MultiSegmentBase) {
|
||||||
return new MultiSegmentRepresentation(
|
return new MultiSegmentRepresentation(
|
||||||
revisionId, format, baseUrl, (MultiSegmentBase) segmentBase, inbandEventStreams);
|
revisionId, format, baseUrl, (MultiSegmentBase) segmentBase, inbandEventStreams);
|
||||||
|
|
@ -156,10 +166,7 @@ public abstract class Representation {
|
||||||
*/
|
*/
|
||||||
public abstract DashSegmentIndex getIndex();
|
public abstract DashSegmentIndex getIndex();
|
||||||
|
|
||||||
/**
|
/** Returns a cache key for the representation if set, or null. */
|
||||||
* Returns a cache key for the representation if a custom cache key or content id has been
|
|
||||||
* provided and there is only single segment.
|
|
||||||
*/
|
|
||||||
public abstract String getCacheKey();
|
public abstract String getCacheKey();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -182,7 +189,6 @@ public abstract class Representation {
|
||||||
private final SingleSegmentIndex segmentIndex;
|
private final SingleSegmentIndex segmentIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contentId Identifies the piece of content to which this representation belongs.
|
|
||||||
* @param revisionId Identifies the revision of the content.
|
* @param revisionId Identifies the revision of the content.
|
||||||
* @param format The format of the representation.
|
* @param format The format of the representation.
|
||||||
* @param uri The uri of the media.
|
* @param uri The uri of the media.
|
||||||
|
|
@ -191,39 +197,49 @@ public abstract class Representation {
|
||||||
* @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 in-band event streams 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 cacheKey An optional key 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(
|
||||||
Format format, String uri, long initializationStart, long initializationEnd,
|
long revisionId,
|
||||||
long indexStart, long indexEnd, List<Descriptor> inbandEventStreams, String customCacheKey,
|
Format format,
|
||||||
|
String uri,
|
||||||
|
long initializationStart,
|
||||||
|
long initializationEnd,
|
||||||
|
long indexStart,
|
||||||
|
long indexEnd,
|
||||||
|
List<Descriptor> inbandEventStreams,
|
||||||
|
String cacheKey,
|
||||||
long contentLength) {
|
long contentLength) {
|
||||||
RangedUri rangedUri = new RangedUri(null, initializationStart,
|
RangedUri rangedUri = new RangedUri(null, initializationStart,
|
||||||
initializationEnd - initializationStart + 1);
|
initializationEnd - initializationStart + 1);
|
||||||
SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, indexStart,
|
SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, indexStart,
|
||||||
indexEnd - indexStart + 1);
|
indexEnd - indexStart + 1);
|
||||||
return new SingleSegmentRepresentation(contentId, revisionId,
|
return new SingleSegmentRepresentation(
|
||||||
format, uri, segmentBase, inbandEventStreams, customCacheKey, contentLength);
|
revisionId, format, uri, segmentBase, inbandEventStreams, cacheKey, contentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contentId Identifies the piece of content to which this representation belongs.
|
|
||||||
* @param revisionId Identifies the revision of the content.
|
* @param revisionId Identifies the revision of the content.
|
||||||
* @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 in-band event streams 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 cacheKey An optional key 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 baseUrl, SingleSegmentBase segmentBase, List<Descriptor> inbandEventStreams,
|
long revisionId,
|
||||||
String customCacheKey, long contentLength) {
|
Format format,
|
||||||
|
String baseUrl,
|
||||||
|
SingleSegmentBase segmentBase,
|
||||||
|
List<Descriptor> inbandEventStreams,
|
||||||
|
String cacheKey,
|
||||||
|
long contentLength) {
|
||||||
super(revisionId, format, baseUrl, segmentBase, inbandEventStreams);
|
super(revisionId, format, baseUrl, segmentBase, inbandEventStreams);
|
||||||
this.uri = Uri.parse(baseUrl);
|
this.uri = Uri.parse(baseUrl);
|
||||||
this.indexUri = segmentBase.getIndex();
|
this.indexUri = segmentBase.getIndex();
|
||||||
this.cacheKey = customCacheKey != null ? customCacheKey
|
this.cacheKey = cacheKey;
|
||||||
: contentId != null ? contentId + "." + format.id + "." + revisionId : null;
|
|
||||||
this.contentLength = contentLength;
|
this.contentLength = contentLength;
|
||||||
// If we have an index uri then the index is defined externally, and we shouldn't return one
|
// If we have an index uri then the index is defined externally, and we shouldn't return one
|
||||||
// directly. If we don't, then we can't do better than an index defining a single segment.
|
// directly. If we don't, then we can't do better than an index defining a single segment.
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public final class DashUtilTest {
|
||||||
if (drmInitData != null) {
|
if (drmInitData != null) {
|
||||||
format = format.copyWithDrmInitData(drmInitData);
|
format = format.copyWithDrmInitData(drmInitData);
|
||||||
}
|
}
|
||||||
return Representation.newInstance("", 0, format, "", new SingleSegmentBase());
|
return Representation.newInstance(0, format, "", new SingleSegmentBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DrmInitData newDrmInitData() {
|
private static DrmInitData newDrmInitData() {
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,8 @@ public class DashManifestTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Representation newRepresentation() {
|
private static Representation newRepresentation() {
|
||||||
return Representation.newInstance("", 0, DUMMY_FORMAT, "", DUMMY_SEGMENT_BASE);
|
return Representation.newInstance(
|
||||||
|
/* revisionId= */ 0, DUMMY_FORMAT, /* baseUrl= */ "", DUMMY_SEGMENT_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static DashManifest newDashManifest(int duration, Period... periods) {
|
private static DashManifest newDashManifest(int duration, Period... periods) {
|
||||||
|
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2016 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.google.android.exoplayer2.source.dash.manifest;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import com.google.android.exoplayer2.Format;
|
|
||||||
import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase;
|
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
|
|
||||||
/** Unit test for {@link Representation}. */
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class RepresentationTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetCacheKey() {
|
|
||||||
String uri = "http://www.google.com";
|
|
||||||
SegmentBase base = new SingleSegmentBase(new RangedUri(null, 0, 1), 1, 0, 1, 1);
|
|
||||||
Format format = createVideoContainerFormat("0");
|
|
||||||
Representation representation =
|
|
||||||
Representation.newInstance("test_stream_1", 3, format, uri, base);
|
|
||||||
assertThat(representation.getCacheKey()).isEqualTo("test_stream_1.0.3");
|
|
||||||
|
|
||||||
format = createVideoContainerFormat("150");
|
|
||||||
representation =
|
|
||||||
Representation.newInstance(
|
|
||||||
"test_stream_1", Representation.REVISION_ID_DEFAULT, format, uri, base);
|
|
||||||
assertThat(representation.getCacheKey()).isEqualTo("test_stream_1.150.-1");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Format createVideoContainerFormat(String id) {
|
|
||||||
return Format.createVideoContainerFormat(
|
|
||||||
id,
|
|
||||||
"label",
|
|
||||||
/* containerMimeType= */ MimeTypes.APPLICATION_MP4,
|
|
||||||
/* sampleMimeType= */ MimeTypes.VIDEO_H264,
|
|
||||||
/* codecs= */ null,
|
|
||||||
/* bitrate= */ 2500000,
|
|
||||||
/* width= */ 1920,
|
|
||||||
/* height= */ 1080,
|
|
||||||
/* frameRate= */ Format.NO_VALUE,
|
|
||||||
/* initializationData= */ null,
|
|
||||||
/* selectionFlags= */ 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue