Beispiel #1
0
        public void Begin()
        {
            try
            {
                log.Debug("Starting processoring");
                config = ConfigurationManager.AppSettings;
                host   = ConfigurationManager.AppSettings["bindhost"];
                port   = int.Parse(ConfigurationManager.AppSettings["bindport"]);
                stats  = new Stats();
                //BT = new BatchTranscoder();
                //LS = new ListenServer(host, port, BT);
                presets = new Presets();
                Dictionary <string, IHttpRequestHandler> handlers = new Dictionary <string, IHttpRequestHandler>();

                jobs = new ConcurrentDictionary <string, TranscodeJob>();

                expireCancelToken = new CancellationTokenSource();
                TaskExecutorFactory.Begin(ExpireJobs, 300000, 100, Timeout.Infinite, -1, expireCancelToken.Token);

                transcodingPool = new Sprite.ThreadPool(int.Parse(ConfigurationManager.AppSettings["maxtasks"]), Sprite.WaitStrategy.MODERATE);


                Directory.CreateDirectory(FFRest.config["file-root"] + Path.DirectorySeparatorChar + FFRest.config["thumb-destination"]);
                Directory.CreateDirectory(FFRest.config["file-root"] + Path.DirectorySeparatorChar + FFRest.config["video-destination"]);


                // Initialize all the endpoint handlers
                var jobHandler      = new JobHandler(jobs, transcodingPool);
                var presetHandler   = new PresetHandler(presets);
                var thumbHandler    = new ThumbnailHandler();
                var adaptiveHandler = new AdaptiveHandler(jobHandler.Jobs);
                var metaHandler     = new MetaHandler();
                var videoHandler    = new VideoHandler();
                handlers.Add("/stats", stats);
                handlers.Add("/jobs", jobHandler);
                handlers.Add("/presets", presetHandler);
                handlers.Add("/thumbs", thumbHandler);
                handlers.Add("/videos", videoHandler);
                handlers.Add("/playlist", adaptiveHandler);
                handlers.Add("/metadata", metaHandler);
                Server server = new Server(host, port, handlers);


                //server = new Httpd(5120, handlers);
                thread = new Thread(new ThreadStart(server.Listen));
                thread.Start();
                transcodingPool.StartPool();
            }
            catch (Exception ex)
            {
                log.Fatal("A fatal exception has occured", ex);
            }
        }
Beispiel #2
0
        public void Begin()
        {
            try
            {
                log.Debug("Starting processoring");
                config = ConfigurationManager.AppSettings;
                host = ConfigurationManager.AppSettings["bindhost"];
                port = int.Parse(ConfigurationManager.AppSettings["bindport"]);
                stats = new Stats();
                //BT = new BatchTranscoder();
                //LS = new ListenServer(host, port, BT);
                presets = new Presets();
                Dictionary<string, IHttpRequestHandler> handlers = new Dictionary<string, IHttpRequestHandler>();

                jobs = new ConcurrentDictionary<string, TranscodeJob>();

                expireCancelToken = new CancellationTokenSource();
                TaskExecutorFactory.Begin(ExpireJobs, 300000, 100, Timeout.Infinite, -1, expireCancelToken.Token);

                transcodingPool = new Sprite.ThreadPool(int.Parse(ConfigurationManager.AppSettings["maxtasks"]), Sprite.WaitStrategy.MODERATE);

                Directory.CreateDirectory(FFRest.config["file-root"] + Path.DirectorySeparatorChar + FFRest.config["thumb-destination"]);
                Directory.CreateDirectory(FFRest.config["file-root"] + Path.DirectorySeparatorChar + FFRest.config["video-destination"]);

                // Initialize all the endpoint handlers
                var jobHandler = new JobHandler(jobs, transcodingPool);
                var presetHandler = new PresetHandler(presets);
                var thumbHandler = new ThumbnailHandler();
                var adaptiveHandler = new AdaptiveHandler(jobHandler.Jobs);
                var metaHandler = new MetaHandler();
                var videoHandler = new VideoHandler();
                handlers.Add("/stats", stats);
                handlers.Add("/jobs", jobHandler);
                handlers.Add("/presets", presetHandler);
                handlers.Add("/thumbs", thumbHandler);
                handlers.Add("/videos", videoHandler);
                handlers.Add("/playlist", adaptiveHandler);
                handlers.Add("/metadata", metaHandler);
                Server server = new Server(host, port, handlers);

                //server = new Httpd(5120, handlers);
                thread = new Thread(new ThreadStart(server.Listen));
                thread.Start();
                transcodingPool.StartPool();
            }
            catch (Exception ex)
            {
                log.Fatal("A fatal exception has occured", ex);
            }
        }