Search in sources :

Example 11 with DashManifest

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);
}
Also used : DashManifest(com.google.android.exoplayer2.source.dash.manifest.DashManifest)

Example 12 with DashManifest

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);
    }
}
Also used : DashManifest(com.google.android.exoplayer2.source.dash.manifest.DashManifest)

Example 13 with DashManifest

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();
    }
}
Also used : DashManifestParser(com.google.android.exoplayer2.source.dash.manifest.DashManifestParser) DataSpec(com.google.android.exoplayer2.upstream.DataSpec) DataSourceInputStream(com.google.android.exoplayer2.upstream.DataSourceInputStream)

Example 14 with DashManifest

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;
    }
}
Also used : BehindLiveWindowException(com.google.android.exoplayer2.source.BehindLiveWindowException) Representation(com.google.android.exoplayer2.source.dash.manifest.Representation)

Example 15 with DashManifest

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);
    }
}
Also used : ParserException(com.google.android.exoplayer2.ParserException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) XmlPullParser(org.xmlpull.v1.XmlPullParser) XmlPullParserException(org.xmlpull.v1.XmlPullParserException)

Aggregations

DashManifest (com.google.android.exoplayer2.source.dash.manifest.DashManifest)10 ParserException (com.google.android.exoplayer2.ParserException)2 Representation (com.google.android.exoplayer2.source.dash.manifest.Representation)2 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)2 Uri (android.net.Uri)1 Pair (android.util.Pair)1 Format (com.google.android.exoplayer2.Format)1 BehindLiveWindowException (com.google.android.exoplayer2.source.BehindLiveWindowException)1 AdaptationSet (com.google.android.exoplayer2.source.dash.manifest.AdaptationSet)1 DashManifestParser (com.google.android.exoplayer2.source.dash.manifest.DashManifestParser)1 Period (com.google.android.exoplayer2.source.dash.manifest.Period)1 DataSourceInputStream (com.google.android.exoplayer2.upstream.DataSourceInputStream)1 DataSpec (com.google.android.exoplayer2.upstream.DataSpec)1 ArrayList (java.util.ArrayList)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1