void UPNPScanner::ParseDevice(QDomElement &element, QString &controlURL, QString &eventURL, QString &friendlyName) { QDomNode dev = element.firstChild(); while (!dev.isNull()) { QDomElement e = dev.toElement(); if (!e.isNull()) { if (e.tagName() == "friendlyName") friendlyName = e.text(); if (e.tagName() == "serviceList") ParseServiceList(e, controlURL, eventURL); } dev = dev.nextSibling(); } }
bool CBat::Parse() { printf("[scan] trying to parse BAT\n"); if(!Read()) return false; sections.sort(compare_section_num); BouquetAssociationSectionConstIterator sit; for (sit = sections.begin(); sit != sections.end(); ++sit) { BouquetAssociationSection * bat = *sit; uint16_t bouquet_id = bat->getTableIdExtension(); if (CServiceScan::getInstance()->Aborted()) return false; const DescriptorList * dlist = bat->getDescriptors(); DescriptorConstIterator dit; #ifdef DEBUG_BAT printf("BAT: section %d, %d descriptors\n", bat->getSectionNumber(), (int)dlist->size()); #endif unsigned int pdsd = 0; for (dit = dlist->begin(); dit != dlist->end(); ++dit) { Descriptor * d = *dit; //printf("BAT: parse descriptor %02x len %d\n", d->getTag(), d->getLength()); switch(d->getTag()) { case BOUQUET_NAME_DESCRIPTOR: { BouquetNameDescriptor * nd = (BouquetNameDescriptor *) d; /*std::string*/ bouquetName = stringDVBUTF8(nd->getBouquetName()); printf("BAT: bouquet name [%s]\n", bouquetName.c_str()); } break; case LINKAGE_DESCRIPTOR: { #ifdef DEBUG_BAT LinkageDescriptor * ld = (LinkageDescriptor*) d; printf("BAT: linkage, tsid %04x onid %04x sid %04x type %02x\n", ld->getTransportStreamId(), ld->getOriginalNetworkId(), ld->getServiceId(), ld->getLinkageType()); #endif } break; case PRIVATE_DATA_SPECIFIER_DESCRIPTOR: { PrivateDataSpecifierDescriptor * pd = (PrivateDataSpecifierDescriptor *)d; pdsd = pd->getPrivateDataSpecifier(); #ifdef DEBUG_BAT printf("BAT: private data specifier %08x\n", pdsd); #endif } break; case COUNTRY_AVAILABILITY_DESCRIPTOR: default: { #ifdef DEBUG_BAT_UNUSED printf("BAT: descriptor %02x: ", d->getTag()); uint8_t len = 2+d->getLength(); uint8_t *buf = new uint8_t[len]; if(buf){ d->writeToBuffer(buf); for(uint8_t i = 0; i < len; i++) printf("%02x ", buf[i]); printf("\n"); delete []buf; } #endif } break; } } const BouquetAssociationList &blist = *bat->getBouquets(); BouquetAssociationConstIterator it; for(it = blist.begin(); it != blist.end(); ++it) { BouquetAssociation * b = *it; dlist = b->getDescriptors(); #if 1 printf("BAT: bouquet_id %04x tsid %04x onid %04x %d descriptors\n", bouquet_id, b->getTransportStreamId(), b->getOriginalNetworkId(), (int)dlist->size()); #endif for (dit = dlist->begin(); dit != dlist->end(); ++dit) { Descriptor * d = *dit; switch(d->getTag()) { case SERVICE_LIST_DESCRIPTOR: ParseServiceList((ServiceListDescriptor *) d, b); break; #if 1 case LOGICAL_CHANNEL_DESCRIPTOR: ParseLogicalChannels((LogicalChannelDescriptor *) d, b); break; #endif case PRIVATE_DATA_SPECIFIER_DESCRIPTOR: { PrivateDataSpecifierDescriptor * pd = (PrivateDataSpecifierDescriptor *)d; pdsd = pd->getPrivateDataSpecifier(); #ifdef DEBUG_BAT printf("BAT: private data specifier %08x\n", pdsd); #endif } break; default: { #ifdef DEBUG_BAT_UNUSED printf("BAT: descriptor %02x: ", d->getTag()); uint8_t len = 2+d->getLength(); uint8_t *buf = new uint8_t[len]; if(buf){ d->writeToBuffer(buf); for(uint8_t i = 0; i < len; i++) printf("%02x ", buf[i]); printf("\n"); delete []buf; } #endif } break; } switch(pdsd) { case 0x00000010: if(d->getTag() == 0x82) { uint8_t *buf = new uint8_t[2 + d->getLength()]; if(buf){ d->writeToBuffer(buf); LogicalChannelDescriptor ld(buf); ParseLogicalChannels(&ld, b); delete []buf; } } break; default: break; } } } } return true; }