博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Packet_TS.cs
阅读量:5966 次
发布时间:2019-06-19

本文共 5715 字,大约阅读时间需要 19 分钟。

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
(); 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
_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
List_Data_Bytes { get { return this._list_data_bytes; } set { this._list_data_bytes = value; } } ///字节中的比特位操作/// }}

转载地址:http://zbmax.baihongyu.com/

你可能感兴趣的文章
MySQL 5.7原生JSON格式支持
查看>>
[吴恩达机器学习笔记]14降维3-4PCA算法原理
查看>>
Solr分词
查看>>
二十四种设计模式:策略模式(Strategy Pattern)
查看>>
统计某个字符串中指定字符串出现的次数
查看>>
asp.net三层结构中,SQL助手类DbHelperSQL
查看>>
scala map和flatMap
查看>>
.Net Core下使用 RSA
查看>>
python 数据库中文乱码 Excel
查看>>
利用console控制台调试php代码
查看>>
递归算法,如何把list中父子类对象递归成树
查看>>
jsf初学解决GlassFish Server 无法启动
查看>>
【Gson】2.2.4 StackOverflowError 异常
查看>>
hdu 1050 (preinitilization or postcleansing, std::fill) ...
查看>>
Form各键盘触发子所对应的“按键”
查看>>
【java IO】使用Java输入输出流 读取txt文件内数据,进行拼接后写入到另一个文件中...
查看>>
Linux系统下安装rz/sz命令及使用说明
查看>>
点击按钮抓不到页面的参数
查看>>
CentOS 6.5 下安装 Redis 2.8.7
查看>>
第一次模拟面试
查看>>