From 9e5b98875f4430473ea3ffebb804cea69008d8fb Mon Sep 17 00:00:00 2001
From: Stefan Becker <chemobejk@gmail.com>
Date: Fri, 13 Dec 2013 22:12:04 +0200
Subject: [PATCH] Fixes #10667. Bind to multicast address.
If multiple servers multicast content on the same port we can't receive
it on multiple recorders if bind to QHostAddress::Any. If we bind to the
multicast address we don't have this problem. Problem discovered and
patched by Niels Ole Kirkeby.
Note: This also adds error handling for when a bind fails.
---
.../libs/libmythtv/recorders/iptvstreamhandler.cpp | 28 ++++++++++++++--------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/mythtv/libs/libmythtv/recorders/iptvstreamhandler.cpp b/mythtv/libs/libmythtv/recorders/iptvstreamhandler.cpp
index 432d248..9fb74eb 100644
|
a
|
b
|
void IPTVStreamHandler::run(void)
|
| 167 | 167 | "", 0); |
| 168 | 168 | } |
| 169 | 169 | |
| | 170 | bool error = false; |
| 170 | 171 | for (uint i = 0; i < IPTV_SOCKET_COUNT; i++) |
| 171 | 172 | { |
| 172 | 173 | QUrl url = tuning.GetURL(i); |
| … |
… |
void IPTVStreamHandler::run(void)
|
| 210 | 211 | m_sockets[i]->setSocketDescriptor( |
| 211 | 212 | fd, QAbstractSocket::UnconnectedState, QIODevice::ReadOnly); |
| 212 | 213 | |
| 213 | | m_sockets[i]->bind(QHostAddress::Any, url.port()); |
| 214 | | |
| 215 | 214 | QHostAddress dest_addr(tuning.GetURL(i).host()); |
| 216 | 215 | |
| | 216 | if (!m_sockets[i]->bind(dest_addr, url.port())) |
| | 217 | { |
| | 218 | LOG(VB_GENERAL, LOG_ERR, LOC + "Binding to port failed."); |
| | 219 | error = true; |
| | 220 | } |
| | 221 | |
| 217 | 222 | if (dest_addr != QHostAddress::Any) |
| 218 | 223 | { |
| 219 | 224 | //m_sockets[i]->joinMulticastGroup(dest_addr); // needs Qt 4.8 |
| … |
… |
void IPTVStreamHandler::run(void)
|
| 235 | 240 | if (!url.userInfo().isEmpty()) |
| 236 | 241 | m_sender[i] = QHostAddress(url.userInfo()); |
| 237 | 242 | } |
| 238 | | if (m_use_rtp_streaming) |
| 239 | | m_buffer = new RTPPacketBuffer(tuning.GetBitrate(0)); |
| 240 | | else |
| 241 | | m_buffer = new UDPPacketBuffer(tuning.GetBitrate(0)); |
| 242 | | m_write_helper = new IPTVStreamHandlerWriteHelper(this); |
| 243 | | m_write_helper->Start(); |
| 244 | 243 | |
| 245 | | bool error = false; |
| 246 | | if (rtsp) |
| | 244 | if (!error) |
| | 245 | { |
| | 246 | if (m_use_rtp_streaming) |
| | 247 | m_buffer = new RTPPacketBuffer(tuning.GetBitrate(0)); |
| | 248 | else |
| | 249 | m_buffer = new UDPPacketBuffer(tuning.GetBitrate(0)); |
| | 250 | m_write_helper = new IPTVStreamHandlerWriteHelper(this); |
| | 251 | m_write_helper->Start(); |
| | 252 | } |
| | 253 | |
| | 254 | if (!error && rtsp) |
| 247 | 255 | { |
| 248 | 256 | // Start Streaming |
| 249 | 257 | if (!rtsp->Setup(m_sockets[0]->localPort(), |