• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ExoMediaCrypto类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.google.android.exoplayer2.drm.ExoMediaCrypto的典型用法代码示例。如果您正苦于以下问题:Java ExoMediaCrypto类的具体用法?Java ExoMediaCrypto怎么用?Java ExoMediaCrypto使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ExoMediaCrypto类属于com.google.android.exoplayer2.drm包,在下文中一共展示了ExoMediaCrypto类的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: VpxDecoder

点赞 3

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * Creates a VP9 decoder.
 *
 * @param numInputBuffers The number of input buffers.
 * @param numOutputBuffers The number of output buffers.
 * @param initialInputBufferSize The initial size of each input buffer.
 * @param exoMediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted
 *     content. Maybe null and can be ignored if decoder does not handle encrypted content.
 * @throws VpxDecoderException Thrown if an exception occurs when initializing the decoder.
 */
public VpxDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize,
    ExoMediaCrypto exoMediaCrypto) throws VpxDecoderException {
  super(new DecoderInputBuffer[numInputBuffers], new VpxOutputBuffer[numOutputBuffers]);
  if (!VpxLibrary.isAvailable()) {
    throw new VpxDecoderException("Failed to load decoder native libraries.");
  }
  this.exoMediaCrypto = exoMediaCrypto;
  if (exoMediaCrypto != null && !VpxLibrary.vpxIsSecureDecodeSupported()) {
    throw new VpxDecoderException("Vpx decoder does not support secure decode.");
  }
  vpxDecContext = vpxInit();
  if (vpxDecContext == 0) {
    throw new VpxDecoderException("Failed to initialize decoder");
  }
  setInitialInputBufferSize(initialInputBufferSize);
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:27,
代码来源:VpxDecoder.java

示例2: LibvpxVideoRenderer

点赞 3

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * @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;
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:36,
代码来源:LibvpxVideoRenderer.java

示例3: VpxDecoder

点赞 3

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * Creates a VP9 decoder.
 *
 * @param numInputBuffers The number of input buffers.
 * @param numOutputBuffers The number of output buffers.
 * @param initialInputBufferSize The initial size of each input buffer.
 * @param exoMediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted
 *     content. Maybe null and can be ignored if decoder does not handle encrypted content.
 * @throws VpxDecoderException Thrown if an exception occurs when initializing the decoder.
 */
public VpxDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize,
    ExoMediaCrypto exoMediaCrypto) throws VpxDecoderException {
  super(new VpxInputBuffer[numInputBuffers], new VpxOutputBuffer[numOutputBuffers]);
  if (!VpxLibrary.isAvailable()) {
    throw new VpxDecoderException("Failed to load decoder native libraries.");
  }
  this.exoMediaCrypto = exoMediaCrypto;
  if (exoMediaCrypto != null && !VpxLibrary.vpxIsSecureDecodeSupported()) {
    throw new VpxDecoderException("Vpx decoder does not support secure decode.");
  }
  vpxDecContext = vpxInit();
  if (vpxDecContext == 0) {
    throw new VpxDecoderException("Failed to initialize decoder");
  }
  setInitialInputBufferSize(initialInputBufferSize);
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:27,
代码来源:VpxDecoder.java

示例4: setUp

点赞 3

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@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();
    }
  };
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:19,
代码来源:SimpleDecoderAudioRendererTest.java

