Search in sources :

Example 6 with Metadata

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

the class SpliceInfoDecoderTest method test2SpliceInsertCommands.

public void test2SpliceInsertCommands() throws MetadataDecoderException {
    byte[] rawSpliceInsertCommand1 = new byte[] { // table_id.
    0, // section_syntax_indicator, private_indicator, reserved, section_length(4).
    (byte) 0x80, // section_length(8).
    0x19, // protocol_version.
    0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1).
    0x00, // pts_adjustment(32).
    0x00, // pts_adjustment(32).
    0x00, // pts_adjustment(32).
    0x00, // pts_adjustment(32).
    0x00, // cw_index.
    0x00, // tier(8).
    0x00, // tier(4), splice_command_length(4).
    0x00, // splice_command_length(8).
    0x0e, // splice_command_type = splice_insert.
    0x05, // splice_event_id.
    0x00, // splice_event_id.
    0x00, // splice_event_id.
    0x00, // splice_event_id.
    0x42, // splice_event_cancel_indicator, reserved.
    0x00, // out_of_network_indicator, program_splice_flag, duration_flag,
    0x40, // time_specified_flag, reserved, pts_time(1).
    (byte) 0x80, // PTS for playback position 3s.
    0x00, // PTS for playback position 3s.
    0x00, // PTS for playback position 3s.
    0x00, // PTS for playback position 3s.
    0x00, // unique_program_id.
    0x00, // unique_program_id.
    0x10, // avail_num.
    0x01, // avails_expected.
    0x02, 0x00, 0x00, 0x00, // CRC_32 (ignored, check happens at extraction).
    0x00 };
    Metadata metadata = feedInputBuffer(rawSpliceInsertCommand1, 2000000, 3000000);
    assertEquals(1, metadata.length());
    SpliceInsertCommand command = (SpliceInsertCommand) metadata.get(0);
    assertEquals(66, command.spliceEventId);
    assertFalse(command.spliceEventCancelIndicator);
    assertFalse(command.outOfNetworkIndicator);
    assertTrue(command.programSpliceFlag);
    assertFalse(command.spliceImmediateFlag);
    assertEquals(3000000, command.programSplicePlaybackPositionUs);
    assertEquals(C.TIME_UNSET, command.breakDuration);
    assertEquals(16, command.uniqueProgramId);
    assertEquals(1, command.availNum);
    assertEquals(2, command.availsExpected);
    byte[] rawSpliceInsertCommand2 = new byte[] { // table_id.
    0, // section_syntax_indicator, private_indicator, reserved, section_length(4).
    (byte) 0x80, // section_length(8).
    0x22, // protocol_version.
    0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1).
    0x00, // pts_adjustment(32).
    0x00, // pts_adjustment(32).
    0x00, // pts_adjustment(32).
    0x00, // pts_adjustment(32).
    0x00, // cw_index.
    0x00, // tier(8).
    0x00, // tier(4), splice_command_length(4).
    0x00, // splice_command_length(8).
    0x13, // splice_command_type = splice_insert.
    0x05, // splice_event_id.
    (byte) 0xff, // splice_event_id.
    (byte) 0xff, // splice_event_id.
    (byte) 0xff, // splice_event_id.
    (byte) 0xff, // splice_event_cancel_indicator, reserved.
    0x00, // out_of_network_indicator, program_splice_flag, duration_flag,
    0x00, // component_count.
    0x02, // component_tag.
    0x10, // time_specified_flag, reserved, pts_time(1).
    (byte) 0x81, // PTS for playback position 10s.
    (byte) 0xff, // PTS for playback position 10s.
    (byte) 0xff, // PTS for playback position 10s.
    (byte) 0xff, // PTS for playback position 10s.
    (byte) 0xff, // component_tag.
    0x11, // time_specified_flag, reserved.
    0x00, // unique_program_id.
    0x00, // unique_program_id.
    0x20, // avail_num.
    0x01, // avails_expected.
    0x02, 0x00, 0x00, 0x00, // CRC_32 (ignored, check happens at extraction).
    0x00 };
    // By changing the subsample offset we force adjuster reconstruction.
    long subsampleOffset = 1000011;
    metadata = feedInputBuffer(rawSpliceInsertCommand2, 1000000, subsampleOffset);
    assertEquals(1, metadata.length());
    command = (SpliceInsertCommand) metadata.get(0);
    assertEquals(0xffffffffL, command.spliceEventId);
    assertFalse(command.spliceEventCancelIndicator);
    assertFalse(command.outOfNetworkIndicator);
    assertFalse(command.programSpliceFlag);
    assertFalse(command.spliceImmediateFlag);
    assertEquals(C.TIME_UNSET, command.programSplicePlaybackPositionUs);
    assertEquals(C.TIME_UNSET, command.breakDuration);
    List<SpliceInsertCommand.ComponentSplice> componentSplices = command.componentSpliceList;
    assertEquals(2, componentSplices.size());
    assertEquals(16, componentSplices.get(0).componentTag);
    assertEquals(1000000, componentSplices.get(0).componentSplicePlaybackPositionUs);
    assertEquals(17, componentSplices.get(1).componentTag);
    assertEquals(C.TIME_UNSET, componentSplices.get(1).componentSplicePts);
    assertEquals(32, command.uniqueProgramId);
    assertEquals(1, command.availNum);
    assertEquals(2, command.availsExpected);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 7 with Metadata

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

