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

项目:ExoPlayer-Offline    文件:ExoHostedTest.java   
@Override
public final void onStart(HostActivity host, Surface surface) {
  // Build the player.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
  trackSelector = buildTrackSelector(host, bandwidthMeter);
  String userAgent = "ExoPlayerPlaybackTests";
  DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
  player = buildExoPlayer(host, surface, trackSelector, drmSessionManager);
  player.prepare(buildSource(host, Util.getUserAgent(host, userAgent), bandwidthMeter));
  player.addListener(this);
  player.setAudioDebugListener(this);
  player.setVideoDebugListener(this);
  player.setPlayWhenReady(true);
  actionHandler = new Handler();
  // Schedule any pending actions.
  if (pendingSchedule != null) {
    pendingSchedule.start(player, trackSelector, actionHandler);
    pendingSchedule = null;
  }
}
项目:Exoplayer2Radio    文件:MediaCodecRenderer.java   
/**
 * @param trackType The track type that the renderer handles. One of the {@code C.TRACK_TYPE_*}
 *     constants defined in {@link C}.
 * @param mediaCodecSelector A decoder selector.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 */
public MediaCodecRenderer(int trackType, MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys) {
  super(trackType);
  Assertions.checkState(Util.SDK_INT >= 16);
  this.mediaCodecSelector = Assertions.checkNotNull(mediaCodecSelector);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
  flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
  formatHolder = new FormatHolder();
  decodeOnlyPresentationTimestamps = new ArrayList<>();
  outputBufferInfo = new MediaCodec.BufferInfo();
  codecReconfigurationState = RECONFIGURATION_STATE_NONE;
  codecReinitializationState = REINITIALIZATION_STATE_NONE;
}
项目:Exoplayer2Radio    文件:MediaCodecVideoRenderer.java   
/**
 * @param context A context.
 * @param mediaCodecSelector A decoder selector.
 * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
 *     can attempt to seamlessly join an ongoing playback.
 * @param drmSessionManager For use with encrypted content. May be null if support for encrypted
 *     content is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
 *     invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
 */
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    long allowedJoiningTimeMs, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys, Handler eventHandler,
    VideoRendererEventListener eventListener, int maxDroppedFramesToNotify) {
  super(C.TRACK_TYPE_VIDEO, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys);
  this.allowedJoiningTimeMs = allowedJoiningTimeMs;
  this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
  frameReleaseTimeHelper = new VideoFrameReleaseTimeHelper(context);
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  deviceNeedsAutoFrcWorkaround = deviceNeedsAutoFrcWorkaround();
  joiningDeadlineMs = C.TIME_UNSET;
  currentWidth = Format.NO_VALUE;
  currentHeight = Format.NO_VALUE;
  currentPixelWidthHeightRatio = Format.NO_VALUE;
  pendingPixelWidthHeightRatio = Format.NO_VALUE;
  scalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  clearReportedVideoSize();
}
项目: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);
}
项目:K-Sonic    文件:MediaCodecRenderer.java   
/**
 * @param trackType The track type that the renderer handles. One of the {@code C.TRACK_TYPE_*}
 *     constants defined in {@link C}.
 * @param mediaCodecSelector A decoder selector.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 */
