상속: IDisposable
예제 #1
0
파일: Form1.cs 프로젝트: automaters/RtpLib
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (File.Exists("temp.mpv"))
                File.Delete("temp.mpv");

            _file = new FileStream("temp.mpv", FileMode.CreateNew);

            _listener = RtpListener.Open(txtUri.Text);
            _listener.SequencedMarkerReceived += MarkerReceived;
            _listener.VerifyPayloadType = false;
        }
예제 #2
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                this._rtpListener.PacketReceived -= OnPacketReceived;
                this._rtpListener.Dispose();
            }

            this._rtpListener = null;


            lock (_dataLock)
            {
                if (_data != null)
                {
                    _data = null;
                }
            }
        }
예제 #3
0
        public static RtpListener Open(string uri)
        {
            var       test = new Regex(@"(?<proto>[a-zA-Z]+)://(?<ip>[\d\.]+)?@(?<joinip>[\d\.]+)?(:(?<port>\d+))?");
            int       port;
            IPAddress ip;
            IPAddress joinip;

            Assert.That(test.IsMatch(uri), () => new ArgumentException("Please use a format of 'udp://@MCIP:PORT' where MCIP is a valid multicast IP address.", "uri"));

            var m = test.Match(uri);

            Assert.AreEqual(m.Groups["proto"].Value.ToLower(), "udp", "protocol");

            if (!IPAddress.TryParse(m.Groups["ip"].Value, out ip))
            {
                ip = IPAddress.Any;
            }

            if (!IPAddress.TryParse(m.Groups["joinip"].Value, out joinip))
            {
                joinip = IPAddress.Any;
            }

            if (!int.TryParse(m.Groups["port"].Value, out port))
            {
                port = 1234;
            }


            var client = new RtpListener(new IPEndPoint(ip, port));

            client.StartListening();
            //check if its MC
            if ((joinip.GetAddressBytes()[0] & 224) == 224)
            {
                client._listener.JoinMulticastGroup(joinip);
            }
            return(client);
        }
예제 #4
0
파일: Form1.cs 프로젝트: automaters/RtpLib
 private void btnStop_Click(object sender, EventArgs e)
 {
     if (_listener == null) return;
     _listener.StopListening();
     _listener.Dispose();
     _listener = null;
     _file.Close();
     _file = null;
 }
예제 #5
0
 public RtpStream(int port)
 {
     _rtpListener = new RtpListener(port);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
예제 #6
0
 public RtpStream(IPEndPoint localEp)
 {
     _rtpListener = new RtpListener(localEp);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
예제 #7
0
        public static RtpListener Open(string uri)
        {
            var test = new Regex(@"(?<proto>[a-zA-Z]+)://(?<ip>[\d\.]+)?@(?<joinip>[\d\.]+)?(:(?<port>\d+))?");
            int port;
            IPAddress ip;
            IPAddress joinip;

            Assert.That(test.IsMatch(uri), () => new ArgumentException("Please use a format of 'udp://@MCIP:PORT' where MCIP is a valid multicast IP address.", "uri"));

            var m = test.Match(uri);

            Assert.AreEqual(m.Groups["proto"].Value.ToLower(), "udp", "protocol");

            if (!IPAddress.TryParse(m.Groups["ip"].Value, out ip))
                ip = IPAddress.Any;

            if (!IPAddress.TryParse(m.Groups["joinip"].Value, out joinip))
                joinip = IPAddress.Any;

            if (!int.TryParse(m.Groups["port"].Value, out port))
                port = 1234;

            var client = new RtpListener(new IPEndPoint(ip, port));
            client.StartListening();
            //check if its MC
            if((joinip.GetAddressBytes()[0] & 224) == 224)
                client._listener.JoinMulticastGroup(joinip);
            return client;
        }
예제 #8
0
파일: Form1.cs 프로젝트: kthompson/RtpLib
        private void btnStart_Click(object sender, EventArgs e)
        {
            btnStop_Click(sender, e);
            if (File.Exists("temp.mpv"))
                File.Delete("temp.mpv");

            _file = new FileStream("temp.mpv", FileMode.CreateNew);

            _listener = RtpListener.Open(txtUri.Text);
            _listener.SequencedMarkerReceived += MarkerReceived;
            _listener.PacketLoss += new EventHandler<EventArgs<int>>(OnPacketLoss);
            _listener.VerifyPayloadType = false;
        }
예제 #9
0
 public RtcpClient(RtpListener client, IPEndPoint localEndPoint)
 {
     this.RtpClient = client;
     this.Listener = new UdpListener(localEndPoint);
     this.Listener.ReceiveCallback = this.OnDataReceived;
 }
예제 #10
0
 public RtcpClient(RtpListener client, int port)
     : this(client, new IPEndPoint(IPAddress.Any, port))
 {
 }
예제 #11
0
 public RtpStream(int port)
 {
     _rtpListener = new RtpListener(port);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
예제 #12
0
 public RtpStream(IPEndPoint localEp)
 {
     _rtpListener = new RtpListener(localEp);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
예제 #13
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (disposing)
            {
                this._rtpListener.PacketReceived -= OnPacketReceived;
                this._rtpListener.Dispose();
            }

            this._rtpListener = null;

            lock (_dataLock)
            {
                if(_data != null)
                    _data = null;
            }
        }