ConnectionManager::ConnectionManager(const int port, const Config &cfg)
{
	this->_cfgMgr = cfg;
#if defined(WIN32) || defined(WIN64)
	this->cmInitWSA();
#endif
	this->cmSetSocket();
	this->cmBind(port);
	this->_cfgMgr.setPort(Tools::intToString(port));
	this->_cfgMgr.setIp(std::string(inet_ntoa(this->_src_inf.sin_addr)));
	this->cmListen();
	this->_selectTime.tv_sec = 0;
	this->_selectTime.tv_usec = 100;
	std::cout << "Socket #" << this->_sock << " OK ! Listening on port " << port << "." << std::endl;
	this->_cfgMgr.dump();

	ModuleManager		*mm;

	mm = ModuleManager::getInstance();

//	mm->LoadModule("mod_bf.dll", this->_cfgMgr);
	mm->LoadModule("./zia_ban.dll", this->_cfgMgr);
	mm->LoadModule("./zia_html.dll", this->_cfgMgr);
//	mm->LoadModule("zia_ban.dll", this->_cfgMgr);
//	mm->LoadModule("mod_test1.dll", this->_cfgMgr);

}
Example #2
0
bool ModuleList::dropMimeData(QTreeWidgetItem *parent, int index,
                              const QMimeData *data, Qt::DropAction action) {
    cout << "DROP! Formats: " << data->formats().join(";").toStdString()
         << endl;

    if (!parent) {
        return false;
    }

    MyMimeData *mmd = (MyMimeData*) data;
    QTreeWidgetItem * draggedItem = mmd->indexes().first();
    QTreeWidgetItem * targetItem = parent;

    ModuleManager * mm = MainWindow::getLastInstance()->getModuleManager();
    ComparisonDialog dia;
    if ((mm->getMatchingModule(draggedItem))->getModuleManager() == mm) {
        cout << "Ja! 1" << endl;
    }
    if ((mm->getMatchingModule(targetItem))->getModuleManager() == mm) {
        cout << "Ja! 2" << endl;
    }
    dia.addWidgets(ModuleManager::cloneModule(
                       mm->getMatchingModule(draggedItem)), ModuleManager::cloneModule(
                       mm->getMatchingModule(targetItem)));
    dia.setModal(true);
    dia.exec();

    return true;
}
Example #3
0
void mod_module_manager_register_module
    (
    Mod_ModuleManager* manager,
    const char* module
    )
{
    ModuleManager* mngr = (ModuleManager*)manager;
    mngr->registerModule( std::string( module ) );
}
Example #4
0
GF::GF()
{
  boost::property_tree::ptree ac, audioCodecs, vc, videoCodecs;
  gst_init (NULL, NULL);

  moduleManager.loadModulesFromDirectories ("../../src/server");

  mediaPipelineId = moduleManager.getFactory ("MediaPipeline")->createObject (
                      config, "",
                      Json::Value() )->getId();
}
int ModuleManager::requestML(const char   *path, 
								const char   *types, 
								lo_arg       **argv, 
								int          argc,
								void         *data, 
								void         *user_data)
{
    ModuleManager *mm = (ModuleManager *)user_data;
	mm->sendModuleList();
	
	return 1;
}
Example #6
0
AutoCommon::~AutoCommon(void)
{
    ModuleManager *pModMng = ModuleManager::instance();
    pModMng->UnRegisterModule(this);    



#ifdef SDB_COMMON_HAS_TIMER           
    delete m_pTimerThread;
#endif

#ifdef SDB_COMMON_HAS_EVENT   
    delete  m_pEventThread;
#endif

};
Example #7
0
int main()
{
    Server              *s;
    Coordinator			*co;
	ModuleManager       *mm;
    XBeeController      *xbc;
	Serial              *se;
    MyModule            *mym;
	int                 mIndex;
    char                dn[128];
    dn[0] = '/';
    
    printf("Please Enter Your Device Name!\n");
    scanf("%s", &dn[1]);

	s = new Server();
    xbc = new XBeeController(s, "/XBC", "/dev/cu.usbserial-A50178PJ");
	mm	= new ModuleManager(s, dn);
	co	= new Coordinator(s, "/Coordinator");
    se  = new Serial(s, "/Serial", "/dev/cu.usbmodemfd131");
	mym = new MyModule(s, "/MM");

	mm->sendModuleList();
    xbc->co = co;
    co->xbc = xbc;
    
    se->connectTo(mym, "/Stream");
    
    while (1) {
        printf("Enter Module Index\n");
        scanf("%d", &mIndex);
        if (!mIndex) break;
        
        if (mIndex == -1) {
            co->ml->requestML();
            co->ml->displayModules();
        }
        
        if (mym->tID) 
            co->ml->createModule(mym->tID, mIndex);

    }	

	return 0;
}
Example #8
0
AutoCommon::AutoCommon(char *szModName):BaseModule(szModName),CmdIFModule(szModName,this)
{
    std::string strTemp;
    
#ifdef SDB_COMMON_HAS_EVENT
    m_pEventThread = NULL;
    m_pEventThread = new mod::EventThread(strTemp);
#endif   
    
#ifdef SDB_COMMON_HAS_TIMER
    m_pTimerThread = NULL;
    strTemp = m_strModName+"Timer";
    m_pTimerThread = new mod::TimerThread(strTemp,150000);
#endif

    ModuleManager *pModMng = ModuleManager::instance();
    pModMng->RegisterModule(this);
    


};
Example #9
0
GF::GF()
{
  boost::property_tree::ptree ac, audioCodecs, vc, videoCodecs;
  gst_init(nullptr, nullptr);

  moduleManager.loadModulesFromDirectories ("../../src/server:../../..");

  config.add ("configPath", "../../../tests" );
  config.add ("modules.kurento.SdpEndpoint.numAudioMedias", 1);
  config.add ("modules.kurento.SdpEndpoint.numVideoMedias", 1);

  ac.put ("name", "opus/48000/2");
  audioCodecs.push_back (std::make_pair ("", ac) );
  config.add_child ("modules.kurento.SdpEndpoint.audioCodecs", audioCodecs);

  vc.put ("name", "VP8/90000");
  videoCodecs.push_back (std::make_pair ("", vc) );
  config.add_child ("modules.kurento.SdpEndpoint.videoCodecs", videoCodecs);

  mediaPipelineId = moduleManager.getFactory ("MediaPipeline")->createObject (
                      config, "",
                      Json::Value() )->getId();
}
Example #10
0
static std::shared_ptr <RtpEndpointImpl>
createRtpEndpoint (bool useIpv6)
{
  std::shared_ptr <kurento::MediaObjectImpl> rtpEndpoint;
  Json::Value constructorParams;

  constructorParams ["mediaPipeline"] = mediaPipelineId;
  constructorParams ["useIpv6"] = useIpv6;

  rtpEndpoint = moduleManager.getFactory ("RtpEndpoint")->createObject (
                  config, "",
                  constructorParams );

  return std::dynamic_pointer_cast <RtpEndpointImpl> (rtpEndpoint);
}
Example #11
0
static std::shared_ptr <RecorderEndpointImpl>
createRecorderEndpoint ()
{
  std::shared_ptr <kurento::MediaObjectImpl> recorderEndpoint;
  Json::Value constructorParams;
  std::string tmp_file = std::tmpnam (nullptr);

  constructorParams ["mediaPipeline"] = mediaPipelineId;
  constructorParams ["uri"] = "file://" + tmp_file;

  recorderEndpoint = moduleManager.getFactory ("RecorderEndpoint")->createObject (
                       config, "",
                       constructorParams );

  return std::dynamic_pointer_cast <RecorderEndpointImpl> (recorderEndpoint);
}
Example #12
0
namespace kurento
{

static ModuleManager moduleManager;

ModuleManager &getModuleManager ()
{
  return moduleManager;
}

void loadModules (const std::string &path)
{
  moduleManager.loadModulesFromDirectories (path);
}

} /* kurento */
Example #13
0
// argument is a configFile
int main(int argc, char** argv){

	// Declare a group of options that will be allowed only on command line
	po::options_description generic("Generic options");
	generic.add_options()
		("version,v", "print version string")
		("help,h", "produce help message")
		;

	po::options_description config("Program options");
	config.add_options()
		("configuration,c", po::value< string >(), "defines the path to an already created and stored chain configuration, written in yaml")
		("input,i", po::value< vector<string> >()->composing(), "defines an input, can be used multiple times format: inputName:fileName inputName is optional if there is only one input")
		("output,o",	po::value< vector<string> >()->composing(), "defines an output, can be used multiple times, format: outputName:fileName. outputName is optional, if there is only one input. Output is optional, if there is only one input and one output, the output filename will be chosen from the input name in this case.")
		("param,p",	po::value< vector<string> >()->composing(),	"defines a parameter, format:  name:value")
		;

	// Hidden options, will be allowed command line, but will not be shown to the user.
	po::options_description hidden("Hidden options");
	hidden.add_options()
		("modulename,m", po::value< string>(), "defines the name of the module")
		;

	// These two lines say that all positional options should be translated into "-modulename" options.
	po::positional_options_description p;
	p.add("modulename", -1);

	// Declare an options description instance which will include all the options
	po::options_description allOptions("Allowed options");
	allOptions.add(generic).add(config).add(hidden);

	// Declare an options description instance which will be shown to the user
	po::options_description visibleOptions("Allowed options");
	visibleOptions.add(generic).add(config);

	// process input parameters and store the result in vm
	po::variables_map vm;
	store(po::command_line_parser(argc, argv).options(allOptions).positional(p).run(), vm);
	po::notify(vm);



	if (argc < 2) {
		std::cerr << "Usage Error!\n\n";
		cout << "Usage:" << endl;
		cout << argv[0] << " -c <path to configuration file>				run a processing chain from a config file." << endl;
		cout << argv[0] << " <moduleName> -i <input> [-p <params> -o <output>]	run a single module." << endl;
		cout << "\n";
		// show help
		cout << visibleOptions;
		return 1;
	}

	// used by the module manager to access Qt components, TODO maybe move to module manager?
	QApplication app (argc,argv);

	ModuleManager mm;
	Configuration conf;

	if (vm.count("configuration")){
	// run a processing chain from a config file.
	// ./uipf -c example.yam

		// loads the configFile and create a Configuration
		string configFileName = argv[2];
		conf.load(configFileName);


	} else{
	// run a single module.
	// ./uipf <moduleName> ...options...

		if (vm.count("version")) {
			cout << "Version: 1.0" << "\n";
			return 0;
		}

		if (vm.count("help")) {
			cout << "Usage:" << endl;
			cout << argv[0] << " -c <path to configuration file>				run a processing chain from a config file." << endl;
			cout << argv[0] << " <moduleName> -i <input> [-p <params> -o <output>]	run a single module." << endl;
			cout << "\n";
			cout << visibleOptions;
			return 0;
		}

		if (!vm.count("modulename") || !vm.count("input")){
			std::cerr << "Usage Error!\n\n";
			cout << "Usage:" << endl;
			cout << argv[0] << " -c <path to configuration file>				run a processing chain from a config file." << endl;
			cout << argv[0] << " <moduleName> -i <input> [-p <params> -o <output>]	run a single module." << endl;
			cout << "\n";
			// show help
			cout << visibleOptions;
			return 1;
		}

		string modName = vm["modulename"].as<string>();
		if (!mm.hasModule(modName)) {
			LOG_E("Module " + modName + " does not exist!");
			return 1;
		}
		MetaData md = mm.getModuleMetaData(modName);

		ProcessingStep processModule;
		processModule.name = "processModule";
		processModule.module = modName;

		if (vm.count("input")) {
			vector<string> inputs = vm["input"].as< vector<string> >();
			// this step is repeated as often, as the number of load modules is created
			for (unsigned int i=0; i<inputs.size(); i++){
				ProcessingStep loadModule;
				loadModule.name = "loadModule" + to_string(i);
				loadModule.module = "loadImage";

				string source = utils::secondPart(inputs[i]);

				loadModule.params.insert (pair<string,string>("filename",source) );

				conf.addProcessingStep(loadModule);

				// the input params of the module are set
				map<string, DataDescription> in = md.getInputs();
				string name;
				// if there is only one input, the name is optional on the command line, will be taken from metadata
				if (in.size() == 1) {
					auto it = in.cbegin();
					name = it->first;
				} else {
					name = utils::firstPart(inputs[i]);
				}
				pair<string,string> loadWithValue(loadModule.name, "image");

				processModule.inputs.insert(pair<string, pair<string, string> >(name, loadWithValue));
			}

			// if only one input, create an output automatically, if none is given explicitly
			if (inputs.size() == 1 && vm.count("output") == 0){
				map<string, DataDescription> out = md.getOutputs();
				// if only one output exists
				if(out.size() ==1){

					auto it = out.cbegin();
					string outName = it->first;

					pair<string, string> storeSource(processModule.name,outName);

					ProcessingStep storeModule;
					storeModule.name = "storeModule";
					storeModule.module = "storeImage";

					// where does the image come from
					storeModule.inputs.insert (pair<string, pair<string, string> >("image", storeSource));

					// where should it be stored
					string newName = utils::rename(utils::secondPart(inputs[0]));
					storeModule.params.insert (pair<string,string>("filename", newName));

					conf.addProcessingStep(storeModule);
				}
			}

		}


		if (vm.count("output")) {

			map<string, DataDescription> out = md.getOutputs();

			vector<string> outputs = vm["output"].as< vector<string> >();
			// this step is repeated as often, as the number of store modules is created
			for (unsigned int i=0; i<outputs.size(); i++){

				// if there is only one output, the name is optional on the command line, will be taken from metadata
				string outName;
				if (out.size() == 1) {
					auto it = out.cbegin();
					outName = it->first;
				} else {
					outName = utils::firstPart(outputs[i]);
				}

				pair<string, string> storeSource(processModule.name, outName);

				ProcessingStep storeModule;
				storeModule.name = "storeModule" + to_string(i);
				storeModule.module = "storeImage";

				// where does the image come from
				storeModule.inputs.insert (pair<string, pair<string, string> >("image",storeSource) );
				// where should it be stored
				string storeName = utils::secondPart(outputs[i]);
				storeModule.params.insert (pair<string,string>("filename",storeName) );

				conf.addProcessingStep(storeModule);

			}
		}


		if (vm.count("param")) {

			vector<string> params = vm["param"].as< vector<string> >();
			// this step is repeated as often, as the number of params is inserted
			for (unsigned int i=0; i<params.size(); i++){

				processModule.params.insert (pair<string,string>(utils::firstPart(params[i]), utils::secondPart(params[i])));

			}
		}

		conf.addProcessingStep(processModule);
	}

	// print the loaded config
	LOG_I("Here is the loaded configuration:");
	conf.print();

	// validate configuration and show errors
	pair< vector<string>, vector<string> > errors = conf.validate(mm.getAllModuleMetaData());
	if (!errors.first.empty()) {
		LOG_E("There are configuration errors!");
		for(unsigned int i = 0; i < errors.first.size(); ++i) {
			LOG_E(errors.first[i]);
		}
		return 1;
	}

	// run the current configuration
	mm.run(conf);

	return 0;
}
Example #14
0
GF::GF()
{
  gst_init (NULL, NULL);
  moduleManager.loadModulesFromDirectories ("../../src/server");
}
Example #15
0
 static nodes_iterator nodes_end(const ModuleManager &Manager) {
   return Manager.end();
 }
Example #16
0
 static nodes_iterator nodes_begin(const ModuleManager &Manager) {
   return Manager.begin();
 }
Example #17
0
void ModuleManager::ensureModuleLoaded(const std::string& moduleName)
{
    ModulePtr module = g_modules.getModule(moduleName);
    if(!module || !module->load())
        g_logger.fatal(stdext::format("Unable to load '%s' module", moduleName));
}
Example #18
0
void ModuleManager::ensureModuleLoaded(const std::string& moduleName)
{
    ModulePtr module = g_modules.getModule(moduleName);
    if(!module || !module->load())
        logFatal("Unable to load '", moduleName, "' module");
}
Example #19
0
GF::GF()
{
  gst_init(nullptr, nullptr);
  moduleManager.loadModulesFromDirectories ("../../src/server");
}
Example #20
0
void loadModules (const std::string &path)
{
  moduleManager.loadModulesFromDirectories (path);
}
Example #21
0
 void ContentManager::initialize(ModuleManager& manager)
 {
    mModules = manager.filter(ModuleKind::eContentModule);
 }