From patchwork Sat Nov 12 22:38:07 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: syrius.ml@no-log.org X-Patchwork-Id: 12086 Received: from 149.30.97-84.rev.gaoland.net ([84.97.30.149] helo=f.smtp.localhost) by www.linuxtv.org with esmtp (Exim 4.50) id 1Eb40e-0002yA-9E for vdr@linuxtv.org; Sat, 12 Nov 2005 23:38:08 +0100 Received: by f.smtp.localhost (Postfix, from userid 1000) id 563273F7; Sat, 12 Nov 2005 23:38:07 +0100 (CET) From: syrius.ml@no-log.org To: vdr@linuxtv.org Message-ID: <87veyxa4mq.87u0eha4mq@87slu1a4mq.message.id> Date: Sat, 12 Nov 2005 23:38:07 +0100 User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Subject: [vdr] [patch] network vdr-xine-0.7.6, use -i to select the ip to bind to X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Nov 2005 22:38:08 -0000 Status: O X-Status: X-Keywords: X-UID: 6050 Hi, I did it for me, maybe it could be of some use for someone else. With the genuine vdr-xine plugin -i could be used to choose the instance number and one can have several vdr+vdr-xine running on the same box. Here with the networked vdr-xine, it could be used to select the ip to bind to. What are the differences ? If -i is not used, the networked vdr-xine bind to all local interfaces (as before) If you want to run 2 vdr+vdr-xine on the same machine, it has to have 2 ip addresses, the first vdr has to be ran with -P 'xine -i IP1.IP1.IP1.IP' and the second one with -P 'xine -i IP2.IP2.IP2.IP' it's a quick hack, I hope i've been clear enough and that it may be of some use. diff -Nru xine-0.7.6+network~old/xine.c xine-0.7.6+network/xine.c --- xine-0.7.6+network~old/xine.c 2005-09-25 18:19:35.000000000 +0200 +++ xine-0.7.6+network/xine.c 2005-11-12 23:37:19.000000000 +0100 @@ -33,7 +33,7 @@ public: PluginXine::cXineLib *m_xineLib; - int m_instanceNo; + in_addr_t m_bindIp; cPluginXine(void); virtual ~cPluginXine(); @@ -56,7 +56,7 @@ , m_remote(0) , m_remoteOn(false) , m_xineLib(0) - , m_instanceNo(-1) + , m_bindIp(0) { // Initialize any member variables here. // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL @@ -73,7 +73,7 @@ //Return a string that describes all known command line options. //" - -- x \n" return - " -i N instance number to append to FIFO directory\n" + " -i ip ip address to bind to\n" " -q turn off debug messages on console\n" " -r turn on remote (pressing keys in xine controls VDR)\n" " -s switch to curses skin, while xine is disconnected\n" @@ -91,11 +91,9 @@ { case 'i': { - const int no = ::atoi(::optarg); - if (no < 0) + m_bindIp = inet_addr(::optarg); + if (m_bindIp == INADDR_NONE) return false; - - m_instanceNo = no; } break; @@ -181,9 +179,9 @@ namespace PluginXine { - int GetInstanceNo(cPlugin *const plugin) + int GetBindIp(cPlugin *const plugin) { - return ((cPluginXine *)plugin)->m_instanceNo; + return ((cPluginXine *)plugin)->m_bindIp; } cXineLib *&GetXineLib(cPlugin *const plugin) diff -Nru xine-0.7.6+network~old/xineLib.c xine-0.7.6+network/xineLib.c --- xine-0.7.6+network~old/xineLib.c 2005-09-25 18:19:35.000000000 +0200 +++ xine-0.7.6+network/xineLib.c 2005-11-12 23:36:02.000000000 +0100 @@ -1847,7 +1847,7 @@ #endif - extern int GetInstanceNo(cPlugin *const plugin); + extern int GetBindIp(cPlugin *const plugin); extern cXineLib *&GetXineLib(cPlugin *const plugin); cXineLib::cXineLib(cPlugin *const plugin, const cXineSettings &settings, cMutex &osdMutex, cXineRemote *const remote) @@ -1877,14 +1877,9 @@ { m_fifoDir = FIFO_DIR; - if (GetInstanceNo(plugin) >= 0) - { - char s[ 20 ]; - ::sprintf(s, "%d", GetInstanceNo(plugin)); - - m_fifoDir += s; - } - + m_bindIp = GetBindIp(plugin); + m_fifoDir += itoa(m_bindIp); + m_fifoNameControl = m_fifoDir + "/stream.control"; m_fifoNameResult = m_fifoDir + "/stream.result"; m_fifoNameRemote = m_fifoDir + "/stream.event"; @@ -1956,7 +1951,7 @@ return -1; } - sain.sin_addr.s_addr = 0; + sain.sin_addr.s_addr = m_bindIp; sain.sin_port = htons(port); ::setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&onoff, sizeof(int) ); diff -Nru xine-0.7.6+network~old/xineLib.h xine-0.7.6+network/xineLib.h --- xine-0.7.6+network~old/xineLib.h 2005-09-25 18:19:35.000000000 +0200 +++ xine-0.7.6+network/xineLib.h 2005-11-12 23:35:25.000000000 +0100 @@ -88,6 +88,7 @@ string m_fifoNameStream; string m_fifoNameExtControl; string m_fifoNameExtResult; + in_addr_t m_bindIp; private: cPlugin *const m_plugin;