示例#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();
        }
示例#2
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();
        }
示例#3
0
        static RecordStartParam parseRecordStartNode(XmlElement node)
        {
            RecordStartParam param = new RecordStartParam();

            System.Diagnostics.Debug.Assert(node.Name == "cmd");
//            XmlNode uuid = node.SelectSingleNode("uuid");
//            XmlNode subject = node.OwnerDocument.SelectSingleNode("/zonekey/cmd/subject");
//            XmlNode files = node.OwnerDocument.SelectSingleNode("/zonekey/cmd/files");

            XmlNode uuid = null, subject = null, files = null;

            foreach (XmlNode c in node.ChildNodes)
            {
                if (c.Name == "uuid")
                {
                    uuid = c;
                }
                else if (c.Name == "subject")
                {
                    subject = c;
                }
                else if (c.Name == "files")
                {
                    files = c;
                }
            }

            if (uuid != null && subject != null && files != null)
            {
                param.uuid    = uuid.InnerText;
                param.subject = subject.InnerText;
                param.files   = new List <RecordFileDesc>();
                foreach (XmlNode file in files.ChildNodes)
                {
                    RecordFileDesc d = parseFileDesc(file);
                    if (d != null)
                    {
                        param.files.Add(d);
                    }
                }
                return(param);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        static RecordStartParam parseRecordStartNode(XmlElement node)
        {
            RecordStartParam param = new RecordStartParam();
            System.Diagnostics.Debug.Assert(node.Name == "cmd");
            //            XmlNode uuid = node.SelectSingleNode("uuid");
            //            XmlNode subject = node.OwnerDocument.SelectSingleNode("/zonekey/cmd/subject");
            //            XmlNode files = node.OwnerDocument.SelectSingleNode("/zonekey/cmd/files");

            XmlNode uuid = null, subject = null, files = null;
            foreach (XmlNode c in node.ChildNodes)
            {
                if (c.Name == "uuid")
                    uuid = c;
                else if (c.Name == "subject")
                    subject = c;
                else if (c.Name == "files")
                    files = c;
            }

            if (uuid != null && subject != null && files != null)
            {
                param.uuid = uuid.InnerText;
                param.subject = subject.InnerText;
                param.files = new List<RecordFileDesc>();
                foreach (XmlNode file in files.ChildNodes)
                {
                    RecordFileDesc d = parseFileDesc(file);
                    if (d != null)
                        param.files.Add(d);
                }
                return param;
            }
            else
            {
                return null;
            }
        }
示例#5
0
        public static void Start(HttpListenerRequest req, HttpListenerResponse res)
        {
            string     command, mcu_jid;
            int        mcu_cid;
            XmlElement node;

            string body_b64 = Utility.BodyFromStream.read(req.InputStream, req.ContentLength64, Encoding.ASCII);
            string body     = Encoding.UTF8.GetString(Convert.FromBase64String(body_b64));

            if (body == null)
            {
                Console.WriteLine("Record.Start: Net broken!");
                return;
            }

            Log.log("Record_Start: xml=" + body);

            if (Utility.BodyParser.parse(body, out command, out node, out mcu_jid, out mcu_cid))
            {
                // 需要继续解析 node, 格式为:

                /*
                 *      <cmd command="record_start">
                 *          <uuid>xxxx-xxx...</uuid>        // 录像目录,上传时,将上传整个 uuid 的目录,这个 uuid 将与直播时的 uuid 一致
                 *          <subject>......</subject>       // 互动描述
                 *          <members>
                 *              <caller>...</caller>            // 主讲 ..
                 *              <callee>...</callee>            // 听讲,可能多个
                 *              <callee>...</callee>
                 *          </members>
                 *          <files>
                 *              <file>             // 描述一个录像文件
                 *                  <aid>xx</aid>   // 音频 id
                 *                  <vid>xx</vid>   // 视频 id
                 *                  <desc>....</desc>       // 录像描述
                 *                  <name> ...</name>       // 录像文件名字
                 *                  ....                    // ...
                 *              </file>
                 *              <file>
                 *              </file>
                 *              ....
                 *          </files>
                 *      </cmd>
                 */
                RecordStartParam param = parseRecordStartNode(node);
                if (param == null)
                {
                    format_error(res);
                    return;
                }

                param.mcu_cid = mcu_cid;
                param.mcu_jid = mcu_jid;

                // 检查录像是否已经启动
                lock (RecordingTasks)
                {
                    if (RecordingTasks.ContainsKey(mcu_cid))
                    {
                        already_recording_error(res, mcu_cid);
                        return;
                    }

                    // 启动录像任务
                    try
                    {
                        RecordingTasks.Add(mcu_cid, new RecordTask(param));
                        done(res, "");
                    }
                    catch
                    {
                        failure_error(res);
                    }
                }
            }
            else
            {
                format_error(res);
            }
        }