Remove part of DemoUtil from demo app
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=183056883
This commit is contained in:
parent
d240249b6c
commit
5dff21e5de
@ -16,44 +16,15 @@
|
||||
package com.google.android.exoplayer2.demo;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.Format;
|
||||
import com.google.android.exoplayer2.drm.UnsupportedDrmException;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Utility methods for demo application.
|
||||
*/
|
||||
/* package */ final class DemoUtil {
|
||||
|
||||
/**
|
||||
* Derives a DRM {@link UUID} from {@code drmScheme}.
|
||||
*
|
||||
* @param drmScheme A protection scheme UUID string; or {@code "widevine"}, {@code "playready"} or
|
||||
* {@code "clearkey"}.
|
||||
* @return The derived {@link UUID}.
|
||||
* @throws UnsupportedDrmException If no {@link UUID} could be derived from {@code drmScheme}.
|
||||
*/
|
||||
public static UUID getDrmUuid(String drmScheme) throws UnsupportedDrmException {
|
||||
switch (Util.toLowerInvariant(drmScheme)) {
|
||||
case "widevine":
|
||||
return C.WIDEVINE_UUID;
|
||||
case "playready":
|
||||
return C.PLAYREADY_UUID;
|
||||
case "clearkey":
|
||||
return C.CLEARKEY_UUID;
|
||||
default:
|
||||
try {
|
||||
return UUID.fromString(drmScheme);
|
||||
} catch (RuntimeException e) {
|
||||
throw new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a track name for display.
|
||||
*
|
||||
|
@ -275,9 +275,14 @@ public class PlayerActivity extends Activity
|
||||
try {
|
||||
String drmSchemeExtra = intent.hasExtra(DRM_SCHEME_EXTRA) ? DRM_SCHEME_EXTRA
|
||||
: DRM_SCHEME_UUID_EXTRA;
|
||||
UUID drmSchemeUuid = DemoUtil.getDrmUuid(intent.getStringExtra(drmSchemeExtra));
|
||||
drmSessionManager = buildDrmSessionManagerV18(drmSchemeUuid, drmLicenseUrl,
|
||||
keyRequestPropertiesArray, multiSession);
|
||||
UUID drmSchemeUuid = Util.getDrmUuid(intent.getStringExtra(drmSchemeExtra));
|
||||
if (drmSchemeUuid == null) {
|
||||
errorStringId = R.string.error_drm_unsupported_scheme;
|
||||
} else {
|
||||
drmSessionManager =
|
||||
buildDrmSessionManagerV18(
|
||||
drmSchemeUuid, drmLicenseUrl, keyRequestPropertiesArray, multiSession);
|
||||
}
|
||||
} catch (UnsupportedDrmException e) {
|
||||
errorStringId = e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
|
||||
? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown;
|
||||
|
@ -33,7 +33,6 @@ import android.widget.ExpandableListView.OnChildClickListener;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import com.google.android.exoplayer2.ParserException;
|
||||
import com.google.android.exoplayer2.drm.UnsupportedDrmException;
|
||||
import com.google.android.exoplayer2.upstream.DataSource;
|
||||
import com.google.android.exoplayer2.upstream.DataSourceInputStream;
|
||||
import com.google.android.exoplayer2.upstream.DataSpec;
|
||||
@ -202,11 +201,9 @@ public class SampleChooserActivity extends Activity {
|
||||
break;
|
||||
case "drm_scheme":
|
||||
Assertions.checkState(!insidePlaylist, "Invalid attribute on nested item: drm_scheme");
|
||||
try {
|
||||
drmUuid = DemoUtil.getDrmUuid(reader.nextString());
|
||||
} catch (UnsupportedDrmException e) {
|
||||
throw new ParserException(e);
|
||||
}
|
||||
String drmScheme = reader.nextString();
|
||||
drmUuid = Util.getDrmUuid(drmScheme);
|
||||
Assertions.checkState(drmUuid != null, "Invalid drm_scheme: " + drmScheme);
|
||||
break;
|
||||
case "drm_license_url":
|
||||
Assertions.checkState(!insidePlaylist,
|
||||
|
@ -53,6 +53,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
@ -1044,6 +1045,30 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Derives a DRM {@link UUID} from {@code drmScheme}.
|
||||
*
|
||||
* @param drmScheme A UUID string, or {@code "widevine"}, {@code "playready"} or {@code
|
||||
* "clearkey"}.
|
||||
* @return The derived {@link UUID}, or {@code null} if one could not be derived.
|
||||
*/
|
||||
public static UUID getDrmUuid(String drmScheme) {
|
||||
switch (Util.toLowerInvariant(drmScheme)) {
|
||||
case "widevine":
|
||||
return C.WIDEVINE_UUID;
|
||||
case "playready":
|
||||
return C.PLAYREADY_UUID;
|
||||
case "clearkey":
|
||||
return C.CLEARKEY_UUID;
|
||||
default:
|
||||
try {
|
||||
return UUID.fromString(drmScheme);
|
||||
} catch (RuntimeException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a best guess to infer the type from a {@link Uri}.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user