Add language to Format (+other misc fix).
This commit is contained in:
parent
bb5cfd52c5
commit
b3277c666b
@ -280,14 +280,20 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
|
||||
|
||||
@Override
|
||||
protected void onDisabled() {
|
||||
releaseCodec();
|
||||
format = null;
|
||||
drmInitData = null;
|
||||
if (openedDrmSession) {
|
||||
drmSessionManager.close();
|
||||
openedDrmSession = false;
|
||||
try {
|
||||
releaseCodec();
|
||||
} finally {
|
||||
try {
|
||||
if (openedDrmSession) {
|
||||
drmSessionManager.close();
|
||||
openedDrmSession = false;
|
||||
}
|
||||
} finally {
|
||||
source.disable(trackIndex);
|
||||
}
|
||||
}
|
||||
source.disable(trackIndex);
|
||||
}
|
||||
|
||||
protected void releaseCodec() {
|
||||
|
@ -71,6 +71,14 @@ public class Format {
|
||||
*/
|
||||
public final int bitrate;
|
||||
|
||||
/**
|
||||
* The language of the format. Can be null if unknown.
|
||||
* <p>
|
||||
* The language codes are two-letter lowercase ISO language codes (such as "en") as defined by
|
||||
* ISO 639-1.
|
||||
*/
|
||||
public final String language;
|
||||
|
||||
/**
|
||||
* The average bandwidth in bytes per second.
|
||||
*
|
||||
@ -90,6 +98,21 @@ public class Format {
|
||||
*/
|
||||
public Format(String id, String mimeType, int width, int height, int numChannels,
|
||||
int audioSamplingRate, int bitrate) {
|
||||
this(id, mimeType, width, height, numChannels, audioSamplingRate, bitrate, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id The format identifier.
|
||||
* @param mimeType The format mime type.
|
||||
* @param width The width of the video in pixels, or -1 for non-video formats.
|
||||
* @param height The height of the video in pixels, or -1 for non-video formats.
|
||||
* @param numChannels The number of audio channels, or -1 for non-audio formats.
|
||||
* @param audioSamplingRate The audio sampling rate in Hz, or -1 for non-audio formats.
|
||||
* @param bitrate The average bandwidth of the format in bits per second.
|
||||
* @param language The language of the format.
|
||||
*/
|
||||
public Format(String id, String mimeType, int width, int height, int numChannels,
|
||||
int audioSamplingRate, int bitrate, String language) {
|
||||
this.id = Assertions.checkNotNull(id);
|
||||
this.mimeType = mimeType;
|
||||
this.width = width;
|
||||
@ -97,6 +120,7 @@ public class Format {
|
||||
this.numChannels = numChannels;
|
||||
this.audioSamplingRate = audioSamplingRate;
|
||||
this.bitrate = bitrate;
|
||||
this.language = language;
|
||||
this.bandwidth = bitrate / 8;
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler {
|
||||
throws XmlPullParserException, IOException {
|
||||
|
||||
String mimeType = xpp.getAttributeValue(null, "mimeType");
|
||||
String language = xpp.getAttributeValue(null, "lang");
|
||||
int contentType = parseAdaptationSetTypeFromMimeType(mimeType);
|
||||
|
||||
int id = -1;
|
||||
@ -160,7 +161,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler {
|
||||
parseAdaptationSetType(xpp.getAttributeValue(null, "contentType")));
|
||||
} else if (isStartTag(xpp, "Representation")) {
|
||||
Representation representation = parseRepresentation(xpp, contentId, baseUrl, periodStartMs,
|
||||
periodDurationMs, mimeType, segmentBase);
|
||||
periodDurationMs, mimeType, language, segmentBase);
|
||||
contentType = checkAdaptationSetTypeConsistency(contentType,
|
||||
parseAdaptationSetTypeFromMimeType(representation.format.mimeType));
|
||||
representations.add(representation);
|
||||
@ -230,8 +231,8 @@ public class MediaPresentationDescriptionParser extends DefaultHandler {
|
||||
// Representation parsing.
|
||||
|
||||
private Representation parseRepresentation(XmlPullParser xpp, String contentId, Uri baseUrl,
|
||||
long periodStartMs, long periodDurationMs, String mimeType, SegmentBase segmentBase)
|
||||
throws XmlPullParserException, IOException {
|
||||
long periodStartMs, long periodDurationMs, String mimeType, String language,
|
||||
SegmentBase segmentBase) throws XmlPullParserException, IOException {
|
||||
String id = xpp.getAttributeValue(null, "id");
|
||||
int bandwidth = parseInt(xpp, "bandwidth");
|
||||
int audioSamplingRate = parseInt(xpp, "audioSamplingRate");
|
||||
@ -257,7 +258,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler {
|
||||
} while (!isEndTag(xpp, "Representation"));
|
||||
|
||||
Format format = new Format(id, mimeType, width, height, numChannels, audioSamplingRate,
|
||||
bandwidth);
|
||||
bandwidth, language);
|
||||
return Representation.newInstance(periodStartMs, periodDurationMs, contentId, -1, format,
|
||||
segmentBase);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user