public MediaCodecRenderer(int trackType, MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys) {
  super(trackType);
  Assertions.checkState(Util.SDK_INT >= 16);
  this.mediaCodecSelector = Assertions.checkNotNull(mediaCodecSelector);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
  formatHolder = new FormatHolder();
  decodeOnlyPresentationTimestamps = new ArrayList<>();
  outputBufferInfo = new MediaCodec.BufferInfo();
  codecReconfigurationState = RECONFIGURATION_STATE_NONE;
  codecReinitializationState = REINITIALIZATION_STATE_NONE;
}
项目:K-Sonic    文件:MediaCodecVideoRenderer.java   
/**
 * @param context A context.
 * @param mediaCodecSelector A decoder selector.
 * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
 *     can attempt to seamlessly join an ongoing playback.
 * @param drmSessionManager For use with encrypted content. May be null if support for encrypted
 *     content is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
 *     invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
 */
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    long allowedJoiningTimeMs, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys, Handler eventHandler,
    VideoRendererEventListener eventListener, int maxDroppedFramesToNotify) {
  super(C.TRACK_TYPE_VIDEO, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys);
  this.allowedJoiningTimeMs = allowedJoiningTimeMs;
  this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
  frameReleaseTimeHelper = new VideoFrameReleaseTimeHelper(context);
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  deviceNeedsAutoFrcWorkaround = deviceNeedsAutoFrcWorkaround();
  joiningDeadlineMs = C.TIME_UNSET;
  currentWidth = Format.NO_VALUE;
  currentHeight = Format.NO_VALUE;
  currentPixelWidthHeightRatio = Format.NO_VALUE;
  pendingPixelWidthHeightRatio = Format.NO_VALUE;
  scalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  clearLastReportedVideoSize();
}
项目:videoPickPlayer    文件:MediaCodecRenderer.java   
/**
 * @param trackType The track type that the renderer handles. One of the {@code C.TRACK_TYPE_*}
 *     constants defined in {@link C}.
 * @param mediaCodecSelector A decoder selector.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 */
public MediaCodecRenderer(int trackType, MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys) {
  super(trackType);
  Assertions.checkState(Util.SDK_INT >= 16);
  this.mediaCodecSelector = Assertions.checkNotNull(mediaCodecSelector);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
  formatHolder = new FormatHolder();
  decodeOnlyPresentationTimestamps = new ArrayList<>();
  outputBufferInfo = new MediaCodec.BufferInfo();
  codecReconfigurationState = RECONFIGURATION_STATE_NONE;
  codecReinitializationState = REINITIALIZATION_STATE_NONE;
}
项目:videoPickPlayer    文件:SimpleExoPlayer.java   
private void buildRenderers(Context context,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, ArrayList<Renderer> renderersList,
    long allowedVideoJoiningTimeMs) {
  MediaCodecVideoRenderer videoRenderer = new MediaCodecVideoRenderer(context,
      MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT,
      allowedVideoJoiningTimeMs, drmSessionManager, false, mainHandler, componentListener,
      MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY);
  renderersList.add(videoRenderer);

  Renderer audioRenderer = new MediaCodecAudioRenderer(MediaCodecSelector.DEFAULT,
      drmSessionManager, true, mainHandler, componentListener,
      AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);
  renderersList.add(audioRenderer);

  Renderer textRenderer = new TextRenderer(componentListener, mainHandler.getLooper());
  renderersList.add(textRenderer);

  MetadataRenderer<List<Id3Frame>> id3Renderer = new MetadataRenderer<>(componentListener,
      mainHandler.getLooper(), new Id3Decoder());
  renderersList.add(id3Renderer);
}
项目:videoPickPlayer    文件:MediaCodecVideoRenderer.java   
/**
 * @param context A context.
 * @param mediaCodecSelector A decoder selector.
 * @param videoScalingMode The scaling mode to pass to
 *     {@link MediaCodec#setVideoScalingMode(int)}.
 * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
 *     can attempt to seamlessly join an ongoing playback.
 * @param drmSessionManager For use with encrypted content. May be null if support for encrypted
 *     content is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
 *     invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
 */
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    int videoScalingMode, long allowedJoiningTimeMs,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys, Handler eventHandler,
    VideoRendererEventListener eventListener, int maxDroppedFramesToNotify) {
  super(C.TRACK_TYPE_VIDEO, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys);
  this.videoScalingMode = videoScalingMode;
  this.allowedJoiningTimeMs = allowedJoiningTimeMs;
  this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
  frameReleaseTimeHelper = new VideoFrameReleaseTimeHelper(context);
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  deviceNeedsAutoFrcWorkaround = deviceNeedsAutoFrcWorkaround();
  joiningDeadlineMs = C.TIME_UNSET;
  currentWidth = Format.NO_VALUE;
  currentHeight = Format.NO_VALUE;
  currentPixelWidthHeightRatio = Format.NO_VALUE;
  pendingPixelWidthHeightRatio = Format.NO_VALUE;
  lastReportedWidth = Format.NO_VALUE;
  lastReportedHeight = Format.NO_VALUE;
  lastReportedPixelWidthHeightRatio = Format.NO_VALUE;
}
项目: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    文件:LibvpxVideoRenderer.java   
/**
 * @param scaleToFit Whether video frames should be scaled to fit when rendering.
 * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
 *     can attempt to seamlessly join an ongoing playback.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
 *     invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 */
