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


Java MediaExtractor.SAMPLE_FLAG_SYNC属性代码示例

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


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

示例1: drainExtractor

private int drainExtractor(long timeoutUs) {
    if (mIsExtractorEOS) return DRAIN_STATE_NONE;
    int trackIndex = mExtractor.getSampleTrackIndex();
    if (trackIndex >= 0 && trackIndex != mTrackIndex) {
        return DRAIN_STATE_NONE;
    }

    final int result = mDecoder.dequeueInputBuffer(timeoutUs);
    if (result < 0) return DRAIN_STATE_NONE;
    if (trackIndex < 0) {
        mIsExtractorEOS = true;
        mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
        return DRAIN_STATE_NONE;
    }

    final int sampleSize = mExtractor.readSampleData(mDecoderBuffers.getInputBuffer(result), 0);
    final boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
    mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
    mExtractor.advance();
    return DRAIN_STATE_CONSUMED;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:21,代码来源:AudioTrackTranscoder.java

示例2: drainExtractor

private int drainExtractor(long timeoutUs) {
    if (mIsExtractorEOS) return DRAIN_STATE_NONE;
    int trackIndex = mExtractor.getSampleTrackIndex();
    if (trackIndex >= 0 && trackIndex != mTrackIndex) {
        return DRAIN_STATE_NONE;
    }
    int result = mDecoder.dequeueInputBuffer(timeoutUs);
    if (result < 0) return DRAIN_STATE_NONE;
    if (trackIndex < 0) {
        mIsExtractorEOS = true;
        mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
        return DRAIN_STATE_NONE;
    }
    int sampleSize = mExtractor.readSampleData(mDecoderInputBuffers[result], 0);
    boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
    mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
    mExtractor.advance();
    return DRAIN_STATE_CONSUMED;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:19,代码来源:VideoTrackTranscoder.java

示例3: drainExtractor

private int drainExtractor(long timeoutUs) {
    if (mIsExtractorEOS) return DRAIN_STATE_NONE;
    int trackIndex = mExtractor.getSampleTrackIndex();
    if (trackIndex >= 0 && trackIndex != mTrackIndex) {
        return DRAIN_STATE_NONE;
    }

    int result = mDecoder.dequeueInputBuffer(timeoutUs);
    if (result < 0) return DRAIN_STATE_NONE;
    if (trackIndex < 0) {
        mIsExtractorEOS = true;
        mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
        return DRAIN_STATE_NONE;
    }

    int sampleSize = mExtractor.readSampleData(MediaUtil.getInputBuffer(mDecoder, result), 0);
    boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
    mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
    mExtractor.advance();
    return DRAIN_STATE_CONSUMED;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:21,代码来源:AudioTrackTranscoder.java

示例4: drainExtractor

private int drainExtractor(long timeoutUs) {
    if (mIsExtractorEOS) return DRAIN_STATE_NONE;
    int trackIndex = mExtractor.getSampleTrackIndex();
    if (trackIndex >= 0 && trackIndex != mTrackIndex) {
        return DRAIN_STATE_NONE;
    }

    int result = mDecoder.dequeueInputBuffer(timeoutUs);
    if (result < 0) return DRAIN_STATE_NONE;
    if (trackIndex < 0) {
        mIsExtractorEOS = true;
        mDecoder.queueInputBuffer(result, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM);
        return DRAIN_STATE_NONE;
    }

    int sampleSize = mExtractor.readSampleData(mDecoderInputBuffers[result], 0);
    boolean isKeyFrame = (mExtractor.getSampleFlags() & MediaExtractor.SAMPLE_FLAG_SYNC) != 0;
    mDecoder.queueInputBuffer(result, 0, sampleSize, mExtractor.getSampleTime(), isKeyFrame ? MediaCodec.BUFFER_FLAG_SYNC_FRAME : 0);
    mExtractor.advance();
    return DRAIN_STATE_CONSUMED;
}
 
开发者ID:uestccokey,项目名称:EZFilter,代码行数:21,代码来源:VideoTrackTranscoder.java

示例5: onBinaryElement

boolean onBinaryElement(
    int id, long elementOffsetBytes, int headerSizeBytes, int contentsSizeBytes,
    NonBlockingInputStream inputStream) throws ParserException {
  switch (id) {
    case ID_SIMPLE_BLOCK:
      // Please refer to http://www.matroska.org/technical/specs/index.html#simpleblock_structure
      // for info about how data is organized in a SimpleBlock element.

      // If we don't have a sample holder then don't consume the data.
      if (sampleHolder == null) {
        readResults |= RESULT_NEED_SAMPLE_HOLDER;
        return false;
      }

      // Value of trackNumber is not used but needs to be read.
      reader.readVarint(inputStream);

      // Next three bytes have timecode and flags.
      reader.readBytes(inputStream, simpleBlockTimecodeAndFlags, 3);

      // First two bytes of the three are the relative timecode.
      int timecode =
          (simpleBlockTimecodeAndFlags[0] << 8) | (simpleBlockTimecodeAndFlags[1] & 0xff);
      long timecodeUs = scaleTimecodeToUs(timecode);

      // Last byte of the three has some flags and the lacing value.
      boolean keyframe = (simpleBlockTimecodeAndFlags[2] & 0x80) == 0x80;
      boolean invisible = (simpleBlockTimecodeAndFlags[2] & 0x08) == 0x08;
      int lacing = (simpleBlockTimecodeAndFlags[2] & 0x06) >> 1;

      // Validate lacing and set info into sample holder.
      switch (lacing) {
        case LACING_NONE:
          long elementEndOffsetBytes = elementOffsetBytes + headerSizeBytes + contentsSizeBytes;
          simpleBlockTimecodeUs = clusterTimecodeUs + timecodeUs;
          sampleHolder.flags = keyframe ? MediaExtractor.SAMPLE_FLAG_SYNC : 0;
          sampleHolder.decodeOnly = invisible;
          sampleHolder.timeUs = clusterTimecodeUs + timecodeUs;
          sampleHolder.size = (int) (elementEndOffsetBytes - reader.getBytesRead());
          break;
        case LACING_EBML:
        case LACING_FIXED:
        case LACING_XIPH:
        default:
          throw new ParserException("Lacing mode " + lacing + " not supported");
      }

      if (sampleHolder.data == null || sampleHolder.data.capacity() < sampleHolder.size) {
        sampleHolder.replaceBuffer(sampleHolder.size);
      }

      ByteBuffer outputData = sampleHolder.data;
      if (outputData == null) {
        reader.skipBytes(inputStream, sampleHolder.size);
        sampleHolder.size = 0;
      } else {
        reader.readBytes(inputStream, outputData, sampleHolder.size);
      }
      readResults |= RESULT_READ_SAMPLE;
      break;
    case ID_CODEC_PRIVATE:
      codecPrivate = new byte[contentsSizeBytes];
      reader.readBytes(inputStream, codecPrivate, contentsSizeBytes);
      break;
    default:
      // pass
  }
  return true;
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:69,代码来源:WebmExtractor.java

示例6: onBinaryElement

boolean onBinaryElement(
    int id, long elementOffsetBytes, int headerSizeBytes, int contentsSizeBytes,
    NonBlockingInputStream inputStream) {
  if (id == ID_SIMPLE_BLOCK) {
    // Please refer to http://www.matroska.org/technical/specs/index.html#simpleblock_structure
    // for info about how data is organized in a SimpleBlock element.

    // If we don't have a sample holder then don't consume the data.
    if (sampleHolder == null) {
      readResults |= RESULT_NEED_SAMPLE_HOLDER;
      return false;
    }

    // Value of trackNumber is not used but needs to be read.
    reader.readVarint(inputStream);

    // Next three bytes have timecode and flags.
    reader.readBytes(inputStream, simpleBlockTimecodeAndFlags, 3);

    // First two bytes of the three are the relative timecode.
    int timecode =
        (simpleBlockTimecodeAndFlags[0] << 8) | (simpleBlockTimecodeAndFlags[1] & 0xff);
    long timecodeUs = scaleTimecodeToUs(timecode);

    // Last byte of the three has some flags and the lacing value.
    boolean keyframe = (simpleBlockTimecodeAndFlags[2] & 0x80) == 0x80;
    boolean invisible = (simpleBlockTimecodeAndFlags[2] & 0x08) == 0x08;
    int lacing = (simpleBlockTimecodeAndFlags[2] & 0x06) >> 1;

    // Validate lacing and set info into sample holder.
    switch (lacing) {
      case LACING_NONE:
        long elementEndOffsetBytes = elementOffsetBytes + headerSizeBytes + contentsSizeBytes;
        simpleBlockTimecodeUs = clusterTimecodeUs + timecodeUs;
        sampleHolder.flags = keyframe ? MediaExtractor.SAMPLE_FLAG_SYNC : 0;
        sampleHolder.decodeOnly = invisible;
        sampleHolder.timeUs = clusterTimecodeUs + timecodeUs;
        sampleHolder.size = (int) (elementEndOffsetBytes - reader.getBytesRead());
        break;
      case LACING_EBML:
      case LACING_FIXED:
      case LACING_XIPH:
      default:
        throw new IllegalStateException("Lacing mode " + lacing + " not supported");
    }

    ByteBuffer outputData = sampleHolder.data;
    if (sampleHolder.allowDataBufferReplacement
        && (sampleHolder.data == null || sampleHolder.data.capacity() < sampleHolder.size)) {
      outputData = ByteBuffer.allocate(sampleHolder.size);
      sampleHolder.data = outputData;
    }

    if (outputData == null) {
      reader.skipBytes(inputStream, sampleHolder.size);
      sampleHolder.size = 0;
    } else {
      reader.readBytes(inputStream, outputData, sampleHolder.size);
    }
    readResults |= RESULT_READ_SAMPLE;
  }
  return true;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:63,代码来源:WebmExtractor.java


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