Migrate usages from C.TYPE_* to C.CONTENT_TYPE_*

PiperOrigin-RevId: 446156308
This commit is contained in:
ibaker 2022-05-03 11:49:51 +01:00 committed by Ian Baker
parent b410a922fe
commit 9a67b30750
24 changed files with 108 additions and 103 deletions

View File

@ -163,12 +163,12 @@ public final class MainActivity extends Activity {
TextUtils.isEmpty(fileExtension) TextUtils.isEmpty(fileExtension)
? Util.inferContentType(uri) ? Util.inferContentType(uri)
: Util.inferContentTypeForExtension(fileExtension); : Util.inferContentTypeForExtension(fileExtension);
if (type == C.TYPE_DASH) { if (type == C.CONTENT_TYPE_DASH) {
mediaSource = mediaSource =
new DashMediaSource.Factory(dataSourceFactory) new DashMediaSource.Factory(dataSourceFactory)
.setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager) .setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager)
.createMediaSource(MediaItem.fromUri(uri)); .createMediaSource(MediaItem.fromUri(uri));
} else if (type == C.TYPE_OTHER) { } else if (type == C.CONTENT_TYPE_OTHER) {
mediaSource = mediaSource =
new ProgressiveMediaSource.Factory(dataSourceFactory) new ProgressiveMediaSource.Factory(dataSourceFactory)
.setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager) .setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager)

View File

@ -208,12 +208,12 @@ public final class MainActivity extends Activity {
TextUtils.isEmpty(fileExtension) TextUtils.isEmpty(fileExtension)
? Util.inferContentType(uri) ? Util.inferContentType(uri)
: Util.inferContentTypeForExtension(fileExtension); : Util.inferContentTypeForExtension(fileExtension);
if (type == C.TYPE_DASH) { if (type == C.CONTENT_TYPE_DASH) {
mediaSource = mediaSource =
new DashMediaSource.Factory(dataSourceFactory) new DashMediaSource.Factory(dataSourceFactory)
.setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager) .setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager)
.createMediaSource(MediaItem.fromUri(uri)); .createMediaSource(MediaItem.fromUri(uri));
} else if (type == C.TYPE_OTHER) { } else if (type == C.CONTENT_TYPE_OTHER) {
mediaSource = mediaSource =
new ProgressiveMediaSource.Factory(dataSourceFactory) new ProgressiveMediaSource.Factory(dataSourceFactory)
.setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager) .setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager)

View File

