Ticket #11979: 0001-Fixes-10667.-Bind-to-multicast-address.patch

File 0001-Fixes-10667.-Bind-to-multicast-address.patch, 2.6 KB (added by chemobejk@…, 13 years ago)

Bind to multicast address instead of 0.0.0.0

  • mythtv/libs/libmythtv/recorders/iptvstreamhandler.cpp

    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)  
    167167            "", 0);
    168168    }
    169169
     170    bool error = false;
    170171    for (uint i = 0; i < IPTV_SOCKET_COUNT; i++)
    171172    {
    172173        QUrl url = tuning.GetURL(i);
    void IPTVStreamHandler::run(void)  
    210211        m_sockets[i]->setSocketDescriptor(
    211212            fd, QAbstractSocket::UnconnectedState, QIODevice::ReadOnly);
    212213
    213         m_sockets[i]->bind(QHostAddress::Any, url.port());
    214 
    215214        QHostAddress dest_addr(tuning.GetURL(i).host());
    216215
     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
    217222        if (dest_addr != QHostAddress::Any)
    218223        {
    219224            //m_sockets[i]->joinMulticastGroup(dest_addr); // needs Qt 4.8
    void IPTVStreamHandler::run(void)  
    235240        if (!url.userInfo().isEmpty())
    236241            m_sender[i] = QHostAddress(url.userInfo());
    237242    }
    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();
    244243
    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)
    247255    {
    248256        // Start Streaming
    249257        if (!rtsp->Setup(m_sockets[0]->localPort(),