即时通讯开发平台的部分C#代码

using System;  
using System.Text;  
using System.Runtime.InteropServices;  
 
namespace Platform  
{  
    /******************************************************************************** 
    * ** AnyChat Platform Core SDK 
    * *********************************************************************************/ 
    public class AnyChatCoreSDK  
    { 
        #region AnyChat Platform Core SDK 常量定义  
        // 内核参数定义,API:BRAC_SetSDKOption、BRAC_GetSDKOption 传入参数  
        public const int BRAC_SO_AUDIO_VADCTRL          =   1;  // 音频静音检测控制(参数为:int型:1打开,0关闭)  
        public const int BRAC_SO_AUDIO_NSCTRL           =   2;  // 音频噪音抑制控制(参数为:int型:1打开,0关闭)  
        public const int BRAC_SO_AUDIO_ECHOCTRL         =   3;  // 音频回音消除控制(参数为:int型:1打开,0关闭)  
        public const int BRAC_SO_AUDIO_AGCCTRL          =   4;  // 音频自动增益控制(参数为:int型:1打开,0关闭)  
        public const int BRAC_SO_AUDIO_CPATUREMODE      =   5;  // 音频采集模式设置(参数为:int型:0 发言模式,1 放歌模式,2 卡拉OK模式,3 线路输入模式)  
        public const int BRAC_SO_AUDIO_MICBOOST         =   6;  // 音频采集Mic增强控制(参数为:int型:0 取消,1 选中,2 设备不存在[查询时返回值])  
        public const int BRAC_SO_RECORD_VIDEOBR         =   10; // 录像视频码率设置(参数为:int型,单位:bps)  
        public const int BRAC_SO_RECORD_AUDIOBR         =   11; // 录像音频码率设置(参数为:int型,单位:bps)  
        public const int BRAC_SO_RECORD_TMPDIR          =   12; // 录像文件临时目录设置(参数为字符串PCHAR类型,必须是完整的绝对路径)  
        public const int BRAC_SO_SNAPSHOT_TMPDIR        =   13; // 快照文件临时目录设置(参数为字符串PCHAR类型,必须是完整的绝对路径)  
        public const int BRAC_SO_CORESDK_TMPDIR         =   14; // 设置AnyChat Core SDK临时目录(参数为字符串PCHAR类型,必须是完整的绝对路径)  
        public const int BRAC_SO_CORESDK_PATH           =   20; // 设置AnyChat Core SDK相关组件路径(参数为字符串PCHAR类型,必须是完整的绝对路径)  
        public const int BRAC_SO_LOCALVIDEO_BITRATECTRL =   30; // 本地视频编码码率设置(参数为int型,单位bps,同服务器配置:VideoBitrate)  
        public const int BRAC_SO_LOCALVIDEO_QUALITYCTRL =   31; // 本地视频编码质量因子控制(参数为int型,同服务器配置:VideoQuality)  
        public const int BRAC_SO_LOCALVIDEO_GOPCTRL     =   32; // 本地视频编码关键帧间隔控制(参数为int型,同服务器配置:VideoGOPSize)  
        public const int BRAC_SO_LOCALVIDEO_FPSCTRL     =   33; // 本地视频编码帧率控制(参数为int型,同服务器配置:VideoFps)  
        public const int BRAC_SO_LOCALVIDEO_PRESETCTRL  =   34; // 本地视频编码预设参数控制(参数为int型,1-5)  
        public const int BRAC_SO_LOCALVIDEO_APPLYPARAM  =   35; // 应用本地视频编码参数,使得前述修改即时生效(参数为int型:1 使用新参数,0 使用默认参数)  
        public const int BRAC_SO_LOCALVIDEO_VIDEOSIZEPOLITIC=36;// 本地视频采集分辩率控制策略(参数为int型,0 自动向下逐级匹配[默认];1 使用采集设备默认分辩率),当配置的分辩率不被采集设备支持时有效  
        public const int BRAC_SO_LOCALVIDEO_DEINTERLACE =   37; // 本地视频反交织参数控制(参数为int型: 0 不进行反交织处理[默认];1 反交织处理),当输入视频源是隔行扫描源(如电视信号)时通过反交织处理可以提高画面质量  
        public const int BRAC_SO_NETWORK_P2PPOLITIC     =   40; // 本地网络P2P策略控制(参数为:int型:0 禁止本地P2P,1 服务器控制P2P[默认],2 上层应用控制P2P连接,3 按需建立P2P连接)  
        public const int BRAC_SO_NETWORK_P2PCONNECT     =   41; // 尝试与指定用户建立P2P连接(参数为int型,表示目标用户ID),连接建立成功后,会通过消息反馈给上层应用,P2P控制策略=2时有效  
        public const int BRAC_SO_NETWORK_P2PBREAK       =   42; // 断开与指定用户的P2P连接(参数为int型,表示目标用户ID)[暂不支持,保留]  
 
