public override void OnNewSection(Section section) { if (section.table_id != TableId) return; int pmtCount = 0; int loop = (section.section_length - 9) / 4; for (int i=0;i<loop;i++) { int offset = (8 +(i * 4)); int program_nr=((section.Data[offset] )<<8) + section.Data[offset+1]; int pmt_pid = ((section.Data[offset+2] & 0x1F)<<8) + section.Data[offset+3]; if (pmt_pid <= 0x10 || pmt_pid > 0x1FFF) continue; if (addToNode) { TreeNode pmtNode = baseNode.Nodes.Add("# " + program_nr.ToString() + " pmt pid: 0x" + pmt_pid.ToString("x")); pmtNode.ForeColor = System.Drawing.Color.Red; pmtNode = pmtNode.Nodes.Add("PMT"); //if (pmtParsers.Count==0) pmtParsers.Add(new PmtParser(pmt_pid,program_nr,pmtNode)); } pmtCount++; } patReady = true; if (addToNode) baseNode.Text = "PAT (" + pmtParsers.Count.ToString() + " programs)"; }
public override void OnNewSection(Section section) { if (section.table_id < 0x4e || section.table_id > 0x6f) return; int service_id = section.table_id_extension; int transport_id=(section.Data[8]<<8)+section.Data[9]; int network_id=(section.Data[10]<<8)+section.Data[11]; ulong nid = (ulong)network_id; ulong tid = (ulong)transport_id; ulong sid = (ulong)service_id; ulong key = (ulong)(nid << 32); key += (ulong)(tid << 16); key+=sid; if (channels.ContainsKey(key)) return; PortalChannel pchannel = new PortalChannel(transport_id, network_id, service_id); channels.Add(key, pchannel); TreeNode pNode=baseNode.Nodes.Add("#"+service_id.ToString()+" nid: " + transport_id.ToString() + " nid: " + network_id.ToString() + " sid: " + service_id.ToString()); int start = 14; while (start + 11 <= section.section_length+1) { int descriptors_len = ((section.Data[start + 10] & 0xF) << 8) + section.Data[start + 11]; start += 12; int off = 0; while (off < descriptors_len) { if (start + off + 1 > section.section_length) return; int descriptor_tag = section.Data[start + off]; int descriptor_len = section.Data[start + off + 1]; if (start + off + descriptor_len + 2 > section.section_length) return; if (descriptor_len < 1) return; if (descriptor_tag == 0x4a) { LinkedChannel lchannel = new LinkedChannel(); lchannel.transport_id = (section.Data[start + off + 2] << 8) + section.Data[start + off + 3]; lchannel.network_id = (section.Data[start + off + 4] << 8) + section.Data[start + off + 5]; lchannel.service_id = (section.Data[start + off + 6] << 8) + section.Data[start + off + 7]; string name = ""; for (int i = 0; i < descriptor_len - 7; i++) name += (char)section.Data[start + off +9+i]; lchannel.displayName = name; pchannel.linkedChannels.Add(lchannel); pNode.Nodes.Add("["+name+"] tid: " + lchannel.transport_id.ToString() + " nid: " + lchannel.network_id.ToString() + " sid: " + lchannel.service_id.ToString()); } off += descriptor_len+2; } // while (off < descriptors_len) start += descriptors_len; } // while (start + 11 <= section.section_length) if (pNode.Nodes.Count == 0) pNode.Remove(); }
public override void OnNewSection(Section sections) { int start = 14; byte[] buf = sections.Data; int service_id = (buf[3] << 8) + buf[4]; if (service_id != 800) return; while (start + 11 <= sections.section_length + 1) { int descriptors_len = ((buf[start + 10] & 0xf) << 8) + buf[start + 11]; start += 12; int off = 0; while (off < descriptors_len) { int descriptor_tag = buf[start + off]; int descriptor_len = buf[start + off + 1]; if (descriptor_len > 0) { switch (descriptor_tag) { case 0x4d: // short event byte[] data1 = new byte[buf.Length-(start+off-1)]; Array.Copy(buf, start + off, data1, 0, buf.Length - (start + off)); DecodeShortEventDescriptor(data1); //frm.WriteLog("short event"); break; case 0x4e: // Extended event //frm.WriteLog("extended event"); break; case 0x54: // genre //frm.WriteLog("genre"); break; case 0x55: // parental rating byte[] data=new byte[buf.Length]; Array.Copy(buf, start + off, data, 0, buf.Length - (start + off)); DecodeParentalRating(data); break; case 0x5f: // private data //frm.WriteLog("private data"); break; case 0x89: // MPAA rating frm.WriteLog("MPAA rating"); break; default: //frm.WriteLog("Unknown descriptor ("+descriptor_tag.ToString()+")"); break; } } off += descriptor_len + 2; } start += descriptors_len; } }
public void OnNewSection(Section section) { int transport_id = section.table_id_extension; int network_id=(section.Data[8]<<8)+section.Data[9]; ulong nid = (ulong)network_id; ulong tid = (ulong)transport_id; //ulong key = (ulong)(nid << 32); //key += (ulong)(tid << 16); int start = 11; while (start < section.section_length) { int service_id = (section.Data[start] << 8) + section.Data[start + 1]; ulong key = (ulong)service_id; int descriptor_loop_len = ((section.Data[start + 3] << 8) | (section.Data[start + 4])) & 0xfff; if (!servicesReceived.Contains(key)) { servicesReceived.Add(key); start += 5; int off = 0; while (off < descriptor_loop_len) { int descriptor_tag = section.Data[start + off]; int descriptor_len = section.Data[start + off + 1]; if (descriptor_len > 0) { switch (descriptor_tag) { case 0x48: // service byte[] desc = new byte[descriptor_len]; Array.Copy(section.Data, start + off + 3, desc, 0, descriptor_len - 1); string provider; string service; DecodeServiceDescriptor(desc, out provider, out service); TreeNode node = baseNode.Nodes.Add("#" + service_id.ToString() + " " + service + " (" + provider + ")"); node.Nodes.Add("transport_id: " + transport_id.ToString() + " nid: " + network_id.ToString() + " sid: " + service_id.ToString()); if (section.table_id == 0x46) node.Nodes.Add("Other mux"); else node.Nodes.Add("Same mux"); break; } } off += descriptor_len + 2; } } start += descriptor_loop_len; } }
public override void OnNewSection(Section section) { if (section.table_id != 1) return; if (IsReady) return; int pos = 8; while (pos+2 < section.section_length) { int descriptor_tag = section.Data[pos]; int decriptor_len = section.Data[pos + 1]; if (descriptor_tag == 0x9) { int ca_system_id = (section.Data[pos + 2] << 8) + section.Data[pos+3]; int ca_pid = ((section.Data[pos + 4] & 0x1f) << 8) + section.Data[pos + 5]; baseNode.Nodes.Add("Pid: 0x" + ca_pid.ToString("x") + " "+ StringUtils.CA_System_ID2Str(ca_system_id)); } pos += (decriptor_len + 2); } baseNode.Text="CAT ("+baseNode.Nodes.Count.ToString()+" pids)"; IsReady=true; }
public override void OnNewSection(Section sections) { if (IsReady) return; if (sections.table_id_extension != service_id) return; if (sections.table_id_extension == 6033) { int xc = 564; } byte[] section = sections.Data; int section_length = sections.section_length; int pcrPid = ((section[8] & 0x1F) << 8) + section[9]; if (addToNode) { baseNode.Parent.ForeColor = System.Drawing.Color.Black; baseNode.Nodes.Add("PCR pid: 0x" + pcrPid.ToString("x")); } int program_info_length = ((section[10] & 0xF) << 8) + section[11]; // Skip the descriptors (if any). int ndx = 12; ndx += program_info_length; // Now we have the actual program data. while (ndx < section_length - 3) { int stream_type = section[ndx++]; int pid = ((section[ndx++] & 0x1f) << 8) + section[ndx++]; int es_descriptors_length = ((section[ndx++] & 0x0f) << 8) + section[ndx++]; if (addToNode) { TreeNode node = baseNode.Nodes.Add("pid: 0x" + pid.ToString("x") + " type: 0x" + stream_type.ToString("x")+" " + StringUtils.StreamTypeToStr(stream_type)); if (es_descriptors_length > 0) { int off = 0; while (off < es_descriptors_length) { int descriptor_tag = section[ndx + off]; int descriptor_len = section[ndx + off + 1]; switch (descriptor_tag) { case 0x5: node.Nodes.Add("0x" + descriptor_tag.ToString("x") + " - Registration descriptor: " + StringUtils.getString468A(section, ndx + off + 2, descriptor_len)); break; case 0x9: // CA Descriptor int ca_system_id = (section[ndx+off+ 2] << 8) + section[ndx+off+3]; int ca_pid = ((section[ndx+off+4] & 0x1f) << 8) + section[ndx+off+5]; node.Nodes.Add("CA: Pid: 0x" + ca_pid.ToString("x") + " "+ StringUtils.CA_System_ID2Str(ca_system_id)); break; case 0x0A: // ISO_639_language node.Nodes.Add("ISO_639_language: " + StringUtils.getString468A(section, ndx + off + 2, 3)); break; case 0x52: node.Nodes.Add("0x" + descriptor_tag.ToString("x") + " - stream identifier descriptor 0x"+section[ndx+off+2].ToString("x")); break; case 0x56: // Teletext node.Text = "pid: 0x" + pid.ToString("x") + " [Teletext] " + StringUtils.StreamTypeToStr(stream_type); break; case 0x59: // Subtitles node.Text = "pid: 0x" + pid.ToString("x") + " [Subtitles] " + StringUtils.StreamTypeToStr(stream_type); break; case 0x6A: // AC3 node.Text = "pid: 0x" + pid.ToString("x") + " [AC3-Audio] " + StringUtils.StreamTypeToStr(stream_type); break; case 0x5F: // private data node.Text = "pid: 0x" + pid.ToString("x") + " [Private Data] " + StringUtils.StreamTypeToStr(stream_type); break; case 0xA1: node.Nodes.Add("0x" + descriptor_tag.ToString("x") + " - ATSC: service location"); break; case 0xA2: node.Nodes.Add("0x" + descriptor_tag.ToString("x")+" - ATSC: time shifted service"); break; case 0xA3: node.Nodes.Add("0x" + descriptor_tag.ToString("x") + " - ATSC: component name"); break; default: node.Nodes.Add("0x" + descriptor_tag.ToString("x")); break; } off += descriptor_len + 2; } } } ndx += es_descriptors_length; if (!streamPids.Contains((ushort)pid)) streamPids.Add((ushort)pid); } int streamcount=baseNode.Nodes.Count-1; if (addToNode) baseNode.Text = "PMT (" + streamcount.ToString() + " streams)"; IsReady=true; }
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 SectionDecoder(ushort pid, int table_id) { m_pid = pid; m_tableId = table_id; m_section = new Section(); }
public virtual void OnNewSection(Section section) { }
public SectionDecoder() { m_pid = 0x1fff; m_tableId = -1; m_section = new Section(); }