the class FormatTest method testParcelable.

public void testParcelable() {
    DrmInitData.SchemeData DRM_DATA_1 = new DrmInitData.SchemeData(WIDEVINE_UUID, VIDEO_MP4, TestUtil.buildTestData(128, 1));
    DrmInitData.SchemeData DRM_DATA_2 = new DrmInitData.SchemeData(C.UUID_NIL, VIDEO_WEBM, TestUtil.buildTestData(128, 1));
    DrmInitData drmInitData = new DrmInitData(DRM_DATA_1, DRM_DATA_2);
    byte[] projectionData = new byte[] { 1, 2, 3 };
    Metadata metadata = new Metadata(new TextInformationFrame("id1", "description1", "value1"), new TextInformationFrame("id2", "description2", "value2"));
    Format formatToParcel = new Format("id", MimeTypes.VIDEO_MP4, MimeTypes.VIDEO_H264, null, 1024, 2048, 1920, 1080, 24, 90, 2, projectionData, C.STEREO_MODE_TOP_BOTTOM, 6, 44100, C.ENCODING_PCM_24BIT, 1001, 1002, 0, "und", Format.NO_VALUE, Format.OFFSET_SAMPLE_RELATIVE, INIT_DATA, drmInitData, metadata);
    Parcel parcel = Parcel.obtain();
    formatToParcel.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    Format formatFromParcel = Format.CREATOR.createFromParcel(parcel);
    assertEquals(formatToParcel, formatFromParcel);
    parcel.recycle();
}
Also used : DrmInitData(com.google.android.exoplayer2.drm.DrmInitData) MediaFormat(android.media.MediaFormat) Parcel(android.os.Parcel) Metadata(com.google.android.exoplayer2.metadata.Metadata) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Example 8 with Metadata

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

the class HlsMediaChunk method peekId3PrivTimestamp.

/**
   * Peek the presentation timestamp of the first sample in the chunk from an ID3 PRIV as defined
   * in the HLS spec, version 20, Section 3.4. Returns {@link C#TIME_UNSET} if the frame is not
   * found. This method only modifies the peek position.
   *
   * @param input The {@link ExtractorInput} to obtain the PRIV frame from.
   * @return The parsed, adjusted timestamp in microseconds
   * @throws IOException If an error occurred peeking from the input.
   * @throws InterruptedException If the thread was interrupted.
   */
