Search in sources :

Example 1 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class SpliceInfoDecoder method decode.

@Override
public Metadata decode(MetadataInputBuffer inputBuffer) throws MetadataDecoderException {
    // Internal timestamps adjustment.
    if (timestampAdjuster == null || inputBuffer.subsampleOffsetUs != timestampAdjuster.getTimestampOffsetUs()) {
        timestampAdjuster = new TimestampAdjuster(inputBuffer.timeUs);
        timestampAdjuster.adjustSampleTimestamp(inputBuffer.timeUs - inputBuffer.subsampleOffsetUs);
    }
    ByteBuffer buffer = inputBuffer.data;
    byte[] data = buffer.array();
    int size = buffer.limit();
    sectionData.reset(data, size);
    sectionHeader.reset(data, size);
    // table_id(8), section_syntax_indicator(1), private_indicator(1), reserved(2),
    // section_length(12), protocol_version(8), encrypted_packet(1), encryption_algorithm(6).
    sectionHeader.skipBits(39);
    long ptsAdjustment = sectionHeader.readBits(1);
    ptsAdjustment = (ptsAdjustment << 32) | sectionHeader.readBits(32);
    // cw_index(8), tier(12).
    sectionHeader.skipBits(20);
    int spliceCommandLength = sectionHeader.readBits(12);
    int spliceCommandType = sectionHeader.readBits(8);
    SpliceCommand command = null;
    // Go to the start of the command by skipping all fields up to command_type.
    sectionData.skipBytes(14);
    switch(spliceCommandType) {
        case TYPE_SPLICE_NULL:
            command = new SpliceNullCommand();
            break;
        case TYPE_SPLICE_SCHEDULE:
            command = SpliceScheduleCommand.parseFromSection(sectionData);
            break;
        case TYPE_SPLICE_INSERT:
            command = SpliceInsertCommand.parseFromSection(sectionData, ptsAdjustment, timestampAdjuster);
            break;
        case TYPE_TIME_SIGNAL:
            command = TimeSignalCommand.parseFromSection(sectionData, ptsAdjustment, timestampAdjuster);
            break;
        case TYPE_PRIVATE_COMMAND:
            command = PrivateCommand.parseFromSection(sectionData, spliceCommandLength, ptsAdjustment);
            break;
        default:
            // Do nothing.
            break;
    }
    return command == null ? new Metadata() : new Metadata(command);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) TimestampAdjuster(com.google.android.exoplayer2.util.TimestampAdjuster) ByteBuffer(java.nio.ByteBuffer)

Example 2 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class Mp4Extractor method processMoovAtom.

/**
   * Updates the stored track metadata to reflect the contents of the specified moov atom.
   */
private void processMoovAtom(ContainerAtom moov) throws ParserException {
    long durationUs = C.TIME_UNSET;
    List<Mp4Track> tracks = new ArrayList<>();
    long earliestSampleOffset = Long.MAX_VALUE;
    Metadata metadata = null;
    GaplessInfoHolder gaplessInfoHolder = new GaplessInfoHolder();
    Atom.LeafAtom udta = moov.getLeafAtomOfType(Atom.TYPE_udta);
    if (udta != null) {
        metadata = AtomParsers.parseUdta(udta, isQuickTime);
        if (metadata != null) {
            gaplessInfoHolder.setFromMetadata(metadata);
        }
    }
    for (int i = 0; i < moov.containerChildren.size(); i++) {
        Atom.ContainerAtom atom = moov.containerChildren.get(i);
        if (atom.type != Atom.TYPE_trak) {
            continue;
        }
        Track track = AtomParsers.parseTrak(atom, moov.getLeafAtomOfType(Atom.TYPE_mvhd), C.TIME_UNSET, null, isQuickTime);
        if (track == null) {
            continue;
        }
        Atom.ContainerAtom stblAtom = atom.getContainerAtomOfType(Atom.TYPE_mdia).getContainerAtomOfType(Atom.TYPE_minf).getContainerAtomOfType(Atom.TYPE_stbl);
        TrackSampleTable trackSampleTable = AtomParsers.parseStbl(track, stblAtom, gaplessInfoHolder);
        if (trackSampleTable.sampleCount == 0) {
            continue;
        }
        Mp4Track mp4Track = new Mp4Track(track, trackSampleTable, extractorOutput.track(i, track.type));
        // Each sample has up to three bytes of overhead for the start code that replaces its length.
        // Allow ten source samples per output sample, like the platform extractor.
        int maxInputSize = trackSampleTable.maximumSize + 3 * 10;
        Format format = track.format.copyWithMaxInputSize(maxInputSize);
        if (track.type == C.TRACK_TYPE_AUDIO) {
            if (gaplessInfoHolder.hasGaplessInfo()) {
                format = format.copyWithGaplessInfo(gaplessInfoHolder.encoderDelay, gaplessInfoHolder.encoderPadding);
            }
            if (metadata != null) {
                format = format.copyWithMetadata(metadata);
            }
        }
        mp4Track.trackOutput.format(format);
        durationUs = Math.max(durationUs, track.durationUs);
        tracks.add(mp4Track);
        long firstSampleOffset = trackSampleTable.offsets[0];
        if (firstSampleOffset < earliestSampleOffset) {
            earliestSampleOffset = firstSampleOffset;
        }
    }
    this.durationUs = durationUs;
    this.tracks = tracks.toArray(new Mp4Track[tracks.size()]);
    extractorOutput.endTracks();
    extractorOutput.seekMap(this);
}
Also used : ArrayList(java.util.ArrayList) Metadata(com.google.android.exoplayer2.metadata.Metadata) ContainerAtom(com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom) ContainerAtom(com.google.android.exoplayer2.extractor.mp4.Atom.ContainerAtom) Format(com.google.android.exoplayer2.Format) GaplessInfoHolder(com.google.android.exoplayer2.extractor.GaplessInfoHolder)

