mirror of
https://github.com/samsonjs/media.git
synced 2026-04-02 10:45:51 +00:00
Move list types to the same class. Expose readHeaderList for external use.
This commit is contained in:
parent
e67d47192b
commit
89d10451ce
6 changed files with 11 additions and 14 deletions
|
|
@ -106,8 +106,6 @@ public class AviExtractor implements Extractor {
|
|||
|
||||
static final int RIFF = 'R' | ('I' << 8) | ('F' << 16) | ('F' << 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
|
||||
static final int MOVI = 'm' | ('o' << 8) | ('v' << 16) | ('i' << 24);
|
||||
//Index
|
||||
|
|
@ -191,7 +189,7 @@ public class AviExtractor implements Extractor {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
static ListBox readHeaderList(ExtractorInput input) throws IOException {
|
||||
public static ListBox readHeaderList(ExtractorInput input) throws IOException {
|
||||
final ByteBuffer byteBuffer = getAviBuffer(input, 20);
|
||||
if (byteBuffer == null) {
|
||||
return null;
|
||||
|
|
@ -313,7 +311,7 @@ public class AviExtractor implements Extractor {
|
|||
|
||||
int streamId = 0;
|
||||
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;
|
||||
aviTracks[streamId] = parseStream(streamList, streamId);
|
||||
streamId++;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ public class ListBox extends Box {
|
|||
public static final int LIST = 'L' | ('I' << 8) | ('S' << 16) | ('T' << 24);
|
||||
//Header List
|
||||
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;
|
||||
|
||||
|
|
@ -47,9 +49,6 @@ public class ListBox extends Box {
|
|||
|
||||
/**
|
||||
* Assume the input is pointing to the list type
|
||||
* @param boxFactory
|
||||
* @param input
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static ListBox newInstance(final int listSize, BoxFactory boxFactory,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class AviExtractorRoboTest {
|
|||
final AviExtractor aviExtractor = new AviExtractor();
|
||||
final FakeExtractorOutput fakeExtractorOutput = new 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));
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ public class AviExtractorRoboTest {
|
|||
final AviExtractor aviExtractor = new AviExtractor();
|
||||
final FakeExtractorOutput fakeExtractorOutput = new 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()));
|
||||
Assert.assertNull(aviExtractor.parseStream(streamList, 0));
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ public class AviExtractorRoboTest {
|
|||
byteBuffer.put(aviHeader);
|
||||
byteBuffer.putInt(ListBox.LIST);
|
||||
byteBuffer.putInt(byteBuffer.remaining() - 4);
|
||||
byteBuffer.putInt(AviExtractor.STRL);
|
||||
byteBuffer.putInt(ListBox.TYPE_STRL);
|
||||
|
||||
final StreamHeaderBox streamHeaderBox = DataHelper.getVidsStreamHeader();
|
||||
byteBuffer.putInt(StreamHeaderBox.STRH);
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ public class AviExtractorTest {
|
|||
@Test
|
||||
public void readHeaderList_givenNoHeaderList() throws IOException {
|
||||
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().
|
||||
setData(byteBuffer.array()).build();
|
||||
Assert.assertNull(AviExtractor.readHeaderList(input));
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class DataHelper {
|
|||
list.add(streamHeaderBox);
|
||||
list.add(streamFormatBox);
|
||||
return new ListBox((int)(streamHeaderBox.getSize() + streamFormatBox.getSize()),
|
||||
AviExtractor.STRL, list);
|
||||
ListBox.TYPE_STRL, list);
|
||||
}
|
||||
|
||||
public static ListBox getAacStreamList() throws IOException {
|
||||
|
|
@ -72,7 +72,7 @@ public class DataHelper {
|
|||
list.add(streamHeaderBox);
|
||||
list.add(streamFormatBox);
|
||||
return new ListBox((int)(streamHeaderBox.getSize() + streamFormatBox.getSize()),
|
||||
AviExtractor.STRL, list);
|
||||
ListBox.TYPE_STRL, list);
|
||||
}
|
||||
|
||||
public static StreamNameBox getStreamNameBox(final String name) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public class StreamNameBoxTest {
|
|||
@Test
|
||||
public void createStreamName_givenList() throws IOException {
|
||||
final String name = "Test";
|
||||
final ListBuilder listBuilder = new ListBuilder(AviExtractor.STRL);
|
||||
final ListBuilder listBuilder = new ListBuilder(ListBox.TYPE_STRL);
|
||||
listBuilder.addBox(DataHelper.getStreamNameBox(name));
|
||||
final ByteBuffer listBuffer = listBuilder.build();
|
||||
final FakeExtractorInput fakeExtractorInput = new FakeExtractorInput.Builder().setData(listBuffer.array()).build();
|
||||
|
|
|
|||
Loading…
Reference in a new issue