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; }
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; } } }
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); }
private void btnStop_Click(object sender, EventArgs e) { if (_listener == null) return; _listener.StopListening(); _listener.Dispose(); _listener = null; _file.Close(); _file = null; }
public RtpStream(int port) { _rtpListener = new RtpListener(port); _rtpListener.PacketReceived += OnPacketReceived; this.AutoFlush = true; }
public RtpStream(IPEndPoint localEp) { _rtpListener = new RtpListener(localEp); _rtpListener.PacketReceived += OnPacketReceived; this.AutoFlush = true; }
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; }
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; }
public RtcpClient(RtpListener client, IPEndPoint localEndPoint) { this.RtpClient = client; this.Listener = new UdpListener(localEndPoint); this.Listener.ReceiveCallback = this.OnDataReceived; }
public RtcpClient(RtpListener client, int port) : this(client, new IPEndPoint(IPAddress.Any, port)) { }
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; } }