Java 类com.google.android.exoplayer2.drm.DefaultDrmSessionManager 实例源码

项目:ExoPlayer-Offline    文件:DashTest.java   
@Override
protected final DefaultDrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(
    final String userAgent) {
  DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = null;
  if (parameters.isWidevineEncrypted) {
    try {
      MediaDrmCallback drmCallback = new HttpMediaDrmCallback(parameters.widevineLicenseUrl,
          new DefaultHttpDataSourceFactory(userAgent));
      drmSessionManager = DefaultDrmSessionManager.newWidevineInstance(drmCallback, null,
          null, null);
      if (!parameters.useL1Widevine) {
        drmSessionManager.setPropertyString(SECURITY_LEVEL_PROPERTY, WIDEVINE_SECURITY_LEVEL_3);
      }
      if (offlineLicenseKeySetId != null) {
        drmSessionManager.setMode(DefaultDrmSessionManager.MODE_PLAYBACK,
            offlineLicenseKeySetId);
      }
    } catch (UnsupportedDrmException e) {
      throw new IllegalStateException(e);
    }
  }
  return drmSessionManager;
}
项目:no-player    文件:ExoPlayerCreator.java   
@NonNull
public SimpleExoPlayer create(DrmSessionCreator drmSessionCreator,
                              DefaultDrmSessionManager.EventListener drmSessionEventListener,
                              MediaCodecSelector mediaCodecSelector) {
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = drmSessionCreator.create(drmSessionEventListener);
    RenderersFactory renderersFactory = new SimpleRenderersFactory(
            context,
            drmSessionManager,
            EXTENSION_RENDERER_MODE_OFF,
            DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS,
            mediaCodecSelector
    );

    DefaultLoadControl loadControl = new DefaultLoadControl();
    return ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl);
}
项目:ExoMedia    文件:ExoMediaPlayer.java   
/**
 * Generates the {@link DrmSessionManager} to use with the {@link RendererProvider}. This will
 * return null on API's &lt; {@value Build.VERSION_CODES#JELLY_BEAN_MR2}
 *
 * @return The {@link DrmSessionManager} to use or <code>null</code>
 */
