Exemplo n.º 1
0
 public static void DecodePtsDts(byte[] tsPacket, ulong offset, out Pcr pts, out Pcr dts)
 {
     pts = new Pcr();
     dts = new Pcr();
     if ((tsPacket[offset + 7] & 0x80) == 0x80)
     {
         pts.isValid = true;
         if ((tsPacket[offset + 7] & 0x40) == 0x40)
         {
             dts.isValid = true;
         }
     }
     if (pts.isValid)
     {
         UInt64 ptsTicks = 0;
         UInt64 k;
         k = (ulong)((tsPacket[offset + 9] >> 1) & 0x7); k <<= 30; ptsTicks += k;        //9: 00101111
         k = tsPacket[offset + 10];                             k <<= 22; ptsTicks += k; //10:00110001
         k = (ulong)(tsPacket[offset + 11] >> 1);          k <<= 15; ptsTicks += k;      //11:10010001
         k = tsPacket[offset + 12];                             k <<= 7;  ptsTicks += k; //12:11000011
         k = (ulong)(tsPacket[offset + 13] >> 1);                   ptsTicks += k;       //13:11010111
         pts.ReferenceBase = ptsTicks;
     }
     if (dts.isValid)
     {
         UInt64 dtsTicks = 0;
         UInt64 k;
         k = (ulong)((tsPacket[offset + 14] >> 1) & 0x7); k <<= 30; dtsTicks += k;
         k = tsPacket[offset + 15];                              k <<= 22; dtsTicks += k;
         k = (ulong)(tsPacket[offset + 16] >> 1);            k <<= 15; dtsTicks += k;
         k = tsPacket[offset + 17];                              k <<= 7;  dtsTicks += k;
         k = (ulong)tsPacket[offset + 18] >> 1;                      dtsTicks += k;
         dts.ReferenceBase = dtsTicks;
     }
 }
Exemplo n.º 2
0
    public static void DecodePtsDts(byte[] tsPacket, ulong offset, out Pcr pts, out Pcr dts)
    {
      pts = new Pcr();
      dts = new Pcr();
      if ((tsPacket[offset+7] & 0x80) == 0x80)
      {
        pts.isValid = true;
        if ((tsPacket[offset+7] & 0x40) == 0x40) 
          dts.isValid = true;
      }
	    if (pts.isValid)
	    {	
	      UInt64 ptsTicks=0;
		    UInt64 k;
		    k=(ulong)((tsPacket[offset+9]>>1)&0x7); k <<=30; ptsTicks+=k;      //9: 00101111
		    k=  tsPacket[offset+10];				 k <<=22; ptsTicks+=k;      //10:00110001
		    k= (ulong)(tsPacket[offset+11]>>1);		 k <<=15; ptsTicks+=k;      //11:10010001
		    k=  tsPacket[offset+12];				 k <<=7;  ptsTicks+=k;      //12:11000011
		    k= (ulong)(tsPacket[offset+13]>>1);		          ptsTicks+=k;      //13:11010111
        pts.ReferenceBase = ptsTicks;
	    }
	    if (dts.isValid)
	    {
	      UInt64 dtsTicks=0;
		    UInt64 k;
		    k=(ulong)((tsPacket[offset+14]>>1)&0x7); k <<=30; dtsTicks+=k;
		    k=  tsPacket[offset+15];				  k <<=22; dtsTicks+=k;
		    k=(ulong)(tsPacket[offset+16]>>1);		  k <<=15; dtsTicks+=k;
		    k=  tsPacket[offset+17];				  k <<=7;  dtsTicks+=k;
		    k= (ulong)tsPacket[offset+18]>>1;		           dtsTicks+=k;
        dts.ReferenceBase = dtsTicks;
	    } 
    }
Exemplo n.º 3
0
        public static void PatchDts(ref byte[] tsPacket, ulong offset, TimeSpan newTimeSpan)
        {
            Pcr pcr = new Pcr(newTimeSpan);

            tsPacket[offset + 18] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
            tsPacket[offset + 17] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
            tsPacket[offset + 16] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
            tsPacket[offset + 15] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
            tsPacket[offset + 14] = (byte)((((pcr.ReferenceBase & 7) << 1) + 0x11));
        }
Exemplo n.º 4
0
        public static void PatchPts(ref byte[] tsPacket, ulong offset, TimeSpan newTimeSpan)
        {
            Pcr pcr = new Pcr(newTimeSpan);

            tsPacket[offset + 13] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
            tsPacket[offset + 12] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
            tsPacket[offset + 11] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
            tsPacket[offset + 10] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
            tsPacket[offset + 9]  = (byte)((((pcr.ReferenceBase & 7) << 1) + 0x31));
        }
Exemplo n.º 5
0
 public PidInfo()
 {
     shouldCheck            = false;
     lastPcr                = new Pcr();
     lastPts                = new Pcr();
     continuityCounter      = 0xFF;
     pcrErrorTexts          = new List <string>();
     ptsErrorTexts          = new List <string>();
     payloadStartErrorTexts = new List <string>();
 }
