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


Java Assertions.checkArgument方法代码示例

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


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

示例1: discardUpstreamSamples

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * Discards samples from the write side of the buffer.
 *
 * @param discardFromIndex The absolute index of the first sample to be discarded.
 * @return The reduced total number of bytes written, after the samples have been discarded.
 */
public long discardUpstreamSamples(int discardFromIndex) {
  int discardCount = getWriteIndex() - discardFromIndex;
  Assertions.checkArgument(0 <= discardCount && discardCount <= queueSize);

  if (discardCount == 0) {
    if (absoluteReadIndex == 0) {
      // queueSize == absoluteReadIndex == 0, so nothing has been written to the queue.
      return 0;
    }
    int lastWriteIndex = (relativeWriteIndex == 0 ? capacity : relativeWriteIndex) - 1;
    return offsets[lastWriteIndex] + sizes[lastWriteIndex];
  }

  queueSize -= discardCount;
  relativeWriteIndex = (relativeWriteIndex + capacity - discardCount) % capacity;
  return offsets[relativeWriteIndex];
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:24,代码来源:RollingSampleBuffer.java

示例2: parseSampleEntryEncryptionData

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * Parses encryption data from an audio/video sample entry, populating {@code out} and returning
 * the unencrypted atom type, or 0 if no sinf atom was present.
 */
private static int parseSampleEntryEncryptionData(ParsableByteArray parent, int position,
    int size, StsdData out, int entryIndex) {
  int childPosition = parent.getPosition();
  while (childPosition - position < size) {
    parent.setPosition(childPosition);
    int childAtomSize = parent.readInt();
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = parent.readInt();
    if (childAtomType == Atom.TYPE_sinf) {
      Pair<Integer, TrackEncryptionBox> result = parseSinfFromParent(parent, childPosition,
          childAtomSize);
      Integer dataFormat = result.first;
      Assertions.checkArgument(dataFormat != null, "frma atom is mandatory");
      out.trackEncryptionBoxes[entryIndex] = result.second;
      return dataFormat;
    }
    childPosition += childAtomSize;
  }
  // This enca/encv box does not have a data format so return an invalid atom type.
  return 0;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:26,代码来源:AtomParsers.java

示例3: DefaultAllocator

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * Constructs a pool with some {@link Allocation}s created up front.
 * <p>
 * Note: Initial {@link Allocation}s will never be discarded by {@link #trim(int)}.
 *
 * @param individualAllocationSize The length of each individual allocation.
 * @param initialAllocationCount The number of allocations to create up front.
 */
public DefaultAllocator(int individualAllocationSize, int initialAllocationCount) {
  Assertions.checkArgument(individualAllocationSize > 0);
  Assertions.checkArgument(initialAllocationCount >= 0);
  this.individualAllocationSize = individualAllocationSize;
  this.availableCount = initialAllocationCount;
  this.availableAllocations = new Allocation[initialAllocationCount + AVAILABLE_EXTRA_CAPACITY];
  if (initialAllocationCount > 0) {
    initialAllocationBlock = new byte[initialAllocationCount * individualAllocationSize];
    for (int i = 0; i < initialAllocationCount; i++) {
      int allocationOffset = i * individualAllocationSize;
      availableAllocations[i] = new Allocation(initialAllocationBlock, allocationOffset);
    }
  } else {
    initialAllocationBlock = null;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:25,代码来源:DefaultAllocator.java

示例4: open

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public DataSink open(DataSpec dataSpec) throws IOException {
  if (dataSpec.length == C.LENGTH_UNBOUNDED) {
    stream = new ByteArrayOutputStream();
  } else {
    Assertions.checkArgument(dataSpec.length <= Integer.MAX_VALUE);
    stream = new ByteArrayOutputStream((int) dataSpec.length);
  }
  return this;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:11,代码来源:ByteArrayDataSink.java

示例5: onEnabled

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
protected void onEnabled(int track, long positionUs, boolean joining) {
    Assertions.checkArgument(mTrackIndex != -1 && track == 0);
    mSource.enable(mTrackIndex, positionUs);
    mInputStreamEnded = false;
    mPresentationTimeUs = positionUs;
    mCurrentPositionUs = Long.MIN_VALUE;
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:9,代码来源:Cea708TextTrackRenderer.java

示例6: DataSpec

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * Construct a {@link DataSpec} where {@link #position} may differ from
 * {@link #absoluteStreamPosition}.
 *
 * @param uri {@link #uri}.
 * @param postBody {@link #postBody}.
 * @param absoluteStreamPosition {@link #absoluteStreamPosition}.
 * @param position {@link #position}.
 * @param length {@link #length}.
 * @param key {@link #key}.
 * @param flags {@link #flags}.
 */
public DataSpec(Uri uri, byte[] postBody, long absoluteStreamPosition, long position, long length,
    String key, int flags) {
  Assertions.checkArgument(absoluteStreamPosition >= 0);
  Assertions.checkArgument(position >= 0);
  Assertions.checkArgument(length > 0 || length == C.LENGTH_UNBOUNDED);
  this.uri = uri;
  this.postBody = postBody;
  this.absoluteStreamPosition = absoluteStreamPosition;
  this.position = position;
  this.length = length;
  this.key = key;
  this.flags = flags;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:26,代码来源:DataSpec.java

示例7: parseStsd

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
private static StsdDataHolder parseStsd(ParsableByteArray stsd, long durationUs) {
  stsd.setPosition(Atom.FULL_HEADER_SIZE);
  int numberOfEntries = stsd.readInt();
  StsdDataHolder holder = new StsdDataHolder(numberOfEntries);
  for (int i = 0; i < numberOfEntries; i++) {
    int childStartPosition = stsd.getPosition();
    int childAtomSize = stsd.readInt();
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = stsd.readInt();
    if (childAtomType == Atom.TYPE_avc1 || childAtomType == Atom.TYPE_avc3
        || childAtomType == Atom.TYPE_encv || childAtomType == Atom.TYPE_mp4v
        || childAtomType == Atom.TYPE_hvc1 || childAtomType == Atom.TYPE_hev1
        || childAtomType == Atom.TYPE_s263) {
      parseVideoSampleEntry(stsd, childStartPosition, childAtomSize, durationUs, holder, i);
    } else if (childAtomType == Atom.TYPE_mp4a || childAtomType == Atom.TYPE_enca
        || childAtomType == Atom.TYPE_ac_3) {
      parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, durationUs,
          holder, i);
    } else if (childAtomType == Atom.TYPE_TTML) {
      holder.mediaFormat = MediaFormat.createTextFormat(MimeTypes.APPLICATION_TTML, durationUs);
    } else if (childAtomType == Atom.TYPE_tx3g) {
      holder.mediaFormat = MediaFormat.createTextFormat(MimeTypes.APPLICATION_TX3G, durationUs);
    }
    stsd.setPosition(childStartPosition + childAtomSize);
  }
  return holder;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:28,代码来源:AtomParsers.java

示例8: TrackSampleTable

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
TrackSampleTable(long[] offsets, int[] sizes, int maximumSize, long[] timestampsUs, int[] flags) {
  Assertions.checkArgument(sizes.length == timestampsUs.length);
  Assertions.checkArgument(offsets.length == timestampsUs.length);
  Assertions.checkArgument(flags.length == timestampsUs.length);

  this.offsets = offsets;
  this.sizes = sizes;
  this.maximumSize = maximumSize;
  this.timestampsUs = timestampsUs;
  this.flags = flags;
  sampleCount = offsets.length;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:13,代码来源:TrackSampleTable.java

示例9: findEsdsPosition

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/** Returns the position of the esds box within a parent, or -1 if no esds box is found */
private static int findEsdsPosition(ParsableByteArray parent, int position, int size) {
  int childAtomPosition = parent.getPosition();
  while (childAtomPosition - position < size) {
    parent.setPosition(childAtomPosition);
    int childAtomSize = parent.readInt();
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childType = parent.readInt();
    if (childType == Atom.TYPE_esds) {
      return childAtomPosition;
    }
    childAtomPosition += childAtomSize;
  }
  return -1;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:16,代码来源:AtomParsers.java

示例10: getEventTime

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public long getEventTime(int index) {
  Assertions.checkArgument(index == 0);
  return 0;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:6,代码来源:Tx3gSubtitle.java

示例11: parseVideoSampleEntry

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
private static void parseVideoSampleEntry(ParsableByteArray parent, int position, int size,
    long durationUs, StsdDataHolder out, int entryIndex) {
  parent.setPosition(position + Atom.HEADER_SIZE);

  parent.skipBytes(24);
  int width = parent.readUnsignedShort();
  int height = parent.readUnsignedShort();
  float pixelWidthHeightRatio = 1;
  parent.skipBytes(50);

  List<byte[]> initializationData = null;
  int childPosition = parent.getPosition();
  String mimeType = null;
  while (childPosition - position < size) {
    parent.setPosition(childPosition);
    int childStartPosition = parent.getPosition();
    int childAtomSize = parent.readInt();
    if (childAtomSize == 0 && parent.getPosition() - position == size) {
      // Handle optional terminating four zero bytes in MOV files.
      break;
    }
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = parent.readInt();
    if (childAtomType == Atom.TYPE_avcC) {
      Assertions.checkState(mimeType == null);
      mimeType = MimeTypes.VIDEO_H264;
      Pair<List<byte[]>, Integer> avcCData = parseAvcCFromParent(parent, childStartPosition);
      initializationData = avcCData.first;
      out.nalUnitLengthFieldLength = avcCData.second;
    } else if (childAtomType == Atom.TYPE_hvcC) {
      Assertions.checkState(mimeType == null);
      mimeType = MimeTypes.VIDEO_H265;
      Pair<List<byte[]>, Integer> hvcCData = parseHvcCFromParent(parent, childStartPosition);
      initializationData = hvcCData.first;
      out.nalUnitLengthFieldLength = hvcCData.second;
    } else if (childAtomType == Atom.TYPE_d263) {
      Assertions.checkState(mimeType == null);
      mimeType = MimeTypes.VIDEO_H263;
    } else if (childAtomType == Atom.TYPE_esds) {
      Assertions.checkState(mimeType == null);
      Pair<String, byte[]> mimeTypeAndInitializationData =
          parseEsdsFromParent(parent, childStartPosition);
      mimeType = mimeTypeAndInitializationData.first;
      initializationData = Collections.singletonList(mimeTypeAndInitializationData.second);
    } else if (childAtomType == Atom.TYPE_sinf) {
      out.trackEncryptionBoxes[entryIndex] =
          parseSinfFromParent(parent, childStartPosition, childAtomSize);
    } else if (childAtomType == Atom.TYPE_pasp) {
      pixelWidthHeightRatio = parsePaspFromParent(parent, childStartPosition);
    }
    childPosition += childAtomSize;
  }

  // If the media type was not recognized, ignore the track.
  if (mimeType == null) {
    return;
  }

  out.mediaFormat = MediaFormat.createVideoFormat(mimeType, MediaFormat.NO_VALUE, durationUs,
      width, height, pixelWidthHeightRatio, initializationData);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:62,代码来源:AtomParsers.java

示例12: parseAudioSampleEntry

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
private static void parseAudioSampleEntry(ParsableByteArray parent, int atomType, int position,
    int size, long durationUs, StsdDataHolder out, int entryIndex) {
  parent.setPosition(position + Atom.HEADER_SIZE);
  parent.skipBytes(16);
  int channelCount = parent.readUnsignedShort();
  int sampleSize = parent.readUnsignedShort();
  parent.skipBytes(4);
  int sampleRate = parent.readUnsignedFixedPoint1616();

  // If the atom type determines a MIME type, set it immediately.
  String mimeType = null;
  if (atomType == Atom.TYPE_ac_3) {
    mimeType = MimeTypes.AUDIO_AC3;
  } else if (atomType == Atom.TYPE_ec_3) {
    mimeType = MimeTypes.AUDIO_EC3;
  }

  byte[] initializationData = null;
  int childPosition = parent.getPosition();
  while (childPosition - position < size) {
    parent.setPosition(childPosition);
    int childStartPosition = parent.getPosition();
    int childAtomSize = parent.readInt();
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = parent.readInt();
    if (atomType == Atom.TYPE_mp4a || atomType == Atom.TYPE_enca) {
      if (childAtomType == Atom.TYPE_esds) {
        Pair<String, byte[]> mimeTypeAndInitializationData =
            parseEsdsFromParent(parent, childStartPosition);
        mimeType = mimeTypeAndInitializationData.first;
        initializationData = mimeTypeAndInitializationData.second;
        if (MimeTypes.AUDIO_AAC.equals(mimeType)) {
          // TODO: Do we really need to do this? See [Internal: b/10903778]
          // Update sampleRate and channelCount from the AudioSpecificConfig initialization data.
          Pair<Integer, Integer> audioSpecificConfig =
              CodecSpecificDataUtil.parseAacAudioSpecificConfig(initializationData);
          sampleRate = audioSpecificConfig.first;
          channelCount = audioSpecificConfig.second;
        }
      } else if (childAtomType == Atom.TYPE_sinf) {
        out.trackEncryptionBoxes[entryIndex] = parseSinfFromParent(parent, childStartPosition,
            childAtomSize);
      }
    } else if (atomType == Atom.TYPE_ac_3 && childAtomType == Atom.TYPE_dac3) {
      // TODO: Choose the right AC-3 track based on the contents of dac3/dec3.
      // TODO: Add support for encryption (by setting out.trackEncryptionBoxes).
      parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
      out.mediaFormat = Ac3Util.parseAnnexFAc3Format(parent);
      return;
    } else if  (atomType == Atom.TYPE_ec_3 && childAtomType == Atom.TYPE_dec3) {
      parent.setPosition(Atom.HEADER_SIZE + childStartPosition);
      out.mediaFormat = Ac3Util.parseAnnexFEAc3Format(parent);
      return;
    }
    childPosition += childAtomSize;
  }

  // If the media type was not recognized, ignore the track.
  if (mimeType == null) {
    return;
  }

  out.mediaFormat = MediaFormat.createAudioFormat(mimeType, sampleSize, durationUs, channelCount,
      sampleRate,
      initializationData == null ? null : Collections.singletonList(initializationData));
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:67,代码来源:AtomParsers.java

示例13: getEventTime

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
@Override
public long getEventTime(int index) {
  Assertions.checkArgument(index == 0);
  return startTimeUs;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:6,代码来源:Tx3gSubtitle.java

示例14: parseVideoSampleEntry

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
private static void parseVideoSampleEntry(ParsableByteArray parent, int atomType, int position,
    int size, int trackId, long durationUs, int rotationDegrees, StsdData out, int entryIndex) {
  parent.setPosition(position + Atom.HEADER_SIZE);

  parent.skipBytes(24);
  int width = parent.readUnsignedShort();
  int height = parent.readUnsignedShort();
  boolean pixelWidthHeightRatioFromPasp = false;
  float pixelWidthHeightRatio = 1;
  parent.skipBytes(50);

  int childPosition = parent.getPosition();
  if (atomType == Atom.TYPE_encv) {
    parseSampleEntryEncryptionData(parent, position, size, out, entryIndex);
    parent.setPosition(childPosition);
  }

  List<byte[]> initializationData = null;
  String mimeType = null;
  while (childPosition - position < size) {
    parent.setPosition(childPosition);
    int childStartPosition = parent.getPosition();
    int childAtomSize = parent.readInt();
    if (childAtomSize == 0 && parent.getPosition() - position == size) {
      // Handle optional terminating four zero bytes in MOV files.
      break;
    }
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = parent.readInt();
    if (childAtomType == Atom.TYPE_avcC) {
      Assertions.checkState(mimeType == null);
      mimeType = MimeTypes.VIDEO_H264;
      AvcCData avcCData = parseAvcCFromParent(parent, childStartPosition);
      initializationData = avcCData.initializationData;
      out.nalUnitLengthFieldLength = avcCData.nalUnitLengthFieldLength;
      if (!pixelWidthHeightRatioFromPasp) {
        pixelWidthHeightRatio = avcCData.pixelWidthAspectRatio;
      }
    } else if (childAtomType == Atom.TYPE_hvcC) {
      Assertions.checkState(mimeType == null);
      mimeType = MimeTypes.VIDEO_H265;
      Pair<List<byte[]>, Integer> hvcCData = parseHvcCFromParent(parent, childStartPosition);
      initializationData = hvcCData.first;
      out.nalUnitLengthFieldLength = hvcCData.second;
    } else if (childAtomType == Atom.TYPE_d263) {
      Assertions.checkState(mimeType == null);
      mimeType = MimeTypes.VIDEO_H263;
    } else if (childAtomType == Atom.TYPE_esds) {
      Assertions.checkState(mimeType == null);
      Pair<String, byte[]> mimeTypeAndInitializationData =
          parseEsdsFromParent(parent, childStartPosition);
      mimeType = mimeTypeAndInitializationData.first;
      initializationData = Collections.singletonList(mimeTypeAndInitializationData.second);
    } else if (childAtomType == Atom.TYPE_pasp) {
      pixelWidthHeightRatio = parsePaspFromParent(parent, childStartPosition);
      pixelWidthHeightRatioFromPasp = true;
    }
    childPosition += childAtomSize;
  }

  // If the media type was not recognized, ignore the track.
  if (mimeType == null) {
    return;
  }

  out.mediaFormat = MediaFormat.createVideoFormat(Integer.toString(trackId), mimeType,
      MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, durationUs, width, height, initializationData,
      rotationDegrees, pixelWidthHeightRatio);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:70,代码来源:AtomParsers.java

示例15: ByteArrayDataSource

import com.google.android.exoplayer.util.Assertions; //导入方法依赖的package包/类
/**
 * @param data The data to be read.
 */
public ByteArrayDataSource(byte[] data) {
  Assertions.checkNotNull(data);
  Assertions.checkArgument(data.length > 0);
  this.data = data;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:9,代码来源:ByteArrayDataSource.java


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