@Nullable
protected DrmSessionManager<FrameworkMediaCrypto> generateDrmSessionManager() {
    // DRM is only supported on API 18 + in the ExoPlayer
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return null;
    }

    // Widevine will capture the majority of use cases however playready is supported on all AndroidTV devices
    UUID uuid = C.WIDEVINE_UUID;

    try {
        return new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), new DelegatedMediaDrmCallback(), null, mainHandler, capabilitiesListener);
    } catch (Exception e) {
        Log.d(TAG, "Unable to create a DrmSessionManager due to an exception", e);
        return null;
    }
}
项目:transistor    文件:DashTestRunner.java   
@Override
protected DefaultDrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(
    final String userAgent) {
  if (widevineLicenseUrl == null) {
    return null;
  }
  try {
    MediaDrmCallback drmCallback = new HttpMediaDrmCallback(widevineLicenseUrl,
        new DefaultHttpDataSourceFactory(userAgent));
    DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager =
        DefaultDrmSessionManager.newWidevineInstance(drmCallback, null, null, null);
    if (!useL1Widevine) {
      drmSessionManager.setPropertyString(
          SECURITY_LEVEL_PROPERTY, WIDEVINE_SECURITY_LEVEL_3);
    }
    if (offlineLicenseKeySetId != null) {
      drmSessionManager.setMode(DefaultDrmSessionManager.MODE_PLAYBACK,
          offlineLicenseKeySetId);
    }
    return drmSessionManager;
  } catch (UnsupportedDrmException e) {
    throw new IllegalStateException(e);
  }
}
项目:ExoPlayer-Offline    文件:PlayerActivity.java   
private DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManager(UUID uuid,
                                                                       String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException {
    if (Util.SDK_INT < 18) {
        return null;
    }
    HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl,
            buildHttpDataSourceFactory(false), keyRequestProperties);
    return new DefaultDrmSessionManager<>(uuid,
            FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, eventLogger);
}
项目:no-player    文件:LocalDrmSessionManager.java   
LocalDrmSessionManager(KeySetId keySetIdToRestore,
                       ExoMediaDrm<FrameworkMediaCrypto> mediaDrm,
                       UUID drmScheme,
                       Handler handler,
                       DefaultDrmSessionManager.EventListener eventListener) {
    this.keySetIdToRestore = keySetIdToRestore;
    this.mediaDrm = mediaDrm;
    this.eventListener = eventListener;
    this.drmScheme = drmScheme;
    this.handler = handler;
}
项目:no-player    文件:DownloadDrmSessionCreator.java   
@Override
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener) {
    return new LocalDrmSessionManager(
            downloadedModularDrm.getKeySetId(),
            mediaDrmCreator.create(WIDEVINE_MODULAR_UUID),
            WIDEVINE_MODULAR_UUID,
            handler,
            eventListener
    );
}
项目:no-player    文件:StreamingDrmSessionCreator.java   
@Override
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener) {
    FrameworkMediaDrm frameworkMediaDrm = frameworkMediaDrmCreator.create(WIDEVINE_MODULAR_UUID);

    return new DefaultDrmSessionManager<>(
            WIDEVINE_MODULAR_UUID,
            frameworkMediaDrm,
            mediaDrmCallback,
            NO_OPTIONAL_PARAMETERS,
            handler,
            eventListener
    );
}
项目:transistor    文件:PlayerActivity.java   
private DrmSessionManager<FrameworkMediaCrypto> buildDrmSessionManagerV18(UUID uuid,
    String licenseUrl, String[] keyRequestPropertiesArray, boolean multiSession)
    throws UnsupportedDrmException {
  HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(licenseUrl,
      buildHttpDataSourceFactory(false));
  if (keyRequestPropertiesArray != null) {
    for (int i = 0; i < keyRequestPropertiesArray.length - 1; i += 2) {
      drmCallback.setKeyRequestProperty(keyRequestPropertiesArray[i],
          keyRequestPropertiesArray[i + 1]);
    }
  }
  return new DefaultDrmSessionManager<>(uuid, FrameworkMediaDrm.newInstance(uuid), drmCallback,
      null, mainHandler, eventLogger, multiSession);
}
项目:ExoPlayer-Offline    文件:PlayerActivity.java   
private DrmSessionManager<FrameworkMediaCrypto> buildOfflineDrmSessionManager(UUID uuid,
                                                                              String licenseUrl, Map<String, String> keyRequestProperties) throws UnsupportedDrmException, IOException, DrmSession.DrmSessionException, InterruptedException {
    if (Util.SDK_INT < 18) {
        return null;
    }

    customDrmCallback = new CustomDrmCallback(
            DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()),
            licenseUrl
    );

    DefaultDrmSessionManager<FrameworkMediaCrypto> drmSessionManager = new DefaultDrmSessionManager<>(uuid,
            FrameworkMediaDrm.newInstance(uuid), customDrmCallback, null, mainHandler, eventLogger);

    String offlineAssetKeyIdStr = DemoApplication.getAppInstance().
            getSharedPreferences().getString(DemoApplication.KEY_OFFLINE_OFFSET_ID,DemoApplication.EMPTY);
    byte[] offlineAssetKeyId = Base64.decode(offlineAssetKeyIdStr, Base64.DEFAULT);
    this.offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(customDrmCallback, null);
    Pair<Long, Long> remainingSecPair = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId);
    Log.e(TAG," License remaining Play time : "+remainingSecPair.first+", Purchase time : "+remainingSecPair.second);
    if(DemoApplication.EMPTY.equals(offlineAssetKeyIdStr) || ( remainingSecPair.first == 0 || remainingSecPair.second == 0)) {
        String path = getIntent().getStringExtra(EXTRA_OFFLINE_URI);
        File file = getUriForManifest(path);
        Uri uri = Uri.fromFile(file);
        InputStream is = new FileInputStream(file);
        Log.e(TAG, "will start download now");
        offlineAssetKeyId = offlineLicenseHelper.download(
                DemoApplication.getAppInstance().buildHttpDataSourceFactory(new DefaultBandwidthMeter()).createDataSource(),
                new DashManifestParser().parse(uri, is));
        Pair<Long, Long> p = offlineLicenseHelper.getLicenseDurationRemainingSec(offlineAssetKeyId);
        Log.e(TAG, "download done : " + p.toString());

        SharedPreferences sharedPreferences = DemoApplication.getAppInstance().getSharedPreferences();
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(DemoApplication.KEY_OFFLINE_OFFSET_ID,
                Base64.encodeToString(offlineAssetKeyId, Base64.DEFAULT));
        editor.commit();
    }


    drmSessionManager.setMode(DefaultDrmSessionManager.MODE_QUERY,offlineAssetKeyId);
    return drmSessionManager;
}
项目:no-player    文件:NoDrmSessionCreator.java   
@Nullable
@Override
public DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener) {
    return NO_DRM_SESSION;
}
项目:no-player    文件:DrmSessionCreator.java   
@Nullable
DrmSessionManager<FrameworkMediaCrypto> create(DefaultDrmSessionManager.EventListener eventListener);
项目:no-player    文件:ExoPlayerDrmSessionEventListener.java   
void add(DefaultDrmSessionManager.EventListener listener) {
    listeners.add(listener);
}
项目:no-player    文件:ExoPlayerDrmSessionEventListener.java   
@Override
public void onDrmKeysLoaded() {
    for (DefaultDrmSessionManager.EventListener listener : listeners) {
        listener.onDrmKeysLoaded();
    }
}
项目:no-player    文件:ExoPlayerDrmSessionEventListener.java   
@Override
public void onDrmSessionManagerError(Exception e) {
    for (DefaultDrmSessionManager.EventListener listener : listeners) {
        listener.onDrmSessionManagerError(e);
    }
}
项目:no-player    文件:ExoPlayerDrmSessionEventListener.java   
@Override
public void onDrmKeysRestored() {
    for (DefaultDrmSessionManager.EventListener listener : listeners) {
        listener.onDrmKeysRestored();
    }
}
项目:no-player    文件:ExoPlayerDrmSessionEventListener.java   
@Override
public void onDrmKeysRemoved() {
    for (DefaultDrmSessionManager.EventListener listener : listeners) {
        listener.onDrmKeysRemoved();
    }
}
项目:no-player    文件:ExoPlayerForwarder.java   
public DefaultDrmSessionManager.EventListener drmSessionEventListener() {
    return drmSessionEventListener;
}