unit TopseeDemo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,PlatInterfaceLib_TLB,ComObj,RtspPullClientLib_TLB, StdCtrls,
  ComCtrls,msxml,TPPlayerLib_TLB, OleCtrls, ImgList, Menus, ExtCtrls;

type 
    TForm1 = class(TForm)
    Button1: TButton;
    TreeView1: TTreeView;
    TPPlayerAtl1: TTPPlayerAtl;
    BstartAudio: TButton;
    BcapImg: TButton;
    Label1: TLabel;
    BstopPlay: TButton;
    BstartPTZ: TButton;
    Bleft: TButton;
    Btop: TButton;
    Bright: TButton;
    Bdown: TButton;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Eip: TEdit;
    Euser: TEdit;
    Eport: TEdit;
    Epass: TEdit;
    BchangeFullFill: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure  OnInterfaceXMLResp(ASender: TObject; nCode: Integer;  nDataLen: Integer;  const XmlData: WideString);
    procedure TreeView1Click(Sender: TObject);
    function GetAttribute(node:IXMLDOMNode;name:widestring):widestring;
    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    procedure TreeView1DblClick(Sender: TObject);
    procedure OnPlayVideo(xmlData: widestring);
    procedure BstartAudioClick(Sender: TObject);
    procedure BcapImgClick(Sender: TObject);
    procedure TPPlayerAtl1Event(ASender: TObject; eventCode: Integer;const eventDescript: WideString);
    procedure BstopPlayClick(Sender: TObject);
    procedure BstartPTZClick(Sender: TObject);
    function GetXmlNodeByCameraId(camId: WideString):IXMLDOMNode;
    procedure BleftMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
 
    procedure BViewPtzNodeClick(Sender: TObject);
    procedure SendPtz(actionName:widestring);
    procedure BchangeFullFillClick(Sender: TObject);
    procedure BleftMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BtopMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BdownMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BrightMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer); 
    procedure BrightMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BtopMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure BdownMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  objLogin:TPlatInterActive;  
  iObjLogin:IPlatInterActive;
  rtsp:TRtspPullClientCtrl;
  streamid:integer;
  FServer:IComponentRegistrar;
  xmlDoc:IXMLDOMDocument;
  lastSelectNode:TTreeNode;
  m_bInviteVideoFinish:integer;
  strLastInviteCameraId:widestring;
  nVideoType:integer;
  strLastPtzXml:widestring;

implementation

{$R *.dfm}














function TForm1.GetAttribute(node:IXMLDOMNode;name:widestring):widestring;
var
idx:integer;
begin
    if(node<>nil) then
    begin
      for idx:= 0 to node.attributes.length -1 do
      begin
          if(node.attributes[idx].nodeName = name) then
          begin
            Result := node.attributes[idx].nodevalue;
            exit;
          end;
      end;
    end;
end;

















//播放视频
procedure TForm1.OnPlayVideo(xmlData: widestring) ;
var
  tempDoc:IXMLDOMDocument;
  xmlResponseNode:IXMLDOMNode;
  xmlGroupNode:IXMLDOMNode;
  xmlMasterNode:IXMLDOMNode;
  xmlCameraNode:IXMLDOMNode;
  xmlTempNode:IXMLDOMNode;
  DevId:widestring;
  Result:widestring;
  VideoParam:widestring;
  VideoParamLen:widestring;
  nTransPro:widestring;
  LocalPort:widestring;
  VSSCmdIP:widestring;
  VSSCmdPort:widestring;
  SrcInst:widestring;
  ConnType:widestring;
  szMediaType:widestring;
  AudioParam:widestring;
  AudioParamLen:widestring;
  szMcastIP:widestring;
  szMulticastPort:widestring;
  szFsmType:widestring;
  MediaSendPort:widestring;
  videoport:integer;
  vssip:integer;
  vssport:integer;
  iSrcInst:integer;
  iVideoParamLen:integer;
  iMediaSendPort:integer;
  mediatype:integer;
  iaudioParamLen:integer;
  nMulticastIP:integer;
  ErrorCode:integer;
