protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            // Register the IUnityContainer so that we can access services from the
            // HTTP server's module handlers.
            ServiceRegistry.RegisterContainer(Container);

            var serializer = new ConfigurationFileSerializer();

            var config      = serializer.Read();
            var sourceMgr   = new FacialDetectionSourceManager(config);
            var sessionMgr  = new RtspSessionManager();
            var rtspHandler = new RtspRequestHandler(sourceMgr, sessionMgr);

            var dispatcher = new DefaultRequestDispatcher();

            dispatcher.RegisterHandler("/stream", rtspHandler);

            var rtspServer = new RtspServer(config.RtspPort, dispatcher);
            var httpServer = new HttpServer(config.HttpPort);

            Container.RegisterInstance(config);
            Container.RegisterInstance(sessionMgr);
            Container.RegisterInstance(rtspServer);
            Container.RegisterInstance(httpServer);
            Container.RegisterInstance <IDetectionSourceManager>(sourceMgr);
            Container.RegisterType <IDataSourcesManager, DataSourcesManager>(new ContainerControlledLifetimeManager());
            Container.RegisterInstance <ISerenityService>(new SerenityService(), new ContainerControlledLifetimeManager());
        }
Esempio n. 2
0
 public bool TryAddRequestHandler(RtspMethod method, RtspRequestHandler handler)
 {
     Exception any;
     if (false == Common.Collections.DictionaryExtensions.TryAdd(m_RequestHandlers, method, handler, out any))
     {
         try { Media.Common.Extensions.Exception.ExceptionExtensions.RaiseTaggedException(this, "Custom Handler already registered", any); }
         catch (Exception ex) { if (Logger != null) Logger.LogException(ex); }
         return false;
     }
     return true;
 }