1
package org.jaudiotagger.audio.real;
3
import java.io.ByteArrayInputStream;
4
import java.io.DataInputStream;
5
import java.io.IOException;
6
import java.io.RandomAccessFile;
8
import org.jaudiotagger.audio.exceptions.CannotReadException;
9
import org.jaudiotagger.audio.generic.Utils;
11
public class RealChunk {
13
protected static final String RMF = ".RMF";
14
protected static final String PROP = "PROP";
15
protected static final String MDPR = "MDPR";
16
protected static final String CONT = "CONT";
17
protected static final String DATA = "DATA";
18
protected static final String INDX = "INDX";
20
private final String id;
21
private final int size;
22
private final byte[] bytes;
24
public static RealChunk readChunk(RandomAccessFile raf)
25
throws CannotReadException, IOException {
26
final String id = Utils.readString(raf, 4);
27
final int size = Utils.readUint32AsInt(raf);
29
throw new CannotReadException(
30
"Corrupt file: RealAudio chunk length at position "
31
+ (raf.getFilePointer() - 4)
32
+ " cannot be less than 8");
34
if (size > (raf.length() - raf.getFilePointer() + 8)) {
35
throw new CannotReadException(
36
"Corrupt file: RealAudio chunk length of " + size
37
+ " at position " + (raf.getFilePointer() - 4)
38
+ " extends beyond the end of the file");
40
final byte[] bytes = new byte[size - 8];
42
return new RealChunk(id, size, bytes);
45
public RealChunk(String id, int size, byte[] bytes) {
52
public DataInputStream getDataInputStream() {
53
return new DataInputStream(new ByteArrayInputStream(getBytes()));
56
public boolean isCONT() {
57
return CONT.equals(id);
60
public boolean isPROP() {
61
return PROP.equals(id);
64
public byte[] getBytes() {
68
public String getId() {
72
public int getSize() {
77
public String toString() {
78
return id + "\t" + size;
1
package org.jaudiotagger.audio.real;
3
import java.io.ByteArrayInputStream;
4
import java.io.DataInputStream;
5
import java.io.IOException;
6
import java.io.RandomAccessFile;
8
import org.jaudiotagger.audio.exceptions.CannotReadException;
9
import org.jaudiotagger.audio.generic.Utils;
11
public class RealChunk {
13
protected static final String RMF = ".RMF";
14
protected static final String PROP = "PROP";
15
protected static final String MDPR = "MDPR";
16
protected static final String CONT = "CONT";
17
protected static final String DATA = "DATA";
18
protected static final String INDX = "INDX";
20
private final String id;
21
private final int size;
22
private final byte[] bytes;
24
public static RealChunk readChunk(RandomAccessFile raf)
25
throws CannotReadException, IOException {
26
final String id = Utils.readString(raf, 4);
27
final int size = Utils.readUint32AsInt(raf);
29
throw new CannotReadException(
30
"Corrupt file: RealAudio chunk length at position "
31
+ (raf.getFilePointer() - 4)
32
+ " cannot be less than 8");
34
if (size > (raf.length() - raf.getFilePointer() + 8)) {
35
throw new CannotReadException(
36
"Corrupt file: RealAudio chunk length of " + size
37
+ " at position " + (raf.getFilePointer() - 4)
38
+ " extends beyond the end of the file");
40
final byte[] bytes = new byte[size - 8];
42
return new RealChunk(id, size, bytes);
45
public RealChunk(String id, int size, byte[] bytes) {
52
public DataInputStream getDataInputStream() {
53
return new DataInputStream(new ByteArrayInputStream(getBytes()));
56
public boolean isCONT() {
57
return CONT.equals(id);
60
public boolean isPROP() {
61
return PROP.equals(id);
64
public byte[] getBytes() {
68
public String getId() {
72
public int getSize() {
77
public String toString() {
78
return id + "\t" + size;