checkstyle
* drop unused methods * split blobs * make no final parameters
This commit is contained in:
parent
e4a4af34c5
commit
ff9a1ebb1b
6 changed files with 1244 additions and 1316 deletions
|
@ -86,11 +86,11 @@ public class DataReader {
|
||||||
return high << 32 | low;
|
return high << 32 | low;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(final byte[] buffer) throws IOException {
|
public int read(byte[] buffer) throws IOException {
|
||||||
return read(buffer, 0, buffer.length);
|
return read(buffer, 0, buffer.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int read(final byte[] buffer, int offset, int count) throws IOException {
|
public int read(byte[] buffer, int offset, int count) throws IOException {
|
||||||
if (readCount < 0) {
|
if (readCount < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,6 @@ public class Mp4DashReader {
|
||||||
moov = parseMoov(box);
|
moov = parseMoov(box);
|
||||||
break;
|
break;
|
||||||
case ATOM_SIDX:
|
case ATOM_SIDX:
|
||||||
break;
|
|
||||||
case ATOM_MFRA:
|
case ATOM_MFRA:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -148,52 +147,6 @@ public class Mp4DashReader {
|
||||||
return tracks[index];
|
return tracks[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Count all fragments present. This operation requires a seekable stream
|
|
||||||
*
|
|
||||||
* @return list with a basic info
|
|
||||||
* @throws IOException if the source stream is not seekeable
|
|
||||||
*/
|
|
||||||
int getFragmentsCount() throws IOException {
|
|
||||||
if (selectedTrack < 0) {
|
|
||||||
throw new IllegalStateException("track no selected");
|
|
||||||
}
|
|
||||||
if (!stream.canRewind()) {
|
|
||||||
throw new IOException("The provided stream doesn't allow seek");
|
|
||||||
}
|
|
||||||
|
|
||||||
Box tmp;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
if (box.type == ATOM_MOOF) {
|
|
||||||
tmp = box;
|
|
||||||
} else {
|
|
||||||
ensure(box);
|
|
||||||
tmp = readBox();
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
if (tmp.type == ATOM_MOOF) {
|
|
||||||
ensure(readBox(ATOM_MFHD));
|
|
||||||
Box traf;
|
|
||||||
while ((traf = untilBox(tmp, ATOM_TRAF)) != null) {
|
|
||||||
Box tfhd = readBox(ATOM_TFHD);
|
|
||||||
if (parseTfhd(tracks[selectedTrack].trak.tkhd.trackId) != null) {
|
|
||||||
count++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ensure(tfhd);
|
|
||||||
ensure(traf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ensure(tmp);
|
|
||||||
} while (stream.available() && (tmp = readBox()) != null);
|
|
||||||
|
|
||||||
rewind();
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] getBrands() {
|
public int[] getBrands() {
|
||||||
if (brands == null) {
|
if (brands == null) {
|
||||||
throw new IllegalStateException("Not parsed");
|
throw new IllegalStateException("Not parsed");
|
||||||
|
|
|
@ -640,7 +640,7 @@ public class Mp4FromDashWriter {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte[] makeMdat(long refSize, final boolean is64) {
|
private byte[] makeMdat(long refSize, boolean is64) {
|
||||||
if (is64) {
|
if (is64) {
|
||||||
refSize += 16;
|
refSize += 16;
|
||||||
} else {
|
} else {
|
||||||
|
@ -674,8 +674,9 @@ public class Mp4FromDashWriter {
|
||||||
0x00, 0x01, 0x00, 0x00, 0x01, 0x00, // default volume and rate
|
0x00, 0x01, 0x00, 0x00, 0x01, 0x00, // default volume and rate
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // reserved values
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // reserved values
|
||||||
// default matrix
|
// default matrix
|
||||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00,
|
||||||
0x40, 0x00, 0x00, 0x00
|
0x40, 0x00, 0x00, 0x00
|
||||||
});
|
});
|
||||||
auxWrite(new byte[24]); // predefined
|
auxWrite(new byte[24]); // predefined
|
||||||
|
@ -717,12 +718,13 @@ public class Mp4FromDashWriter {
|
||||||
|
|
||||||
// udta/meta/ilst/©too
|
// udta/meta/ilst/©too
|
||||||
auxWrite(new byte[]{
|
auxWrite(new byte[]{
|
||||||
0x00, 0x00, 0x00, 0x5C, 0x75, 0x64, 0x74, 0x61, 0x00, 0x00, 0x00, 0x54, 0x6D, 0x65, 0x74, 0x61,
|
0x00, 0x00, 0x00, 0x5C, 0x75, 0x64, 0x74, 0x61, 0x00, 0x00, 0x00, 0x54, 0x6D, 0x65,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x68, 0x64, 0x6C, 0x72, 0x00, 0x00, 0x00, 0x00,
|
0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x68, 0x64, 0x6C, 0x72,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x6D, 0x64, 0x69, 0x72, 0x61, 0x70, 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x64, 0x69, 0x72, 0x61, 0x70,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x69, 0x6C, 0x73, 0x74, 0x00, 0x00, 0x00,
|
0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x1F, (byte) 0xA9, 0x74, 0x6F, 0x6F, 0x00, 0x00, 0x00, 0x17, 0x64, 0x61, 0x74, 0x61, 0x00, 0x00,
|
0x27, 0x69, 0x6C, 0x73, 0x74, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
0x1F, (byte) 0xA9, 0x74, 0x6F, 0x6F, 0x00, 0x00, 0x00, 0x17, 0x64, 0x61, 0x74, 0x61,
|
||||||
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65 // "NewPipe" binary string
|
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65 // "NewPipe" binary string
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -759,7 +761,8 @@ public class Mp4FromDashWriter {
|
||||||
|
|
||||||
auxWrite(new byte[]{
|
auxWrite(new byte[]{
|
||||||
0x00, 0x00, 0x00, 0x24, 0x65, 0x64, 0x74, 0x73, // edts header
|
0x00, 0x00, 0x00, 0x24, 0x65, 0x64, 0x74, 0x73, // edts header
|
||||||
0x00, 0x00, 0x00, 0x1C, 0x65, 0x6C, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 // elst header
|
0x00, 0x00, 0x00, 0x1C, 0x65, 0x6C, 0x73, 0x74,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 // elst header
|
||||||
});
|
});
|
||||||
|
|
||||||
int bMediaRate;
|
int bMediaRate;
|
||||||
|
@ -845,14 +848,18 @@ public class Mp4FromDashWriter {
|
||||||
private byte[] makeHdlr(final Hdlr hdlr) {
|
private byte[] makeHdlr(final Hdlr hdlr) {
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(new byte[]{
|
ByteBuffer buffer = ByteBuffer.wrap(new byte[]{
|
||||||
0x00, 0x00, 0x00, 0x77, 0x68, 0x64, 0x6C, 0x72, // hdlr
|
0x00, 0x00, 0x00, 0x77, 0x68, 0x64, 0x6C, 0x72, // hdlr
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
// binary string "ISO Media file created in NewPipe (A libre lightweight streaming frontend for Android)."
|
// binary string
|
||||||
0x49, 0x53, 0x4F, 0x20, 0x4D, 0x65, 0x64, 0x69, 0x61, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x63,
|
// "ISO Media file created in NewPipe (
|
||||||
0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x69, 0x6E, 0x20, 0x4E, 0x65, 0x77, 0x50, 0x69, 0x70,
|
// A libre lightweight streaming frontend for Android)."
|
||||||
0x65, 0x20, 0x28, 0x41, 0x20, 0x6C, 0x69, 0x62, 0x72, 0x65, 0x20, 0x6C, 0x69, 0x67, 0x68, 0x74,
|
0x49, 0x53, 0x4F, 0x20, 0x4D, 0x65, 0x64, 0x69, 0x61, 0x20, 0x66, 0x69, 0x6C, 0x65,
|
||||||
0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6D, 0x69, 0x6E, 0x67,
|
0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x69, 0x6E, 0x20, 0x4E, 0x65,
|
||||||
0x20, 0x66, 0x72, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x64, 0x20, 0x66, 0x6F, 0x72, 0x20, 0x41, 0x6E,
|
0x77, 0x50, 0x69, 0x70, 0x65, 0x20, 0x28, 0x41, 0x20, 0x6C, 0x69, 0x62, 0x72, 0x65,
|
||||||
|
0x20, 0x6C, 0x69, 0x67, 0x68, 0x74, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x73,
|
||||||
|
0x74, 0x72, 0x65, 0x61, 0x6D, 0x69,0x6E, 0x67,
|
||||||
|
0x20, 0x66, 0x72, 0x6F, 0x6E, 0x74, 0x65, 0x6E, 0x64, 0x20, 0x66, 0x6F, 0x72, 0x20,
|
||||||
|
0x41, 0x6E,
|
||||||
0x64, 0x72, 0x6F, 0x69, 0x64, 0x29, 0x2E
|
0x64, 0x72, 0x6F, 0x69, 0x64, 0x29, 0x2E
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -289,11 +289,13 @@ public class OggFromWebMWriter implements Closeable {
|
||||||
/*
|
/*
|
||||||
// whole file duration (not implemented)
|
// whole file duration (not implemented)
|
||||||
0x44,// tag string size
|
0x44,// tag string size
|
||||||
0x55, 0x52, 0x41, 0x54, 0x49, 0x4F, 0x4E, 0x3D, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30,
|
0x55, 0x52, 0x41, 0x54, 0x49, 0x4F, 0x4E, 0x3D, 0x30,
|
||||||
0x30, 0x2E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30
|
0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x2E, 0x30,
|
||||||
|
0x30, 0x30, 0x30, 0x30, 0x30, 0x30
|
||||||
*/
|
*/
|
||||||
0x0F, // tag string size
|
0x0F, // tag string size
|
||||||
0x00, 0x00, 0x00, 0x45, 0x4E, 0x43, 0x4F, 0x44, 0x45, 0x52, 0x3D, // "ENCODER=" binary string
|
0x00, 0x00, 0x00, 0x45, 0x4E, 0x43, 0x4F,
|
||||||
|
0x44, 0x45, 0x52, 0x3D, // "ENCODER=" binary string
|
||||||
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65, // "NewPipe" binary string
|
0x4E, 0x65, 0x77, 0x50, 0x69, 0x70, 0x65, // "NewPipe" binary string
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ????????
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ????????
|
||||||
};
|
};
|
||||||
|
@ -417,7 +419,7 @@ public class OggFromWebMWriter implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int calcCrc32(int initialCrc, final byte[] buffer, final int size) {
|
private int calcCrc32(int initialCrc, byte[] buffer, int size) {
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
int reg = (initialCrc >>> 24) & 0xff;
|
int reg = (initialCrc >>> 24) & 0xff;
|
||||||
initialCrc = (initialCrc << 8) ^ crc32Table[reg ^ (buffer[i] & 0xff)];
|
initialCrc = (initialCrc << 8) ^ crc32Table[reg ^ (buffer[i] & 0xff)];
|
||||||
|
|
|
@ -102,10 +102,6 @@ public class WebMWriter implements Closeable {
|
||||||
return done;
|
return done;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isParsed() {
|
|
||||||
return parsed;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
done = true;
|
done = true;
|
||||||
|
@ -360,7 +356,7 @@ public class WebMWriter implements Closeable {
|
||||||
|
|
||||||
Block bloq = new Block();
|
Block bloq = new Block();
|
||||||
bloq.data = res.data;
|
bloq.data = res.data;
|
||||||
bloq.dataSize = (int) res.dataSize;
|
bloq.dataSize = res.dataSize;
|
||||||
bloq.trackNumber = internalTrackId;
|
bloq.trackNumber = internalTrackId;
|
||||||
bloq.flags = res.flags;
|
bloq.flags = res.flags;
|
||||||
bloq.absoluteTimecode = res.absoluteTimeCodeNs / DEFAULT_TIMECODE_SCALE;
|
bloq.absoluteTimecode = res.absoluteTimeCodeNs / DEFAULT_TIMECODE_SCALE;
|
||||||
|
@ -728,7 +724,7 @@ public class WebMWriter implements Closeable {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class KeyFrame {
|
static class KeyFrame {
|
||||||
KeyFrame(final long segment, final long cluster, final long block, final long timecode) {
|
KeyFrame(final long segment, final long cluster, final long block, final long timecode) {
|
||||||
clusterPosition = cluster - segment;
|
clusterPosition = cluster - segment;
|
||||||
relativePosition = (int) (block - cluster - CLUSTER_HEADER_SIZE);
|
relativePosition = (int) (block - cluster - CLUSTER_HEADER_SIZE);
|
||||||
|
@ -740,7 +736,7 @@ public class WebMWriter implements Closeable {
|
||||||
final long duration;
|
final long duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Block {
|
static class Block {
|
||||||
InputStream data;
|
InputStream data;
|
||||||
int trackNumber;
|
int trackNumber;
|
||||||
byte flags;
|
byte flags;
|
||||||
|
@ -759,7 +755,7 @@ public class WebMWriter implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClusterInfo {
|
static class ClusterInfo {
|
||||||
long offset;
|
long offset;
|
||||||
int size;
|
int size;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,34 +10,4 @@
|
||||||
<suppress checks="FinalParameters"
|
<suppress checks="FinalParameters"
|
||||||
files="InfoListAdapter.java"
|
files="InfoListAdapter.java"
|
||||||
lines="253,325"/>
|
lines="253,325"/>
|
||||||
|
|
||||||
<!-- org.schabi.newpipe.streams -->
|
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="WebMWriter.java"
|
|
||||||
lines="423,595"/>
|
|
||||||
<suppress checks="LineLength"
|
|
||||||
files="WebMWriter.java"
|
|
||||||
lines="160,162"/>
|
|
||||||
|
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="OggFromWebMWriter.java"
|
|
||||||
lines="378,420"/>
|
|
||||||
<suppress checks="LineLength"
|
|
||||||
files="OggFromWebMWriter.java"
|
|
||||||
lines="292,296"/>
|
|
||||||
|
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="Mp4FromDashWriter.java"
|
|
||||||
lines="643"/>
|
|
||||||
<suppress checks="LineLength"
|
|
||||||
files="Mp4FromDashWriter.java"
|
|
||||||
lines="677,678,720-724,738,762,848,850-855"/>
|
|
||||||
|
|
||||||
<suppress checks="InnerAssignment"
|
|
||||||
files="Mp4DashReader.java"
|
|
||||||
lines="190"/>
|
|
||||||
|
|
||||||
<suppress checks="FinalParameters"
|
|
||||||
files="DataReader.java"
|
|
||||||
lines="46,93"/>
|
|
||||||
</suppressions>
|
</suppressions>
|
||||||
|
|
Loading…
Reference in a new issue