From 1f1315e92e71748d3d42c145a39e9f00e5ad173b Mon Sep 17 00:00:00 2001 From: "[CST] Focus" Date: Wed, 1 Feb 2012 16:57:05 +0400 Subject: [PATCH] real copy of sectionsd includes Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/1b4e149bd17440eb55fac6fc3daec17e1ece8e13 Author: [CST] Focus Date: 2012-02-01 (Wed, 01 Feb 2012) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/eitd/debug.h | 40 +++++++++++++++ src/eitd/dmx.h | 116 ++++++++++++++++++++++++++++++++++++++++++ src/eitd/dmxapi.h | 46 +++++++++++++++++ src/eitd/edvbstring.h | 14 +++++ 4 files changed, 216 insertions(+) create mode 100644 src/eitd/debug.h create mode 100644 src/eitd/dmx.h create mode 100644 src/eitd/dmxapi.h create mode 100644 src/eitd/edvbstring.h diff --git a/src/eitd/debug.h b/src/eitd/debug.h new file mode 100644 index 000000000..ca4bec645 --- /dev/null +++ b/src/eitd/debug.h @@ -0,0 +1,40 @@ +/* + * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/daemons/sectionsd/debug.h,v 1.4 2008/10/05 13:40:36 seife Exp $ + * + * Debug tools (sectionsd) - d-box2 linux project + * + * (C) 2003 by thegoodguy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef __sectionsd__debug_h__ +#define __sectionsd__debug_h__ + + +#include + + +extern bool sections_debug; + +#define dprintf(fmt, args...) do { if (sections_debug) { printdate_ms(stdout); printf(fmt, ## args); fflush(stdout); }} while (0) +#define dputs(str) do { if (sections_debug) { printdate_ms(stdout); puts(str); fflush(stdout); }} while (0) +#define xprintf(fmt, args...) do { printdate_ms(stderr); fprintf(stderr, fmt, ## args); } while (0) + +void printdate_ms(FILE* f); + +#endif /* __sectionsd__debug_h__ */ + diff --git a/src/eitd/dmx.h b/src/eitd/dmx.h new file mode 100644 index 000000000..a0209bad8 --- /dev/null +++ b/src/eitd/dmx.h @@ -0,0 +1,116 @@ +/* + * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/daemons/sectionsd/dmx.h,v 1.17 2009/05/23 16:50:12 seife Exp $ + * + * DMX class (sectionsd) - d-box2 linux project + * + * (C) 2003 by thegoodguy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef __sectionsd__dmx_h__ +#define __sectionsd__dmx_h__ + +#include +#include +#include +#include +#include +#if HAVE_COOL_HARDWARE +#include +#endif +#if HAVE_TRIPLEDRAGON +#include +#endif + +typedef uint64_t sections_id_t; +typedef unsigned char version_number_t; + +class DMX +{ +private: + + int fd; + cDemux * dmx; + int dmx_num; + pthread_mutex_t pauselock; + unsigned short pID; + unsigned short dmxBufferSizeInKB; + sections_id_t first_skipped; + int current_service; + unsigned char eit_version; + bool cache; /* should read sections be cached? true for all but dmxCN */ + + inline bool isOpen(void) { + return (fd != -1); + } + + int immediate_start(void); /* mutex must be locked before and unlocked after this method */ + int immediate_stop(void); /* mutex must be locked before and unlocked after this method */ + bool check_complete(const unsigned char table_id, const unsigned short extension_id, const unsigned short onid, const unsigned short tsid, const unsigned char); + sections_id_t create_sections_id(const unsigned char table_id, const unsigned short extension_id, const unsigned char section_number, const unsigned short onid, const unsigned short tsid); + ssize_t readNbytes(int fd, char * buf, const size_t n, unsigned timeoutInMSeconds); + +public: + struct s_filters + { + unsigned char filter; + unsigned char mask; + }; + + std::vector filters; + int filter_index; + time_t lastChanged; + + int real_pauseCounter; + pthread_cond_t change_cond; + pthread_mutex_t start_stop_mutex; + + + DMX(const unsigned short p, const unsigned short bufferSizeInKB, const bool cache = true, int dmx_source = 0); + ~DMX(); + + int start(void); + ssize_t read(char * const buf, const size_t buflength, const unsigned timeoutMInSeconds); + void closefd(void); + void addfilter(const unsigned char filter, const unsigned char mask); + int stop(void); + void close(void); + + int real_pause(void); + int real_unpause(void); + + int request_pause(void); + int request_unpause(void); + + int change(const int new_filter_index, const int new_current_service = -1); // locks while changing + + void lock(void); + void unlock(void); + + int getSection(char *buf, const unsigned timeoutInMSeconds, int &timeouts); + // section with size < 3 + 5 are skipped ! + int setPid(const unsigned short new_pid); + int setCurrentService(int new_current_service); + int dropCachedSectionIDs(); + + unsigned char get_eit_version(void); + // was useful for debugging... + unsigned int get_current_service(void); +}; + +#endif /* __sectionsd__dmx_h__ */ + diff --git a/src/eitd/dmxapi.h b/src/eitd/dmxapi.h new file mode 100644 index 000000000..25d1a0e6f --- /dev/null +++ b/src/eitd/dmxapi.h @@ -0,0 +1,46 @@ +/* + * $Header: /cvs/tuxbox/apps/tuxbox/neutrino/daemons/sectionsd/dmxapi.h,v 1.3 2003/03/01 19:26:51 thegoodguy Exp $ + * + * DMX low level functions (sectionsd) - d-box2 linux project + * + * (C) 2003 by thegoodguy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 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 General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef __sectionsd__dmxapi_h__ +#define __sectionsd__dmxapi_h__ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#if !HAVE_TRIPLEDRAGON +#include +#endif + +bool setfilter(const int fd, const uint16_t pid, const uint8_t filter, const uint8_t mask, const uint32_t flags); + +typedef struct UTC_time +{ + uint64_t time : 40; +} __attribute__ ((packed)) UTC_t; + +bool getUTC(UTC_t * const UTC, const bool TDT = true); + +#endif /* __sectionsd__dmxapi_h__ */ + diff --git a/src/eitd/edvbstring.h b/src/eitd/edvbstring.h new file mode 100644 index 000000000..0554adb9c --- /dev/null +++ b/src/eitd/edvbstring.h @@ -0,0 +1,14 @@ +#ifndef __E_STRING__ +#define __E_STRING__ + +const std::string convertLatin1UTF8(const std::string &string); +int isUTF8(const std::string &string); +std::string convertDVBUTF8(const char *data, int len, int table, int tsidonid = 0); +int readEncodingFile(); + +inline std::string stringDVBUTF8(const std::string &string, int table=0, int tsidonid=0) +{ + return convertDVBUTF8((const char*)string.c_str(), string.length(), table, tsidonid); +} + +#endif // __E_STRING__