Пример #1
0
        private void MenuNVSPlayer_OnClick(object sender, RoutedEventArgs e)
        {
            //因为dll是64位的,程序生成也要是64位的,幸亏没有引用其他32位的dll

            //NVSPlayerForm form = new NVSPlayerForm();
            //form.Show();

            //NVSSDK.NetClient_Startup_V4(0, 0, 0);

            //NVRPlayerClientWindow window = new NVRPlayerClientWindow();
            //window.Show()

            NVSManage.RTMP_Host = ConfigurationHelper.GetValue("RTMP_Host");

            NVSManage.NVRIP   = ConfigurationHelper.GetValue("NVRIP");
            NVSManage.NVRPort = ConfigurationHelper.GetValue("NVRPort");
            NVSManage.NVRUser = ConfigurationHelper.GetValue("NVRUser");
            NVSManage.NVRPass = ConfigurationHelper.GetValue("NVRPass");
            NVSManage.Init();//启动天地伟业Playback界面

            string nginx = AppDomain.CurrentDomain.BaseDirectory + "\\nginx-1.7.11.3-Gryphon\\restart-rtmp.bat";

            if (File.Exists(nginx))
            {
                nginxCmdProcess = Process.Start(nginx);//启动nginx-rtmp
            }
            else
            {
                //WriteLog("找不到nginx启动文件:" + nginx);
            }
        }
Пример #2
0
        public void StartPlayBackManage()
        {
            var EnabelNVS = ConfigurationHelper.GetBoolValue("EnabelNVS");

            if (EnabelNVS)
            {
                NVSManage.RTMP_Host = ConfigurationHelper.GetValue("RTMP_Host");

                NVSManage.NVRIP   = ConfigurationHelper.GetValue("NVRIP");
                NVSManage.NVRPort = ConfigurationHelper.GetValue("NVRPort");
                NVSManage.NVRUser = ConfigurationHelper.GetValue("NVRUser");
                NVSManage.NVRPass = ConfigurationHelper.GetValue("NVRPass");
                NVSManage.Init();//启动天地伟业Playback界面

                string nginx = AppDomain.CurrentDomain.BaseDirectory + "\\nginx-1.7.11.3-Gryphon\\restart-rtmp.bat";
                if (File.Exists(nginx))
                {
                    nginxCmdProcess = Process.Start(nginx);//启动nginx-rtmp
                }
                else
                {
                    WriteLog("找不到nginx启动文件:" + nginx);
                }
            }
        }
 public DownloadInfo StopGetNVSVideo(DownloadInfo info)
 {
     try
     {
         Log.Info("NVS", "StopGetNVSVideo:" + info);
         NVSManage.GetPlayBackFormEx(info.Ip, (f, s) => { f.Stop(); });
         return(info);
     }
     catch (Exception e)
     {
         Log.Error("NVS", "LocationService.StopGetNVSVideo:" + ToString());
         return(null);
     }
 }
        public DownloadInfo StartGetNVSVideo(DownloadInfo info)
        {
            try
            {
                Log.Info("NVS", "StartGetNVSVideo:" + info);
                if (info == null)
                {
                    return(null);
                }

                //客户端可以把IP(录像机的IP)和Channel传过来(不用查数据库),也可以只传一个摄像机Id(要查数据库)
                if (string.IsNullOrEmpty(info.Ip) || string.IsNullOrEmpty(info.Channel))
                {
                    Log.Info("NVS", "GetIpAndChannelFormDb");

                    if (!GetIpAndChannelFormDb(info))//GetIpAndChannelFormDb里面会填充Ip和Channel信息,但是没有找到摄像头的话就返回了。
                    {
                        info.Result  = false;
                        info.Message = "camera == null";
                        return(info);
                    }
                }

                Log.Info("NVS", "info:" + info);

                var start = info.StartTime.ToDateTime();
                var end   = info.EndTime.ToDateTime();
                var file  = Downloader.GetFileName(info.Ip, info.Channel, 1, start, end);//视频文件的名称(预订)
                Log.Info("NVS", string.Format("start:{0},end:{1},file:{2}", start, end, file));
                var filePath = AppDomain.CurrentDomain.BaseDirectory + "\\" + file;
                Log.Info("NVS", string.Format("filePath:{0}", filePath));
                if (Downloader.IsFileExist(file))//文件已经存在
                {
                    string url = Downloader.GetHlsUrl(NVSManage.RTMP_Host, file);
                    info.Url     = url;
                    info.Result  = true;
                    info.Message = "ExistFile";
                    Log.Info("NVS", string.Format("ExistFile url:{0}", url));
                }
                else
                {
                    var waitForLogin = true;

                    NVSManage.GetPlayBackFormEx(info.Ip, (form1, loginState) =>
                    {
                        Log.Info("NVS", string.Format("loginState:{0}", loginState));
                        if (loginState)
                        {
                            var channel = info.Channel.ToInt();
                            var r       = form1.Download(channel, start, end);//有文件正在下载的情况
                            info.Result = r;
                            if (r == false)
                            {
                                Log.Error("NVS", form1.Message);
                                info.Message = form1.Message;
                            }
                            else
                            {
                                info.DId = form1.downloader.m_iDLTimeId;//下载用的Id,查询下载进度用
                            }
                        }
                        else
                        {
                            info.Result  = false;
                            info.Message = form1.Message;
                        }
                        waitForLogin = false;
                    });

                    for (int i = 0; i < 300; i++)//等待登录结果
                    {
                        if (waitForLogin == false)
                        {
                            break;
                        }
                        Application.DoEvents();
                        Thread.Sleep(50);//等待登录结果
                    }
                }
                Log.Info("NVS", string.Format("Return:{0}", info));
                return(info);
            }
            catch (Exception e)
            {
                Log.Error("NVS", "LocationService.StartGetNVSVideo:" + e.ToString());
                return(null);
            }
        }
Пример #5
0
        public void StopServices()
        {
            try
            {
                WriteLog("停止服务");
                //StopConnectEngine();
                if (LocationService.u3dositionSP != null)
                {
                    LocationService.u3dositionSP.Stop();
                    LocationService.u3dositionSP = null;
                    WriteLog("停止LocationService.u3dositionSP");
                }
                if (locationServiceHost != null)
                {
                    locationServiceHost.Close();
                    locationServiceHost = null;
                    WriteLog("停止locationServiceHost");
                }
                if (httpHost != null)
                {
                    httpHost.CloseAsync();
                    httpHost = null;
                    WriteLog("停止httpHost");
                }
                if (SignalR != null)
                {
                    SignalR.Dispose();
                    SignalR = null;
                    WriteLog("停止SignalR");
                }

                if (wcfApiHost != null)
                {
                    wcfApiHost.Close();
                    wcfApiHost = null;
                    WriteLog("停止wcfApiHost");
                }

                StopReceiveAlarm();
                StopRemoveAlarm();
                StopLocationAlarmService();
                StopGetInspectionTrack();
                StopExtremeVisionListener();
                StopGetHistoryPositon();

                WriteLog("SisDataSaveClient.Stop");
                SisDataSaveClient.Stop();

                WriteLog("NVSManage.Stop");
                NVSManage.Stop();
                if (nginxCmdProcess != null)
                {
                    nginxCmdProcess.CloseMainWindow();
                }

                if (filterErrorPointThread != null)
                {
                    filterErrorPointThread.Abort();
                    filterErrorPointThread = null;
                }

                StopAnchorScan();
                StopCheckRepeatDev();
                StopDBBackupThread();
            }
            catch (Exception ex)
            {
                WriteLog(ex.ToString());
            }
        }