bool scan_function(const std::vector<std::string> & tokens, std::ofstream & out_file) { if ( not is_scan(tokens)) return false; if(tokens[4] == "string") out_file << "\n\tstd::string " << tokens[0] << ';'; else if( tokens[4] == "int") out_file << "\n\tint "<< tokens[0] << ';'; else if( tokens[4] == "float") out_file << "\n\tfloat " << tokens[0] << ';'; return true; }
void* tune::scan_thread() { if (!is_scan()) { scan_progress_t progress; progress.total = (unsigned int)scan_channel_list.size(), progress.current = 0, progress.physical_channel = 0, state |= TUNE_STATE_SCAN; feeder.parser.set_scan_mode(true); feeder.parser.set_epg_mode(scan_epg); for (channel_map::const_iterator iter = scan_channel_list.begin(); iter != scan_channel_list.end(); ++iter) { unsigned int channel = iter->first; progress.current++; progress.physical_channel = channel; if (f_kill_thread) break; #if 0 map_chan_to_ts_id::const_iterator iter = channels.find(channel); if (iter != channels.end()) { #else if (channels.count(channel)) { #endif fprintf(stderr, "ALREADY SCANNED CHANNEL %d\n", channel); continue; } fprintf(stderr, "scan channel %d...\n", channel); if (scan_progress_cb) scan_progress_cb(scan_progress_context, &progress); if ((!f_kill_thread) && ((tune_channel((scan_mode == SCAN_VSB) ? DVBTEE_VSB_8 : DVBTEE_QAM_256, channel)) && (wait_for_lock_or_timeout(2000)))) { if (f_kill_thread) break; switch (fe_type) { default: case DVBTEE_FE_ATSC: feeder.parser.set_channel_info(channel, (scan_mode == SCAN_VSB) ? atsc_vsb_chan_to_freq(channel) : atsc_qam_chan_to_freq(channel), (scan_mode == SCAN_VSB) ? "8VSB" : "QAM_256"); break; case DVBTEE_FE_OFDM: feeder.parser.set_channel_info(channel, dvbt_chan_to_freq(channel), ((channel <= 12) ? "INVERSION_AUTO:BANDWIDTH_7_MHZ:FEC_AUTO:FEC_AUTO:QAM_AUTO:TRANSMISSION_MODE_AUTO:GUARD_INTERVAL_AUTO:HIERARCHY_AUTO" : "INVERSION_AUTO:BANDWIDTH_8_MHZ:FEC_AUTO:FEC_AUTO:QAM_AUTO:TRANSMISSION_MODE_AUTO:GUARD_INTERVAL_AUTO:HIERARCHY_AUTO")); break; } if (0 == start_feed()) { int timeout = (scan_epg) ? 16 : (fe_type == DVBTEE_FE_ATSC) ? 4 : 12; while ((!f_kill_thread) && (timeout)) { if (scan_epg) feeder.wait_for_epg(1000); else feeder.wait_for_psip(1000); timeout--; } stop_feed(); channels[channel] = feeder.parser.get_ts_id(); } // else what if we cant start the feed??? } } close_fe(); scan_complete = true; state &= ~TUNE_STATE_SCAN; } pthread_exit(NULL); } #define CHAR_CMD_COMMA "," int tune::start_scan(unsigned int mode, char *channel_list, bool epg, scan_progress_callback progress_cb, void *progress_context) { char *save; char *item = strtok_r(channel_list, CHAR_CMD_COMMA, &save); scan_channel_list.clear(); if (item) while (item) { #if 0 if (!item) item = channel_list; #endif scan_channel_list[atoi(item)] = false; item = strtok_r(NULL, CHAR_CMD_COMMA, &save); } else scan_channel_list[atoi(channel_list)] = false; return start_scan(mode, epg, progress_cb, progress_context); }