        // 用户状态标志定义,API:BRAC_QueryUserState 传入参数  
        public const int BRAC_USERSTATE_CAMERA          =   1;  // 用户摄像头状态(参数为DWORD型)  
        public const int BRAC_USERSTATE_HOLDMIC         =   2;  // 用户持有Mic状态(参数为DWORD型)  
        public const int BRAC_USERSTATE_SPEAKVOLUME     =   3;  // 用户当前说话音量(参数为DOUBLE类型(0.0 ~ 100.0))  
        public const int BRAC_USERSTATE_RECORDING       =   4;  // 用户录像(音)状态(参数为DWORD型)  
        public const int BRAC_USERSTATE_LEVEL           =   5;  // 用户级别(参数为DWORD型)  
        public const int BRAC_USERSTATE_NICKNAME        =   6;  // 用户昵称(参数为字符串PCHAR类型)  
        public const int BRAC_USERSTATE_LOCALIP         =   7;  // 用户本地IP地址(内网,参数为字符串PCHAR类型)  
        public const int BRAC_USERSTATE_INTERNETIP      =   8;  // 用户互联网IP地址(参数为字符串PCHAR类型)  
        public const int BRAC_USERSTATE_VIDEOBITRATE    =   9;  // 用户当前的视频码率(参数为DWORD类型,Bps)  
        public const int BRAC_USERSTATE_AUDIOBITRATE    =   10; // 用户当前的音频码率(参数为DWORD类型,Bps)  
        public const int BRAC_USERSTATE_P2PCONNECT      =   11; // 查询本地用户与指定用户的当前P2P连接状态(参数为DWORD类型,返回值:0 P2P不通, 1 P2P连接成功[TCP],2 P2P连接成功[UDP],3 P2P连接成功[TCP、UDP])  
        public const int BRAC_USERSTATE_NETWORKSTATUS   =   12; // 查询指定用户的网络状态(参数为DWORD类型,返回值:0 优良,1 较好,2 一般,3 较差,4 非常差),注:查询间隔需要>1s  
 
        // SDK消息定义  
        public const int WM_GV = 0x0400 + 200;  
        public const int WM_GV_CONNECT          =   WM_GV + 1;  // 客户端连接服务器,wParam(BOOL)表示是否连接成功  
        public const int WM_GV_LOGINSYSTEM      =   WM_GV + 2;  // 客户端登录系统,wParam(INT)表示自己的用户ID号,lParam(INT)表示登录结果:0 成功,否则为出错代码,参考出错代码定义  
        public const int WM_GV_ENTERROOM        =   WM_GV + 3;  // 客户端进入房间,wParam(INT)表示所进入房间的ID号,lParam(INT)表示是否进入房间:0成功进入,否则为出错代码  
        public const int WM_GV_MICSTATECHANGE   =   WM_GV + 4;  // 用户的Mic状态变化消息,wParam(INT)表示用户ID号,lParam(BOOL)表示该用户是否持有Mic  
        public const int WM_GV_USERATROOM       =   WM_GV + 5;  // 用户进入(离开)房间,wParam(INT)表示用户ID号,lParam(BOOL)表示该用户是进入(TRUE)或离开(FALSE)房间  
        public const int WM_GV_LINKCLOSE        =   WM_GV + 6;  // 网络连接已关闭,该消息只有在客户端连接服务器成功之后,网络异常中断之时触发,wParam(INT)表示连接断开的原因  
        public const int WM_GV_ONLINEUSER       =   WM_GV + 7;  // 收到当前房间的在线用户信息,进入房间后触发一次,wParam(INT)表示在线用户数(包含自己),lParam(INT)表示房间ID  
        public const int WM_GV_FORTUNEMENU      =   WM_GV + 8;  // 用户选择了一项财富菜单项,wParam(INT)表示用户ID号,lParam(INT)表示财富菜单标记,指示是选择了哪一项菜单  
        public const int WM_GV_ROOMWAITQUEUE    =   WM_GV + 9;  // 用户收到当前房间等待队列消息,wParam(INT)表示用户前面的队列长度,lParam(INT)表示当前房间总的等待队列长度  
        public const int WM_GV_ENTERREQUEST     =   WM_GV + 10; // 用户申请进入房间消息,wParam(INT)表示用户ID号,lParam(BOOL)表示该用户是申请进入(TRUE)房间或离开(FALSE)房间等待队列  
        public const int WM_GV_CAMERASTATE      =   WM_GV + 11; // 用户摄像头状态发生变化,wParam(INT)表示用户ID号,lParam(INT)表示摄像头的当前状态,定义为:GV_CAMERA_STATE_XXXX  
        public const int WM_GV_CHATMODECHG      =   WM_GV + 12; // 用户聊天模式发生变化,wParam(INT)表示用户ID号,lParam(INT)表示用户的当前聊天模式  
        public const int WM_GV_ACTIVESTATE      =   WM_GV + 13; // 用户活动状态发生变化,wParam(INT)表示用户ID号,lParam(INT)表示用户的当前活动状态  
        public const int WM_GV_P2PCONNECTSTATE  =   WM_GV + 14; // 本地用户与其它用户的P2P网络连接状态发生变化,wParam(INT)表示其它用户ID号,lParam(INT)表示本地用户与其它用户的当前P2P网络连接状态  
        public const int WM_GV_PRIVATEREQUEST   =   WM_GV + 21; // 用户发起私聊请求,wParam(INT)表示发起者的用户ID号,lParam(INT)表示私聊请求编号,标识该请求  
        public const int WM_GV_PRIVATEECHO      =   WM_GV + 22; // 用户回复私聊请求,wParam(INT)表示回复者的用户ID号,lParam(INT)为出错代码  
        public const int WM_GV_PRIVATEEXIT      =   WM_GV + 23; // 用户退出私聊,wParam(INT)表示退出者的用户ID号,lParam(INT)为出错代码  
        public const int WM_GV_EXTENDBTNPRESS   =   WM_GV + 31; // 用户按下扩展按钮,wParam(INT)表示按钮所对应的用户ID号,lParam(DWORD)指示按钮(左下角)所在屏幕位置(x,y),用户可以利用该参数显示菜单等  
        public const int WM_GV_SDKWARNING       =   WM_GV + 41; // SDK警告信息,当SDK在运行过程中自检发现异常状态时,将向上层发送该消息,wParam(INT)表示警告代码,定义为:GV_ERR_WARNING_XXXX  
 
