Java Code Examples for com.google.android.exoplayer2.C#TIME_UNSET
The following examples show how to use
com.google.android.exoplayer2.C#TIME_UNSET .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SsManifest.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * @param majorVersion The client manifest major version. * @param minorVersion The client manifest minor version. * @param timescale The timescale of the media as the number of units that pass in one second. * @param duration The overall presentation duration in units of the timescale attribute, or 0 if * the duration is unknown. * @param dvrWindowLength The length of the trailing window in units of the timescale attribute, * or 0 if this attribute is unspecified or not applicable. * @param lookAheadCount The number of fragments in a lookahead, or {@link #UNSET_LOOKAHEAD} if * this attribute is unspecified or not applicable. * @param isLive True if the manifest describes a live presentation still in progress. False * otherwise. * @param protectionElement Content protection information, or null if the content is not * protected. * @param streamElements The contained stream elements. */ public SsManifest( int majorVersion, int minorVersion, long timescale, long duration, long dvrWindowLength, int lookAheadCount, boolean isLive, ProtectionElement protectionElement, StreamElement[] streamElements) { this( majorVersion, minorVersion, duration == 0 ? C.TIME_UNSET : Util.scaleLargeTimestamp(duration, C.MICROS_PER_SECOND, timescale), dvrWindowLength == 0 ? C.TIME_UNSET : Util.scaleLargeTimestamp(dvrWindowLength, C.MICROS_PER_SECOND, timescale), lookAheadCount, isLive, protectionElement, streamElements); }
Example 2
Source File: VideoFrameReleaseTimeHelper.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Constructs an instance that smooths frame release timestamps and aligns them with the default * display's vsync signal. * * @param context A context from which information about the default display can be retrieved. */ public VideoFrameReleaseTimeHelper(@Nullable Context context) { if (context != null) { context = context.getApplicationContext(); windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); } else { windowManager = null; } if (windowManager != null) { displayListener = Util.SDK_INT >= 17 ? maybeBuildDefaultDisplayListenerV17(context) : null; vsyncSampler = VSyncSampler.getInstance(); } else { displayListener = null; vsyncSampler = null; } vsyncDurationNs = C.TIME_UNSET; vsyncOffsetNs = C.TIME_UNSET; }
Example 3
Source File: MatroskaExtractor.java From K-Sonic with MIT License | 6 votes |
private static void setSubripSampleEndTimecode(byte[] subripSampleData, long timeUs) { byte[] timeCodeData; if (timeUs == C.TIME_UNSET) { timeCodeData = SUBRIP_TIMECODE_EMPTY; } else { int hours = (int) (timeUs / 3600000000L); timeUs -= (hours * 3600000000L); int minutes = (int) (timeUs / 60000000); timeUs -= (minutes * 60000000); int seconds = (int) (timeUs / 1000000); timeUs -= (seconds * 1000000); int milliseconds = (int) (timeUs / 1000); timeCodeData = Util.getUtf8Bytes(String.format(Locale.US, "%02d:%02d:%02d,%03d", hours, minutes, seconds, milliseconds)); } System.arraycopy(timeCodeData, 0, subripSampleData, SUBRIP_PREFIX_END_TIMECODE_OFFSET, SUBRIP_TIMECODE_LENGTH); }
Example 4
Source File: ClippingMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public Window getWindow( int windowIndex, Window window, boolean setTag, long defaultPositionProjectionUs) { timeline.getWindow( /* windowIndex= */ 0, window, setTag, /* defaultPositionProjectionUs= */ 0); window.positionInFirstPeriodUs += startUs; window.durationUs = durationUs; window.isDynamic = isDynamic; if (window.defaultPositionUs != C.TIME_UNSET) { window.defaultPositionUs = Math.max(window.defaultPositionUs, startUs); window.defaultPositionUs = endUs == C.TIME_UNSET ? window.defaultPositionUs : Math.min(window.defaultPositionUs, endUs); window.defaultPositionUs -= startUs; } long startMs = C.usToMs(startUs); if (window.presentationStartTimeMs != C.TIME_UNSET) { window.presentationStartTimeMs += startMs; } if (window.windowStartTimeMs != C.TIME_UNSET) { window.windowStartTimeMs += startMs; } return window; }
Example 5
Source File: DashMediaSource.java From MediaSDK with Apache License 2.0 | 6 votes |
LoadErrorAction onManifestLoadError( ParsingLoadable<DashManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) { long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor( C.DATA_TYPE_MANIFEST, loadDurationMs, error, errorCount); LoadErrorAction loadErrorAction = retryDelayMs == C.TIME_UNSET ? Loader.DONT_RETRY_FATAL : Loader.createRetryAction(/* resetErrorCount= */ false, retryDelayMs); manifestEventDispatcher.loadError( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded(), error, !loadErrorAction.isRetry()); return loadErrorAction; }
Example 6
Source File: AtomParsers.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Parses a trak atom (defined in 14496-12). * * @param trak Atom to decode. * @param mvhd Movie header atom, used to get the timescale. * @param duration The duration in units of the timescale declared in the mvhd atom, or * {@link C#TIME_UNSET} if the duration should be parsed from the tkhd atom. * @param drmInitData {@link DrmInitData} to be included in the format. * @param ignoreEditLists Whether to ignore any edit lists in the trak box. * @param isQuickTime True for QuickTime media. False otherwise. * @return A {@link Track} instance, or {@code null} if the track's type isn't supported. */ public static Track parseTrak(Atom.ContainerAtom trak, Atom.LeafAtom mvhd, long duration, DrmInitData drmInitData, boolean ignoreEditLists, boolean isQuickTime) throws ParserException { Atom.ContainerAtom mdia = trak.getContainerAtomOfType(Atom.TYPE_mdia); int trackType = getTrackTypeForHdlr(parseHdlr(mdia.getLeafAtomOfType(Atom.TYPE_hdlr).data)); if (trackType == C.TRACK_TYPE_UNKNOWN) { return null; } TkhdData tkhdData = parseTkhd(trak.getLeafAtomOfType(Atom.TYPE_tkhd).data); if (duration == C.TIME_UNSET) { duration = tkhdData.duration; } long movieTimescale = parseMvhd(mvhd.data); long durationUs; if (duration == C.TIME_UNSET) { durationUs = C.TIME_UNSET; } else { durationUs = Util.scaleLargeTimestamp(duration, C.MICROS_PER_SECOND, movieTimescale); } Atom.ContainerAtom stbl = mdia.getContainerAtomOfType(Atom.TYPE_minf) .getContainerAtomOfType(Atom.TYPE_stbl); Pair<Long, String> mdhdData = parseMdhd(mdia.getLeafAtomOfType(Atom.TYPE_mdhd).data); StsdData stsdData = parseStsd(stbl.getLeafAtomOfType(Atom.TYPE_stsd).data, tkhdData.id, tkhdData.rotationDegrees, mdhdData.second, drmInitData, isQuickTime); long[] editListDurations = null; long[] editListMediaTimes = null; if (!ignoreEditLists) { Pair<long[], long[]> edtsData = parseEdts(trak.getContainerAtomOfType(Atom.TYPE_edts)); editListDurations = edtsData.first; editListMediaTimes = edtsData.second; } return stsdData.format == null ? null : new Track(tkhdData.id, trackType, mdhdData.first, movieTimescale, durationUs, stsdData.format, stsdData.requiredSampleTransformation, stsdData.trackEncryptionBoxes, stsdData.nalUnitLengthFieldLength, editListDurations, editListMediaTimes); }
Example 7
Source File: InitializationChunk.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * @param dataSource The source from which the data should be loaded. * @param dataSpec Defines the data to be loaded. * @param trackFormat See {@link #trackFormat}. * @param trackSelectionReason See {@link #trackSelectionReason}. * @param trackSelectionData See {@link #trackSelectionData}. * @param extractorWrapper A wrapped extractor to use for parsing the initialization data. */ public InitializationChunk( DataSource dataSource, DataSpec dataSpec, Format trackFormat, int trackSelectionReason, @Nullable Object trackSelectionData, ChunkExtractorWrapper extractorWrapper) { super(dataSource, dataSpec, C.DATA_TYPE_MEDIA_INITIALIZATION, trackFormat, trackSelectionReason, trackSelectionData, C.TIME_UNSET, C.TIME_UNSET); this.extractorWrapper = extractorWrapper; }
Example 8
Source File: ProgressiveMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onSourceInfoRefreshed(long durationUs, boolean isSeekable) { // If we already have the duration from a previous source info refresh, use it. durationUs = durationUs == C.TIME_UNSET ? timelineDurationUs : durationUs; if (timelineDurationUs == durationUs && timelineIsSeekable == isSeekable) { // Suppress no-op source info changes. return; } notifySourceInfoRefreshed(durationUs, isSeekable); }
Example 9
Source File: Mp3Extractor.java From K-Sonic with MIT License | 5 votes |
@Override public void seek(long position, long timeUs) { synchronizedHeaderData = 0; basisTimeUs = C.TIME_UNSET; samplesRead = 0; sampleBytesRemaining = 0; }
Example 10
Source File: DefaultSsChunkSource.java From MediaSDK with Apache License 2.0 | 5 votes |
private static MediaChunk newMediaChunk( Format format, DataSource dataSource, Uri uri, String cacheKey, int chunkIndex, long chunkStartTimeUs, long chunkEndTimeUs, long chunkSeekTimeUs, int trackSelectionReason, Object trackSelectionData, ChunkExtractorWrapper extractorWrapper) { DataSpec dataSpec = new DataSpec(uri, 0, C.LENGTH_UNSET, cacheKey); // In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk. // To convert them the absolute timestamps, we need to set sampleOffsetUs to chunkStartTimeUs. long sampleOffsetUs = chunkStartTimeUs; return new ContainerMediaChunk( dataSource, dataSpec, format, trackSelectionReason, trackSelectionData, chunkStartTimeUs, chunkEndTimeUs, chunkSeekTimeUs, /* clippedEndTimeUs= */ C.TIME_UNSET, chunkIndex, /* chunkCount= */ 1, sampleOffsetUs, extractorWrapper); }
Example 11
Source File: DefaultHlsPlaylistTracker.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void stop() { primaryHlsUrl = null; primaryUrlSnapshot = null; masterPlaylist = null; initialStartTimeUs = C.TIME_UNSET; initialPlaylistLoader.release(); initialPlaylistLoader = null; for (MediaPlaylistBundle bundle : playlistBundles.values()) { bundle.release(); } playlistRefreshHandler.removeCallbacksAndMessages(null); playlistRefreshHandler = null; playlistBundles.clear(); }
Example 12
Source File: PlayerEmsgHandler.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static long getManifestPublishTimeMsInEmsg(EventMessage eventMessage) { try { return parseXsDateTime(new String(eventMessage.messageData)); } catch (ParserException ignored) { // if we can't parse this event, ignore return C.TIME_UNSET; } }
Example 13
Source File: DeferredMediaPeriod.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** * Creates a new deferred media period. * * @param mediaSource The media source to wrap. * @param id The identifier used to create the deferred media period. * @param allocator The allocator used to create the media period. * @param preparePositionUs The expected start position, in microseconds. */ public DeferredMediaPeriod( MediaSource mediaSource, MediaPeriodId id, Allocator allocator, long preparePositionUs) { this.id = id; this.allocator = allocator; this.mediaSource = mediaSource; this.preparePositionUs = preparePositionUs; preparePositionOverrideUs = C.TIME_UNSET; }
Example 14
Source File: CustomPlayBackController.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
@Override public void onAttachedToWindow() { super.onAttachedToWindow(); isAttachedToWindow = true; if (hideAtMs != C.TIME_UNSET) { long delayMs = hideAtMs - SystemClock.uptimeMillis(); if (delayMs <= 0) { hide(); } else { postDelayed(hideAction, delayMs); } } updateAll(); }
Example 15
Source File: ClippingMediaSource.java From K-Sonic with MIT License | 4 votes |
@Override public Period getPeriod(int periodIndex, Period period, boolean setIds) { period = timeline.getPeriod(0, period, setIds); period.durationUs = endUs != C.TIME_UNSET ? endUs - startUs : C.TIME_UNSET; return period; }
Example 16
Source File: MediaSourceEventListener.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private long adjustMediaTime(long mediaTimeUs) { long mediaTimeMs = C.usToMs(mediaTimeUs); return mediaTimeMs == C.TIME_UNSET ? C.TIME_UNSET : mediaTimeOffsetMs + mediaTimeMs; }
Example 17
Source File: EventSampleStream.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
/** * Seeks to the specified position in microseconds. * * @param positionUs The seek position in microseconds. */ public void seekToUs(long positionUs) { currentIndex = Util.binarySearchCeil(eventTimesUs, positionUs, true, false); boolean isPendingSeek = eventStreamUpdatable && currentIndex == eventTimesUs.length; pendingSeekPositionUs = isPendingSeek ? positionUs : C.TIME_UNSET; }
Example 18
Source File: TtmlDecoder.java From K-Sonic with MIT License | 4 votes |
private TtmlNode parseNode(XmlPullParser parser, TtmlNode parent, Map<String, TtmlRegion> regionMap, FrameAndTickRate frameAndTickRate) throws SubtitleDecoderException { long duration = C.TIME_UNSET; long startTime = C.TIME_UNSET; long endTime = C.TIME_UNSET; String regionId = TtmlNode.ANONYMOUS_REGION_ID; String[] styleIds = null; int attributeCount = parser.getAttributeCount(); TtmlStyle style = parseStyleAttributes(parser, null); for (int i = 0; i < attributeCount; i++) { String attr = parser.getAttributeName(i); String value = parser.getAttributeValue(i); switch (attr) { case ATTR_BEGIN: startTime = parseTimeExpression(value, frameAndTickRate); break; case ATTR_END: endTime = parseTimeExpression(value, frameAndTickRate); break; case ATTR_DURATION: duration = parseTimeExpression(value, frameAndTickRate); break; case ATTR_STYLE: // IDREFS: potentially multiple space delimited ids String[] ids = parseStyleIds(value); if (ids.length > 0) { styleIds = ids; } break; case ATTR_REGION: if (regionMap.containsKey(value)) { // If the region has not been correctly declared or does not define a position, we use // the anonymous region. regionId = value; } break; default: // Do nothing. break; } } if (parent != null && parent.startTimeUs != C.TIME_UNSET) { if (startTime != C.TIME_UNSET) { startTime += parent.startTimeUs; } if (endTime != C.TIME_UNSET) { endTime += parent.startTimeUs; } } if (endTime == C.TIME_UNSET) { if (duration != C.TIME_UNSET) { // Infer the end time from the duration. endTime = startTime + duration; } else if (parent != null && parent.endTimeUs != C.TIME_UNSET) { // If the end time remains unspecified, then it should be inherited from the parent. endTime = parent.endTimeUs; } } return TtmlNode.buildNode(parser.getName(), startTime, endTime, style, styleIds, regionId); }
Example 19
Source File: TimestampAdjuster.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
/** * Resets the instance to its initial state. */ public void reset() { lastSampleTimestamp = C.TIME_UNSET; }
Example 20
Source File: PlayerEmsgHandler.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
/** * Called when the a new chunk in the current media stream has been loaded. * * @param chunk The chunk whose load has been completed. */ /* package */ void onChunkLoadCompleted(Chunk chunk) { if (lastLoadedChunkEndTimeUs != C.TIME_UNSET || chunk.endTimeUs > lastLoadedChunkEndTimeUs) { lastLoadedChunkEndTimeUs = chunk.endTimeUs; } }