diff options
Diffstat (limited to 'p2pvr/scanner/eitRows.cpp')
-rw-r--r-- | p2pvr/scanner/eitRows.cpp | 109 |
1 files changed, 38 insertions, 71 deletions
diff --git a/p2pvr/scanner/eitRows.cpp b/p2pvr/scanner/eitRows.cpp index 23e8cfe..6f1934a 100644 --- a/p2pvr/scanner/eitRows.cpp +++ b/p2pvr/scanner/eitRows.cpp @@ -88,45 +88,20 @@ EitRows::loadComplete(const CommonObjects *) { } -void -EitRows::setFilter(const Glib::ustring &) +EitRowState::EitRowState() : + current(NULL) { } -unsigned int -EitRows::columnCount() const +const Columns & +EitRowState::getColumns() const { - return 1; -} - -const Glib::ustring & -EitRows::getColumnName(unsigned int) const { - return title; -} - -VariableType -EitRows::getCurrentValue(const Glib::ustring &) const { - return current->title; -} - -VariableType -EitRows::getCurrentValue(unsigned int) const { - return current->title; -} - -bool -EitRows::isNull(unsigned int ) const { - return false; -} - -bool -EitRows::isNull(const Glib::ustring & ) const { - return false; + return columns; } #define returnAttr(name) if (attrName == #name) return boost::bind(getMember<EitProgram, VariableType>, &EitProgram::name, boost::ref(current)) -RowSet::RowAttribute -EitRows::resolveAttr(const Glib::ustring & attrName) const { +RowState::RowAttribute +EitRowState::resolveAttr(const Glib::ustring & attrName) const { returnAttr(serviceID); returnAttr(eventID); returnAttr(title); @@ -158,10 +133,9 @@ EitRows::resolveAttr(const Glib::ustring & attrName) const { DECLARE_LOADER("eitrows", EitRows); -EitRows::EitRows(const xmlpp::Element * p) : +EitRows::EitRows(const ScriptNodePtr p) : RowSet(p), - DvbSiReaderHelper(p), - current(NULL) + DvbSiReaderHelper(p) { } @@ -169,15 +143,15 @@ EitRows::~EitRows() { } -static int time_offset = 0; -static int chan_filter = 0; +static int time_offset = 0; +static int chan_filter = 0; static int chan_filter_mask = 0; static Glib::RefPtr<Glib::Regex> episodeRegex = Glib::Regex::create("[ (]+(?:\\w+ )?([0-9]+)(?: of |/)([0-9]+)[.)]+"); static Glib::RefPtr<Glib::Regex> yearRegex = Glib::Regex::create("\\(([0-9]{4})[ )]+"); static Glib::RefPtr<Glib::Regex> flagsRegex = Glib::Regex::create("[ []+([A-Z,]+)\\]"); void -EitRows::parseEventDescription(const u_char *data) const { +EitRows::parseEventDescription(const u_char * data, EitProgram * current) const { assert(GetDescriptorTag(data) == 0x4D); const struct descr_short_event *evtdesc = reinterpret_cast<const struct descr_short_event *>(data); @@ -240,25 +214,25 @@ EitRows::parseEventDescription(const u_char *data) const { } if (title) { boost::algorithm::trim_if(*title, isspace); - current->title = title; + current->title = *title; } if (subtitle) { boost::algorithm::trim_if(*subtitle, isspace); if (!subtitle->empty()) { - current->subtitle = subtitle; + current->subtitle = *subtitle; } } if (desc) { boost::algorithm::trim_if(*desc, isspace); if (!desc->empty()) { - current->desc1 = desc; + current->desc1 = *desc; } } } /* Parse 0x4E Extended Event Descriptor. {{{ */ void -EitRows::parseLongEventDescription(const u_char *data) const { +EitRows::parseLongEventDescription(const u_char * data, EitProgram * current) const { assert(GetDescriptorTag(data) == 0x4E); const struct descr_extended_event *levt = reinterpret_cast<const struct descr_extended_event *>(data); bool non_empty = (levt->descriptor_number || levt->last_descriptor_number || levt->length_of_items || levt->data[0]); @@ -274,21 +248,21 @@ EitRows::parseLongEventDescription(const u_char *data) const { const struct item_extended_event *name = reinterpret_cast<const struct item_extended_event *>(p); size_t name_len = name->item_description_length; assert(p + ITEM_EXTENDED_EVENT_LEN + name_len < data_end); - current->desc1 = convert((const char *)name->data, name_len); + current->desc1 = *convert((const char *)name->data, name_len); p += ITEM_EXTENDED_EVENT_LEN + name_len; const struct item_extended_event *value = reinterpret_cast<const struct item_extended_event *>(p); size_t value_len = value->item_description_length; assert(p + ITEM_EXTENDED_EVENT_LEN + value_len < data_end); - current->desc2 = convert((const char *)value->data, value_len); + current->desc2 = *convert((const char *)value->data, value_len); p += ITEM_EXTENDED_EVENT_LEN + value_len; } const struct item_extended_event *text = reinterpret_cast<const struct item_extended_event *>(p); size_t len = text->item_description_length; if (non_empty && len) { - current->desc3 = convert((const char *)text->data, len); + current->desc3 = *convert((const char *)text->data, len); } } @@ -300,7 +274,7 @@ EitRows::parseLongEventDescription(const u_char *data) const { only output the first one of each (XMLTV can't cope with more than one) */ void -EitRows::parseComponentDescription(const u_char *data) const { +EitRows::parseComponentDescription(const u_char * data, EitProgram * current) const { assert(GetDescriptorTag(data) == 0x50); const struct descr_component *dc = reinterpret_cast<const struct descr_component *>(data); @@ -325,7 +299,7 @@ EitRows::parseComponentDescription(const u_char *data) const { } /*}}}*/ void -EitRows::parseContentDescription(const u_char *data) const { +EitRows::parseContentDescription(const u_char * data, EitProgram * current) const { assert(GetDescriptorTag(data) == 0x54); const struct descr_content * dc = reinterpret_cast<const struct descr_content *>(data); for (const u_char * p = reinterpret_cast<const u_char*>(&dc->data); p < data + DESCR_GEN_LEN + dc->descriptor_length; p += NIBBLE_CONTENT_LEN) { @@ -337,7 +311,7 @@ EitRows::parseContentDescription(const u_char *data) const { } void -EitRows::parseRatingDescription(const u_char *data) const { +EitRows::parseRatingDescription(const u_char * data, EitProgram * current) const { assert(GetDescriptorTag(data) == 0x55); const struct descr_parental_rating * pr = reinterpret_cast<const struct descr_parental_rating *>(data); for (const u_char * p = reinterpret_cast<const u_char *>(&pr->data); p < data + DESCR_GEN_LEN + pr->descriptor_length; p += PARENTAL_RATING_ITEM_LEN) { @@ -362,7 +336,7 @@ int parsePrivateDataSpecifier(const u_char *data) { /* Parse 0x76 Content Identifier Descriptor. {{{ */ /* See ETSI TS 102 323, section 12 */ void -EitRows::parseContentIdentifierDescription(const u_char *data) const { +EitRows::parseContentIdentifierDescription(const u_char * data, EitProgram * current) const { assert(GetDescriptorTag(data) == 0x76); const struct descr_content_identifier *ci = reinterpret_cast<const struct descr_content_identifier *>(data); for (const u_char * p = reinterpret_cast<const u_char *>(&ci->data); p < data + DESCR_GEN_LEN + ci->descriptor_length; p += DESCR_GEN_LEN + ci->descriptor_length) { @@ -404,7 +378,7 @@ EitRows::parseContentIdentifierDescription(const u_char *data) const { 'new', 'subtitles', 'rating', 'star-rating' */ void -EitRows::parseDescription(const u_char * data, size_t len) const { +EitRows::parseDescription(const u_char * data, size_t len, EitProgram * current) const { int pds = 0; for (const u_char * p = data; p < data + len; p += DESCR_GEN_LEN + GetDescriptorLength(p)) { const struct descr_gen *desc = reinterpret_cast<const struct descr_gen *>(p); @@ -413,21 +387,21 @@ EitRows::parseDescription(const u_char * data, size_t len) const { break; case 0x4D: //short evt desc, [title] [sub-title] // there can be multiple language versions of these - parseEventDescription(p); + parseEventDescription(p, current); break; case 0x4E: //long evt descriptor [desc] - parseLongEventDescription(p); + parseLongEventDescription(p, current); break; case 0x50: //component desc [language] [video] [audio] [subtitles] - parseComponentDescription(p); + parseComponentDescription(p, current); break; case 0x53: // CA Identifier Descriptor break; case 0x54: // content desc [category] - parseContentDescription(p); + parseContentDescription(p, current); break; case 0x55: // Parental Rating Descriptor [rating] - parseRatingDescription(p); + parseRatingDescription(p, current); break; case 0x5f: // Private Data Specifier pds = parsePrivateDataSpecifier(p); @@ -452,7 +426,7 @@ EitRows::parseDescription(const u_char * data, size_t len) const { case 0x86: // Eacem Stream Identifier Descriptor break; case 0x76: // Content identifier descriptor - parseContentIdentifierDescription(p); + parseContentIdentifierDescription(p, current); break; default: break; @@ -491,6 +465,7 @@ EitRows::parseInfoTable(const u_char *data, size_t len, const RowProcessor * rp) len -= 4; //remove CRC // For each event listing + EitRowState state; bool found = false; for (const u_char *p = reinterpret_cast<const u_char *>(&e->data); p < data + len; p += EIT_EVENT_LEN + GetEITDescriptorsLoopLength(p)) { const struct eit_event *evt = reinterpret_cast<const struct eit_event *>(p); @@ -512,7 +487,7 @@ EitRows::parseInfoTable(const u_char *data, size_t len, const RowProcessor * rp) BcdCharToInt(evt->start_time_m), BcdCharToInt(evt->start_time_s)); EitProgram results; - current = &results; + state.current = &results; results.startTime = startTime; results.stopTime = startTime + boost::posix_time::time_duration( BcdCharToInt(evt->duration_h), @@ -528,9 +503,8 @@ EitRows::parseInfoTable(const u_char *data, size_t len, const RowProcessor * rp) results.serviceID = HILO(e->service_id); results.eventID = HILO(evt->event_id); - parseDescription(reinterpret_cast<const u_char *>(&evt->data), GetEITDescriptorsLoopLength(evt)); - rp->rowReady(); - rowNum += 1; + parseDescription(reinterpret_cast<const u_char *>(&evt->data), GetEITDescriptorsLoopLength(evt), &results); + state.process(rp); found = true; } return found; @@ -555,17 +529,10 @@ EitRows::filterInput(int fd) const } void -EitRows::execute(const RowProcessor * rp) const +EitRows::execute(const Glib::ustring &, const RowProcessor * rp) const { - try { - openInput(); - readTables(rp); - closeInput(); - seenPrograms.clear(); - } - catch (...) { - seenPrograms.clear(); - throw; - } + openInput(); + readTables(rp); + closeInput(); } |