        // SDK出错代码定义,其它代码请参考:C++ SDK目录中的GVErrorCodeDefine.h文件  
        public const int GV_ERR_SUCCESS         =   0;          // 成功  
 
 
        public const ulong BRAC_FUNC_VIDEO_CBDATA   =   0x00000001L ;///< 通过回调函数输出视频数据  
        public const ulong BRAC_FUNC_VIDEO_AUTODISP =0x00000002L    ;///< 由SDK包处理视频,将视频显示在指定的窗口上  
        public const ulong BRAC_FUNC_AUDIO_CBDATA   =   0x00000004L;    ///< 通过回调函数输出音频数据  
        public const ulong BRAC_FUNC_AUDIO_AUTOPLAY =0x00000008L    ;///< 由SDK包处理音频,直接播放  
        public const ulong BRAC_FUNC_CONFIG_LOCALINI    =0x00000010L    ;///< 生成本地配置文件(AnyChatSDK.ini)  
        public const ulong BRAC_FUNC_FIREWALL_OPEN  =   0x00000020L;    ///< 允许SDK操作Windows防火墙,将当前应用程序加入防火墙访问列表(避免Windows提示用户是否阻止当前应用程序)  
        public const ulong BRAC_FUNC_CHKDEPENDMODULE    =0x00000040L    ;///< 自动检查SDK所依赖的组件,并自动注册  
        public const ulong BRAC_FUNC_AUDIO_VOLUMECALC=  0x00000080L;    ///< 由SDK自动计算语音的音量  
        public const ulong BRAC_FUNC_AUDIO_AUTOVOLUME=  0x00000100L;    ///< 允许SDK自动控制Mic录音音量  
        public const ulong BRAC_FUNC_NET_SUPPORTUPNP    =0x00000200L    ;///< 允许SDK打开用户网络中的UPNP设备,如果用户的路由器或是防火墙支持UPNP协议,则可提高P2P打洞的成功率  
        public const ulong BRAC_FUNC_DISABLEDECODE = 0x00000400L;///< 禁止对收到的数据进行解码和播放,为了提高代理客户端的数据转发性能,可设置该标志,否则不能设置该标志  
 
 
 
      
 
 
 
 
 
 
 
 
 
 
        // 音频设备枚举定义  
        public enum AudioDevice  
        {  
            BRAC_AD_WAVEIN  = 0,                                // 输入设备:Mic  
            BRAC_AD_WAVEOUT = 1                                 // 输出设备:Wave  
        }  
 
        public enum PixelFormat{  
            BRAC_PIX_FMT_RGB24 = 0,                     ///< Packed RGB 8:8:8, 24bpp, RGBRGB...(MEDIASUBTYPE_RGB24)  
            BRAC_PIX_FMT_RGB32,                         ///< 对应于:MEDIASUBTYPE_RGB32,Packed RGB 8:8:8, 32bpp, (msb)8A 8R 8G 8B(lsb), in cpu endianness  
            BRAC_PIX_FMT_YV12,                          ///< 对应于:MEDIASUBTYPE_YV12,Planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)  
            BRAC_PIX_FMT_YUY2,                          ///< 对应于:MEDIASUBTYPE_YUY2,Packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr  
        }  
        [StructLayout(LayoutKind.Sequential)]            
        //BitmapInfoHeader   定义了位图的头部信息            
        public struct BITMAPINFOHEADER            
        {                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biSize;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biWidth;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biHeight;                
            [MarshalAs(UnmanagedType.I2)]                
            public short biPlanes;                
            [MarshalAs(UnmanagedType.I2)]                
            public short biBitCount;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biCompression;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biSizeImage;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biXPelsPerMeter;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biYPelsPerMeter;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biClrUsed;                
            [MarshalAs(UnmanagedType.I4)]                
            public Int32 biClrImportant;            
        }  
 
