1010import org .intellij .lang .annotations .MagicConstant ;
1111
1212import static de .kaleidox .vban .Util .appendByteArray ;
13+ import static de .kaleidox .vban .Util .checkRange ;
1314import static de .kaleidox .vban .Util .intToByteArray ;
1415import static de .kaleidox .vban .Util .stringToBytesASCII ;
1516import static de .kaleidox .vban .Util .trimArray ;
@@ -21,17 +22,19 @@ public class VBANPacketHead implements ByteArray {
2122
2223 private VBANPacketHead (@ MagicConstant (flagsFromClass = Protocol .class ) int protocol ,
2324 @ MagicConstant (flagsFromClass = SampleRate .class ) int sampleRateIndex ,
24- byte samples ,
25- byte channel ,
25+ int samples ,
26+ int channel ,
2627 @ MagicConstant (flagsFromClass = Format .class ) int format ,
2728 @ MagicConstant (flagsFromClass = Codec .class ) int codec ,
2829 String streamName ,
2930 int frameCounter ) {
3031 byte [] bytes = new byte [0 ];
32+ checkRange (samples , 0 , 255 );
33+ checkRange (channel , 0 , 255 );
3134
3235 bytes = appendByteArray (bytes , "VBAN" .getBytes ());
3336 bytes = appendByteArray (bytes , (byte ) (protocol | sampleRateIndex ));
34- bytes = appendByteArray (bytes , samples , channel );
37+ bytes = appendByteArray (bytes , ( byte ) samples , ( byte ) channel );
3538 bytes = appendByteArray (bytes , (byte ) (format | codec ));
3639 bytes = appendByteArray (bytes , trimArray (stringToBytesASCII (streamName ), 16 ));
3740 bytes = appendByteArray (bytes , intToByteArray (frameCounter , 4 ));
@@ -114,16 +117,16 @@ public static class Factory implements de.kaleidox.util.model.Factory<VBANPacket
114117 private final int protocol ;
115118 @ MagicConstant (valuesFromClass = SampleRate .class )
116119 private final int sampleRate ;
117- private final byte samples ;
118- private final byte channel ;
120+ private final int samples ;
121+ private final int channel ;
119122 @ MagicConstant (valuesFromClass = Format .class )
120123 private final int format ;
121124 @ MagicConstant (valuesFromClass = Codec .class )
122125 private final int codec ;
123126 private final String streamName ;
124127 private int counter = 1 ;
125128
126- private Factory (int protocol , int sampleRate , byte samples , byte channel , int format , int codec , String streamName ) {
129+ private Factory (int protocol , int sampleRate , int samples , int channel , int format , int codec , String streamName ) {
127130 this .protocol = protocol ;
128131 this .sampleRate = sampleRate ;
129132 this .samples = samples ;
@@ -152,8 +155,8 @@ public static class Builder implements de.kaleidox.util.model.Builder<Factory> {
152155 private int protocol = -1 ;
153156 @ MagicConstant (valuesFromClass = SampleRate .class )
154157 private int sampleRate = SampleRate .hz48000 ;
155- private byte samples = - 1 ;
156- private byte channel = 2 ;
158+ private int samples = 255 ;
159+ private int channel = 2 ;
157160 @ MagicConstant (valuesFromClass = Format .class )
158161 private int format = Format .INT16 ;
159162 @ MagicConstant (valuesFromClass = Codec .class )
@@ -181,7 +184,7 @@ public Builder setSampleRate(int sampleRate) {
181184 return this ;
182185 }
183186
184- public byte getSamples () {
187+ public int getSamples () {
185188 return samples ;
186189 }
187190
@@ -190,7 +193,7 @@ public Builder setSamples(byte samples) {
190193 return this ;
191194 }
192195
193- public byte getChannel () {
196+ public int getChannel () {
194197 return channel ;
195198 }
196199
0 commit comments