begin
    tempDoc:=CoDOMDocument.Create();
    tempDoc.loadXML(XmlData);
    xmlMasterNode:=tempDoc.firstChild;
    DevId:=GetAttribute(xmlMasterNode,'DevId');//播放的设备ID
    Result:=GetAttribute(xmlMasterNode,'Result');//成功时，此值为0,否则为错误代码

    VideoParam:=GetAttribute(xmlMasterNode,'VideoParam');//视频解码参数
    VideoParamLen:=GetAttribute(xmlMasterNode,'VideoParamLen');//视频解码参数长度
    nTransPro:=GetAttribute(xmlMasterNode,'nTransPro');//是否为TCP连接，如果为１则表示为ＴＣＰ，调用m_pPlayer->SetConnectType进行设置
    LocalPort:=GetAttribute(xmlMasterNode,'LocalPort');//视频端口
    VSSCmdIP:=GetAttribute(xmlMasterNode,'VSSCmdIP');//视频流vss服务器ip
    VSSCmdPort:=GetAttribute(xmlMasterNode,'VSSCmdPort');//vss端口
    SrcInst:=GetAttribute(xmlMasterNode,'SrcInst');//唯一标识符
    ConnType:=GetAttribute(xmlMasterNode,'ConnType');//
    szMediaType:=GetAttribute(xmlMasterNode,'MediaType');////0x0101 后面是视频，前面是音频
    AudioParam:=GetAttribute(xmlMasterNode,'AudioParam');
    AudioParamLen:=GetAttribute(xmlMasterNode,'AudioParamLen');
    szMcastIP:=GetAttribute(xmlMasterNode,'MulticastIP');//组播放IP
    szMulticastPort:=GetAttribute(xmlMasterNode,'MulticastPort');//组播端口
    szFsmType:=GetAttribute(xmlMasterNode,'nFsmType'); //1不是组播放，２是组播
    
    if(ConnType='1') then
    begin
        VSSCmdIP:=GetAttribute(xmlMasterNode,'MFSCmdIP');//视频流vss服务器ip
    end;

    MediaSendPort:=GetAttribute(xmlMasterNode,'MediaSendPort');//打洞端口
    videoport:=StrToInt((LocalPort));
    vssip:=StrToInt((VSSCmdIP));
    vssport:=StrToInt((VSSCmdPort));
    iSrcInst:=StrToInt((SrcInst));
    iVideoParamLen:=StrToInt((VideoParamLen));
    iMediaSendPort:=StrToInt((MediaSendPort));

    

    if (StrToInt(nTransPro) <> 0) then
    begin
       ErrorCode:=TPPlayerAtl1.SetConnectType(1);
    end
    else
    begin
        ErrorCode:=TPPlayerAtl1.SetConnectType(0);
    end;

	  TPPlayerAtl1.Stop();
		if(iVideoParamLen>0)  then
    begin
  		ErrorCode:=TPPlayerAtl1.SetupDecode(VideoParam,iVideoParamLen,0);//设置视频解码参数
    end;


		mediatype:=StrToInt(szMediaType);////0x0101 后面是视频，前面是音频
		if((mediatype and $0100)<>0) then
    begin
			iaudioParamLen:=StrToInt(AudioParamLen);
			if(iaudioParamLen>0)   then
      begin
    end;
				ErrorCode:=TPPlayerAtl1.SetupDecode((AudioParam),iaudioParamLen,1);//设置音频解码参数
      end;


		nMulticastIP:=0;
		if (StrToInt(nTransPro) = 0) then
    begin
			if(StrToInt(szFsmType)=2) then
      begin
				nMulticastIP:=StrToInt(szMcastIP);
				videoport:=StrToInt(szMulticastPort);//组播端口
      end;
    end;


    
		m_bInviteVideoFinish:=1;//标记不用再新请求
		ErrorCode:=TPPlayerAtl1.SetVideoParameter(nMulticastIP,videoport,vssip,iMediaSendPort,iSrcInst);//设置收流参数
    Tpplayeratl1.SetFullFillStatus(1);
		ErrorCode:=TPPlayerAtl1.Play();//启动播放
    if((mediatype and  $0100)<>0)  then
    begin
      ErrorCode:=TPPlayerAtl1.SetAudioOn(1);
      BstartAudio.Caption:='停止声音';
    end
    else
    begin
      ErrorCode:=TPPlayerAtl1.SetAudioOn(0);
      BstartAudio.Caption:='播放声音';
    end;
    if(ErrorCode<>0) then
    begin
        ShowMessage('播放失败，返回错误:'+inttostr(ErrorCode));
    end;

    