Exemplo n.º 6
0
 public PidInfo()
 {
   shouldCheck = false;
   lastPcr = new Pcr();
   lastPts = new Pcr();
   continuityCounter = 0xFF;
   pcrErrorTexts = new List<string>();
   ptsErrorTexts = new List<string>();
   payloadStartErrorTexts = new List<string>();
 }
Exemplo n.º 7
0
        public static void PatchPcr(ref byte[] tsPacket, TimeSpan newTimeSpan)
        {
            Pcr pcr = new Pcr(newTimeSpan);

            tsPacket[6]  = (byte)(((pcr.ReferenceBase >> 25) & 0xff));
            tsPacket[7]  = (byte)(((pcr.ReferenceBase >> 17) & 0xff));
            tsPacket[8]  = (byte)(((pcr.ReferenceBase >> 9) & 0xff));
            tsPacket[9]  = (byte)(((pcr.ReferenceBase >> 1) & 0xff));
            tsPacket[10] = (byte)(((pcr.ReferenceBase & 0x1) << 7) + 0x7e + ((pcr.ReferenceExtension >> 8) & 0x1));
            tsPacket[11] = (byte)(pcr.ReferenceExtension & 0xff);
        }
Exemplo n.º 8
0
 private void CheckPcr(TsHeader header, byte[] tsPacket, ref PidInfo pi)
 {
   if (!pi.shouldCheck) return;
   if (!PacketContainsPcr(header, tsPacket)) return;
   Pcr pcr = new Pcr(tsPacket);
   if (pi.lastPcr.isValid)
   {
     TimeSpan diff = pcr.ToDateTime() - pi.lastPcr.ToDateTime();
     if (diff.TotalSeconds > diffAllowed)
     {
       pi.pcrErrorTexts.Add("last pcr: " + pi.lastPcr.ToDateTime().ToString("HH:MM:ss") + " current pcr: " + pcr.ToDateTime().ToString("HH:MM:ss"));
       totalPcrErrors++;
     }
   }
   pi.lastPcr = pcr;
 }
Exemplo n.º 9
0
        private void CheckPcr(TsHeader header, byte[] tsPacket, ref PidInfo pi)
        {
            if (!pi.shouldCheck)
            {
                return;
            }
            if (!PacketContainsPcr(header, tsPacket))
            {
                return;
            }
            Pcr pcr = new Pcr(tsPacket);

            if (pi.lastPcr.isValid)
            {
                TimeSpan diff = pcr.ToDateTime() - pi.lastPcr.ToDateTime();
                if (diff.TotalSeconds > diffAllowed)
                {
                    pi.pcrErrorTexts.Add("last pcr: " + pi.lastPcr.ToDateTime().ToString("HH:MM:ss") + " current pcr: " + pcr.ToDateTime().ToString("HH:MM:ss"));
                    totalPcrErrors++;
                }
            }
            pi.lastPcr = pcr;
        }
Exemplo n.º 10
0
 public static void PatchPcr(ref byte[] tsPacket, TimeSpan newTimeSpan)
 {
   Pcr pcr = new Pcr(newTimeSpan);
   tsPacket[6] = (byte)(((pcr.ReferenceBase >> 25) & 0xff));
   tsPacket[7] = (byte)(((pcr.ReferenceBase >> 17) & 0xff));
   tsPacket[8] = (byte)(((pcr.ReferenceBase >> 9) & 0xff));
   tsPacket[9] = (byte)(((pcr.ReferenceBase >> 1) & 0xff));
   tsPacket[10] = (byte)(((pcr.ReferenceBase & 0x1) << 7) + 0x7e + ((pcr.ReferenceExtension >> 8) & 0x1));
   tsPacket[11] = (byte)(pcr.ReferenceExtension & 0xff);
 }
Exemplo n.º 11
0
 public static void PatchDts(ref byte[] tsPacket, ulong offset, TimeSpan newTimeSpan)
 {
   Pcr pcr = new Pcr(newTimeSpan);
   tsPacket[offset + 18] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
   tsPacket[offset + 17] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
   tsPacket[offset + 16] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
   tsPacket[offset + 15] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
   tsPacket[offset + 14] = (byte)((((pcr.ReferenceBase & 7) << 1) + 0x11));
 }
Exemplo n.º 12
0
 public static void PatchPts(ref byte[] tsPacket, ulong offset, TimeSpan newTimeSpan)
 {
   Pcr pcr = new Pcr(newTimeSpan);
   tsPacket[offset + 13] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
   tsPacket[offset + 12] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
   tsPacket[offset + 11] = (byte)((((pcr.ReferenceBase & 0x7f) << 1) + 1)); pcr.ReferenceBase >>= 7;
   tsPacket[offset + 10] = (byte)((pcr.ReferenceBase & 0xff)); pcr.ReferenceBase >>= 8;
   tsPacket[offset + 9] = (byte)((((pcr.ReferenceBase & 7) << 1) + 0x31)); 
 }