        // 功能模式枚举定义,API:BRAC_InitSDK 传入参数  
        public enum FUNCMode : ulong 
        {  
            BRAC_FUNC_VIDEO_CBDATA          =   0x00000001L,    // 通过回调函数输出视频数据  
            BRAC_FUNC_VIDEO_AUTODISP        =   0x00000002L,    // 由SDK包处理视频,将视频显示在指定的窗口上  
            BRAC_FUNC_AUDIO_CBDATA          =   0x00000004L,    // 通过回调函数输出音频数据  
            BRAC_FUNC_AUDIO_AUTOPLAY        =   0x00000008L,    // 由SDK包处理音频,直接播放  
            BRAC_FUNC_CONFIG_LOCALINI       =   0x00000010L,    // 生成本地配置文件(AnyChatSDK.ini)  
            BRAC_FUNC_FIREWALL_OPEN         =   0x00000020L,    // 允许SDK操作Windows防火墙,将当前应用程序加入防火墙访问列表(避免Windows提示用户是否阻止当前应用程序)  
            BRAC_FUNC_CHKDEPENDMODULE       =   0x00000040L,    // 自动检查SDK所依赖的组件,并自动注册  
            BRAC_FUNC_AUDIO_VOLUMECALC      =   0x00000080L,    // 由SDK自动计算语音的音量  
            BRAC_FUNC_AUDIO_AUTOVOLUME      =   0x00000100L,    // 允许SDK自动控制Mic录音音量  
            BRAC_FUNC_NET_SUPPORTUPNP       =   0x00000200L,    // 允许SDK打开用户网络中的UPNP设备,如果用户的路由器或是防火墙支持UPNP协议,则可提高P2P打洞的成功率  
            BRAC_FUNC_DISABLEDECODE         =   0x00000400L     // 禁止对收到的数据进行解码和播放,为了提高代理客户端的数据转发性能,可设置该标志,否则不能设置该标志  
        }  
 
 
 
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]  
        public struct WaveFormat  
        {  
            public short wFormatTag;  
            public short nChannels;  
            public uint nSamplesPerSec;  
            public uint nAvgBytesPerSec;  
            public short nBlockAlign;  
            public short wBitsPerSample;  
            public short cbSize;  
        }  
        #endregion 
 
        #region AnyChat Platform Core SDK 功能函数API接口封装  
        /// <summary>  
        /// 透明通道数据回调函数定义  
        /// </summary>  
        /// <param name="userId">用户ID</param>  
        /// <param name="buf">缓冲区</param>  
        /// <param name="len">缓冲区长度</param>  
        /// <param name="userValue">附带信息</param>  
        public delegate void TransBufferCallBack(int userId, IntPtr buf, int len, int userValue);  
 
        /// <summary>  
        /// 透明通道扩展回调函数定义  
        /// </summary>  
        /// <param name="userId">用户ID</param>  
        /// <param name="buf">缓冲区</param>  
        /// <param name="len">缓冲区长度</param>  
        /// <param name="wParam">缓冲区附带信息1</param>  
        /// <param name="lParam">缓冲区附带信息2</param>  
        /// <param name="taskId">传输任务编号</param>  
        /// <param name="userValue">自定义参数</param>  
        public delegate void TransBufferCallBackEx(int userId, IntPtr buf, int len,int wParam,int lParam,int taskId, int userValue);  
 
        /// <summary>  
        /// 传输文件回调函数定义  
        /// </summary>  
        /// <param name="userId">用户ID</param>  
        /// <param name="fileName">文件名</param>  
        /// <param name="filePath">文件接收后保存在本地的路径</param>  
        /// <param name="fileLength">文件长度</param>  
        /// <param name="wParam">附带信息1</param>  
        /// <param name="lParam">附带信息2</param>  
        /// <param name="taskId">传输任务编号</param>  
        /// <param name="userValue">自定义参数</param>  
        public delegate void TransFileCallBack(int userId, string fileName, string filePath, int fileLength, int wParam, int lParam, int taskId, int userValue);  
 
        /// <summary>  
        /// 音量变化回调函数定义  
        /// </summary>  
        /// <param name="device">音频设备</param>  
        /// <param name="currentVolume">当前音量</param>  
        /// <param name="lpUserValue">附带信息</param>  
        public delegate void VolumeChangeCallBack(AudioDevice device, int currentVolume, int userValue);  
 
        public delegate void SDKFilterDataCallBack(IntPtr buf,int len,int userValue);  
 