public LibvpxVideoRenderer(boolean scaleToFit, long allowedJoiningTimeMs,
    Handler eventHandler, VideoRendererEventListener eventListener,
    int maxDroppedFramesToNotify, DrmSessionManager<ExoMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys) {
  super(C.TRACK_TYPE_VIDEO);
  this.scaleToFit = scaleToFit;
  this.allowedJoiningTimeMs = allowedJoiningTimeMs;
  this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  joiningDeadlineMs = C.TIME_UNSET;
  clearReportedVideoSize();
  formatHolder = new FormatHolder();
  flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  outputMode = VpxDecoder.OUTPUT_MODE_NONE;
  decoderReinitializationState = REINITIALIZATION_STATE_NONE;
}
项目:transistor    文件:MediaCodecRenderer.java   
/**
 * @param trackType The track type that the renderer handles. One of the {@code C.TRACK_TYPE_*}
 *     constants defined in {@link C}.
 * @param mediaCodecSelector A decoder selector.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 */
public MediaCodecRenderer(int trackType, MediaCodecSelector mediaCodecSelector,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys) {
  super(trackType);
  Assertions.checkState(Util.SDK_INT >= 16);
  this.mediaCodecSelector = Assertions.checkNotNull(mediaCodecSelector);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
  flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
  formatHolder = new FormatHolder();
  decodeOnlyPresentationTimestamps = new ArrayList<>();
  outputBufferInfo = new MediaCodec.BufferInfo();
  codecReconfigurationState = RECONFIGURATION_STATE_NONE;
  codecReinitializationState = REINITIALIZATION_STATE_NONE;
}
项目:transistor    文件:MediaCodecVideoRenderer.java   
/**
 * @param context A context.
 * @param mediaCodecSelector A decoder selector.
 * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer
 *     can attempt to seamlessly join an ongoing playback.
 * @param drmSessionManager For use with encrypted content. May be null if support for encrypted
 *     content is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param maxDroppedFramesToNotify The maximum number of frames that can be dropped between
 *     invocations of {@link VideoRendererEventListener#onDroppedFrames(int, long)}.
 */
