本文整理汇总了Java中com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement类的典型用法代码示例。如果您正苦于以下问题:Java StreamElement类的具体用法?Java StreamElement怎么用?Java StreamElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StreamElement类属于com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest包,在下文中一共展示了StreamElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseStreamElementStartTag
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的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<>();
}
示例2: parseStreamElementStartTag
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的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);
putNormalizedAttribute(KEY_LANGUAGE, language);
timescale = parseInt(parser, KEY_TIME_SCALE, -1);
if (timescale == -1) {
timescale = (Long) getNormalizedAttribute(KEY_TIME_SCALE);
}
startTimes = new ArrayList<>();
}
示例3: adaptiveTrack
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
@Override
public void adaptiveTrack(SmoothStreamingManifest manifest, int element, int[] trackIndices) {
if (adaptiveFormatEvaluator == null) {
// Do nothing.
return;
}
MediaFormat maxHeightMediaFormat = null;
StreamElement streamElement = manifest.streamElements[element];
int maxWidth = -1;
int maxHeight = -1;
Format[] formats = new Format[trackIndices.length];
for (int i = 0; i < formats.length; i++) {
int manifestTrackIndex = trackIndices[i];
formats[i] = streamElement.tracks[manifestTrackIndex].format;
MediaFormat mediaFormat = initManifestTrack(manifest, element, manifestTrackIndex);
if (maxHeightMediaFormat == null || mediaFormat.height > maxHeight) {
maxHeightMediaFormat = mediaFormat;
}
maxWidth = Math.max(maxWidth, mediaFormat.width);
maxHeight = Math.max(maxHeight, mediaFormat.height);
}
Arrays.sort(formats, new DecreasingBandwidthComparator());
MediaFormat adaptiveMediaFormat = maxHeightMediaFormat.copyAsAdaptive(null);
tracks.add(new ExposedTrack(adaptiveMediaFormat, element, formats, maxWidth, maxHeight));
}
示例4: parseStreamElementStartTag
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的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<Long>();
}
示例5: continueBuffering
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
@Override
public void continueBuffering(long playbackPositionUs) {
if (manifestFetcher == null || !currentManifest.isLive || fatalError != null) {
return;
}
SmoothStreamingManifest newManifest = manifestFetcher.getManifest();
if (currentManifest != newManifest && newManifest != null) {
StreamElement currentElement = getElement(currentManifest);
StreamElement newElement = getElement(newManifest);
if (newElement.chunkCount == 0) {
currentManifestChunkOffset += currentElement.chunkCount;
} else if (currentElement.chunkCount > 0) {
currentManifestChunkOffset += currentElement.getChunkIndex(newElement.getStartTimeUs(0));
}
currentManifest = newManifest;
finishedCurrentManifest = false;
}
if (finishedCurrentManifest && (SystemClock.elapsedRealtime()
> manifestFetcher.getManifestLoadTimestamp() + MINIMUM_MANIFEST_REFRESH_PERIOD_MS)) {
manifestFetcher.requestRefresh();
}
}
示例6: parseStreamElementStartTag
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的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 long[parseRequiredInt(parser, KEY_CHUNKS)];
}
示例7: build
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
@Override
public Object build() {
StreamElement[] streamElementArray = new StreamElement[streamElements.size()];
streamElements.toArray(streamElementArray);
return new SmoothStreamingManifest(majorVersion, minorVersion, timescale, duration,
dvrWindowLength, lookAheadCount, isLive, protectionElement, streamElementArray);
}
示例8: parseType
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
private int parseType(XmlPullParser parser) throws ParserException {
String value = parser.getAttributeValue(null, KEY_TYPE);
if (value != null) {
if (KEY_TYPE_AUDIO.equalsIgnoreCase(value)) {
return StreamElement.TYPE_AUDIO;
} else if (KEY_TYPE_VIDEO.equalsIgnoreCase(value)) {
return StreamElement.TYPE_VIDEO;
} else if (KEY_TYPE_TEXT.equalsIgnoreCase(value)) {
return StreamElement.TYPE_TEXT;
} else {
throw new ParserException("Invalid key value[" + value + "]");
}
}
throw new MissingFieldException(KEY_TYPE);
}
示例9: continueBuffering
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
@Override
public void continueBuffering(long playbackPositionUs) {
if (manifestFetcher == null || !currentManifest.isLive || fatalError != null) {
return;
}
SmoothStreamingManifest newManifest = manifestFetcher.getManifest();
if (currentManifest != newManifest && newManifest != null) {
StreamElement currentElement = getElement(currentManifest);
int currentElementChunkCount = currentElement.chunkCount;
StreamElement newElement = getElement(newManifest);
if (currentElementChunkCount == 0 || newElement.chunkCount == 0) {
// There's no overlap between the old and new elements because at least one is empty.
currentManifestChunkOffset += currentElementChunkCount;
} else {
long currentElementEndTimeUs = currentElement.getStartTimeUs(currentElementChunkCount - 1)
+ currentElement.getChunkDurationUs(currentElementChunkCount - 1);
long newElementStartTimeUs = newElement.getStartTimeUs(0);
if (currentElementEndTimeUs <= newElementStartTimeUs) {
// There's no overlap between the old and new elements.
currentManifestChunkOffset += currentElementChunkCount;
} else {
// The new element overlaps with the old one.
currentManifestChunkOffset += currentElement.getChunkIndex(newElementStartTimeUs);
}
}
currentManifest = newManifest;
finishedCurrentManifest = false;
}
if (finishedCurrentManifest && (SystemClock.elapsedRealtime()
> manifestFetcher.getManifestLoadStartTimestamp() + MINIMUM_MANIFEST_REFRESH_PERIOD_MS)) {
manifestFetcher.requestRefresh();
}
}
示例10: getLiveSeekPosition
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
/**
* For live playbacks, determines the seek position that snaps playback to be
* {@link #liveEdgeLatencyUs} behind the live edge of the current manifest
*
* @return The seek position in microseconds.
*/
private long getLiveSeekPosition() {
long liveEdgeTimestampUs = Long.MIN_VALUE;
for (int i = 0; i < currentManifest.streamElements.length; i++) {
StreamElement streamElement = currentManifest.streamElements[i];
if (streamElement.chunkCount > 0) {
long elementLiveEdgeTimestampUs =
streamElement.getStartTimeUs(streamElement.chunkCount - 1)
+ streamElement.getChunkDurationUs(streamElement.chunkCount - 1);
liveEdgeTimestampUs = Math.max(liveEdgeTimestampUs, elementLiveEdgeTimestampUs);
}
}
return liveEdgeTimestampUs - liveEdgeLatencyUs;
}
示例11: selectTracks
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
@Override
public void selectTracks(SmoothStreamingManifest manifest, Output output) throws IOException {
for (int i = 0; i < manifest.streamElements.length; i++) {
TrackElement[] tracks = manifest.streamElements[i].tracks;
if (manifest.streamElements[i].type == streamElementType) {
if (streamElementType == StreamElement.TYPE_VIDEO) {
int[] trackIndices;
if (filterVideoRepresentations) {
trackIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
context, Arrays.asList(tracks), null,
filterProtectedHdContent && manifest.protectionElement != null);
} else {
trackIndices = Util.firstIntegersArray(tracks.length);
}
int trackCount = trackIndices.length;
if (trackCount > 1) {
output.adaptiveTrack(manifest, i, trackIndices);
}
for (int j = 0; j < trackCount; j++) {
output.fixedTrack(manifest, i, trackIndices[j]);
}
} else {
for (int j = 0; j < tracks.length; j++) {
output.fixedTrack(manifest, i, j);
}
}
}
}
}
示例12: continueBuffering
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
@Override
public void continueBuffering(long playbackPositionUs) {
if (manifestFetcher == null || !currentManifest.isLive || fatalError != null) {
return;
}
SmoothStreamingManifest newManifest = manifestFetcher.getManifest();
if (currentManifest != newManifest && newManifest != null) {
StreamElement currentElement = currentManifest.streamElements[enabledTrack.elementIndex];
int currentElementChunkCount = currentElement.chunkCount;
StreamElement newElement = newManifest.streamElements[enabledTrack.elementIndex];
if (currentElementChunkCount == 0 || newElement.chunkCount == 0) {
// There's no overlap between the old and new elements because at least one is empty.
currentManifestChunkOffset += currentElementChunkCount;
} else {
long currentElementEndTimeUs = currentElement.getStartTimeUs(currentElementChunkCount - 1)
+ currentElement.getChunkDurationUs(currentElementChunkCount - 1);
long newElementStartTimeUs = newElement.getStartTimeUs(0);
if (currentElementEndTimeUs <= newElementStartTimeUs) {
// There's no overlap between the old and new elements.
currentManifestChunkOffset += currentElementChunkCount;
} else {
// The new element overlaps with the old one.
currentManifestChunkOffset += currentElement.getChunkIndex(newElementStartTimeUs);
}
}
currentManifest = newManifest;
needManifestRefresh = false;
}
if (needManifestRefresh && (SystemClock.elapsedRealtime()
> manifestFetcher.getManifestLoadStartTimestamp() + MINIMUM_MANIFEST_REFRESH_PERIOD_MS)) {
manifestFetcher.requestRefresh();
}
}
示例13: getLiveSeekPosition
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
/**
* For live playbacks, determines the seek position that snaps playback to be
* {@code liveEdgeLatencyUs} behind the live edge of the provided manifest.
*
* @param manifest The manifest.
* @param liveEdgeLatencyUs The live edge latency, in microseconds.
* @return The seek position in microseconds.
*/
private static long getLiveSeekPosition(SmoothStreamingManifest manifest,
long liveEdgeLatencyUs) {
long liveEdgeTimestampUs = Long.MIN_VALUE;
for (int i = 0; i < manifest.streamElements.length; i++) {
StreamElement streamElement = manifest.streamElements[i];
if (streamElement.chunkCount > 0) {
long elementLiveEdgeTimestampUs =
streamElement.getStartTimeUs(streamElement.chunkCount - 1)
+ streamElement.getChunkDurationUs(streamElement.chunkCount - 1);
liveEdgeTimestampUs = Math.max(liveEdgeTimestampUs, elementLiveEdgeTimestampUs);
}
}
return liveEdgeTimestampUs - liveEdgeLatencyUs;
}
示例14: getManifestTrackIndex
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
private static int getManifestTrackIndex(StreamElement element, Format format) {
TrackElement[] tracks = element.tracks;
for (int i = 0; i < tracks.length; i++) {
if (tracks[i].format.equals(format)) {
return i;
}
}
// Should never happen.
throw new IllegalStateException("Invalid format: " + format);
}
示例15: build
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; //导入依赖的package包/类
@Override
public Object build() {
StreamElement[] streamElementArray = new StreamElement[streamElements.size()];
streamElements.toArray(streamElementArray);
return new SmoothStreamingManifest(majorVersion, minorVersion, timeScale, duration,
lookAheadCount, protectionElement, streamElementArray);
}