        /// <summary>  
        /// 录像回调函数  
        /// </summary>  
        /// <param name="userId">用户id</param>  
        /// <param name="filePath">录像保存路径</param>  
        /// <param name="param">参数</param>  
        /// <param name="recordType">录像类型,1录像,0拍照</param>  
        /// <param name="userValue">用户参数</param>  
        public delegate void RecordCallBack(int userId, string filePath, int param, bool recordType,int userValue);  
 
        /// <summary>  
        /// 视频回调函数  
        /// </summary>  
        /// <param name="userId"></param>  
        /// <param name="buf"></param>  
        /// <param name="len"></param>  
        /// <param name="bitMap"></param>  
        /// <param name="userValue"></param>  
        public delegate void VideoData_CallBack(int userId, IntPtr buf, int len, BITMAPINFOHEADER bitMap, int userValue);  
 
        /// <summary>  
        /// 声音回调  
        /// </summary>  
        /// <param name="userId"></param>  
        /// <param name="buf"></param>  
        /// <param name="len"></param>  
        /// <param name="format"></param>  
        /// <param name="userValue"></param>  
        public delegate void AudioData_CallBack(int userId,IntPtr buf,int len,WaveFormat format,int userValue);  
 
        /// <summary>  
        /// 消息接收回调  
        /// </summary>  
        /// <param name="fromuserId"></param>  
        /// <param name="touserId"></param>  
        /// <param name="isserect"></param>  
        /// <param name="message"></param>  
        /// <param name="len"></param>  
        /// <param name="userValue"></param>  
        public delegate void TextMessage_CallBack(int fromuserId, int touserId, bool isserect,   
            string message, int len, int userValue);  
 
        /// <summary>  
        /// 视频事件注册  
        /// </summary>  
        /// <param name="format"></param>  
        /// <param name="function"></param>  
        /// <param name="userValue"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetVideoDataCallBack")]  
        public static extern int SetVideoDataCallBack(PixelFormat format, VideoData_CallBack function,int userValue);  
 
 
          
 
        /// <summary>  
        /// SDK Filter 注册回调  
        /// </summary>  
        /// <param name="format"></param>  
        /// <param name="function"></param>  
        /// <param name="userValue"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetSDKFilterDataCallBack")]  
        public static extern int SetSDKFilterDataCallBack(SDKFilterDataCallBack function, int userValue);  
 
        /// <summary>  
        /// SDK Filter 发送数据到服务器端  
        /// </summary>  
        /// <param name="format"></param>  
        /// <param name="function"></param>  
        /// <param name="userValue"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SendSDKFilterData")]  
        public static extern int SendSDKFilterData(IntPtr buf, int len);  
 
          
        /// <summary>  
        /// 声音事件注册  
        /// </summary>  
        /// <param name="format"></param>  
        /// <param name="function"></param>  
        /// <param name="userValue"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetAudioDataCallBack")]  
        public static extern int SetAudioDataCallBack(AudioData_CallBack function, int userValue);  
 
 
        /// <summary>  
        /// 注册文字消息回调  
        /// </summary>  
        /// <param name="format"></param>  
        /// <param name="function"></param>  
        /// <param name="userValue"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetTextMessageCallBack")]  
        public static extern int SetTextMessageCallBack(TextMessage_CallBack function, int userValue);  
 
 
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetServerAuthPass")]  
        public static extern int SetServerAuthPass(StringBuilder key);  
 
        /// <summary>  
        /// 发送消息  
        /// </summary>  
        /// <param name="userID">-1为所有人</param>  
        /// <param name="isSerect">仅用户id 不为-1时有效</param>  
        /// <param name="msg">消息内容</param>  
        /// <param name="len"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SendTextMessage")]  
        public static extern int SendTextMessage(int userID,bool isSerect,string msg,int len);  
          
        /// <summary>  
        /// 与服务器端交换  
        /// </summary>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SendTextMessage")]  
        public static extern int SendSDKFilterData();  
        /// <summary>  
        /// 获取用户名  
        /// </summary>  
        /// <param name="userId">用户ID</param>  
        /// <param name="userName">用户名</param>  
        /// <param name="bufLen">缓冲区长度</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_GetUserName")]  
        public static extern int GetUserName(int userId, StringBuilder userName, int bufLen);  
 
        /// <summary>  
        /// 初始化系统  
        /// </summary>  
        /// <param name="hWnd">接收消息窗口句柄,可为空</param>  
        /// <param name="funcMode">功能模式</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_InitSDK")]  
        public static extern int InitSDK(IntPtr hWnd, ulong funcMode);  
 
        /// <summary>  
        /// 设置透明通道数据回调函数  
        /// </summary>  
        /// <param name="function">回调函数</param>  
        /// <param name="userValue">附带信息</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetTransBufferCallBack")]  
        public static extern int SetTransBufferCallBack(TransBufferCallBack function, int userValue);  
 