public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    long allowedJoiningTimeMs,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys, @Nullable Handler eventHandler,
    @Nullable VideoRendererEventListener eventListener, int maxDroppedFramesToNotify) {
  super(C.TRACK_TYPE_VIDEO, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys);
  this.allowedJoiningTimeMs = allowedJoiningTimeMs;
  this.maxDroppedFramesToNotify = maxDroppedFramesToNotify;
  this.context = context.getApplicationContext();
  frameReleaseTimeHelper = new VideoFrameReleaseTimeHelper(context);
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  deviceNeedsAutoFrcWorkaround = deviceNeedsAutoFrcWorkaround();
  pendingOutputStreamOffsetsUs = new long[MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT];
  outputStreamOffsetUs = C.TIME_UNSET;
  joiningDeadlineMs = C.TIME_UNSET;
  currentWidth = Format.NO_VALUE;
  currentHeight = Format.NO_VALUE;
  currentPixelWidthHeightRatio = Format.NO_VALUE;
  pendingPixelWidthHeightRatio = Format.NO_VALUE;
  scalingMode = C.VIDEO_SCALING_MODE_DEFAULT;
  clearReportedVideoSize();
}
项目:transistor    文件:SimpleDecoderAudioRendererTest.java   
@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
  audioRenderer = new SimpleDecoderAudioRenderer(null, null, null, false, mockAudioSink) {
    @Override
    protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
        Format format) {
      return FORMAT_HANDLED;
    }

    @Override
    protected SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer,
        ? extends AudioDecoderException> createDecoder(Format format, ExoMediaCrypto mediaCrypto)
        throws AudioDecoderException {
      return new FakeDecoder();
    }
  };
}
项目: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);
}
项目:ExoPlayer-Offline    文件:DebugSimpleExoPlayer.java   
@Override
protected void buildVideoRenderers(Context context, Handler mainHandler,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    @ExtensionRendererMode int extensionRendererMode, VideoRendererEventListener eventListener,
    long allowedVideoJoiningTimeMs, ArrayList<Renderer> out) {
  out.add(new DebugMediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT,
      allowedVideoJoiningTimeMs, mainHandler, drmSessionManager, eventListener,
      MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY));
}
项目:ExoPlayer-Offline    文件:DebugSimpleExoPlayer.java   
public DebugMediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    long allowedJoiningTimeMs, Handler eventHandler,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    VideoRendererEventListener eventListener, int maxDroppedFrameCountToNotify) {
  super(context, mediaCodecSelector, allowedJoiningTimeMs, drmSessionManager, false,
      eventHandler, eventListener, maxDroppedFrameCountToNotify);
}
项目:ExoPlayer-Offline    文件:ExoHostedTest.java   
@SuppressWarnings("unused")
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
    MappingTrackSelector trackSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(host, trackSelector,
      new DefaultLoadControl(), drmSessionManager, SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF,
      0);
  player.setVideoSurface(surface);
  return player;
}
项目:ExoPlayer-Offline    文件:DashTest.java   
@Override
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
    MappingTrackSelector trackSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  SimpleExoPlayer player = new DebugSimpleExoPlayer(host, trackSelector,
      new DefaultLoadControl(), drmSessionManager);
  player.setVideoSurface(surface);
  return player;
}
项目: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
    );
}
项目:no-player    文件:SimpleRenderersFactory.java   
/**
 * @param context                   A {@link Context}.
 * @param drmSessionManager         An optional {@link DrmSessionManager}. May be null if DRM protected
 *                                  playbacks are not required..
 * @param extensionRendererMode     The extension renderer mode, which determines if and how
 *                                  available extension renderers are used. Note that extensions must be included in the
 *                                  application build for them to be considered available.
 * @param allowedVideoJoiningTimeMs The maximum duration for which video renderers can attempt
 *                                  to seamlessly join an ongoing playback.
 * @param mediaCodecSelector        Used for selecting the codec for the video renderer.
 */
