Commit 89d10451 by Dustin

Move list types to the same class. Expose readHeaderList for external use.

parent e67d4719
...@@ -106,8 +106,6 @@ public class AviExtractor implements Extractor { ...@@ -106,8 +106,6 @@ public class AviExtractor implements Extractor {
static final int RIFF = 'R' | ('I' << 8) | ('F' << 16) | ('F' << 24); static final int RIFF = 'R' | ('I' << 8) | ('F' << 16) | ('F' << 24);
static final int AVI_ = 'A' | ('V' << 8) | ('I' << 16) | (' ' << 24); static final int AVI_ = 'A' | ('V' << 8) | ('I' << 16) | (' ' << 24);
//Stream List
static final int STRL = 's' | ('t' << 8) | ('r' << 16) | ('l' << 24);
//movie data box //movie data box
static final int MOVI = 'm' | ('o' << 8) | ('v' << 16) | ('i' << 24); static final int MOVI = 'm' | ('o' << 8) | ('v' << 16) | ('i' << 24);
//Index //Index
...@@ -191,7 +189,7 @@ public class AviExtractor implements Extractor { ...@@ -191,7 +189,7 @@ public class AviExtractor implements Extractor {
} }
@Nullable @Nullable
static ListBox readHeaderList(ExtractorInput input) throws IOException { public static ListBox readHeaderList(ExtractorInput input) throws IOException {
final ByteBuffer byteBuffer = getAviBuffer(input, 20); final ByteBuffer byteBuffer = getAviBuffer(input, 20);
if (byteBuffer == null) { if (byteBuffer == null) {
return null; return null;
...@@ -313,7 +311,7 @@ public class AviExtractor implements Extractor { ...@@ -313,7 +311,7 @@ public class AviExtractor implements Extractor {
int streamId = 0; int streamId = 0;
for (Box box : headerList.getChildren()) { for (Box box : headerList.getChildren()) {
if (box instanceof ListBox && ((ListBox) box).getListType() == STRL) { if (box instanceof ListBox && ((ListBox) box).getListType() == ListBox.TYPE_STRL) {
final ListBox streamList = (ListBox) box; final ListBox streamList = (ListBox) box;
aviTracks[streamId] = parseStream(streamList, streamId); aviTracks[streamId] = parseStream(streamList, streamId);
streamId++; streamId++;
......
...@@ -15,6 +15,8 @@ public class ListBox extends Box { ...@@ -15,6 +15,8 @@ public class ListBox extends Box {
public static final int LIST = 'L' | ('I' << 8) | ('S' << 16) | ('T' << 24); public static final int LIST = 'L' | ('I' << 8) | ('S' << 16) | ('T' << 24);
//Header List //Header List
public static final int TYPE_HDRL = 'h' | ('d' << 8) | ('r' << 16) | ('l' << 24); public static final int TYPE_HDRL = 'h' | ('d' << 8) | ('r' << 16) | ('l' << 24);
//Stream List
public static final int TYPE_STRL = 's' | ('t' << 8) | ('r' << 16) | ('l' << 24);
private final int listType; private final int listType;
...@@ -47,9 +49,6 @@ public class ListBox extends Box { ...@@ -47,9 +49,6 @@ public class ListBox extends Box {
/** /**
* Assume the input is pointing to the list type * Assume the input is pointing to the list type
* @param boxFactory
* @param input
* @return
* @throws IOException * @throws IOException
*/ */
public static ListBox newInstance(final int listSize, BoxFactory boxFactory, public static ListBox newInstance(final int listSize, BoxFactory boxFactory,
......
...@@ -46,7 +46,7 @@ public class AviExtractorRoboTest { ...@@ -46,7 +46,7 @@ public class AviExtractorRoboTest {
final AviExtractor aviExtractor = new AviExtractor(); final AviExtractor aviExtractor = new AviExtractor();
final FakeExtractorOutput fakeExtractorOutput = new FakeExtractorOutput(); final FakeExtractorOutput fakeExtractorOutput = new FakeExtractorOutput();
aviExtractor.init(fakeExtractorOutput); aviExtractor.init(fakeExtractorOutput);
final ListBox streamList = new ListBox(128, AviExtractor.STRL, Collections.EMPTY_LIST); final ListBox streamList = new ListBox(128, ListBox.TYPE_STRL, Collections.EMPTY_LIST);
Assert.assertNull(aviExtractor.parseStream(streamList, 0)); Assert.assertNull(aviExtractor.parseStream(streamList, 0));
} }
...@@ -55,7 +55,7 @@ public class AviExtractorRoboTest { ...@@ -55,7 +55,7 @@ public class AviExtractorRoboTest {
final AviExtractor aviExtractor = new AviExtractor(); final AviExtractor aviExtractor = new AviExtractor();
final FakeExtractorOutput fakeExtractorOutput = new FakeExtractorOutput(); final FakeExtractorOutput fakeExtractorOutput = new FakeExtractorOutput();
aviExtractor.init(fakeExtractorOutput); aviExtractor.init(fakeExtractorOutput);
final ListBox streamList = new ListBox(128, AviExtractor.STRL, final ListBox streamList = new ListBox(128, ListBox.TYPE_STRL,
Collections.singletonList(DataHelper.getVidsStreamHeader())); Collections.singletonList(DataHelper.getVidsStreamHeader()));
Assert.assertNull(aviExtractor.parseStream(streamList, 0)); Assert.assertNull(aviExtractor.parseStream(streamList, 0));
} }
...@@ -73,7 +73,7 @@ public class AviExtractorRoboTest { ...@@ -73,7 +73,7 @@ public class AviExtractorRoboTest {
byteBuffer.put(aviHeader); byteBuffer.put(aviHeader);
byteBuffer.putInt(ListBox.LIST); byteBuffer.putInt(ListBox.LIST);
byteBuffer.putInt(byteBuffer.remaining() - 4); byteBuffer.putInt(byteBuffer.remaining() - 4);
byteBuffer.putInt(AviExtractor.STRL); byteBuffer.putInt(ListBox.TYPE_STRL);
final StreamHeaderBox streamHeaderBox = DataHelper.getVidsStreamHeader(); final StreamHeaderBox streamHeaderBox = DataHelper.getVidsStreamHeader();
byteBuffer.putInt(StreamHeaderBox.STRH); byteBuffer.putInt(StreamHeaderBox.STRH);
......
...@@ -319,7 +319,7 @@ public class AviExtractorTest { ...@@ -319,7 +319,7 @@ public class AviExtractorTest {
@Test @Test
public void readHeaderList_givenNoHeaderList() throws IOException { public void readHeaderList_givenNoHeaderList() throws IOException {
final ByteBuffer byteBuffer = DataHelper.getRiffHeader(88, 0x44); final ByteBuffer byteBuffer = DataHelper.getRiffHeader(88, 0x44);
byteBuffer.putInt(0x14, AviExtractor.STRL); //Overwrite header list with stream list byteBuffer.putInt(0x14, ListBox.TYPE_STRL); //Overwrite header list with stream list
final FakeExtractorInput input = new FakeExtractorInput.Builder(). final FakeExtractorInput input = new FakeExtractorInput.Builder().
setData(byteBuffer.array()).build(); setData(byteBuffer.array()).build();
Assert.assertNull(AviExtractor.readHeaderList(input)); Assert.assertNull(AviExtractor.readHeaderList(input));
......
...@@ -62,7 +62,7 @@ public class DataHelper { ...@@ -62,7 +62,7 @@ public class DataHelper {
list.add(streamHeaderBox); list.add(streamHeaderBox);
list.add(streamFormatBox); list.add(streamFormatBox);
return new ListBox((int)(streamHeaderBox.getSize() + streamFormatBox.getSize()), return new ListBox((int)(streamHeaderBox.getSize() + streamFormatBox.getSize()),
AviExtractor.STRL, list); ListBox.TYPE_STRL, list);
} }
public static ListBox getAacStreamList() throws IOException { public static ListBox getAacStreamList() throws IOException {
...@@ -72,7 +72,7 @@ public class DataHelper { ...@@ -72,7 +72,7 @@ public class DataHelper {
list.add(streamHeaderBox); list.add(streamHeaderBox);
list.add(streamFormatBox); list.add(streamFormatBox);
return new ListBox((int)(streamHeaderBox.getSize() + streamFormatBox.getSize()), return new ListBox((int)(streamHeaderBox.getSize() + streamFormatBox.getSize()),
AviExtractor.STRL, list); ListBox.TYPE_STRL, list);
} }
public static StreamNameBox getStreamNameBox(final String name) { public static StreamNameBox getStreamNameBox(final String name) {
......
...@@ -10,7 +10,7 @@ public class StreamNameBoxTest { ...@@ -10,7 +10,7 @@ public class StreamNameBoxTest {
@Test @Test
public void createStreamName_givenList() throws IOException { public void createStreamName_givenList() throws IOException {
final String name = "Test"; final String name = "Test";
final ListBuilder listBuilder = new ListBuilder(AviExtractor.STRL); final ListBuilder listBuilder = new ListBuilder(ListBox.TYPE_STRL);
listBuilder.addBox(DataHelper.getStreamNameBox(name)); listBuilder.addBox(DataHelper.getStreamNameBox(name));
final ByteBuffer listBuffer = listBuilder.build(); final ByteBuffer listBuffer = listBuilder.build();
final FakeExtractorInput fakeExtractorInput = new FakeExtractorInput.Builder().setData(listBuffer.array()).build(); final FakeExtractorInput fakeExtractorInput = new FakeExtractorInput.Builder().setData(listBuffer.array()).build();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment