diff --git a/configure.cpp b/configure.cpp index 6daa59a..2c7d32d 100644 --- a/configure.cpp +++ b/configure.cpp @@ -45,6 +45,11 @@ Configure::Configure(int argc, char** argv) : _linesPerField = 16; // default to 16 lines per field _multiplexedSignalFlag = false; // using this would require changing all the line counting and a way to send full field through raspi-teletext - something for the distant future when everything else is done... + + uint8_t priority[8]={9,3,3,6,3,3,5,6}; // 1=High priority,9=low. Note: priority[0] is mag 8 + + for (int i=0; i<8; i++) + _magazinePriority[i] = priority[i]; //Scan the command line for overriding the pages file. //std::cerr << "[Configure::Configure] Parameters=" << argc << " " << std::endl; @@ -92,7 +97,7 @@ int Configure::LoadConfigFile(std::string filename) std::vector::iterator iter; // these are all the valid strings for config lines - std::vector nameStrings{ "header_template", "initial_teletext_page", "row_adaptive_mode", "network_identification_code", "country_network_identification", "full_field", "status_display", "subtitle_repeats","enable_command_port","command_port","lines_per_field" }; + std::vector nameStrings{ "header_template", "initial_teletext_page", "row_adaptive_mode", "network_identification_code", "country_network_identification", "full_field", "status_display", "subtitle_repeats","enable_command_port","command_port","lines_per_field","magazine_priority" }; if (filein.is_open()){ std::cerr << "[Configure::LoadConfigFile] opened " << filename << std::endl; @@ -246,6 +251,37 @@ int Configure::LoadConfigFile(std::string filename) error = 1; } break; + case 11: // "magazine_priority" + // TODO: implement parsing from config + std::stringstream ss(value); + std::string temps; + int tmp[8]; + int i; + for (i=0; i<8; i++) + { + if (std::getline(ss, temps, ',')) + { + try { + tmp[i] = stoi(temps); + } catch (const std::invalid_argument& ia) { + error = 1; + break; + } + if (!(tmp[i] > 0 && tmp[i] < 10)) // must be 1-9 + { + error = 1; + break; + } + } + else + { + error = 1; + break; + } + } + for (i=0; i<8; i++) + _magazinePriority[i] = tmp[i]; + break; } } else { error = 1; // unrecognised config line diff --git a/configure.h b/configure.h index e2201f7..59660fe 100644 --- a/configure.h +++ b/configure.h @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -47,6 +48,7 @@ class Configure bool GetCommandPortEnabled(){return _commandPortEnabled;} uint8_t GetLinesPerField(){return _linesPerField;} bool GetReverseFlag(){return _reverseBits;} + int GetMagazinePriority(uint8_t mag){return _magazinePriority[mag];} private: int DirExists(char *path); @@ -62,6 +64,7 @@ class Configure uint8_t _linesPerField; // settings for generation of packet 8/30 bool _multiplexedSignalFlag; // false indicates teletext is multiplexed with video, true means full frame teletext. + int _magazinePriority[8]; uint8_t _initialMag; uint8_t _initialPage; uint16_t _initialSubcode; diff --git a/example-vbit.conf b/example-vbit.conf index da51a5a..07fa5f5 100644 --- a/example-vbit.conf +++ b/example-vbit.conf @@ -40,6 +40,13 @@ header_template=TEEFAX %%# %%a %e %%b C%H:%M/%S ; omit blank rows to increase transmission efficiency (defaults to false) ;row_adaptive_mode=false +; specify number of VBI lines per video field +;lines_per_field=16 + +; set the priority of each magazine. 1=highest priority, 9=lowest. +; eight comma separated values for magazines 8,1,2,3,4,5,6,7. +;magazine_priority=9,3,3,6,3,3,5,6 + ; 20 character status message for broadcast service data packet status_display=TEEFAX diff --git a/service.cpp b/service.cpp index 849d80b..03a4a8f 100644 --- a/service.cpp +++ b/service.cpp @@ -15,15 +15,14 @@ Service::Service(Configure *configure, PageList *pageList) : _lineCounter(0), _fieldCounter(50) // roll over immediately { - // @todo Put priority into config and add commands to allow updates. - uint8_t priority[8]={9,3,3,6,3,3,5,6}; // 1=High priority,9=low. Note: priority[0] is mag 8 + // @todo Add commands to allow updates to priority. vbit::PacketMag **magList=_pageList->GetMagazines(); // Register all the packet sources for (uint8_t mag=0;mag<8;mag++) { vbit::PacketMag* m=magList[mag]; - m->SetPriority(priority[mag]); // set the mags to the desired priorities + m->SetPriority(_configure->GetMagazinePriority(mag)); // set the mags to the desired priorities _register(m); // use the PacketMags created in pageList rather than duplicating them } // Add packet sources for subtitles, databroadcast and packet 830