本文整理汇总了Java中com.google.android.exoplayer2.C.POSITION_UNSET属性的典型用法代码示例。如果您正苦于以下问题:Java C.POSITION_UNSET属性的具体用法?Java C.POSITION_UNSET怎么用?Java C.POSITION_UNSET使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.exoplayer2.C
的用法示例。
在下文中一共展示了C.POSITION_UNSET属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: maybeSeekForCues
/**
* Updates the position of the holder to Cues element's position if the extractor configuration
* permits use of master seek entry. After building Cues sets the holder's position back to where
* it was before.
*
* @param seekPosition The holder whose position will be updated.
* @param currentPosition Current position of the input.
* @return Whether the seek position was updated.
*/
private boolean maybeSeekForCues(PositionHolder seekPosition, long currentPosition) {
if (seekForCues) {
seekPositionAfterBuildingCues = currentPosition;
seekPosition.position = cuesContentPosition;
seekForCues = false;
return true;
}
// After parsing Cues, seek back to original position if available. We will not do this unless
// we seeked to get to the Cues in the first place.
if (sentSeekMap && seekPositionAfterBuildingCues != C.POSITION_UNSET) {
seekPosition.position = seekPositionAfterBuildingCues;
seekPositionAfterBuildingCues = C.POSITION_UNSET;
return true;
}
return false;
}
示例2: append
public void append(char text) {
if (text == '\n') {
rolledUpCaptions.add(buildSpannableString());
captionStringBuilder.clear();
if (italicsStartPosition != C.POSITION_UNSET) {
italicsStartPosition = 0;
}
if (underlineStartPosition != C.POSITION_UNSET) {
underlineStartPosition = 0;
}
if (foregroundColorStartPosition != C.POSITION_UNSET) {
foregroundColorStartPosition = 0;
}
if (backgroundColorStartPosition != C.POSITION_UNSET) {
backgroundColorStartPosition = 0;
}
while ((rowLock && (rolledUpCaptions.size() >= rowCount))
|| (rolledUpCaptions.size() >= MAXIMUM_ROW_COUNT)) {
rolledUpCaptions.remove(0);
}
} else {
captionStringBuilder.append(text);
}
}
示例3: findEsdsPosition
/**
* 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;
}
示例4: buildSeekMap
/**
* Builds a {@link SeekMap} from the recently gathered Cues information.
*
* @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
* information was missing or incomplete.
*/
private SeekMap buildSeekMap() {
if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
|| cueTimesUs == null || cueTimesUs.size() == 0
|| cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
// Cues information is missing or incomplete.
cueTimesUs = null;
cueClusterPositions = null;
return new SeekMap.Unseekable(durationUs);
}
int cuePointsSize = cueTimesUs.size();
int[] sizes = new int[cuePointsSize];
long[] offsets = new long[cuePointsSize];
long[] durationsUs = new long[cuePointsSize];
long[] timesUs = new long[cuePointsSize];
for (int i = 0; i < cuePointsSize; i++) {
timesUs[i] = cueTimesUs.get(i);
offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
}
for (int i = 0; i < cuePointsSize - 1; i++) {
sizes[i] = (int) (offsets[i + 1] - offsets[i]);
durationsUs[i] = timesUs[i + 1] - timesUs[i];
}
sizes[cuePointsSize - 1] =
(int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
cueTimesUs = null;
cueClusterPositions = null;
return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
示例5: skipAll
/**
* Skips all samples currently in the buffer.
*/
public void skipAll() {
long nextOffset = infoQueue.skipAll();
if (nextOffset != C.POSITION_UNSET) {
dropDownstreamTo(nextOffset);
}
}
示例6: skipToKeyframeBefore
/**
* Attempts to locate the keyframe before or at the specified time. If
* {@code allowTimeBeyondBuffer} is {@code false} then it is also required that {@code timeUs}
* falls within the buffer.
*
* @param timeUs The seek time.
* @param allowTimeBeyondBuffer Whether the skip can succeed if {@code timeUs} is beyond the end
* of the buffer.
* @return The offset of the keyframe's data if the keyframe was present.
* {@link C#POSITION_UNSET} otherwise.
*/
public synchronized long skipToKeyframeBefore(long timeUs, boolean allowTimeBeyondBuffer) {
if (queueSize == 0 || timeUs < timesUs[relativeReadIndex]) {
return C.POSITION_UNSET;
}
if (timeUs > largestQueuedTimestampUs && !allowTimeBeyondBuffer) {
return C.POSITION_UNSET;
}
// This could be optimized to use a binary search, however in practice callers to this method
// often pass times near to the start of the buffer. Hence it's unclear whether switching to
// a binary search would yield any real benefit.
int sampleCount = 0;
int sampleCountToKeyframe = -1;
int searchIndex = relativeReadIndex;
while (searchIndex != relativeWriteIndex) {
if (timesUs[searchIndex] > timeUs) {
// We've gone too far.
break;
} else if ((flags[searchIndex] & C.BUFFER_FLAG_KEY_FRAME) != 0) {
// We've found a keyframe, and we're still before the seek position.
sampleCountToKeyframe = sampleCount;
}
searchIndex = (searchIndex + 1) % capacity;
sampleCount++;
}
if (sampleCountToKeyframe == -1) {
return C.POSITION_UNSET;
}
relativeReadIndex = (relativeReadIndex + sampleCountToKeyframe) % capacity;
absoluteReadIndex += sampleCountToKeyframe;
queueSize -= sampleCountToKeyframe;
return offsets[relativeReadIndex];
}
示例7: clear
public void clear() {
rolledUpCaptions.clear();
captionStringBuilder.clear();
italicsStartPosition = C.POSITION_UNSET;
underlineStartPosition = C.POSITION_UNSET;
foregroundColorStartPosition = C.POSITION_UNSET;
backgroundColorStartPosition = C.POSITION_UNSET;
row = 0;
}
示例8: setPenAttributes
public void setPenAttributes(int textTag, int offset, int penSize, boolean italicsToggle,
boolean underlineToggle, int edgeType, int fontStyle) {
// TODO: Add support for text tags.
// TODO: Add support for other offsets.
// TODO: Add support for other pen sizes.
if (italicsStartPosition != C.POSITION_UNSET) {
if (!italicsToggle) {
captionStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition,
captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
italicsStartPosition = C.POSITION_UNSET;
}
} else if (italicsToggle) {
italicsStartPosition = captionStringBuilder.length();
}
if (underlineStartPosition != C.POSITION_UNSET) {
if (!underlineToggle) {
captionStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition,
captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
underlineStartPosition = C.POSITION_UNSET;
}
} else if (underlineToggle) {
underlineStartPosition = captionStringBuilder.length();
}
// TODO: Add support for edge types.
// TODO: Add support for other font styles.
}
示例9: setPenColor
public void setPenColor(int foregroundColor, int backgroundColor, int edgeColor) {
if (foregroundColorStartPosition != C.POSITION_UNSET) {
if (this.foregroundColor != foregroundColor) {
captionStringBuilder.setSpan(new ForegroundColorSpan(this.foregroundColor),
foregroundColorStartPosition, captionStringBuilder.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
if (foregroundColor != COLOR_SOLID_WHITE) {
foregroundColorStartPosition = captionStringBuilder.length();
this.foregroundColor = foregroundColor;
}
if (backgroundColorStartPosition != C.POSITION_UNSET) {
if (this.backgroundColor != backgroundColor) {
captionStringBuilder.setSpan(new BackgroundColorSpan(this.backgroundColor),
backgroundColorStartPosition, captionStringBuilder.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
if (backgroundColor != COLOR_SOLID_BLACK) {
backgroundColorStartPosition = captionStringBuilder.length();
this.backgroundColor = backgroundColor;
}
// TODO: Add support for edge color.
}
示例10: buildSpannableString
public SpannableString buildSpannableString() {
SpannableStringBuilder spannableStringBuilder =
new SpannableStringBuilder(captionStringBuilder);
int length = spannableStringBuilder.length();
if (length > 0) {
if (italicsStartPosition != C.POSITION_UNSET) {
spannableStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition,
length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (underlineStartPosition != C.POSITION_UNSET) {
spannableStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition,
length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (foregroundColorStartPosition != C.POSITION_UNSET) {
spannableStringBuilder.setSpan(new ForegroundColorSpan(foregroundColor),
foregroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (backgroundColorStartPosition != C.POSITION_UNSET) {
spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor),
backgroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
return new SpannableString(spannableStringBuilder);
}
示例11: decodeChapterFrame
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);
}
示例12: consume
@Override
public void consume(ParsableByteArray data, boolean payloadUnitStartIndicator) {
int payloadStartPosition = C.POSITION_UNSET;
if (payloadUnitStartIndicator) {
int payloadStartOffset = data.readUnsignedByte();
payloadStartPosition = data.getPosition() + payloadStartOffset;
}
if (waitingForPayloadStart) {
if (!payloadUnitStartIndicator) {
return;
}
waitingForPayloadStart = false;
data.setPosition(payloadStartPosition);
bytesRead = 0;
}
while (data.bytesLeft() > 0) {
if (bytesRead < SECTION_HEADER_LENGTH) {
// Note: see ISO/IEC 13818-1, section 2.4.4.3 for detailed information on the format of
// the header.
if (bytesRead == 0) {
int tableId = data.readUnsignedByte();
data.setPosition(data.getPosition() - 1);
if (tableId == 0xFF /* forbidden value */) {
// No more sections in this ts packet.
waitingForPayloadStart = true;
return;
}
}
int headerBytesToRead = Math.min(data.bytesLeft(), SECTION_HEADER_LENGTH - bytesRead);
data.readBytes(sectionData.data, bytesRead, headerBytesToRead);
bytesRead += headerBytesToRead;
if (bytesRead == SECTION_HEADER_LENGTH) {
sectionData.reset(SECTION_HEADER_LENGTH);
sectionData.skipBytes(1); // Skip table id (8).
int secondHeaderByte = sectionData.readUnsignedByte();
int thirdHeaderByte = sectionData.readUnsignedByte();
sectionSyntaxIndicator = (secondHeaderByte & 0x80) != 0;
totalSectionLength =
(((secondHeaderByte & 0x0F) << 8) | thirdHeaderByte) + SECTION_HEADER_LENGTH;
if (sectionData.capacity() < totalSectionLength) {
// Ensure there is enough space to keep the whole section.
byte[] bytes = sectionData.data;
sectionData.reset(
Math.min(MAX_SECTION_LENGTH, Math.max(totalSectionLength, bytes.length * 2)));
System.arraycopy(bytes, 0, sectionData.data, 0, SECTION_HEADER_LENGTH);
}
}
} else {
// Reading the body.
int bodyBytesToRead = Math.min(data.bytesLeft(), totalSectionLength - bytesRead);
data.readBytes(sectionData.data, bytesRead, bodyBytesToRead);
bytesRead += bodyBytesToRead;
if (bytesRead == totalSectionLength) {
if (sectionSyntaxIndicator) {
// This section has common syntax as defined in ISO/IEC 13818-1, section 2.4.4.11.
if (Util.crc(sectionData.data, 0, totalSectionLength, 0xFFFFFFFF) != 0) {
// The CRC is invalid so discard the section.
waitingForPayloadStart = true;
return;
}
sectionData.reset(totalSectionLength - 4); // Exclude the CRC_32 field.
} else {
// This is a private section with private defined syntax.
sectionData.reset(totalSectionLength);
}
reader.consume(sectionData);
bytesRead = 0;
}
}
}
}
示例13: startMasterElement
void startMasterElement(int id, long contentPosition, long contentSize)
throws ParserException {
switch (id) {
case ID_SEGMENT:
if (segmentContentPosition != C.POSITION_UNSET
&& segmentContentPosition != contentPosition) {
throw new ParserException("Multiple Segment elements not supported");
}
segmentContentPosition = contentPosition;
segmentContentSize = contentSize;
break;
case ID_SEEK:
seekEntryId = UNSET_ENTRY_ID;
seekEntryPosition = C.POSITION_UNSET;
break;
case ID_CUES:
cueTimesUs = new LongArray();
cueClusterPositions = new LongArray();
break;
case ID_CUE_POINT:
seenClusterPositionForCurrentCuePoint = false;
break;
case ID_CLUSTER:
if (!sentSeekMap) {
// We need to build cues before parsing the cluster.
if (seekForCuesEnabled && cuesContentPosition != C.POSITION_UNSET) {
// We know where the Cues element is located. Seek to request it.
seekForCues = true;
} else {
// We don't know where the Cues element is located. It's most likely omitted. Allow
// playback, but disable seeking.
extractorOutput.seekMap(new SeekMap.Unseekable(durationUs));
sentSeekMap = true;
}
}
break;
case ID_BLOCK_GROUP:
sampleSeenReferenceBlock = false;
break;
case ID_CONTENT_ENCODING:
// TODO: check and fail if more than one content encoding is present.
break;
case ID_CONTENT_ENCRYPTION:
currentTrack.hasContentEncryption = true;
break;
case ID_TRACK_ENTRY:
currentTrack = new Track();
break;
case ID_MASTERING_METADATA:
currentTrack.hasColorInfo = true;
break;
default:
break;
}
}
示例14: endMasterElement
void endMasterElement(int id) throws ParserException {
switch (id) {
case ID_SEGMENT_INFO:
if (timecodeScale == C.TIME_UNSET) {
// timecodeScale was omitted. Use the default value.
timecodeScale = 1000000;
}
if (durationTimecode != C.TIME_UNSET) {
durationUs = scaleTimecodeToUs(durationTimecode);
}
break;
case ID_SEEK:
if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.POSITION_UNSET) {
throw new ParserException("Mandatory element SeekID or SeekPosition not found");
}
if (seekEntryId == ID_CUES) {
cuesContentPosition = seekEntryPosition;
}
break;
case ID_CUES:
if (!sentSeekMap) {
extractorOutput.seekMap(buildSeekMap());
sentSeekMap = true;
} else {
// We have already built the cues. Ignore.
}
break;
case ID_BLOCK_GROUP:
if (blockState != BLOCK_STATE_DATA) {
// We've skipped this block (due to incompatible track number).
return;
}
// If the ReferenceBlock element was not found for this sample, then it is a keyframe.
if (!sampleSeenReferenceBlock) {
blockFlags |= C.BUFFER_FLAG_KEY_FRAME;
}
commitSampleToOutput(tracks.get(blockTrackNumber), blockTimeUs);
blockState = BLOCK_STATE_START;
break;
case ID_CONTENT_ENCODING:
if (currentTrack.hasContentEncryption) {
if (currentTrack.encryptionKeyId == null) {
throw new ParserException("Encrypted Track found but ContentEncKeyID was not found");
}
currentTrack.drmInitData = new DrmInitData(
new SchemeData(C.UUID_NIL, MimeTypes.VIDEO_WEBM, currentTrack.encryptionKeyId));
}
break;
case ID_CONTENT_ENCODINGS:
if (currentTrack.hasContentEncryption && currentTrack.sampleStrippedBytes != null) {
throw new ParserException("Combining encryption and compression is not supported");
}
break;
case ID_TRACK_ENTRY:
if (isCodecSupported(currentTrack.codecId)) {
currentTrack.initializeOutput(extractorOutput, currentTrack.number);
tracks.put(currentTrack.number, currentTrack);
}
currentTrack = null;
break;
case ID_TRACKS:
if (tracks.size() == 0) {
throw new ParserException("No valid tracks were found");
}
extractorOutput.endTracks();
break;
default:
break;
}
}