示例5: maybeInitDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
private void maybeInitDecoder() throws ExoPlaybackException {
  if (decoder != null) {
    return;
  }

  drmSession = pendingDrmSession;
  ExoMediaCrypto mediaCrypto = null;
  if (drmSession != null) {
    @DrmSession.State int drmSessionState = drmSession.getState();
    if (drmSessionState == DrmSession.STATE_ERROR) {
      throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
    } else if (drmSessionState == DrmSession.STATE_OPENED
        || drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) {
      mediaCrypto = drmSession.getMediaCrypto();
    } else {
      // The drm session isn't open yet.
      return;
    }
  }

  try {
    long codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createAudioDecoder");
    decoder = createDecoder(inputFormat, mediaCrypto);
    TraceUtil.endSection();
    long codecInitializedTimestamp = SystemClock.elapsedRealtime();
    eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
        codecInitializedTimestamp - codecInitializingTimestamp);
    decoderCounters.decoderInitCount++;
  } catch (AudioDecoderException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
 

开发者ID:sanjaysingh1990,
项目名称:Exoplayer2Radio,
代码行数:34,
代码来源:SimpleDecoderAudioRenderer.java

示例6: createDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@Override
protected FfmpegDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
    throws FfmpegDecoderException {
  decoder = new FfmpegDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
      format.sampleMimeType, format.initializationData);
  return decoder;
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:8,
代码来源:FfmpegAudioRenderer.java

示例7: maybeInitDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
private void maybeInitDecoder() throws ExoPlaybackException {
  if (decoder != null) {
    return;
  }

  drmSession = pendingDrmSession;
  ExoMediaCrypto mediaCrypto = null;
  if (drmSession != null) {
    mediaCrypto = drmSession.getMediaCrypto();
    if (mediaCrypto == null) {
      DrmSessionException drmError = drmSession.getError();
      if (drmError != null) {
        throw ExoPlaybackException.createForRenderer(drmError, getIndex());
      }
      // The drm session isn't open yet.
      return;
    }
  }

  try {
    long codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createVpxDecoder");
    decoder = new VpxDecoder(NUM_INPUT_BUFFERS, NUM_OUTPUT_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
        mediaCrypto);
    decoder.setOutputMode(outputMode);
    TraceUtil.endSection();
    long codecInitializedTimestamp = SystemClock.elapsedRealtime();
    eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
        codecInitializedTimestamp - codecInitializingTimestamp);
    decoderCounters.decoderInitCount++;
  } catch (VpxDecoderException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:35,
代码来源:LibvpxVideoRenderer.java

示例8: supportsFormatInternal

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@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;
  }
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:15,
代码来源:LibopusAudioRenderer.java

示例9: createDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@Override
protected OpusDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
    throws OpusDecoderException {
  decoder = new OpusDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
      format.initializationData, mediaCrypto);
  return decoder;
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:8,
代码来源:LibopusAudioRenderer.java

示例10: supportsFormatInternal

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@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;
  }
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:15,
代码来源:LibflacAudioRenderer.java

示例11: supportsFormatInternal

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@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;
  }
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:15,
代码来源:FfmpegAudioRenderer.java

示例12: createDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@Override
protected FfmpegDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
    throws FfmpegDecoderException {
  decoder = new FfmpegDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
      format.sampleMimeType, format.initializationData, shouldUseFloatOutput(format));
  return decoder;
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:8,
代码来源:FfmpegAudioRenderer.java

示例13: SimpleDecoderAudioRenderer

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * @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;
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:28,
代码来源:SimpleDecoderAudioRenderer.java

示例14: maybeInitDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
private void maybeInitDecoder() throws ExoPlaybackException {
  if (decoder != null) {
    return;
  }

  drmSession = pendingDrmSession;
  ExoMediaCrypto mediaCrypto = null;
  if (drmSession != null) {
    mediaCrypto = drmSession.getMediaCrypto();
    if (mediaCrypto == null) {
      DrmSessionException drmError = drmSession.getError();
      if (drmError != null) {
        throw ExoPlaybackException.createForRenderer(drmError, getIndex());
      }
      // The drm session isn't open yet.
      return;
    }
  }

  try {
    long codecInitializingTimestamp = SystemClock.elapsedRealtime();
    TraceUtil.beginSection("createAudioDecoder");
    decoder = createDecoder(inputFormat, mediaCrypto);
    TraceUtil.endSection();
    long codecInitializedTimestamp = SystemClock.elapsedRealtime();
    eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
        codecInitializedTimestamp - codecInitializingTimestamp);
    decoderCounters.decoderInitCount++;
  } catch (AudioDecoderException e) {
    throw ExoPlaybackException.createForRenderer(e, getIndex());
  }
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:33,
代码来源:SimpleDecoderAudioRenderer.java

示例15: LibvpxVideoRenderer

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * @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 = -1;
  clearLastReportedVideoSize();
  formatHolder = new FormatHolder();
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  outputMode = VpxDecoder.OUTPUT_MODE_NONE;
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:34,
代码来源:LibvpxVideoRenderer.java

