Ejemplo n.º 1
0
        private void OnTemperatureCallback(float[] data)
        {
            if ((temperature == null) || (temperature.Length != data.Length))
            {
                temperature = new byte[data.Length * 4];
            }

            Buffer.BlockCopy(data, 0, temperature, 0, temperature.Length);

            var userData = new UserData()
            {
                temperature     = Convert.ToBase64String(temperature),
                selections      = cell.GetAllSelectionInfo(),
                groupSelections = cell.GetAllSelectionGroupInfo()
            };
            var content = CompressUtils.Compress(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(userData)));
            var header  = new byte[] { 0xAA, 0xBB, 0xCC, 0xDD };
            var length  = BitConverter.GetBytes(content.Length);

            var sei = new byte[header.Length + length.Length + content.Length];

            Buffer.BlockCopy(header, 0, sei, 0, header.Length);
            Buffer.BlockCopy(length, 0, sei, header.Length, length.Length);
            Buffer.BlockCopy(content, 0, sei, header.Length + length.Length, content.Length);
            encoder.EncodeSEI(sei);
        }