        /// <summary>  
        /// 设置透明通道扩展回调函数  
        /// </summary>  
        /// <param name="function">回调函数</param>  
        /// <param name="userValue">附带信息</param>  
        /// <returns>0为成功,否则失败</param>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetTransBufferExCallBack")]  
        public static extern int SetTransBufferExCallBack(TransBufferCallBackEx function, int userValue);  
 
        /// <summary>  
        /// 设置文件传输回调函数  
        /// </summary>  
        /// <param name="function">回调函数</param>  
        /// <param name="userValue">附带信息</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetTransFileCallBack")]  
        public static extern int SetTransFileCallBack(TransFileCallBack function, int userValue);  
 
        /// <summary>  
        /// 设置音量变化回调函数  
        /// </summary>  
        /// <param name="function">回调函数</param>  
        /// <param name="userValue">附带信息</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetVolumeChangeCallBack")]  
        public static extern int SetVolumeChangeCallBack(VolumeChangeCallBack function, int userValue);  
 
        /// <summary>  
        /// 设置录像回调函数  
        /// </summary>  
        /// <param name="function"></param>  
        /// <param name="userValue"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetRecordSnapShotCallBack")]  
        public static extern int SetRecordCallBack(RecordCallBack function, int userValue);  
 
        /// <summary>  
        /// 连接服务器  
        /// </summary>  
        /// <param name="serverAddr">服务器地址</param>  
        /// <param name="port">端口号</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_Connect")]  
        public static extern int Connect(string serverAddr, int port);  
 
        /// <summary>  
        /// 登录系统  
        /// </summary>  
        /// <param name="userName">用户名</param>  
        /// <param name="password">密码</param>  
        /// <param name="passEncType">是否加密</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_Login")]  
        public static extern int Login(string userName, string password, int passEncType);  
 
        /// <summary>  
        /// 进入房间  
        /// </summary>  
        /// <param name="roomid">房间号</param>  
        /// <param name="roomPass">房间密码</param>  
        /// <param name="passEncType">是否加密</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_EnterRoom")]  
        public static extern int EnterRoom(int roomid, string roomPass, int passEncType);  
 
        /// <summary>  
        /// 离开房间  
        /// </summary>  
        /// <param name="roomid">房间号</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_LeaveRoom")]  
        public static extern int LeaveRoom(int roomid);  
 
        /// <summary>  
        /// 注销系统  
        /// </summary>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_Logout")]  
        public static extern int Logout();  
 
        /// <summary>  
        /// 释放所有资源  
        /// </summary>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_Release")]  
        public static extern int Release();  
 
        /// <summary>  
        /// 获取当前房间在线用户列表  
        /// </summary>  
        /// <param name="userIDArray">用户列表</param>  
        /// <param name="userNum">用户数量</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_GetOnlineUser")]  
        public static extern int GetOnlineUser(int[] userIDArray, ref int userNum);  
 
        /// <summary>  
        /// 查询用户摄像头的状态  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="state">当前状态,0为没有摄像头,1为有但没打开,2为已打开</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_GetCameraState")]  
        public static extern int GetCameraState(int userid, ref int state);  
 
        /// <summary>  
        /// 查询用户发言状态  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="state">0为没说话,1为正在说话</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_GetSpeakState")]  
        public static extern int GetSpeakState(int userid, ref int state);  
 
        /// <summary>  
        /// 查询指定用户相关状态(非字符串类型)  
        /// </summary>  
        /// <param name="userid">用户编号</param>  
        /// <param name="infoname">参数名,参考常量定义:BRAC_USERSTATE_XXXX</param>  
        /// <param name="infoval">参数地址</param>  
        /// <param name="infolen">参数长度</param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_QueryUserState")]  
        public static extern int QueryUserState(int userid, int infoname, ref int infoval, int infolen);  
        // BRAC_API DWORD BRAC_QueryUserState(DWORD dwUserId, int infoname, char FAR* infoval, int infolen);  
 
        /// <summary>  
        /// 查询指定用户相关状态(字符串类型)  
        /// </summary>  
        /// <param name="userid">用户编号</param>  
        /// <param name="infoname">参数名,参考常量定义:BRAC_USERSTATE_XXXX</param>  
        /// <param name="infoval">参数地址</param>  
        /// <param name="infolen">参数长度</param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_QueryUserState")]  
        public static extern int QueryUserState(int userid, int infoname, StringBuilder infoval, int infolen);  
        // BRAC_API DWORD BRAC_QueryUserState(DWORD dwUserId, int infoname, char FAR* infoval, int infolen);  
 
        /// <summary>  
        /// 显示本地视频画面调节对话框  
        /// </summary>  
        /// <param name="parent">父窗体句柄</param>  
        /// <param name="caption">窗体标题</param>  
        /// <param name="dwX">X位置</param>  
        /// <param name="dwY">Y位置</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_ShowLVProperty")]  
        public static extern int ShowLVProperty(IntPtr parent, string caption, int dwX, int dwY);  
 