end;



function   TForm1.GetXmlNodeByCameraId(camId: WideString):IXMLDOMNode;
var
strGroupNmae:WideString;
strMasterName:WideString;
strCameraNmae:WideString;
strTemp:WideString;
nParamLen:integer;
tempDoc:IXMLDOMDocument;
xmlResponseNode:IXMLDOMNode;
xmlGroupNode:IXMLDOMNode;
xmlMasterNode:IXMLDOMNode;
xmlCameraNode:IXMLDOMNode;
xmlTempNode:IXMLDOMNode;
trGroupNode:TTreeNode;
trMasterNode:TTreeNode;
trCameraNode:TTreeNode;
begin
          if(xmlDoc=nil)then
          begin
              exit;
          end;
          xmlResponseNode:=xmlDoc.firstChild;
          xmlGroupNode:=xmlResponseNode.firstChild;
          while( xmlGroupNode<>nil) do
            //<DevGroup Id="860020002" Name="第二组(高清)" DomainId="86002">
            begin
            xmlMasterNode:=xmlGroupNode.firstChild;
            while( xmlMasterNode<>nil)   do
            //<Master Id="86002M1281583478" Name="IPC88196" Type="3" GroupId="860020002" DomainId="86002" DevCount="1"
            //IpAddr="3294144704" CommPort="1024" LoginName="admin" LoginPassword="123456" PTZRight="1" SURVEILRight="1"
            //VideoReplayRight="1" AudioControlRight="1" BCControlRight="1" AlarmMngRight="1">
            begin
                xmlCameraNode:=xmlMasterNode.firstChild;
                while(xmlCameraNode<>nil) do
                //<Camera Id="86002S1284363112" Name="196" MasterId="86002M1281583478" Type="1" IsDoubleStream="1" WithPTZ="0"
                //WithAudioIn="0" WithAudioOut="0" VSSId="4" ConnType="2" MFSCmdIP="0" MFSCmdPort="0" VSSCmdIP="-2074564416"
                //VSSCmdPort="554" VisitStreamOption="0" IpAddr="3294144704" CommPort="1024" LoginName="admin"
                //LoginPassword="123456"/>
                begin
                      strCameraNmae:=GetAttribute(xmlCameraNode,'Id');//mastrenode.attributes[0].nodeValue;
                      if( strCameraNmae= camId)then
                      begin
                          Result:=xmlCameraNode;
                          exit;
                      end;
                      xmlCameraNode:=xmlCameraNode.nextSibling;
                end;
                xmlMasterNode:=xmlMasterNode.nextSibling;
            end;
            xmlGroupNode:=xmlGroupNode.nextSibling;        
         end;
         Result:=nil;
 end;



