示例#1
0
        public void ptzControl(int cmd, string puId, int channelNo, BVCU_PTZ_MOVE move, int presetNo = 0)
        {
            Channel channel = m_session.getChannel(puId, channelNo);

            if (channel == null)
            {
                return;
            }
            BVCU_PUCFG_PTZControl ptzCtrl = new BVCU_PUCFG_PTZControl();

            ptzCtrl.bStop       = (int)move;
            ptzCtrl.iPTZCommand = cmd;
            ptzCtrl.iParam3     = ptzCtrl.iParam2 = ptzCtrl.iParam1 = 0;
            switch (cmd)
            {
            case BVCU.BVCU_PTZ_COMMAND.LEFT:
            case BVCU.BVCU_PTZ_COMMAND.RIGHT:
            case BVCU.BVCU_PTZ_COMMAND.UP:
            case BVCU.BVCU_PTZ_COMMAND.DOWN:
                ptzCtrl.iParam2 = m_ptzSpeed;
                break;

            case BVCU.BVCU_PTZ_COMMAND.LEFTDOWN:
            case BVCU.BVCU_PTZ_COMMAND.LEFTTOP:
            case BVCU.BVCU_PTZ_COMMAND.RIGHTDOWN:
            case BVCU.BVCU_PTZ_COMMAND.RIGHTTOP:
                ptzCtrl.iParam1 = ptzCtrl.iParam2 = m_ptzSpeed;
                break;

            case BVCU.BVCU_PTZ_COMMAND.PRESET_GO:
                ptzCtrl.iParam1 = presetNo;
                ptzCtrl.iParam2 = ptzCtrl.iParam3 = m_ptzSpeed;
                break;

            case BVCU.BVCU_PTZ_COMMAND.CRUISE_GO:
                ptzCtrl.iParam1 = presetNo;
                break;

            default:
                break;
            }
            IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BVCU_PUCFG_PTZControl)));

            Marshal.StructureToPtr(ptzCtrl, pt, true);
            BVCU.ManagedLayer_CuSetPuPtzControl(m_bvcuSdkHandle, m_session.Handle, Encoding.UTF8.GetBytes(puId), channel.ptzIdx, pt);
        }