@ -1924,18 +1924,18 @@ public final class Util {
public static @ContentType int inferContentType(Uri uri) { public static @ContentType int inferContentType(Uri uri) {
@Nullable String scheme = uri.getScheme(); @Nullable String scheme = uri.getScheme();
if (scheme != null && Ascii.equalsIgnoreCase("rtsp", scheme)) { if (scheme != null && Ascii.equalsIgnoreCase("rtsp", scheme)) {
return C.TYPE_RTSP; return C.CONTENT_TYPE_RTSP;
} }
@Nullable String lastPathSegment = uri.getLastPathSegment(); @Nullable String lastPathSegment = uri.getLastPathSegment();
if (lastPathSegment == null) { if (lastPathSegment == null) {
return C.TYPE_OTHER; return C.CONTENT_TYPE_OTHER;
} }
int lastDotIndex = lastPathSegment.lastIndexOf('.'); int lastDotIndex = lastPathSegment.lastIndexOf('.');
if (lastDotIndex >= 0) { if (lastDotIndex >= 0) {
@C.ContentType @C.ContentType
int contentType = inferContentTypeForExtension(lastPathSegment.substring(lastDotIndex + 1)); int contentType = inferContentTypeForExtension(lastPathSegment.substring(lastDotIndex + 1));
if (contentType != C.TYPE_OTHER) { if (contentType != C.CONTENT_TYPE_OTHER) {
// If contentType is TYPE_SS that indicates the extension is .ism or .isml and shows the ISM // If contentType is TYPE_SS that indicates the extension is .ism or .isml and shows the ISM
// URI is missing the "/manifest" suffix, which contains the information used to // URI is missing the "/manifest" suffix, which contains the information used to
// disambiguate between Smooth Streaming, HLS and DASH below - so we can just return TYPE_SS // disambiguate between Smooth Streaming, HLS and DASH below - so we can just return TYPE_SS
@ -1949,15 +1949,15 @@ public final class Util {
@Nullable String extensions = ismMatcher.group(2); @Nullable String extensions = ismMatcher.group(2);
if (extensions != null) { if (extensions != null) {
if (extensions.contains(ISM_DASH_FORMAT_EXTENSION)) { if (extensions.contains(ISM_DASH_FORMAT_EXTENSION)) {
return C.TYPE_DASH; return C.CONTENT_TYPE_DASH;
} else if (extensions.contains(ISM_HLS_FORMAT_EXTENSION)) { } else if (extensions.contains(ISM_HLS_FORMAT_EXTENSION)) {
return C.TYPE_HLS; return C.CONTENT_TYPE_HLS;
} }
} }
return C.TYPE_SS; return C.CONTENT_TYPE_SS;
} }
return C.TYPE_OTHER; return C.CONTENT_TYPE_OTHER;
} }
/** /**
@ -1980,14 +1980,14 @@ public final class Util {
fileExtension = Ascii.toLowerCase(fileExtension); fileExtension = Ascii.toLowerCase(fileExtension);
switch (fileExtension) { switch (fileExtension) {
case "mpd": case "mpd":
return C.TYPE_DASH; return C.CONTENT_TYPE_DASH;
case "m3u8": case "m3u8":
return C.TYPE_HLS; return C.CONTENT_TYPE_HLS;
case "ism": case "ism":
case "isml": case "isml":
return C.TYPE_SS; return C.TYPE_SS;
default: default:
return C.TYPE_OTHER; return C.CONTENT_TYPE_OTHER;
} }
} }
@ -2005,15 +2005,15 @@ public final class Util {
} }
switch (mimeType) { switch (mimeType) {
case MimeTypes.APPLICATION_MPD: case MimeTypes.APPLICATION_MPD:
return C.TYPE_DASH; return C.CONTENT_TYPE_DASH;
case MimeTypes.APPLICATION_M3U8: case MimeTypes.APPLICATION_M3U8:
return C.TYPE_HLS; return C.CONTENT_TYPE_HLS;
case MimeTypes.APPLICATION_SS: case MimeTypes.APPLICATION_SS:
return C.TYPE_SS; return C.CONTENT_TYPE_SS;
case MimeTypes.APPLICATION_RTSP: case MimeTypes.APPLICATION_RTSP:
return C.TYPE_RTSP; return C.CONTENT_TYPE_RTSP;
default: default:
return C.TYPE_OTHER; return C.CONTENT_TYPE_OTHER;
} }
} }
@ -2024,14 +2024,14 @@ public final class Util {
@Nullable @Nullable
public static String getAdaptiveMimeTypeForContentType(@ContentType int contentType) { public static String getAdaptiveMimeTypeForContentType(@ContentType int contentType) {
switch (contentType) { switch (contentType) {
case C.TYPE_DASH: case C.CONTENT_TYPE_DASH:
return MimeTypes.APPLICATION_MPD; return MimeTypes.APPLICATION_MPD;
case C.TYPE_HLS: case C.CONTENT_TYPE_HLS:
return MimeTypes.APPLICATION_M3U8; return MimeTypes.APPLICATION_M3U8;
case C.TYPE_SS: case C.CONTENT_TYPE_SS:
return MimeTypes.APPLICATION_SS; return MimeTypes.APPLICATION_SS;
case C.TYPE_RTSP: case C.CONTENT_TYPE_RTSP:
case C.TYPE_OTHER: case C.CONTENT_TYPE_OTHER:
default: default:
return null; return null;
} }

View File

@ -104,65 +104,67 @@ public class UtilTest {
@Test @Test
public void inferContentType_handlesHlsIsmUris() { public void inferContentType_handlesHlsIsmUris() {
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl)"))) assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl)")))
.isEqualTo(C.TYPE_HLS); .isEqualTo(C.CONTENT_TYPE_HLS);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl,quality=hd)"))) Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl,quality=hd)")))
.isEqualTo(C.TYPE_HLS); .isEqualTo(C.CONTENT_TYPE_HLS);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("http://a.b/c.ism/manifest(quality=hd,format=m3u8-aapl)"))) Uri.parse("http://a.b/c.ism/manifest(quality=hd,format=m3u8-aapl)")))
.isEqualTo(C.TYPE_HLS); .isEqualTo(C.CONTENT_TYPE_HLS);
} }
@Test @Test
public void inferContentType_handlesHlsIsmV3Uris() { public void inferContentType_handlesHlsIsmV3Uris() {
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl-v3)"))) assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl-v3)")))
.isEqualTo(C.TYPE_HLS); .isEqualTo(C.CONTENT_TYPE_HLS);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl-v3,quality=hd)"))) Uri.parse("http://a.b/c.ism/manifest(format=m3u8-aapl-v3,quality=hd)")))
.isEqualTo(C.TYPE_HLS); .isEqualTo(C.CONTENT_TYPE_HLS);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("http://a.b/c.ism/manifest(quality=hd,format=m3u8-aapl-v3)"))) Uri.parse("http://a.b/c.ism/manifest(quality=hd,format=m3u8-aapl-v3)")))
.isEqualTo(C.TYPE_HLS); .isEqualTo(C.CONTENT_TYPE_HLS);
} }
@Test @Test
public void inferContentType_handlesDashIsmUris() { public void inferContentType_handlesDashIsmUris() {
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest(format=mpd-time-csf)"))) assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest(format=mpd-time-csf)")))
.isEqualTo(C.TYPE_DASH); .isEqualTo(C.CONTENT_TYPE_DASH);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("http://a.b/c.isml/manifest(format=mpd-time-csf,quality=hd)"))) Uri.parse("http://a.b/c.isml/manifest(format=mpd-time-csf,quality=hd)")))
.isEqualTo(C.TYPE_DASH); .isEqualTo(C.CONTENT_TYPE_DASH);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("http://a.b/c.isml/manifest(quality=hd,format=mpd-time-csf)"))) Uri.parse("http://a.b/c.isml/manifest(quality=hd,format=mpd-time-csf)")))
.isEqualTo(C.TYPE_DASH); .isEqualTo(C.CONTENT_TYPE_DASH);
} }
@Test @Test
public void inferContentType_handlesSmoothStreamingIsmUris() { public void inferContentType_handlesSmoothStreamingIsmUris() {
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism"))).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism"))).isEqualTo(C.CONTENT_TYPE_SS);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml"))).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml"))).isEqualTo(C.CONTENT_TYPE_SS);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/"))).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/"))).isEqualTo(C.CONTENT_TYPE_SS);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/"))).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/"))).isEqualTo(C.CONTENT_TYPE_SS);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/Manifest"))).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/Manifest")))
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest"))).isEqualTo(C.TYPE_SS); .isEqualTo(C.CONTENT_TYPE_SS);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest")))
.isEqualTo(C.CONTENT_TYPE_SS);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest(filter=x)"))) assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest(filter=x)")))
.isEqualTo(C.TYPE_SS); .isEqualTo(C.CONTENT_TYPE_SS);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest_hd"))) assertThat(Util.inferContentType(Uri.parse("http://a.b/c.isml/manifest_hd")))
.isEqualTo(C.TYPE_SS); .isEqualTo(C.CONTENT_TYPE_SS);
} }
@Test @Test
public void inferContentType_handlesOtherIsmUris() { public void inferContentType_handlesOtherIsmUris() {
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/video.mp4"))) assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/video.mp4")))
.isEqualTo(C.TYPE_OTHER); .isEqualTo(C.CONTENT_TYPE_OTHER);
assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/prefix-manifest"))) assertThat(Util.inferContentType(Uri.parse("http://a.b/c.ism/prefix-manifest")))
.isEqualTo(C.TYPE_OTHER); .isEqualTo(C.CONTENT_TYPE_OTHER);
} }
/** /**
@ -172,11 +174,11 @@ public class UtilTest {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Test @Test
public void inferContentType_extensionAsPath() { public void inferContentType_extensionAsPath() {
assertThat(Util.inferContentType(".m3u8")).isEqualTo(C.TYPE_HLS); assertThat(Util.inferContentType(".m3u8")).isEqualTo(C.CONTENT_TYPE_HLS);
assertThat(Util.inferContentType(".mpd")).isEqualTo(C.TYPE_DASH); assertThat(Util.inferContentType(".mpd")).isEqualTo(C.CONTENT_TYPE_DASH);
assertThat(Util.inferContentType(".ism")).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentType(".ism")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentType(".isml")).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentType(".isml")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentType(".mp4")).isEqualTo(C.TYPE_OTHER); assertThat(Util.inferContentType(".mp4")).isEqualTo(C.CONTENT_TYPE_OTHER);
} }
// Testing deprecated method. // Testing deprecated method.
@ -186,24 +188,24 @@ public class UtilTest {
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("file:///path/to/something.mpd"), /* overrideExtension= */ null)) Uri.parse("file:///path/to/something.mpd"), /* overrideExtension= */ null))
.isEqualTo(C.TYPE_DASH); .isEqualTo(C.CONTENT_TYPE_DASH);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("file:///path/to/something.mpd"), /* overrideExtension= */ "")) Uri.parse("file:///path/to/something.mpd"), /* overrideExtension= */ ""))
.isEqualTo(C.TYPE_DASH); .isEqualTo(C.CONTENT_TYPE_DASH);
assertThat( assertThat(
Util.inferContentType( Util.inferContentType(
Uri.parse("file:///path/to/something.mpd"), /* overrideExtension= */ "m3u8")) Uri.parse("file:///path/to/something.mpd"), /* overrideExtension= */ "m3u8"))
.isEqualTo(C.TYPE_HLS); .isEqualTo(C.CONTENT_TYPE_HLS);
} }
@Test @Test
public void inferContentTypeForExtension() { public void inferContentTypeForExtension() {
assertThat(Util.inferContentTypeForExtension("m3u8")).isEqualTo(C.TYPE_HLS); assertThat(Util.inferContentTypeForExtension("m3u8")).isEqualTo(C.CONTENT_TYPE_HLS);
assertThat(Util.inferContentTypeForExtension("mpd")).isEqualTo(C.TYPE_DASH); assertThat(Util.inferContentTypeForExtension("mpd")).isEqualTo(C.CONTENT_TYPE_DASH);
assertThat(Util.inferContentTypeForExtension("ism")).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentTypeForExtension("ism")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentTypeForExtension("isml")).isEqualTo(C.TYPE_SS); assertThat(Util.inferContentTypeForExtension("isml")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentTypeForExtension("mp4")).isEqualTo(C.TYPE_OTHER); assertThat(Util.inferContentTypeForExtension("mp4")).isEqualTo(C.CONTENT_TYPE_OTHER);
} }
@Test @Test

