Merge "Add parameter for including supplemental data" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3fe718ae20
@@ -468,7 +468,24 @@ public final class MediaParser {
|
|||||||
public @interface SampleFlags {}
|
public @interface SampleFlags {}
|
||||||
/** Indicates that the sample holds a synchronization sample. */
|
/** Indicates that the sample holds a synchronization sample. */
|
||||||
public static final int SAMPLE_FLAG_KEY_FRAME = MediaCodec.BUFFER_FLAG_KEY_FRAME;
|
public static final int SAMPLE_FLAG_KEY_FRAME = MediaCodec.BUFFER_FLAG_KEY_FRAME;
|
||||||
/** Indicates that the sample has supplemental data. */
|
/**
|
||||||
|
* Indicates that the sample has supplemental data.
|
||||||
|
*
|
||||||
|
* <p>Samples will not have this flag set unless the {@code
|
||||||
|
* "android.media.mediaparser.includeSupplementalData"} parameter is set to {@code true} via
|
||||||
|
* {@link #setParameter}.
|
||||||
|
*
|
||||||
|
* <p>Samples with supplemental data have the following sample data format:
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>If the {@code "android.media.mediaparser.inBandCryptoInfo"} parameter is set, all
|
||||||
|
* encryption information.
|
||||||
|
* <li>(4 bytes) {@code sample_data_size}: The size of the actual sample data, not including
|
||||||
|
* supplemental data or encryption information.
|
||||||
|
* <li>({@code sample_data_size} bytes): The media sample data.
|
||||||
|
* <li>(remaining bytes) The supplemental data.
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
public static final int SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA = 1 << 28;
|
public static final int SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA = 1 << 28;
|
||||||
/** Indicates that the sample is known to contain the last media sample of the stream. */
|
/** Indicates that the sample is known to contain the last media sample of the stream. */
|
||||||
public static final int SAMPLE_FLAG_LAST_SAMPLE = 1 << 29;
|
public static final int SAMPLE_FLAG_LAST_SAMPLE = 1 << 29;
|
||||||
@@ -579,7 +596,9 @@ public final class MediaParser {
|
|||||||
PARAMETER_TS_IGNORE_AVC_STREAM,
|
PARAMETER_TS_IGNORE_AVC_STREAM,
|
||||||
PARAMETER_TS_IGNORE_SPLICE_INFO_STREAM,
|
PARAMETER_TS_IGNORE_SPLICE_INFO_STREAM,
|
||||||
PARAMETER_TS_DETECT_ACCESS_UNITS,
|
PARAMETER_TS_DETECT_ACCESS_UNITS,
|
||||||
PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS
|
PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS,
|
||||||
|
PARAMETER_IN_BAND_CRYPTO_INFO,
|
||||||
|
PARAMETER_INCLUDE_SUPPLEMENTAL_DATA
|
||||||
})
|
})
|
||||||
public @interface ParameterName {}
|
public @interface ParameterName {}
|
||||||
|
|
||||||
@@ -741,6 +760,16 @@ public final class MediaParser {
|
|||||||
public static final String PARAMETER_IN_BAND_CRYPTO_INFO =
|
public static final String PARAMETER_IN_BAND_CRYPTO_INFO =
|
||||||
"android.media.mediaparser.inBandCryptoInfo";
|
"android.media.mediaparser.inBandCryptoInfo";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether supplemental data should be included as part of the sample data. {@code boolean}
|
||||||
|
* expected. Default value is {@code false}. See {@link #SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA} for
|
||||||
|
* information about the sample data format.
|
||||||
|
*
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String PARAMETER_INCLUDE_SUPPLEMENTAL_DATA =
|
||||||
|
"android.media.mediaparser.includeSupplementalData";
|
||||||
|
|
||||||
// Private constants.
|
// Private constants.
|
||||||
|
|
||||||
private static final String TAG = "MediaParser";
|
private static final String TAG = "MediaParser";
|
||||||
@@ -900,6 +929,7 @@ public final class MediaParser {
|
|||||||
private final ParsableByteArrayAdapter mScratchParsableByteArrayAdapter;
|
private final ParsableByteArrayAdapter mScratchParsableByteArrayAdapter;
|
||||||
@Nullable private final Constructor<DrmInitData.SchemeInitData> mSchemeInitDataConstructor;
|
@Nullable private final Constructor<DrmInitData.SchemeInitData> mSchemeInitDataConstructor;
|
||||||
private boolean mInBandCryptoInfo;
|
private boolean mInBandCryptoInfo;
|
||||||
|
private boolean mIncludeSupplementalData;
|
||||||
private String mParserName;
|
private String mParserName;
|
||||||
private Extractor mExtractor;
|
private Extractor mExtractor;
|
||||||
private ExtractorInput mExtractorInput;
|
private ExtractorInput mExtractorInput;
|
||||||
@@ -950,6 +980,9 @@ public final class MediaParser {
|
|||||||
if (PARAMETER_IN_BAND_CRYPTO_INFO.equals(parameterName)) {
|
if (PARAMETER_IN_BAND_CRYPTO_INFO.equals(parameterName)) {
|
||||||
mInBandCryptoInfo = (boolean) value;
|
mInBandCryptoInfo = (boolean) value;
|
||||||
}
|
}
|
||||||
|
if (PARAMETER_INCLUDE_SUPPLEMENTAL_DATA.equals(parameterName)) {
|
||||||
|
mIncludeSupplementalData = (boolean) value;
|
||||||
|
}
|
||||||
mParserParameters.put(parameterName, value);
|
mParserParameters.put(parameterName, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -1334,6 +1367,7 @@ public final class MediaParser {
|
|||||||
private int mEncryptionVectorSize;
|
private int mEncryptionVectorSize;
|
||||||
private boolean mHasSubsampleEncryptionData;
|
private boolean mHasSubsampleEncryptionData;
|
||||||
private CryptoInfo.Pattern mEncryptionPattern;
|
private CryptoInfo.Pattern mEncryptionPattern;
|
||||||
|
private int mSkippedSupplementalDataBytes;
|
||||||
|
|
||||||
private TrackOutputAdapter(int trackIndex) {
|
private TrackOutputAdapter(int trackIndex) {
|
||||||
mTrackIndex = trackIndex;
|
mTrackIndex = trackIndex;
|
||||||
@@ -1423,6 +1457,10 @@ public final class MediaParser {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (sampleDataPart == SAMPLE_DATA_PART_SUPPLEMENTAL
|
||||||
|
&& !mIncludeSupplementalData) {
|
||||||
|
mSkippedSupplementalDataBytes += length;
|
||||||
|
data.skipBytes(length);
|
||||||
} else {
|
} else {
|
||||||
outputSampleData(data, length);
|
outputSampleData(data, length);
|
||||||
}
|
}
|
||||||
@@ -1431,6 +1469,8 @@ public final class MediaParser {
|
|||||||
@Override
|
@Override
|
||||||
public void sampleMetadata(
|
public void sampleMetadata(
|
||||||
long timeUs, int flags, int size, int offset, @Nullable CryptoData cryptoData) {
|
long timeUs, int flags, int size, int offset, @Nullable CryptoData cryptoData) {
|
||||||
|
size -= mSkippedSupplementalDataBytes;
|
||||||
|
mSkippedSupplementalDataBytes = 0;
|
||||||
mOutputConsumer.onSampleCompleted(
|
mOutputConsumer.onSampleCompleted(
|
||||||
mTrackIndex,
|
mTrackIndex,
|
||||||
timeUs,
|
timeUs,
|
||||||
@@ -1690,13 +1730,13 @@ public final class MediaParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getMediaParserFlags(int flags) {
|
private int getMediaParserFlags(int flags) {
|
||||||
@SampleFlags int result = 0;
|
@SampleFlags int result = 0;
|
||||||
result |= (flags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? SAMPLE_FLAG_ENCRYPTED : 0;
|
result |= (flags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? SAMPLE_FLAG_ENCRYPTED : 0;
|
||||||
result |= (flags & C.BUFFER_FLAG_KEY_FRAME) != 0 ? SAMPLE_FLAG_KEY_FRAME : 0;
|
result |= (flags & C.BUFFER_FLAG_KEY_FRAME) != 0 ? SAMPLE_FLAG_KEY_FRAME : 0;
|
||||||
result |= (flags & C.BUFFER_FLAG_DECODE_ONLY) != 0 ? SAMPLE_FLAG_DECODE_ONLY : 0;
|
result |= (flags & C.BUFFER_FLAG_DECODE_ONLY) != 0 ? SAMPLE_FLAG_DECODE_ONLY : 0;
|
||||||
result |=
|
result |=
|
||||||
(flags & C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA) != 0
|
(flags & C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA) != 0 && mIncludeSupplementalData
|
||||||
? SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA
|
? SAMPLE_FLAG_HAS_SUPPLEMENTAL_DATA
|
||||||
: 0;
|
: 0;
|
||||||
result |= (flags & C.BUFFER_FLAG_LAST_SAMPLE) != 0 ? SAMPLE_FLAG_LAST_SAMPLE : 0;
|
result |= (flags & C.BUFFER_FLAG_LAST_SAMPLE) != 0 ? SAMPLE_FLAG_LAST_SAMPLE : 0;
|
||||||
@@ -1759,6 +1799,7 @@ public final class MediaParser {
|
|||||||
expectedTypeByParameterName.put(PARAMETER_TS_DETECT_ACCESS_UNITS, Boolean.class);
|
expectedTypeByParameterName.put(PARAMETER_TS_DETECT_ACCESS_UNITS, Boolean.class);
|
||||||
expectedTypeByParameterName.put(PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS, Boolean.class);
|
expectedTypeByParameterName.put(PARAMETER_TS_ENABLE_HDMV_DTS_AUDIO_STREAMS, Boolean.class);
|
||||||
expectedTypeByParameterName.put(PARAMETER_IN_BAND_CRYPTO_INFO, Boolean.class);
|
expectedTypeByParameterName.put(PARAMETER_IN_BAND_CRYPTO_INFO, Boolean.class);
|
||||||
|
expectedTypeByParameterName.put(PARAMETER_INCLUDE_SUPPLEMENTAL_DATA, Boolean.class);
|
||||||
EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName);
|
EXPECTED_TYPE_BY_PARAMETER_NAME = Collections.unmodifiableMap(expectedTypeByParameterName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user