Example 3 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class EventMessageDecoderTest method testDecodeEventMessage.

public void testDecodeEventMessage() {
    byte[] rawEmsgBody = new byte[] { // scheme_id_uri = "urn:test"
    117, // scheme_id_uri = "urn:test"
    114, // scheme_id_uri = "urn:test"
    110, // scheme_id_uri = "urn:test"
    58, // scheme_id_uri = "urn:test"
    116, // scheme_id_uri = "urn:test"
    101, // scheme_id_uri = "urn:test"
    115, // scheme_id_uri = "urn:test"
    116, // scheme_id_uri = "urn:test"
    0, // value = "123"
    49, // value = "123"
    50, // value = "123"
    51, // value = "123"
    0, // timescale = 48000
    0, // timescale = 48000
    0, // timescale = 48000
    -69, // timescale = 48000
    -128, // presentation_time_delta (ignored) = 0
    0, // presentation_time_delta (ignored) = 0
    0, // presentation_time_delta (ignored) = 0
    0, // presentation_time_delta (ignored) = 0
    0, // event_duration = 144000
    0, // event_duration = 144000
    2, // event_duration = 144000
    50, // event_duration = 144000
    -128, // id = 1000403
    0, // id = 1000403
    15, // id = 1000403
    67, // id = 1000403
    -45, 0, 1, 2, 3, // message_data = {0, 1, 2, 3, 4}
    4 };
    EventMessageDecoder decoder = new EventMessageDecoder();
    MetadataInputBuffer buffer = new MetadataInputBuffer();
    buffer.data = ByteBuffer.allocate(rawEmsgBody.length).put(rawEmsgBody);
    Metadata metadata = decoder.decode(buffer);
    assertEquals(1, metadata.length());
    EventMessage eventMessage = (EventMessage) metadata.get(0);
    assertEquals("urn:test", eventMessage.schemeIdUri);
    assertEquals("123", eventMessage.value);
    assertEquals(3000, eventMessage.durationMs);
    assertEquals(1000403, eventMessage.id);
    MoreAsserts.assertEquals(new byte[] { 0, 1, 2, 3, 4 }, eventMessage.messageData);
}
Also used : MetadataInputBuffer(com.google.android.exoplayer2.metadata.MetadataInputBuffer) Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 4 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class Id3DecoderTest method testDecodeTxxxFrame.

public void testDecodeTxxxFrame() throws MetadataDecoderException {
    byte[] rawId3 = new byte[] { 73, 68, 51, 4, 0, 0, 0, 0, 0, 41, 84, 88, 88, 88, 0, 0, 0, 31, 0, 0, 3, 0, 109, 100, 105, 97, 108, 111, 103, 95, 86, 73, 78, 68, 73, 67, 79, 49, 53, 50, 55, 54, 54, 52, 95, 115, 116, 97, 114, 116, 0 };
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertEquals(1, metadata.length());
    TextInformationFrame textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertEquals("TXXX", textInformationFrame.id);
    assertEquals("", textInformationFrame.description);
    assertEquals("mdialog_VINDICO1527664_start", textInformationFrame.value);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 5 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class Id3DecoderTest method testDecodeApicFrame.

public void testDecodeApicFrame() throws MetadataDecoderException {
    byte[] rawId3 = new byte[] { 73, 68, 51, 4, 0, 0, 0, 0, 0, 45, 65, 80, 73, 67, 0, 0, 0, 35, 0, 0, 3, 105, 109, 97, 103, 101, 47, 106, 112, 101, 103, 0, 16, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertEquals(1, metadata.length());
    ApicFrame apicFrame = (ApicFrame) metadata.get(0);
    assertEquals("image/jpeg", apicFrame.mimeType);
    assertEquals(16, apicFrame.pictureType);
    assertEquals("Hello World", apicFrame.description);
    assertEquals(10, apicFrame.pictureData.length);
    MoreAsserts.assertEquals(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }, apicFrame.pictureData);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata)

Aggregations

DhisSpringTest (org.hisp.dhis.DhisSpringTest)55 Test (org.junit.Test)55 List (java.util.List)46 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)46 ClassPathResource (org.springframework.core.io.ClassPathResource)42 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)37 DataElement (org.hisp.dhis.dataelement.DataElement)25 User (org.hisp.dhis.user.User)20 MetadataVersion (org.hisp.dhis.metadata.version.MetadataVersion)19 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)19 Metadata (com.google.android.exoplayer2.metadata.Metadata)18 DataSet (org.hisp.dhis.dataset.DataSet)15 ArrayList (java.util.ArrayList)14 MetadataVersionServiceException (org.hisp.dhis.dxf2.metadata.version.exception.MetadataVersionServiceException)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)14 IOException (java.io.IOException)10 Metadata (org.hisp.dhis.dxf2.metadata.Metadata)10 DhisHttpResponse (org.hisp.dhis.system.util.DhisHttpResponse)10 UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)10 IntegrationTest (org.hisp.dhis.IntegrationTest)9