Java Code Examples for com.google.android.exoplayer2.upstream.ParsingLoadable#getResult()
The following examples show how to use
com.google.android.exoplayer2.upstream.ParsingLoadable#getResult() .
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: DefaultHlsPlaylistTracker.java From MediaSDK with Apache License 2.0 | 6 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); if (result instanceof HlsMediaPlaylist) { processLoadedPlaylist((HlsMediaPlaylist) result, loadDurationMs); eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); } else { playlistError = new ParserException("Loaded playlist has unexpected type."); } }
Example 2
Source File: DefaultHlsPlaylistTracker.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); if (result instanceof HlsMediaPlaylist) { processLoadedPlaylist((HlsMediaPlaylist) result, loadDurationMs); eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); } else { playlistError = new ParserException("Loaded playlist has unexpected type."); } }
Example 3
Source File: SsMediaSource.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); manifest = loadable.getResult(); manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs; processManifest(); scheduleManifestRefresh(); }
Example 4
Source File: DefaultHlsPlaylistTracker.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); if (result instanceof HlsMediaPlaylist) { processLoadedPlaylist((HlsMediaPlaylist) result); eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); } else { playlistError = new ParserException("Loaded playlist has unexpected type."); } }
Example 5
Source File: SsMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); manifest = loadable.getResult(); manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs; processManifest(); scheduleManifestRefresh(); }
Example 6
Source File: DefaultHlsPlaylistTracker.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); if (result instanceof HlsMediaPlaylist) { processLoadedPlaylist((HlsMediaPlaylist) result, loadDurationMs); eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); } else { playlistError = new ParserException("Loaded playlist has unexpected type."); } }
Example 7
Source File: DefaultHlsPlaylistTracker.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); if (result instanceof HlsMediaPlaylist) { processLoadedPlaylist((HlsMediaPlaylist) result); eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); } else { playlistError = new ParserException("Loaded playlist has unexpected type."); } }
Example 8
Source File: DefaultHlsPlaylistTracker.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); HlsMasterPlaylist masterPlaylist; boolean isMediaPlaylist = result instanceof HlsMediaPlaylist; if (isMediaPlaylist) { masterPlaylist = HlsMasterPlaylist.createSingleVariantMasterPlaylist(result.baseUri); } else /* result instanceof HlsMasterPlaylist */ { masterPlaylist = (HlsMasterPlaylist) result; } this.masterPlaylist = masterPlaylist; mediaPlaylistParser = playlistParserFactory.createPlaylistParser(masterPlaylist); primaryMediaPlaylistUrl = masterPlaylist.variants.get(0).url; createBundles(masterPlaylist.mediaPlaylistUrls); MediaPlaylistBundle primaryBundle = playlistBundles.get(primaryMediaPlaylistUrl); if (isMediaPlaylist) { // We don't need to load the playlist again. We can use the same result. primaryBundle.processLoadedPlaylist((HlsMediaPlaylist) result, loadDurationMs); } else { primaryBundle.loadPlaylist(); } eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); }
Example 9
Source File: DefaultHlsPlaylistTracker.java From MediaSDK with Apache License 2.0 | 5 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); HlsMasterPlaylist masterPlaylist; boolean isMediaPlaylist = result instanceof HlsMediaPlaylist; if (isMediaPlaylist) { masterPlaylist = HlsMasterPlaylist.createSingleVariantMasterPlaylist(result.baseUri); } else /* result instanceof HlsMasterPlaylist */ { masterPlaylist = (HlsMasterPlaylist) result; } this.masterPlaylist = masterPlaylist; mediaPlaylistParser = playlistParserFactory.createPlaylistParser(masterPlaylist); primaryMediaPlaylistUrl = masterPlaylist.variants.get(0).url; createBundles(masterPlaylist.mediaPlaylistUrls); MediaPlaylistBundle primaryBundle = playlistBundles.get(primaryMediaPlaylistUrl); if (isMediaPlaylist) { // We don't need to load the playlist again. We can use the same result. primaryBundle.processLoadedPlaylist((HlsMediaPlaylist) result, loadDurationMs); } else { primaryBundle.loadPlaylist(); } eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); }
Example 10
Source File: SsMediaSource.java From K-Sonic with MIT License | 5 votes |
@Override public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { eventDispatcher.loadCompleted(loadable.dataSpec, loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); manifest = loadable.getResult(); manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs; processManifest(); scheduleManifestRefresh(); }
Example 11
Source File: HlsPlaylistTracker.java From K-Sonic with MIT License | 5 votes |
@Override public void onLoadCompleted(ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); HlsMasterPlaylist masterPlaylist; boolean isMediaPlaylist = result instanceof HlsMediaPlaylist; if (isMediaPlaylist) { masterPlaylist = HlsMasterPlaylist.createSingleVariantMasterPlaylist(result.baseUri); } else /* result instanceof HlsMasterPlaylist */ { masterPlaylist = (HlsMasterPlaylist) result; } this.masterPlaylist = masterPlaylist; primaryHlsUrl = masterPlaylist.variants.get(0); ArrayList<HlsUrl> urls = new ArrayList<>(); urls.addAll(masterPlaylist.variants); urls.addAll(masterPlaylist.audios); urls.addAll(masterPlaylist.subtitles); createBundles(urls); MediaPlaylistBundle primaryBundle = playlistBundles.get(primaryHlsUrl); if (isMediaPlaylist) { // We don't need to load the playlist again. We can use the same result. primaryBundle.processLoadedPlaylist((HlsMediaPlaylist) result); } else { primaryBundle.loadPlaylist(); } eventDispatcher.loadCompleted(loadable.dataSpec, C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); }
Example 12
Source File: SsMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); manifest = loadable.getResult(); manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs; processManifest(); scheduleManifestRefresh(); }
Example 13
Source File: DefaultHlsPlaylistTracker.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onLoadCompleted( ParsingLoadable<HlsPlaylist> loadable, long elapsedRealtimeMs, long loadDurationMs) { HlsPlaylist result = loadable.getResult(); HlsMasterPlaylist masterPlaylist; boolean isMediaPlaylist = result instanceof HlsMediaPlaylist; if (isMediaPlaylist) { masterPlaylist = HlsMasterPlaylist.createSingleVariantMasterPlaylist(result.baseUri); } else /* result instanceof HlsMasterPlaylist */ { masterPlaylist = (HlsMasterPlaylist) result; } this.masterPlaylist = masterPlaylist; primaryHlsUrl = masterPlaylist.variants.get(0); ArrayList<HlsUrl> urls = new ArrayList<>(); urls.addAll(masterPlaylist.variants); urls.addAll(masterPlaylist.audios); urls.addAll(masterPlaylist.subtitles); createBundles(urls); MediaPlaylistBundle primaryBundle = playlistBundles.get(primaryHlsUrl); if (isMediaPlaylist) { // We don't need to load the playlist again. We can use the same result. primaryBundle.processLoadedPlaylist((HlsMediaPlaylist) result); } else { primaryBundle.loadPlaylist(); } eventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), C.DATA_TYPE_MANIFEST, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); }
Example 14
Source File: SsMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public void onLoadCompleted(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); manifest = loadable.getResult(); manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs; processManifest(); scheduleManifestRefresh(); }
Example 15
Source File: DashMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
void onManifestLoadCompleted(ParsingLoadable<DashManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); DashManifest newManifest = loadable.getResult(); int periodCount = manifest == null ? 0 : manifest.getPeriodCount(); int removedPeriodCount = 0; long newFirstPeriodStartTimeMs = newManifest.getPeriod(0).startMs; while (removedPeriodCount < periodCount && manifest.getPeriod(removedPeriodCount).startMs < newFirstPeriodStartTimeMs) { removedPeriodCount++; } if (newManifest.dynamic) { boolean isManifestStale = false; if (periodCount - removedPeriodCount > newManifest.getPeriodCount()) { // After discarding old periods, we should never have more periods than listed in the new // manifest. That would mean that a previously announced period is no longer advertised. If // this condition occurs, assume that we are hitting a manifest server that is out of sync // and // behind. Log.w(TAG, "Loaded out of sync manifest"); isManifestStale = true; } else if (dynamicMediaPresentationEnded || (expiredManifestPublishTimeUs != C.TIME_UNSET && newManifest.publishTimeMs * 1000 <= expiredManifestPublishTimeUs)) { // If we receive a dynamic manifest that's older than expected (i.e. its publish time has // expired, or it's dynamic and we know the presentation has ended), then this manifest is // stale. Log.w( TAG, "Loaded stale dynamic manifest: " + newManifest.publishTimeMs + ", " + dynamicMediaPresentationEnded + ", " + expiredManifestPublishTimeUs); isManifestStale = true; } if (isManifestStale) { if (staleManifestReloadAttempt++ < minLoadableRetryCount) { scheduleManifestRefresh(getManifestLoadRetryDelayMillis()); } else { manifestFatalError = new DashManifestStaleException(); } return; } staleManifestReloadAttempt = 0; } manifest = newManifest; manifestLoadPending &= manifest.dynamic; manifestLoadStartTimestampMs = elapsedRealtimeMs - loadDurationMs; manifestLoadEndTimestampMs = elapsedRealtimeMs; if (manifest.location != null) { synchronized (manifestUriLock) { // This condition checks that replaceManifestUri wasn't called between the start and end of // this load. If it was, we ignore the manifest location and prefer the manual replacement. @SuppressWarnings("ReferenceEquality") boolean isSameUriInstance = loadable.dataSpec.uri == manifestUri; if (isSameUriInstance) { manifestUri = manifest.location; } } } if (periodCount == 0) { if (manifest.utcTiming != null) { resolveUtcTimingElement(manifest.utcTiming); } else { processManifest(true); } } else { firstPeriodId += removedPeriodCount; processManifest(true); } }
Example 16
Source File: DashMediaSource.java From K-Sonic with MIT License | 4 votes |
void onManifestLoadCompleted(ParsingLoadable<DashManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { eventDispatcher.loadCompleted(loadable.dataSpec, loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); DashManifest newManifest = loadable.getResult(); int periodCount = manifest == null ? 0 : manifest.getPeriodCount(); int removedPeriodCount = 0; long newFirstPeriodStartTimeMs = newManifest.getPeriod(0).startMs; while (removedPeriodCount < periodCount && manifest.getPeriod(removedPeriodCount).startMs < newFirstPeriodStartTimeMs) { removedPeriodCount++; } // After discarding old periods, we should never have more periods than listed in the new // manifest. That would mean that a previously announced period is no longer advertised. If // this condition occurs, assume that we are hitting a manifest server that is out of sync and // behind, discard this manifest, and try again later. if (periodCount - removedPeriodCount > newManifest.getPeriodCount()) { Log.w(TAG, "Out of sync manifest"); scheduleManifestRefresh(); return; } manifest = newManifest; manifestLoadStartTimestamp = elapsedRealtimeMs - loadDurationMs; manifestLoadEndTimestamp = elapsedRealtimeMs; if (manifest.location != null) { synchronized (manifestUriLock) { // This condition checks that replaceManifestUri wasn't called between the start and end of // this load. If it was, we ignore the manifest location and prefer the manual replacement. if (loadable.dataSpec.uri == manifestUri) { manifestUri = manifest.location; } } } if (periodCount == 0) { if (manifest.utcTiming != null) { resolveUtcTimingElement(manifest.utcTiming); } else { processManifest(true); } } else { firstPeriodId += removedPeriodCount; processManifest(true); } }
Example 17
Source File: DashMediaSource.java From Telegram with GNU General Public License v2.0 | 4 votes |
void onManifestLoadCompleted(ParsingLoadable<DashManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); DashManifest newManifest = loadable.getResult(); int oldPeriodCount = manifest == null ? 0 : manifest.getPeriodCount(); int removedPeriodCount = 0; long newFirstPeriodStartTimeMs = newManifest.getPeriod(0).startMs; while (removedPeriodCount < oldPeriodCount && manifest.getPeriod(removedPeriodCount).startMs < newFirstPeriodStartTimeMs) { removedPeriodCount++; } if (newManifest.dynamic) { boolean isManifestStale = false; if (oldPeriodCount - removedPeriodCount > newManifest.getPeriodCount()) { // After discarding old periods, we should never have more periods than listed in the new // manifest. That would mean that a previously announced period is no longer advertised. If // this condition occurs, assume that we are hitting a manifest server that is out of sync // and // behind. Log.w(TAG, "Loaded out of sync manifest"); isManifestStale = true; } else if (expiredManifestPublishTimeUs != C.TIME_UNSET && newManifest.publishTimeMs * 1000 <= expiredManifestPublishTimeUs) { // If we receive a dynamic manifest that's older than expected (i.e. its publish time has // expired, or it's dynamic and we know the presentation has ended), then this manifest is // stale. Log.w( TAG, "Loaded stale dynamic manifest: " + newManifest.publishTimeMs + ", " + expiredManifestPublishTimeUs); isManifestStale = true; } if (isManifestStale) { if (staleManifestReloadAttempt++ < loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type)) { scheduleManifestRefresh(getManifestLoadRetryDelayMillis()); } else { manifestFatalError = new DashManifestStaleException(); } return; } staleManifestReloadAttempt = 0; } manifest = newManifest; manifestLoadPending &= manifest.dynamic; manifestLoadStartTimestampMs = elapsedRealtimeMs - loadDurationMs; manifestLoadEndTimestampMs = elapsedRealtimeMs; if (manifest.location != null) { synchronized (manifestUriLock) { // This condition checks that replaceManifestUri wasn't called between the start and end of // this load. If it was, we ignore the manifest location and prefer the manual replacement. @SuppressWarnings("ReferenceEquality") boolean isSameUriInstance = loadable.dataSpec.uri == manifestUri; if (isSameUriInstance) { manifestUri = manifest.location; } } } if (oldPeriodCount == 0) { if (manifest.dynamic && manifest.utcTiming != null) { resolveUtcTimingElement(manifest.utcTiming); } else { processManifest(true); } } else { firstPeriodId += removedPeriodCount; processManifest(true); } }
Example 18
Source File: DashMediaSource.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
void onManifestLoadCompleted(ParsingLoadable<DashManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); DashManifest newManifest = loadable.getResult(); int oldPeriodCount = manifest == null ? 0 : manifest.getPeriodCount(); int removedPeriodCount = 0; long newFirstPeriodStartTimeMs = newManifest.getPeriod(0).startMs; while (removedPeriodCount < oldPeriodCount && manifest.getPeriod(removedPeriodCount).startMs < newFirstPeriodStartTimeMs) { removedPeriodCount++; } if (newManifest.dynamic) { boolean isManifestStale = false; if (oldPeriodCount - removedPeriodCount > newManifest.getPeriodCount()) { // After discarding old periods, we should never have more periods than listed in the new // manifest. That would mean that a previously announced period is no longer advertised. If // this condition occurs, assume that we are hitting a manifest server that is out of sync // and // behind. Log.w(TAG, "Loaded out of sync manifest"); isManifestStale = true; } else if (expiredManifestPublishTimeUs != C.TIME_UNSET && newManifest.publishTimeMs * 1000 <= expiredManifestPublishTimeUs) { // If we receive a dynamic manifest that's older than expected (i.e. its publish time has // expired, or it's dynamic and we know the presentation has ended), then this manifest is // stale. Log.w( TAG, "Loaded stale dynamic manifest: " + newManifest.publishTimeMs + ", " + expiredManifestPublishTimeUs); isManifestStale = true; } if (isManifestStale) { if (staleManifestReloadAttempt++ < loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type)) { scheduleManifestRefresh(getManifestLoadRetryDelayMillis()); } else { manifestFatalError = new DashManifestStaleException(); } return; } staleManifestReloadAttempt = 0; } manifest = newManifest; manifestLoadPending &= manifest.dynamic; manifestLoadStartTimestampMs = elapsedRealtimeMs - loadDurationMs; manifestLoadEndTimestampMs = elapsedRealtimeMs; if (manifest.location != null) { synchronized (manifestUriLock) { // This condition checks that replaceManifestUri wasn't called between the start and end of // this load. If it was, we ignore the manifest location and prefer the manual replacement. @SuppressWarnings("ReferenceEquality") boolean isSameUriInstance = loadable.dataSpec.uri == manifestUri; if (isSameUriInstance) { manifestUri = manifest.location; } } } if (oldPeriodCount == 0) { if (manifest.dynamic && manifest.utcTiming != null) { resolveUtcTimingElement(manifest.utcTiming); } else { processManifest(true); } } else { firstPeriodId += removedPeriodCount; processManifest(true); } }
Example 19
Source File: DashMediaSource.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
void onManifestLoadCompleted(ParsingLoadable<DashManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); DashManifest newManifest = loadable.getResult(); int periodCount = manifest == null ? 0 : manifest.getPeriodCount(); int removedPeriodCount = 0; long newFirstPeriodStartTimeMs = newManifest.getPeriod(0).startMs; while (removedPeriodCount < periodCount && manifest.getPeriod(removedPeriodCount).startMs < newFirstPeriodStartTimeMs) { removedPeriodCount++; } if (newManifest.dynamic) { boolean isManifestStale = false; if (periodCount - removedPeriodCount > newManifest.getPeriodCount()) { // After discarding old periods, we should never have more periods than listed in the new // manifest. That would mean that a previously announced period is no longer advertised. If // this condition occurs, assume that we are hitting a manifest server that is out of sync // and // behind. Log.w(TAG, "Loaded out of sync manifest"); isManifestStale = true; } else if (dynamicMediaPresentationEnded || (expiredManifestPublishTimeUs != C.TIME_UNSET && newManifest.publishTimeMs * 1000 <= expiredManifestPublishTimeUs)) { // If we receive a dynamic manifest that's older than expected (i.e. its publish time has // expired, or it's dynamic and we know the presentation has ended), then this manifest is // stale. Log.w( TAG, "Loaded stale dynamic manifest: " + newManifest.publishTimeMs + ", " + dynamicMediaPresentationEnded + ", " + expiredManifestPublishTimeUs); isManifestStale = true; } if (isManifestStale) { if (staleManifestReloadAttempt++ < minLoadableRetryCount) { scheduleManifestRefresh(getManifestLoadRetryDelayMillis()); } else { manifestFatalError = new DashManifestStaleException(); } return; } staleManifestReloadAttempt = 0; } manifest = newManifest; manifestLoadPending &= manifest.dynamic; manifestLoadStartTimestampMs = elapsedRealtimeMs - loadDurationMs; manifestLoadEndTimestampMs = elapsedRealtimeMs; if (manifest.location != null) { synchronized (manifestUriLock) { // This condition checks that replaceManifestUri wasn't called between the start and end of // this load. If it was, we ignore the manifest location and prefer the manual replacement. @SuppressWarnings("ReferenceEquality") boolean isSameUriInstance = loadable.dataSpec.uri == manifestUri; if (isSameUriInstance) { manifestUri = manifest.location; } } } if (periodCount == 0) { if (manifest.utcTiming != null) { resolveUtcTimingElement(manifest.utcTiming); } else { processManifest(true); } } else { firstPeriodId += removedPeriodCount; processManifest(true); } }
Example 20
Source File: DashMediaSource.java From MediaSDK with Apache License 2.0 | 4 votes |
void onManifestLoadCompleted(ParsingLoadable<DashManifest> loadable, long elapsedRealtimeMs, long loadDurationMs) { manifestEventDispatcher.loadCompleted( loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); DashManifest newManifest = loadable.getResult(); int oldPeriodCount = manifest == null ? 0 : manifest.getPeriodCount(); int removedPeriodCount = 0; long newFirstPeriodStartTimeMs = newManifest.getPeriod(0).startMs; while (removedPeriodCount < oldPeriodCount && manifest.getPeriod(removedPeriodCount).startMs < newFirstPeriodStartTimeMs) { removedPeriodCount++; } if (newManifest.dynamic) { boolean isManifestStale = false; if (oldPeriodCount - removedPeriodCount > newManifest.getPeriodCount()) { // After discarding old periods, we should never have more periods than listed in the new // manifest. That would mean that a previously announced period is no longer advertised. If // this condition occurs, assume that we are hitting a manifest server that is out of sync // and // behind. Log.w(TAG, "Loaded out of sync manifest"); isManifestStale = true; } else if (expiredManifestPublishTimeUs != C.TIME_UNSET && newManifest.publishTimeMs * 1000 <= expiredManifestPublishTimeUs) { // If we receive a dynamic manifest that's older than expected (i.e. its publish time has // expired, or it's dynamic and we know the presentation has ended), then this manifest is // stale. Log.w( TAG, "Loaded stale dynamic manifest: " + newManifest.publishTimeMs + ", " + expiredManifestPublishTimeUs); isManifestStale = true; } if (isManifestStale) { if (staleManifestReloadAttempt++ < loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type)) { scheduleManifestRefresh(getManifestLoadRetryDelayMillis()); } else { manifestFatalError = new DashManifestStaleException(); } return; } staleManifestReloadAttempt = 0; } manifest = newManifest; manifestLoadPending &= manifest.dynamic; manifestLoadStartTimestampMs = elapsedRealtimeMs - loadDurationMs; manifestLoadEndTimestampMs = elapsedRealtimeMs; if (manifest.location != null) { synchronized (manifestUriLock) { // This condition checks that replaceManifestUri wasn't called between the start and end of // this load. If it was, we ignore the manifest location and prefer the manual replacement. @SuppressWarnings("ReferenceEquality") boolean isSameUriInstance = loadable.dataSpec.uri == manifestUri; if (isSameUriInstance) { manifestUri = manifest.location; } } } if (oldPeriodCount == 0) { if (manifest.dynamic && manifest.utcTiming != null) { resolveUtcTimingElement(manifest.utcTiming); } else { processManifest(true); } } else { firstPeriodId += removedPeriodCount; processManifest(true); } }