Search in sources :

Example 31 with Metadata

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);
}
Also used : DrmInitData(com.google.android.exoplayer2.drm.DrmInitData) MediaFormat(android.media.MediaFormat) SuppressLint(android.annotation.SuppressLint)

Example 32 with 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);
}
Also used : Metadata(org.hisp.dhis.dxf2.metadata.Metadata) IOException(java.io.IOException)

Example 33 with Metadata

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;
}
Also used : CsvReader(com.csvreader.CsvReader) OrganisationUnitGroup(org.hisp.dhis.organisationunit.OrganisationUnitGroup) CategoryOptionGroup(org.hisp.dhis.dataelement.CategoryOptionGroup) Metadata(org.hisp.dhis.dxf2.metadata.Metadata) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) OptionSet(org.hisp.dhis.option.OptionSet)

Example 34 with 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());
    }
}
Also used : DataElementCategoryOption(org.hisp.dhis.dataelement.DataElementCategoryOption) Metadata(org.hisp.dhis.dxf2.metadata.Metadata) DhisSpringTest(org.hisp.dhis.DhisSpringTest) Test(org.junit.Test)

Example 35 with Metadata

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()));
}
Also used : ClassPathUriResolver(org.hisp.dhis.webapi.view.ClassPathUriResolver) TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) StreamResult(javax.xml.transform.stream.StreamResult) MetadataExportParams(org.hisp.dhis.dxf2.metadata.MetadataExportParams) DataSet(org.hisp.dhis.dataset.DataSet) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) Metadata(org.hisp.dhis.dxf2.metadata.Metadata) ClassPathResource(org.springframework.core.io.ClassPathResource) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) DataElement(org.hisp.dhis.dataelement.DataElement) ByteArrayInputStream(java.io.ByteArrayInputStream) List(java.util.List) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Metadata (com.google.android.exoplayer2.metadata.Metadata)18 Metadata (org.hisp.dhis.dxf2.metadata.Metadata)10 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)6 IOException (java.io.IOException)5 Format (com.google.android.exoplayer2.Format)3 ArrayList (java.util.ArrayList)3 MediaFormat (android.media.MediaFormat)2 DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)2 ApicFrame (com.google.android.exoplayer2.metadata.id3.ApicFrame)2 Id3Frame (com.google.android.exoplayer2.metadata.id3.Id3Frame)2 PrivFrame (com.google.android.exoplayer2.metadata.id3.PrivFrame)2 TextInformationFrame (com.google.android.exoplayer2.metadata.id3.TextInformationFrame)2 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)2 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)2 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)2 FlacStreamInfo (com.google.android.exoplayer2.util.FlacStreamInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ByteBuffer (java.nio.ByteBuffer)2 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)2