mirror of
https://github.com/androidx/media.git
synced 2025-05-08 16:10:38 +08:00
SmoothStreaming fixes
- The -1 needs to be a 0. My bad. - Create AAC CSD if not defined in manifest, like in V1. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=131190995
This commit is contained in:
parent
fd3d7be9c0
commit
42efb5413a
@ -95,7 +95,7 @@ public class DefaultSsChunkSource implements SsChunkSource {
|
|||||||
for (int i = 0; i < extractorWrappers.length; i++) {
|
for (int i = 0; i < extractorWrappers.length; i++) {
|
||||||
int manifestTrackIndex = trackSelection.getIndexInTrackGroup(i);
|
int manifestTrackIndex = trackSelection.getIndexInTrackGroup(i);
|
||||||
Format format = streamElement.formats[manifestTrackIndex];
|
Format format = streamElement.formats[manifestTrackIndex];
|
||||||
int nalUnitLengthFieldLength = streamElement.type == C.TRACK_TYPE_VIDEO ? 4 : -1;
|
int nalUnitLengthFieldLength = streamElement.type == C.TRACK_TYPE_VIDEO ? 4 : 0;
|
||||||
Track track = new Track(manifestTrackIndex, streamElement.type, streamElement.timescale,
|
Track track = new Track(manifestTrackIndex, streamElement.type, streamElement.timescale,
|
||||||
C.TIME_UNSET, manifest.durationUs, format, Track.TRANSFORMATION_NONE,
|
C.TIME_UNSET, manifest.durationUs, format, Track.TRANSFORMATION_NONE,
|
||||||
trackEncryptionBoxes, nalUnitLengthFieldLength, null, null);
|
trackEncryptionBoxes, nalUnitLengthFieldLength, null, null);
|
||||||
|
@ -633,6 +633,10 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
|
|||||||
int samplingRate = parseRequiredInt(parser, KEY_SAMPLING_RATE);
|
int samplingRate = parseRequiredInt(parser, KEY_SAMPLING_RATE);
|
||||||
List<byte[]> codecSpecificData = buildCodecSpecificData(
|
List<byte[]> codecSpecificData = buildCodecSpecificData(
|
||||||
parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA));
|
parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA));
|
||||||
|
if (codecSpecificData.isEmpty() && MimeTypes.AUDIO_AAC.equals(sampleMimeType)) {
|
||||||
|
codecSpecificData = Collections.singletonList(
|
||||||
|
CodecSpecificDataUtil.buildAacLcAudioSpecificConfig(samplingRate, channels));
|
||||||
|
}
|
||||||
String language = (String) getNormalizedAttribute(KEY_LANGUAGE);
|
String language = (String) getNormalizedAttribute(KEY_LANGUAGE);
|
||||||
format = Format.createAudioContainerFormat(id, MimeTypes.AUDIO_MP4, sampleMimeType, null,
|
format = Format.createAudioContainerFormat(id, MimeTypes.AUDIO_MP4, sampleMimeType, null,
|
||||||
bitrate, channels, samplingRate, codecSpecificData, 0, language);
|
bitrate, channels, samplingRate, codecSpecificData, 0, language);
|
||||||
|
@ -67,6 +67,8 @@ public final class CodecSpecificDataUtil {
|
|||||||
AUDIO_SPECIFIC_CONFIG_CHANNEL_CONFIGURATION_INVALID
|
AUDIO_SPECIFIC_CONFIG_CHANNEL_CONFIGURATION_INVALID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Advanced Audio Coding Low-Complexity profile.
|
||||||
|
private static final int AUDIO_OBJECT_TYPE_AAC_LC = 2;
|
||||||
// Spectral Band Replication.
|
// Spectral Band Replication.
|
||||||
private static final int AUDIO_OBJECT_TYPE_SBR = 5;
|
private static final int AUDIO_OBJECT_TYPE_SBR = 5;
|
||||||
// Error Resilient Bit-Sliced Arithmetic Coding.
|
// Error Resilient Bit-Sliced Arithmetic Coding.
|
||||||
@ -118,6 +120,33 @@ public final class CodecSpecificDataUtil {
|
|||||||
return Pair.create(sampleRate, channelCount);
|
return Pair.create(sampleRate, channelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a simple HE-AAC LC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1
|
||||||
|
*
|
||||||
|
* @param sampleRate The sample rate in Hz.
|
||||||
|
* @param numChannels The number of channels.
|
||||||
|
* @return The AudioSpecificConfig.
|
||||||
|
*/
|
||||||
|
public static byte[] buildAacLcAudioSpecificConfig(int sampleRate, int numChannels) {
|
||||||
|
int sampleRateIndex = C.INDEX_UNSET;
|
||||||
|
for (int i = 0; i < AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE.length; ++i) {
|
||||||
|
if (sampleRate == AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE[i]) {
|
||||||
|
sampleRateIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int channelConfig = C.INDEX_UNSET;
|
||||||
|
for (int i = 0; i < AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE.length; ++i) {
|
||||||
|
if (numChannels == AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE[i]) {
|
||||||
|
channelConfig = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sampleRate == C.INDEX_UNSET || channelConfig == C.INDEX_UNSET) {
|
||||||
|
throw new IllegalArgumentException("Invalid sample rate or number of channels: "
|
||||||
|
+ sampleRate + ", " + numChannels);
|
||||||
|
}
|
||||||
|
return buildAacAudioSpecificConfig(AUDIO_OBJECT_TYPE_AAC_LC, sampleRateIndex, channelConfig);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a simple AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1
|
* Builds a simple AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user