Search in sources :

Example 6 with Metadata

use of com.google.android.exoplayer2.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 7 with Metadata

use of com.google.android.exoplayer2.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)

Example 8 with Metadata

use of com.google.android.exoplayer2.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 9 with Metadata

use of com.google.android.exoplayer2.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 10 with Metadata

use of com.google.android.exoplayer2.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)

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