diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java b/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java index e033ec31fc..f7c26bbd27 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java @@ -56,6 +56,8 @@ public final class MimeTypes { public static final String VIDEO_OGG = BASE_TYPE_VIDEO + "/ogg"; public static final String VIDEO_AVI = BASE_TYPE_VIDEO + "/x-msvideo"; public static final String VIDEO_MJPEG = BASE_TYPE_VIDEO + "/mjpeg"; + public static final String VIDEO_MP42 = BASE_TYPE_VIDEO + "/mp42"; + public static final String VIDEO_MP43 = BASE_TYPE_VIDEO + "/mp43"; public static final String VIDEO_UNKNOWN = BASE_TYPE_VIDEO + "/x-unknown"; // audio/ MIME types diff --git a/library/extractor/build.gradle b/library/extractor/build.gradle index 0d4ef9abfd..f05134129b 100644 --- a/library/extractor/build.gradle +++ b/library/extractor/build.gradle @@ -19,11 +19,6 @@ android { testCoverageEnabled = true } } - testOptions{ - unitTests.all { - jvmArgs '-noverify' - } - } sourceSets.test.assets.srcDir '../../testdata/src/test/assets/' } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java index f709a68e82..5efd155396 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/AviSeekMap.java @@ -26,13 +26,13 @@ import java.util.Arrays; * Consists of Video chunk offsets and indexes for all streams */ public class AviSeekMap implements SeekMap { - final int videoId; - final long videoUsPerChunk; - final long duration; + private final int videoId; + private final long videoUsPerChunk; + private final long duration; //These are ints / 2 - final int[] keyFrameOffsetsDiv2; + private final int[] keyFrameOffsetsDiv2; //Seek chunk indexes by streamId - final int[][] seekIndexes; + private final int[][] seekIndexes; /** * Usually the same as moviOffset, but sometimes 0 (muxer bug) */ @@ -118,4 +118,19 @@ public class AviSeekMap implements SeekMap { } return indexes; } + + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + public long getKeyFrameOffsets(int streamId) { + return keyFrameOffsetsDiv2[streamId] * 2L; + } + + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + public int[] getSeekIndexes(int streamId) { + return seekIndexes[streamId]; + } + + @VisibleForTesting(otherwise = VisibleForTesting.NONE) + public long getVideoUsPerChunk() { + return videoUsPerChunk; + } } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ChunkHandler.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ChunkHandler.java index e764515343..c18c76e496 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ChunkHandler.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ChunkHandler.java @@ -35,8 +35,8 @@ public class ChunkHandler { */ public static final int[] ALL_KEY_FRAMES = new int[0]; - public static int TYPE_VIDEO = ('d' << 16) | ('c' << 24); - public static int TYPE_AUDIO = ('w' << 16) | ('b' << 24); + public static final int TYPE_VIDEO = ('d' << 16) | ('c' << 24); + public static final int TYPE_AUDIO = ('w' << 16) | ('b' << 24); @NonNull ChunkClock clock; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ListBox.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ListBox.java index daf5b4fc7a..761328c4e1 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ListBox.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/ListBox.java @@ -37,7 +37,7 @@ public class ListBox extends Box { final List children; - ListBox(int size, int listType, List children) { + public ListBox(int size, int listType, List children) { super(LIST, size); this.listType = listType; this.children = children; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/VideoFormat.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/VideoFormat.java index 8bda2df4e6..9f12ff813f 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/VideoFormat.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/VideoFormat.java @@ -32,12 +32,11 @@ public class VideoFormat { static { //Although other types are technically supported, AVI is almost exclusively MP4V and MJPEG final String mimeType = MimeTypes.VIDEO_MP4V; - //final String mimeType = MimeTypes.VIDEO_H263; //I've never seen an Android devices that actually supports MP42 - STREAM_MAP.put('M' | ('P' << 8) | ('4' << 16) | ('2' << 24), MimeTypes.BASE_TYPE_VIDEO+"/mp42"); + STREAM_MAP.put('M' | ('P' << 8) | ('4' << 16) | ('2' << 24), MimeTypes.VIDEO_MP42); //Samsung seems to support the rare MP43. - STREAM_MAP.put('M' | ('P' << 8) | ('4' << 16) | ('3' << 24), MimeTypes.BASE_TYPE_VIDEO+"/mp43"); + STREAM_MAP.put('M' | ('P' << 8) | ('4' << 16) | ('3' << 24), MimeTypes.VIDEO_MP43); STREAM_MAP.put('H' | ('2' << 8) | ('6' << 16) | ('4' << 24), MimeTypes.VIDEO_H264); STREAM_MAP.put('a' | ('v' << 8) | ('c' << 16) | ('1' << 24), MimeTypes.VIDEO_H264); STREAM_MAP.put('A' | ('V' << 8) | ('C' << 16) | ('1' << 24), MimeTypes.VIDEO_H264); diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorTest.java index 205ddab5c6..29500f4edd 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviExtractorTest.java @@ -176,10 +176,10 @@ public class AviExtractorTest { Assert.assertEquals(2 * framesPerKeyFrame, videoTrack.keyFrames[2]); Assert.assertEquals(2 * keyFrameRate * DataHelper.AUDIO_PER_VIDEO, - aviSeekMap.seekIndexes[DataHelper.AUDIO_ID][2]); + aviSeekMap.getSeekIndexes(DataHelper.AUDIO_ID)[2]); Assert.assertEquals(4L + 2 * keyFrameRate * DataHelper.VIDEO_SIZE + 2 * keyFrameRate * DataHelper.AUDIO_SIZE * DataHelper.AUDIO_PER_VIDEO, - aviSeekMap.keyFrameOffsetsDiv2[2] * 2L); + aviSeekMap.getKeyFrameOffsets(2)); } @@ -471,9 +471,10 @@ public class AviExtractorTest { final AviSeekMap aviSeekMap = DataHelper.getAviSeekMap(); aviExtractor.aviSeekMap = aviSeekMap; final ChunkHandler chunkHandler = aviExtractor.getVideoTrack(); - final long position = DataHelper.MOVI_OFFSET + aviSeekMap.keyFrameOffsetsDiv2[1] * 2L; + final long position = DataHelper.MOVI_OFFSET + aviSeekMap.getKeyFrameOffsets(DataHelper.AUDIO_ID); aviExtractor.seek(position, 0L); - Assert.assertEquals(aviSeekMap.seekIndexes[chunkHandler.getId()][1], chunkHandler.getClock().getIndex()); + Assert.assertEquals(aviSeekMap.getSeekIndexes(chunkHandler.getId())[1], + chunkHandler.getClock().getIndex()); } @Test diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviSeekMapTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviSeekMapTest.java index 60e12289c9..1f32a93490 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviSeekMapTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/AviSeekMapTest.java @@ -24,14 +24,14 @@ public class AviSeekMapTest { @Test public void getFrames_givenExactSeekPointMatch() { final AviSeekMap aviSeekMap = DataHelper.getAviSeekMap(); - final long position = aviSeekMap.keyFrameOffsetsDiv2[1] * 2L + aviSeekMap.seekOffset; + final long position = aviSeekMap.getKeyFrameOffsets(DataHelper.AUDIO_ID) + aviSeekMap.seekOffset; final int secs = 4; final ChunkHandler[] chunkHandlers = new ChunkHandler[]{DataHelper.getVideoChunkHandler(secs), DataHelper.getAudioChunkHandler(secs)}; int[] indexes = aviSeekMap.getIndexes(position); for (int i=0;i