예제 #1
0
파일: RtpStream.cs 프로젝트: inrg/sipstack
        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
파일: RtpStream.cs 프로젝트: inrg/sipstack
        public void AddSample(RtpPayload rtpPacket)
        {
            if (this.RemoteEndpoint == null)
            {
                return;
            }

            var data = rtpPacket.ToArray();

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