就刚刚提出的问题再次请教坛友 xiaopei,下面是vc 函数的的描述,你刚转成delphi,但是我还不会用,特别是回调函数过程体要怎么写以及参数输入 100(

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

psynet123

Unregistered / Unconfirmed
GUEST, unregistred user!
5.3. MP4_ClientStart <br>函数名: LONG &nbsp;MP4_ClientStart(PCLIENT_VIDEOINFO pClientInfo,<br> &nbsp; &nbsp; void(CALLBACK *ReadDataCallBack)(DWORD dwClientDescriptor,<br> &nbsp; &nbsp; UCHAR *pPacketBuffer,<br> &nbsp; &nbsp; DWORD dwPacketSize,<br> &nbsp; &nbsp; DWORD dwFrameType,<br> &nbsp; &nbsp; VOID *pContext),<br> &nbsp; &nbsp; VOID *pContext)<br><br>功 &nbsp;能:启动某个通道<br>参 &nbsp;数:<br>&nbsp; &nbsp; &nbsp; &nbsp;pContext 上下文地址,回调函数最后一个参数相同<br>&nbsp; &nbsp; &nbsp; &nbsp;pClientInfo<br>&nbsp;typedef struct tag_CLIENT_VIDEOINFO{<br>&nbsp; &nbsp;BYTE &nbsp; &nbsp;bServerChannel; &nbsp;//对应服务器的通道号<br>&nbsp; &nbsp; BYTE &nbsp; &nbsp;bReserved; &nbsp; &nbsp; &nbsp; &nbsp;//保留以后使用 <br>&nbsp; &nbsp;BYTE &nbsp; &nbsp;bClientChannel; &nbsp;//客户端的描述符,由用户自己定义,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ReadDataCallBack的第一个参数会使用相同的值<br>&nbsp; &nbsp;char &nbsp; &nbsp;*strIPAddress; &nbsp; &nbsp; &nbsp; //服务器的IP地址<br>&nbsp; &nbsp;char &nbsp; &nbsp;*strUserName; &nbsp; &nbsp; &nbsp; &nbsp;//用户名<br>&nbsp; &nbsp;char &nbsp; &nbsp;*strUserPassword; &nbsp; //密码<br>&nbsp; &nbsp;BOOL &nbsp; &nbsp;bUserCheck; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//是否需要发送用户名和密码到服务器<br>&nbsp; &nbsp;HWND &nbsp; &nbsp;hShowVideo; &nbsp; &nbsp; &nbsp; &nbsp; //显示窗口句柄<br>&nbsp;}CLIENT_VIDEOINFO, *PCLIENT_VIDEOINFO;<br>回调函数ReadDataCallBack说明:<br>&nbsp; bClientChannel客户端的描述符,由pClientInfo传入<br>&nbsp; pPacketBuffer &nbsp; 数据缓冲区<br>&nbsp; dwPacketSize &nbsp; &nbsp;缓冲区的大小<br>&nbsp; dwFrameType &nbsp; &nbsp; 帧类型<br>&nbsp; pContext &nbsp; &nbsp; &nbsp; &nbsp;提供的上下文<br><br>返回值:返回-1 表示失败,其他值表示成功,作为后面函数调用的通道句柄<br>注 &nbsp;意:MP4_ClientStart 返回成功,并不表示已经成功连接服务端。您需要通<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 过MP4_ClientGetState 函数去获得网络连接的状态<br><br>说 &nbsp;明: strUserName和strUserPassword的最大为50个字符,如果bUserCheck为FALSE, 则直接发送NULL指针到服务器<br>----------------------------------------------------------------------------
 
很奇怪啊,dll带有回调函数的这些函数,在delphi无法调用啊,找不到输入点啊
 
//所谓的回调函数,是用户提供给系统或服务器等外部程序调用的接口函数指针。并不是由你用户调用的。你所要做的就是定义一个回调函数,然后将接口回调函数地址传给系统或服务器就行了(回调函数的参数不是由你传给系统或服务器的,是由系统或服务器传给你的,你只能根据参数的结果处理对应的事件)。这样,当某些事件产生时,系统或服务器就会填充相关的参数并调用你提供的回调函数。这个时候,你就可以在这个事件触发中(你的回调函数中)处理某些事情了。<br>//因我没有用过下面这些函数,所以我也没办法给你完全的解释,下面的解释仅供参考。<br>type TCLIENT_VIDEOINFO = packed record<br>&nbsp; bServerChannel:BYTE;<br>&nbsp; bReserved:BYTE;<br>&nbsp; bClientChannel:BYTE;<br>&nbsp; strIPAddress:pChar;<br>&nbsp; strUserName:pChar;<br>&nbsp; strUserPassword:pChar;<br>&nbsp; bUserCheck:BOOL;<br>&nbsp; hShowVideo:HWND;<br>end;<br>&nbsp; PCLIENT_VIDEOINFO = ^TCLIENT_VIDEOINFO;<br>&nbsp; TReadDataCallBack = Procedure (dwClientDescriptor:DWORD; pPacketBuffer:pChar; dwPacketSize, dwFrameType:DWORD; pContext:Pointer); stdcall; <br><br>Function MP4_ClientStart(pClientInfo:PCLIENT_VIDEOINFO; ReadDataCallBack:TReadDataCallBack; pContext:Pointer); cdecl; external 'DllName.dll';<br><br>Procedure _ReadDataCallBack(dwClientDescriptor:DWORD; pPacketBuffer:pChar; dwPacketSize, dwFrameType:DWORD; pContext:Pointer); stdcall;<br>begin<br>&nbsp; ShowMessage(Format('dwClientDescriptor: %u'+ #13#10 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'pPacketBuffer: %s' + #13#10 + // 这一句可能出问题,因为并不清楚该参数的数是不是都是可显示的字符,这里只是做个演示。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'dwPacketSize: %u' + #13#10 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'dwFrameType: %u' + #13#10 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'pContext: %X' + #13#10, // 因不清楚指向的是什么环境数据,这里只演示输出pContext的地址。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[dwClientDescriptor,pPacketBuffer,dwPacketSize,dwFrameType,pContext]));<br>end;<br><br>//大概是如下调用。<br>var ClientInfo:CLIENT_VIDEOINFO;<br>&nbsp; &nbsp; Context:Pointer;<br>begin<br>&nbsp; ClientInfo.bServerChannel := SreverChannel;<br>&nbsp; ClientInfo.bReserved := 0; // 保留,不使用,所以用0填充<br>&nbsp; ClientInfo.bClientChannel := ClientChannel;<br>&nbsp; ClientInfo.strIPAddress := '192.168.1.1'; // 指向一个服务器IP字符串的地址,这里只是演示<br>&nbsp; ClientInfo.strUserName := 'UserName';<br>&nbsp; ClientInfo.strUserPassword := 'UserPassword';<br>&nbsp; ClientInfo.bUserCheck := TRUE; // 如果是FALSE,函数可能是忽略用户名和密码的<br>&nbsp; ClientInfo.hShowVideo := Handle;<br>&nbsp; Context := Pointer(Address);<br>&nbsp; MP4_ClientStart(@ClientInfo,_ReadDataCallBack,Context);<br>end;
 
Procedure _ReadDataCallBack(dwClientDescriptor:DWORD; pPacketBuffer:pChar; dwPacketSize, dwFrameType:DWORD; pContext:Pointer); stdcall;<br>begin<br>&nbsp; ShowMessage(Format('dwClientDescriptor: %u'+ #13#10 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'pPacketBuffer: %s' + #13#10 + // 这一句可能出问题,因为并不清楚该参数的数是不是都是可显示的字符,这里只是做个演示。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'dwPacketSize: %u' + #13#10 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'dwFrameType: %u' + #13#10 +<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'pContext: %X' + #13#10, // 因不清楚指向的是什么环境数据,这里只演示输出pContext的地址。<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[dwClientDescriptor,pPacketBuffer,dwPacketSize,dwFrameType,pContext]));<br>end;<br>--------------------------------------------------------------<br>我这个过程体就让他空,什么都不写,可以吗?他那里不是说返回-1或其他的值吗
 
ReadDataCallBack回调函数是没有返回值的(void)。返回-1的说的是MP4_ClientStart函数,说该函数返回-1是失败,返回其它数则是成功,是作为后面函数调用的通道句柄
 
o ,谢谢,我这里这个调用不知道什么原因,老是不成功,按道理应该是可以的了
 
这就不清楚了,因为我也没使用过这些函数。
 
接受答案了.
 
后退
顶部