public PeerConnectionObserver()
        {
            Native = new PeerConnectionObserverSafeHandle();

            var userData = GCHandleHelper.ToIntPtr(this, out _handle);

            SetRenegotiationNeededCallback(Native, _renegotiationNeededCallback, userData);
            SetIceGatheringStateChangedCallback(Native, _iceGatheringStateChangedCallback, userData);
            SetIceConnectionChangeCallback(Native, _iceConnectionChangeCallback, userData);
            SetIceCandidateCallback(Native, _iceCandidateCallback, userData);
            SetIceCandidatesRemovedCallback(Native, _iceCandidatesRemovedCallback, userData);
            SetRemoteTrackAddedCallback(Native, _remoteTrackAddedCallback, userData);
            SetRemoteTrackRemovedCallback(Native, _remoteTrackRemovedCallback, userData);
        }
Esempio n. 2
0
        public void Post(Action <object> handler, object userData = null)
        {
            var actualHandler = new RtcThreadInterops.Handler(userDataPtr =>
            {
                try
                {
                    handler(userData);
                }
                catch (Exception ex)
                {
                    _logger.Error(ex, "Action posted to unmanaged thread caused an exception");
                }
                finally
                {
                    GCHandle.FromIntPtr(userDataPtr).Free();
                }
            });

            RtcThreadInterops.Post(_handle, actualHandler, GCHandleHelper.ToIntPtr(actualHandler));
        }