        /// <summary>  
        /// 操作用户视频  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="open">是否打开</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_UserCameraControl")]  
        public static extern int UserCameraControl(int userid, bool open);  
 
        /// <summary>  
        /// 操作用户语音  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="open">是否打开</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_UserSpeakControl")]  
        public static extern int UserSpeakControl(int userid, bool open);  
 
        /// <summary>  
        /// 设置视频显示位置  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="hWnd">窗口句柄</param>  
        /// <param name="left">左位置</param>  
        /// <param name="top">上位置</param>  
        /// <param name="right">右位置</param>  
        /// <param name="bottom">底位置</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetVideoPos")]  
        public static extern int SetVideoPos(int userid, IntPtr hWnd, int left, int top, int right, int bottom);  
 
        /// <summary>  
        /// 获取指定音频设备的当前音量  
        /// </summary>  
        /// <param name="device">音频设备</param>  
        /// <param name="volume">音量</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_AudioGetVolume")]  
        public static extern int AudioGetVolume(AudioDevice device, ref int volume);  
 
        /// <summary>  
        /// 设置指定音频设备的音量  
        /// </summary>  
        /// <param name="device">音频设备</param>  
        /// <param name="volume">音量</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_AudioSetVolume")]  
        public static extern int AudioSetVolume(AudioDevice device, int volume);  
 
        /// <summary>  
        /// 利用透明通道传送数据  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="buf">缓冲区</param>  
        /// <param name="len">缓冲区长度</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_TransBuffer")]  
        public static extern int TransBuffer(int  userid, IntPtr buf, int len);  
 
        /// <summary>  
        /// 利用扩展透明通道传送数据  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="buf">缓冲区</param>  
        /// <param name="len">缓冲区长度</param>  
        /// <param name="wParam">附带信息1</param>  
        /// <param name="lParam">附带信息2</param>  
        /// <param name="flag">特殊标志,默认为0</param>  
        /// <param name="taskId">任务ID,添加任务后系统自动生成</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_TransBufferEx")]  
        public static extern int TransBufferEx(int userid, IntPtr buf, int len, int wParam, int lParam, int flag, ref int taskId);  
 
        /// <summary>  
        /// 传送文件  
        /// </summary>  
        /// <param name="userid">用户ID</param>  
        /// <param name="localFilePath">本地文件路径</param>  
        /// <param name="wParam">附带信息1</param>  
        /// <param name="lParam">附带信息2</param>  
        /// <param name="flag">特殊标志</param>  
        /// <param name="taskId">任务ID</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_TransFile")]  
        public static extern int TransFile(int userid, string localFilePath, int wParam, int lParam, int flag, ref int taskId);  
 
        /// <summary>  
        /// 开启或关闭录像  
        /// </summary>  
        /// <param name="userId">用户id</param>  
        /// <param name="startRecord">是否开启录像</param>  
        /// <param name="flags">标志,0为录制视频音频</param>  
        /// <param name="param">参数</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_StreamRecordCtrl")]  
        public static extern int StreamRecordCtrl(int userId, bool startRecord, ulong flags, int param);  
 
        /// <summary>  
        /// 抓取视频,对指定用户进行拍照  
        /// </summary>  
        /// <param name="userId"></param>  
        /// <param name="flags"></param>  
        /// <param name="param"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SnapShot")]  
        public static extern int SnapShot(int userId, ulong flags, int param);  
 
        /// <summary>  
        /// 是否打开SDK日记  
        /// </summary>  
        /// <param name="isOpen">是否打开</param>  
        /// <returns>0为成功,否则失败</returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_ActiveCallLog")]  
        public static extern int ActiveCallLog(bool isOpen);  
 
        /// <summary>  
        /// 设置SDK内核参数(字符串类型)  
        /// </summary>  
        /// <param name="optName">参数名</param>  
        /// <param name="optval">参数值</param>  
        /// <param name="optlen">参数长度</param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetSDKOption")]  
        public static extern int SetSDKOption(int optName, string optval, int optlen);  
 
        /// <summary>  
        /// 设置SDK内核参数(非字符串类型,INT、BOOL类型)  
        /// </summary>  
        /// <param name="optName">参数名,参考常量定义:BRAC_SO_XXXX</param>  
        /// <param name="optval">参数地址</param>  
        /// <param name="optlen">参数长度</param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SetSDKOption")]  
        public static extern int SetSDKOption(int optName, ref int optval, int optlen);  
 
        /// <summary>  
        /// 获取SDK内核参数  
        /// </summary>  
        /// <param name="optName">参数名,参考常量定义:BRAC_SO_XXXX</param>  
        /// <param name="optval">保存参数值的缓冲区地址</param>  
        /// <param name="optlen">参数缓冲区大小</param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_GetSDKOption")]  
        public static extern int GetSDKOption(int optName, ref int optval, int optlen);  
 
