Packet_TS.cs

简介:
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;
             }
         }
 
         ///////////////////字节中的比特位操作///////////////////
     }
}

本文转自静默虚空博客园博客,原文链接:http://www.cnblogs.com/jingmoxukong/archive/2011/07/29/2121289.html,如需转载请自行联系原作者
相关文章
fetch上传文件报错的问题(multipart: NextPart: EOF)
技术栈 后台: gin(golang) 前端: react+antd+dva 问题 前端这边使用fetch发送http请求的时候,后端解析formData报错: multipart: NextPart: EOF 分析问题 原因是上传文件太小了Content-Length数量太小了,尝试将headers里这字段的value变大,发现实际的请求依然是较小值。
|
3月前
|
JavaScript
Component name “header“ should always be multi-word
Component name “header“ should always be multi-word
|
5月前
|
前端开发 JavaScript
Error_ Multipart_ Boundary not foun
Error_ Multipart_ Boundary not foun
85 0
|
定位技术
QT QHttpMultiPart上传总结
QT QHttpMultiPart上传总结
439 0
913 error Component name “home“ should always be multi-word vuemulti-word-component-names
913 error Component name “home“ should always be multi-word vuemulti-word-component-names
90 0
|
JavaScript 前端开发 开发者
Component name “xxx“ should always be multi-word
Component name “xxx“ should always be multi-word
Component name “xxx“ should always be multi-word
ionic4 pipe.ts is part of the declarations of 2 modules:
ionic4 pipe.ts is part of the declarations of 2 modules:
147 0
ionic4 pipe.ts is part of the declarations of 2 modules:
|
Web App开发 安全 网络架构