procedure   TForm1.OnInterfaceXMLResp(ASender: TObject; nCode: Integer;  nDataLen: Integer;  const XmlData: WideString);
var
strGroupNmae:WideString;
strMasterName:WideString;
strCameraNmae:WideString;
strTemp:WideString;
nParamLen:integer;
tempDoc:IXMLDOMDocument;
xmlResponseNode:IXMLDOMNode;
xmlGroupNode:IXMLDOMNode;
xmlMasterNode:IXMLDOMNode;
xmlCameraNode:IXMLDOMNode;
xmlTempNode:IXMLDOMNode;
trGroupNode:TTreeNode;
trMasterNode:TTreeNode;
trCameraNode:TTreeNode;
tempDoc2:IXMLDOMDocument;
begin
     case nCode of  
     81:
     begin
         //'<Response Code="81" nFsmType="1" MediaType="257" DevId="86002S1284438976"
         //nRecordState="1" LocalPort="36936" MulticastIP="0" MulticastPort="0" MediaSendPort="60000" VideoParamLen="316"
         // VideoParam="vvv" AudioParamLen="56" AudioParam="aaa" ConnType="0" nTransPro="0"
         //SrcInst="280" VSSCmdIP="-2074564416" VSSCmdPort="554" MFSCmdIP="-2074564416" MFSCmdPort="554"  Result ="0"/>'
         if(pos('Result ="0"',XmlData)<0) then
         begin
               ShowMessage('请求流失败'+XmlData);
         end
         else
         begin
            OnPlayVideo(XmlData);
         end;
     end;



     
     27:
     begin

     end;




     92:
     begin
     //云台预置点
           if(strLastPtzXml<>XmlData) then
           begin
                tempDoc:=CoDOMDocument.Create();
                tempDoc.loadXML(XmlData);
                xmlTempNode:=tempDoc.firstChild;
                strTemp:=GetAttribute(xmlTempNode,'PTZResponse');
                if(strTemp<>'') then
                begin
                  tempDoc2:=CoDOMDocument.Create();
                  tempDoc2.loadXML(strTemp);
                  xmlTempNode:=tempDoc2.selectSingleNode('XML_TOPSEE');
                  if(xmlTempNode<>nil) then
                  begin
                    xmlTempNode:=xmlTempNode.selectSingleNode('MESSAGE_BODY');
                    if(xmlTempNode<>nil) then
                    begin
                      //strTemp:=xmlTempNode.nodeValue;//GetAttribute(xmlTempNode,'MESSAGE_BODY');
                      //strLastPtzXml:=XmlData;
                    end;
                  end;
                end;
           end;
     end;



     225:
     begin
     //设备状态更改了
            
     end;



     141:
     begin
     //录像查询返回结果
     end;




     145:
     begin   
          //录像查询返回结果
     end;


     149:
     begin 
          //录像查询返回结果
     end;



     213:
     begin
           label1.Caption :='云台被抢占或视频被抢占';
     end;



     
     203:
     begin
            Label1.Caption :='实时事件:' + XmlData;
     end;




     204:
     begin
            Label1.Caption :='告警信息:' + XmlData;
     end;

     
     33:
     begin
          xmlDoc:=CoDOMDocument.Create();
          xmlDoc.loadXML(XmlData);
          TreeView1.Items.Clear();
          xmlResponseNode:=xmlDoc.firstChild;
          xmlGroupNode:=xmlResponseNode.firstChild;
          while( xmlGroupNode<>nil) do
            //<DevGroup Id="860020002" Name="第二组(高清)" DomainId="86002">
            begin
            xmlMasterNode:=xmlGroupNode.firstChild;
            strGroupNmae:=GetAttribute(xmlGroupNode,'Id');//mastrenode.attributes[0].nodeValue;
            trGroupNode:=TreeView1.Items.AddChild(nil,strGroupNmae);   
            trGroupNode.data:=@(xmlGroupNode);
            while( xmlMasterNode<>nil)   do
            //<Master Id="86002M1281583478" Name="IPC88196" Type="3" GroupId="860020002" DomainId="86002" DevCount="1"
            //IpAddr="3294144704" CommPort="1024" LoginName="admin" LoginPassword="123456" PTZRight="1" SURVEILRight="1"
            //VideoReplayRight="1" AudioControlRight="1" BCControlRight="1" AlarmMngRight="1">
            begin
                strMasterName:=GetAttribute(xmlMasterNode,'Id');//mastrenode.attributes[0].nodeValue;
                trMasterNode:=treeview1.Items.AddChild(trGroupNode,strMasterName);
                trMasterNode.Data:=@(xmlMasterNode);
                xmlCameraNode:=xmlMasterNode.firstChild;
                while(xmlCameraNode<>nil) do
                //<Camera Id="86002S1284363112" Name="196" MasterId="86002M1281583478" Type="1" IsDoubleStream="1" WithPTZ="0"
                //WithAudioIn="0" WithAudioOut="0" VSSId="4" ConnType="2" MFSCmdIP="0" MFSCmdPort="0" VSSCmdIP="-2074564416"
                //VSSCmdPort="554" VisitStreamOption="0" IpAddr="3294144704" CommPort="1024" LoginName="admin"
                //LoginPassword="123456"/>
                begin
                      strCameraNmae:=GetAttribute(xmlCameraNode,'Id');//mastrenode.attributes[0].nodeValue;
                      trCameraNode:=treeview1.Items.AddChild(trMasterNode,strCameraNmae);
                      trCameraNode.data:=@(xmlCameraNode);
                      xmlCameraNode:=xmlCameraNode.nextSibling;
                end;
                xmlMasterNode:=xmlMasterNode.nextSibling;
            end;
            xmlGroupNode:=xmlGroupNode.nextSibling;         
            xmlTempNode:=IXMLDOMNode(trGroupNode.data^);
        end;
     end;
     end;
