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


Java ParsableByteArray.getPosition方法代码示例

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


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

示例1: maybeSkipComment

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static boolean maybeSkipComment(ParsableByteArray input) {
  int position = input.getPosition();
  int limit = input.limit();
  byte[] data = input.data;
  if (position + 2 <= limit && data[position++] == '/' && data[position++] == '*') {
    while (position + 1 < limit) {
      char skippedChar = (char) data[position++];
      if (skippedChar == '*') {
        if (((char) data[position]) == '/') {
          position++;
          limit = position;
        }
      }
    }
    input.skipBytes(limit - input.getPosition());
    return true;
  }
  return false;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:20,代码来源:CssParser.java

示例2: consume

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
@Override
public void consume(ParsableByteArray data) {
  if (writingSample) {
    if (bytesToCheck == 2 && !checkNextByte(data, 0x20)) {
      // Failed to check data_identifier
      return;
    }
    if (bytesToCheck == 1 && !checkNextByte(data, 0x00)) {
      // Check and discard the subtitle_stream_id
      return;
    }
    int dataPosition = data.getPosition();
    int bytesAvailable = data.bytesLeft();
    for (TrackOutput output : outputs) {
      data.setPosition(dataPosition);
      output.sampleData(data, bytesAvailable);
    }
    sampleBytesWritten += bytesAvailable;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:21,代码来源:DvbSubtitleReader.java

示例3: parseUdta

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Parses a udta atom.
 *
 * @param udtaAtom The udta (user data) atom to decode.
 * @param isQuickTime True for QuickTime media. False otherwise.
 * @return Parsed metadata, or null.
 */
public static Metadata parseUdta(Atom.LeafAtom udtaAtom, boolean isQuickTime) {
  if (isQuickTime) {
    // Meta boxes are regular boxes rather than full boxes in QuickTime. For now, don't try and
    // decode one.
    return null;
  }
  ParsableByteArray udtaData = udtaAtom.data;
  udtaData.setPosition(Atom.HEADER_SIZE);
  while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) {
    int atomPosition = udtaData.getPosition();
    int atomSize = udtaData.readInt();
    int atomType = udtaData.readInt();
    if (atomType == Atom.TYPE_meta) {
      udtaData.setPosition(atomPosition);
      return parseMetaAtom(udtaData, atomPosition + atomSize);
    }
    udtaData.skipBytes(atomSize - Atom.HEADER_SIZE);
  }
  return null;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:28,代码来源:AtomParsers.java

示例4: parseIdentifier

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static String parseIdentifier(ParsableByteArray input, StringBuilder stringBuilder) {
  stringBuilder.setLength(0);
  int position = input.getPosition();
  int limit = input.limit();
  boolean identifierEndFound = false;
  while (position  < limit && !identifierEndFound) {
    char c = (char) input.data[position];
    if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '#'
        || c == '-' || c == '.' || c == '_') {
      position++;
      stringBuilder.append(c);
    } else {
      identifierEndFound = true;
    }
  }
  input.skipBytes(position - input.getPosition());
  return stringBuilder.toString();
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:19,代码来源:CssParser.java

示例5: parsePropertyValue

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static String parsePropertyValue(ParsableByteArray input, StringBuilder stringBuilder) {
  StringBuilder expressionBuilder = new StringBuilder();
  String token;
  int position;
  boolean expressionEndFound = false;
  // TODO: Add support for "Strings in quotes with spaces".
  while (!expressionEndFound) {
    position = input.getPosition();
    token = parseNextToken(input, stringBuilder);
    if (token == null) {
      // Syntax error.
      return null;
    }
    if (BLOCK_END.equals(token) || ";".equals(token)) {
      input.setPosition(position);
      expressionEndFound = true;
    } else {
      expressionBuilder.append(token);
    }
  }
  return expressionBuilder.toString();
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:23,代码来源:CssParser.java

示例6: parseBlock

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Takes a CSS style block and consumes up to the first empty line found. Attempts to parse the
 * contents of the style block and returns a {@link WebvttCssStyle} instance if successful, or
 * {@code null} otherwise.
 *
 * @param input The input from which the style block should be read.
 * @return A {@link WebvttCssStyle} that represents the parsed block.
 */
public WebvttCssStyle parseBlock(ParsableByteArray input) {
  stringBuilder.setLength(0);
  int initialInputPosition = input.getPosition();
  skipStyleBlock(input);
  styleInput.reset(input.data, input.getPosition());
  styleInput.setPosition(initialInputPosition);
  String selector = parseSelector(styleInput, stringBuilder);
  if (selector == null || !BLOCK_START.equals(parseNextToken(styleInput, stringBuilder))) {
    return null;
  }
  WebvttCssStyle style = new WebvttCssStyle();
  applySelectorToStyle(style, selector);
  String token = null;
  boolean blockEndFound = false;
  while (!blockEndFound) {
    int position = styleInput.getPosition();
    token = parseNextToken(styleInput, stringBuilder);
    blockEndFound = token == null || BLOCK_END.equals(token);
    if (!blockEndFound) {
      styleInput.setPosition(position);
      parseStyleDeclaration(styleInput, style, stringBuilder);
    }
  }
  return BLOCK_END.equals(token) ? style : null; // Check that the style block ended correctly.
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:34,代码来源:CssParser.java

示例7: parseVttCueBox

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static Cue parseVttCueBox(ParsableByteArray sampleData, WebvttCue.Builder builder,
      int remainingCueBoxBytes) throws SubtitleDecoderException {
  builder.reset();
  while (remainingCueBoxBytes > 0) {
    if (remainingCueBoxBytes < BOX_HEADER_SIZE) {
      throw new SubtitleDecoderException("Incomplete vtt cue box header found.");
    }
    int boxSize = sampleData.readInt();
    int boxType = sampleData.readInt();
    remainingCueBoxBytes -= BOX_HEADER_SIZE;
    int payloadLength = boxSize - BOX_HEADER_SIZE;
    String boxPayload = new String(sampleData.data, sampleData.getPosition(), payloadLength);
    sampleData.skipBytes(payloadLength);
    remainingCueBoxBytes -= payloadLength;
    if (boxType == TYPE_sttg) {
      WebvttCueParser.parseCueSettingsList(boxPayload, builder);
    } else if (boxType == TYPE_payl) {
      WebvttCueParser.parseCueText(null, boxPayload.trim(), builder,
          Collections.<WebvttCssStyle>emptyList());
    } else {
      // Other VTTCueBox children are still not supported and are ignored.
    }
  }
  return builder.build();
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:26,代码来源:Mp4WebvttDecoder.java

示例8: decodeChapterFrame

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static ChapterFrame decodeChapterFrame(ParsableByteArray id3Data, int frameSize,
    int majorVersion, boolean unsignedIntFrameSizeHack, int frameHeaderSize,
    FramePredicate framePredicate) throws UnsupportedEncodingException {
  int framePosition = id3Data.getPosition();
  int chapterIdEndIndex = indexOfZeroByte(id3Data.data, framePosition);
  String chapterId = new String(id3Data.data, framePosition, chapterIdEndIndex - framePosition,
      "ISO-8859-1");
  id3Data.setPosition(chapterIdEndIndex + 1);

  int startTime = id3Data.readInt();
  int endTime = id3Data.readInt();
  long startOffset = id3Data.readUnsignedInt();
  if (startOffset == 0xFFFFFFFFL) {
    startOffset = C.POSITION_UNSET;
  }
  long endOffset = id3Data.readUnsignedInt();
  if (endOffset == 0xFFFFFFFFL) {
    endOffset = C.POSITION_UNSET;
  }

  ArrayList<Id3Frame> subFrames = new ArrayList<>();
  int limit = framePosition + frameSize;
  while (id3Data.getPosition() < limit) {
    Id3Frame frame = decodeFrame(majorVersion, id3Data, unsignedIntFrameSizeHack,
        frameHeaderSize, framePredicate);
    if (frame != null) {
      subFrames.add(frame);
    }
  }

  Id3Frame[] subFrameArray = new Id3Frame[subFrames.size()];
  subFrames.toArray(subFrameArray);
  return new ChapterFrame(chapterId, startTime, endTime, startOffset, endOffset, subFrameArray);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:35,代码来源:Id3Decoder.java

示例9: decode

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Decodes ID3 tags.
 *
 * @param data The bytes to decode ID3 tags from.
 * @param size Amount of bytes in {@code data} to read.
 * @return A {@link Metadata} object containing the decoded ID3 tags.
 */
public Metadata decode(byte[] data, int size) {
  List<Id3Frame> id3Frames = new ArrayList<>();
  ParsableByteArray id3Data = new ParsableByteArray(data, size);

  Id3Header id3Header = decodeHeader(id3Data);
  if (id3Header == null) {
    return null;
  }

  int startPosition = id3Data.getPosition();
  int frameHeaderSize = id3Header.majorVersion == 2 ? 6 : 10;
  int framesSize = id3Header.framesSize;
  if (id3Header.isUnsynchronized) {
    framesSize = removeUnsynchronization(id3Data, id3Header.framesSize);
  }
  id3Data.setLimit(startPosition + framesSize);

  boolean unsignedIntFrameSizeHack = false;
  if (!validateFrames(id3Data, id3Header.majorVersion, frameHeaderSize, false)) {
    if (id3Header.majorVersion == 4 && validateFrames(id3Data, 4, frameHeaderSize, true)) {
      unsignedIntFrameSizeHack = true;
    } else {
      Log.w(TAG, "Failed to validate ID3 tag with majorVersion=" + id3Header.majorVersion);
      return null;
    }
  }

  while (id3Data.bytesLeft() >= frameHeaderSize) {
    Id3Frame frame = decodeFrame(id3Header.majorVersion, id3Data, unsignedIntFrameSizeHack,
        frameHeaderSize, framePredicate);
    if (frame != null) {
      id3Frames.add(frame);
    }
  }

  return new Metadata(id3Frames);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:45,代码来源:Id3Decoder.java

示例10: parseMetaAtom

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
private static Metadata parseMetaAtom(ParsableByteArray meta, int limit) {
  meta.skipBytes(Atom.FULL_HEADER_SIZE);
  while (meta.getPosition() < limit) {
    int atomPosition = meta.getPosition();
    int atomSize = meta.readInt();
    int atomType = meta.readInt();
    if (atomType == Atom.TYPE_ilst) {
      meta.setPosition(atomPosition);
      return parseIlst(meta, atomPosition + atomSize);
    }
    meta.skipBytes(atomSize - Atom.HEADER_SIZE);
  }
  return null;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:15,代码来源:AtomParsers.java

示例11: removeUnsynchronization

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Performs in-place removal of unsynchronization for {@code length} bytes starting from
 * {@link ParsableByteArray#getPosition()}
 *
 * @param data Contains the data to be processed.
 * @param length The length of the data to be processed.
 * @return The length of the data after processing.
 */
private static int removeUnsynchronization(ParsableByteArray data, int length) {
  byte[] bytes = data.data;
  for (int i = data.getPosition(); i + 1 < length; i++) {
    if ((bytes[i] & 0xFF) == 0xFF && bytes[i + 1] == 0x00) {
      System.arraycopy(bytes, i + 2, bytes, i + 1, length - i - 2);
      length--;
    }
  }
  return length;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:19,代码来源:Id3Decoder.java

示例12: parseStsd

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Parses a stsd atom (defined in 14496-12).
 *
 * @param stsd The stsd atom to decode.
 * @param trackId The track's identifier in its container.
 * @param rotationDegrees The rotation of the track in degrees.
 * @param language The language of the track.
 * @param drmInitData {@link DrmInitData} to be included in the format.
 * @param isQuickTime True for QuickTime media. False otherwise.
 * @return An object containing the parsed data.
 */
private static StsdData parseStsd(ParsableByteArray stsd, int trackId, int rotationDegrees,
    String language, DrmInitData drmInitData, boolean isQuickTime) throws ParserException {
  stsd.setPosition(Atom.FULL_HEADER_SIZE);
  int numberOfEntries = stsd.readInt();
  StsdData out = new StsdData(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 || childAtomType == Atom.TYPE_vp08
        || childAtomType == Atom.TYPE_vp09) {
      parseVideoSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId,
          rotationDegrees, drmInitData, out, i);
    } else if (childAtomType == Atom.TYPE_mp4a || childAtomType == Atom.TYPE_enca
        || childAtomType == Atom.TYPE_ac_3 || childAtomType == Atom.TYPE_ec_3
        || childAtomType == Atom.TYPE_dtsc || childAtomType == Atom.TYPE_dtse
        || childAtomType == Atom.TYPE_dtsh || childAtomType == Atom.TYPE_dtsl
        || childAtomType == Atom.TYPE_samr || childAtomType == Atom.TYPE_sawb
        || childAtomType == Atom.TYPE_lpcm || childAtomType == Atom.TYPE_sowt
        || childAtomType == Atom.TYPE__mp3 || childAtomType == Atom.TYPE_alac) {
      parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId,
          language, isQuickTime, drmInitData, out, i);
    } else if (childAtomType == Atom.TYPE_TTML || childAtomType == Atom.TYPE_tx3g
        || childAtomType == Atom.TYPE_wvtt || childAtomType == Atom.TYPE_stpp
        || childAtomType == Atom.TYPE_c608) {
      parseTextSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId,
          language, drmInitData, out);
    } else if (childAtomType == Atom.TYPE_camm) {
      out.format = Format.createSampleFormat(Integer.toString(trackId),
          MimeTypes.APPLICATION_CAMERA_MOTION, null, Format.NO_VALUE, drmInitData);
    }
    stsd.setPosition(childStartPosition + childAtomSize);
  }
  return out;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:51,代码来源:AtomParsers.java

示例13: findEsdsPosition

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Returns the position of the esds box within a parent, or {@link C#POSITION_UNSET} 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 C.POSITION_UNSET;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:19,代码来源:AtomParsers.java

示例14: parseSampleEntryEncryptionData

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Parses encryption data from an audio/video sample entry, populating {@code out} and returning
 * the unencrypted atom type, or 0 if no common encryption 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);
      if (result != null) {
        out.trackEncryptionBoxes[entryIndex] = result.second;
        return result.first;
      }
    }
    childPosition += childAtomSize;
  }
  // This enca/encv box does not have a data format so return an invalid atom type.
  return 0;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:26,代码来源:AtomParsers.java

示例15: parseFourCcVc1Private

import com.google.android.exoplayer2.util.ParsableByteArray; //导入方法依赖的package包/类
/**
 * Builds initialization data for a {@link Format} from FourCC codec private data.
 * <p>
 * VC1 is the only supported compression type.
 *
 * @return The initialization data for the {@link Format}, or null if the compression type is
 *     not VC1.
 * @throws ParserException If the initialization data could not be built.
 */
private static List<byte[]> parseFourCcVc1Private(ParsableByteArray buffer)
    throws ParserException {
  try {
    buffer.skipBytes(16); // size(4), width(4), height(4), planes(2), bitcount(2).
    long compression = buffer.readLittleEndianUnsignedInt();
    if (compression != FOURCC_COMPRESSION_VC1) {
      return null;
    }

    // Search for the initialization data from the end of the BITMAPINFOHEADER. The last 20
    // bytes of which are: sizeImage(4), xPel/m (4), yPel/m (4), clrUsed(4), clrImportant(4).
    int startOffset = buffer.getPosition() + 20;
    byte[] bufferData = buffer.data;
    for (int offset = startOffset; offset < bufferData.length - 4; offset++) {
      if (bufferData[offset] == 0x00 && bufferData[offset + 1] == 0x00
          && bufferData[offset + 2] == 0x01 && bufferData[offset + 3] == 0x0F) {
        // We've found the initialization data.
        byte[] initializationData = Arrays.copyOfRange(bufferData, offset, bufferData.length);
        return Collections.singletonList(initializationData);
      }
    }

    throw new ParserException("Failed to find FourCC VC1 initialization data");
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ParserException("Error parsing FourCC VC1 codec private");
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:37,代码来源:MatroskaExtractor.java


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