private bool NormalizeApplication(ApplicationSection appConfig) { var name = appConfig.AppName; var node = new Variant { { "name", name } }; if (!string.IsNullOrEmpty(appConfig.Master)) node["master"] = appConfig.Master; var temp = ""; if (string.IsNullOrEmpty(name)) { FATAL("Invalid application name"); return false; } if (_uniqueNames.Contains(name)) { FATAL("Application name {0} already taken", name); return false; } _uniqueNames.Add(name); string appDir = appConfig.AppDir; if (string.IsNullOrEmpty(appDir)) appDir = _rootAppFolder + name; temp = appDir.NormalizePath(); if (temp.Equals(string.Empty)) WARN("path not found:{0}", appDir); else appDir = temp; if (appDir.Last() != Path.DirectorySeparatorChar) appDir += Path.DirectorySeparatorChar; node[CONF_APPLICATION_DIRECTORY] = appDir; string mediaFolder = appConfig.MediaFolder; if (!string.IsNullOrEmpty(mediaFolder)) { temp = mediaFolder.NormalizePath(); if (temp.Equals(string.Empty)) { WARN("path not found:{0}", mediaFolder); try { Directory.CreateDirectory(mediaFolder); } catch (Exception) { FATAL("can't create mediafolder"); } } else mediaFolder = temp; if (mediaFolder.Last() != Path.DirectorySeparatorChar) mediaFolder += Path.DirectorySeparatorChar; node[CONF_APPLICATION_MEDIAFOLDER] = mediaFolder; } string libraryPath = appConfig.LibraryPath; if (string.IsNullOrEmpty(libraryPath)) libraryPath = appDir + name + ".dll"; temp = libraryPath.NormalizePath(); if (temp.Equals(string.Empty)) { if (_staticGetApplicationFunction == null || _staticGetFactoryFunction == null) { WARN("Library not found:{0}", libraryPath); //return false; } temp = libraryPath; } libraryPath = temp; node[CONF_APPLICATION_LIBRARY] = libraryPath; //if (string.IsNullOrEmpty(node[CONF_APPLICATION_INIT_APPLICATION_FUNCTION])) node[CONF_APPLICATION_INIT_APPLICATION_FUNCTION] = "GetApplication_" + name; //if (string.IsNullOrEmpty(node[CONF_APPLICATION_INIT_FACTORY_FUNCTION])) node[CONF_APPLICATION_INIT_FACTORY_FUNCTION] = "GetFactory_" + name; //if (node[CONF_APPLICATION_VALIDATEHANDSHAKE] == null) // node[CONF_APPLICATION_VALIDATEHANDSHAKE] = true; //if (node[CONF_APPLICATION_DEFAULT] == null) // node[CONF_APPLICATION_DEFAULT] = false; //if (node[CONF_APPLICATION_GENERATE_METFILES] == null) // node[CONF_APPLICATION_GENERATE_METFILES] = false; node[CONF_APPLICATION_KEYFRAMESEEK] = appConfig.KeyFrameSeek; //if (node[CONF_APPLICATION_RENAMEBADFILES] == null) // node[CONF_APPLICATION_RENAMEBADFILES] = false; //if (node[CONF_APPLICATION_EXTERNSEEKGENERATOR] == null) // node[CONF_APPLICATION_EXTERNSEEKGENERATOR] = false; var seekGranularity = appConfig.SeekGranularity; if (seekGranularity < 0 || seekGranularity > 300)seekGranularity = 1; node[CONF_APPLICATION_SEEKGRANULARITY] = seekGranularity; var clientSideBuffer = appConfig.ClientSideBuffer; if (clientSideBuffer < 0 || clientSideBuffer > 300)clientSideBuffer = 5; node[CONF_APPLICATION_CLIENTSIDEBUFFER] = clientSideBuffer; node[CONF_APPLICATION_RTCPDETECTIONINTERVAL] = appConfig.RtcpDetectionInterval>=60?60:appConfig.RtcpDetectionInterval; if (appConfig.Acceptors.Count > 0) { var acceptors = new Variant(); node["acceptors"] = acceptors; foreach (Acceptor acceptor in appConfig.Acceptors) { var acceptorVariant = new Variant { {"ip", acceptor.Ip}, {"port", acceptor.Port}, {"protocol", acceptor.Protocol} }; node["acceptors"].Add(acceptorVariant); if (NormalizeApplicationAcceptor(acceptorVariant, appDir)) continue; FATAL("Invalid acceptor in {0}", appDir); return false; } } //var aliases = node[CONF_APPLICATION_ALIASES]; //if (aliases == null||aliases.Children.Values.All(x => _uniqueNames.Add( x))) return true; //FATAL("Alias name is already taken"); _applications.Add(node); return true; }