Пример #1
0
        /// <summary>
        /// VCHAT释放,需要在SDK的Client.Cleanup之前
        /// </summary>
        /// <returns>无返回值</returns>
        public static void Cleanup()
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            VChatNativeMethods.nim_vchat_cleanup("");
#else
#endif
        }
Пример #2
0
        /// <summary>
        /// 结束通话(需要主动在通话结束后调用,用于底层挂断和清理数据)
        /// </summary>
        /// <param name="jsonExtension">可扩展添加session_id,用于关闭对应的通话,如果session_id缺省.则关闭当前通话.如.{"session_id":"leewp"}</param>
        /// <returns>无返回值</returns>
        public static void End(string jsonExtension = "")
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            VChatNativeMethods.nim_vchat_end(jsonExtension);
#else
#endif
        }
Пример #3
0
        /// <summary>
        /// 设置观众模式(多人模式下),全局有效(重新发起时也生效)
        /// </summary>
        /// <param name="viewer">是否观众模式</param>
        /// <returns>无返回值</returns>
        public static void SetViewerMode(bool viewer)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            VChatNativeMethods.nim_vchat_set_viewer_mode(viewer);
#else
#endif
        }
Пример #4
0
        /// <summary>
        /// 设置音频静音,全局有效(重新发起时也生效)
        /// </summary>
        /// <param name="muted">true 静音,false 不静音</param>
        /// <returns>无返回值</returns>
        public static void SetAudioMute(bool muted)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            VChatNativeMethods.nim_vchat_set_audio_mute(muted);
#else
#endif
        }
Пример #5
0
        /// <summary>
        /// 音视频网络探测接口
        /// </summary>
        /// <param name="json_extension"></param>
        /// <param name="cb">
        /// 回调函数json_extension keys:
        /// "task_id":uint64 任务id
        /// "loss":int 丢包率百分比
        /// "rttmax":int rtt 最大值
        /// "rttmin":int rtt 最小值
        /// "rttavg":int rtt 平均值
        /// "rttmdev":int rtt 偏差值 mdev
        /// "detailinfo":string 扩展信息
        /// </param>
        /// <param name="user_data"></param>
        /// <returns>探测任务id
        /// 200:成功
        /// 0:流程错误
        /// 400:非法请求格式
        /// 417:请求数据不对
        /// 606:ip为内网ip
        /// 607:频率超限
        /// 20001:探测类型错误
        /// 20002:ip错误
        /// 20003:sock错误
        /// </returns>
        public static ulong DetectNetwork(string json_extension, nim_vchat_opt_cb_func cb, IntPtr user_data)
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            var ret = VChatNativeMethods.nim_vchat_net_detect(json_extension, VChatNormalOptCb, ptr);

            return(ret);
        }
Пример #6
0
        /// <summary>
        /// 设置统一的通话回调或者服务器通知
        /// </summary>
        /// <param name="session">回调通知对象</param>
        /// <returns>无返回值</returns>
        public static void SetSessionStatusCb(NIMVChatSessionStatus session)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            session_status = session;
            VChatNativeMethods.nim_vchat_set_cb_func(VChatStatusCb, IntPtr.Zero);
#else
#endif
        }
Пример #7
0
        /// <summary>
        /// 设置单个成员的黑名单状态,即是否显示对方的音频或视频数据,当前通话有效(只能设置进入过房间的成员)
        /// </summary>
        /// <param name="uid">uid成员 account</param>
        /// <param name="add">true:添加到黑名单.false:从黑名单中移除</param>
        /// <param name="audio">ture:表示音频黑名单.false:表示视频黑名单</param>
        /// <param name="json_extension">无效扩展字段</param>
        /// <param name="cb">返回的json_extension无效</param>
        /// <returns>无返回值</returns>
        public static void SetMemberInBlackList(string uid, bool add, bool audio, string json_extension, NIMVChatOptHandler cb)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            VChatNativeMethods.nim_vchat_set_member_in_blacklist(uid, add, audio, json_extension, VChatNormalOptCb, ptr);
#else
#endif
        }
Пример #8
0
        /// <summary>
        /// 获取音频静音状态
        /// </summary>
        /// <returns>bool true 静音,false 不静音</returns>
        public static bool GetAudioMuteEnabled()
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            return(VChatNativeMethods.nim_vchat_audio_mute_enabled());
#else
            return(false);
