use of com.google.android.exoplayer2.metadata.Metadata in project ExoPlayer by google.
the class Format method copyWithManifestFormatInfo.
public Format copyWithManifestFormatInfo(Format manifestFormat) {
if (this == manifestFormat) {
// No need to copy from ourselves.
return this;
}
String id = manifestFormat.id;
String codecs = this.codecs == null ? manifestFormat.codecs : this.codecs;
int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate;
float frameRate = this.frameRate == NO_VALUE ? manifestFormat.frameRate : this.frameRate;
@C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags;
String language = this.language == null ? manifestFormat.language : this.language;
DrmInitData drmInitData = manifestFormat.drmInitData != null ? manifestFormat.drmInitData : this.drmInitData;
return new Format(id, containerMimeType, sampleMimeType, codecs, bitrate, maxInputSize, width, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, selectionFlags, language, accessibilityChannel, subsampleOffsetUs, initializationData, drmInitData, metadata);
}
use of com.google.android.exoplayer2.metadata.Metadata in project dhis2-core by dhis2.
the class ImportMetaDataCsvTask method call.
// -------------------------------------------------------------------------
// Runnable implementation
// -------------------------------------------------------------------------
@Override
public void call() {
Metadata metadata;
try {
metadata = csvImportService.fromCsv(inputStream, clazz);
importParams.addMetadata(schemaService.getMetadataSchemas(), metadata);
log.info("Read CSV file. Importing metadata.");
} catch (IOException ex) {
log.error("Unable to read meta-data while reading input stream", ex);
return;
}
importService.importMetadata(importParams);
}
use of com.google.android.exoplayer2.metadata.Metadata in project dhis2-core by dhis2.
the class DefaultCsvImportService method fromCsv.
// -------------------------------------------------------------------------
// CsvImportService implementation
// -------------------------------------------------------------------------
@Override
public Metadata fromCsv(InputStream input, Class<? extends IdentifiableObject> clazz) throws IOException {
CsvReader reader = new CsvReader(input, Charset.forName("UTF-8"));
// Ignore first row
reader.readRecord();
Metadata metadata = new Metadata();
if (DataElement.class.equals(clazz)) {
metadata.setDataElements(dataElementsFromCsv(reader));
} else if (DataElementGroup.class.equals(clazz)) {
metadata.setDataElementGroups(dataElementGroupsFromCsv(reader));
} else if (DataElementCategoryOption.class.equals(clazz)) {
metadata.setCategoryOptions(categoryOptionsFromCsv(reader));
} else if (CategoryOptionGroup.class.equals(clazz)) {
metadata.setCategoryOptionGroups(categoryOptionGroupsFromCsv(reader));
} else if (OrganisationUnit.class.equals(clazz)) {
metadata.setOrganisationUnits(organisationUnitsFromCsv(reader));
} else if (OrganisationUnitGroup.class.equals(clazz)) {
metadata.setOrganisationUnitGroups(organisationUnitGroupsFromCsv(reader));
} else if (ValidationRule.class.equals(clazz)) {
metadata.setValidationRules(validationRulesFromCsv(reader));
} else if (OptionSet.class.equals(clazz)) {
setOptionSetsFromCsv(reader, metadata);
}
return metadata;
}
use of com.google.android.exoplayer2.metadata.Metadata in project dhis2-core by dhis2.
the class CsvImportServiceTest method testCategoryOptionImport.
@Test
public void testCategoryOptionImport() throws IOException {
Metadata metadata = csvImportService.fromCsv(inputBasicObjects, DataElementCategoryOption.class);
assertEquals(3, metadata.getCategoryOptions().size());
for (DataElementCategoryOption categoryOption : metadata.getCategoryOptions()) {
assertNotNull(categoryOption.getUid());
assertNotNull(categoryOption.getName());
assertNotNull(categoryOption.getShortName());
}
}
use of com.google.android.exoplayer2.metadata.Metadata in project dhis2-core by dhis2.
the class DataSetController method getStructureDefinition.
// -------------------------------------------------------------------------
// Controller
// -------------------------------------------------------------------------
@SuppressWarnings("unchecked")
@RequestMapping(produces = "application/dsd+xml")
public void getStructureDefinition(@RequestParam Map<String, String> parameters, HttpServletResponse response) throws IOException, TransformerException {
MetadataExportParams exportParams = filterMetadataOptions();
Map<Class<? extends IdentifiableObject>, List<? extends IdentifiableObject>> metadataMap = exportService.getMetadata(exportParams);
Metadata metadata = new Metadata();
metadata.setDataElements((List<DataElement>) metadataMap.get(DataElement.class));
metadata.setDataSets((List<DataSet>) metadataMap.get(DataSet.class));
metadata.setCategoryOptionCombos((List<DataElementCategoryOptionCombo>) metadataMap.get(DataElementCategoryOptionCombo.class));
InputStream input = new ByteArrayInputStream(DefaultRenderService.getXmlMapper().writeValueAsString(metadata).getBytes("UTF-8"));
TransformerFactory tf = TransformerFactory.newInstance();
tf.setURIResolver(new ClassPathUriResolver());
Transformer transformer = tf.newTransformer(new StreamSource(new ClassPathResource(DSD_TRANSFORM).getInputStream()));
transformer.transform(new StreamSource(input), new StreamResult(response.getOutputStream()));
}
Aggregations