public CcDataSection(int ccDataCount, byte[] bytes)
        {
            DataSection   = 0x72;
            ProcessEmData = true;
            ProcessEmData = true;
            ProcessEmData = true;

            if (bytes.Length / 2 > 16)
            {
                throw new Exception("Too many bytes for CCData!");
            }

            CcData = new CcData[ccDataCount];
            int bytesIndex = 0;

            for (int i = 0; i < ccDataCount; i++)
            {
                if (i == 0)
                {
                    CcData[i] = new CcData
                    {
                        Valid = true,
                        Type  = 0,
                        Data1 = 0x97,
                        Data2 = 0xa2,
                    };
                }
                else if (i == 1)
                {
                    CcData[i] = new CcData
                    {
                        Valid = true,
                        Type  = 1,
                        Data1 = 0x80,
                        Data2 = 0x80,
                    };
                }
                else if (i == 2)
                {
                    CcData[i] = new CcData
                    {
                        Valid = true,
                        Type  = 3,
                        Data1 = 0x0b,
                        Data2 = 0x33,
                    };
                }
                else
                {
                    CcData[i] = new CcData {
                        Type = 2
                    };
                    if (bytesIndex < bytes.Length)
                    {
                        CcData[i].Valid = true;

                        CcData[i].Data1 = bytes[bytesIndex];
                        bytesIndex++;

                        if (bytesIndex < bytes.Length)
                        {
                            CcData[i].Data2 = bytes[bytesIndex];
                        }

                        bytesIndex++;
                    }
                }
            }
        }
Пример #2
0
        public CcDataSection(int ccDataCount, byte[] bytes, int sequenceCount)
        {
            DataSection    = 0x72;
            ProcessEmData  = true;
            ProcessCcData  = true;
            AdditionalData = true;

            if (bytes.Length / 2 > 16)
            {
                throw new Exception("Too many bytes for CCData!");
            }

            CcData = new CcData[ccDataCount];
            int bytesIndex  = 0;
            var lastContent = true;

            for (int i = 0; i < ccDataCount; i++)
            {
                if (i == 0)
                {
                    CcData[i] = new CcData
                    {
                        Valid = true,
                        Type  = 0,
                        Data1 = 0x80,
                        Data2 = 0x80,
                    };
                }
                else if (i == 1)
                {
                    CcData[i] = new CcData
                    {
                        Valid = true,
                        Type  = 1,
                        Data1 = 0x80,
                        Data2 = 0x80,
                    };
                }
                else if (i == 2)
                {
                    var rollingSequence   = sequenceCount % 4; // rolling sequence 0-3
                    var ccContentLength   = bytes.Length / 2 + 2;
                    var sequenceAndLength = (byte)((rollingSequence << 6) + ccContentLength);
                    CcData[i] = new CcData
                    {
                        Valid = true,
                        Type  = 3,
                        Data1 = sequenceAndLength,
                        Data2 = 0x33, // What is this?
                    };
                }
                else
                {
                    CcData[i] = new CcData {
                        Type = 2
                    };
                    if (bytesIndex < bytes.Length)
                    {
                        CcData[i].Valid = true;

                        CcData[i].Data1 = bytes[bytesIndex];
                        bytesIndex++;

                        if (bytesIndex < bytes.Length)
                        {
                            CcData[i].Data2 = bytes[bytesIndex];
                        }

                        bytesIndex++;
                    }
                    else if (lastContent)
                    {
                        CcData[i].Valid = true;
                        lastContent     = false;
                    }
                }
            }
        }