/// <summary> /// Unpacks an array of binary data given reference start and end pointers. /// </summary> /// <param name="data"> /// A <see cref="System.Byte[]"/> /// </param> /// <param name="start"> /// A <see cref="System.Int32"/> /// </param> /// <param name="end"> /// A <see cref="System.Int32"/> /// </param> /// <returns> /// A <see cref="OSCPacket"/> /// </returns> public static OSCPacket Unpack(byte[] data, ref int start, int end) { if (data[start] == '#') { return(OSCBundle.Unpack(data, ref start, end)); } else { return(OSCMessage.Unpack(data, ref start)); } }
/// <summary> /// Unpacks an OSC bundle from a data stream. /// </summary> /// <param name="data"> /// A <see cref="System.Byte[]"/> /// </param> /// <param name="start"> /// A <see cref="System.Int32"/> /// </param> /// <param name="end"> /// A <see cref="System.Int32"/> /// </param> /// <returns> /// A <see cref="OSCBundle"/> /// </returns> public new static OSCBundle Unpack(byte[] data, ref int start, int end) { string address = OSCPacket.UnpackValue <string>(data, ref start); Trace.Assert(address == BUNDLE); long timeStamp = OSCPacket.UnpackValue <long>(data, ref start); OSCBundle bundle = new OSCBundle(timeStamp); while (start < end) { int length = OSCPacket.UnpackValue <int>(data, ref start); int packetEnd = start + length; bundle.Append(OSCPacket.Unpack(data, ref start, packetEnd)); } return(bundle); }