Inheritance: IDisposable
Exemplo n.º 1
0
        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;
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     if (_listener == null) return;
     _listener.StopListening();
     _listener.Dispose();
     _listener = null;
     _file.Close();
     _file = null;
 }
Exemplo n.º 5
0
 public RtpStream(int port)
 {
     _rtpListener = new RtpListener(port);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
Exemplo n.º 6
0
 public RtpStream(IPEndPoint localEp)
 {
     _rtpListener = new RtpListener(localEp);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
Exemplo n.º 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;
        }
Exemplo n.º 8
0
        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;
        }
Exemplo n.º 9
0
 public RtcpClient(RtpListener client, IPEndPoint localEndPoint)
 {
     this.RtpClient = client;
     this.Listener = new UdpListener(localEndPoint);
     this.Listener.ReceiveCallback = this.OnDataReceived;
 }
Exemplo n.º 10
0
 public RtcpClient(RtpListener client, int port)
     : this(client, new IPEndPoint(IPAddress.Any, port))
 {
 }
Exemplo n.º 11
0
 public RtpStream(int port)
 {
     _rtpListener = new RtpListener(port);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
Exemplo n.º 12
0
 public RtpStream(IPEndPoint localEp)
 {
     _rtpListener = new RtpListener(localEp);
     _rtpListener.PacketReceived += OnPacketReceived;
     this.AutoFlush = true;
 }
Exemplo n.º 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;
            }
        }