#endif
        }
Пример #9
0
        /// <summary>
        /// 音视频通话控制操作
        /// </summary>
        /// <param name="channel_id">音视频通话通道id</param>
        /// <param name="type">操作类型</param>
        /// <returns>bool true 调用成功,false 调用失败</returns>
        public static bool ChatControl(long channel_id, NIMVChatControlType type)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            return(VChatNativeMethods.nim_vchat_control(channel_id, type, "", IntPtr.Zero));
#else
            return(false);
#endif
        }
Пример #10
0
        /// <summary>
        /// 获取当前是否是观众模式
        /// </summary>
        /// <returns>bool true 观众模式,false 非观众模式</returns>
        public static bool GetViewerMode()
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            return(VChatNativeMethods.nim_vchat_get_viewer_mode());
#else
            return(false);
#endif
        }
Пример #11
0
        /// <summary>
        /// 通话中修改自定义音视频数据模式
        /// </summary>
        /// <param name="custom_audio">true:表示使用自定义的音频数据.false:表示不使用</param>
        /// <param name="custom_video">true:表示使用自定义的视频数据.false:表示不使用</param>
        /// <param name="json_extension">无效扩展字段</param>
        /// <param name="cb">cb 结果回调</param>
        /// <returns>无返回值</returns>
        public static void SetCustomData(bool custom_audio, bool custom_video, string json_extension, NIMVChatOptHandler cb)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            VChatNativeMethods.nim_vchat_set_custom_data(custom_audio, custom_video, json_extension, VChatNormalOptCb, ptr);
#else
#endif
        }
Пример #12
0
        /// <summary>
        /// 设置通话模式,在更改通话模式后,通知底层
        /// </summary>
        /// <param name="mode">音视频通话类型</param>
        /// <returns>true 调用成功,false 调用失败</returns>
        ///
        public static bool SetMode(NIMVideoChatMode mode)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            return(VChatNativeMethods.nim_vchat_set_talking_mode(mode, ""));
#else
            return(false);
#endif
        }
Пример #13
0
        /// <summary>
        /// 启动点对点通话
        /// </summary>
        /// <param name="mode">启动音视频通话类型</param>
        /// <param name="apns_text">自定义推送字段,填空用默认推送</param>
        /// <param name="info">json扩展封装类,见NIMVChatInfo</param>
        /// <param name="customInfo">自定义信息</param>
        /// <returns> bool true 调用成功,false 调用失败可能有正在进行的通话</returns>
        public static bool Start(NIMVideoChatMode mode, string apns_text, NIMVChatInfo info, string customInfo = null)
        {
            if (info == null)
            {
                info = new NIMVChatInfo();
            }
            string json_extension = info.Serialize();

            return(VChatNativeMethods.nim_vchat_start(mode, apns_text, customInfo, json_extension, IntPtr.Zero));
        }
Пример #14
0
        /// <summary>
        /// 音视频通话重新连接,用于底层链接在上层认为异常时尝试重连
        /// </summary>
        /// <param name="json_extension">可扩展添加kNIMVChatSessionId,用于指定对应的通话</param>
        /// <param name="cb">操作结果的回调函数,当通话通话不存在或通话</param>
        public static void NIMVChatRelogin(string sessionid, NIMVChatOptHandler cb)
        {
            NIMVChatInfo vchatinfo = new NIMVChatInfo();

            vchatinfo.SessionId = sessionid;
            string json_extension = vchatinfo.Serialize();
            var    ptr            = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            VChatNativeMethods.nim_vchat_relogin(json_extension, VChatNormalOptCb, ptr);
        }
Пример #15
0
        /// <summary>
        /// 停止录制MP4
        /// </summary>
        /// <param name="recordInfo">json扩展封装类,见NIMVChatMP4RecordJsonEx</param>
        /// <param name="cb">结果回调</param>
        /// <returns>无返回值</returns>
        public static void StopRecord(NIMVChatMP4RecordJsonEx recordInfo, NIMVChatMp4RecordOptHandler cb)
        {
            if (recordInfo == null)
            {
                recordInfo = new NIMVChatMP4RecordJsonEx();
            }
            string json_extension = recordInfo.Serialize();
            var    ptr            = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            VChatNativeMethods.nim_vchat_stop_record(json_extension, VChatMP4RecordOptCb, ptr);
        }