        /// <summary>  
        /// 枚举视频设备  
        /// </summary>  
        /// <param name="deviceName"></param>  
        /// <param name="deviceNum"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_EnumVideoCapture")]  
        public static extern int EnumVideoCapture(IntPtr[] deviceName, ref int deviceNum);  
 
        /// <summary>  
        /// 指定特定视频设备  
        /// </summary>  
        /// <param name="deviceName"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SelectVideoCapture")]  
        public static extern int SelectVideoCapture(string deviceName);  
 
        /// <summary>  
        /// 获取当前视频设备  
        /// </summary>  
        /// <param name="deviceName"></param>  
        /// <param name="length"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_GetCurVideoCapture")]  
        public static extern int GetCurVideoCapture(StringBuilder deviceName, int length);  
 
        /// <summary>  
        /// 枚举音频设备  
        /// </summary>  
        /// <param name="deviceName"></param>  
        /// <param name="deviceNum"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_EnumAudioCapture")]  
        public static extern int EnumAudioCapture(IntPtr[] deviceName, ref int deviceNum);  
 
        /// <summary>  
        /// 指定特定音频设备  
        /// </summary>  
        /// <param name="deviceName"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_SelectAudioCapture")]  
        public static extern int SelectAudioCapture(string deviceName);  
 
        /// <summary>  
        /// 获取当前音频设备  
        /// </summary>  
        /// <param name="deviceName"></param>  
        /// <param name="length"></param>  
        /// <returns></returns>  
        [DllImport("BRAnyChatCore.dll", EntryPoint = "BRAC_GetCurAudioCapture")]  
        public static extern int GetCurAudioCapture(StringBuilder deviceName, int length); 
 
        #endregion  
    }  

详细代码请查看附件

附件:http://download.csdn.net/detail/bairui_allen/4811682

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本源码来自外星人源码论坛 文件夹 PATH 列表 卷序列号码为 0006EE50 EC5F:C44B C:. │ v5目录的结构树.TXT │ www.eenot.net.bat │ ├─开发库 │ ├─Include │ │ │ AndroidUserItem.h │ │ │ AndroidUserManager.h │ │ │ Array.h │ │ │ AvatarControlHead.h │ │ │ BitImage.h │ │ │ BitImageEx.h │ │ │ CameraControl.h │ │ │ CMD_Commom.h │ │ │ CMD_Correspond.h │ │ │ CMD_GameServer.h │ │ │ CMD_LogonServer.h │ │ │ CustomFaceManager.h │ │ │ Custsite.h │ │ │ D2DEngine.h │ │ │ D2DInterface.h │ │ │ D3DDevice.h │ │ │ D3DDirect.h │ │ │ D3DFont.h │ │ │ D3DMusic.h │ │ │ D3DSound.h │ │ │ D3DSoundBuffer.h │ │ │ D3DSoundThread.h │ │ │ D3DSprite.h │ │ │ D3DSurface.h │ │ │ D3DTexture.h │ │ │ DataBaseAide.h │ │ │ Define.h │ │ │ DFontEx.h │ │ │ DirectShowBasic.h │ │ │ DlgBrowser.h │ │ │ DlgGameRule.h │ │ │ DlgInsureCounter.h │ │ │ DlgInsureGame.h │ │ │ DlgMatchAwards.h │ │ │ DlgServerItem.h │ │ │ DlgServerWizard.h │ │ │ DlgTrumpetItem.h │ │ │ DlgVideoClone.h │ │ │ DownLoad.h │ │ │ DownLoadHead.h │ │ │ Expression.h │ │ │ FaceCustomControl.h │ │ │ FaceItemControl.h │ │ │ FaceItemView.h │ │ │ FaceSelectControl.h │ │ │ Flash.ocx │ │ │ FlashControl.h │ │ │ GameEngineHead.h │ │ │ GameFrameApp.h │ │ │ GameFrameAvatar.h │ │ │ GameFrameControl.h │ │ │ GameFrameEngine.h │ │ │ GameFrameHead.h │ │ │ GameFrameMedalView.h │ │ │ GameFramePublicize.h │ │ │ GameFrameService.h │ │ │ GameFrameUserView.h │ │ │ GameFrameView.h │ │ │ GameFrameViewD3D.h │ │ │ GameFrameViewGDI.h │ │ │ GameFrameWnd.h │ │ │ GamePropertyCtrl.h │ │ │ GamePropertyHead.h │ │ │ GamePropertyItem.h │ │ │ GamePropertyManager.h │ │ │ GameServiceHead.h │ │ │ GIFImage.h │ │ │ GlobalServer.h │ │ │ GlobalUnits.h │ │ │ GlobalUserInfo.h │ │ │ HeadTranslate.h │ │ │ IDispimp.h │ │ │ ImageEditorControl.h │ │ │ ImageOle.dll │ │ │ Information.h │ │ │ IPC_GameFrame.h │ │ │ K

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值