示例16: render

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (outputStreamEnded) {
    return;
  }

  // Try and read a format if we don't have one already.
  if (format == null && !readFormat()) {
    // We can't make progress without one.
    return;
  }

  if (isRendererAvailable()) {
    drmSession = pendingDrmSession;
    ExoMediaCrypto mediaCrypto = null;
    if (drmSession != null) {
      int drmSessionState = drmSession.getState();
      if (drmSessionState == DrmSession.STATE_ERROR) {
        throw ExoPlaybackException.createForRenderer(drmSession.getError(), getIndex());
      } else if (drmSessionState == DrmSession.STATE_OPENED
          || drmSessionState == DrmSession.STATE_OPENED_WITH_KEYS) {
        mediaCrypto = drmSession.getMediaCrypto();
      } else {
        // The drm session isn't open yet.
        return;
      }
    }
    try {
      if (decoder == null) {
        // If we don't have a decoder yet, we need to instantiate one.
        long codecInitializingTimestamp = SystemClock.elapsedRealtime();
        TraceUtil.beginSection("createVpxDecoder");
        decoder = new VpxDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
            mediaCrypto);
        decoder.setOutputMode(outputMode);
        TraceUtil.endSection();
        long codecInitializedTimestamp = SystemClock.elapsedRealtime();
        eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp,
            codecInitializedTimestamp - codecInitializingTimestamp);
        decoderCounters.decoderInitCount++;
      }
      TraceUtil.beginSection("drainAndFeed");
      while (drainOutputBuffer(positionUs)) {}
      while (feedInputBuffer()) {}
      TraceUtil.endSection();
    } catch (VpxDecoderException e) {
      throw ExoPlaybackException.createForRenderer(e, getIndex());
    }
  } else {
    skipToKeyframeBefore(positionUs);
  }
  decoderCounters.ensureUpdated();
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:54,
代码来源:LibvpxVideoRenderer.java

示例17: vpxSecureDecode

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
private native long vpxSecureDecode(long context, ByteBuffer encoded, int length,
ExoMediaCrypto wvCrypto, int inputMode, byte[] key, byte[] iv,
int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData);
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:4,
代码来源:VpxDecoder.java

示例18: OpusDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * Creates an Opus decoder.
 *
 * @param numInputBuffers The number of input buffers.
 * @param numOutputBuffers The number of output buffers.
 * @param initialInputBufferSize The initial size of each input buffer.
 * @param initializationData Codec-specific initialization data. The first element must contain an
 *     opus header. Optionally, the list may contain two additional buffers, which must contain
 *     the encoder delay and seek pre roll values in nanoseconds, encoded as longs.
 * @param exoMediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted
 *     content. Maybe null and can be ignored if decoder does not handle encrypted content.
 * @throws OpusDecoderException Thrown if an exception occurs when initializing the decoder.
 */
