mirror of
				https://github.com/TeamNewPipe/NewPipe
				synced 2025-10-25 12:27:38 +00:00 
			
		
		
		
	checkstyle
* drop unused methods * split blobs * make no final parameters
This commit is contained in:
		| @@ -1,262 +1,262 @@ | ||||
| package org.schabi.newpipe.streams; | ||||
|  | ||||
| import org.schabi.newpipe.streams.io.SharpStream; | ||||
|  | ||||
| import java.io.EOFException; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
|  | ||||
| /** | ||||
|  * @author kapodamy | ||||
|  */ | ||||
| public class DataReader { | ||||
|     public static final int SHORT_SIZE = 2; | ||||
|     public static final int LONG_SIZE = 8; | ||||
|     public static final int INTEGER_SIZE = 4; | ||||
|     public static final int FLOAT_SIZE = 4; | ||||
|  | ||||
|     private static final int BUFFER_SIZE = 128 * 1024; // 128 KiB | ||||
|  | ||||
|     private long position = 0; | ||||
|     private final SharpStream stream; | ||||
|  | ||||
|     private InputStream view; | ||||
|     private int viewSize; | ||||
|  | ||||
|     public DataReader(final SharpStream stream) { | ||||
|         this.stream = stream; | ||||
|         this.readOffset = this.readBuffer.length; | ||||
|     } | ||||
|  | ||||
|     public long position() { | ||||
|         return position; | ||||
|     } | ||||
|  | ||||
|     public int read() throws IOException { | ||||
|         if (fillBuffer()) { | ||||
|             return -1; | ||||
|         } | ||||
|  | ||||
|         position++; | ||||
|         readCount--; | ||||
|  | ||||
|         return readBuffer[readOffset++] & 0xFF; | ||||
|     } | ||||
|  | ||||
|     public long skipBytes(long amount) throws IOException { | ||||
|         if (readCount < 0) { | ||||
|             return 0; | ||||
|         } else if (readCount == 0) { | ||||
|             amount = stream.skip(amount); | ||||
|         } else { | ||||
|             if (readCount > amount) { | ||||
|                 readCount -= (int) amount; | ||||
|                 readOffset += (int) amount; | ||||
|             } else { | ||||
|                 amount = readCount + stream.skip(amount - readCount); | ||||
|                 readCount = 0; | ||||
|                 readOffset = readBuffer.length; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         position += amount; | ||||
|         return amount; | ||||
|     } | ||||
|  | ||||
|     public int readInt() throws IOException { | ||||
|         primitiveRead(INTEGER_SIZE); | ||||
|         return primitive[0] << 24 | primitive[1] << 16 | primitive[2] << 8 | primitive[3]; | ||||
|     } | ||||
|  | ||||
|     public long readUnsignedInt()  throws IOException { | ||||
|         long value = readInt(); | ||||
|         return value & 0xffffffffL; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public short readShort() throws IOException { | ||||
|         primitiveRead(SHORT_SIZE); | ||||
|         return (short) (primitive[0] << 8 | primitive[1]); | ||||
|     } | ||||
|  | ||||
|     public long readLong() throws IOException { | ||||
|         primitiveRead(LONG_SIZE); | ||||
|         long high = primitive[0] << 24 | primitive[1] << 16 | primitive[2] << 8 | primitive[3]; | ||||
|         long low = primitive[4] << 24 | primitive[5] << 16 | primitive[6] << 8 | primitive[7]; | ||||
|         return high << 32 | low; | ||||
|     } | ||||
|  | ||||
|     public int read(final byte[] buffer) throws IOException { | ||||
|         return read(buffer, 0, buffer.length); | ||||
|     } | ||||
|  | ||||
|     public int read(final byte[] buffer, int offset, int count) throws IOException { | ||||
|         if (readCount < 0) { | ||||
|             return -1; | ||||
|         } | ||||
|         int total = 0; | ||||
|  | ||||
|         if (count >= readBuffer.length) { | ||||
|             if (readCount > 0) { | ||||
|                 System.arraycopy(readBuffer, readOffset, buffer, offset, readCount); | ||||
|                 readOffset += readCount; | ||||
|  | ||||
|                 offset += readCount; | ||||
|                 count -= readCount; | ||||
|  | ||||
|                 total = readCount; | ||||
|                 readCount = 0; | ||||
|             } | ||||
|             total += Math.max(stream.read(buffer, offset, count), 0); | ||||
|         } else { | ||||
|             while (count > 0 && !fillBuffer()) { | ||||
|                 int read = Math.min(readCount, count); | ||||
|                 System.arraycopy(readBuffer, readOffset, buffer, offset, read); | ||||
|  | ||||
|                 readOffset += read; | ||||
|                 readCount -= read; | ||||
|  | ||||
|                 offset += read; | ||||
|                 count -= read; | ||||
|  | ||||
|                 total += read; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         position += total; | ||||
|         return total; | ||||
|     } | ||||
|  | ||||
|     public boolean available() { | ||||
|         return readCount > 0 || stream.available() > 0; | ||||
|     } | ||||
|  | ||||
|     public void rewind() throws IOException { | ||||
|         stream.rewind(); | ||||
|  | ||||
|         if ((position - viewSize) > 0) { | ||||
|             viewSize = 0; // drop view | ||||
|         } else { | ||||
|             viewSize += position; | ||||
|         } | ||||
|  | ||||
|         position = 0; | ||||
|         readOffset = readBuffer.length; | ||||
|         readCount = 0; | ||||
|     } | ||||
|  | ||||
|     public boolean canRewind() { | ||||
|         return stream.canRewind(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Wraps this instance of {@code DataReader} into {@code InputStream} | ||||
|      * object. Note: Any read in the {@code DataReader} will not modify | ||||
|      * (decrease) the view size | ||||
|      * | ||||
|      * @param size the size of the view | ||||
|      * @return the view | ||||
|      */ | ||||
|     public InputStream getView(final int size) { | ||||
|         if (view == null) { | ||||
|             view = new InputStream() { | ||||
|                 @Override | ||||
|                 public int read() throws IOException { | ||||
|                     if (viewSize < 1) { | ||||
|                         return -1; | ||||
|                     } | ||||
|                     int res = DataReader.this.read(); | ||||
|                     if (res > 0) { | ||||
|                         viewSize--; | ||||
|                     } | ||||
|                     return res; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public int read(final byte[] buffer) throws IOException { | ||||
|                     return read(buffer, 0, buffer.length); | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public int read(final byte[] buffer, final int offset, final int count) | ||||
|                         throws IOException { | ||||
|                     if (viewSize < 1) { | ||||
|                         return -1; | ||||
|                     } | ||||
|  | ||||
|                     int res = DataReader.this.read(buffer, offset, Math.min(viewSize, count)); | ||||
|                     viewSize -= res; | ||||
|  | ||||
|                     return res; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public long skip(final long amount) throws IOException { | ||||
|                     if (viewSize < 1) { | ||||
|                         return 0; | ||||
|                     } | ||||
|                     int res = (int) DataReader.this.skipBytes(Math.min(amount, viewSize)); | ||||
|                     viewSize -= res; | ||||
|  | ||||
|                     return res; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public int available() { | ||||
|                     return viewSize; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public void close() { | ||||
|                     viewSize = 0; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public boolean markSupported() { | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|             }; | ||||
|         } | ||||
|         viewSize = size; | ||||
|  | ||||
|         return view; | ||||
|     } | ||||
|  | ||||
|     private final short[] primitive = new short[LONG_SIZE]; | ||||
|  | ||||
|     private void primitiveRead(final int amount) throws IOException { | ||||
|         byte[] buffer = new byte[amount]; | ||||
|         int read = read(buffer, 0, amount); | ||||
|  | ||||
|         if (read != amount) { | ||||
|             throw new EOFException("Truncated stream, missing " | ||||
|                     + String.valueOf(amount - read) + " bytes"); | ||||
|         } | ||||
|  | ||||
|         for (int i = 0; i < amount; i++) { | ||||
|             // the "byte" data type in java is signed and is very annoying | ||||
|             primitive[i] = (short) (buffer[i] & 0xFF); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private final byte[] readBuffer = new byte[BUFFER_SIZE]; | ||||
|     private int readOffset; | ||||
|     private int readCount; | ||||
|  | ||||
|     private boolean fillBuffer() throws IOException { | ||||
|         if (readCount < 0) { | ||||
|             return true; | ||||
|         } | ||||
|         if (readOffset >= readBuffer.length) { | ||||
|             readCount = stream.read(readBuffer); | ||||
|             if (readCount < 1) { | ||||
|                 readCount = -1; | ||||
|                 return true; | ||||
|             } | ||||
|             readOffset = 0; | ||||
|         } | ||||
|  | ||||
|         return readCount < 1; | ||||
|     } | ||||
| } | ||||
| package org.schabi.newpipe.streams; | ||||
|  | ||||
| import org.schabi.newpipe.streams.io.SharpStream; | ||||
|  | ||||
| import java.io.EOFException; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
|  | ||||
| /** | ||||
|  * @author kapodamy | ||||
|  */ | ||||
| public class DataReader { | ||||
|     public static final int SHORT_SIZE = 2; | ||||
|     public static final int LONG_SIZE = 8; | ||||
|     public static final int INTEGER_SIZE = 4; | ||||
|     public static final int FLOAT_SIZE = 4; | ||||
|  | ||||
|     private static final int BUFFER_SIZE = 128 * 1024; // 128 KiB | ||||
|  | ||||
|     private long position = 0; | ||||
|     private final SharpStream stream; | ||||
|  | ||||
|     private InputStream view; | ||||
|     private int viewSize; | ||||
|  | ||||
|     public DataReader(final SharpStream stream) { | ||||
|         this.stream = stream; | ||||
|         this.readOffset = this.readBuffer.length; | ||||
|     } | ||||
|  | ||||
|     public long position() { | ||||
|         return position; | ||||
|     } | ||||
|  | ||||
|     public int read() throws IOException { | ||||
|         if (fillBuffer()) { | ||||
|             return -1; | ||||
|         } | ||||
|  | ||||
|         position++; | ||||
|         readCount--; | ||||
|  | ||||
|         return readBuffer[readOffset++] & 0xFF; | ||||
|     } | ||||
|  | ||||
|     public long skipBytes(long amount) throws IOException { | ||||
|         if (readCount < 0) { | ||||
|             return 0; | ||||
|         } else if (readCount == 0) { | ||||
|             amount = stream.skip(amount); | ||||
|         } else { | ||||
|             if (readCount > amount) { | ||||
|                 readCount -= (int) amount; | ||||
|                 readOffset += (int) amount; | ||||
|             } else { | ||||
|                 amount = readCount + stream.skip(amount - readCount); | ||||
|                 readCount = 0; | ||||
|                 readOffset = readBuffer.length; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         position += amount; | ||||
|         return amount; | ||||
|     } | ||||
|  | ||||
|     public int readInt() throws IOException { | ||||
|         primitiveRead(INTEGER_SIZE); | ||||
|         return primitive[0] << 24 | primitive[1] << 16 | primitive[2] << 8 | primitive[3]; | ||||
|     } | ||||
|  | ||||
|     public long readUnsignedInt()  throws IOException { | ||||
|         long value = readInt(); | ||||
|         return value & 0xffffffffL; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public short readShort() throws IOException { | ||||
|         primitiveRead(SHORT_SIZE); | ||||
|         return (short) (primitive[0] << 8 | primitive[1]); | ||||
|     } | ||||
|  | ||||
|     public long readLong() throws IOException { | ||||
|         primitiveRead(LONG_SIZE); | ||||
|         long high = primitive[0] << 24 | primitive[1] << 16 | primitive[2] << 8 | primitive[3]; | ||||
|         long low = primitive[4] << 24 | primitive[5] << 16 | primitive[6] << 8 | primitive[7]; | ||||
|         return high << 32 | low; | ||||
|     } | ||||
|  | ||||
|     public int read(byte[] buffer) throws IOException { | ||||
|         return read(buffer, 0, buffer.length); | ||||
|     } | ||||
|  | ||||
|     public int read(byte[] buffer, int offset, int count) throws IOException { | ||||
|         if (readCount < 0) { | ||||
|             return -1; | ||||
|         } | ||||
|         int total = 0; | ||||
|  | ||||
|         if (count >= readBuffer.length) { | ||||
|             if (readCount > 0) { | ||||
|                 System.arraycopy(readBuffer, readOffset, buffer, offset, readCount); | ||||
|                 readOffset += readCount; | ||||
|  | ||||
|                 offset += readCount; | ||||
|                 count -= readCount; | ||||
|  | ||||
|                 total = readCount; | ||||
|                 readCount = 0; | ||||
|             } | ||||
|             total += Math.max(stream.read(buffer, offset, count), 0); | ||||
|         } else { | ||||
|             while (count > 0 && !fillBuffer()) { | ||||
|                 int read = Math.min(readCount, count); | ||||
|                 System.arraycopy(readBuffer, readOffset, buffer, offset, read); | ||||
|  | ||||
|                 readOffset += read; | ||||
|                 readCount -= read; | ||||
|  | ||||
|                 offset += read; | ||||
|                 count -= read; | ||||
|  | ||||
|                 total += read; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         position += total; | ||||
|         return total; | ||||
|     } | ||||
|  | ||||
|     public boolean available() { | ||||
|         return readCount > 0 || stream.available() > 0; | ||||
|     } | ||||
|  | ||||
|     public void rewind() throws IOException { | ||||
|         stream.rewind(); | ||||
|  | ||||
|         if ((position - viewSize) > 0) { | ||||
|             viewSize = 0; // drop view | ||||
|         } else { | ||||
|             viewSize += position; | ||||
|         } | ||||
|  | ||||
|         position = 0; | ||||
|         readOffset = readBuffer.length; | ||||
|         readCount = 0; | ||||
|     } | ||||
|  | ||||
|     public boolean canRewind() { | ||||
|         return stream.canRewind(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Wraps this instance of {@code DataReader} into {@code InputStream} | ||||
|      * object. Note: Any read in the {@code DataReader} will not modify | ||||
|      * (decrease) the view size | ||||
|      * | ||||
|      * @param size the size of the view | ||||
|      * @return the view | ||||
|      */ | ||||
|     public InputStream getView(final int size) { | ||||
|         if (view == null) { | ||||
|             view = new InputStream() { | ||||
|                 @Override | ||||
|                 public int read() throws IOException { | ||||
|                     if (viewSize < 1) { | ||||
|                         return -1; | ||||
|                     } | ||||
|                     int res = DataReader.this.read(); | ||||
|                     if (res > 0) { | ||||
|                         viewSize--; | ||||
|                     } | ||||
|                     return res; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public int read(final byte[] buffer) throws IOException { | ||||
|                     return read(buffer, 0, buffer.length); | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public int read(final byte[] buffer, final int offset, final int count) | ||||
|                         throws IOException { | ||||
|                     if (viewSize < 1) { | ||||
|                         return -1; | ||||
|                     } | ||||
|  | ||||
|                     int res = DataReader.this.read(buffer, offset, Math.min(viewSize, count)); | ||||
|                     viewSize -= res; | ||||
|  | ||||
|                     return res; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public long skip(final long amount) throws IOException { | ||||
|                     if (viewSize < 1) { | ||||
|                         return 0; | ||||
|                     } | ||||
|                     int res = (int) DataReader.this.skipBytes(Math.min(amount, viewSize)); | ||||
|                     viewSize -= res; | ||||
|  | ||||
|                     return res; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public int available() { | ||||
|                     return viewSize; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public void close() { | ||||
|                     viewSize = 0; | ||||
|                 } | ||||
|  | ||||
|                 @Override | ||||
|                 public boolean markSupported() { | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|             }; | ||||
|         } | ||||
|         viewSize = size; | ||||
|  | ||||
|         return view; | ||||
|     } | ||||
|  | ||||
|     private final short[] primitive = new short[LONG_SIZE]; | ||||
|  | ||||
|     private void primitiveRead(final int amount) throws IOException { | ||||
|         byte[] buffer = new byte[amount]; | ||||
|         int read = read(buffer, 0, amount); | ||||
|  | ||||
|         if (read != amount) { | ||||
|             throw new EOFException("Truncated stream, missing " | ||||
|                     + String.valueOf(amount - read) + " bytes"); | ||||
|         } | ||||
|  | ||||
|         for (int i = 0; i < amount; i++) { | ||||
|             // the "byte" data type in java is signed and is very annoying | ||||
|             primitive[i] = (short) (buffer[i] & 0xFF); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private final byte[] readBuffer = new byte[BUFFER_SIZE]; | ||||
|     private int readOffset; | ||||
|     private int readCount; | ||||
|  | ||||
|     private boolean fillBuffer() throws IOException { | ||||
|         if (readCount < 0) { | ||||
|             return true; | ||||
|         } | ||||
|         if (readOffset >= readBuffer.length) { | ||||
|             readCount = stream.read(readBuffer); | ||||
|             if (readCount < 1) { | ||||
|                 readCount = -1; | ||||
|                 return true; | ||||
|             } | ||||
|             readOffset = 0; | ||||
|         } | ||||
|  | ||||
|         return readCount < 1; | ||||
|     } | ||||
| } | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -640,7 +640,7 @@ public class Mp4FromDashWriter { | ||||
|         return size; | ||||
|     } | ||||
|  | ||||
|     private byte[] makeMdat(long refSize, final boolean is64) { | ||||
|     private byte[] makeMdat(long refSize, boolean is64) { | ||||
|         if (is64) { | ||||
|             refSize += 16; | ||||
|         } else { | ||||
| @@ -674,8 +674,9 @@ public class Mp4FromDashWriter { | ||||
|                 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, // default volume and rate | ||||
|                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // reserved values | ||||
|                 // 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, 0x00, | ||||
|                 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, 0x00, | ||||
|                 0x40, 0x00, 0x00, 0x00 | ||||
|         }); | ||||
|         auxWrite(new byte[24]); // predefined | ||||
| @@ -717,12 +718,13 @@ public class Mp4FromDashWriter { | ||||
|  | ||||
|         // udta/meta/ilst/©too | ||||
|         auxWrite(new byte[]{ | ||||
|                 0x00, 0x00, 0x00, 0x5C, 0x75, 0x64, 0x74, 0x61, 0x00, 0x00, 0x00, 0x54, 0x6D, 0x65, 0x74, 0x61, | ||||
|                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x68, 0x64, 0x6C, 0x72, 0x00, 0x00, 0x00, 0x00, | ||||
|                 0x00, 0x00, 0x00, 0x00, 0x6D, 0x64, 0x69, 0x72, 0x61, 0x70, 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, | ||||
|                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27, 0x69, 0x6C, 0x73, 0x74, 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, | ||||
|                 0x00, 0x00, 0x00, 0x5C, 0x75, 0x64, 0x74, 0x61, 0x00, 0x00, 0x00, 0x54, 0x6D, 0x65, | ||||
|                 0x74, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x68, 0x64, 0x6C, 0x72, | ||||
|                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x64, 0x69, 0x72, 0x61, 0x70, | ||||
|                 0x70, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||||
|                 0x27, 0x69, 0x6C, 0x73, 0x74, 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 | ||||
|         }); | ||||
|  | ||||
| @@ -759,7 +761,8 @@ public class Mp4FromDashWriter { | ||||
|  | ||||
|         auxWrite(new byte[]{ | ||||
|                 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; | ||||
| @@ -845,14 +848,18 @@ public class Mp4FromDashWriter { | ||||
|     private byte[] makeHdlr(final Hdlr hdlr) { | ||||
|         ByteBuffer buffer = ByteBuffer.wrap(new byte[]{ | ||||
|                 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, | ||||
|                 // binary string "ISO Media file created in NewPipe (A libre lightweight streaming frontend for Android)." | ||||
|                 0x49, 0x53, 0x4F, 0x20, 0x4D, 0x65, 0x64, 0x69, 0x61, 0x20, 0x66, 0x69, 0x6C, 0x65, 0x20, 0x63, | ||||
|                 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x69, 0x6E, 0x20, 0x4E, 0x65, 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, | ||||
|                 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)." | ||||
|                 0x49, 0x53, 0x4F, 0x20, 0x4D, 0x65, 0x64, 0x69, 0x61, 0x20, 0x66, 0x69, 0x6C, 0x65, | ||||
|                 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x69, 0x6E, 0x20, 0x4E, 0x65, | ||||
|                 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 | ||||
|         }); | ||||
|  | ||||
|   | ||||
| @@ -289,11 +289,13 @@ public class OggFromWebMWriter implements Closeable { | ||||
|                     /* | ||||
|                         // whole file duration (not implemented) | ||||
|                         0x44,// tag string size | ||||
|                         0x55, 0x52, 0x41, 0x54, 0x49, 0x4F, 0x4E, 0x3D, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, | ||||
|                         0x30, 0x2E, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30 | ||||
|                         0x55, 0x52, 0x41, 0x54, 0x49, 0x4F, 0x4E, 0x3D, 0x30, | ||||
|                         0x30, 0x3A, 0x30, 0x30, 0x3A, 0x30, 0x30, 0x2E, 0x30, | ||||
|                         0x30, 0x30, 0x30, 0x30, 0x30, 0x30 | ||||
|                      */ | ||||
|                     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 | ||||
|                     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++) { | ||||
|             int reg = (initialCrc >>> 24) & 0xff; | ||||
|             initialCrc = (initialCrc << 8) ^ crc32Table[reg ^ (buffer[i] & 0xff)]; | ||||
|   | ||||
| @@ -102,10 +102,6 @@ public class WebMWriter implements Closeable { | ||||
|         return done; | ||||
|     } | ||||
|  | ||||
|     public boolean isParsed() { | ||||
|         return parsed; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void close() { | ||||
|         done = true; | ||||
| @@ -360,7 +356,7 @@ public class WebMWriter implements Closeable { | ||||
|  | ||||
|         Block bloq = new Block(); | ||||
|         bloq.data = res.data; | ||||
|         bloq.dataSize = (int) res.dataSize; | ||||
|         bloq.dataSize = res.dataSize; | ||||
|         bloq.trackNumber = internalTrackId; | ||||
|         bloq.flags = res.flags; | ||||
|         bloq.absoluteTimecode = res.absoluteTimeCodeNs / DEFAULT_TIMECODE_SCALE; | ||||
| @@ -728,7 +724,7 @@ public class WebMWriter implements Closeable { | ||||
|         return 0; | ||||
|     } | ||||
|  | ||||
|     class KeyFrame { | ||||
|     static class KeyFrame { | ||||
|         KeyFrame(final long segment, final long cluster, final long block, final long timecode) { | ||||
|             clusterPosition = cluster - segment; | ||||
|             relativePosition = (int) (block - cluster - CLUSTER_HEADER_SIZE); | ||||
| @@ -740,7 +736,7 @@ public class WebMWriter implements Closeable { | ||||
|         final long duration; | ||||
|     } | ||||
|  | ||||
|     class Block { | ||||
|     static class Block { | ||||
|         InputStream data; | ||||
|         int trackNumber; | ||||
|         byte flags; | ||||
| @@ -759,7 +755,7 @@ public class WebMWriter implements Closeable { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     class ClusterInfo { | ||||
|     static class ClusterInfo { | ||||
|         long offset; | ||||
|         int size; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 kapodamy
					kapodamy