private long peekId3PrivTimestamp(ExtractorInput input) throws IOException, InterruptedException {
    input.resetPeekPosition();
    if (!input.peekFully(id3Data.data, 0, Id3Decoder.ID3_HEADER_LENGTH, true)) {
        return C.TIME_UNSET;
    }
    id3Data.reset(Id3Decoder.ID3_HEADER_LENGTH);
    int id = id3Data.readUnsignedInt24();
    if (id != Id3Decoder.ID3_TAG) {
        return C.TIME_UNSET;
    }
    // version(2), flags(1).
    id3Data.skipBytes(3);
    int id3Size = id3Data.readSynchSafeInt();
    int requiredCapacity = id3Size + Id3Decoder.ID3_HEADER_LENGTH;
    if (requiredCapacity > id3Data.capacity()) {
        byte[] data = id3Data.data;
        id3Data.reset(requiredCapacity);
        System.arraycopy(data, 0, id3Data.data, 0, Id3Decoder.ID3_HEADER_LENGTH);
    }
    if (!input.peekFully(id3Data.data, Id3Decoder.ID3_HEADER_LENGTH, id3Size, true)) {
        return C.TIME_UNSET;
    }
    Metadata metadata = id3Decoder.decode(id3Data.data, id3Size);
    if (metadata == null) {
        return C.TIME_UNSET;
    }
    int metadataLength = metadata.length();
    for (int i = 0; i < metadataLength; i++) {
        Metadata.Entry frame = metadata.get(i);
        if (frame instanceof PrivFrame) {
            PrivFrame privFrame = (PrivFrame) frame;
            if (PRIV_TIMESTAMP_FRAME_OWNER.equals(privFrame.owner)) {
                System.arraycopy(privFrame.privateData, 0, id3Data.data, 0, 8);
                id3Data.reset(8);
                return id3Data.readLong();
            }
        }
    }
    return C.TIME_UNSET;
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) PrivFrame(com.google.android.exoplayer2.metadata.id3.PrivFrame)

Example 9 with Metadata

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

the class SimpleExoPlayerView method updateForCurrentTrackSelections.

private void updateForCurrentTrackSelections() {
    if (player == null) {
        return;
    }
    TrackSelectionArray selections = player.getCurrentTrackSelections();
    for (int i = 0; i < selections.length; i++) {
        if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) {
            // Video enabled so artwork must be hidden. If the shutter is closed, it will be opened in
            // onRenderedFirstFrame().
            hideArtwork();
            return;
        }
    }
    // Video disabled so the shutter must be closed.
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    // Display artwork if enabled and available, else hide it.
    if (useArtwork) {
        for (int i = 0; i < selections.length; i++) {
            TrackSelection selection = selections.get(i);
            if (selection != null) {
                for (int j = 0; j < selection.length(); j++) {
                    Metadata metadata = selection.getFormat(j).metadata;
                    if (metadata != null && setArtworkFromMetadata(metadata)) {
                        return;
                    }
                }
            }
        }
        if (setArtworkFromBitmap(defaultArtwork)) {
            return;
        }
    }
    // Artwork disabled or unavailable.
    hideArtwork();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) TrackSelection(com.google.android.exoplayer2.trackselection.TrackSelection) TrackSelectionArray(com.google.android.exoplayer2.trackselection.TrackSelectionArray)

Example 10 with Metadata

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

the class SimpleExoPlayerView method setArtworkFromMetadata.

private boolean setArtworkFromMetadata(Metadata metadata) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry metadataEntry = metadata.get(i);
        if (metadataEntry instanceof ApicFrame) {
            byte[] bitmapData = ((ApicFrame) metadataEntry).pictureData;
            Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length);
            return setArtworkFromBitmap(bitmap);
        }
    }
    return false;
}
Also used : Bitmap(android.graphics.Bitmap) ApicFrame(com.google.android.exoplayer2.metadata.id3.ApicFrame) 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