public OpusDecoder(int numInputBuffers, int numOutputBuffers, int initialInputBufferSize,
    List<byte[]> initializationData, ExoMediaCrypto exoMediaCrypto) throws OpusDecoderException {
  super(new DecoderInputBuffer[numInputBuffers], new SimpleOutputBuffer[numOutputBuffers]);
  if (!OpusLibrary.isAvailable()) {
    throw new OpusDecoderException("Failed to load decoder native libraries.");
  }
  this.exoMediaCrypto = exoMediaCrypto;
  if (exoMediaCrypto != null && !OpusLibrary.opusIsSecureDecodeSupported()) {
    throw new OpusDecoderException("Opus decoder does not support secure decode.");
  }
  byte[] headerBytes = initializationData.get(0);
  if (headerBytes.length < 19) {
    throw new OpusDecoderException("Header size is too small.");
  }
  channelCount = headerBytes[9] & 0xFF;
  if (channelCount > 8) {
    throw new OpusDecoderException("Invalid channel count: " + channelCount);
  }
  int preskip = readLittleEndian16(headerBytes, 10);
  int gain = readLittleEndian16(headerBytes, 16);

  byte[] streamMap = new byte[8];
  int numStreams;
  int numCoupled;
  if (headerBytes[18] == 0) { // Channel mapping
    // If there is no channel mapping, use the defaults.
    if (channelCount > 2) { // Maximum channel count with default layout.
      throw new OpusDecoderException("Invalid Header, missing stream map.");
    }
    numStreams = 1;
    numCoupled = (channelCount == 2) ? 1 : 0;
    streamMap[0] = 0;
    streamMap[1] = 1;
  } else {
    if (headerBytes.length < 21 + channelCount) {
      throw new OpusDecoderException("Header size is too small.");
    }
    // Read the channel mapping.
    numStreams = headerBytes[19] & 0xFF;
    numCoupled = headerBytes[20] & 0xFF;
    System.arraycopy(headerBytes, 21, streamMap, 0, channelCount);
  }
  if (initializationData.size() == 3) {
    if (initializationData.get(1).length != 8 || initializationData.get(2).length != 8) {
      throw new OpusDecoderException("Invalid Codec Delay or Seek Preroll");
    }
    long codecDelayNs =
        ByteBuffer.wrap(initializationData.get(1)).order(ByteOrder.nativeOrder()).getLong();
    long seekPreRollNs =
        ByteBuffer.wrap(initializationData.get(2)).order(ByteOrder.nativeOrder()).getLong();
    headerSkipSamples = nsToSamples(codecDelayNs);
    headerSeekPreRollSamples = nsToSamples(seekPreRollNs);
  } else {
    headerSkipSamples = preskip;
    headerSeekPreRollSamples = DEFAULT_SEEK_PRE_ROLL_SAMPLES;
  }
  nativeDecoderContext = opusInit(SAMPLE_RATE, channelCount, numStreams, numCoupled, gain,
      streamMap);
  if (nativeDecoderContext == 0) {
    throw new OpusDecoderException("Failed to initialize decoder");
  }
  setInitialInputBufferSize(initialInputBufferSize);
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:77,
代码来源:OpusDecoder.java

示例19: opusSecureDecode

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
private native int opusSecureDecode(long decoder, long timeUs, ByteBuffer inputBuffer,
int inputSize, SimpleOutputBuffer outputBuffer, int sampleRate,
ExoMediaCrypto wvCrypto, int inputMode, byte[] key, byte[] iv,
int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData);
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:5,
代码来源:OpusDecoder.java

示例20: createDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@Override
protected OpusDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
    throws OpusDecoderException {
  return new OpusDecoder(NUM_BUFFERS, NUM_BUFFERS, INITIAL_INPUT_BUFFER_SIZE,
      format.initializationData, mediaCrypto);
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:7,
代码来源:LibopusAudioRenderer.java

示例21: createDecoder

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
@Override
protected FlacDecoder createDecoder(Format format, ExoMediaCrypto mediaCrypto)
    throws FlacDecoderException {
  return new FlacDecoder(NUM_BUFFERS, NUM_BUFFERS, format.initializationData);
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:6,
代码来源:LibflacAudioRenderer.java

示例22: vpxSecureDecode

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
private native long vpxSecureDecode(long context, ByteBuffer encoded, int length,
ExoMediaCrypto mediaCrypto, int inputMode, byte[] key, byte[] iv,
int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData);
 

开发者ID:y20k,
项目名称:transistor,
代码行数:4,
代码来源:VpxDecoder.java

示例23: opusSecureDecode

点赞 2

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
private native int opusSecureDecode(long decoder, long timeUs, ByteBuffer inputBuffer,
int inputSize, SimpleOutputBuffer outputBuffer, int sampleRate,
ExoMediaCrypto mediaCrypto, int inputMode, byte[] key, byte[] iv,
int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData);
 

开发者ID:y20k,
项目名称:transistor,
代码行数:5,
代码来源:OpusDecoder.java

示例24: SimpleDecoderAudioRenderer

点赞 1

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * @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 audioCapabilities The audio capabilities for playback on this device. May be null if the
 *     default capabilities (no encoded audio passthrough support) should be assumed.
 * @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 audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
 */
public SimpleDecoderAudioRenderer(Handler eventHandler,
    AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities,
    DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean playClearSamplesWithoutKeys,
    AudioProcessor... audioProcessors) {
  super(C.TRACK_TYPE_AUDIO);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  audioTrack = new AudioTrack(audioCapabilities, audioProcessors, new AudioTrackListener());
  formatHolder = new FormatHolder();
  flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
  decoderReinitializationState = REINITIALIZATION_STATE_NONE;
  audioTrackNeedsConfigure = true;
}
 

开发者ID:sanjaysingh1990,
项目名称:Exoplayer2Radio,
代码行数:30,
代码来源:SimpleDecoderAudioRenderer.java

示例25: SimpleDecoderAudioRenderer

点赞 1

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * @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 audioCapabilities The audio capabilities for playback on this device. May be null if the
 *     default capabilities (no encoded audio passthrough support) should be assumed.
 * @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 audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
 */
public SimpleDecoderAudioRenderer(Handler eventHandler,
    AudioRendererEventListener eventListener, AudioCapabilities audioCapabilities,
    DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean playClearSamplesWithoutKeys,
    AudioProcessor... audioProcessors) {
  super(C.TRACK_TYPE_AUDIO);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  eventDispatcher = new EventDispatcher(eventHandler, eventListener);
  audioTrack = new AudioTrack(audioCapabilities, audioProcessors, new AudioTrackListener());
  formatHolder = new FormatHolder();
  flagsOnlyBuffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
  decoderReinitializationState = REINITIALIZATION_STATE_NONE;
  audioTrackNeedsConfigure = true;
}
 

开发者ID:jcodeing,
项目名称:K-Sonic,
代码行数:30,
代码来源:SimpleDecoderAudioRenderer.java

示例26: LibopusAudioRenderer

点赞 1

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * @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 audioCapabilities The audio capabilities for playback on this device. May be null if the
 *     default capabilities (no encoded audio passthrough support) should be assumed.
 */
public LibopusAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener,
    AudioCapabilities audioCapabilities, DrmSessionManager<ExoMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys) {
  super(eventHandler, eventListener, audioCapabilities, drmSessionManager,
      playClearSamplesWithoutKeys);
}
 

开发者ID:TakumaMochizuki,
项目名称:Komica,
代码行数:14,
代码来源:LibopusAudioRenderer.java

示例27: LibopusAudioRenderer

点赞 1

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * @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 audioProcessors Optional {@link AudioProcessor}s that will process audio before output.
 */
public LibopusAudioRenderer(Handler eventHandler, AudioRendererEventListener eventListener,
    DrmSessionManager<ExoMediaCrypto> drmSessionManager, boolean playClearSamplesWithoutKeys,
    AudioProcessor... audioProcessors) {
  super(eventHandler, eventListener, null, drmSessionManager, playClearSamplesWithoutKeys,
      audioProcessors);
}
 

开发者ID:y20k,
项目名称:transistor,
代码行数:20,
代码来源:LibopusAudioRenderer.java

示例28: createDecoder

点赞 1

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * Creates a decoder for the given format.
 *
 * @param format The format for which a decoder is required.
 * @param mediaCrypto The {@link ExoMediaCrypto} object required for decoding encrypted content.
 *     Maybe null and can be ignored if decoder does not handle encrypted content.
 * @return The decoder.
 * @throws AudioDecoderException If an error occurred creating a suitable decoder.
 */
protected abstract SimpleDecoder<DecoderInputBuffer, ? extends SimpleOutputBuffer,
    ? extends AudioDecoderException> createDecoder(Format format, ExoMediaCrypto mediaCrypto)
    throws AudioDecoderException;
 

开发者ID:sanjaysingh1990,
项目名称:Exoplayer2Radio,
代码行数:13,
代码来源:SimpleDecoderAudioRenderer.java

示例29: supportsFormatInternal

点赞 1

import com.google.android.exoplayer2.drm.ExoMediaCrypto; //导入依赖的package包/类
/**
 * Returns the {@link #FORMAT_SUPPORT_MASK} component of the return value for
 * {@link #supportsFormat(Format)}.
 *
 * @param drmSessionManager The renderer's {@link DrmSessionManager}.
 * @param format The format.
 * @return The extent to which the renderer supports the format itself.
 */
protected abstract int supportsFormatInternal(DrmSessionManager<ExoMediaCrypto> drmSessionManager,
    Format format);
 

开发者ID:y20k,
项目名称:transistor,
代码行数:11,
代码来源:SimpleDecoderAudioRenderer.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)