SimpleRenderersFactory(Context context,
                       DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
                       @ExtensionRendererMode int extensionRendererMode,
                       long allowedVideoJoiningTimeMs,
                       MediaCodecSelector mediaCodecSelector) {
    this.context = context;
    this.drmSessionManager = drmSessionManager;
    this.extensionRendererMode = extensionRendererMode;
    this.allowedVideoJoiningTimeMs = allowedVideoJoiningTimeMs;
    this.mediaCodecSelector = mediaCodecSelector;
}
项目:K-Sonic    文件:SonicMediaCodecAudioRenderer.java   
public SonicMediaCodecAudioRenderer(MediaCodecSelector mediaCodecSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys, Handler eventHandler,
    AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities,
    AudioProcessor... audioProcessors) {
  super(mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys, eventHandler, eventListener, audioCapabilities, audioProcessors);
  //Init
  bufferIndex = -1;
  speed = 1.0f;
  pitch = 1.0f;
  rate = 1.0f;
}
项目:K-Sonic    文件:SimpleExoPlayer.java   
protected SimpleExoPlayer(Context context, TrackSelector trackSelector, LoadControl loadControl,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    @ExtensionRendererMode int extensionRendererMode, long allowedVideoJoiningTimeMs) {
  mainHandler = new Handler();
  componentListener = new ComponentListener();

  // Build the renderers.
  ArrayList<Renderer> renderersList = new ArrayList<>();
  buildRenderers(context, mainHandler, drmSessionManager, extensionRendererMode,
      allowedVideoJoiningTimeMs, renderersList);
  renderers = renderersList.toArray(new Renderer[renderersList.size()]);

  // Obtain counts of video and audio renderers.
  int videoRendererCount = 0;
  int audioRendererCount = 0;
  for (Renderer renderer : renderers) {
    switch (renderer.getTrackType()) {
      case C.TRACK_TYPE_VIDEO:
        videoRendererCount++;
        break;
      case C.TRACK_TYPE_AUDIO:
        audioRendererCount++;
        break;
    }
  }
  this.videoRendererCount = videoRendererCount;
  this.audioRendererCount = audioRendererCount;

  // Set initial values.
  audioVolume = 1;
  audioSessionId = C.AUDIO_SESSION_ID_UNSET;
  audioStreamType = C.STREAM_TYPE_DEFAULT;
  videoScalingMode = C.VIDEO_SCALING_MODE_DEFAULT;

  // Build the player and associated objects.
  player = new ExoPlayerImpl(renderers, trackSelector, loadControl);
}
项目:K-Sonic    文件:SimpleExoPlayer.java   
private void buildRenderers(Context context, Handler mainHandler,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    @ExtensionRendererMode int extensionRendererMode, long allowedVideoJoiningTimeMs,
    ArrayList<Renderer> out) {
  buildVideoRenderers(context, mainHandler, drmSessionManager, extensionRendererMode,
      componentListener, allowedVideoJoiningTimeMs, out);
  buildAudioRenderers(context, mainHandler, drmSessionManager, extensionRendererMode,
      componentListener, buildAudioProcessors(), out);
  buildTextRenderers(context, mainHandler, extensionRendererMode, componentListener, out);
  buildMetadataRenderers(context, mainHandler, extensionRendererMode, componentListener, out);
  buildMiscellaneousRenderers(context, mainHandler, extensionRendererMode, out);
}
项目:MDVideo    文件:PlayerActivityV2.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 StreamingDrmSessionManager<>(uuid,
            FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, eventLogger);
}
项目:Komica    文件: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 StreamingDrmSessionManager<>(uuid,
      FrameworkMediaDrm.newInstance(uuid), drmCallback, null, mainHandler, eventLogger);
}
项目: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);
}
项目:transistor    文件:DashTestRunner.java   
@Override
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
    MappingTrackSelector trackSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(
      new DebugRenderersFactory(host, drmSessionManager), trackSelector);
  player.setVideoSurface(surface);
  return player;
}
项目:transistor    文件:LibopusAudioRenderer.java   
@Override
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
    Format format) {
  if (!OpusLibrary.isAvailable()
      || !MimeTypes.AUDIO_OPUS.equalsIgnoreCase(format.sampleMimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  } else if (!supportsOutputEncoding(C.ENCODING_PCM_16BIT)) {
    return FORMAT_UNSUPPORTED_SUBTYPE;
  } else if (!supportsFormatDrm(drmSessionManager, format.drmInitData)) {
    return FORMAT_UNSUPPORTED_DRM;
  } else {
    return FORMAT_HANDLED;
  }
}
项目:transistor    文件:LibflacAudioRenderer.java   
@Override
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
    Format format) {
  if (!FlacLibrary.isAvailable()
      || !MimeTypes.AUDIO_FLAC.equalsIgnoreCase(format.sampleMimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  } else if (!supportsOutputEncoding(C.ENCODING_PCM_16BIT)) {
    return FORMAT_UNSUPPORTED_SUBTYPE;
  } else if (!supportsFormatDrm(drmSessionManager, format.drmInitData)) {
    return FORMAT_UNSUPPORTED_DRM;
  } else {
    return FORMAT_HANDLED;
  }
}
项目:transistor    文件:FfmpegAudioRenderer.java   
@Override
protected int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
    Format format) {
  String sampleMimeType = format.sampleMimeType;
  if (!FfmpegLibrary.isAvailable() || !MimeTypes.isAudio(sampleMimeType)) {
    return FORMAT_UNSUPPORTED_TYPE;
  } else if (!FfmpegLibrary.supportsFormat(sampleMimeType) || !isOutputSupported(format)) {
    return FORMAT_UNSUPPORTED_SUBTYPE;
  } else if (!supportsFormatDrm(drmSessionManager, format.drmInitData)) {
    return FORMAT_UNSUPPORTED_DRM;
  } else {
    return FORMAT_HANDLED;
  }
}
项目:transistor    文件:DebugRenderersFactory.java   
@Override
protected void buildVideoRenderers(Context context,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager, long allowedVideoJoiningTimeMs,
    Handler eventHandler, VideoRendererEventListener eventListener,
    @ExtensionRendererMode int extensionRendererMode, ArrayList<Renderer> out) {
  out.add(new DebugMediaCodecVideoRenderer(context, MediaCodecSelector.DEFAULT,
      allowedVideoJoiningTimeMs, drmSessionManager, eventHandler, eventListener,
      MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY));
}
项目:transistor    文件:DebugRenderersFactory.java   
public DebugMediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector,
    long allowedJoiningTimeMs, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    Handler eventHandler, VideoRendererEventListener eventListener,
    int maxDroppedFrameCountToNotify) {
  super(context, mediaCodecSelector, allowedJoiningTimeMs, drmSessionManager, false,
      eventHandler, eventListener, maxDroppedFrameCountToNotify);
}
项目:transistor    文件:ExoHostedTest.java   
@Override
public final void onStart(HostActivity host, Surface surface) {
  this.surface = surface;
  // Build the player.
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
  trackSelector = buildTrackSelector(host, bandwidthMeter);
  String userAgent = "ExoPlayerPlaybackTests";
  DrmSessionManager<FrameworkMediaCrypto> drmSessionManager = buildDrmSessionManager(userAgent);
  player = buildExoPlayer(host, surface, trackSelector, drmSessionManager);
  player.prepare(buildSource(host, Util.getUserAgent(host, userAgent), bandwidthMeter));
  if (playerEventListener != null) {
    player.addListener(playerEventListener);
  }
  if (videoDebugListener != null) {
    player.addVideoDebugListener(videoDebugListener);
  }
  if (audioDebugListener != null) {
    player.addAudioDebugListener(audioDebugListener);
  }
  player.addListener(this);
  player.addAudioDebugListener(this);
  player.addVideoDebugListener(this);
  player.setPlayWhenReady(true);
  actionHandler = new Handler();
  // Schedule any pending actions.
  if (pendingSchedule != null) {
    pendingSchedule.start(player, trackSelector, surface, actionHandler);
    pendingSchedule = null;
  }
}
项目:transistor    文件:ExoHostedTest.java   
@SuppressWarnings("unused")
protected SimpleExoPlayer buildExoPlayer(HostActivity host, Surface surface,
    MappingTrackSelector trackSelector,
    DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  RenderersFactory renderersFactory = new DefaultRenderersFactory(host, drmSessionManager,
      DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF, 0);
  SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector);
  player.setVideoSurface(surface);
  return player;
}
项目:transistor    文件:BaseRenderer.java   
/**
 * Returns whether {@code drmSessionManager} supports the specified {@code drmInitData}, or true
 * if {@code drmInitData} is null.
 *
 * @param drmSessionManager The drm session manager.
 * @param drmInitData {@link DrmInitData} of the format to check for support.
 * @return Whether {@code drmSessionManager} supports the specified {@code drmInitData}, or
 *     true if {@code drmInitData} is null.
 */
