本文整理汇总了Java中com.google.android.exoplayer.ParserException类的典型用法代码示例。如果您正苦于以下问题:Java ParserException类的具体用法?Java ParserException怎么用?Java ParserException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParserException类属于com.google.android.exoplayer包,在下文中一共展示了ParserException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSkipToPageOfGranuleAfterTargetPage
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
public void testSkipToPageOfGranuleAfterTargetPage() throws IOException, InterruptedException {
byte[] packet = TestUtil.buildTestData(3 * 254, random);
FakeExtractorInput input = TestData.createInput(
TestUtil.joinByteArrays(
TestData.buildOggHeader(0x01, 20000, 1000, 0x03),
TestUtil.createByteArray(254, 254, 254), // Laces.
packet,
TestData.buildOggHeader(0x04, 40000, 1001, 0x03),
TestUtil.createByteArray(254, 254, 254), // Laces.
packet,
TestData.buildOggHeader(0x04, 60000, 1002, 0x03),
TestUtil.createByteArray(254, 254, 254), // Laces.
packet), false);
try {
skipToPageOfGranule(input, 10000, 20000);
fail();
} catch (ParserException e) {
// ignored
}
assertEquals(0, input.getPosition());
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:23,代码来源:OggParserTest.java
示例2: parseContentProtection
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
/**
* Parses a ContentProtection element.
*
* @throws XmlPullParserException If an error occurs parsing the element.
* @throws IOException If an error occurs reading the element.
**/
protected ContentProtection parseContentProtection(XmlPullParser xpp)
throws XmlPullParserException, IOException {
String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
UUID uuid = null;
byte[] psshAtom = null;
do {
xpp.next();
// The cenc:pssh element is defined in 23001-7:2015
if (isStartTag(xpp, "cenc:pssh") && xpp.next() == XmlPullParser.TEXT) {
psshAtom = Base64.decode(xpp.getText(), Base64.DEFAULT);
uuid = PsshAtomUtil.parseUuid(psshAtom);
if (uuid == null) {
throw new ParserException("Invalid pssh atom in cenc:pssh element");
}
}
} while (!isEndTag(xpp, "ContentProtection"));
return buildContentProtection(schemeIdUri, uuid, psshAtom);
}
开发者ID:XueyanLiu,项目名称:miku,代码行数:26,代码来源:MediaPresentationDescriptionParser.java
示例3: parseMsAcmCodecPrivate
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
/**
* Parses an MS/ACM codec private, returning whether it indicates PCM audio.
*
* @return True if the codec private indicates PCM audio. False otherwise.
* @throws ParserException If a parsing error occurs.
*/
private static boolean parseMsAcmCodecPrivate(ParsableByteArray buffer) throws ParserException {
try {
int formatTag = buffer.readLittleEndianUnsignedShort();
if (formatTag == WAVE_FORMAT_PCM) {
return true;
} else if (formatTag == WAVE_FORMAT_EXTENSIBLE) {
buffer.setPosition(WAVE_FORMAT_SIZE + 6); // unionSamples(2), channelMask(4)
return buffer.readLong() == WAVE_SUBFORMAT_PCM.getMostSignificantBits()
&& buffer.readLong() == WAVE_SUBFORMAT_PCM.getLeastSignificantBits();
} else {
return false;
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new ParserException("Error parsing MS/ACM codec private");
}
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:23,代码来源:WebmExtractor.java
示例4: parseStreamElementStartTag
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
private void parseStreamElementStartTag(XmlPullParser parser) throws ParserException {
type = parseType(parser);
putNormalizedAttribute(KEY_TYPE, type);
if (type == StreamElement.TYPE_TEXT) {
subType = parseRequiredString(parser, KEY_SUB_TYPE);
} else {
subType = parser.getAttributeValue(null, KEY_SUB_TYPE);
}
name = parser.getAttributeValue(null, KEY_NAME);
qualityLevels = parseInt(parser, KEY_QUALITY_LEVELS, -1);
url = parseRequiredString(parser, KEY_URL);
maxWidth = parseInt(parser, KEY_MAX_WIDTH, -1);
maxHeight = parseInt(parser, KEY_MAX_HEIGHT, -1);
displayWidth = parseInt(parser, KEY_DISPLAY_WIDTH, -1);
displayHeight = parseInt(parser, KEY_DISPLAY_HEIGHT, -1);
language = parser.getAttributeValue(null, KEY_LANGUAGE);
timescale = parseInt(parser, KEY_TIME_SCALE, -1);
if (timescale == -1) {
timescale = (Long) getNormalizedAttribute(KEY_TIME_SCALE);
}
startTimes = new ArrayList<>();
}
开发者ID:XueyanLiu,项目名称:miku,代码行数:23,代码来源:SmoothStreamingManifestParser.java
示例5: verifyVorbisHeaderCapturePattern
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
/**
* Verifies whether the next bytes in {@code header} are a vorbis header of the given
* {@code headerType}.
*
* @param headerType the type of the header expected.
* @param header the alleged header bytes.
* @param quite if {@code true} no exceptions are thrown. Instead {@code false} is returned.
* @return the number of bytes read.
* @throws ParserException thrown if header type or capture pattern is not as expected.
*/
public static boolean verifyVorbisHeaderCapturePattern(int headerType, ParsableByteArray header,
boolean quite)
throws ParserException {
if (header.readUnsignedByte() != headerType) {
if (quite) {
return false;
} else {
throw new ParserException("expected header type " + Integer.toHexString(headerType));
}
}
if (!(header.readUnsignedByte() == 'v'
&& header.readUnsignedByte() == 'o'
&& header.readUnsignedByte() == 'r'
&& header.readUnsignedByte() == 'b'
&& header.readUnsignedByte() == 'i'
&& header.readUnsignedByte() == 's')) {
if (quite) {
return false;
} else {
throw new ParserException("expected characters 'vorbis'");
}
}
return true;
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:36,代码来源:VorbisUtil.java
示例6: skipToPageOfGranule
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
/**
* Skips to the position of the start of the page containing the {@code targetGranule} and
* returns the elapsed samples which is the granule of the page previous to the target page.
* <p>
* Note that the position of the {@code input} must be before the start of the page previous to
* the page containing the targetGranule to get the correct number of elapsed samples.
* Which is in short like: {@code pos(input) <= pos(targetPage.pageSequence - 1)}.
*
* @param input the {@link ExtractorInput} to read from.
* @param targetGranule the target granule (number of frames per channel).
* @return the number of elapsed samples at the start of the target page.
* @throws ParserException thrown if populating the page header fails.
* @throws IOException thrown if reading from the input fails.
* @throws InterruptedException thrown if interrupted while reading from the input.
*/
public long skipToPageOfGranule(ExtractorInput input, long targetGranule)
throws IOException, InterruptedException {
OggUtil.skipToNextPage(input);
OggUtil.populatePageHeader(input, pageHeader, headerArray, false);
while (pageHeader.granulePosition < targetGranule) {
input.skipFully(pageHeader.headerSize + pageHeader.bodySize);
// Store in a member field to be able to resume after IOExceptions.
elapsedSamples = pageHeader.granulePosition;
// Peek next header.
OggUtil.populatePageHeader(input, pageHeader, headerArray, false);
}
if (elapsedSamples == 0) {
throw new ParserException();
}
input.resetPeekPosition();
long returnValue = elapsedSamples;
// Reset member state.
elapsedSamples = 0;
currentSegmentIndex = -1;
return returnValue;
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:37,代码来源:OggParser.java
示例7: stringElement
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
void stringElement(int id, String value) throws ParserException {
switch (id) {
case ID_DOC_TYPE:
// Validate that DocType is supported.
if (!DOC_TYPE_WEBM.equals(value) && !DOC_TYPE_MATROSKA.equals(value)) {
throw new ParserException("DocType " + value + " not supported");
}
return;
case ID_CODEC_ID:
currentTrack.codecId = value;
return;
case ID_LANGUAGE:
currentTrack.language = value;
return;
default:
return;
}
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:19,代码来源:WebmExtractor.java
示例8: parseSaio
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
/**
* Parses a saio atom (defined in 14496-12).
*
* @param saio The saio atom to parse.
* @param out The {@link TrackFragment} to populate with data from the saio atom.
*/
private static void parseSaio(ParsableByteArray saio, TrackFragment out) throws ParserException {
saio.setPosition(Atom.HEADER_SIZE);
int fullAtom = saio.readInt();
int flags = Atom.parseFullAtomFlags(fullAtom);
if ((flags & 0x01) == 1) {
saio.skipBytes(8);
}
int entryCount = saio.readUnsignedIntToInt();
if (entryCount != 1) {
// We only support one trun element currently, so always expect one entry.
throw new ParserException("Unexpected saio entry count: " + entryCount);
}
int version = Atom.parseFullAtomVersion(fullAtom);
out.auxiliaryDataPosition +=
version == 0 ? saio.readUnsignedInt() : saio.readUnsignedLongToLong();
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:25,代码来源:FragmentedMp4Extractor.java
示例9: parseSenc
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
private static void parseSenc(ParsableByteArray senc, int offset, TrackFragment out)
throws ParserException {
senc.setPosition(Atom.HEADER_SIZE + offset);
int fullAtom = senc.readInt();
int flags = Atom.parseFullAtomFlags(fullAtom);
if ((flags & 0x01 /* override_track_encryption_box_parameters */) != 0) {
// TODO: Implement this.
throw new ParserException("Overriding TrackEncryptionBox parameters is unsupported.");
}
boolean subsampleEncryption = (flags & 0x02 /* use_subsample_encryption */) != 0;
int sampleCount = senc.readUnsignedIntToInt();
if (sampleCount != out.length) {
throw new ParserException("Length mismatch: " + sampleCount + ", " + out.length);
}
Arrays.fill(out.sampleHasSubsampleEncryptionTable, 0, sampleCount, subsampleEncryption);
out.initEncryptionData(senc.bytesLeft());
out.fillEncryptionData(senc);
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:22,代码来源:FragmentedMp4Extractor.java
示例10: testReadVorbisModes
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
public void testReadVorbisModes() throws ParserException {
byte[] data = TestData.getSetupHeaderData();
ParsableByteArray headerData = new ParsableByteArray(data, data.length);
VorbisUtil.Mode[] modes = VorbisUtil.readVorbisModes(headerData, 2);
assertEquals(2, modes.length);
assertEquals(false, modes[0].blockFlag);
assertEquals(0, modes[0].mapping);
assertEquals(0, modes[0].transformType);
assertEquals(0, modes[0].windowType);
assertEquals(true, modes[1].blockFlag);
assertEquals(1, modes[1].mapping);
assertEquals(0, modes[1].transformType);
assertEquals(0, modes[1].windowType);
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:19,代码来源:VorbisUtilTest.java
示例11: readEncryptionData
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
private void readEncryptionData(ExtractorInput input) throws IOException, InterruptedException {
TrackBundle nextTrackBundle = null;
long nextDataOffset = Long.MAX_VALUE;
int trackBundlesSize = trackBundles.size();
for (int i = 0; i < trackBundlesSize; i++) {
TrackFragment trackFragment = trackBundles.valueAt(i).fragment;
if (trackFragment.sampleEncryptionDataNeedsFill
&& trackFragment.auxiliaryDataPosition < nextDataOffset) {
nextDataOffset = trackFragment.auxiliaryDataPosition;
nextTrackBundle = trackBundles.valueAt(i);
}
}
if (nextTrackBundle == null) {
parserState = STATE_READING_SAMPLE_START;
return;
}
int bytesToSkip = (int) (nextDataOffset - input.getPosition());
if (bytesToSkip < 0) {
throw new ParserException("Offset to encryption data was negative.");
}
input.skipFully(bytesToSkip);
nextTrackBundle.fragment.fillEncryptionData(input);
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:24,代码来源:FragmentedMp4Extractor.java
示例12: parseVttCueBox
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
private static Cue parseVttCueBox(ParsableByteArray sampleData, WebvttCue.Builder builder,
int remainingCueBoxBytes) throws ParserException {
builder.reset();
while (remainingCueBoxBytes > 0) {
if (remainingCueBoxBytes < BOX_HEADER_SIZE) {
throw new ParserException("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(boxPayload.trim(), builder);
} else {
// Other VTTCueBox children are still not supported and are ignored.
}
}
return builder.build();
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:25,代码来源:Mp4WebvttParser.java
示例13: parse
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
public static TvListing parse(InputStream inputStream) {
try {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(inputStream, null);
int eventType = parser.next();
if (eventType != XmlPullParser.START_TAG || !TAG_TV.equals(parser.getName())) {
throw new ParserException(
"inputStream does not contain a xml tv description");
}
return parseTvListings(parser);
} catch (XmlPullParserException | IOException | ParseException e) {
e.printStackTrace();
}
return null;
}
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:16,代码来源:XmlTvParser.java
示例14: parse
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
@Override
public HlsPlaylist parse(String connectionUrl, InputStream inputStream)
throws IOException, ParserException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
Queue<String> extraLines = new LinkedList<>();
String line;
try {
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.isEmpty()) {
// Do nothing.
} else if (line.startsWith(STREAM_INF_TAG)) {
extraLines.add(line);
return parseMasterPlaylist(new LineIterator(extraLines, reader), connectionUrl);
} else if (line.startsWith(TARGET_DURATION_TAG)
|| line.startsWith(MEDIA_SEQUENCE_TAG)
|| line.startsWith(MEDIA_DURATION_TAG)
|| line.startsWith(KEY_TAG)
|| line.startsWith(BYTERANGE_TAG)
|| line.equals(DISCONTINUITY_TAG)
|| line.equals(ENDLIST_TAG)) {
extraLines.add(line);
return parseMediaPlaylist(new LineIterator(extraLines, reader), connectionUrl);
} else {
extraLines.add(line);
}
}
} finally {
reader.close();
}
throw new ParserException("Failed to parse the playlist, could not identify any tags.");
}
开发者ID:XueyanLiu,项目名称:miku,代码行数:33,代码来源:HlsPlaylistParser.java
示例15: testPrepareInvalidContentEncAlgo
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
public void testPrepareInvalidContentEncAlgo() throws IOException, InterruptedException {
ContentEncodingSettings settings = new ContentEncodingSettings(0, 1, 4, 1);
byte[] data = new StreamBuilder()
.setHeader(WEBM_DOC_TYPE)
.setInfo(DEFAULT_TIMECODE_SCALE, TEST_DURATION_TIMECODE)
.addVp9Track(VIDEO_TRACK_NUMBER, TEST_WIDTH, TEST_HEIGHT, settings)
.build(1);
try {
TestUtil.consumeTestData(extractor, data);
fail();
} catch (ParserException exception) {
assertEquals("ContentEncAlgo 4 not supported", exception.getMessage());
}
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:15,代码来源:WebmExtractorTest.java
示例16: testPrepareInvalidContentEncodingScope
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
public void testPrepareInvalidContentEncodingScope() throws IOException, InterruptedException {
ContentEncodingSettings settings = new ContentEncodingSettings(0, 0, 5, 1);
byte[] data = new StreamBuilder()
.setHeader(WEBM_DOC_TYPE)
.setInfo(DEFAULT_TIMECODE_SCALE, TEST_DURATION_TIMECODE)
.addVp9Track(VIDEO_TRACK_NUMBER, TEST_WIDTH, TEST_HEIGHT, settings)
.build(1);
try {
TestUtil.consumeTestData(extractor, data);
fail();
} catch (ParserException exception) {
assertEquals("ContentEncodingScope 0 not supported", exception.getMessage());
}
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:15,代码来源:WebmExtractorTest.java
示例17: parseId3Header
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
/**
* Parses an ID3 header.
*
* @param id3Buffer A {@link ParsableByteArray} from which data should be read.
* @return The size of ID3 frames in bytes, excluding the header and footer.
* @throws ParserException If ID3 file identifier != "ID3".
*/
private static int parseId3Header(ParsableByteArray id3Buffer) throws ParserException {
int id1 = id3Buffer.readUnsignedByte();
int id2 = id3Buffer.readUnsignedByte();
int id3 = id3Buffer.readUnsignedByte();
if (id1 != 'I' || id2 != 'D' || id3 != '3') {
throw new ParserException(String.format(Locale.US,
"Unexpected ID3 file identifier, expected \"ID3\", actual \"%c%c%c\".", id1, id2, id3));
}
id3Buffer.skipBytes(2); // Skip version.
int flags = id3Buffer.readUnsignedByte();
int id3Size = id3Buffer.readSynchSafeInt();
// Check if extended header presents.
if ((flags & 0x2) != 0) {
int extendedHeaderSize = id3Buffer.readSynchSafeInt();
if (extendedHeaderSize > 4) {
id3Buffer.skipBytes(extendedHeaderSize - 4);
}
id3Size -= extendedHeaderSize;
}
// Check if footer presents.
if ((flags & 0x8) != 0) {
id3Size -= 10;
}
return id3Size;
}
开发者ID:XueyanLiu,项目名称:miku,代码行数:37,代码来源:Id3Parser.java
示例18: resolveDirect
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
private void resolveDirect() {
try {
long utcTimestamp = Util.parseXsDateTime(timingElement.value);
long elapsedRealtimeOffset = utcTimestamp - timingElementElapsedRealtime;
callback.onTimestampResolved(timingElement, elapsedRealtimeOffset);
} catch (ParseException e) {
callback.onTimestampError(timingElement, new ParserException(e));
}
}
开发者ID:XueyanLiu,项目名称:miku,代码行数:10,代码来源:UtcTimingElementResolver.java
示例19: testPrepareInvalidContentCompAlgo
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
public void testPrepareInvalidContentCompAlgo()
throws IOException, InterruptedException {
ContentEncodingSettings settings = new ContentEncodingSettings(0, 1, 0, new byte[0]);
byte[] data = new StreamBuilder()
.setHeader(WEBM_DOC_TYPE)
.setInfo(DEFAULT_TIMECODE_SCALE, TEST_DURATION_TIMECODE)
.addVp9Track(VIDEO_TRACK_NUMBER, TEST_WIDTH, TEST_HEIGHT, settings)
.build(1);
try {
TestUtil.consumeTestData(extractor, data);
fail();
} catch (ParserException exception) {
assertEquals("ContentCompAlgo 0 not supported", exception.getMessage());
}
}
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:16,代码来源:WebmExtractorTest.java
示例20: parse
import com.google.android.exoplayer.ParserException; //导入依赖的package包/类
@Override
public Long parse(String connectionUrl, InputStream inputStream) throws ParserException,
IOException {
String firstLine = new BufferedReader(new InputStreamReader(inputStream)).readLine();
try {
// TODO: It may be necessary to handle timestamp offsets from UTC.
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
return format.parse(firstLine).getTime();
} catch (ParseException e) {
throw new ParserException(e);
}
}
开发者ID:XueyanLiu,项目名称:miku,代码行数:14,代码来源:UtcTimingElementResolver.java
注:本文中的com.google.android.exoplayer.ParserException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论