diff options
Diffstat (limited to 'src/ParserConfigfile.cpp')
-rw-r--r-- | src/ParserConfigfile.cpp | 120 |
1 files changed, 78 insertions, 42 deletions
diff --git a/src/ParserConfigfile.cpp b/src/ParserConfigfile.cpp index ca9983b..3ac6537 100644 --- a/src/ParserConfigfile.cpp +++ b/src/ParserConfigfile.cpp @@ -63,6 +63,7 @@ #include "dabInputDmbUdp.h" #include "dabInputZmq.h" #include "DabMux.h" +#include "StatsServer.h" #ifdef _WIN32 @@ -144,7 +145,9 @@ void parse_configfile(string configuration_file, bool* enableTist, unsigned* FICL, bool* factumAnalyzer, - unsigned long* limit + unsigned long* limit, + BaseRemoteController* rc, + int* statsServerPort ) { using boost::property_tree::ptree; @@ -183,6 +186,19 @@ void parse_configfile(string configuration_file, *enableTist = pt_general.get("tist", false); + *statsServerPort = pt_general.get<int>("statsserverport", 0); + + /************** READ REMOTE CONTROL PARAMETERS *************/ + ptree pt_rc = pt.get_child("remotecontrol"); + int telnetport = pt_rc.get<int>("telnetport", 0); + + if (telnetport != 0) { + rc = new RemoteControllerTelnet(telnetport); + } + else { + rc = new RemoteControllerDummy(); + } + /******************** READ ENSEMBLE PARAMETERS *************/ ptree pt_ensemble = pt.get_child("ensemble"); @@ -213,7 +229,7 @@ void parse_configfile(string configuration_file, ptree pt_services = pt.get_child("services"); for (ptree::iterator it = pt_services.begin(); - it != pt_services.end(); it++) { + it != pt_services.end(); ++it) { string serviceuid = it->first; ptree pt_service = it->second; dabService* service = new dabService(); @@ -264,14 +280,14 @@ void parse_configfile(string configuration_file, map<string, dabSubchannel*> allsubchans; ptree pt_subchans = pt.get_child("subchannels"); - for (ptree::iterator it = pt_subchans.begin(); it != pt_subchans.end(); it++) { + for (ptree::iterator it = pt_subchans.begin(); it != pt_subchans.end(); ++it) { string subchanuid = it->first; dabSubchannel* subchan = new dabSubchannel(); ensemble->subchannels.push_back(subchan); try { - setup_subchannel_from_ptree(subchan, it->second, ensemble, subchanuid); + setup_subchannel_from_ptree(subchan, it->second, ensemble, subchanuid, rc); } catch (runtime_error &e) { etiLog.log(error, @@ -294,7 +310,7 @@ void parse_configfile(string configuration_file, /******************** READ COMPONENT PARAMETERS ************/ map<string, dabComponent*> allcomponents; ptree pt_components = pt.get_child("components"); - for (ptree::iterator it = pt_components.begin(); it != pt_components.end(); it++) { + for (ptree::iterator it = pt_components.begin(); it != pt_components.end(); ++it) { string componentuid = it->first; ptree pt_comp = it->second; @@ -371,7 +387,7 @@ void parse_configfile(string configuration_file, /******************** READ OUTPUT PARAMETERS ***************/ map<string, dabOutput*> alloutputs; ptree pt_outputs = pt.get_child("outputs"); - for (ptree::iterator it = pt_outputs.begin(); it != pt_outputs.end(); it++) { + for (ptree::iterator it = pt_outputs.begin(); it != pt_outputs.end(); ++it) { string outputuid = it->first; string uri = pt_outputs.get<string>(outputuid); @@ -409,7 +425,8 @@ void parse_configfile(string configuration_file, void setup_subchannel_from_ptree(dabSubchannel* subchan, boost::property_tree::ptree &pt, dabEnsemble* ensemble, - string subchanuid) + string subchanuid, + BaseRemoteController* rc) { using boost::property_tree::ptree; using boost::property_tree::ptree_error; @@ -444,7 +461,12 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, subchan->inputName = inputName; - + /* The input is of the old_style type, + * with the struct of function pointers, + * and needs to be a DabInputCompatible + */ + bool input_is_old_style = true; + dabInputOperations operations; dabProtection* protection = &subchan->protection; if (0) { @@ -453,7 +475,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, subchan->inputProto = "file"; subchan->type = 0; subchan->bitrate = 0; - subchan->operations = dabInputMpegFileOperations; + operations = dabInputMpegFileOperations; #endif // defined(HAVE_INPUT_FILE) && defined(HAVE_FORMAT_MPEG) #if defined(HAVE_FORMAT_DABPLUS) } else if (type == "dabplus") { @@ -462,6 +484,10 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, char* proto; + char* full_inputName = new char[256]; + full_inputName[255] = '\0'; + memcpy(full_inputName, inputName, 255); + proto = strstr(inputName, "://"); if (proto == NULL) { subchan->inputProto = "file"; @@ -474,22 +500,32 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, if (0) { #if defined(HAVE_INPUT_FILE) } else if (strcmp(subchan->inputProto, "file") == 0) { - subchan->operations = dabInputDabplusFileOperations; + operations = dabInputDabplusFileOperations; #endif // defined(HAVE_INPUT_FILE) #if defined(HAVE_INPUT_ZEROMQ) } else if (strcmp(subchan->inputProto, "tcp") == 0) { - subchan->operations = dabInputZmqOperations; + input_is_old_style = false; + DabInputZmq* inzmq = new DabInputZmq(subchanuid); + inzmq->enrol_at(*rc); + subchan->input = inzmq; + subchan->inputName = full_inputName; } else if (strcmp(subchan->inputProto, "epmg") == 0) { - etiLog.log(warn, - "Using untested epmg:// zeromq input\n"); - subchan->operations = dabInputZmqOperations; + etiLog.level(warn) << "Using untested epmg:// zeromq input"; + input_is_old_style = false; + DabInputZmq* inzmq = new DabInputZmq(subchanuid); + inzmq->enrol_at(*rc); + subchan->input = inzmq; + subchan->inputName = full_inputName; } else if (strcmp(subchan->inputProto, "ipc") == 0) { - etiLog.log(warn, - "Using untested ipc:// zeromq input\n"); - subchan->operations = dabInputZmqOperations; + etiLog.level(warn) << "Using untested ipc:// zeromq input"; + input_is_old_style = false; + DabInputZmq* inzmq = new DabInputZmq(subchanuid); + inzmq->enrol_at(*rc); + subchan->input = inzmq; + subchan->inputName = full_inputName; #endif // defined(HAVE_INPUT_ZEROMQ) } else { stringstream ss; @@ -514,11 +550,11 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, #if defined(HAVE_FORMAT_BRIDGE) #if defined(HAVE_INPUT_UDP) } else if (strcmp(subchan->inputProto, "udp") == 0) { - subchan->operations = dabInputBridgeUdpOperations; + operations = dabInputBridgeUdpOperations; #endif // defined(HAVE_INPUT_UDP) #if defined(HAVE_INPUT_SLIP) } else if (strcmp(subchan->inputProto, "slip") == 0) { - subchan->operations = dabInputSlipOperations; + operations = dabInputSlipOperations; #endif // defined(HAVE_INPUT_SLIP) #endif // defined(HAVE_FORMAT_BRIDGE) } @@ -536,18 +572,18 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, if (0) { #if defined(HAVE_INPUT_UDP) } else if (strcmp(subchan->inputProto, "udp") == 0) { - subchan->operations = dabInputUdpOperations; + operations = dabInputUdpOperations; #endif #if defined(HAVE_INPUT_PRBS) && defined(HAVE_FORMAT_RAW) } else if (strcmp(subchan->inputProto, "prbs") == 0) { - subchan->operations = dabInputPrbsOperations; + operations = dabInputPrbsOperations; #endif #if defined(HAVE_INPUT_FILE) && defined(HAVE_FORMAT_RAW) } else if (strcmp(subchan->inputProto, "file") == 0) { - subchan->operations = dabInputRawFileOperations; + operations = dabInputRawFileOperations; #endif } else if (strcmp(subchan->inputProto, "fifo") == 0) { - subchan->operations = dabInputRawFifoOperations; + operations = dabInputRawFifoOperations; } else { stringstream ss; ss << "Subchannel with uid " << subchanuid << @@ -563,7 +599,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, subchan->inputProto = "test"; subchan->type = 1; subchan->bitrate = DEFAULT_DATA_BITRATE; - subchan->operations = dabInputTestOperations; + operations = dabInputTestOperations; #endif // defined(HAVE_INPUT_TEST)) && defined(HAVE_FORMAT_RAW) #ifdef HAVE_FORMAT_PACKET } else if (type == "packet") { @@ -571,9 +607,9 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, subchan->type = 3; subchan->bitrate = DEFAULT_PACKET_BITRATE; #ifdef HAVE_INPUT_FILE - subchan->operations = dabInputPacketFileOperations; + operations = dabInputPacketFileOperations; #elif defined(HAVE_INPUT_FIFO) - subchan->operations = dabInputFifoOperations; + operations = dabInputFifoOperations; #else # pragma error("Must defined at least one packet input") #endif // defined(HAVE_INPUT_FILE) @@ -582,7 +618,7 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, subchan->inputProto = "file"; subchan->type = 3; subchan->bitrate = DEFAULT_PACKET_BITRATE; - subchan->operations = dabInputEnhancedPacketFileOperations; + operations = dabInputEnhancedPacketFileOperations; #endif // defined(HAVE_FORMAT_EPM) #endif // defined(HAVE_FORMAT_PACKET) #ifdef HAVE_FORMAT_DMB @@ -598,9 +634,9 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, *proto = 0; } if (strcmp(subchan->inputProto, "udp") == 0) { - subchan->operations = dabInputDmbUdpOperations; + operations = dabInputDmbUdpOperations; } else if (strcmp(subchan->inputProto, "file") == 0) { - subchan->operations = dabInputDmbFileOperations; + operations = dabInputDmbFileOperations; } else { stringstream ss; ss << "Subchannel with uid " << subchanuid << @@ -617,7 +653,6 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, ss << "Subchannel with uid " << subchanuid << " has unknown type!"; throw runtime_error(ss.str()); } - subchan->operations.init(&subchan->data); subchan->startAddress = 0; if (type == "audio") { @@ -649,37 +684,33 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, switch (subchan->type) { #ifdef HAVE_FORMAT_PACKET case 3: - subchan->operations.clean(&subchan->data); - if (subchan->operations == dabInputPacketFileOperations) { - subchan->operations = dabInputFifoOperations; + if (operations == dabInputPacketFileOperations) { + operations = dabInputFifoOperations; #ifdef HAVE_FORMAT_EPM - } else if (subchan->operations == dabInputEnhancedPacketFileOperations) { - subchan->operations = dabInputEnhancedFifoOperations; + } else if (operations == dabInputEnhancedPacketFileOperations) { + operations = dabInputEnhancedFifoOperations; #endif // defined(HAVE_FORMAT_EPM) } else { etiLog.log(error, "Error, wrong packet subchannel operations!\n"); throw runtime_error("Error, wrong packet subchannel operations!\n"); } - subchan->operations.init(&subchan->data); subchan->inputProto = "fifo"; break; #endif // defined(HAVE_FORMAT_PACKET) #ifdef HAVE_FORMAT_MPEG case 0: - subchan->operations.clean(&subchan->data); - if (subchan->operations == dabInputMpegFileOperations) { - subchan->operations = dabInputMpegFifoOperations; - } else if (subchan->operations == + if (operations == dabInputMpegFileOperations) { + operations = dabInputMpegFifoOperations; + } else if (operations == dabInputDabplusFileOperations) { - subchan->operations = dabInputDabplusFifoOperations; + operations = dabInputDabplusFifoOperations; } else { etiLog.log(error, "Error, wrong audio subchannel operations!\n"); throw runtime_error( "Error, wrong audio subchannel operations!\n"); } - subchan->operations.init(&subchan->data); subchan->inputProto = "fifo"; break; #endif // defined(HAVE_FORMAT_MPEG) @@ -735,4 +766,9 @@ void setup_subchannel_from_ptree(dabSubchannel* subchan, } catch (ptree_error &e) {} + /* Create object */ + if (input_is_old_style) { + subchan->input = new DabInputCompatible(operations); + } + // else { it's already been created! } } |