View File

@ -679,13 +679,13 @@ public final class MediaMetricsListener
Util.inferContentTypeForUriAndMimeType( Util.inferContentTypeForUriAndMimeType(
mediaItem.localConfiguration.uri, mediaItem.localConfiguration.mimeType); mediaItem.localConfiguration.uri, mediaItem.localConfiguration.mimeType);
switch (contentType) { switch (contentType) {
case C.TYPE_HLS: case C.CONTENT_TYPE_HLS:
return PlaybackMetrics.STREAM_TYPE_HLS; return PlaybackMetrics.STREAM_TYPE_HLS;
case C.TYPE_DASH: case C.CONTENT_TYPE_DASH:
return PlaybackMetrics.STREAM_TYPE_DASH; return PlaybackMetrics.STREAM_TYPE_DASH;
case C.TYPE_SS: case C.CONTENT_TYPE_SS:
return PlaybackMetrics.STREAM_TYPE_SS; return PlaybackMetrics.STREAM_TYPE_SS;
case C.TYPE_RTSP: case C.CONTENT_TYPE_RTSP:
default: default:
return PlaybackMetrics.STREAM_TYPE_OTHER; return PlaybackMetrics.STREAM_TYPE_OTHER;
} }

View File

@ -73,11 +73,11 @@ public class DefaultDownloaderFactory implements DownloaderFactory {
@C.ContentType @C.ContentType
int contentType = Util.inferContentTypeForUriAndMimeType(request.uri, request.mimeType); int contentType = Util.inferContentTypeForUriAndMimeType(request.uri, request.mimeType);
switch (contentType) { switch (contentType) {
case C.TYPE_DASH: case C.CONTENT_TYPE_DASH:
case C.TYPE_HLS: case C.CONTENT_TYPE_HLS:
case C.TYPE_SS: case C.CONTENT_TYPE_SS:
return createDownloader(request, contentType); return createDownloader(request, contentType);
case C.TYPE_OTHER: case C.CONTENT_TYPE_OTHER:
return new ProgressiveDownloader( return new ProgressiveDownloader(
new MediaItem.Builder() new MediaItem.Builder()
.setUri(request.uri) .setUri(request.uri)
@ -113,7 +113,7 @@ public class DefaultDownloaderFactory implements DownloaderFactory {
SparseArray<Constructor<? extends Downloader>> array = new SparseArray<>(); SparseArray<Constructor<? extends Downloader>> array = new SparseArray<>();
try { try {
array.put( array.put(
C.TYPE_DASH, C.CONTENT_TYPE_DASH,
getDownloaderConstructor( getDownloaderConstructor(
Class.forName("androidx.media3.exoplayer.dash.offline.DashDownloader"))); Class.forName("androidx.media3.exoplayer.dash.offline.DashDownloader")));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
@ -122,7 +122,7 @@ public class DefaultDownloaderFactory implements DownloaderFactory {
try { try {
array.put( array.put(
C.TYPE_HLS, C.CONTENT_TYPE_HLS,
getDownloaderConstructor( getDownloaderConstructor(
Class.forName("androidx.media3.exoplayer.hls.offline.HlsDownloader"))); Class.forName("androidx.media3.exoplayer.hls.offline.HlsDownloader")));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
@ -130,7 +130,7 @@ public class DefaultDownloaderFactory implements DownloaderFactory {
} }
try { try {
array.put( array.put(
C.TYPE_SS, C.CONTENT_TYPE_SS,
getDownloaderConstructor( getDownloaderConstructor(
Class.forName("androidx.media3.exoplayer.smoothstreaming.offline.SsDownloader"))); Class.forName("androidx.media3.exoplayer.smoothstreaming.offline.SsDownloader")));
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {

View File

@ -960,7 +960,7 @@ public final class DownloadHelper {
private static boolean isProgressive(MediaItem.LocalConfiguration localConfiguration) { private static boolean isProgressive(MediaItem.LocalConfiguration localConfiguration) {
return Util.inferContentTypeForUriAndMimeType( return Util.inferContentTypeForUriAndMimeType(
localConfiguration.uri, localConfiguration.mimeType) localConfiguration.uri, localConfiguration.mimeType)
== C.TYPE_OTHER; == C.CONTENT_TYPE_OTHER;
} }
private static final class MediaPreparer private static final class MediaPreparer

View File

@ -138,7 +138,9 @@ public final class DownloadRequest implements Parcelable {
@Nullable String customCacheKey, @Nullable String customCacheKey,
@Nullable byte[] data) { @Nullable byte[] data) {
@C.ContentType int contentType = Util.inferContentTypeForUriAndMimeType(uri, mimeType); @C.ContentType int contentType = Util.inferContentTypeForUriAndMimeType(uri, mimeType);
if (contentType == C.TYPE_DASH || contentType == C.TYPE_HLS || contentType == C.TYPE_SS) { if (contentType == C.CONTENT_TYPE_DASH
|| contentType == C.CONTENT_TYPE_HLS
|| contentType == C.CONTENT_TYPE_SS) {
Assertions.checkArgument( Assertions.checkArgument(
customCacheKey == null, "customCacheKey must be null for type: " + contentType); customCacheKey == null, "customCacheKey must be null for type: " + contentType);
} }

View File

@ -519,11 +519,11 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
} }
private void ensureAllSuppliersAreLoaded() { private void ensureAllSuppliersAreLoaded() {
maybeLoadSupplier(C.TYPE_DASH); maybeLoadSupplier(C.CONTENT_TYPE_DASH);
maybeLoadSupplier(C.TYPE_SS); maybeLoadSupplier(C.CONTENT_TYPE_SS);
maybeLoadSupplier(C.TYPE_HLS); maybeLoadSupplier(C.CONTENT_TYPE_HLS);
maybeLoadSupplier(C.TYPE_RTSP); maybeLoadSupplier(C.CONTENT_TYPE_RTSP);
maybeLoadSupplier(C.TYPE_OTHER); maybeLoadSupplier(C.CONTENT_TYPE_OTHER);
} }
@Nullable @Nullable
@ -536,31 +536,31 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
try { try {
Class<? extends MediaSource.Factory> clazz; Class<? extends MediaSource.Factory> clazz;
switch (contentType) { switch (contentType) {
case C.TYPE_DASH: case C.CONTENT_TYPE_DASH:
clazz = clazz =
Class.forName("androidx.media3.exoplayer.dash.DashMediaSource$Factory") Class.forName("androidx.media3.exoplayer.dash.DashMediaSource$Factory")
.asSubclass(MediaSource.Factory.class); .asSubclass(MediaSource.Factory.class);
mediaSourceFactorySupplier = () -> newInstance(clazz, dataSourceFactory); mediaSourceFactorySupplier = () -> newInstance(clazz, dataSourceFactory);
break; break;
case C.TYPE_SS: case C.CONTENT_TYPE_SS:
clazz = clazz =
Class.forName("androidx.media3.exoplayer.smoothstreaming.SsMediaSource$Factory") Class.forName("androidx.media3.exoplayer.smoothstreaming.SsMediaSource$Factory")
.asSubclass(MediaSource.Factory.class); .asSubclass(MediaSource.Factory.class);
mediaSourceFactorySupplier = () -> newInstance(clazz, dataSourceFactory); mediaSourceFactorySupplier = () -> newInstance(clazz, dataSourceFactory);
break; break;
case C.TYPE_HLS: case C.CONTENT_TYPE_HLS:
clazz = clazz =
Class.forName("androidx.media3.exoplayer.hls.HlsMediaSource$Factory") Class.forName("androidx.media3.exoplayer.hls.HlsMediaSource$Factory")
.asSubclass(MediaSource.Factory.class); .asSubclass(MediaSource.Factory.class);
mediaSourceFactorySupplier = () -> newInstance(clazz, dataSourceFactory); mediaSourceFactorySupplier = () -> newInstance(clazz, dataSourceFactory);
break; break;
case C.TYPE_RTSP: case C.CONTENT_TYPE_RTSP:
clazz = clazz =
Class.forName("androidx.media3.exoplayer.rtsp.RtspMediaSource$Factory") Class.forName("androidx.media3.exoplayer.rtsp.RtspMediaSource$Factory")
.asSubclass(MediaSource.Factory.class); .asSubclass(MediaSource.Factory.class);
mediaSourceFactorySupplier = () -> newInstance(clazz); mediaSourceFactorySupplier = () -> newInstance(clazz);
break; break;
case C.TYPE_OTHER: case C.CONTENT_TYPE_OTHER:
mediaSourceFactorySupplier = mediaSourceFactorySupplier =
() -> new ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory); () -> new ProgressiveMediaSource.Factory(dataSourceFactory, extractorsFactory);
break; break;

View File

@ -198,7 +198,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
@Override @Override
public int[] getSupportedTypes() { public int[] getSupportedTypes() {
return new int[] {C.TYPE_OTHER}; return new int[] {C.CONTENT_TYPE_OTHER};
} }
} }

View File

@ -124,7 +124,8 @@ public interface AdsLoader {
* be ignored. Called on the main thread by {@link AdsMediaSource}. * be ignored. Called on the main thread by {@link AdsMediaSource}.
* *
* @param contentTypes The supported content types for ad media. Each element must be one of * @param contentTypes The supported content types for ad media. Each element must be one of
* {@link C#TYPE_DASH}, {@link C#TYPE_HLS}, {@link C#TYPE_SS} and {@link C#TYPE_OTHER}. * {@link C#CONTENT_TYPE_DASH}, {@link C#CONTENT_TYPE_HLS}, {@link C#CONTENT_TYPE_SS} and
* {@link C#CONTENT_TYPE_OTHER}.
*/ */
@UnstableApi @UnstableApi
void setSupportedContentTypes(@C.ContentType int... contentTypes); void setSupportedContentTypes(@C.ContentType int... contentTypes);

View File

@ -188,7 +188,7 @@ public final class DefaultMediaSourceFactoryTest {
new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()) new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext())
.getSupportedTypes(); .getSupportedTypes();
assertThat(supportedTypes).asList().containsExactly(C.TYPE_OTHER); assertThat(supportedTypes).asList().containsExactly(C.CONTENT_TYPE_OTHER);
} }
@Test @Test

View File

@ -292,7 +292,7 @@ public final class DashMediaSource extends BaseMediaSource {
@Override @Override
public int[] getSupportedTypes() { public int[] getSupportedTypes() {
return new int[] {C.TYPE_DASH}; return new int[] {C.CONTENT_TYPE_DASH};
} }
} }

View File

@ -95,6 +95,6 @@ public class DefaultMediaSourceFactoryTest {
new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()) new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext())
.getSupportedTypes(); .getSupportedTypes();
assertThat(supportedTypes).asList().containsExactly(C.TYPE_OTHER, C.TYPE_DASH); assertThat(supportedTypes).asList().containsExactly(C.CONTENT_TYPE_OTHER, C.CONTENT_TYPE_DASH);
} }
} }

View File

@ -331,7 +331,7 @@ public final class HlsMediaSource extends BaseMediaSource
@Override @Override
public int[] getSupportedTypes() { public int[] getSupportedTypes() {
return new int[] {C.TYPE_HLS}; return new int[] {C.CONTENT_TYPE_HLS};
} }
} }

View File

@ -95,6 +95,6 @@ public class DefaultMediaSourceFactoryTest {
new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()) new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext())
.getSupportedTypes(); .getSupportedTypes();
assertThat(supportedTypes).asList().containsExactly(C.TYPE_OTHER, C.TYPE_HLS); assertThat(supportedTypes).asList().containsExactly(C.CONTENT_TYPE_OTHER, C.CONTENT_TYPE_HLS);
} }
} }

View File

@ -525,11 +525,11 @@ public final class ImaAdsLoader implements AdsLoader {
List<String> supportedMimeTypes = new ArrayList<>(); List<String> supportedMimeTypes = new ArrayList<>();
for (@C.ContentType int contentType : contentTypes) { for (@C.ContentType int contentType : contentTypes) {
// IMA does not support Smooth Streaming ad media. // IMA does not support Smooth Streaming ad media.
if (contentType == C.TYPE_DASH) { if (contentType == C.CONTENT_TYPE_DASH) {
supportedMimeTypes.add(MimeTypes.APPLICATION_MPD); supportedMimeTypes.add(MimeTypes.APPLICATION_MPD);
} else if (contentType == C.TYPE_HLS) { } else if (contentType == C.CONTENT_TYPE_HLS) {
supportedMimeTypes.add(MimeTypes.APPLICATION_M3U8); supportedMimeTypes.add(MimeTypes.APPLICATION_M3U8);
} else if (contentType == C.TYPE_OTHER) { } else if (contentType == C.CONTENT_TYPE_OTHER) {
supportedMimeTypes.addAll( supportedMimeTypes.addAll(
Arrays.asList( Arrays.asList(
MimeTypes.VIDEO_MP4, MimeTypes.VIDEO_MP4,

View File

@ -74,7 +74,7 @@ public final class ImaServerSideAdInsertionUriBuilder {
public ImaServerSideAdInsertionUriBuilder() { public ImaServerSideAdInsertionUriBuilder() {
adTagParameters = ImmutableMap.of(); adTagParameters = ImmutableMap.of();
loadVideoTimeoutMs = DEFAULT_LOAD_VIDEO_TIMEOUT_MS; loadVideoTimeoutMs = DEFAULT_LOAD_VIDEO_TIMEOUT_MS;
format = C.TYPE_OTHER; format = C.CONTENT_TYPE_OTHER;
} }
/** /**
@ -143,7 +143,7 @@ public final class ImaServerSideAdInsertionUriBuilder {
* @return This instance, for convenience. * @return This instance, for convenience.
*/ */
public ImaServerSideAdInsertionUriBuilder setFormat(@ContentType int format) { public ImaServerSideAdInsertionUriBuilder setFormat(@ContentType int format) {
checkArgument(format == C.TYPE_DASH || format == C.TYPE_HLS); checkArgument(format == C.CONTENT_TYPE_DASH || format == C.CONTENT_TYPE_HLS);
this.format = format; this.format = format;
return this; return this;
} }
@ -245,7 +245,7 @@ public final class ImaServerSideAdInsertionUriBuilder {
|| (!TextUtils.isEmpty(assetKey) || (!TextUtils.isEmpty(assetKey)
&& TextUtils.isEmpty(contentSourceId) && TextUtils.isEmpty(contentSourceId)
&& TextUtils.isEmpty(videoId))); && TextUtils.isEmpty(videoId)));
checkState(format != C.TYPE_OTHER); checkState(format != C.CONTENT_TYPE_OTHER);
@Nullable String adsId = this.adsId; @Nullable String adsId = this.adsId;
if (adsId == null) { if (adsId == null) {
adsId = assetKey != null ? assetKey : checkNotNull(videoId); adsId = assetKey != null ? assetKey : checkNotNull(videoId);
@ -332,9 +332,9 @@ public final class ImaServerSideAdInsertionUriBuilder {
.createVodStreamRequest(checkNotNull(contentSourceId), checkNotNull(videoId), apiKey); .createVodStreamRequest(checkNotNull(contentSourceId), checkNotNull(videoId), apiKey);
} }
int format = Integer.parseInt(uri.getQueryParameter(FORMAT)); int format = Integer.parseInt(uri.getQueryParameter(FORMAT));
if (format == C.TYPE_DASH) { if (format == C.CONTENT_TYPE_DASH) {
streamRequest.setFormat(StreamFormat.DASH); streamRequest.setFormat(StreamFormat.DASH);
} else if (format == C.TYPE_HLS) { } else if (format == C.CONTENT_TYPE_HLS) {
streamRequest.setFormat(StreamFormat.HLS); streamRequest.setFormat(StreamFormat.HLS);
} else { } else {
throw new IllegalArgumentException("Unsupported stream format:" + format); throw new IllegalArgumentException("Unsupported stream format:" + format);

View File

@ -962,7 +962,7 @@ public final class ImaAdsLoaderTest {
@Test @Test
public void setsDefaultMimeTypes() throws Exception { public void setsDefaultMimeTypes() throws Exception {
imaAdsLoader.setSupportedContentTypes(C.TYPE_DASH, C.TYPE_OTHER); imaAdsLoader.setSupportedContentTypes(C.CONTENT_TYPE_DASH, C.CONTENT_TYPE_OTHER);
imaAdsLoader.start( imaAdsLoader.start(
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
@ -996,7 +996,7 @@ public final class ImaAdsLoaderTest {
adViewProvider); adViewProvider);
when(mockAdsManager.getAdCuePoints()).thenReturn(PREROLL_CUE_POINTS_SECONDS); when(mockAdsManager.getAdCuePoints()).thenReturn(PREROLL_CUE_POINTS_SECONDS);
imaAdsLoader.setSupportedContentTypes(C.TYPE_OTHER); imaAdsLoader.setSupportedContentTypes(C.CONTENT_TYPE_OTHER);
imaAdsLoader.start( imaAdsLoader.start(
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
@ -1257,7 +1257,7 @@ public final class ImaAdsLoaderTest {
adViewProvider); adViewProvider);
when(mockAdsManager.getAdCuePoints()).thenReturn(PREROLL_CUE_POINTS_SECONDS); when(mockAdsManager.getAdCuePoints()).thenReturn(PREROLL_CUE_POINTS_SECONDS);
imaAdsLoader.setSupportedContentTypes(C.TYPE_OTHER); imaAdsLoader.setSupportedContentTypes(C.CONTENT_TYPE_OTHER);
imaAdsLoader.start( imaAdsLoader.start(
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);
@ -1283,7 +1283,7 @@ public final class ImaAdsLoaderTest {
adViewProvider); adViewProvider);
when(mockAdsManager.getAdCuePoints()).thenReturn(PREROLL_CUE_POINTS_SECONDS); when(mockAdsManager.getAdCuePoints()).thenReturn(PREROLL_CUE_POINTS_SECONDS);
imaAdsLoader.setSupportedContentTypes(C.TYPE_OTHER); imaAdsLoader.setSupportedContentTypes(C.CONTENT_TYPE_OTHER);
imaAdsLoader.start( imaAdsLoader.start(
adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener); adsMediaSource, TEST_DATA_SPEC, TEST_ADS_ID, adViewProvider, adsLoaderListener);

View File

@ -60,7 +60,7 @@ public final class ImaServerSideAdInsertionUriBuilderTest {
builder.setContentUrl(CONTENT_URL); builder.setContentUrl(CONTENT_URL);
builder.setAuthToken(AUTH_TOKEN); builder.setAuthToken(AUTH_TOKEN);
builder.setStreamActivityMonitorId(STREAM_ACTIVITY_MONITOR_ID); builder.setStreamActivityMonitorId(STREAM_ACTIVITY_MONITOR_ID);
builder.setFormat(C.TYPE_HLS); builder.setFormat(C.CONTENT_TYPE_HLS);
builder.setAdTagParameters(adTagParameters); builder.setAdTagParameters(adTagParameters);
builder.setLoadVideoTimeoutMs(ADS_LOADER_TIMEOUT_MS); builder.setLoadVideoTimeoutMs(ADS_LOADER_TIMEOUT_MS);
Uri uri = builder.build(); Uri uri = builder.build();
@ -96,7 +96,7 @@ public final class ImaServerSideAdInsertionUriBuilderTest {
builder.setContentUrl(CONTENT_URL); builder.setContentUrl(CONTENT_URL);
builder.setAuthToken(AUTH_TOKEN); builder.setAuthToken(AUTH_TOKEN);
builder.setStreamActivityMonitorId(STREAM_ACTIVITY_MONITOR_ID); builder.setStreamActivityMonitorId(STREAM_ACTIVITY_MONITOR_ID);
builder.setFormat(C.TYPE_DASH); builder.setFormat(C.CONTENT_TYPE_DASH);
builder.setAdTagParameters(adTagParameters); builder.setAdTagParameters(adTagParameters);
builder.setLoadVideoTimeoutMs(ADS_LOADER_TIMEOUT_MS); builder.setLoadVideoTimeoutMs(ADS_LOADER_TIMEOUT_MS);
Uri uri = builder.build(); Uri uri = builder.build();
@ -127,7 +127,7 @@ public final class ImaServerSideAdInsertionUriBuilderTest {
ImaServerSideAdInsertionUriBuilder builder = new ImaServerSideAdInsertionUriBuilder(); ImaServerSideAdInsertionUriBuilder builder = new ImaServerSideAdInsertionUriBuilder();
builder.setContentSourceId(CONTENT_SOURCE_ID); builder.setContentSourceId(CONTENT_SOURCE_ID);
builder.setVideoId(VIDEO_ID); builder.setVideoId(VIDEO_ID);
builder.setFormat(C.TYPE_DASH); builder.setFormat(C.CONTENT_TYPE_DASH);
Uri streamRequest = builder.build(); Uri streamRequest = builder.build();
@ -139,7 +139,7 @@ public final class ImaServerSideAdInsertionUriBuilderTest {
public void build_liveWithNoAdsId_usesAssetKeyAsDefault() { public void build_liveWithNoAdsId_usesAssetKeyAsDefault() {
ImaServerSideAdInsertionUriBuilder builder = new ImaServerSideAdInsertionUriBuilder(); ImaServerSideAdInsertionUriBuilder builder = new ImaServerSideAdInsertionUriBuilder();
builder.setAssetKey(ASSET_KEY); builder.setAssetKey(ASSET_KEY);
builder.setFormat(C.TYPE_DASH); builder.setFormat(C.CONTENT_TYPE_DASH);
Uri streamRequest = builder.build(); Uri streamRequest = builder.build();
@ -177,7 +177,7 @@ public final class ImaServerSideAdInsertionUriBuilderTest {
Uri uri = Uri uri =
new ImaServerSideAdInsertionUriBuilder() new ImaServerSideAdInsertionUriBuilder()
.setAssetKey(ASSET_KEY) .setAssetKey(ASSET_KEY)
.setFormat(C.TYPE_DASH) .setFormat(C.CONTENT_TYPE_DASH)
.build(); .build();
int loadVideoTimeoutMs = ImaServerSideAdInsertionUriBuilder.getLoadVideoTimeoutMs(uri); int loadVideoTimeoutMs = ImaServerSideAdInsertionUriBuilder.getLoadVideoTimeoutMs(uri);

View File

@ -163,7 +163,7 @@ public final class RtspMediaSource extends BaseMediaSource {
@Override @Override
public int[] getSupportedTypes() { public int[] getSupportedTypes() {
return new int[] {C.TYPE_RTSP}; return new int[] {C.CONTENT_TYPE_RTSP};
} }
/** /**

View File

@ -273,7 +273,7 @@ public final class SsMediaSource extends BaseMediaSource
@Override @Override
public int[] getSupportedTypes() { public int[] getSupportedTypes() {
return new int[] {C.TYPE_SS}; return new int[] {C.CONTENT_TYPE_SS};
} }
} }

View File

@ -106,6 +106,6 @@ public class DefaultMediaSourceFactoryTest {
new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext()) new DefaultMediaSourceFactory((Context) ApplicationProvider.getApplicationContext())
.getSupportedTypes(); .getSupportedTypes();
assertThat(supportedTypes).asList().containsExactly(C.TYPE_OTHER, C.TYPE_SS); assertThat(supportedTypes).asList().containsExactly(C.CONTENT_TYPE_OTHER, C.CONTENT_TYPE_SS);
} }
} }

View File

@ -51,7 +51,7 @@ public final class FakeMediaSourceFactory implements MediaSourceFactory {
@Override @Override
public int[] getSupportedTypes() { public int[] getSupportedTypes() {
return new int[] {C.TYPE_OTHER}; return new int[] {C.CONTENT_TYPE_OTHER};
} }
@Override @Override