Ejemplo n.º 1
0
 static void DataChannelNativeOnClose(IntPtr ptr)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCDataChannel channel)
         {
             channel.onClose?.Invoke();
         }
     });
 }
 static void OnStatsDeliveredCallback(IntPtr ptr, IntPtr report)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.OnStatsDelivered(report);
         }
     });
 }
Ejemplo n.º 3
0
 static void DataChannelNativeOnMessage(IntPtr ptr, byte[] msg, int len)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCDataChannel channel)
         {
             channel.onMessage?.Invoke(msg);
         }
     });
 }
 static void OnSetSessionDescSuccess(IntPtr ptr)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.OnSetSessionDescriptionSuccess();
         }
     });
 }
 static void PCOnDataChannel(IntPtr ptr, IntPtr ptrChannel)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.OnDataChannel?.Invoke(new RTCDataChannel(ptrChannel, connection));
         }
     });
 }
 static void PCOnTrack(IntPtr ptr, IntPtr transceiver)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.OnTrack?.Invoke(new RTCTrackEvent(transceiver, connection));
         }
     });
 }
 static void PCOnIceGatheringChange(IntPtr ptr, RTCIceGatheringState state)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.OnIceGatheringStateChange?.Invoke(state);
         }
     });
 }
 static void PCOnNegotiationNeeded(IntPtr ptr)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.OnNegotiationNeeded?.Invoke();
         }
     });
 }
Ejemplo n.º 9
0
 static void OnVideoFrameResize(IntPtr ptrRenderer, int width, int height)
 {
     WebRTC.Sync(ptrRenderer, () =>
     {
         if (WebRTC.Table[ptrRenderer] is UnityVideoRenderer renderer)
         {
             renderer.OnVideoFrameResizeInternal(width, height);
         }
     });
 }
Ejemplo n.º 10
0
 static void OnAudioReceive(
     IntPtr ptrTrack, float[] audioData, int size, int sampleRate, int numOfChannels, int numOfFrames)
 {
     WebRTC.Sync(ptrTrack, () =>
     {
         if (WebRTC.Table[ptrTrack] is AudioStreamTrack track)
         {
             track.OnAudioReceivedInternal(audioData, sampleRate, numOfChannels, numOfFrames);
         }
     });
 }
Ejemplo n.º 11
0
 static void PCOnTrack(IntPtr ptr, IntPtr transceiver)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             var e = new RTCTrackEvent(transceiver, connection);
             connection.OnTrack?.Invoke(e);
             connection.cacheTracks.Add(e.Track);
         }
     });
 }
 static void OnSetSessionDescFailure(IntPtr ptr, RTCErrorType type, string message)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             RTCError error = new RTCError {
                 errorType = type, message = message
             };
             connection.OnSetSessionDescriptionFailure(error);
         }
     });
 }
 static void OnSuccessCreateSessionDesc(IntPtr ptr, RTCSdpType type, string sdp)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.m_opSessionDesc.Desc = new RTCSessionDescription {
                 sdp = sdp, type = type
             };
             connection.m_opSessionDesc.Done();
         }
     });
 }
 static void OnFailureCreateSessionDesc(IntPtr ptr, RTCErrorType type, string message)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             connection.m_opSessionDesc.IsError = true;
             connection.m_opSessionDesc.Error   = new RTCError {
                 errorType = type, message = message
             };
             connection.m_opSessionDesc.Done();
         }
     });
 }
Ejemplo n.º 15
0
 static void PCOnRemoveTrack(IntPtr ptr, IntPtr receiverPtr)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             var receiver = WebRTC.FindOrCreate(
                 receiverPtr, _ptr => new RTCRtpReceiver(_ptr, connection));
             if (receiver != null)
             {
                 connection.cacheTracks.Remove(receiver.Track);
             }
         }
     });
 }
 static void PCOnIceCandidate(IntPtr ptr, string sdp, string sdpMid, int sdpMlineIndex)
 {
     WebRTC.Sync(ptr, () =>
     {
         if (WebRTC.Table[ptr] is RTCPeerConnection connection)
         {
             var options = new RTCIceCandidateInit
             {
                 candidate     = sdp,
                 sdpMid        = sdpMid,
                 sdpMLineIndex = sdpMlineIndex
             };
             var candidate = new RTCIceCandidate(options);
             connection.OnIceCandidate?.Invoke(candidate);
         }
     });
 }