Example #1
0
 /// <summary>
 /// 持有一个数据通道
 /// </summary>
 /// <param name="handler">数据通道指针</param>
 internal protected RTCDataChannel(IntPtr handler) : base(handler)
 {
     _stateChange         = () => this.OnStateChange();
     _message             = buffer => this.OnMessage(buffer);
     _bufferedAmoutChange = state => this.OnBufferedAmoutChange(state);
     this.observer        = new WebrtcObjectRef(RTCDataChannel_RegisterObserver(handler, _stateChange, _message, _bufferedAmoutChange), "RTCDataChannel Observer");
 }
Example #2
0
 /// <summary>
 /// 添加监听器
 /// </summary>
 private void AddSink()
 {
     if (sink != null) return;
     IntPtr ptr = default;
     Dispatcher.Invoke(() => ptr = VideoTrack_AddSink(Handler, NativeDataReady));
     if (ptr == IntPtr.Zero) throw new Exception("AddSink C++ Error");
     sink = new WebrtcObjectUnref(ptr, "VideoTrack Sink");
 }
Example #3
0
 /// <summary>
 /// 从C++移除监听器
 /// </summary>
 private void RemoveSinkPrivate()
 {
     if (sink == null)
     {
         return;
     }
     AudioSource_RemoveSink(Handler, sink.Handler);
     sink = null;
 }
Example #4
0
 /// <summary>
 /// 检查删除指针时,是否需要从缓存里面干掉
 /// </summary>
 /// <param name="val"></param>
 private static void Val_BeforeDelete(WebrtcObject val)
 {
     val.BeforeDelete -= Val_BeforeDelete;
     lock (senderCache)
     {
         var key = val.Handler.ToInt64();
         senderCache.Remove(key);
     }
 }
Example #5
0
 /// <summary>
 /// 删除监听器
 /// </summary>
 private void RemoveSink()
 {
     if (sink == null)
     {
         return;
     }
     Dispatcher.Invoke(() => VideoTrack_RemoveSink(Handler, sink.Handler));
     sink = null;
 }
Example #6
0
        /// <summary>
        /// 添加监听器到C++
        /// </summary>
        protected virtual void AddSink()
        {
            if (sink != null)
            {
                return;
            }
            IntPtr ptr = AudioSource_AddSink(Handler, DataReadyCallback);

            if (ptr == IntPtr.Zero)
            {
                throw new Exception("AddSink C++ Error");
            }
            sink = new WebrtcObjectRef(ptr, "AudioSource Sink");
        }
Example #7
0
        /// <summary>
        /// 添加监听器
        /// </summary>
        protected virtual void AddSink()
        {
            if (sink != null)
            {
                return;
            }
            IntPtr ptr = VideoSource_AddSink(Handler, NativeDataReady);

            if (ptr == IntPtr.Zero)
            {
                throw new Exception("AddSink C++ Error");
            }
            sink = new WebrtcObjectUnref(ptr, "VideoSource Sink");
        }
Example #8
0
        /// <summary>
        /// 添加监听器到C++
        /// </summary>
        private void AddSink()
        {
            if (sink != null)
            {
                return;
            }
            IntPtr ptr = default;

            Dispatcher.Invoke(() => ptr = AudioTrack_AddSink(Handler, DataReadyCallback));
            if (ptr == IntPtr.Zero)
            {
                throw new Exception("AddSink C++ Error");
            }
            sink = new WebrtcObjectRef(ptr, "AudioTrack Sink");
        }