end;










procedure TForm1.FormCreate(Sender: TObject);
begin
      //创建通信控件
      objLogin:= TPlatInterActive.Create(nil);
      objLogin.OnInterfaceXMLResp:= OnInterfaceXMLResp;  //事件通知接口
end;










procedure TForm1.FormDestroy(Sender: TObject);
begin
  //rtsp.StopAll();
  objLogin.LogoutPlat();
  TPPlayerAtl1.Stop();
end;











procedure TForm1.Button1Click(Sender: TObject);
var
  retstr:WideString;
  portvalue:integer;
begin
    objLogin.LogoutPlat();
    portvalue:=strtoint(Eport.Text);
    retstr:=objLogin.LoginPlat(Euser.Text ,Epass.Text ,Eip.Text ,portvalue,1);
    if(Pos('Result ="0"',retstr)<0) then
    begin
      ShowMessage(retstr);
    end;
end;






procedure TForm1.TreeView1Click(Sender: TObject);
begin
//  Treeview1.GetNodeAt();
end;









procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
var
pNode:Pointer;   
xmlNode:IXMLDOMNode;
begin
  pNode:=Node.Data;
  //xmlNode:= IXMLDOMNode(pNode^);
  lastSelectNode:=Node;
end;










procedure TForm1.TreeView1DblClick(Sender: TObject);
var
nPort:integer;
xmlNode:IXMLDOMNode;
cameraId:widestring;
retValue:widestring;
begin
  if(lastSelectNode<>nil) then
  begin
        //<Camera Id="86002S1284363112" Name="196" MasterId="86002M1281583478" Type="1" IsDoubleStream="1" WithPTZ="0"
        // WithAudioIn="0" WithAudioOut="0" VSSId="4" ConnType="2" MFSCmdIP="0" MFSCmdPort="0" VSSCmdIP="-2074564416"
        // VSSCmdPort="554" VisitStreamOption="0" IpAddr="3294144704" CommPort="1024" LoginName="admin"
        // LoginPassword="123456"/>
         //xmlNode:=IXMLDOMNode(lastSelectNode.data^);
         //if(xmlNode<>nil) then
         //begin
           nPort:=TPPlayerAtl1.GetBindPort();
           cameraId:=lastSelectNode.Text;


           if(strLastInviteCameraId<>'')then
           begin
              objLogin.StopDeviceMonitor(strLastInviteCameraId,nVideoType); //请求cif视频流
           end;
           
           //cameraId:=GetAttribute(xmlNode,'Id');
           retValue:=objLogin.InviteDeviceMonitor(cameraId,1,nPort,0); //请求cif视频流
           nVideoType:=1;
           if(Pos('Result ="0"',retValue)<0) then
           begin
              showMessage('申请流失败，返回:' + retValue+','+cameraId);
           end
           else
           begin
              strLastInviteCameraId:=cameraId;
              //showMessage('申请流成功，返回:' + retValue+','+cameraId);
           end;
         //end;
  end;
