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


Java Extractor.RESULT_CONTINUE属性代码示例

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


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

示例1: maybeLoadInitData

private void maybeLoadInitData() throws IOException, InterruptedException {
  if (previousExtractor == extractor || initLoadCompleted || initDataSpec == null) {
    // According to spec, for packed audio, initDataSpec is expected to be null.
    return;
  }
  DataSpec initSegmentDataSpec = Util.getRemainderDataSpec(initDataSpec, initSegmentBytesLoaded);
  try {
    ExtractorInput input = new DefaultExtractorInput(initDataSource,
        initSegmentDataSpec.absoluteStreamPosition, initDataSource.open(initSegmentDataSpec));
    try {
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractor.read(input, null);
      }
    } finally {
      initSegmentBytesLoaded = (int) (input.getPosition() - initDataSpec.absoluteStreamPosition);
    }
  } finally {
    Util.closeQuietly(dataSource);
  }
  initLoadCompleted = true;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:HlsMediaChunk.java

示例2: read

@Override
public int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  int currentFileSize = (int) input.getLength();

  // Increase the size of sampleData if necessary.
  if (sampleSize == sampleData.length) {
    sampleData = Arrays.copyOf(sampleData,
        (currentFileSize != C.LENGTH_UNSET ? currentFileSize : sampleData.length) * 3 / 2);
  }

  // Consume to the input.
  int bytesRead = input.read(sampleData, sampleSize, sampleData.length - sampleSize);
  if (bytesRead != C.RESULT_END_OF_INPUT) {
    sampleSize += bytesRead;
    if (currentFileSize == C.LENGTH_UNSET || sampleSize != currentFileSize) {
      return Extractor.RESULT_CONTINUE;
    }
  }

  // We've reached the end of the input, which corresponds to the end of the current file.
  processSample();
  return Extractor.RESULT_END_OF_INPUT;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:WebvttExtractor.java

示例3: read

/**
 * @see Extractor#read(ExtractorInput, PositionHolder)
 */
