示例#1
0
 internal static extern void PeerConnection_CreateAnswer(IntPtr ptr,
                                                         WebrtcUnityResult2Callback success,
                                                         WebrtcUnityResultCallback failure,
                                                         bool offer_to_receive_video,
                                                         bool offer_to_receive_audio,
                                                         bool voice_activity_detection,
                                                         bool ice_restart,
                                                         bool use_rtp_mux);
示例#2
0
        /// <summary>
        /// 创建Offer
        /// </summary>
        /// <param name="ice_restart">ice restart</param>
        /// <param name="voice_activity_detection">voice activity detection</param>
        /// <param name="use_rtp_mux">use rtp mux</param>
        /// <returns>offer 字符串</returns>
        public async Task <string> CreateOffer(
            bool ice_restart = false,
            bool voice_activity_detection = true,
            bool use_rtp_mux = true)
        {
            var holder = new UnmanageHolder();

            try
            {
                return(await Promise <string> .Await((cs, ce) =>
                {
                    WebrtcUnityResult2Callback done = (type, sdp) =>
                    {
                        unsafe
                        {
                            //var strType = new string((sbyte*)type.ToPointer());
                            var strSdp = new string((sbyte *)sdp.ToPointer());
                            cs(strSdp);
                        }
                    };
                    WebrtcUnityResultCallback error = msg =>
                    {
                        unsafe
                        {
                            ce(new Exception(new string((sbyte *)msg.ToPointer())));
                        }
                    };
                    holder.Hold(done, error);
                    PeerConnection_CreateOffer(Handler,
                                               done,
                                               error,
                                               true,
                                               true,
                                               voice_activity_detection,
                                               ice_restart,
                                               use_rtp_mux);
                }));
            }
            finally
            {
                holder.Release();
            }
        }