use of com.att.aro.core.videoanalysis.parsers.encodedsegment.MPDEncodedSegment in project VideoOptimzer by attdevsupport.
the class ManifestBuilderDASH method processEncodedSegment.
public void processEncodedSegment(Manifest newManifest, XmlManifestHelper manifestView, String key) {
// DASH-VOD EncodedSegmentList
switchManifestCollection(newManifest, key, manifest.getRequestTime());
newManifest.setVideoType(VideoType.DASH_ENCODEDSEGMENTLIST);
MPDEncodedSegment mpdEncodedSegment = (MPDEncodedSegment) manifestView.getManifest();
DashEncodedSegmentParser dashEncodedSegmentParser = new DashEncodedSegmentParser(mpdEncodedSegment, newManifest, manifestCollection, childManifest);
List<AdaptationSetESL> adaptationSetList = dashEncodedSegmentParser.getAdaptationSet();
String[] encodedSegmentDurationList = null;
Double segmentTimeScale = null;
/*
* Sort Adaptations by minBandwidth, for the purpose of assigning track numbers.
* Video tracks will start with track 0
* Audio tracks will start with track 0, also
*/
SortedMap<Double, AdaptationSetESL> sortedAdaptationSet;
Map<String, SortedMap<Double, AdaptationSetESL>> sortedAdaptationSets = new HashMap<>();
Map<String, Integer> trackMap = new HashMap<>();
Integer track;
Double bandWidth;
for (AdaptationSetESL adaptation : adaptationSetList) {
List<RepresentationESL> representation = adaptation.getRepresentation();
if (sortedAdaptationSets.containsKey(adaptation.getContentType())) {
sortedAdaptationSet = sortedAdaptationSets.get(adaptation.getContentType());
} else {
sortedAdaptationSet = new TreeMap<>();
sortedAdaptationSets.put(adaptation.getContentType(), sortedAdaptationSet);
trackMap.put(createKey(adaptation), 0);
}
if ((bandWidth = adaptation.getMinBandwidth()) == null || bandWidth == 0) {
bandWidth = Double.MAX_VALUE;
for (RepresentationESL repSet : representation) {
if (repSet.getBandwidth() == null) {
bandWidth = 1.0;
break;
}
if (repSet.getBandwidth() < bandWidth) {
bandWidth = repSet.getBandwidth();
}
}
}
sortedAdaptationSet.put(bandWidth, adaptation);
}
for (SortedMap<Double, AdaptationSetESL> sortedMap : sortedAdaptationSets.values()) {
for (AdaptationSetESL adaptation : sortedMap.values()) {
ContentType contentType = manifest.matchContentType(adaptation.getContentType());
if (adaptation.getEncodedSegmentDurations() != null && adaptation.getEncodedSegmentDurations().getEncodedSegmentDurationList() != null) {
segmentTimeScale = StringParse.stringToDouble(adaptation.getEncodedSegmentDurations().getTimescale(), 1);
encodedSegmentDurationList = adaptation.getEncodedSegmentDurations().getEncodedSegmentDurationList().split(";");
}
track = trackMap.get(createKey(adaptation));
SortedMap<Double, RepresentationESL> sortedRepresentationESL = sortRepresentationByBandwidth(adaptation.getRepresentation());
for (RepresentationESL representation : sortedRepresentationESL.values()) {
if (representation.getEncodedSegment() != null) {
track++;
manifest.setTimeScale(StringParse.stringToDouble(representation.getEncodedSegment().getTimescale(), 1));
LOG.debug(String.format("representation.getBandwidth() %d:%s", track, representation.getBandwidth()));
generateChildManifestFromEncodedSegmentList(newManifest, contentType, track, representation, encodedSegmentDurationList, segmentTimeScale);
if (representation.getRepresentationACC() != null) {
// audio
childManifest.setChannels(representation.getRepresentationACC().getValue());
}
addToSegmentManifestCollectionMap(childManifest.getUriName());
}
}
trackMap.put(createKey(adaptation), track);
}
}
}
use of com.att.aro.core.videoanalysis.parsers.encodedsegment.MPDEncodedSegment in project VideoOptimzer by attdevsupport.
the class XmlManifestHelper method xml2EncodedSegmentList.
/**
* Load Amazon manifest into an MPDAmz object
*
* @param xmlByte
* @return an MPDAmz object
*/
private MPDEncodedSegment xml2EncodedSegmentList(ByteArrayInputStream xmlByte) {
JAXBContext context;
Unmarshaller unMarshaller;
MPDEncodedSegment mpdOutput = new MPDEncodedSegment();
try {
context = JAXBContext.newInstance(MPDEncodedSegment.class);
unMarshaller = context.createUnmarshaller();
mpdOutput = (MPDEncodedSegment) unMarshaller.unmarshal(xmlByte);
if (mpdOutput.getPeriod().isEmpty()) {
LOG.error("MPD NULL");
}
} catch (JAXBException e) {
LOG.error("JAXBException", e);
} catch (Exception ex) {
LOG.error("JaxB parse Exception", ex);
}
return mpdOutput;
}
Aggregations