diff options
-rw-r--r-- | HISTORY | 1 | ||||
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | dxr3unixserversocket.c | 209 | ||||
-rw-r--r-- | dxr3unixserversocket.h | 84 |
5 files changed, 3 insertions, 299 deletions
@@ -280,3 +280,4 @@ NOTE: I havent found time to include all of the languages, will be done in pre2 - eliminate some compiler warnings (Ville Skyttä) - fix OSD going pink after returning from the MPlayer plugin (Ville Skyttä, Martin Cap) +- remove unused dxr3unixserversocket.* from 0.2.x (Ville Skyttä) @@ -1,7 +1,7 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile,v 1.1.2.9 2005/03/23 21:41:09 scop Exp $ +# $Id: Makefile,v 1.1.2.10 2005/03/30 21:22:48 scop Exp $ # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. @@ -45,7 +45,6 @@ PACKAGE = $(shell echo vdr-$(ARCHIVE) | sed -e 's/cvs$$/cvs'`date +%Y%m%d`/) INCLUDES += -I$(VDRDIR)/include -I$(DVBDIR)/include -I$(FFMDIR) -I$(EM8300) LIBS = -L$(FFMDIR)/libavcodec -lavcodec -ljpeg DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -DEFINES += -DSOCKET_CHMOD=0660 DEFINES += -D_GNU_SOURCE # where is the microcode for the dxr3 located? @@ -63,7 +62,7 @@ DEFINES += -DUSE_XINE_SCALER OBJS = $(PLUGIN).o dxr3multichannelaudio.o dxr3sysclock.o dxr3colormanager.o dxr3syncbuffer.o dxr3audiodecoder.o \ dxr3blackframe.o dxr3palettemanager.o dxr3nextpts.o dxr3pesframe.o dxr3demuxdevice.o dxr3configdata.o \ dxr3log.o dxr3ffmpeg.o dxr3interface_spu_encoder.o dxr3i18n.o \ -dxr3interface.o dxr3device.o dxr3outputthread.o dxr3osd.o dxr3osd_subpicture.o dxr3spudecoder.o dxr3unixserversocket.o \ +dxr3interface.o dxr3device.o dxr3outputthread.o dxr3osd.o dxr3osd_subpicture.o dxr3spudecoder.o \ dxr3cpu.o dxr3memcpy.o ### Default target: @@ -59,6 +59,3 @@ Other TODOs: * optimize (is it worth it?) Rgb2YCrCb YUV2Rgb - -* look at following parts - - dxr3unixserversocket diff --git a/dxr3unixserversocket.c b/dxr3unixserversocket.c deleted file mode 100644 index d4a9100..0000000 --- a/dxr3unixserversocket.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * dxr3unixserversocket.c - * - * Copyright (C) 2002-2004 Kai Möller - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <stdio.h> - -#include <iostream> -#include <cstring> -#include <string> - -#include "dxr3unixserversocket.h" -#include "dxr3interface.h" -#include "dxr3log.h" - -#ifndef SOCKET_CHMOD -#define SOCKET_CHMOD 0660 -#endif - -// ================================== -//! constructor -cDxr3UnixServerSocket::cDxr3UnixServerSocket(const char* pFileName, int backlog) -{ - m_bConnected = false; - m_backlog = backlog; - m_addr.sun_family = AF_UNIX; - m_msgSize = 0; - - m_pFileName = pFileName; - strcpy(m_addr.sun_path, pFileName); - unlink(pFileName); - - - m_fdServerSocket = socket(PF_UNIX, SOCK_STREAM, 0); - if (m_fdServerSocket > -1) - { - if (bind(m_fdServerSocket, (sockaddr*)&m_addr, (socklen_t)sizeof(m_addr))) { - cLog::Instance() << "cDxr3UnixServerSocket::cDxr3UnixServerSocket Error: binding socket failed\n"; - } - - if (listen(m_fdServerSocket, m_backlog)) - { - cLog::Instance() << "cDxr3UnixServerSocket::cDxr3UnixServerSocket Error: Listen failed\n"; - } - - if (chmod(m_pFileName, SOCKET_CHMOD)) - { - cLog::Instance() << "cDxr3UnixServerSocket::cDxr3UnixServerSocket Error: Chmod failed\n"; - } - } - else - { - cLog::Instance() << "cDxr3UnixServerSocket::cDxr3UnixServerSocket Error: Unable to create socket\n"; - } -} - -// ================================== -bool cDxr3UnixServerSocket::WaitForConnection() -{ - cLog::Instance() << "cDxr3UnixServerSocket::WaitForConnection Waiting ...\n"; - if (m_fdServerSocket > -1) - { - m_fdConnectionSocket = accept(m_fdServerSocket, 0, 0); - if (m_fdConnectionSocket > -1) - { - m_bConnected = true; - cLog::Instance() << "cDxr3UnixServerSocket::WaitForConnection Connected\n"; - } - else - { - m_bConnected = false; - cLog::Instance() << "cDxr3UnixServerSocket::WaitForConnection failed\n"; - } - } - else - { - m_bConnected = false; - } - return m_bConnected; -} - -// ================================== -bool cDxr3UnixServerSocket::GetNextMessage() -{ - bool ret = false; - m_msgSize = 0; - memset(m_msg, 0, MAX_REC_SIZE); - - if (m_bConnected) - { - m_msgSize = read(m_fdConnectionSocket, m_msg, MAX_REC_SIZE - 1); - if (m_msgSize <= 0) - { - m_msgSize = 0; - m_bConnected = 0; - close(m_fdConnectionSocket); - cLog::Instance() << "cDxr3UnixServerSocket::GetNextMessage failed/connection closed\n"; - } - else - { - ret = true; - } - } - - if (ret) ProcessMessage(); - - return ret; -} - -// ================================== -bool cDxr3UnixServerSocket::IsConnected() -{ - return m_bConnected; -} - -// ================================== -cDxr3UnixServerSocket::~cDxr3UnixServerSocket() -{ - close(m_fdConnectionSocket); - close(m_fdServerSocket); - unlink(m_pFileName); -} - -// ================================== -void cDxr3StartStopSocket::SendStatus() -{ - if (cDxr3Interface::Instance().IsExternalReleased()) - { - std::string res("CloseDxr3DeviceRsp\n"); - write(m_fdConnectionSocket, res.c_str(), res.size()); - } - else - { - std::string res("OpenDxr3DeviceRsp\n"); - write(m_fdConnectionSocket, res.c_str(), res.size()); - } -} - -// ================================== -void cDxr3StartStopSocket::ProcessMessage(void) -{ - cLog::Instance() << "cDxr3StartStopSocket::ProcessMessage Rec: " << (const char*) m_msg << "\n"; - - if (std::string((const char*)m_msg) == std::string("OpenDxr3DeviceCmd")) - { - cDxr3Interface::Instance().ExternalReopenDevices(); - SendStatus(); - } - else if (std::string((const char*)m_msg) == std::string("CloseDxr3DeviceCmd")) - { - cDxr3Interface::Instance().ExternalReleaseDevices(); - SendStatus(); - } - else if (std::string((const char*)m_msg) == std::string("StatusDxr3DeviceCmd")) - { - SendStatus(); - } - else if (std::string((const char *)m_msg) == std::string("SaveDxr3DeviceCmd")) - { - m_bSavedState = cDxr3Interface::Instance().IsExternalReleased(); - SendStatus(); - } - else if (std::string((const char *)m_msg) == std::string("RestoreDxr3DeviceCmd")) - { - if (m_bSavedState) - { - cDxr3Interface::Instance().ExternalReleaseDevices(); - } - else - { - cDxr3Interface::Instance().ExternalReopenDevices(); - } - SendStatus(); - } - else - { - std::string res("Error\n"); - write(m_fdConnectionSocket, res.c_str(), res.size()); - } -} - -// ================================== -void cDxr3StartStopThread::Action() -{ - cDxr3StartStopSocket mySocket; - while (mySocket.WaitForConnection()) - { - while (mySocket.GetNextMessage()); - } -} diff --git a/dxr3unixserversocket.h b/dxr3unixserversocket.h deleted file mode 100644 index 3638a30..0000000 --- a/dxr3unixserversocket.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - * dxr3unixserversocket.h - * - * Copyright (C) 2002-2004 Kai Möller - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __DXR3_UNIX_SERVER_SOCKET_H -#define __DXR3_UNIX_SERVER_SOCKET_H - -#include <stdint.h> -#include <sys/socket.h> -#include <sys/un.h> - - -#include "dxr3vdrincludes.h" - -class cDxr3UnixServerSocket { -public: - cDxr3UnixServerSocket(const char* pFileName = "/tmp/.dxr3-ux-sock", int backlog = 5); - virtual ~cDxr3UnixServerSocket(); - - bool WaitForConnection(void); - bool GetNextMessage(void); - bool IsConnected(void); -protected: - virtual void ProcessMessage(void) = 0; - - const char* m_pFileName; - bool m_bConnected; - int m_backlog; - int m_fdServerSocket; - int m_fdConnectionSocket; - sockaddr_un m_addr; - enum eDxr3socketMessageSize { MAX_REC_SIZE = 100 }; - uint8_t m_msg[MAX_REC_SIZE]; - uint8_t m_msgSize; - -private: - cDxr3UnixServerSocket(cDxr3UnixServerSocket&); // no copy constructor -}; - - -class cDxr3StartStopSocket : public cDxr3UnixServerSocket { -public: - cDxr3StartStopSocket() : m_bSavedState(false) {}; - virtual ~cDxr3StartStopSocket() {}; -protected: - void ProcessMessage(void); - void SendStatus(void); - - bool m_bSavedState; - -private: - cDxr3StartStopSocket(cDxr3StartStopSocket&); // no copy constructor -}; - - -class cDxr3StartStopThread : public cThread { -public: - cDxr3StartStopThread() {}; - virtual ~cDxr3StartStopThread() {}; -protected: - virtual void Action(void); - -private: - cDxr3StartStopThread(cDxr3StartStopThread&); // no copy constructor -}; - -#endif // __DXR3_UNIX_SERVER_SOCKET_H |