With Preon , RtpHeader can be represented as follows:
public class RtpHeader { @BoundNumber(size = "2") public int version; @Bound public boolean padding; @Bound public boolean extension; @BoundNumber(size="4") public int csrcCount; @Bound public boolean marker; @BoundNumber(size="7") public int payloadType; @BoundNumber(size="16", byteOrder = ByteOrder.BigEndian) public int sequenceNumber; @BoundNumber(size="32", byteOrder = ByteOrder.BigEndian) public int timestamp; @BoundNumber(size="32", byteOrder = ByteOrder.BigEndian) public int synchronizationSource; @BoundList(size="csrcCount") public int[] csrcs; }
Encoding this byte can be as simple as this:
Codec<RtpHeader> codec = Codecs.create(RtpHeader.class); RtpHeader header = new RtpHeader(); ...
However, remember that coding in Preon is still in its early stages. This seems to work in this particular case, but I'm not going to make any guarantees.
The advantage of using Preon is obviously the fact that you don't have to worry about writing all the coding and decoding logic.
source share