Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        public JsonResult GetVhostIngestNameList(string deviceId, string vhostDomain = "")
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { deviceId, vhostDomain });

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

            var rt = VhostIngestApis.GetVhostIngestNameList(deviceId, out ResponseStruct rs, vhostDomain);

            return(Program.CommonFunctions.DelApisResult(rt, rs));
        }
Ejemplo n.º 3
0
        private void completionOnvifIpAddress()
        {
            if (Common.SrsManagers != null)
            {
                foreach (var srs in Common.SrsManagers)
                {
                    if (srs.IsInit && srs.Srs != null && srs.IsRunning)
                    {
                        var ret = VhostIngestApis.GetVhostIngestNameList(srs.SrsDeviceId, out ResponseStruct rs);
                        if (ret != null)
                        {
                            foreach (var r in ret)
                            {
                                var ingest = VhostIngestApis.GetVhostIngest(srs.SrsDeviceId, r.VhostDomain !,
                                                                            r.IngestInstanceName !,
                                                                            out rs);

                                if (ingest != null)
                                {
                                    string inputIp =
                                        SrsManageCommon.Common
                                        .GetIngestRtspMonitorUrlIpAddress(ingest.Input !.Url !) !;
                                    if (SrsManageCommon.Common.IsIpAddr(inputIp !))
                                    {
                                        lock (SrsManageCommon.Common.LockDbObjForOnlineClient)
                                        {
                                            var reti = OrmService.Db.Update <OnlineClient>()
                                                       .Set(x => x.MonitorIp, inputIp)
                                                       .Set(x => x.RtspUrl, ingest.Input !.Url !)
                                                       .Where(x => x.Stream !.Equals(ingest.IngestName) &&
                                                              x.Device_Id !.Equals(srs.SrsDeviceId) &&
                                                              (x.MonitorIp == null || x.MonitorIp == "" ||
                                                               x.MonitorIp == "127.0.0.1"))
                                                       .ExecuteAffrows();
                                            if (reti > 0)
                                            {
                                                LogWriter.WriteLog("补全Ingest拉流器中的摄像头IP地址...",
                                                                   srs.SrsDeviceId + "/" + r.VhostDomain + "/" + ingest.IngestName +
                                                                   " 获取到IP:" + inputIp + " 获取到Rtsp地址:" + ingest.Input !.Url);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public JsonResult DeleteVhostIngestByIngestInstanceName(string deviceId, string vhostDomain,
                                                                string ingestInstanceName)
        {
            ResponseStruct rss = CommonFunctions.CheckParams(new object[] { deviceId, vhostDomain, ingestInstanceName });

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

            var rt = VhostIngestApis.DeleteVhostIngestByIngestInstanceName(deviceId, vhostDomain, ingestInstanceName,
                                                                           out ResponseStruct rs);

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