Search in sources :

Example 6 with Id3Decoder

use of com.google.android.exoplayer2.metadata.id3.Id3Decoder in project ExoPlayer by google.

the class Id3DecoderTest method decodePrivFrame.

@Test
public void decodePrivFrame() {
    byte[] rawId3 = buildSingleFrameTag("PRIV", new byte[] { 116, 101, 115, 116, 0, 1, 2, 3, 4 });
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    PrivFrame privFrame = (PrivFrame) metadata.get(0);
    assertThat(privFrame.owner).isEqualTo("test");
    assertThat(privFrame.privateData).isEqualTo(new byte[] { 1, 2, 3, 4 });
    // Test empty.
    rawId3 = buildSingleFrameTag("PRIV", new byte[0]);
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    privFrame = (PrivFrame) metadata.get(0);
    assertThat(privFrame.owner).isEmpty();
    assertThat(privFrame.privateData).isEqualTo(new byte[0]);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Example 7 with Id3Decoder

use of com.google.android.exoplayer2.metadata.id3.Id3Decoder in project ExoPlayer by google.

the class Id3DecoderTest method decodeUrlLinkFrame.

@Test
public void decodeUrlLinkFrame() {
    byte[] rawId3 = buildSingleFrameTag("WCOM", new byte[] { 104, 116, 116, 112, 115, 58, 47, 47, 116, 101, 115, 116, 46, 99, 111, 109, 47, 97, 98, 99, 63, 100, 101, 102 });
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    UrlLinkFrame urlLinkFrame = (UrlLinkFrame) metadata.get(0);
    assertThat(urlLinkFrame.id).isEqualTo("WCOM");
    assertThat(urlLinkFrame.description).isNull();
    assertThat(urlLinkFrame.url).isEqualTo("https://test.com/abc?def");
    // Test empty.
    rawId3 = buildSingleFrameTag("WCOM", new byte[0]);
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    urlLinkFrame = (UrlLinkFrame) metadata.get(0);
    assertThat(urlLinkFrame.id).isEqualTo("WCOM");
    assertThat(urlLinkFrame.description).isNull();
    assertThat(urlLinkFrame.url).isEmpty();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Example 8 with Id3Decoder

use of com.google.android.exoplayer2.metadata.id3.Id3Decoder in project ExoPlayer by google.

the class Id3DecoderTest method decodeMultiFrames.

@Test
public void decodeMultiFrames() {
    byte[] rawId3 = buildMultiFramesTag(new FrameSpec("COMM", new byte[] { 3, 101, 110, 103, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 116, 101, 120, 116, 0 }), new FrameSpec("APIC", new byte[] { 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);
    assertThat(metadata.length()).isEqualTo(2);
    CommentFrame commentFrame = (CommentFrame) metadata.get(0);
    ApicFrame apicFrame = (ApicFrame) metadata.get(1);
    assertThat(commentFrame.language).isEqualTo("eng");
    assertThat(commentFrame.description).isEqualTo("description");
    assertThat(commentFrame.text).isEqualTo("text");
    assertThat(apicFrame.mimeType).isEqualTo("image/jpeg");
    assertThat(apicFrame.pictureType).isEqualTo(16);
    assertThat(apicFrame.description).isEqualTo("Hello World");
    assertThat(apicFrame.pictureData).hasLength(10);
    assertThat(apicFrame.pictureData).isEqualTo(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 });
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Example 9 with Id3Decoder

use of com.google.android.exoplayer2.metadata.id3.Id3Decoder in project ExoPlayer by google.

the class Id3DecoderTest method decodeTxxxFrame.

@Test
public void decodeTxxxFrame() {
    // Test UTF-8.
    byte[] rawId3 = buildSingleFrameTag("TXXX", new byte[] { 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);
    assertThat(metadata.length()).isEqualTo(1);
    TextInformationFrame textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TXXX");
    assertThat(textInformationFrame.description).isEmpty();
    assertThat(textInformationFrame.value).isEqualTo("mdialog_VINDICO1527664_start");
    // Test UTF-16.
    rawId3 = buildSingleFrameTag("TXXX", new byte[] { 1, 0, 72, 0, 101, 0, 108, 0, 108, 0, 111, 0, 32, 0, 87, 0, 111, 0, 114, 0, 108, 0, 100, 0, 0 });
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TXXX");
    assertThat(textInformationFrame.description).isEqualTo("Hello World");
    assertThat(textInformationFrame.value).isEmpty();
    // Test empty.
    rawId3 = buildSingleFrameTag("TXXX", new byte[0]);
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(0);
    // Test encoding byte only.
    rawId3 = buildSingleFrameTag("TXXX", new byte[] { ID3_TEXT_ENCODING_UTF_8 });
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertThat(textInformationFrame.id).isEqualTo("TXXX");
    assertThat(textInformationFrame.description).isEmpty();
    assertThat(textInformationFrame.value).isEmpty();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Example 10 with Id3Decoder

use of com.google.android.exoplayer2.metadata.id3.Id3Decoder in project ExoPlayer by google.

the class Id3DecoderTest method decodeCommentFrame.

@Test
public void decodeCommentFrame() {
    byte[] rawId3 = buildSingleFrameTag("COMM", new byte[] { ID3_TEXT_ENCODING_UTF_8, 101, 110, 103, 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 116, 101, 120, 116, 0 });
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    CommentFrame commentFrame = (CommentFrame) metadata.get(0);
    assertThat(commentFrame.language).isEqualTo("eng");
    assertThat(commentFrame.description).isEqualTo("description");
    assertThat(commentFrame.text).isEqualTo("text");
    // Test empty.
    rawId3 = buildSingleFrameTag("COMM", new byte[0]);
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(0);
    // Test language only.
    rawId3 = buildSingleFrameTag("COMM", new byte[] { ID3_TEXT_ENCODING_UTF_8, 101, 110, 103 });
    metadata = decoder.decode(rawId3, rawId3.length);
    assertThat(metadata.length()).isEqualTo(1);
    commentFrame = (CommentFrame) metadata.get(0);
    assertThat(commentFrame.language).isEqualTo("eng");
    assertThat(commentFrame.description).isEmpty();
    assertThat(commentFrame.text).isEmpty();
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata) Test(org.junit.Test)

Aggregations

Metadata (com.google.android.exoplayer2.metadata.Metadata)13 Test (org.junit.Test)11 MetadataInputBuffer (com.google.android.exoplayer2.metadata.MetadataInputBuffer)3 Nullable (androidx.annotation.Nullable)2 Id3Decoder (com.google.android.exoplayer2.metadata.id3.Id3Decoder)2 Uri (android.net.Uri)1 HlsMediaPlaylist (com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist)1 DataSource (com.google.android.exoplayer2.upstream.DataSource)1 DataSpec (com.google.android.exoplayer2.upstream.DataSpec)1 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)1 EOFException (java.io.EOFException)1