Пример #16
0
        /// <summary>
        /// 回应音视频通话邀请
        /// </summary>
        /// <param name="channel_id">音视频通话通道id</param>
        /// <param name="accept">true 接受,false 拒绝</param>
        /// <param name="info">json扩展封装类,见NIMVChatInfo</param>
        /// <returns>bool true 调用成功,false 调用失败(可能channel_id无匹配,如要接起另一路通话前先结束当前通话)</returns>
        public static bool CalleeAck(long channel_id, bool accept, NIMVChatInfo info)
        {
            if (info == null)
            {
                info = new NIMVChatInfo();
            }
            string json_extension = info.Serialize();

            //string debug_info = string.Format("callee ack.cid:{0},accept:{1},info:{2}", channel_id, accept, json_extension);
            //System.Diagnostics.Debug.WriteLine(debug_info);
            return(VChatNativeMethods.nim_vchat_callee_ack(channel_id, accept, json_extension, IntPtr.Zero));
        }
Пример #17
0
        /// <summary>
        /// VCHAT初始化,需要在SDK的Client.Init成功之后
        /// </summary>
        /// <param name="path">服务器配置文件路径 </param>
        /// <returns>初始化结果,如果是false则以下所有接口调用无效</returns>
        public static bool Init(string server_setting_path)
        {
            string info = "";

            if (!String.IsNullOrEmpty(server_setting_path))
            {
                NIMVChatResourceJsonEx json = new NIMVChatResourceJsonEx();
                json.Path = server_setting_path;
                info      = json.Serialize();
            }
            return(VChatNativeMethods.nim_vchat_init(info));
        }
Пример #18
0
        /// <summary>
        ///创建一个多人房间(后续需要主动调用加入接口进入房间)
        /// </summary>
        /// <param name="room_name">房间名</param>
        /// <param name="custom_info">自定义的房间信息(加入房间的时候会返回)</param>
        /// <param name="createRoomInfo">json封装类,见NIMCreateRoomJsonEx</param>
        /// <param name="cb">结果回调</param>
        /// <returns>无返回值</returns>
        public static void CreateRoom(string room_name, string custom_info, NIMCreateRoomJsonEx createRoomInfo, NIMVChatOpt2Handler cb)
        {
            string json_extension = null;

            if (createRoomInfo != null)
            {
                json_extension = createRoomInfo.Serialize();
            }
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            VChatNativeMethods.nim_vchat_create_room(room_name, custom_info, json_extension, VChatOpt2Cb, ptr);
        }
Пример #19
0
        /// <summary>
        /// 音视频网络探测接口,需要在sdk初始化时带上app key
        /// </summary>
        /// <param name="json_extension">扩展参数,允许用户设置探测时间限制kNIMNetDetectTimeLimit,及探测类型kNIMNetDetectType</param>
        /// <param name="cb">操作结果的回调函数</param>
        /// <returns>探测任务id</returns>
        /// 回调函数json_extension keys:
        /// "task_id":uint64 任务id
        /// "loss":int 丢包率百分比
        /// "rttmax":int rtt 最大值
        /// "rttmin":int rtt 最小值
        /// "rttavg":int rtt 平均值
        /// "rttmdev":int rtt 偏差值 mdev
        /// "detailinfo":string 扩展信息
        /// </param>
        /// <param name="user_data"></param>
        /// <returns>探测任务id
        /// 200:成功
        /// 0:流程错误
        /// 400:非法请求格式
        /// 417:请求数据不对
        /// 606:ip为内网ip
        /// 607:频率超限
        /// 20001:探测类型错误
        /// 20002:ip错误
        /// 20003:sock错误
        /// </returns>
        public static ulong DetectNetwork(NIMVChatNetDetectJsonEx json, NIMVChatOptHandler cb)
        {
            string json_str = "";

            if (json != null)
            {
                json_str = json.Serialize();
            }
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            var ret = VChatNativeMethods.nim_vchat_net_detect(json_str, VChatNormalOptCb, ptr);

            return(ret);
        }
