Skip to content

Commit f4b27e6

Browse files
authored
Fix KLVInputStream::readBatch()
#168
1 parent e72f03d commit f4b27e6

File tree

4 files changed

+7
-58
lines changed

4 files changed

+7
-58
lines changed

src/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/**
3131
* ULValueAdapter converts a UL to and from a KLV Triplet Value
3232
*/
33-
public class ULValueAdapter extends TripletValueAdapter {
33+
public class ULValueAdapter {
3434

3535
/**
3636
* Converts a KLV Triplet Value to a UL.

src/main/java/com/sandflow/smpte/mxf/MXFInputStream.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
package com.sandflow.smpte.mxf;
2727

2828
import com.sandflow.smpte.klv.KLVInputStream;
29-
import com.sandflow.smpte.klv.adapters.TripletValueAdapter;
3029
import com.sandflow.smpte.klv.exceptions.KLVException;
31-
import com.sandflow.smpte.util.AUID;
3230
import com.sandflow.smpte.util.IDAU;
3331
import com.sandflow.smpte.util.UMID;
3432
import com.sandflow.smpte.util.UUID;
@@ -37,6 +35,7 @@
3735
import java.io.InputStream;
3836
import java.util.ArrayList;
3937
import java.util.Collection;
38+
import java.util.function.Function;
4039

4140
/**
4241
* MXFInputStream allows MXF data structures to be read from an InputStream
@@ -125,8 +124,8 @@ public UMID readUMID() throws IOException, EOFException {
125124
* @throws KLVException
126125
* @throws IOException
127126
*/
128-
public <T, W extends TripletValueAdapter> Collection<T> readArray() throws KLVException, IOException {
129-
return readBatch();
127+
public <T> Collection<T> readArray(Function<byte[], T> converter) throws KLVException, IOException {
128+
return readBatch(converter);
130129
}
131130

132131
/**
@@ -138,7 +137,7 @@ public <T, W extends TripletValueAdapter> Collection<T> readArray() throws KLVEx
138137
* @throws KLVException
139138
* @throws IOException
140139
*/
141-
public <T, W extends TripletValueAdapter> Collection<T> readBatch() throws KLVException, IOException {
140+
public <T> Collection<T> readBatch(Function<byte[], T> converter) throws KLVException, IOException {
142141
ArrayList<T> batch = new ArrayList<>();
143142
long itemcount = readUnsignedInt();
144143
long itemlength = readUnsignedInt();
@@ -148,7 +147,7 @@ public <T, W extends TripletValueAdapter> Collection<T> readBatch() throws KLVEx
148147
for (int i = 0; i < itemcount; i++) {
149148
byte[] value = new byte[(int) itemlength];
150149
read(value);
151-
batch.add(W.<T>fromValue(value));
150+
batch.add(converter.apply(value));
152151
}
153152
return batch;
154153
}

src/main/java/com/sandflow/smpte/mxf/PartitionPack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public static PartitionPack fromTriplet(Triplet triplet) throws KLVException {
126126

127127
pp.setOperationalPattern(kis.readUL());
128128

129-
pp.setEssenceContainers(kis.<UL, ULValueAdapter>readBatch());
129+
pp.setEssenceContainers(kis.readBatch(ULValueAdapter::fromValue));
130130

131131
} catch (IOException e) {
132132
throw new KLVException(e);

0 commit comments

Comments
 (0)