Example #1
0
        public Form1()
        {
            InitializeComponent();
            SetClassLong(this.Handle, GCL_STYLE, GetClassLong(this.Handle, GCL_STYLE) | CS_DropSHADOW);
            int i = CMSSdk.VM_CMS_Init();

            if (i < 0)
            {
                MessageBox.Show("流媒体初始化失败!");
            }
            else
            {
                CMSSdk.LPCMS_USER_LOGIN_INFO LoginInfo = new CMSSdk.LPCMS_USER_LOGIN_INFO();
                LoginInfo.szIP       = "192.0.0.66";
                LoginInfo.uPort      = 8000;
                LoginInfo.szUser     = "******";
                LoginInfo.szPassword = "******";
                lHandle = CMSSdk.VM_CMS_Login(ref LoginInfo, 0);
                if (lHandle < 0)
                {
                    MessageBox.Show("媒体管理服务器登录失败!");
                }
                else
                {
                    MessageBox.Show("媒体管理服务器登录成功!");
                }
            }
        }
Example #2
0
        string szSID = "ch1";        //视频标识
        public Form2()
        {
            InitializeComponent();
            #region 连接外部数据中心
            //IPAddress ExternalDataCentreService_IP = IPAddress.Parse(ConfigurationManager.AppSettings["ExternalDataCentreService_IP"]);
            //int ExternalDataCentreService_Port1 = int.Parse(ConfigurationManager.AppSettings["ExternalDataCentreService_Port1"]);
            //int ExternalDataCentreService_Port2 = int.Parse(ConfigurationManager.AppSettings["ExternalDataCentreService_Port2"]);

            //IPEndPoint ipe1 = new IPEndPoint(ExternalDataCentreService_IP, ExternalDataCentreService_Port1);
            //clientSocket1 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //clientSocket1.Connect(ipe1);
            //IPEndPoint ipe2 = new IPEndPoint(ExternalDataCentreService_IP, ExternalDataCentreService_Port2);
            //clientSocket2 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //clientSocket2.Connect(ipe2);
            #endregion

            #region 建立socket服务器监听外部数据中心返回值
            int        ListenPort = int.Parse(ConfigurationManager.AppSettings["ListenPort"]);
            IPAddress  ListenIP   = IPAddress.Parse(ConfigurationManager.AppSettings["ListenIP"]);
            IPEndPoint ipe        = new IPEndPoint(ListenIP, ListenPort);
            sSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            sSocket.Bind(ipe);
            sSocket.Listen(0);
            Thread th = new Thread(new ThreadStart(ReveiceData));
            th.IsBackground = true;
            th.Start();
            #endregion
            //初始化流媒体
            //returningValue1 = VMSdk.VM_CLIENT_Init();
            returningValue1 = CMSSdk.VM_CMS_Init();
            CMSSdk.LPCMS_USER_LOGIN_INFO LoginInfo = new CMSSdk.LPCMS_USER_LOGIN_INFO();
            LoginInfo.szIP       = ConfigurationManager.AppSettings["MediaStream_IP"];
            LoginInfo.uPort      = int.Parse(ConfigurationManager.AppSettings["MediaStream_Port"]);
            LoginInfo.szUser     = ConfigurationManager.AppSettings["MediaStream_User"];
            LoginInfo.szPassword = ConfigurationManager.AppSettings["MediaStream_Password"];
            lHandle = CMSSdk.VM_CMS_Login(ref LoginInfo, 0);
            if (lHandle < 0)
            {
                MessageBox.Show("媒体管理服务器登录失败!");
            }
            else
            {
                MessageBox.Show("媒体管理服务器登录成功!");
            }
        }
Example #3
0
        private void LoginMediaServer()
        {
            //单独启动该窗体时需要初始化、登录媒体服务器
            int i = CMSSdk.VM_CMS_Init();

            if (i < 0)
            {
                MessageBox.Show("媒体管理器初始化失败!");
                return;
            }
            CMSSdk.LPCMS_USER_LOGIN_INFO LoginInfo = new CMSSdk.LPCMS_USER_LOGIN_INFO();
            LoginInfo.szIP       = "192.0.0.66";
            LoginInfo.uPort      = 8000;
            LoginInfo.szUser     = "******";
            LoginInfo.szPassword = "******";
            lRet = CMSSdk.VM_CMS_Login(ref LoginInfo, 0);
            if (lRet < 0)
            {
                MessageBox.Show("媒体管理器登录失败!");
                return;
            }
        }
Example #4
0
        private static void Init()
        {
            //绑定服务状态事件
            CommunicationClass.ServiceStatusEvent += CommunicationClass_ServiceStatusEvent;
            //1、初始化通信类
            bool result1 = CommunicationClass.Init();

            if (result1)
            {
                ShowResult("通讯初始化成功!");
                //初始化设备数据
                Class1 class1 = new Class1();
                class1.Init();
                if (Class1.IsDone)
                {
                    NetPing.StateCallback();//状态实时信息
                }
                //报警预案数据初始化
                //ClassPlan classplan = new ClassPlan();
                //classplan.PlanInit();
            }
            else
            {
                ShowResult("通讯初始化失败!");
            }



            //2、流媒体初始化
            //先判断流媒体是否启用
            if (System.Configuration.ConfigurationManager.AppSettings["MediaStream"] == "1")
            {
                int result5 = CMSSdk.VM_CMS_Init();
                if (result5 != -1)
                {
                    ShowResult("流媒体初始化成功!");
                }
                else
                {
                    ShowResult("流媒体初始化失败!");
                }
                CMSSdk.LPCMS_USER_LOGIN_INFO LoginInfo = new CMSSdk.LPCMS_USER_LOGIN_INFO();
                LoginInfo.szIP       = System.Configuration.ConfigurationManager.AppSettings["MediaStream_IP"];
                LoginInfo.uPort      = int.Parse(System.Configuration.ConfigurationManager.AppSettings["MediaStream_Port"]);
                LoginInfo.szUser     = System.Configuration.ConfigurationManager.AppSettings["MediaStream_User"];
                LoginInfo.szPassword = System.Configuration.ConfigurationManager.AppSettings["MediaStream_Password"];
                form1.lHandle        = CMSSdk.VM_CMS_Login(ref LoginInfo, 0);
                if (form1.lHandle < 0)
                {
                    MessageBox.Show("媒体管理服务器登录失败!");
                }
                else
                {
                    MessageBox.Show("媒体管理服务器登录成功!");
                }
            }

            //3、录像初始化
            bool result6 = RecDataClass.Init();

            if (result6)
            {
                ShowResult("SDK初始化成功!");
            }
            else
            {
                ShowResult("SDK初始化失败!");
            }

            //4、报警初始化
            CommunicationClass.AlarmEvent += AlarmOperation.Alarm;
        }