提交 0ae56cc1 编写于 作者: E eguven 提交者: Oliver Woodman

Fix SmoothStreaming manifest url for downloading

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185526653
上级 93e6813f
......@@ -53,10 +53,8 @@ public final class DashUtil {
*/
public static DashManifest loadManifest(DataSource dataSource, Uri uri)
throws IOException {
DataSpec dataSpec = new DataSpec(uri,
DataSpec.FLAG_ALLOW_CACHING_UNKNOWN_LENGTH | DataSpec.FLAG_ALLOW_GZIP);
ParsingLoadable<DashManifest> loadable = new ParsingLoadable<>(dataSource, dataSpec,
C.DATA_TYPE_MANIFEST, new DashManifestParser());
ParsingLoadable<DashManifest> loadable =
new ParsingLoadable<>(dataSource, uri, C.DATA_TYPE_MANIFEST, new DashManifestParser());
loadable.load();
return loadable.getResult();
}
......
......@@ -104,10 +104,8 @@ public final class HlsDownloader extends SegmentDownloader<HlsMasterPlaylist, St
}
private static HlsPlaylist loadManifest(DataSource dataSource, Uri uri) throws IOException {
DataSpec dataSpec = new DataSpec(uri,
DataSpec.FLAG_ALLOW_CACHING_UNKNOWN_LENGTH | DataSpec.FLAG_ALLOW_GZIP);
ParsingLoadable<HlsPlaylist> loadable = new ParsingLoadable<>(dataSource, dataSpec,
C.DATA_TYPE_MANIFEST, new HlsPlaylistParser());
ParsingLoadable<HlsPlaylist> loadable =
new ParsingLoadable<>(dataSource, uri, C.DATA_TYPE_MANIFEST, new HlsPlaylistParser());
loadable.load();
return loadable.getResult();
}
......
......@@ -36,13 +36,13 @@ import com.google.android.exoplayer2.source.ads.AdsMediaSource;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsUtil;
import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.Loader;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.ParsingLoadable;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
import java.util.ArrayList;
......@@ -403,9 +403,7 @@ public final class SsMediaSource implements MediaSource,
MediaSourceEventListener eventListener) {
Assertions.checkState(manifest == null || !manifest.isLive);
this.manifest = manifest;
this.manifestUri = manifestUri == null ? null
: Util.toLowerInvariant(manifestUri.getLastPathSegment()).matches("manifest(\\(.+\\))?")
? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest");
this.manifestUri = manifestUri == null ? null : SsUtil.fixManifestUri(manifestUri);
this.manifestDataSourceFactory = manifestDataSourceFactory;
this.manifestParser = manifestParser;
this.chunkSourceFactory = chunkSourceFactory;
......
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.source.smoothstreaming.manifest;
import android.net.Uri;
import com.google.android.exoplayer2.util.Util;
/** SmoothStreaming related utility methods. */
public final class SsUtil {
/** Returns a fixed SmoothStreaming client manifest {@link Uri}. */
public static Uri fixManifestUri(Uri manifestUri) {
if (Util.toLowerInvariant(manifestUri.getLastPathSegment()).matches("manifest(\\(.+\\))?")) {
return manifestUri;
}
return Uri.withAppendedPath(manifestUri, "Manifest");
}
private SsUtil() {}
}
......@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.offline.SegmentDownloader;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsUtil;
import com.google.android.exoplayer2.source.smoothstreaming.manifest.TrackKey;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
......@@ -64,7 +65,7 @@ public final class SsDownloader extends SegmentDownloader<SsManifest, TrackKey>
* @see SegmentDownloader#SegmentDownloader(Uri, DownloaderConstructorHelper)
*/
public SsDownloader(Uri manifestUri, DownloaderConstructorHelper constructorHelper) {
super(manifestUri, constructorHelper);
super(SsUtil.fixManifestUri(manifestUri), constructorHelper);
}
@Override
......@@ -82,10 +83,8 @@ public final class SsDownloader extends SegmentDownloader<SsManifest, TrackKey>
@Override
protected SsManifest getManifest(DataSource dataSource, Uri uri) throws IOException {
DataSpec dataSpec = new DataSpec(uri,
DataSpec.FLAG_ALLOW_CACHING_UNKNOWN_LENGTH | DataSpec.FLAG_ALLOW_GZIP);
ParsingLoadable<SsManifest> loadable = new ParsingLoadable<>(dataSource, dataSpec,
C.DATA_TYPE_MANIFEST, new SsManifestParser());
ParsingLoadable<SsManifest> loadable =
new ParsingLoadable<>(dataSource, uri, C.DATA_TYPE_MANIFEST, new SsManifestParser());
loadable.load();
return loadable.getResult();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册