示例#1
0
        private void OnReceived(IAsyncResult ar)
        {
            if (this.disposed)
            {
                return;
            }

            var ep = this.RemoteEndpoint;

            byte[] buffer;

            try
            {
                buffer = this.receiveSocket.EndReceive(ar, ref ep);
            }
            catch (SocketException ex)
            {
                if (ex.SocketErrorCode == SocketError.ConnectionReset)
                {
                    return;
                }

                Console.WriteLine("number = {0}. Code = {1}", ex.ErrorCode, ex.SocketErrorCode);
                throw;
            }

            this.receiveSocket.BeginReceive(this.OnReceived, null);

            if (buffer != null && buffer.Length > 0)
            {
                var packet = new RtpPayload(buffer);
                this.receiveCallback.BeginInvoke(packet, 0, null, null);
            }
        }
示例#2
0
        public void AddSample(RtpPayload rtpPacket)
        {
            if (this.RemoteEndpoint == null)
            {
                return;
            }

            var data = rtpPacket.ToArray();

            this.receiveSocket.Send(data, data.Length, this.RemoteEndpoint);
        }