Skip to content

Commit

Permalink
Handle bracket params on the end of SmoothStreaming URLs
Browse files Browse the repository at this point in the history
Issue: #3230

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169421873
  • Loading branch information
ojw28 committed Sep 20, 2017
1 parent 6314a0e commit ce7aaab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,7 @@ public static int inferContentType(String fileName) {
return C.TYPE_DASH;
} else if (fileName.endsWith(".m3u8")) {
return C.TYPE_HLS;
} else if (fileName.endsWith(".ism") || fileName.endsWith(".isml")
|| fileName.endsWith(".ism/manifest") || fileName.endsWith(".isml/manifest")) {
} else if (fileName.matches(".*\\.ism(l)?(/manifest(\\(.+\\))?)?")) {
return C.TYPE_SS;
} else {
return C.TYPE_OTHER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static com.google.android.exoplayer2.util.Util.unescapeFileName;
import static com.google.common.truth.Truth.assertThat;

import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.testutil.TestUtil;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -39,6 +40,18 @@
@Config(sdk = Config.TARGET_SDK, manifest = Config.NONE)
public class UtilTest {

@Test
public void testInferContentType() {
assertThat(Util.inferContentType("http://a.b/c.ism")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentType("http://a.b/c.isml")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentType("http://a.b/c.ism/Manifest")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentType("http://a.b/c.isml/manifest")).isEqualTo(C.TYPE_SS);
assertThat(Util.inferContentType("http://a.b/c.isml/manifest(filter=x)")).isEqualTo(C.TYPE_SS);

assertThat(Util.inferContentType("http://a.b/c.ism/prefix-manifest")).isEqualTo(C.TYPE_OTHER);
assertThat(Util.inferContentType("http://a.b/c.ism/manifest-suffix")).isEqualTo(C.TYPE_OTHER);
}

@Test
public void testArrayBinarySearchFloor() {
long[] values = new long[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ private SsMediaSource(SsManifest manifest, Uri manifestUri,
Assertions.checkState(manifest == null || !manifest.isLive);
this.manifest = manifest;
this.manifestUri = manifestUri == null ? null
: Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest") ? manifestUri
: Uri.withAppendedPath(manifestUri, "Manifest");
: Util.toLowerInvariant(manifestUri.getLastPathSegment()).matches("manifest(\\(.+\\))?")
? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest");
this.manifestDataSourceFactory = manifestDataSourceFactory;
this.manifestParser = manifestParser;
this.chunkSourceFactory = chunkSourceFactory;
Expand Down

0 comments on commit ce7aaab

Please sign in to comment.