From d74166cd355a6ae3b2d71382b234cf40606e984c Mon Sep 17 00:00:00 2001 From: anjalibh Date: Mon, 26 Sep 2016 11:20:58 -0700 Subject: [PATCH] Parse Projection, ProjectionPrivate As described in https://github.com/google/spatial-media/blob/master/docs/spherical-video-v2-rfc.md. Also parse StereoMode as per standard matroska spec. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134302208 --- .../extractor/mkv/MatroskaExtractor.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java b/library/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java index 2d84e73c1e..bc2d891dab 100644 --- a/library/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java +++ b/library/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java @@ -163,6 +163,9 @@ public final class MatroskaExtractor implements Extractor { private static final int ID_CUE_TRACK_POSITIONS = 0xB7; private static final int ID_CUE_CLUSTER_POSITION = 0xF1; private static final int ID_LANGUAGE = 0x22B59C; + private static final int ID_PROJECTION = 0x7670; + private static final int ID_PROJECTION_PRIVATE = 0x7672; + private static final int ID_STEREO_MODE = 0x53B8; private static final int LACING_NONE = 0; private static final int LACING_XIPH = 1; @@ -362,6 +365,7 @@ public final class MatroskaExtractor implements Extractor { case ID_CUE_POINT: case ID_CUE_TRACK_POSITIONS: case ID_BLOCK_GROUP: + case ID_PROJECTION: return EbmlReader.TYPE_MASTER; case ID_EBML_READ_VERSION: case ID_DOC_TYPE_READ_VERSION: @@ -391,6 +395,7 @@ public final class MatroskaExtractor implements Extractor { case ID_CUE_TIME: case ID_CUE_CLUSTER_POSITION: case ID_REFERENCE_BLOCK: + case ID_STEREO_MODE: return EbmlReader.TYPE_UNSIGNED_INT; case ID_DOC_TYPE: case ID_CODEC_ID: @@ -402,6 +407,7 @@ public final class MatroskaExtractor implements Extractor { case ID_SIMPLE_BLOCK: case ID_BLOCK: case ID_CODEC_PRIVATE: + case ID_PROJECTION_PRIVATE: return EbmlReader.TYPE_BINARY; case ID_DURATION: case ID_SAMPLING_FREQUENCY: @@ -656,6 +662,22 @@ public final class MatroskaExtractor implements Extractor { case ID_BLOCK_DURATION: blockDurationUs = scaleTimecodeToUs(value); return; + case ID_STEREO_MODE: + int layout = (int) value; + switch (layout) { + case 0: + currentTrack.stereoMode = C.STEREO_MODE_MONO; + break; + case 1: + currentTrack.stereoMode = C.STEREO_MODE_LEFT_RIGHT; + break; + case 3: + currentTrack.stereoMode = C.STEREO_MODE_TOP_BOTTOM; + break; + default: + break; + } + return; default: return; } @@ -706,6 +728,10 @@ public final class MatroskaExtractor implements Extractor { currentTrack.codecPrivate = new byte[contentSize]; input.readFully(currentTrack.codecPrivate, 0, contentSize); return; + case ID_PROJECTION_PRIVATE: + currentTrack.projectionData = new byte[contentSize]; + input.readFully(currentTrack.projectionData, 0, contentSize); + return; case ID_CONTENT_COMPRESSION_SETTINGS: // This extractor only supports header stripping, so the payload is the stripped bytes. currentTrack.sampleStrippedBytes = new byte[contentSize]; @@ -1292,6 +1318,9 @@ public final class MatroskaExtractor implements Extractor { public int displayWidth = Format.NO_VALUE; public int displayHeight = Format.NO_VALUE; public int displayUnit = DISPLAY_UNIT_PIXELS; + public byte[] projectionData = null; + @C.StereoMode + public int stereoMode = Format.NO_VALUE; // Audio elements. Initially set to their default values. public int channelCount = 1; @@ -1450,7 +1479,7 @@ public final class MatroskaExtractor implements Extractor { } format = Format.createVideoSampleFormat(Integer.toString(trackId), mimeType, null, Format.NO_VALUE, maxInputSize, width, height, Format.NO_VALUE, initializationData, - Format.NO_VALUE, pixelWidthHeightRatio, drmInitData); + Format.NO_VALUE, pixelWidthHeightRatio, projectionData, stereoMode, drmInitData); } else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) { format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, null, Format.NO_VALUE, selectionFlags, language, drmInitData);