Beispiel #1
0
 private static void Add(IList <ECMEMM> list, ECMEMM newEcm)
 {
     for (int i = 0; i < list.Count; ++i)
     {
         if (list[i].ProviderId == newEcm.ProviderId &&
             list[i].Pid == newEcm.Pid &&
             list[i].CaId == newEcm.CaId)
         {
             return;
         }
     }
     list.Add(newEcm);
 }
Beispiel #2
0
    /// <summary>
    /// Returns the ECM's found in the PMT.
    /// </summary>
    /// <returns></returns>
    private static void Parse(byte[] descriptor, IList<ECMEMM> newEcms)
    {
      ECMEMM ecm = new ECMEMM();
      int off = 0;
      while (off < descriptor.Length)
      {
        byte tag = descriptor[off];
        byte len = descriptor[off + 1];
        if (tag == 0x9)
        {
          int offset;
          if (ecm.Pid != 0)
            Add(newEcms, ecm);
          ecm = new ECMEMM();
          int caId = ecm.CaId = ((descriptor[off + 2]) << 8) + descriptor[off + 3];
          ecm.Pid = ((descriptor[off + 4] & 0x1f) << 8) + descriptor[off + 5];
          if (ecm.CaId == 0x100 && len >= 17)
          {
            if (descriptor[off + 8] == 0xff)
            {
              //0  1 2 3  4  5 6  7  8 9 10
              //9 11 1 0 E6 43 0 6A FF 0  0 0 0 0 0 2 14 21 8C 
              //
              //
              //0  1  2 3  4  5  6  7  8 9 10
              //9 11  1 0 E6  1C 41 1 FF FF FF FF FF FF FF FF FF 21 8C 
              int count = (len - 2) / 15;
              for (int i = 0; i < count; ++i)
              {
                offset = off + i * 15;
                if (offset >= descriptor.Length)
                  break;
                ecm = new ECMEMM();
                ecm.CaId = caId;
                ecm.Pid = ((descriptor[offset + 4] & 0x1f) << 8) + descriptor[offset + 5];
                ecm.ProviderId = ((descriptor[offset + 6]) << 8) + descriptor[offset + 7];
                Add(newEcms, ecm);
                ecm = new ECMEMM();
              }
            }
          }

          if (ecm.CaId == 0x100 && len >= 8)
          {
            if (descriptor[off + 7] == 0xe0 && descriptor[8] != 0xff)
            {
              //0  1 2 3  4  5 6  7 8  9  10
              //9 11 1 0 E0 C1 3 E0 92 41  1 E0 93 40 1 E0 C4 0 64 
              //9  D 1 0 E0 B6 2 E0 B7  0 6A E0 B9 0  6C 
              if (descriptor[off + 6] > 0 || descriptor[off + 6] <= 9)
              {
                ecm.ProviderId = ((descriptor[off + 9]) << 8) + descriptor[off + 10];
              }
            }
          }
          offset = off + 6;
          while (offset + 2 < descriptor.Length)
          {
            byte tagInd = descriptor[offset];
            byte tagLen = descriptor[offset + 1];
            if (tagLen + offset < descriptor.Length)
            {
              if (tagInd == 0x14)
              {
                ecm.ProviderId = (descriptor[offset + 2] << 16) + (descriptor[offset + 3] << 8) +
                                 descriptor[offset + 4];
                // Some providers sends wrong information in provider id (Boxer),
                // so reset lower 4 bits for Via Access
                if (ecm.CaId == 0x500)
                {
                  ecm.ProviderId = ecm.ProviderId & 0xFFFFF0;
                }
              }
            }
            offset += (tagLen + 2);
          }
        }
        off += (len + 2);
      }
      if (ecm.Pid > 0)
        Add(newEcms, ecm);
    }
Beispiel #3
0
 private static void Add(IList<ECMEMM> list, ECMEMM newEcm)
 {
   for (int i = 0; i < list.Count; ++i)
   {
     if (list[i].ProviderId == newEcm.ProviderId &&
         list[i].Pid == newEcm.Pid &&
         list[i].CaId == newEcm.CaId)
       return;
   }
   list.Add(newEcm);
 }
Beispiel #4
0
        /// <summary>
        /// Returns the ECM's found in the PMT.
        /// </summary>
        /// <returns></returns>
        private static void Parse(byte[] descriptor, IList <ECMEMM> newEcms)
        {
            ECMEMM ecm = new ECMEMM();
            int    off = 0;

            while (off < descriptor.Length)
            {
                byte tag = descriptor[off];
                byte len = descriptor[off + 1];
                if (tag == 0x9)
                {
                    int offset;
                    if (ecm.Pid != 0)
                    {
                        Add(newEcms, ecm);
                    }
                    ecm = new ECMEMM();
                    int caId = ecm.CaId = ((descriptor[off + 2]) << 8) + descriptor[off + 3];
                    ecm.Pid = ((descriptor[off + 4] & 0x1f) << 8) + descriptor[off + 5];
                    if (ecm.CaId == 0x100 && len >= 17)
                    {
                        if (descriptor[off + 8] == 0xff)
                        {
                            //0  1 2 3  4  5 6  7  8 9 10
                            //9 11 1 0 E6 43 0 6A FF 0  0 0 0 0 0 2 14 21 8C
                            //
                            //
                            //0  1  2 3  4  5  6  7  8 9 10
                            //9 11  1 0 E6  1C 41 1 FF FF FF FF FF FF FF FF FF 21 8C
                            int count = (len - 2) / 15;
                            for (int i = 0; i < count; ++i)
                            {
                                offset = off + i * 15;
                                if (offset >= descriptor.Length)
                                {
                                    break;
                                }
                                ecm            = new ECMEMM();
                                ecm.CaId       = caId;
                                ecm.Pid        = ((descriptor[offset + 4] & 0x1f) << 8) + descriptor[offset + 5];
                                ecm.ProviderId = ((descriptor[offset + 6]) << 8) + descriptor[offset + 7];
                                Add(newEcms, ecm);
                                ecm = new ECMEMM();
                            }
                        }
                    }

                    if (ecm.CaId == 0x100 && len >= 8)
                    {
                        if (descriptor[off + 7] == 0xe0 && descriptor[8] != 0xff)
                        {
                            //0  1 2 3  4  5 6  7 8  9  10
                            //9 11 1 0 E0 C1 3 E0 92 41  1 E0 93 40 1 E0 C4 0 64
                            //9  D 1 0 E0 B6 2 E0 B7  0 6A E0 B9 0  6C
                            if (descriptor[off + 6] > 0 || descriptor[off + 6] <= 9)
                            {
                                ecm.ProviderId = ((descriptor[off + 9]) << 8) + descriptor[off + 10];
                            }
                        }
                    }
                    offset = off + 6;
                    while (offset + 2 < descriptor.Length)
                    {
                        byte tagInd = descriptor[offset];
                        byte tagLen = descriptor[offset + 1];
                        if (tagLen + offset < descriptor.Length)
                        {
                            if (tagInd == 0x14)
                            {
                                ecm.ProviderId = (descriptor[offset + 2] << 16) + (descriptor[offset + 3] << 8) +
                                                 descriptor[offset + 4];
                                // Some providers sends wrong information in provider id (Boxer),
                                // so reset lower 4 bits for Via Access
                                if (ecm.CaId == 0x500)
                                {
                                    ecm.ProviderId = ecm.ProviderId & 0xFFFFF0;
                                }
                            }
                        }
                        offset += (tagLen + 2);
                    }
                }
                off += (len + 2);
            }
            if (ecm.Pid > 0)
            {
                Add(newEcms, ecm);
            }
        }