Packet_TS.cs

简介: using System; using System.Collections.Generic; using System.Text; using Bit; namespace Packet { class Packet_TS { BitOper...
using System;
using System.Collections.Generic;
using System.Text;
using Bit;

namespace Packet
{
    class Packet_TS
    {
        BitOperation bitOperarion = new BitOperation();

        public Packet_TS(Byte[] bytes)
        {
            _TSBytes = bytes;

            _list_data_bytes = new List<byte>();
            for (int i = 5; i < bytes.Length ; i++)  //把data字节数组填充为0
            {
                _list_data_bytes.Add(bytes[i]);
            }

        }

        private Byte[] _TSBytes;
        ///////////////////TS Header/////////////////////
        private Byte _sync_byte;
        private Byte _transport_error_indicator;
        private Byte _payload_unit_start_indicator;
        private Byte _transport_priority;
        private UInt16 _PID;
        private Byte _transport_scrambling_control;
        private Byte _adaption_field_control;
        private Byte _continuity_counter;

        ///////////////////Data//////////////////////////
        private Byte _position_indicator;
        private List<Byte> _list_data_bytes;

        ///////////////////get set方法///////////////////
        public Byte[] TSBytes
        {
            get
            {
                return this._TSBytes;
            }
            set
            {
                this._TSBytes = value;
            }
        }
        public Byte Sync_Byte
        {
            get
            {
                this._sync_byte = Convert.ToByte(_TSBytes[0]);
                return this._sync_byte;
            }
            set
            {
                this._sync_byte = value;
                this._TSBytes[0] = value;
            }
        }
        public Byte Transport_Error_Indicator
        {
            get
            {
                this._transport_error_indicator = Convert.ToByte(_TSBytes[1] >> 7);
                return this._transport_error_indicator;
            }
            set
            {
                this._transport_error_indicator = value;

                this._TSBytes[1] = bitOperarion.setBit(_TSBytes[1], 0, value);
            }
        }
        public Byte Payload_Unit_Start_Indicator
        {
            get
            {
                this._payload_unit_start_indicator = Convert.ToByte((_TSBytes[1] >> 6) & 0x01);
                return this._payload_unit_start_indicator;
            }
            set
            {
                this._payload_unit_start_indicator = value;

                this._TSBytes[1] = bitOperarion.setBit(_TSBytes[1], 1, value);
            }
        }
        public Byte Transport_Priority
        {
            get
            {
                this._transport_priority = Convert.ToByte((_TSBytes[1] >> 5) & 0x01);
                return this._transport_priority;
            }
            set
            {
                this._transport_priority = value;

                this._TSBytes[1] = bitOperarion.setBit(_TSBytes[1], 2, value);
            }
        }
        public UInt16 Pid
        {
            get
            {
                UInt16 high = Convert.ToUInt16((_TSBytes[1] & 0x1F) << 8);
                UInt16 low = Convert.ToUInt16(_TSBytes[2]);
                this._PID = Convert.ToUInt16(high | low);
                return this._PID;
            }
            set
            {
                this._PID = value;
                Byte high = Convert.ToByte(value >> 8);
                Byte low = Convert.ToByte(value & 0x00ff);
                for (int i = 3; i < 8; i++)
                {
                    int temp = bitOperarion.getBit(high, i);
                    this._TSBytes[1] = bitOperarion.setBit(this._TSBytes[1], i, temp);
                }
                this._TSBytes[2] = low;
            }
        }
        public Byte Transport_Scrambling_Control
        {
            get
            {
                this._transport_scrambling_control = Convert.ToByte((_TSBytes[3] >> 6) & 0x03);
                return this._transport_scrambling_control;
            }
            set
            {
                this._transport_scrambling_control = value;

                this._TSBytes[3] = bitOperarion.setBit( _TSBytes[3], 0, (value >> 1) & 0x01 );
                this._TSBytes[3] = bitOperarion.setBit( _TSBytes[3], 1, (value & 0x01) );
            }
        }
        public Byte Adaption_Field_Control
        {
            get
            {
                this._continuity_counter = Convert.ToByte((_TSBytes[3] >> 4) & 0x03);
                return this._continuity_counter;
            }
            set
            {
                this._continuity_counter = value;

                this._TSBytes[3] = bitOperarion.setBit( _TSBytes[3], 2, (value >> 1) & 0x01 );
                this._TSBytes[3] = bitOperarion.setBit( _TSBytes[3], 3, (value & 0x01) );
            }
        }
        public Byte Continuity_Counter
        {
            get
            {
                this._adaption_field_control = Convert.ToByte(_TSBytes[3] & 0x0f);
                return this._adaption_field_control;
            }
            set
            {
                this._adaption_field_control = value;

                for (int i = 4; i < 8; i++)
                {
                    int temp = bitOperarion.getBit(value, i);
                    this._TSBytes[3] = bitOperarion.setBit(this._TSBytes[3], i, temp);
                }
            }
        }
        public Byte Position_Indicator
        {
            get
            {
                this._position_indicator = Convert.ToByte(_TSBytes[4]);
                return this._position_indicator;
            }
            set
            {
                this._position_indicator = value;
                this._TSBytes[4] = value;
            }
        }
        public List<Byte> List_Data_Bytes
        {
            get
            {
                return this._list_data_bytes;
            }
            set
            {
                this._list_data_bytes = value;
            }
        }

        ///////////////////字节中的比特位操作///////////////////
    }
}
目录
相关文章
fetch上传文件报错的问题(multipart: NextPart: EOF)
技术栈 后台: gin(golang) 前端: react+antd+dva 问题 前端这边使用fetch发送http请求的时候,后端解析formData报错: multipart: NextPart: EOF 分析问题 原因是上传文件太小了Content-Length数量太小了,尝试将headers里这字段的value变大,发现实际的请求依然是较小值。
|
6月前
|
关系型数据库 MySQL Linux
FATAL ERROR: Could not find my_print_defaults
FATAL ERROR: Could not find my_print_defaults
186 0
|
7月前
|
资源调度 JavaScript 前端开发
介绍一下ts
介绍一下ts
132 1
|
JavaScript 前端开发 开发者
ts详解以及相关例子(一篇带你详细了解ts)
ts详解以及相关例子(一篇带你详细了解ts)
176 1
|
7月前
ts文件解密
ts文件解密
266 0
|
JavaScript 前端开发
ts - ts基础
https://www.tslang.cn/ TypeScript是Microsoft公司注册商标。 TypeScript具有类型系统,且是JavaScript的超集。 它可以编译成普通的JavaScript代码。 TypeScript支持任意浏览器,任意环境,任意系统并且是开源的。
|
JavaScript 开发者
什么是TS?
什么是TS?
163 0
ionic4 pipe.ts is part of the declarations of 2 modules:
ionic4 pipe.ts is part of the declarations of 2 modules:
162 0
ionic4 pipe.ts is part of the declarations of 2 modules:
|
人工智能 自然语言处理 JavaScript
为什么我们需要 TS ?
文中不少观点的想法系个人见解,有一定的个人局限性,欢迎交流
836 0
为什么我们需要 TS ?