protected static boolean supportsFormatDrm(@Nullable DrmSessionManager<?> drmSessionManager,
    @Nullable DrmInitData drmInitData) {
  if (drmInitData == null) {
    // Content is unencrypted.
    return true;
  } else if (drmSessionManager == null) {
    // Content is encrypted, but no drm session manager is available.
    return false;
  }
  return drmSessionManager.canAcquireSession(drmInitData);
}
项目:transistor    文件:SimpleDecoderAudioRenderer.java   
/**
 * @param eventHandler A handler to use when delivering events to {@code eventListener}. May be
 *     null if delivery of events is not required.
 * @param eventListener A listener of events. May be null if delivery of events is not required.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param audioSink The sink to which audio will be output.
 */
public SimpleDecoderAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener,
    DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean playClearSamplesWithoutKeys,
    AudioSink audioSink) {
  super(C.TRACK_TYPE_AUDIO);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  this.audioSink = audioSink;
  audioSink.setListener(new AudioSinkListener());
  formatHolder = new FormatHolder();
  flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
  decoderReinitializationState = REINITIALIZATION_STATE_NONE;
  audioTrackNeedsConfigure = true;
}
项目: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;
}
项目:ExoPlayer-Offline    文件:DebugSimpleExoPlayer.java   
public DebugSimpleExoPlayer(Context context, TrackSelector trackSelector,
    LoadControl loadControl, DrmSessionManager<FrameworkMediaCrypto> drmSessionManager) {
  super(context, trackSelector, loadControl, drmSessionManager,
      SimpleExoPlayer.EXTENSION_RENDERER_MODE_OFF, 0);
}