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


Java C类代码示例

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


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

示例1: readData

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public int readData(int track, long positionUs, MediaFormatHolder formatHolder,
  SampleHolder sampleHolder) {
    Assertions.checkState(mPrepared);
    Assertions.checkState(mTrackStates.get(track) != TRACK_STATE_DISABLED);
    if (mPendingDiscontinuities.get(track)) {
        return NOTHING_READ;
    }
    if (mTrackStates.get(track) != TRACK_STATE_FORMAT_SENT) {
        mSampleExtractor.getTrackMediaFormat(track, formatHolder);
        mTrackStates.set(track, TRACK_STATE_FORMAT_SENT);
        return FORMAT_READ;
    }

    mPendingSeekPositionUs = C.UNKNOWN_TIME_US;
    return mSampleExtractor.readSample(track, sampleHolder);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:18,代码来源:MpegTsSampleSource.java

示例2: testParsesValidMp4File

import com.google.android.exoplayer.C; //导入依赖的package包/类
public void testParsesValidMp4File() throws Exception {
  TestUtil.consumeTestData(extractor,
      getTestInputData(true /* includeStss */, false /* mp4vFormat */));

  // The seek map is correct.
  assertSeekMap(extractorOutput.seekMap, true);

  // The video and audio formats are set correctly.
  assertEquals(2, extractorOutput.trackOutputs.size());
  MediaFormat videoFormat = extractorOutput.trackOutputs.get(0).format;
  MediaFormat audioFormat = extractorOutput.trackOutputs.get(1).format;
  assertEquals(MimeTypes.VIDEO_H264, videoFormat.mimeType);
  assertEquals(VIDEO_WIDTH, videoFormat.width);
  assertEquals(VIDEO_HEIGHT, videoFormat.height);
  assertEquals(MimeTypes.AUDIO_AAC, audioFormat.mimeType);

  // The timestamps and sizes are set correctly.
  FakeTrackOutput videoTrackOutput = extractorOutput.trackOutputs.get(0);
  videoTrackOutput.assertSampleCount(SAMPLE_TIMESTAMPS.length);
  for (int i = 0; i < SAMPLE_TIMESTAMPS.length; i++) {
    byte[] sampleData = getOutputSampleData(i, true);
    int sampleFlags = SAMPLE_IS_SYNC[i] ? C.SAMPLE_FLAG_SYNC : 0;
    long sampleTimestampUs = getVideoTimestampUs(SAMPLE_TIMESTAMPS[i]);
    videoTrackOutput.assertSample(i, sampleData, sampleTimestampUs, sampleFlags, null);
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:27,代码来源:Mp4ExtractorTest.java

示例3: readInternal

import com.google.android.exoplayer.C; //导入依赖的package包/类
/**
 * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at
 * index {@code offset}.
 * <p>
 * This method blocks until at least one byte of data can be read, the end of the opened range is
 * detected, or an exception is thrown.
 *
 * @param buffer The buffer into which the read data should be stored.
 * @param offset The start offset into {@code buffer} at which data should be written.
 * @param readLength The maximum number of bytes to read.
 * @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
 *     range is reached.
 * @throws IOException If an error occurs reading from the source.
 */
private int readInternal(byte[] buffer, int offset, int readLength) throws IOException {
  readLength = bytesToRead == C.LENGTH_UNBOUNDED ? readLength
      : (int) Math.min(readLength, bytesToRead - bytesRead);
  if (readLength == 0) {
    // We've read all of the requested data.
    return C.RESULT_END_OF_INPUT;
  }

  int read = inputStream.read(buffer, offset, readLength);
  if (read == -1) {
    if (bytesToRead != C.LENGTH_UNBOUNDED && bytesToRead != bytesRead) {
      // The server closed the connection having not sent sufficient data.
      throw new EOFException();
    }
    return C.RESULT_END_OF_INPUT;
  }

  bytesRead += read;
  if (listener != null) {
    listener.onBytesTransferred(read);
  }
  return read;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:38,代码来源:DefaultHttpDataSource.java

示例4: appendData

import com.google.android.exoplayer.C; //导入依赖的package包/类
/**
 * Appends data to the rolling buffer.
 *
 * @param dataSource The source from which to read.
 * @param length The maximum length of the read.
 * @param allowEndOfInput True if encountering the end of the input having appended no data is
 *     allowed, and should result in {@link C#RESULT_END_OF_INPUT} being returned. False if it
 *     should be considered an error, causing an {@link EOFException} to be thrown.
 * @return The number of bytes appended, or {@link C#RESULT_END_OF_INPUT} if the input has ended.
 * @throws IOException If an error occurs reading from the source.
 */
public int appendData(DataSource dataSource, int length, boolean allowEndOfInput)
    throws IOException {
  length = prepareForAppend(length);
  int bytesAppended = dataSource.read(lastAllocation.data,
      lastAllocation.translateOffset(lastAllocationOffset), length);
  if (bytesAppended == C.RESULT_END_OF_INPUT) {
    if (allowEndOfInput) {
      return C.RESULT_END_OF_INPUT;
    }
    throw new EOFException();
  }
  lastAllocationOffset += bytesAppended;
  totalBytesWritten += bytesAppended;
  return bytesAppended;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:27,代码来源:RollingSampleBuffer.java

示例5: StreamElement

import com.google.android.exoplayer.C; //导入依赖的package包/类
public StreamElement(String baseUri, String chunkTemplate, int type, String subType,
    long timescale, String name, int qualityLevels, int maxWidth, int maxHeight,
    int displayWidth, int displayHeight, String language, TrackElement[] tracks,
    List<Long> chunkStartTimes, long lastChunkDuration) {
  this.baseUri = baseUri;
  this.chunkTemplate = chunkTemplate;
  this.type = type;
  this.subType = subType;
  this.timescale = timescale;
  this.name = name;
  this.qualityLevels = qualityLevels;
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  this.displayWidth = displayWidth;
  this.displayHeight = displayHeight;
  this.language = language;
  this.tracks = tracks;
  this.chunkCount = chunkStartTimes.size();
  this.chunkStartTimes = chunkStartTimes;
  lastChunkDurationUs =
      Util.scaleLargeTimestamp(lastChunkDuration, C.MICROS_PER_SECOND, timescale);
  chunkStartTimesUs =
      Util.scaleLargeTimestamps(chunkStartTimes, C.MICROS_PER_SECOND, timescale);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:25,代码来源:SmoothStreamingManifest.java

示例6: consume

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public void consume(ParsableByteArray seiBuffer, long pesTimeUs, boolean startOfPacket) {
  int b;
  while (seiBuffer.bytesLeft() > 1 /* last byte will be rbsp_trailing_bits */) {
    // Parse payload type.
    int payloadType = 0;
    do {
      b = seiBuffer.readUnsignedByte();
      payloadType += b;
    } while (b == 0xFF);
    // Parse payload size.
    int payloadSize = 0;
    do {
      b = seiBuffer.readUnsignedByte();
      payloadSize += b;
    } while (b == 0xFF);
    // Process the payload. We only support EIA-608 payloads currently.
    if (Eia608Parser.isSeiMessageEia608(payloadType, payloadSize, seiBuffer)) {
      output.sampleData(seiBuffer, payloadSize);
      output.sampleMetadata(pesTimeUs, C.SAMPLE_FLAG_SYNC, payloadSize, 0, null);
    } else {
      seiBuffer.skipBytes(payloadSize);
    }
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:26,代码来源:SeiReader.java

示例7: read

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public int read(byte[] target, int offset, int length) throws IOException, InterruptedException {
  if (Thread.interrupted()) {
    throw new InterruptedException();
  }
  int peekBytes = Math.min(peekBufferLength, length);
  System.arraycopy(peekBuffer, 0, target, offset, peekBytes);
  offset += peekBytes;
  length -= peekBytes;
  int bytesRead = length != 0 ? dataSource.read(target, offset, length) : 0;
  if (bytesRead == C.RESULT_END_OF_INPUT) {
    return C.RESULT_END_OF_INPUT;
  }
  updatePeekBuffer(peekBytes);
  bytesRead += peekBytes;
  position += bytesRead;
  return bytesRead;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:19,代码来源:DefaultExtractorInput.java

示例8: readFully

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public boolean readFully(byte[] target, int offset, int length, boolean allowEndOfInput)
    throws IOException, InterruptedException {
  int peekBytes = Math.min(peekBufferLength, length);
  System.arraycopy(peekBuffer, 0, target, offset, peekBytes);
  offset += peekBytes;
  int remaining = length - peekBytes;
  while (remaining > 0) {
    if (Thread.interrupted()) {
      throw new InterruptedException();
    }
    int bytesRead = dataSource.read(target, offset, remaining);
    if (bytesRead == C.RESULT_END_OF_INPUT) {
      if (allowEndOfInput && remaining == length) {
        return false;
      }
      throw new EOFException();
    }
    offset += bytesRead;
    remaining -= bytesRead;
  }
  updatePeekBuffer(peekBytes);
  position += length;
  return true;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:26,代码来源:DefaultExtractorInput.java

示例9: skipFully

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public void skipFully(int length) throws IOException, InterruptedException {
  int peekBytes = Math.min(peekBufferLength, length);
  int remaining = length - peekBytes;
  while (remaining > 0) {
    if (Thread.interrupted()) {
      throw new InterruptedException();
    }
    int bytesRead = dataSource.read(SCRATCH_SPACE, 0, Math.min(SCRATCH_SPACE.length, remaining));
    if (bytesRead == C.RESULT_END_OF_INPUT) {
      throw new EOFException();
    }
    remaining -= bytesRead;
  }
  updatePeekBuffer(peekBytes);
  position += length;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:18,代码来源:DefaultExtractorInput.java

示例10: open

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public long open(DataSpec dataSpec) throws FileDataSourceException {
  try {
    uriString = dataSpec.uri.toString();
    file = new RandomAccessFile(dataSpec.uri.getPath(), "r");
    file.seek(dataSpec.position);
    bytesRemaining = dataSpec.length == C.LENGTH_UNBOUNDED ? file.length() - dataSpec.position
        : dataSpec.length;
    if (bytesRemaining < 0) {
      throw new EOFException();
    }
  } catch (IOException e) {
    throw new FileDataSourceException(e);
  }

  opened = true;
  if (listener != null) {
    listener.onTransferStart();
  }

  return bytesRemaining;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:23,代码来源:FileDataSource.java

示例11: fixedTrack

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public void fixedTrack(MediaPresentationDescription manifest, int periodIndex,
    int adaptationSetIndex, int representationIndex) {
  List<AdaptationSet> adaptationSets = manifest.getPeriod(periodIndex).adaptationSets;
  AdaptationSet adaptationSet = adaptationSets.get(adaptationSetIndex);
  Format representationFormat = adaptationSet.representations.get(representationIndex).format;
  String mediaMimeType = getMediaMimeType(representationFormat);
  if (mediaMimeType == null) {
    Log.w(TAG, "Skipped track " + representationFormat.id + " (unknown media mime type)");
    return;
  }
  MediaFormat trackFormat = getTrackFormat(adaptationSet.type, representationFormat,
      mediaMimeType, manifest.dynamic ? C.UNKNOWN_TIME_US : manifest.duration * 1000);
  if (trackFormat == null) {
    Log.w(TAG, "Skipped track " + representationFormat.id + " (unknown media format)");
    return;
  }
  tracks.add(new ExposedTrack(trackFormat, adaptationSetIndex, representationFormat));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:20,代码来源:DashChunkSource.java

示例12: consume

import com.google.android.exoplayer.C; //导入依赖的package包/类
public void consume(long pesTimeUs, ParsableByteArray seiBuffer) {
  int b;
  while (seiBuffer.bytesLeft() > 1 /* last byte will be rbsp_trailing_bits */) {
    // Parse payload type.
    int payloadType = 0;
    do {
      b = seiBuffer.readUnsignedByte();
      payloadType += b;
    } while (b == 0xFF);
    // Parse payload size.
    int payloadSize = 0;
    do {
      b = seiBuffer.readUnsignedByte();
      payloadSize += b;
    } while (b == 0xFF);
    // Process the payload.
    if (Eia608Parser.isSeiMessageEia608(payloadType, payloadSize, seiBuffer)) {
      output.sampleData(seiBuffer, payloadSize);
      output.sampleMetadata(pesTimeUs, C.SAMPLE_FLAG_SYNC, payloadSize, 0, null);
    } else {
      seiBuffer.skipBytes(payloadSize);
    }
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:25,代码来源:SeiReader.java

示例13: read

import com.google.android.exoplayer.C; //导入依赖的package包/类
@Override
public int read(byte[] buffer, int offset, int max) throws IOException {
  try {
    int bytesRead = currentDataSource.read(buffer, offset, max);
    if (bytesRead >= 0) {
      if (currentDataSource == cacheReadDataSource) {
        totalCachedBytesRead += bytesRead;
      }
      readPosition += bytesRead;
      if (bytesRemaining != C.LENGTH_UNBOUNDED) {
        bytesRemaining -= bytesRead;
      }
    } else {
      closeCurrentSource();
      if (bytesRemaining > 0 && bytesRemaining != C.LENGTH_UNBOUNDED) {
        openNextSource();
        return read(buffer, offset, max);
      }
    }
    return bytesRead;
  } catch (IOException e) {
    handleBeforeThrow(e);
    throw e;
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:26,代码来源:CacheDataSource.java

示例14: readInternal

import com.google.android.exoplayer.C; //导入依赖的package包/类
/**
 * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at
 * index {@code offset}.
 * <p>
 * This method blocks until at least one byte of data can be read, the end of the opened range is
 * detected, or an exception is thrown.
 *
 * @param buffer The buffer into which the read data should be stored.
 * @param offset The start offset into {@code buffer} at which data should be written.
 * @param readLength The maximum number of bytes to read.
 * @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
 *     range is reached.
 * @throws IOException If an error occurs reading from the source.
 */
private int readInternal(byte[] buffer, int offset, int readLength) throws IOException {
  readLength = bytesToRead == C.LENGTH_UNBOUNDED ? readLength
      : (int) Math.min(readLength, bytesToRead - bytesRead);
  if (readLength == 0) {
    // We've read all of the requested data.
    return C.RESULT_END_OF_INPUT;
  }

  int read = responseByteStream.read(buffer, offset, readLength);
  if (read == -1) {
    if (bytesToRead != C.LENGTH_UNBOUNDED && bytesToRead != bytesRead) {
      // The server closed the connection having not sent sufficient data.
      throw new EOFException();
    }
    return C.RESULT_END_OF_INPUT;
  }

  bytesRead += read;
  if (listener != null) {
    listener.onBytesTransferred(read);
  }
  return read;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:38,代码来源:OkHttpDataSource.java

示例15: readInternal

import com.google.android.exoplayer.C; //导入依赖的package包/类
/**
 * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at index
 * {@code offset}.
 *
 * <p>This method blocks until at least one byte of data can be read, the end of the opened range
 * is detected, or an exception is thrown.
 *
 * @param buffer     The buffer into which the read data should be stored.
 * @param offset     The start offset into {@code buffer} at which data should be written.
 * @param readLength The maximum number of bytes to read.
 * @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
 *     range is reached.
 * @throws IOException If an error occurs reading from the source.
 */
private int readInternal(byte[] buffer, int offset, int readLength) throws IOException {
  readLength = bytesToRead == C.LENGTH_UNBOUNDED ? readLength
      : (int) Math.min(readLength, bytesToRead - bytesRead);
  if (readLength == 0) {
    // We've read all of the requested data.
    return C.RESULT_END_OF_INPUT;
  }

  int read = responseByteStream.read(buffer, offset, readLength);
  if (read == -1) {
    if (bytesToRead != C.LENGTH_UNBOUNDED && bytesToRead != bytesRead) {
      // The server closed the connection having not sent sufficient data.
      throw new EOFException();
    }
    return C.RESULT_END_OF_INPUT;
  }

  bytesRead += read;
  if (listener != null) {
    listener.onBytesTransferred(read);
  }
  return read;
}
 
开发者ID:mkjensen,项目名称:danish-media-license,代码行数:38,代码来源:OkHttpDataSource.java


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