Search in sources :

Example 11 with HttpDataSource

use of com.google.android.exoplayer2.upstream.HttpDataSource 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 HttpDataSource

use of com.google.android.exoplayer2.upstream.HttpDataSource 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)

Aggregations

DashManifest (com.google.android.exoplayer2.source.dash.manifest.DashManifest)9 DataSourceInputStream (com.google.android.exoplayer2.upstream.DataSourceInputStream)2 DataSpec (com.google.android.exoplayer2.upstream.DataSpec)2 Format (com.google.android.exoplayer2.Format)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 Representation (com.google.android.exoplayer2.source.dash.manifest.Representation)1 HttpDataSource (com.google.android.exoplayer2.upstream.HttpDataSource)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1