end;













procedure TForm1.BstartAudioClick(Sender: TObject);
var
bSoundOn:integer;
begin
      bSoundOn:=TPPlayerAtl1.AudioIsOn;
      if(bSoundOn<>0)then
      begin
        TPPlayerAtl1.SetAudioOn(0);
      end
      else
      begin
        TPPlayerAtl1.SetAudioOn(1);
      end;    
      bSoundOn:=TPPlayerAtl1.AudioIsOn;
      if(bSoundOn<>0)then
      begin
        BstartAudio.Caption:='停止声音';
      end
      else
      begin
        BstartAudio.Caption:='播放声音';
      end;
end;













procedure TForm1.BcapImgClick(Sender: TObject);
begin
     TPPlayerAtl1.SnapShot('c:\\');
end;













procedure TForm1.TPPlayerAtl1Event(ASender: TObject; eventCode: Integer;const eventDescript: WideString);
begin
      case    eventCode of
        0:
        begin

        end;
      end;
end;









procedure TForm1.BstopPlayClick(Sender: TObject);
begin
      TPPlayerAtl1.Stop();
      if(strLastInviteCameraId<>'')then
      begin
        objLogin.StopDeviceMonitor(strLastInviteCameraId,nVideoType);
        strLastInviteCameraId:='';
      end;
end;




procedure TForm1.BstartPTZClick(Sender: TObject);
var
xmlNode:IXMLDOMNode;
atrrMsg:widestring;
begin
        xmlNode:= GetXmlNodeByCameraId(strLastInviteCameraId);
        if(  xmlNode=nil)then
        begin
            showMessage('请先播放视频!');
        end
        else
        begin
          //BstartPTZ

          atrrMsg:=GetAttribute(xmlNode,'WithPTZ');
          if(atrrMsg<>'1') then
          begin
            showmessage('此设备没有云台');
            exit;
          end;

          xmlNode:=xmlNode.parentNode;
          atrrMsg:=GetAttribute(xmlNode,'PTZRight');
          if(atrrMsg<>'1') then
          begin
            showmessage('此用户没有权限控制此云台');
            exit;
          end;
          objLogin.InvitePTZControl(strLastInviteCameraId);//请求控制
        end;
end;

procedure TForm1.BleftMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
       SendPtz('left');
end;

procedure TForm1.BrightMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
           
       SendPtz('right');
end;


procedure TForm1.SendPtz(actionName:widestring);
var
cmd:widestring;
addstr:widestring;
pspeed:widestring;
tspeed:widestring;
begin
      tspeed:='5';
      pspeed:='5';
      addstr:='';
      cmd:='<xml><cmd>'+actionName+'</cmd><panspeed>'+pspeed+'</panspeed><tiltspeed>'+tspeed+'</tiltspeed>'+addstr+'</xml>';
      objLogin.SendPTZCmd(strLastInviteCameraId,1,cmd);
end;







procedure TForm1.BViewPtzNodeClick(Sender: TObject);
var
precmd:widestring;
begin 
	    //precmd:='<xml><cmd>callpreset</cmd><preset>'+ptzNode.text+'</preset></xml>';
      //objLogin.SendPTZCmd(strLastInviteCameraId,1,precmd);
end;

procedure TForm1.BchangeFullFillClick(Sender: TObject);
var
nowStatus:integer;
begin
      nowStatus:=TpplayerAtl1.GetFullFillStatus();
      if (nowStatus<>0) then
      begin
        TpplayerAtl1.SetFullFillStatus(0);
      end
      else
      begin
        TpplayerAtl1.SetFullFillStatus(1);
      end;
end;

procedure TForm1.BleftMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
       SendPtz('stop');
end;

procedure TForm1.BtopMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
       SendPtz('stop');
end;

procedure TForm1.BdownMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
       SendPtz('stop');
end;

procedure TForm1.BrightMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
       SendPtz('stop');
end;





procedure TForm1.BtopMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin

       SendPtz('up');
end;

procedure TForm1.BdownMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin

       SendPtz('down');
end;

end.
