当前位置: 首页>>代码示例>>Java>>正文


Java MediaExtractor.SAMPLE_FLAG_ENCRYPTED属性代码示例

本文整理汇总了Java中android.media.MediaExtractor.SAMPLE_FLAG_ENCRYPTED属性的典型用法代码示例。如果您正苦于以下问题:Java MediaExtractor.SAMPLE_FLAG_ENCRYPTED属性的具体用法?Java MediaExtractor.SAMPLE_FLAG_ENCRYPTED怎么用?Java MediaExtractor.SAMPLE_FLAG_ENCRYPTED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.media.MediaExtractor的用法示例。


在下文中一共展示了MediaExtractor.SAMPLE_FLAG_ENCRYPTED属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readData

@Override
public int readData(int track, long positionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder, boolean onlyReadDiscontinuity) {
  Assertions.checkState(prepared);
  Assertions.checkState(trackStates[track] != TRACK_STATE_DISABLED);
  if (pendingDiscontinuities[track]) {
    pendingDiscontinuities[track] = false;
    return DISCONTINUITY_READ;
  }
  if (onlyReadDiscontinuity) {
    return NOTHING_READ;
  }
  if (trackStates[track] != TRACK_STATE_FORMAT_SENT) {
    formatHolder.format = MediaFormat.createFromFrameworkMediaFormatV16(
        extractor.getTrackFormat(track));
    formatHolder.drmInitData = Util.SDK_INT >= 18 ? getPsshInfoV18() : null;
    trackStates[track] = TRACK_STATE_FORMAT_SENT;
    return FORMAT_READ;
  }
  int extractorTrackIndex = extractor.getSampleTrackIndex();
  if (extractorTrackIndex == track) {
    if (sampleHolder.data != null) {
      int offset = sampleHolder.data.position();
      sampleHolder.size = extractor.readSampleData(sampleHolder.data, offset);
      sampleHolder.data.position(offset + sampleHolder.size);
    } else {
      sampleHolder.size = 0;
    }
    sampleHolder.timeUs = extractor.getSampleTime();
    sampleHolder.flags = extractor.getSampleFlags();
    if ((sampleHolder.flags & MediaExtractor.SAMPLE_FLAG_ENCRYPTED) != 0) {
      sampleHolder.cryptoInfo.setFromExtractorV16(extractor);
    }
    seekPositionUs = -1;
    extractor.advance();
    return SAMPLE_READ;
  } else {
    return extractorTrackIndex < 0 ? END_OF_STREAM : NOTHING_READ;
  }
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:40,代码来源:FrameworkSampleSource.java

示例2: readSampleEncryptionData

@SuppressLint("InlinedApi")
private void readSampleEncryptionData(ParsableByteArray sampleEncryptionData, SampleHolder out) {
  TrackEncryptionBox encryptionBox =
      track.sampleDescriptionEncryptionBoxes[fragmentRun.sampleDescriptionIndex];
  byte[] keyId = encryptionBox.keyId;
  boolean isEncrypted = encryptionBox.isEncrypted;
  int vectorSize = encryptionBox.initializationVectorSize;
  boolean subsampleEncryption = fragmentRun.sampleHasSubsampleEncryptionTable[sampleIndex];

  byte[] vector = out.cryptoInfo.iv;
  if (vector == null || vector.length != 16) {
    vector = new byte[16];
  }
  sampleEncryptionData.readBytes(vector, 0, vectorSize);

  int subsampleCount = subsampleEncryption ? sampleEncryptionData.readUnsignedShort() : 1;
  int[] clearDataSizes = out.cryptoInfo.numBytesOfClearData;
  if (clearDataSizes == null || clearDataSizes.length < subsampleCount) {
    clearDataSizes = new int[subsampleCount];
  }
  int[] encryptedDataSizes = out.cryptoInfo.numBytesOfEncryptedData;
  if (encryptedDataSizes == null || encryptedDataSizes.length < subsampleCount) {
    encryptedDataSizes = new int[subsampleCount];
  }
  if (subsampleEncryption) {
    for (int i = 0; i < subsampleCount; i++) {
      clearDataSizes[i] = sampleEncryptionData.readUnsignedShort();
      encryptedDataSizes[i] = sampleEncryptionData.readUnsignedIntToInt();
    }
  } else {
    clearDataSizes[0] = 0;
    encryptedDataSizes[0] = fragmentRun.sampleSizeTable[sampleIndex];
  }
  out.cryptoInfo.set(subsampleCount, clearDataSizes, encryptedDataSizes, keyId, vector,
      isEncrypted ? MediaCodec.CRYPTO_MODE_AES_CTR : MediaCodec.CRYPTO_MODE_UNENCRYPTED);
  if (isEncrypted) {
    out.flags |= MediaExtractor.SAMPLE_FLAG_ENCRYPTED;
  }
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:39,代码来源:FragmentedMp4Extractor.java

示例3: readSample

@Override
  public int readSample(int track, SampleHolder sampleHolder) {
    int sampleTrack = mediaExtractor.getSampleTrackIndex();
    if (sampleTrack != track) {
      return sampleTrack < 0 ? SampleSource.END_OF_STREAM : SampleSource.NOTHING_READ;
    }

    if (sampleHolder.data != null) {
      int offset = sampleHolder.data.position();
      sampleHolder.size = mediaExtractor.readSampleData(sampleHolder.data, offset);
      sampleHolder.data.position(offset + sampleHolder.size);
    } else {
      sampleHolder.size = 0;
    }
    sampleHolder.timeUs = mediaExtractor.getSampleTime();
    sampleHolder.flags = mediaExtractor.getSampleFlags();
    if ((sampleHolder.flags & MediaExtractor.SAMPLE_FLAG_ENCRYPTED) != 0) {
      sampleHolder.cryptoInfo.setFromExtractorV16(mediaExtractor);
    }

//      // yy debug stuff
//      if (MediaCodecVideoTrackRenderer.bb == null) {
//          MediaCodecVideoTrackRenderer.bb = new ArrayList<byte[]>();
//      }
//      int len = sampleHolder.size;
//      byte[] dd = new byte[len];
//      for (int i=0; i<len; i++) {
//          dd[i] = sampleHolder.data.get(i);
//      }
//      MediaCodecVideoTrackRenderer.bb.add(dd);
//
//      if (MediaCodecVideoTrackRenderer.pts == null) {
//          MediaCodecVideoTrackRenderer.pts = new ArrayList<Long>();
//      }
//      MediaCodecVideoTrackRenderer.pts.add(new Long(sampleHolder.timeUs));

      mediaExtractor.advance();

    return SampleSource.SAMPLE_READ;
  }
 
开发者ID:tyazid,项目名称:Exoplayer_VLC,代码行数:40,代码来源:FrameworkSampleExtractor.java

示例4: readData

@Override
public int readData(int track, long playbackPositionUs, MediaFormatHolder formatHolder,
    SampleHolder sampleHolder, boolean onlyReadDiscontinuity) {
  Assertions.checkState(prepared);
  Assertions.checkState(trackStates[track] != TRACK_STATE_DISABLED);
  if (pendingDiscontinuities[track]) {
    pendingDiscontinuities[track] = false;
    return DISCONTINUITY_READ;
  }
  if (onlyReadDiscontinuity) {
    return NOTHING_READ;
  }
  if (trackStates[track] != TRACK_STATE_FORMAT_SENT) {
    formatHolder.format = MediaFormat.createFromFrameworkMediaFormatV16(
        extractor.getTrackFormat(track));
    formatHolder.drmInitData = Util.SDK_INT >= 18 ? getPsshInfoV18() : null;
    trackStates[track] = TRACK_STATE_FORMAT_SENT;
    return FORMAT_READ;
  }
  int extractorTrackIndex = extractor.getSampleTrackIndex();
  if (extractorTrackIndex == track) {
    if (sampleHolder.data != null) {
      int offset = sampleHolder.data.position();
      sampleHolder.size = extractor.readSampleData(sampleHolder.data, offset);
      sampleHolder.data.position(offset + sampleHolder.size);
    } else {
      sampleHolder.size = 0;
    }
    sampleHolder.timeUs = extractor.getSampleTime();
    sampleHolder.flags = extractor.getSampleFlags();
    if ((sampleHolder.flags & MediaExtractor.SAMPLE_FLAG_ENCRYPTED) != 0) {
      sampleHolder.cryptoInfo.setFromExtractorV16(extractor);
    }
    seekTimeUs = -1;
    extractor.advance();
    return SAMPLE_READ;
  } else {
    return extractorTrackIndex < 0 ? END_OF_STREAM : NOTHING_READ;
  }
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:40,代码来源:FrameworkSampleSource.java

示例5: readData

@Override
public int readData(int track, long playbackPositionUs, FormatHolder formatHolder,
    SampleHolder sampleHolder, boolean onlyReadDiscontinuity) {
  Assertions.checkState(prepared);
  Assertions.checkState(trackStates[track] != TRACK_STATE_DISABLED);
  if (pendingDiscontinuities[track]) {
    pendingDiscontinuities[track] = false;
    return DISCONTINUITY_READ;
  }
  if (onlyReadDiscontinuity) {
    return NOTHING_READ;
  }
  if (trackStates[track] != TRACK_STATE_FORMAT_SENT) {
    formatHolder.format = MediaFormat.createFromFrameworkMediaFormatV16(
        extractor.getTrackFormat(track));
    formatHolder.drmInitData = Util.SDK_INT >= 18 ? getPsshInfoV18() : null;
    trackStates[track] = TRACK_STATE_FORMAT_SENT;
    return FORMAT_READ;
  }
  int extractorTrackIndex = extractor.getSampleTrackIndex();
  if (extractorTrackIndex == track) {
    if (sampleHolder.data != null) {
      int offset = sampleHolder.data.position();
      sampleHolder.size = extractor.readSampleData(sampleHolder.data, offset);
      sampleHolder.data.position(offset + sampleHolder.size);
    } else {
      sampleHolder.size = 0;
    }
    sampleHolder.timeUs = extractor.getSampleTime();
    sampleHolder.flags = extractor.getSampleFlags();
    if ((sampleHolder.flags & MediaExtractor.SAMPLE_FLAG_ENCRYPTED) != 0) {
      sampleHolder.cryptoInfo.setFromExtractorV16(extractor);
    }
    seekTimeUs = -1;
    extractor.advance();
    return SAMPLE_READ;
  } else {
    return extractorTrackIndex < 0 ? END_OF_STREAM : NOTHING_READ;
  }
}
 
开发者ID:lsjwzh,项目名称:ExoPlayerCompat,代码行数:40,代码来源:FrameworkSampleSource.java


注:本文中的android.media.MediaExtractor.SAMPLE_FLAG_ENCRYPTED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。