use of com.att.aro.core.tracemetadata.pojo.MetaStream in project VideoOptimzer by attdevsupport.
the class MetaDataHelper method updateMetaData.
private boolean updateMetaData(PacketAnalyzerResult packetAnalyzerResult) {
TraceDirectoryResult result = (TraceDirectoryResult) packetAnalyzerResult.getTraceresult();
boolean isMetaDataUpdated = false;
if (metaData.getVideoStreams().isEmpty() || metaData.getVideoStreams().get(0).getVideoResolutionMap().isEmpty()) {
ArrayList<MetaStream> videoStreams = new ArrayList<>();
for (VideoStream videoStream : packetAnalyzerResult.getStreamingVideoData().getVideoStreams()) {
MetaStream metaStream = new MetaStream();
metaStream.setVideoDuration(videoStream.getDuration());
metaStream.setType(videoStream.getManifest().getVideoFormat().toString());
metaStream.setVideo(videoStream.getManifest().getVideoName());
metaStream.setVideoOrientation(result.getCollectOptions().getOrientation());
metaStream.setVideoDownloadtime(videoStream.getVideoActiveMap().entrySet().stream().mapToDouble(e -> e.getValue().getDLTime()).sum());
metaStream.setAudioDownloadtime(videoStream.getAudioActiveMap().entrySet().stream().mapToDouble(e -> e.getValue().getDLTime()).sum());
metaStream.setVideoSegmentTotal(videoStream.getVideoActiveMap().size());
metaStream.setAudioSegmentTotal(videoStream.getAudioActiveMap().size());
setVideoStreamTotals(metaStream, videoStream);
videoStream.setMetaStream(metaStream);
videoStreams.add(metaStream);
}
metaData.setVideoStreams(videoStreams);
isMetaDataUpdated = true;
}
if (metaData.getCollectorName().isEmpty()) {
metaData.setCollectorName(result.getCollectorName());
isMetaDataUpdated = true;
}
if (metaData.getCollectorVersion().isEmpty()) {
metaData.setCollectorVersion(result.getCollectorVersion());
isMetaDataUpdated = true;
}
if (metaData.getTraceName().isEmpty()) {
String name = result.getTraceDirectory();
int pos = name.lastIndexOf(Util.FILE_SEPARATOR);
if (pos > 0) {
name = name.substring(pos + 1);
}
metaData.setTraceName(name);
isMetaDataUpdated = true;
}
if (metaData.getDeviceScreenSize() == null) {
metaData.setDeviceScreenSize(new Dimension(result.getDeviceScreenSizeX(), result.getDeviceScreenSizeY()));
isMetaDataUpdated = true;
}
if (metaData.getPhoneMake().isEmpty()) {
metaData.setPhoneMake(result.getDeviceMake());
isMetaDataUpdated = true;
}
if (metaData.getPhoneModel().isEmpty()) {
metaData.setPhoneModel(result.getDeviceModel());
isMetaDataUpdated = true;
}
if (metaData.getOs().isEmpty()) {
metaData.setOs(result.getOsType());
isMetaDataUpdated = true;
}
if (metaData.getOsVersion().isEmpty()) {
metaData.setOsVersion(result.getOsVersion());
isMetaDataUpdated = true;
}
if (metaData.getStartUTC().isEmpty()) {
ZonedDateTime startUTC = null;
if (result != null && result.getTraceDateTime() != null) {
startUTC = ZonedDateTime.ofInstant(result.getTraceDateTime().toInstant(), ZoneId.systemDefault());
isMetaDataUpdated = true;
}
metaData.setStartUTC(startUTC != null ? startUTC.format(DateTimeFormatter.ISO_OFFSET_DATE_TIME) : "");
}
if (metaData.getUtc() == null || metaData.getUtc() == 0L) {
metaData.setUtc(result.getTraceDateTime().toInstant().getEpochSecond());
isMetaDataUpdated = true;
}
if (metaData.getTraceDuration() == null) {
metaData.setTraceDuration(result.getTraceDuration());
isMetaDataUpdated = true;
}
if (metaData.getTraceSource().isEmpty()) {
metaData.setTraceSource("Manual");
isMetaDataUpdated = true;
}
if ((metaData.getTargetAppVer().isEmpty() || UNKNOWN.equals(metaData.getTargetAppVer())) && (!metaData.getTargetedApp().isEmpty() && !UNKNOWN.equals(metaData.getTargetedApp()))) {
String appVersion = findAppVersion(result);
if (!UNKNOWN.equals(appVersion)) {
isMetaDataUpdated = true;
metaData.setTargetAppVer(appVersion);
}
}
return isMetaDataUpdated;
}
Aggregations