示例#1
0
        private void setDvrOnorOff(StreamDvrPlan sdp, bool eanble)
        {
            var dvr = VhostDvrApis.GetVhostDvr(sdp.DeviceId, sdp.VhostDomain, out ResponseStruct rs);

            if (dvr != null)
            {
                string?       dvrApply   = dvr.Dvr_apply !;
                List <string> dvrStreams = new List <string>();
                if (!string.IsNullOrEmpty(dvrApply))
                {
                    dvrStreams = Regex.Split(dvrApply, @"[\s]+").ToList();
                }


                if (dvrStreams.Count == 0)
                {
                    dvrStreams.Add("");
                }

                for (int i = 0; i <= dvrStreams.Count - 1; i++)
                {
                    dvrStreams[i] = dvrStreams[i].TrimEnd(';').Trim();
                }

                bool needWrite = false;
                switch (eanble)
                {
                case true:
                    if (!dvrStreams.Contains((sdp.App + "/" + sdp.Stream).Trim()))
                    {
                        dvrStreams.Add((sdp.App + "/" + sdp.Stream).Trim());
                        needWrite = true;
                    }

                    break;

                case false:
                    if (dvrStreams.Contains((sdp.App + "/" + sdp.Stream).Trim()))
                    {
                        dvrStreams.Remove((sdp.App + "/" + sdp.Stream).Trim());
                        needWrite = true;
                    }

                    break;
                }

                if (needWrite)
                {
                    dvr.Dvr_apply = "";
                    foreach (var str in dvrStreams)
                    {
                        dvr.Dvr_apply += str + "\t";
                    }

                    dvr.Dvr_apply = dvr.Dvr_apply.TrimEnd('\t');
                    VhostDvrApis.SetVhostDvr(sdp.DeviceId, sdp.VhostDomain, dvr, out rs);
                    SystemApis.RefreshSrsObject(sdp.DeviceId, out rs);
                }
            }
        }
示例#2
0
        private void doThing(string deviceId, string vhostDomain, Ingest ingest)
        {
            LogWriter.WriteLog("重启设备ID" + deviceId + "下的" + vhostDomain + "下的" + ingest.IngestName + " Ingest");

            lock (SrsManageCommon.Common.LockDbObjForOnlineClient)
            {
                OrmService.Db.Delete <OnlineClient>().Where(x => x.RtspUrl == ingest.Input !.Url).ExecuteAffrows();
            }

            var retInt = foundProcess(ingest);

            if (retInt > -1)
            {
                try
                {
                    string cmd = "kill -9 " + retInt.ToString();
                    LinuxShell.Run(cmd, 1000);
                }
                catch (Exception ex)
                {
                    LogWriter.WriteLog(
                        "重启设备ID" + deviceId + "下的" + vhostDomain + "下的" + ingest.IngestName + " Ingest失败",
                        ex.Message + "\r\n" + ex.StackTrace, ConsoleColor.Yellow);
                }
            }

            ResponseStruct rs = null !;

            VhostIngestApis.OnOrOffIngest(deviceId, vhostDomain, ingest.IngestName !, false, out rs);
            SystemApis.RefreshSrsObject(deviceId, out rs);
            Thread.Sleep(1000);
            VhostIngestApis.OnOrOffIngest(deviceId, vhostDomain, ingest.IngestName !, true, out rs);
            SystemApis.RefreshSrsObject(deviceId, out rs);
        }
示例#3
0
        public JsonResult RefreshSrsObject(string deviceId)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { deviceId });

            if (rss.Code != ErrorNumber.None)
            {
                return(Program.CommonFunctions.DelApisResult(null !, rss));
            }

            var rt = SystemApis.RefreshSrsObject(deviceId, out ResponseStruct rs);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }