mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Formatting cleanup
This commit is contained in:
parent
2e950633c7
commit
730d2dd18f
2 changed files with 44 additions and 35 deletions
|
|
@ -33,13 +33,31 @@ public final class Ac3Util {
|
||||||
*/
|
*/
|
||||||
public static final class Ac3SyncFrameInfo {
|
public static final class Ac3SyncFrameInfo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undefined AC3 stream type.
|
||||||
|
*/
|
||||||
|
public static final int STREAM_TYPE_UNDEFINED = -1;
|
||||||
|
/**
|
||||||
|
* Type 0 AC3 stream type. See ETSI TS 102 366 E.1.3.1.1.
|
||||||
|
*/
|
||||||
|
public static final int STREAM_TYPE_TYPE0 = 0;
|
||||||
|
/**
|
||||||
|
* Type 1 AC3 stream type. See ETSI TS 102 366 E.1.3.1.1.
|
||||||
|
*/
|
||||||
|
public static final int STREAM_TYPE_TYPE1 = 1;
|
||||||
|
/**
|
||||||
|
* Type 2 AC3 stream type. See ETSI TS 102 366 E.1.3.1.1.
|
||||||
|
*/
|
||||||
|
public static final int STREAM_TYPE_TYPE2 = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The sample mime type of the bitstream. One of {@link MimeTypes#AUDIO_AC3} and
|
* The sample mime type of the bitstream. One of {@link MimeTypes#AUDIO_AC3} and
|
||||||
* {@link MimeTypes#AUDIO_E_AC3}.
|
* {@link MimeTypes#AUDIO_E_AC3}.
|
||||||
*/
|
*/
|
||||||
public final String mimeType;
|
public final String mimeType;
|
||||||
/**
|
/**
|
||||||
* The type of the bitstream, only for AUDIO_E_AC3
|
* The type of the stream if {@link #mimeType} is {@link MimeTypes#AUDIO_E_AC3}, or
|
||||||
|
* {@link #STREAM_TYPE_UNDEFINED} otherwise.
|
||||||
*/
|
*/
|
||||||
public final int streamType;
|
public final int streamType;
|
||||||
/**
|
/**
|
||||||
|
|
@ -106,13 +124,6 @@ public final class Ac3Util {
|
||||||
private static final int[] SYNCFRAME_SIZE_WORDS_BY_HALF_FRMSIZECOD_44_1 = new int[] {69, 87, 104,
|
private static final int[] SYNCFRAME_SIZE_WORDS_BY_HALF_FRMSIZECOD_44_1 = new int[] {69, 87, 104,
|
||||||
121, 139, 174, 208, 243, 278, 348, 417, 487, 557, 696, 835, 975, 1114, 1253, 1393};
|
121, 139, 174, 208, 243, 278, 348, 417, 487, 557, 696, 835, 975, 1114, 1253, 1393};
|
||||||
|
|
||||||
/**
|
|
||||||
* Stream type. See ETSI TS 102 366 E.1.3.1.1.
|
|
||||||
*/
|
|
||||||
public static final int STREAM_TYPE_UNDEFINED = -1;
|
|
||||||
public static final int STREAM_TYPE_TYPE0 = 0;
|
|
||||||
public static final int STREAM_TYPE_TYPE1 = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the AC-3 format given {@code data} containing the AC3SpecificBox according to
|
* Returns the AC-3 format given {@code data} containing the AC3SpecificBox according to
|
||||||
* ETSI TS 102 366 Annex F. The reading position of {@code data} will be modified.
|
* ETSI TS 102 366 Annex F. The reading position of {@code data} will be modified.
|
||||||
|
|
@ -150,8 +161,7 @@ public final class Ac3Util {
|
||||||
String language, DrmInitData drmInitData) {
|
String language, DrmInitData drmInitData) {
|
||||||
data.skipBytes(2); // data_rate, num_ind_sub
|
data.skipBytes(2); // data_rate, num_ind_sub
|
||||||
|
|
||||||
// Read only the first independent substream.
|
// Read the first independent substream.
|
||||||
// TODO: Read later independent substreams?
|
|
||||||
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
|
int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
|
||||||
int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod];
|
int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod];
|
||||||
int nextByte = data.readUnsignedByte();
|
int nextByte = data.readUnsignedByte();
|
||||||
|
|
@ -160,8 +170,7 @@ public final class Ac3Util {
|
||||||
channelCount++;
|
channelCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read only the first dependent substream.
|
// Read the first dependent substream.
|
||||||
// TODO: Read later dependent substreams?
|
|
||||||
nextByte = data.readUnsignedByte();
|
nextByte = data.readUnsignedByte();
|
||||||
int numDepSub = ((nextByte & 0x1E) >> 1);
|
int numDepSub = ((nextByte & 0x1E) >> 1);
|
||||||
if (numDepSub > 0) {
|
if (numDepSub > 0) {
|
||||||
|
|
@ -189,7 +198,7 @@ public final class Ac3Util {
|
||||||
boolean isEac3 = data.readBits(5) == 16;
|
boolean isEac3 = data.readBits(5) == 16;
|
||||||
data.setPosition(initialPosition);
|
data.setPosition(initialPosition);
|
||||||
String mimeType;
|
String mimeType;
|
||||||
int streamType;
|
int streamType = Ac3SyncFrameInfo.STREAM_TYPE_UNDEFINED;
|
||||||
int sampleRate;
|
int sampleRate;
|
||||||
int acmod;
|
int acmod;
|
||||||
int frameSize;
|
int frameSize;
|
||||||
|
|
@ -215,7 +224,6 @@ public final class Ac3Util {
|
||||||
} else /* is AC-3 */ {
|
} else /* is AC-3 */ {
|
||||||
mimeType = MimeTypes.AUDIO_AC3;
|
mimeType = MimeTypes.AUDIO_AC3;
|
||||||
data.skipBits(16 + 16); // syncword, crc1
|
data.skipBits(16 + 16); // syncword, crc1
|
||||||
streamType = STREAM_TYPE_UNDEFINED; // AC-3 stream hasn't streamType
|
|
||||||
int fscod = data.readBits(2);
|
int fscod = data.readBits(2);
|
||||||
int frmsizecod = data.readBits(6);
|
int frmsizecod = data.readBits(6);
|
||||||
frameSize = getAc3SyncframeSize(fscod, frmsizecod);
|
frameSize = getAc3SyncframeSize(fscod, frmsizecod);
|
||||||
|
|
@ -235,8 +243,8 @@ public final class Ac3Util {
|
||||||
}
|
}
|
||||||
boolean lfeon = data.readBit();
|
boolean lfeon = data.readBit();
|
||||||
int channelCount = CHANNEL_COUNT_BY_ACMOD[acmod] + (lfeon ? 1 : 0);
|
int channelCount = CHANNEL_COUNT_BY_ACMOD[acmod] + (lfeon ? 1 : 0);
|
||||||
return new Ac3SyncFrameInfo(mimeType, streamType, channelCount, sampleRate,
|
return new Ac3SyncFrameInfo(mimeType, streamType, channelCount, sampleRate, frameSize,
|
||||||
frameSize, sampleCount);
|
sampleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -690,9 +690,9 @@ public class DashManifestParser extends DefaultHandler
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
String schemeIdUri = parseString(xpp, "schemeIdUri", null);
|
String schemeIdUri = parseString(xpp, "schemeIdUri", null);
|
||||||
int audioChannels = "urn:mpeg:dash:23003:3:audio_channel_configuration:2011".equals(schemeIdUri)
|
int audioChannels = "urn:mpeg:dash:23003:3:audio_channel_configuration:2011".equals(schemeIdUri)
|
||||||
? parseInt(xpp, "value", Format.NO_VALUE) :
|
? parseInt(xpp, "value", Format.NO_VALUE)
|
||||||
("tag:dolby.com,2014:dash:audio_channel_configuration:2011".equals(schemeIdUri)
|
: ("tag:dolby.com,2014:dash:audio_channel_configuration:2011".equals(schemeIdUri)
|
||||||
? parseDolbyChannelConfiguration(xpp, "value", Format.NO_VALUE) : Format.NO_VALUE);
|
? parseDolbyChannelConfiguration(xpp) : Format.NO_VALUE);
|
||||||
do {
|
do {
|
||||||
xpp.next();
|
xpp.next();
|
||||||
} while (!XmlPullParserUtil.isEndTag(xpp, "AudioChannelConfiguration"));
|
} while (!XmlPullParserUtil.isEndTag(xpp, "AudioChannelConfiguration"));
|
||||||
|
|
@ -903,31 +903,32 @@ public class DashManifestParser extends DefaultHandler
|
||||||
return value == null ? defaultValue : value;
|
return value == null ? defaultValue : value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int parseDolbyChannelConfiguration(XmlPullParser xpp, String name,
|
/**
|
||||||
int defaultValue) {
|
* Parses the number of channels from the value attribute of an AudioElementConfiguration with
|
||||||
String value = Util.toLowerInvariant(xpp.getAttributeValue(null, name));
|
* schemeIdUri "tag:dolby.com,2014:dash:audio_channel_configuration:2011", as defined by table E.5
|
||||||
|
* in ETSI TS 102 366.
|
||||||
|
*
|
||||||
|
* @param xpp The parser from which to read.
|
||||||
|
* @return The parsed number of channels, or {@link Format#NO_VALUE} if the channel count could
|
||||||
|
* not be parsed.
|
||||||
|
*/
|
||||||
|
protected static int parseDolbyChannelConfiguration(XmlPullParser xpp) {
|
||||||
|
String value = Util.toLowerInvariant(xpp.getAttributeValue(null, "value"));
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return defaultValue;
|
return Format.NO_VALUE;
|
||||||
}
|
}
|
||||||
int channels;
|
|
||||||
// TODO: Parse other channel configurations
|
|
||||||
switch (value) {
|
switch (value) {
|
||||||
case "4000":
|
case "4000":
|
||||||
channels = 1;
|
return 1;
|
||||||
break;
|
|
||||||
case "a000":
|
case "a000":
|
||||||
channels = 2;
|
return 2;
|
||||||
break;
|
|
||||||
case "f801":
|
case "f801":
|
||||||
channels = 6;
|
return 6;
|
||||||
break;
|
|
||||||
case "fa01":
|
case "fa01":
|
||||||
channels = 8;
|
return 8;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
channels = defaultValue;
|
return Format.NO_VALUE;
|
||||||
}
|
}
|
||||||
return channels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class RepresentationInfo {
|
private static final class RepresentationInfo {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue