Remove part of DemoUtil from demo app

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=183056883
This commit is contained in:
olly 2018-01-24 02:11:56 -08:00 committed by Oliver Woodman
parent d240249b6c
commit 5dff21e5de
4 changed files with 36 additions and 38 deletions

View File

@ -16,44 +16,15 @@
package com.google.android.exoplayer2.demo; package com.google.android.exoplayer2.demo;
import android.text.TextUtils; import android.text.TextUtils;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format; 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.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import java.util.Locale; import java.util.Locale;
import java.util.UUID;
/** /**
* Utility methods for demo application. * Utility methods for demo application.
*/ */
/* package */ final class DemoUtil { /* 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. * Builds a track name for display.
* *

View File

@ -275,9 +275,14 @@ public class PlayerActivity extends Activity
try { try {
String drmSchemeExtra = intent.hasExtra(DRM_SCHEME_EXTRA) ? DRM_SCHEME_EXTRA String drmSchemeExtra = intent.hasExtra(DRM_SCHEME_EXTRA) ? DRM_SCHEME_EXTRA
: DRM_SCHEME_UUID_EXTRA; : DRM_SCHEME_UUID_EXTRA;
UUID drmSchemeUuid = DemoUtil.getDrmUuid(intent.getStringExtra(drmSchemeExtra)); UUID drmSchemeUuid = Util.getDrmUuid(intent.getStringExtra(drmSchemeExtra));
drmSessionManager = buildDrmSessionManagerV18(drmSchemeUuid, drmLicenseUrl, if (drmSchemeUuid == null) {
keyRequestPropertiesArray, multiSession); errorStringId = R.string.error_drm_unsupported_scheme;
} else {
drmSessionManager =
buildDrmSessionManagerV18(
drmSchemeUuid, drmLicenseUrl, keyRequestPropertiesArray, multiSession);
}
} catch (UnsupportedDrmException e) { } catch (UnsupportedDrmException e) {
errorStringId = e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME errorStringId = e.reason == UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME
? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown; ? R.string.error_drm_unsupported_scheme : R.string.error_drm_unknown;

View File

@ -33,7 +33,6 @@ import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.exoplayer2.ParserException; 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.DataSource;
import com.google.android.exoplayer2.upstream.DataSourceInputStream; import com.google.android.exoplayer2.upstream.DataSourceInputStream;
import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.DataSpec;
@ -202,11 +201,9 @@ public class SampleChooserActivity extends Activity {
break; break;
case "drm_scheme": case "drm_scheme":
Assertions.checkState(!insidePlaylist, "Invalid attribute on nested item: drm_scheme"); Assertions.checkState(!insidePlaylist, "Invalid attribute on nested item: drm_scheme");
try { String drmScheme = reader.nextString();
drmUuid = DemoUtil.getDrmUuid(reader.nextString()); drmUuid = Util.getDrmUuid(drmScheme);
} catch (UnsupportedDrmException e) { Assertions.checkState(drmUuid != null, "Invalid drm_scheme: " + drmScheme);
throw new ParserException(e);
}
break; break;
case "drm_license_url": case "drm_license_url":
Assertions.checkState(!insidePlaylist, Assertions.checkState(!insidePlaylist,

View File

@ -53,6 +53,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory; 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}. * Makes a best guess to infer the type from a {@link Uri}.
* *