diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-07-22 16:52:00 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2024-07-22 16:52:00 +0200 |
commit | 3986a7b40c0043ec33c2c2b7cf5c615c65599997 (patch) | |
tree | 8600d4d1615ca80ed6cc99ea0141e32dcf99cce8 | |
parent | d92a11ac9bcbb16e1eb4940343c5e61db7ad33eb (diff) | |
download | dabmux-3986a7b40c0043ec33c2c2b7cf5c615c65599997.tar.gz dabmux-3986a7b40c0043ec33c2c2b7cf5c615c65599997.tar.bz2 dabmux-3986a7b40c0043ec33c2c2b7cf5c615c65599997.zip |
Rework STI/EDI/UDP multicast input group join
-rw-r--r-- | doc/example.mux | 2 | ||||
-rw-r--r-- | src/input/Edi.cpp | 23 |
2 files changed, 23 insertions, 2 deletions
diff --git a/doc/example.mux b/doc/example.mux index 383a2ab..d53b789 100644 --- a/doc/example.mux +++ b/doc/example.mux @@ -215,6 +215,8 @@ subchannels { ;inputuri "udp://:9001" ; Multicast UDP input: ;inputuri "udp://@239.10.0.1:9001" + ; Multicast UDP input with local interface (192.168.0.10) specification + ;inputuri "udp://192.168.0.10@239.10.0.1:9001" ; Two buffer-management types are available: prebuffering and timestamped. ; prebuffering will accumulate a few frames before it starts streaming, and each diff --git a/src/input/Edi.cpp b/src/input/Edi.cpp index 3838541..fc380d8 100644 --- a/src/input/Edi.cpp +++ b/src/input/Edi.cpp @@ -81,6 +81,7 @@ void Edi::open(const std::string& name) { const std::regex re_udp("udp://:([0-9]+)"); const std::regex re_udp_multicast("udp://@([0-9.]+):([0-9]+)"); + const std::regex re_udp_multicast_bindto("udp://([0-9.])+@([0-9.]+):([0-9]+)"); const std::regex re_tcp("tcp://(.*):([0-9]+)"); lock_guard<mutex> lock(m_mutex); @@ -97,13 +98,31 @@ void Edi::open(const std::string& name) m_udp_sock.reinit(udp_port); m_udp_sock.setBlocking(false); } + else if (std::regex_match(name, m, re_udp_multicast_bindto)) { + const string bind_to = m[1].str(); + const string multicast_address = m[2].str(); + const int udp_port = std::stoi(m[3].str()); + + m_input_used = InputUsed::UDP; + if (IN_MULTICAST(ntohl(inet_addr(multicast_address.c_str())))) { + m_udp_sock.init_receive_multicast(udp_port, bind_to, multicast_address); + } + else { + throw runtime_error(string("Address ") + multicast_address + " is not a multicast address"); + } + m_udp_sock.setBlocking(false); + } else if (std::regex_match(name, m, re_udp_multicast)) { const string multicast_address = m[1].str(); const int udp_port = std::stoi(m[2].str()); m_input_used = InputUsed::UDP; - m_udp_sock.reinit(udp_port); + if (IN_MULTICAST(ntohl(inet_addr(multicast_address.c_str())))) { + m_udp_sock.init_receive_multicast(udp_port, "0.0.0.0", multicast_address); + } + else { + throw runtime_error(string("Address ") + multicast_address + " is not a multicast address"); + } m_udp_sock.setBlocking(false); - m_udp_sock.joinGroup(multicast_address.c_str()); } else if (std::regex_match(name, m, re_tcp)) { m_input_used = InputUsed::TCP; |