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


Java Assertions类代码示例

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


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

示例1: readData

import com.google.android.exoplayer.util.Assertions; //导入依赖的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: open

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public long open(DataSpec dataSpec) throws IOException {
  Assertions.checkState(dataSource == null);
  // Choose the correct source for the scheme.
  String scheme = dataSpec.uri.getScheme();
  if (SCHEME_FILE.equals(scheme) || TextUtils.isEmpty(scheme)) {
    if (dataSpec.uri.getPath().startsWith("/android_asset/")) {
      dataSource = assetDataSource;
    } else {
      dataSource = fileDataSource;
    }
  } else if (SCHEME_ASSET.equals(scheme)) {
    dataSource = assetDataSource;
  } else if (SCHEME_CONTENT.equals(scheme)) {
    dataSource = contentDataSource;
  } else {
    dataSource = httpDataSource;
  }
  // Open the source and return.
  return dataSource.open(dataSpec);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:22,代码来源:DefaultUriDataSource.java

示例3: continueBuffering

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public boolean continueBuffering(int track, long playbackPositionUs) {
  Assertions.checkState(prepared);
  Assertions.checkState(trackEnabledStates[track]);
  downstreamPositionUs = playbackPositionUs;
  if (!extractors.isEmpty()) {
    discardSamplesForDisabledTracks(getCurrentExtractor(), downstreamPositionUs);
  }
  if (loadingFinished) {
    return true;
  }
  maybeStartLoading();
  if (isPendingReset() || extractors.isEmpty()) {
    return false;
  }
  for (int extractorIndex = 0; extractorIndex < extractors.size(); extractorIndex++) {
    HlsExtractorWrapper extractor = extractors.get(extractorIndex);
    if (!extractor.isPrepared()) {
      break;
    }
    if (extractor.hasSamples(track)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:27,代码来源:HlsSampleSource.java

示例4: endRepresentation

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
/**
 * Should be invoked after processing each child Representation element, in order to apply
 * consistency checks.
 */
public void endRepresentation() {
  if (!representationProtectionsSet) {
    if (currentRepresentationProtections != null) {
      Collections.sort(currentRepresentationProtections, this);
    }
    representationProtections = currentRepresentationProtections;
    representationProtectionsSet = true;
  } else {
    // Assert that each Representation element defines the same ContentProtection elements.
    if (currentRepresentationProtections == null) {
      Assertions.checkState(representationProtections == null);
    } else {
      Collections.sort(currentRepresentationProtections, this);
      Assertions.checkState(currentRepresentationProtections.equals(representationProtections));
    }
  }
  currentRepresentationProtections = null;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:23,代码来源:MediaPresentationDescriptionParser.java

示例5: getNextSeekPosition

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
/**
 * Returns a position converging to the {@code targetGranule} to which the {@link ExtractorInput}
 * has to seek and then be passed for another call until -1 is return. If -1 is returned the
 * input is at a position which is before the start of the page before the target page and at
 * which it is sensible to just skip pages to the target granule and pre-roll instead of doing
 * another seek request.
 *
 * @param targetGranule the target granule position to seek to.
 * @param input the {@link ExtractorInput} to read from.
 * @return the position to seek the {@link ExtractorInput} to for a next call or -1 if it's close
 *    enough to skip to the target page.
 * @throws IOException thrown if reading from the input fails.
 * @throws InterruptedException thrown if interrupted while reading from the input.
 */
public long getNextSeekPosition(long targetGranule, ExtractorInput input)
    throws IOException, InterruptedException {
  Assertions.checkState(audioDataLength != C.LENGTH_UNBOUNDED && totalSamples != 0);
  OggUtil.populatePageHeader(input, pageHeader, headerArray, false);
  long granuleDistance = targetGranule - pageHeader.granulePosition;
  if (granuleDistance <= 0 || granuleDistance > MATCH_RANGE) {
    // estimated position too high or too low
    long offset = (pageHeader.bodySize + pageHeader.headerSize)
        * (granuleDistance <= 0 ? 2 : 1);
    return input.getPosition() - offset + (granuleDistance * audioDataLength / totalSamples);
  }
  // position accepted (below target granule and within MATCH_RANGE)
  input.resetPeekPosition();
  return -1;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:30,代码来源:OggSeeker.java

示例6: seekToUs

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public void seekToUs(long positionUs) {
  Assertions.checkState(prepared);
  Assertions.checkState(enabledTrackCount > 0);
  // Treat all seeks into live streams as being to t=0.
  positionUs = chunkSource.isLive() ? 0 : positionUs;

  // Ignore seeks to the current position.
  long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs;
  downstreamPositionUs = positionUs;
  lastSeekPositionUs = positionUs;
  if (currentPositionUs == positionUs) {
    return;
  }

  seekToInternal(positionUs);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:18,代码来源:HlsSampleSource.java

示例7: disable

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public void disable(int track) {
  Assertions.checkState(prepared);
  Assertions.checkState(trackEnabledStates[track]);
  enabledTrackCount--;
  trackEnabledStates[track] = false;
  if (enabledTrackCount == 0) {
    downstreamPositionUs = Long.MIN_VALUE;
    if (loader.isLoading()) {
      loader.cancelLoading();
    } else {
      clearState();
      allocator.trim(0);
    }
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:17,代码来源:ExtractorSampleSource.java

示例8: onLoadCompleted

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public void onLoadCompleted(Loadable loadable) {
  Assertions.checkState(loadable == currentLoadable);
  long now = SystemClock.elapsedRealtime();
  long loadDurationMs = now - currentLoadStartTimeMs;
  chunkSource.onChunkLoadCompleted(currentLoadable);
  if (isTsChunk(currentLoadable)) {
    Assertions.checkState(currentLoadable == currentTsLoadable);
    previousTsLoadable = currentTsLoadable;
    notifyLoadCompleted(currentLoadable.bytesLoaded(), currentTsLoadable.type,
        currentTsLoadable.trigger, currentTsLoadable.format, currentTsLoadable.startTimeUs,
        currentTsLoadable.endTimeUs, now, loadDurationMs);
  } else {
    notifyLoadCompleted(currentLoadable.bytesLoaded(), currentLoadable.type,
        currentLoadable.trigger, currentLoadable.format, -1, -1, now, loadDurationMs);
  }
  clearCurrentLoadable();
  maybeStartLoading();
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:20,代码来源:HlsSampleSource.java

示例9: disable

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public void disable(int track) {
  Assertions.checkState(state == STATE_ENABLED);
  Assertions.checkState(--enabledTrackCount == 0);
  state = STATE_PREPARED;
  try {
    chunkSource.disable(mediaChunks);
  } finally {
    loadControl.unregister(this);
    if (loader.isLoading()) {
      loader.cancelLoading();
    } else {
      sampleQueue.clear();
      mediaChunks.clear();
      clearCurrentLoadable();
      loadControl.trimAllocator();
    }
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:20,代码来源:ChunkSampleSource.java

示例10: OkHttpDataSource

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
/**
 * @param userAgent            The User-Agent string that should be used.
 * @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
 *                             predicate then a {@link HttpDataSource.InvalidContentTypeException}
 *                             is thrown from {@link #open(DataSpec)}.
 * @param listener             An optional listener.
 * @param cacheControl         An optional {@link CacheControl} which sets all requests'
 *                             Cache-Control header. For example, you could force the network
 *                             response for all requests.
 */
private OkHttpDataSource(String userAgent, Predicate<String> contentTypePredicate,
                         TransferListener listener, CacheControl cacheControl) {
  DmlApplication.getInstance().getBackendComponent().inject(this);
  Assertions.checkNotNull(callFactory);
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.contentTypePredicate = contentTypePredicate;
  this.listener = listener;
  this.cacheControl = cacheControl;
  this.requestProperties = new HashMap<>();
}
 
开发者ID:mkjensen,项目名称:danish-media-license,代码行数:21,代码来源:OkHttpDataSource.java

示例11: ChunkIterator

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
public ChunkIterator(ParsableByteArray stsc, ParsableByteArray chunkOffsets,
    boolean chunkOffsetsAreLongs) {
  this.stsc = stsc;
  this.chunkOffsets = chunkOffsets;
  this.chunkOffsetsAreLongs = chunkOffsetsAreLongs;
  chunkOffsets.setPosition(Atom.FULL_HEADER_SIZE);
  length = chunkOffsets.readUnsignedIntToInt();
  stsc.setPosition(Atom.FULL_HEADER_SIZE);
  remainingSamplesPerChunkChanges = stsc.readUnsignedIntToInt();
  Assertions.checkState(stsc.readInt() == 1, "first_chunk must be 1");
  index = -1;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:13,代码来源:AtomParsers.java

示例12: enable

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public void enable(int track, long positionUs) {
  Assertions.checkState(prepared);
  setTrackEnabledState(track, true);
  downstreamMediaFormats[track] = null;
  pendingDiscontinuities[track] = false;
  downstreamFormat = null;
  boolean wasLoadControlRegistered = loadControlRegistered;
  if (!loadControlRegistered) {
    loadControl.register(this, bufferSizeContribution);
    loadControlRegistered = true;
  }
  // Treat enabling of a live stream as occurring at t=0 in both of the blocks below.
  positionUs = chunkSource.isLive() ? 0 : positionUs;
  int chunkSourceTrack = chunkSourceTrackIndices[track];
  if (chunkSourceTrack != -1 && chunkSourceTrack != chunkSource.getSelectedTrackIndex()) {
    // This is a primary track whose corresponding chunk source track is different to the one
    // currently selected. We need to change the selection and restart. Since other exposed tracks
    // may be enabled too, we need to implement the restart as a seek so that all downstream
    // renderers receive a discontinuity event.
    chunkSource.selectTrack(chunkSourceTrack);
    seekToInternal(positionUs);
    return;
  }
  if (enabledTrackCount == 1) {
    lastSeekPositionUs = positionUs;
    if (wasLoadControlRegistered && downstreamPositionUs == positionUs) {
      // TODO: Address [Internal: b/21743989] to remove the need for this kind of hack.
      // This is the first track to be enabled after preparation and the position is the same as
      // was passed to prepare. In this case we can avoid restarting, which would reload the same
      // chunks as were loaded during preparation.
      maybeStartLoading();
    } else {
      downstreamPositionUs = positionUs;
      restartFrom(positionUs);
    }
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:39,代码来源:HlsSampleSource.java

示例13: enable

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public void enable(int track, long positionUs) {
  Assertions.checkState(state == STATE_PREPARED);
  Assertions.checkState(enabledTrackCount++ == 0);
  state = STATE_ENABLED;
  chunkSource.enable(track);
  loadControl.register(this, bufferSizeContribution);
  downstreamFormat = null;
  downstreamMediaFormat = null;
  downstreamPositionUs = positionUs;
  lastSeekPositionUs = positionUs;
  pendingDiscontinuity = false;
  restartFrom(positionUs);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:15,代码来源:ChunkSampleSource.java

示例14: release

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public void release() {
  Assertions.checkState(remainingReleaseCount > 0);
  if (--remainingReleaseCount == 0 && extractor != null) {
    extractor.release();
    extractor = null;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:9,代码来源:FrameworkSampleSource.java

示例15: getBufferedPositionUs

import com.google.android.exoplayer.util.Assertions; //导入依赖的package包/类
@Override
public long getBufferedPositionUs() {
  Assertions.checkState(prepared);
  long bufferedDurationUs = extractor.getCachedDuration();
  if (bufferedDurationUs == -1) {
    return TrackRenderer.UNKNOWN_TIME_US;
  } else {
    long sampleTime = extractor.getSampleTime();
    return sampleTime == -1 ? TrackRenderer.END_OF_TRACK_US : sampleTime + bufferedDurationUs;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:12,代码来源:FrameworkSampleSource.java


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