Exemplo n.º 1
0
        // 创建录像目录,启动工作线程,可能抛出异常!
        public RecordTask(RecordStartParam param)
        {
            Param = param;

            // 录像存储目录,应该通过外部设置获取
            string record_path = ".\\";

            if (config.ContainsKey("record_path"))
            {
                record_path = config["record_path"];
            }

            BatchFile = @"c:\zonekey.config\RecordingLivingcastServer\ts_upload.bat";
            if (config.ContainsKey("task_script"))
            {
                BatchFile = config["task_script"];
            }

            DirectoryInfo di = new DirectoryInfo(record_path); //

            RecordingPath  = di.FullName + "\\";
            TaskPath       = RecordingPath + Param.uuid;
            ScriptFilename = RecordingPath + Param.uuid + ".lftp";
            string cpath = winpath_2_cygpath(ScriptFilename);

            Directory.CreateDirectory(TaskPath);

            Quit = false;
            th   = new Thread(new ThreadStart(proc_run));
            th.Start();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 启动直播
        /// </summary>
        /// <param name="param"></param>
        public LivingcastTask(LivingcastStartParam param)
        {
            StartParam = param;

            if (!config.ContainsKey("fms_ip"))
            {
                config["fms_ip"] = "127.0.0.1";
            }

            if (!config.ContainsKey("cloud_ip"))
            {
                config["cloud_ip"] = "127.0.0.1";
            }

            if (!config.ContainsKey("cloud_port"))
            {
                config["cloud_port"] = "80";
            }

            if (!config.ContainsKey("teacher"))
            {
                config["teacher"] = "admin";
            }

            if (!config.ContainsKey("grade"))
            {
                config["grade"] = "";
            }

            if (!config.ContainsKey("domain"))
            {
                config["domain"] = "space.whhc";
            }

            if (!config.ContainsKey("device_id"))
            {
                config["device_id"] = "000000000000";
            }

            if (!config.ContainsKey("title"))
            {
                config["title"] = "互动";
            }

            Streams = new List <LivingcastStream>();
            foreach (LivingcastStreamDesc desc in param.streams)
            {
                string rtmp_url = build_rtmp_livingcast_url(param.mcu_cid, desc);
                Streams.Add(new LivingcastStream(param.mcu_jid, param.mcu_cid, desc.aid, desc.vid, rtmp_url));
            }

            // 发布到nabo平台
            SendStart(param.uuid);

            th_ = new Thread(new ParameterizedThreadStart(proc_HeartBeat));
            th_.Start(new Params()
            {
                machine_id = config["device_id"], uuid = param.uuid,
            });
        }
Exemplo n.º 3
0
        NaboConfig()
        {
            //  使用配置文件
            cfg_ = new KVConfig(cfg_file_);

            DeviceID = "000000000000";
            if (cfg_.ContainsKey("device_id"))
            {
                DeviceID = cfg_["device_id"];
            }
            Grade = "";
            if (cfg_.ContainsKey("grade"))
            {
                Grade = cfg_["grade"];
            }
            Domain = "space.whhc";
            if (cfg_.ContainsKey("domain"))
            {
                Domain = cfg_["domain"];
            }
            Teacher = "Admin";
            if (cfg_.ContainsKey("teacher"))
            {
                Teacher = cfg_["teacher"];
            }
            Title = "互动录像";
            if (cfg_.ContainsKey("title"))
            {
                Title = cfg_["title"];
            }
            FtpPath = "ftp://*****:*****@172.16.1.10/shared";
            if (cfg_.ContainsKey("ftppath"))
            {
                FtpPath = cfg_["ftppath"];
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 工作线程,启动 httpListener ....
        /// </summary>
        void proc_run()
        {
            evt_.Set();

            int port = 3300;

            if (config_.ContainsKey("server_port"))
            {
                BindingUrl = "http://*:" + config_["server_port"] + "/";
                port       = int.Parse(config_["server_port"]);
            }

            Log.log("HttpServer starting at port=" + port);

            MseService.Instance(port);

            HttpListener listener = new HttpListener();

            listener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
            listener.Prefixes.Add(BindingUrl);
            try
            {
                listener.Start();
                Console.WriteLine("启动服务,使用 " + BindingUrl);
                Log.log("        ok");
            }
            catch (Exception e)
            {
                Console.WriteLine("[MyHttpServer] to start " + BindingUrl + " exception: " + e.Message);
                Log.log("HttpServer start ERR: msg=" + e.Message);

                throw new Exception("启动失败,请检查日志");
            }

            Console.WriteLine("[MyHttpServer] starting " + BindingUrl + " OK!");

            bool quit = false;

            do
            {
                HttpListenerContext  ctx = listener.GetContext();
                HttpListenerRequest  req = ctx.Request;
                HttpListenerResponse res = ctx.Response;

                if (req.Url.AbsolutePath == "/cmd/killme")
                {
                    quit = true;

                    try {
                        res.StatusCode = 200;
                        StreamWriter sw = new StreamWriter(res.OutputStream);
                        sw.Write("OK: server will be killed.");
                        sw.Close();
                        //res.Close();
                    }
                    catch { }
                }
                else
                {
                    Handler(req, res);
                    res.Close();
                }
            } while (!quit);
        }