Пример #20
0
        /// <summary>
        /// 回应音视频通话邀请
        /// </summary>
        /// <param name="channel_id">音视频通话通道id</param>
        /// <param name="accept">true 接受,false 拒绝</param>
        /// <param name="info">json扩展封装类,见NIMVChatInfo</param>
        /// <returns>bool true 调用成功,false 调用失败(可能channel_id无匹配,如要接起另一路通话前先结束当前通话)</returns>
        public static bool CalleeAck(long channel_id, bool accept, NIMVChatInfo info)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            if (info == null)
            {
                info = new NIMVChatInfo();
            }
            string json_extension = info.Serialize();
            return(VChatNativeMethods.nim_vchat_callee_ack(channel_id, accept, json_extension, IntPtr.Zero));
#else
            return(false);
#endif
        }
Пример #21
0
        /// <summary>
        /// 启动点对点通话
        /// </summary>
        /// <param name="mode">启动音视频通话类型</param>
        /// <param name="apns_text">自定义推送字段,填空用默认推送</param>
        /// <param name="info">json扩展封装类,见NIMVChatInfo</param>
        /// <param name="customInfo">自定义信息</param>
        /// <returns> bool true 调用成功,false 调用失败可能有正在进行的通话</returns>
        public static bool Start(NIMVideoChatMode mode, string apns_text, NIMVChatInfo info, string customInfo = null)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            if (info == null)
            {
                info = new NIMVChatInfo();
            }
            string json_extension = info.Serialize();
            return(VChatNativeMethods.nim_vchat_start(mode, apns_text, customInfo, json_extension, IntPtr.Zero));
#else
            return(false);
#endif
        }
Пример #22
0
        /// <summary>
        ///创建一个多人房间(后续需要主动调用加入接口进入房间)
        /// </summary>
        /// <param name="room_name">房间名</param>
        /// <param name="custom_info">自定义的房间信息(加入房间的时候会返回)</param>
        /// <param name="createRoomInfo">json封装类,见NIMCreateRoomJsonEx</param>
        /// <param name="cb">结果回调</param>
        /// <returns>无返回值</returns>
        public static void CreateRoom(string room_name, string custom_info, NIMCreateRoomJsonEx createRoomInfo, NIMVChatOpt2Handler cb)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            string json_extension = null;
            if (createRoomInfo != null)
            {
                json_extension = createRoomInfo.Serialize();
            }
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            VChatNativeMethods.nim_vchat_create_room(room_name, custom_info, json_extension, VChatOpt2Cb, ptr);
#else
#endif
        }
Пример #23
0
        /// <summary>
        /// 加入一个多人房间(进入房间后成员变化等,等同点对点NIMVChatHander)
        /// </summary>
        /// <param name="mode">音视频通话类型</param>
        /// <param name="room_name">房间名</param>
        /// <param name="joinRoomInfo">json封装类,见NIMJoinRoomJsonEx</param>
        /// <param name="cb">cb 结果回调,返回的json_extension扩展字段中包含 "custom_info","session_id"</param>
        /// <returns>bool true 调用成功,false 调用失败可能有正在进行的通话</returns>
        public static bool JoinRoom(NIMVideoChatMode mode, string room_name, NIMJoinRoomJsonEx joinRoomInfo, NIMVChatOpt2Handler cb)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            if (joinRoomInfo == null)
            {
                joinRoomInfo = new NIMJoinRoomJsonEx();
            }
            string json_extension = joinRoomInfo.Serialize();
            var    ptr            = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            return(VChatNativeMethods.nim_vchat_join_room(mode, room_name, json_extension, VChatOpt2Cb, ptr));
#else
            return(false);
#endif
        }
Пример #24
0
        /// <summary>
        /// VCHAT初始化,需要在SDK的Client.Init成功之后
        /// </summary>
        /// <param name="path">nrtc等资源库路径,Unity下有效</param>
        /// <returns>初始化结果,如果是false则以下所有接口调用无效</returns>
        public static bool Init(string path)
        {
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN
            string info = "";
            if (!String.IsNullOrEmpty(path))
            {
                NIMVChatResourceJsonEx json = new NIMVChatResourceJsonEx();
                json.Path = path;
                info      = json.Serialize();
            }
            return(VChatNativeMethods.nim_vchat_init(info));
#else
            return(false);
#endif
        }
