use of com.google.android.exoplayer2.source.dash.manifest.DashManifest in project ExoPlayer by google.
the class OfflineLicenseHelperTest method testDownloadRenewReleaseKey.
public void testDownloadRenewReleaseKey() throws Exception {
DashManifest manifest = newDashManifestWithAllElements();
setStubLicenseAndPlaybackDurationValues(1000, 200);
byte[] keySetId = { 2, 5, 8 };
setStubKeySetId(keySetId);
byte[] offlineLicenseKeySetId = offlineLicenseHelper.download(httpDataSource, manifest);
assertOfflineLicenseKeySetIdEqual(keySetId, offlineLicenseKeySetId);
byte[] keySetId2 = { 6, 7, 0, 1, 4 };
setStubKeySetId(keySetId2);
byte[] offlineLicenseKeySetId2 = offlineLicenseHelper.renew(offlineLicenseKeySetId);
assertOfflineLicenseKeySetIdEqual(keySetId2, offlineLicenseKeySetId2);
offlineLicenseHelper.release(offlineLicenseKeySetId2);
}
use of com.google.android.exoplayer2.source.dash.manifest.DashManifest in project ExoPlayer by google.
the class DashMediaSource method onManifestLoadCompleted.
// Loadable callbacks.
/* package */
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++;
}
// 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 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);
}
}
use of com.google.android.exoplayer2.source.dash.manifest.DashManifest in project ExoPlayer by google.
the class DashUtil method loadManifest.
/**
* Loads a DASH manifest.
*
* @param dataSource The {@link HttpDataSource} from which the manifest should be read.
* @param manifestUriString The URI of the manifest to be read.
* @return An instance of {@link DashManifest}.
* @throws IOException If an error occurs reading data from the stream.
* @see DashManifestParser
*/
public static DashManifest loadManifest(DataSource dataSource, String manifestUriString) throws IOException {
DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, new DataSpec(Uri.parse(manifestUriString), DataSpec.FLAG_ALLOW_CACHING_UNKNOWN_LENGTH));
try {
inputStream.open();
DashManifestParser parser = new DashManifestParser();
return parser.parse(dataSource.getUri(), inputStream);
} finally {
inputStream.close();
}
}
use of com.google.android.exoplayer2.source.dash.manifest.DashManifest in project ExoPlayer by google.
the class DefaultDashChunkSource method updateManifest.
@Override
public void updateManifest(DashManifest newManifest, int newPeriodIndex) {
try {
manifest = newManifest;
periodIndex = newPeriodIndex;
long periodDurationUs = manifest.getPeriodDurationUs(periodIndex);
List<Representation> representations = getAdaptationSet().representations;
for (int i = 0; i < representationHolders.length; i++) {
Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
representationHolders[i].updateRepresentation(periodDurationUs, representation);
}
} catch (BehindLiveWindowException e) {
fatalError = e;
}
}
use of com.google.android.exoplayer2.source.dash.manifest.DashManifest in project ExoPlayer by google.
the class DashManifestParser method parse.
// MPD parsing.
@Override
public DashManifest parse(Uri uri, InputStream inputStream) throws IOException {
try {
XmlPullParser xpp = xmlParserFactory.newPullParser();
xpp.setInput(inputStream, null);
int eventType = xpp.next();
if (eventType != XmlPullParser.START_TAG || !"MPD".equals(xpp.getName())) {
throw new ParserException("inputStream does not contain a valid media presentation description");
}
return parseMediaPresentationDescription(xpp, uri.toString());
} catch (XmlPullParserException e) {
throw new ParserException(e);
}
}
Aggregations