海康视频卡服务端问题!客户端连接的时候出现拒绝访问(200分)

  • 主题发起人 主题发起人 peng123456
  • 开始时间 开始时间
P

peng123456

Unregistered / Unconfirmed
GUEST, unregistred user!
// Dvr_Main.Dvr_ServerBtn.Click;
if (initdsps() <= 0) then

showmessage('初始化DSP失败!');

dspchannl := gettotaldsps();

// for i := 0 to dspchannldo

begin

// hChannelHandle := channelopen(i);
end;

hChannelHandle[0] := channelopen(0);
SetOverlayColorKey(RGB(10, 10, 10));
registerdrawfun(0,@Drawfun,frmWeight.panVideo1.Handle );
lpRect[0] := frmWeight.panVideo1.clientrect;
startvideopreview(hChannelHandle[0],frmWeight. panVideo1.Handle, @lpRect[0], false, 128, 25);
hChannelHandle[1] := channelopen(1) ;
SetOverlayColorKey(RGB(10, 10, 10));
registerdrawfun(1,@Drawfun,frmWeight.panVideo2.Handle );
lpRect[1] :=frmWeight. panVideo2.clientrect;
startvideopreview(hChannelHandle[1],frmWeight. panVideo2.Handle, @lpRect[1], TRUE, 128, 25);
hChannelHandle[2] := channelopen(2) ;
SetOverlayColorKey(RGB(10, 10, 10));
registerdrawfun(2,@Drawfun,frmWeight. panVideo3.Handle );
lpRect[2] :=frmWeight. panVideo3.clientrect;
startvideopreview(hChannelHandle[2],frmWeight. panVideo3.Handle, @lpRect[2], TRUE, 128, 25);
hChannelHandle[3] := channelopen(3);
SetOverlayColorKey(RGB(10, 10, 10));
registerdrawfun(3,@Drawfun,frmWeight. panVideo4.Handle );
lpRect[3] :=frmWeight. panVideo4.clientrect;
startvideopreview(hChannelHandle[3],frmWeight. panVideo4.Handle, @lpRect[3], TRUE, 128, 25);

MP4_ServerSetStart(@StartCap);//优先调用1
MP4_ServerSetNetPort(5050,6050);//优先调用2
//
for i:=0 to 3do

begin

if(i = 0) then

begin

MP4_ServerSetBufNum(i,90);
//优先调用3
end
else

begin

MP4_ServerSetBufNum(i,80);
//优先调用3
end;

videoinfo.m_datatype := 50;
end;

///// addd

RegisterMessageNotifyHandle(self.Handle, MsgDataReady);
videoinfo.m_channum :=4 ;
videoinfo.m_waittime:= 23;
// for i:=0 to g_nChannelTotal-1do

begin

lpRect:=frmWeight.panVideo1.clientrect;
lpRect:=frmWeight.panVideo2.clientrect;
lpRect:=frmWeight.panVideo3.clientrect;
lpRect:=frmWeight.panVideo4.clientrect;
end;


bb:=MP4_ServerStart(@videoinfo);
MP4_ServerSetTTL(32);
MP4_ServerMaxUser(0,24);
if bb=true then

begin

//Dvr_ServerBtn.Enabled:=false;
end;

MP4_ServerSetMessage(WM_MYCOMMAND,self.Handle);
 
没有人顶一下!
 
没做过这卡,帮顶
 
const
WM_MYCOMMAND = WM_USER + 1000;

type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure WndProc(var Msg: TMessage);override;
end;


var
Form1: TForm1;
DSPChannl: integer;
hChannelHandle: array[0..63] of integer;
msgdataready:integer;
StreamBuf : array [0..1000000] of char;
sel:integer;//选择通道
function OnDataReady(channelNum:integer;
lparam:integer):integer;
procedure StartCap(nPort: integer );
stdcall
implementation

{$R *.dfm}
procedure StartCap(nPort: integer );
stdcall
begin

StartVideoCapture(hChannelHandle[nport]);
end;


function OnDataReady(channelNum:integer;
lparam:integer):integer;
var
length:integer;// = 1000000;
frameType:integer;
status:integer;
// nframetype:integer;// =0;

begin

unit1.Form1.Memo1.Lines.Add('.........'+inttostr(sel));
unit1.Form1.Memo1.Lines.Add('PktAudioFrames.length...'+inttostr(channelNum));


{ if (frameType=integer(PktAudioFrames)) then

begin


end;

}

if (sel=channelNum) then
begin

status := ReadStreamData(hChannelHandle[sel], StreamBuf, @length, @frameType);
if status<0 then

begin

exit;
end;

MP4_ServerWriteDataEx(0,@StreamBuf,length,frameType,status,1);
MP4_ServerWriteDataEx(0,@StreamBuf, length,frameType,status,0);
end
else

begin

ReadStreamData(hChannelHandle[channelNum], StreamBuf, @length, @frameType);
unit1.Form1.Memo1.Lines.Add('errtttyyy...');
end;

end;


procedure TForm1.FormCreate(Sender: TObject);

var
temp:string;
begin

sel:=0;
temp:=inttohex(MP4_ServerGetSDKVersion(),8);
MsgDataReady := RegisterWindowMessage('Data_ready');
end;


procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin

if (InitDSPs() <= 0) then

showmessage('初始化DSP失败!');
DSPChannl := GetTotalDSPs();
//获取系统内正确安装的编码通道个数
Memo1.Lines.Add('GetTotalDSPs................'+inttostr(DSPChannl));
DSPChannl:=2;
for i:=0 to DSPChannl-1do

begin

hChannelHandle:=channelopen(i);
SetEncoderPictureFormat(hChannelHandle,ENC_4CIF);
SetStreamType(hChannelHandle,3);
SetOverlayColorKey(RGB(10,10,10) );
SetDefaultQuant(hChannelHandle,14,14,20);
SetupBitrateControl(hChannelHandle,0);
SetBitrateControlMode(hChannelHandle,brVBR);
end;


end;


procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
videoinfo: SERVER_VIDEOINFO;
bb:boolean;
begin

i:=strtoint(trim(Edit1.Text));
Memo1.Lines.Add('................'+inttostr(DSPChannl));
RegisterMessageNotifyHandle(self.Handle, MsgDataReady);
MP4_ServerSetMessage(WM_MYCOMMAND,self.Handle );

MP4_ServerSetBufNum(i,50);
videoinfo.m_datatype := 50;

MP4_ServerSetBufNum(1,50);
videoinfo.m_datatype[1] := 50;

videoinfo.m_channum :=dspchannl ;
videoinfo.m_waittime:= 2;
MP4_ServerSetStart(@StartCap);
//MP4_ServerSetStart(nil);
MP4_ServerSetTTL(64);
MP4_ServerSetNetPort(5050,6050);
MP4_ServerSetWait(1000,1);
MP4_ServerMaxUser(0,24);
bb:=MP4_ServerStart(@videoinfo);
if bb then

Memo1.Lines.Add('.....true...........')
else

Memo1.Lines.Add('....false...........');
end;

procedure TForm1.WndProc(var Msg: TMessage);
begin

if Msg.Msg = msgdataready then

begin

OnDataReady(msg.WParam ,msg.LParam );
end;

inherited;
end;


procedure TForm1.Button4Click(Sender: TObject);
begin

sel:=strtoint(trim(Edit1.Text));
end;


end.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
850
import
I
后退
顶部