mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Add maybeInflate() which inflates only if the source buffer starts with the INFLATE_HEADER
This commit is contained in:
parent
0254b2d16e
commit
3cd0e1ad3d
@ -212,6 +212,8 @@ public final class Util {
|
||||
private static final String ISM_HLS_FORMAT_EXTENSION = "format=m3u8-aapl";
|
||||
private static final String ISM_DASH_FORMAT_EXTENSION = "format=mpd-time-csf";
|
||||
|
||||
private static final int INFLATE_HEADER = 0x78;
|
||||
|
||||
// Replacement map of ISO language codes used for normalization.
|
||||
@Nullable private static HashMap<String, String> languageTagReplacementMap;
|
||||
|
||||
@ -3102,6 +3104,28 @@ public final class Util {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Uncompresses the data in {@code input} if it starts with {@code INFLATE_HEADER}
|
||||
* ({@code 0x78}).
|
||||
*
|
||||
* @param input Wraps the compressed input data.
|
||||
* @param output Wraps an output buffer to be used to store the uncompressed data. If {@code
|
||||
* output.data} isn't big enough to hold the uncompressed data, a new array is created. If
|
||||
* {@code true} is returned then the output's position will be set to 0 and its limit will be
|
||||
* set to the length of the uncompressed data.
|
||||
* @param inflater If not null, used to uncompressed the input. Otherwise a new {@link Inflater}
|
||||
* is created.
|
||||
* @return Whether the input is uncompressed successfully.
|
||||
*/
|
||||
@UnstableApi
|
||||
public static boolean maybeInflate(
|
||||
ParsableByteArray input, ParsableByteArray output, @Nullable Inflater inflater) {
|
||||
if (input.bytesLeft() > 0 && input.peekUnsignedByte() == INFLATE_HEADER) {
|
||||
return inflate(input, output, inflater);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the app is running on a TV device.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user