final int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  switch (state) {
    case STATE_READ_HEADERS:
      return readHeaders(input);
    case STATE_SKIP_HEADERS:
      input.skipFully((int) payloadStartPosition);
      state = STATE_READ_PAYLOAD;
      return Extractor.RESULT_CONTINUE;
    case STATE_READ_PAYLOAD:
      return readPayload(input, seekPosition);
    default:
      // Never happens.
      throw new IllegalStateException();
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:19,代码来源:StreamReader.java

示例4: load

@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public void load() throws IOException, InterruptedException {
  DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded);
  try {
    // Create and open the input.
    ExtractorInput input = new DefaultExtractorInput(dataSource,
        loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
    if (bytesLoaded == 0) {
      extractorWrapper.init(null);
    }
    // Load and decode the initialization data.
    try {
      Extractor extractor = extractorWrapper.extractor;
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractor.read(input, null);
      }
      Assertions.checkState(result != Extractor.RESULT_SEEK);
    } finally {
      bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
    }
  } finally {
    Util.closeQuietly(dataSource);
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:26,代码来源:InitializationChunk.java

示例5: read

/**
 * @see Extractor#read(ExtractorInput, PositionHolder)
 */
final int read(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  switch (state) {
    case STATE_READ_HEADERS:
      return readHeaders(input);

    case STATE_SKIP_HEADERS:
      input.skipFully((int) payloadStartPosition);
      state = STATE_READ_PAYLOAD;
      return Extractor.RESULT_CONTINUE;

    case STATE_READ_PAYLOAD:
      return readPayload(input, seekPosition);

    default:
      // Never happens.
      throw new IllegalStateException();
  }
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:22,代码来源:StreamReader.java

示例6: load

@Override
public void load() throws IOException, InterruptedException {
  DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded);
  try {
    ExtractorInput input = new DefaultExtractorInput(dataSource,
        loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
    try {
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractor.read(input, null);
      }
    } finally {
      bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
    }
  } finally {
    dataSource.close();
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:18,代码来源:HlsInitializationChunk.java

示例7: load

@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public void load() throws IOException, InterruptedException {
  DataSpec loadDataSpec = Util.getRemainderDataSpec(dataSpec, bytesLoaded);
  try {
    // Create and open the input.
    ExtractorInput input = new DefaultExtractorInput(dataSource,
        loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
    if (bytesLoaded == 0) {
      // Set the target to ourselves.
      extractorWrapper.init(this, this);
    }
    // Load and decode the initialization data.
    try {
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractorWrapper.read(input);
      }
    } finally {
      bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
    }
  } finally {
    dataSource.close();
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:25,代码来源:InitializationChunk.java

示例8: testCustomPesReader

public void testCustomPesReader() throws Exception {
  CustomEsReaderFactory factory = new CustomEsReaderFactory();
  TsExtractor tsExtractor = new TsExtractor(new TimestampAdjuster(0), factory, false);
  FakeExtractorInput input = new FakeExtractorInput.Builder()
      .setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample.ts"))
      .setSimulateIOErrors(false)
      .setSimulateUnknownLength(false)
      .setSimulatePartialReads(false).build();
  FakeExtractorOutput output = new FakeExtractorOutput();
  tsExtractor.init(output);
  tsExtractor.seek(input.getPosition());
  PositionHolder seekPositionHolder = new PositionHolder();
  int readResult = Extractor.RESULT_CONTINUE;
  while (readResult != Extractor.RESULT_END_OF_INPUT) {
    readResult = tsExtractor.read(input, seekPositionHolder);
  }
  CustomEsReader reader = factory.reader;
  assertEquals(2, reader.packetsRead);
  TrackOutput trackOutput = reader.getTrackOutput();
  assertTrue(trackOutput == output.trackOutputs.get(257 /* PID of audio track. */));
  assertEquals(
      Format.createTextSampleFormat("Overriding format", "mime", null, 0, 0, "und", null, 0),
      ((FakeTrackOutput) trackOutput).format);
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:24,代码来源:TsExtractorTest.java

示例9: maybeLoadInitData

private void maybeLoadInitData() throws IOException, InterruptedException {
  if (initLoadCompleted || initDataSpec == null) {
    // Note: The HLS spec forbids initialization segments for packed audio.
    return;
  }
  DataSpec initSegmentDataSpec = initDataSpec.subrange(initSegmentBytesLoaded);
  try {
    ExtractorInput input = new DefaultExtractorInput(initDataSource,
        initSegmentDataSpec.absoluteStreamPosition, initDataSource.open(initSegmentDataSpec));
    try {
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractor.read(input, null);
      }
    } finally {
      initSegmentBytesLoaded = (int) (input.getPosition() - initDataSpec.absoluteStreamPosition);
    }
  } finally {
    Util.closeQuietly(dataSource);
  }
  initLoadCompleted = true;
}
 
开发者ID:y20k,项目名称:transistor,代码行数:22,代码来源:HlsMediaChunk.java

示例10: load

@SuppressWarnings("NonAtomicVolatileUpdate")
@Override
public void load() throws IOException, InterruptedException {
  DataSpec loadDataSpec = dataSpec.subrange(bytesLoaded);
  try {
    // Create and open the input.
    ExtractorInput input = new DefaultExtractorInput(dataSource,
        loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
    if (bytesLoaded == 0) {
      extractorWrapper.init(null);
    }
    // Load and decode the initialization data.
    try {
      Extractor extractor = extractorWrapper.extractor;
      int result = Extractor.RESULT_CONTINUE;
      while (result == Extractor.RESULT_CONTINUE && !loadCanceled) {
        result = extractor.read(input, null);
      }
      Assertions.checkState(result != Extractor.RESULT_SEEK);
    } finally {
      bytesLoaded = (int) (input.getPosition() - dataSpec.absoluteStreamPosition);
    }
  } finally {
    Util.closeQuietly(dataSource);
  }
}
 
开发者ID:y20k,项目名称:transistor,代码行数:26,代码来源:InitializationChunk.java

示例11: testCustomPesReader

public void testCustomPesReader() throws Exception {
  CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(true, false);
  TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0),
      factory);
  FakeExtractorInput input = new FakeExtractorInput.Builder()
      .setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample.ts"))
      .setSimulateIOErrors(false)
      .setSimulateUnknownLength(false)
      .setSimulatePartialReads(false).build();
  FakeExtractorOutput output = new FakeExtractorOutput();
  tsExtractor.init(output);
  PositionHolder seekPositionHolder = new PositionHolder();
  int readResult = Extractor.RESULT_CONTINUE;
  while (readResult != Extractor.RESULT_END_OF_INPUT) {
    readResult = tsExtractor.read(input, seekPositionHolder);
  }
  CustomEsReader reader = factory.esReader;
  assertEquals(2, reader.packetsRead);
  TrackOutput trackOutput = reader.getTrackOutput();
  assertTrue(trackOutput == output.trackOutputs.get(257 /* PID of audio track. */));
  assertEquals(
      Format.createTextSampleFormat("1/257", "mime", null, 0, 0, "und", null, 0),
      ((FakeTrackOutput) trackOutput).format);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:24,代码来源:TsExtractorTest.java

示例12: testCustomInitialSectionReader

public void testCustomInitialSectionReader() throws Exception {
  CustomTsPayloadReaderFactory factory = new CustomTsPayloadReaderFactory(false, true);
  TsExtractor tsExtractor = new TsExtractor(TsExtractor.MODE_MULTI_PMT, new TimestampAdjuster(0),
      factory);
  FakeExtractorInput input = new FakeExtractorInput.Builder()
      .setData(TestUtil.getByteArray(getInstrumentation(), "ts/sample_with_sdt.ts"))
      .setSimulateIOErrors(false)
      .setSimulateUnknownLength(false)
      .setSimulatePartialReads(false).build();
  tsExtractor.init(new FakeExtractorOutput());
  PositionHolder seekPositionHolder = new PositionHolder();
  int readResult = Extractor.RESULT_CONTINUE;
  while (readResult != Extractor.RESULT_END_OF_INPUT) {
    readResult = tsExtractor.read(input, seekPositionHolder);
  }
  assertEquals(1, factory.sdtReader.consumedSdts);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:17,代码来源:TsExtractorTest.java

示例13: consumeTestData

private static void consumeTestData(Extractor extractor, FakeExtractorInput input, long timeUs,
    FakeExtractorOutput output, boolean retryFromStartIfLive)
    throws IOException, InterruptedException {
  extractor.seek(input.getPosition(), timeUs);
  PositionHolder seekPositionHolder = new PositionHolder();
  int readResult = Extractor.RESULT_CONTINUE;
  while (readResult != Extractor.RESULT_END_OF_INPUT) {
    try {
      // Extractor.read should not read seekPositionHolder.position. Set it to a value that's
      // likely to cause test failure if a read does occur.
      seekPositionHolder.position = Long.MIN_VALUE;
      readResult = extractor.read(input, seekPositionHolder);
      if (readResult == Extractor.RESULT_SEEK) {
        long seekPosition = seekPositionHolder.position;
        Assertions.checkState(0 <= seekPosition && seekPosition <= Integer.MAX_VALUE);
        input.setPosition((int) seekPosition);
      }
    } catch (SimulatedIOException e) {
      if (!retryFromStartIfLive) {
        continue;
      }
      boolean isOnDemand = input.getLength() != C.LENGTH_UNSET
          || (output.seekMap != null && output.seekMap.getDurationUs() != C.TIME_UNSET);
      if (isOnDemand) {
        continue;
      }
      input.setPosition(0);
      for (int i = 0; i < output.numberOfTracks; i++) {
        output.trackOutputs.valueAt(i).clear();
      }
      extractor.seek(0, 0);
    }
  }
}
 
开发者ID:ashwanijanghu,项目名称:ExoPlayer-Offline,代码行数:34,代码来源:TestUtil.java

示例14: readHeaders

private int readHeaders(ExtractorInput input) throws IOException, InterruptedException {
  boolean readingHeaders = true;
  while (readingHeaders) {
    if (!oggPacket.populate(input)) {
      state = STATE_END_OF_INPUT;
      return Extractor.RESULT_END_OF_INPUT;
    }
    lengthOfReadPacket = input.getPosition() - payloadStartPosition;

    readingHeaders = readHeaders(oggPacket.getPayload(), payloadStartPosition, setupData);
    if (readingHeaders) {
      payloadStartPosition = input.getPosition();
    }
  }

  sampleRate = setupData.format.sampleRate;
  if (!formatSet) {
    trackOutput.format(setupData.format);
    formatSet = true;
  }

  if (setupData.oggSeeker != null) {
    oggSeeker = setupData.oggSeeker;
  } else if (input.getLength() == C.LENGTH_UNSET) {
    oggSeeker = new UnseekableOggSeeker();
  } else {
    OggPageHeader firstPayloadPageHeader = oggPacket.getPageHeader();
    oggSeeker = new DefaultOggSeeker(payloadStartPosition, input.getLength(), this,
        firstPayloadPageHeader.headerSize + firstPayloadPageHeader.bodySize,
        firstPayloadPageHeader.granulePosition);
  }

  setupData = null;
  state = STATE_READ_PAYLOAD;
  // First payload packet. Trim the payload array of the ogg packet after headers have been read.
  oggPacket.trimPayload();
  return Extractor.RESULT_CONTINUE;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:38,代码来源:StreamReader.java

示例15: readPayload

private int readPayload(ExtractorInput input, PositionHolder seekPosition)
    throws IOException, InterruptedException {
  long position = oggSeeker.read(input);
  if (position >= 0) {
    seekPosition.position = position;
    return Extractor.RESULT_SEEK;
  } else if (position < -1) {
    onSeekEnd(-(position + 2));
  }
  if (!seekMapSet) {
    SeekMap seekMap = oggSeeker.createSeekMap();
    extractorOutput.seekMap(seekMap);
    seekMapSet = true;
  }

  if (lengthOfReadPacket > 0 || oggPacket.populate(input)) {
    lengthOfReadPacket = 0;
    ParsableByteArray payload = oggPacket.getPayload();
    long granulesInPacket = preparePayload(payload);
    if (granulesInPacket >= 0 && currentGranule + granulesInPacket >= targetGranule) {
      // calculate time and send payload data to codec
      long timeUs = convertGranuleToTime(currentGranule);
      trackOutput.sampleData(payload, payload.limit());
      trackOutput.sampleMetadata(timeUs, C.BUFFER_FLAG_KEY_FRAME, payload.limit(), 0, null);
      targetGranule = -1;
    }
    currentGranule += granulesInPacket;
  } else {
    state = STATE_END_OF_INPUT;
    return Extractor.RESULT_END_OF_INPUT;
  }
  return Extractor.RESULT_CONTINUE;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:33,代码来源:StreamReader.java


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