Example #1
0
    public void OnNewSection(Section section)
    {
      int network_descriptor_length = ((section.Data[8] & 0xF) << 8) + section.Data[9];

      int l1 = network_descriptor_length;
      int pointer = 10;
      string network_name = "";

      while (l1 > 0)
      {
        int descriptor_tag = section.Data[pointer];
        int x = section.Data[pointer + 1] + 2;
        if (descriptor_tag == 0x40)
          network_name = StringUtils.getString468A(section.Data, pointer + 2, x - 2);
        l1 -= x;
        pointer += x;
      }

      pointer = 10 + network_descriptor_length;

      if (pointer > section.section_length) return;

      int transport_stream_loop_length = ((section.Data[pointer] & 0xF) << 8) + section.Data[pointer + 1];
      l1 = transport_stream_loop_length;
      pointer += 2;

      while (l1 > 0)
      {
        if (pointer + 2 > section.section_length) return;

        int transport_stream_id = (section.Data[pointer] << 8) + section.Data[pointer + 1];
        int original_network_id = (section.Data[pointer + 2] << 8) + section.Data[pointer + 3];

        ulong key = (ulong)(original_network_id << 16);
        key += (ulong)transport_stream_id;

        int transport_descriptor_length = ((section.Data[pointer + 4] & 0xF) << 8) + section.Data[pointer + 5];
        netInfo = new NetworkInfo(network_name, transport_stream_id, original_network_id);
        pointer += 6;
        l1 -= 6;
        int l2 = transport_descriptor_length;

        while (l2 > 0)
        {
          if (pointer + 2 > section.section_length) return;

          int descriptor_tag = section.Data[pointer];
          int descriptor_length = section.Data[pointer + 1] + 2;

          switch (descriptor_tag)
          {
            case 0x43: // sat
              DVB_GetSatDelivSys(section.Data, pointer, descriptor_length);
              break;
            case 0x44: // cable
              DVB_GetCableDelivSys(section.Data, pointer, descriptor_length);
              break;
            case 0x5A: // terrestrial
              DVB_GetTerrestrialDelivSys(section.Data, pointer, descriptor_length);
              break;
            case 0x83: // logical channel number
              DVB_GetLogicalChannelNumber(original_network_id, transport_stream_id, section.Data, pointer);
              break;
          }
          pointer += descriptor_length;
          l2 -= descriptor_length;
          l1 -= descriptor_length;
        }
        if (netInfo.netType!=NetworkType.Unknown)
          baseNode.Text = "NIT " + netInfo.netType.ToString();
        if (!seenNITs.Contains(netInfo.frequency))
        {
          netInfo.AddToNode(baseNode,(section.table_id==0x41));
          seenNITs.Add(netInfo.frequency);
        }
      }
    }
        public void OnNewSection(Section section)
        {
            int network_descriptor_length = ((section.Data[8] & 0xF) << 8) + section.Data[9];

            int    l1           = network_descriptor_length;
            int    pointer      = 10;
            string network_name = "";

            while (l1 > 0)
            {
                int descriptor_tag = section.Data[pointer];
                int x = section.Data[pointer + 1] + 2;
                if (descriptor_tag == 0x40)
                {
                    network_name = StringUtils.getString468A(section.Data, pointer + 2, x - 2);
                }
                l1      -= x;
                pointer += x;
            }

            pointer = 10 + network_descriptor_length;

            if (pointer > section.section_length)
            {
                return;
            }

            int transport_stream_loop_length = ((section.Data[pointer] & 0xF) << 8) + section.Data[pointer + 1];

            l1       = transport_stream_loop_length;
            pointer += 2;

            while (l1 > 0)
            {
                if (pointer + 2 > section.section_length)
                {
                    return;
                }

                int transport_stream_id = (section.Data[pointer] << 8) + section.Data[pointer + 1];
                int original_network_id = (section.Data[pointer + 2] << 8) + section.Data[pointer + 3];

                ulong key = (ulong)(original_network_id << 16);
                key += (ulong)transport_stream_id;

                int transport_descriptor_length = ((section.Data[pointer + 4] & 0xF) << 8) + section.Data[pointer + 5];
                netInfo  = new NetworkInfo(network_name, transport_stream_id, original_network_id);
                pointer += 6;
                l1      -= 6;
                int l2 = transport_descriptor_length;

                while (l2 > 0)
                {
                    if (pointer + 2 > section.section_length)
                    {
                        return;
                    }

                    int descriptor_tag    = section.Data[pointer];
                    int descriptor_length = section.Data[pointer + 1] + 2;

                    switch (descriptor_tag)
                    {
                    case 0x43: // sat
                        DVB_GetSatDelivSys(section.Data, pointer, descriptor_length);
                        break;

                    case 0x44: // cable
                        DVB_GetCableDelivSys(section.Data, pointer, descriptor_length);
                        break;

                    case 0x5A: // terrestrial
                        DVB_GetTerrestrialDelivSys(section.Data, pointer, descriptor_length);
                        break;

                    case 0x83: // logical channel number
                        DVB_GetLogicalChannelNumber(original_network_id, transport_stream_id, section.Data, pointer);
                        break;
                    }
                    pointer += descriptor_length;
                    l2      -= descriptor_length;
                    l1      -= descriptor_length;
                }
                if (netInfo.netType != NetworkType.Unknown)
                {
                    baseNode.Text = "NIT " + netInfo.netType.ToString();
                }
                if (!seenNITs.Contains(netInfo.frequency))
                {
                    netInfo.AddToNode(baseNode, (section.table_id == 0x41));
                    seenNITs.Add(netInfo.frequency);
                }
            }
        }