Пример #25
0
        /// <summary>
        /// 加入一个多人房间(进入房间后成员变化等,等同点对点NIMVChatHander)
        /// </summary>
        /// <param name="mode">音视频通话类型</param>
        /// <param name="room_name">房间名</param>
        /// <param name="joinRoomInfo">json封装类,见NIMJoinRoomJsonEx</param>
        /// <param name="cb">cb 结果回调,返回的json_extension扩展字段中包含 "custom_info","session_id"</param>
        /// <returns>bool true 调用成功,false 调用失败可能有正在进行的通话</returns>
        public static bool JoinRoom(NIMVideoChatMode mode, string room_name, NIMJoinRoomJsonEx joinRoomInfo, NIMVChatOpt2Handler cb)
        {
            if (joinRoomInfo == null)
            {
                joinRoomInfo = new NIMJoinRoomJsonEx();
#if NIMAPI_UNDER_WIN_DESKTOP_ONLY
                CustomLayout layout = new CustomLayout();
                layout.Hostarea     = new HostArea();
                layout.Background   = new BackGround();
                joinRoomInfo.Layout = layout.Serialize();
#endif
            }
            string json_extension = joinRoomInfo.Serialize();
            var    ptr            = NimUtility.DelegateConverter.ConvertToIntPtr(cb);
            return(VChatNativeMethods.nim_vchat_join_room(mode, room_name, json_extension, VChatOpt2Cb, ptr));
        }
Пример #26
0
        /// <summary>
        /// VCHAT初始化,需要在SDK的Client.Init成功之后
        /// </summary>
        /// <param name="path">nrtc等资源库路径,Unity下pc有效</param>
        /// <param name="context">android 上下文,Unity下android有效</param>
        /// <returns>初始化结果,如果是false则以下所有接口调用无效</returns>
        public static bool Init(string path, IntPtr context)
        {
            string info = "";

            if (!String.IsNullOrEmpty(path))
            {
                NIMVChatResourceJsonEx json = new NIMVChatResourceJsonEx();
                json.Path = path;
                info      = json.Serialize();
            }

#if UNITY_ANDROID
            return(VChatNativeMethods.nim_vchat_init(context));
#else
            return(VChatNativeMethods.nim_vchat_init(info));
#endif
        }
Пример #27
0
        /// <summary>
        ///  互动直播设置uid为房间主画面
        /// </summary>
        /// <param name="uid">用户uid</param>
        /// <param name="json_extension">无效扩展字段</param>
        /// <param name="cb">回调函数</param>
        public static void NIMVChatSetUidPictureAsMain(string uid, string json_extension, NIMVChatOptHandler cb)
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            VChatNativeMethods.nim_vchat_set_uid_picture_as_main(uid, json_extension, VChatNormalOptCb, ptr);
        }
Пример #28
0
        /// <summary>
        /// 通话中修改视频编码模式
        /// </summary>
        /// <param name="mode">选用的策略模式</param>
        /// <param name="json_extension">无效扩展字段</param>
        /// <param name="cb">回调函数,code 见</param>
        public static void NIMVChatSelectVideoAdaptiveStrategy(NIMVChatVideoEncodeMode mode, string json_extension, NIMVChatOptHandler cb)
        {
            var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(cb);

            VChatNativeMethods.nim_vchat_select_video_adaptive_strategy(mode, json_extension, VChatNormalOptCb, ptr);
        }
Пример #29
0
        /// <summary>
        /// 获取视频画面的裁剪模式
        /// </summary>
        /// <returns>当前的裁剪模式NIMVChatVideoFrameScaleType</returns>
        public static NIMVChatVideoFrameScaleType GetVideoFrameScale()
        {
            int ret = VChatNativeMethods.nim_vchat_get_video_frame_scale_type();

            return((NIMVChatVideoFrameScaleType)Enum.ToObject(typeof(NIMVChatVideoFrameScaleType), ret));
        }
Пример #30
0
 /// <summary>
 /// 设置发送时视频画面的长宽比例裁剪模式,裁剪的时候不改变横竖屏(重新发起时也生效)
 /// </summary>
 /// <param name="type">裁剪模式NIMVChatVideoFrameScaleType</param>
 /// <returns>无返回值</returns>
 public static void SetVideoFrameScale(NIMVChatVideoFrameScaleType type)
 {
     VChatNativeMethods.nim_vchat_set_video_frame_scale(type);
 }