public static void Init() { //注册视频采集数据回调 //JObject jo = new JObject(); //jo.Add(new JProperty("subtype", NIMVideoSubType.kNIMVideoSubTypeI420)); //string json_extention = jo.ToString(); NIM.NIMVChatCustomAudioJsonEx audioJsonEx = new NIMVChatCustomAudioJsonEx(); NIM.NIMVChatCustomVideoJsonEx videoJsonEx = new NIMVChatCustomVideoJsonEx(); videoJsonEx.VideoSubType = Convert.ToInt32(NIMVideoSubType.kNIMVideoSubTypeI420); NIM.DeviceAPI.SetVideoCaptureDataCb(VideoDataCaptureHandler, videoJsonEx); NIM.DeviceAPI.SetAudioCaptureDataCb(AudioDataCaptureHandler, audioJsonEx); }
/// <summary> /// 监听接收音频数据(可以不监听,通过启动设备kNIMDeviceTypeAudioOutChat由底层播放) /// </summary> /// <param name="handler">回调</param> /// <returns>无返回值</returns> public static void SetAudioReceiveDataCb(AudioDataHandler handler, NIMVChatCustomAudioJsonEx audioJsonEx) { #if NIMAPI_UNDER_WIN_DESKTOP_ONLY || UNITY_STANDALONE_WIN string audioInfo = ""; if (audioJsonEx != null) { audioInfo = audioJsonEx.Serialize(); } var ptr = NimUtility.DelegateConverter.ConvertToIntPtr(handler); DeviceNativeMethods.nim_vchat_set_audio_data_cb(false, audioInfo, AudioDataCb, ptr); #else #endif }