From a17be48caed92e5b51bc58ae8a3ab390da242ac7 Mon Sep 17 00:00:00 2001 From: Wesnydy Ribeiro Date: Tue, 27 Jan 2015 10:41:40 -0200 Subject: [PATCH] Remoção de componentesnão utilizados (correção) --- codificador/src/codificadormanager.cpp | 171 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- codificador/src/crc32.cpp | 80 -------------------------------------------------------------------------------- codificador/src/include/codificadormanager.h | 51 --------------------------------------------------- codificador/src/include/crc32.h | 6 ------ codificador/src/include/inmanagementdata.h | 27 --------------------------- codificador/src/include/librascontrolmessage.h | 57 --------------------------------------------------------- codificador/src/include/librascontrolsection.h | 26 -------------------------- codificador/src/include/librasdatamessage.h | 42 ------------------------------------------ codificador/src/include/librassection.h | 53 ----------------------------------------------------- codificador/src/include/recebeglosa.h | 39 --------------------------------------- codificador/src/inmanagementdata.cpp | 36 ------------------------------------ codificador/src/librascontrolmessage.cpp | 143 ----------------------------------------------------------------------------------------------------------------------------------------------- codificador/src/librascontrolsection.cpp | 27 --------------------------- codificador/src/librasdatamessage.cpp | 98 -------------------------------------------------------------------------------------------------- codificador/src/librassection.cpp | 138 ------------------------------------------------------------------------------------------------------------------------------------------ codificador/src/recebeglosa.cpp | 102 ------------------------------------------------------------------------------------------------------ demux/src/bitutil_hal.cpp | 71 ----------------------------------------------------------------------- demux/src/demux.cpp | 256 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- demux/src/demuxListener.cpp | 7 ------- demux/src/filter.cpp | 147 --------------------------------------------------------------------------------------------------------------------------------------------------- demux/src/include/bitutil_hal.h | 20 -------------------- demux/src/include/demux.h | 70 ---------------------------------------------------------------------- demux/src/include/demuxListener.h | 34 ---------------------------------- demux/src/include/filter.h | 48 ------------------------------------------------ demux/src/include/ouvinteDemux.h | 26 -------------------------- demux/src/include/packet.h | 41 ----------------------------------------- demux/src/include/sectionBuffer.h | 34 ---------------------------------- demux/src/include/section_hal.h | 22 ---------------------- demux/src/include/util.h | 37 ------------------------------------- demux/src/ouvinteDemux.cpp | 15 --------------- demux/src/packet.cpp | 129 --------------------------------------------------------------------------------------------------------------------------------- demux/src/sectionBuffer.cpp | 123 --------------------------------------------------------------------------------------------------------------------------- demux/src/section_hal.cpp | 132 ------------------------------------------------------------------------------------------------------------------------------------ demux/src/util.cpp | 135 --------------------------------------------------------------------------------------------------------------------------------------- extratorCC/src/extratorCC.cpp | 487 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- extratorCC/src/include/extratorCC.h | 76 ---------------------------------------------------------------------------- extratorCC/src/include/ouvinteCC.h | 29 ----------------------------- extratorCC/src/ouvinteCC.cpp | 16 ---------------- servico/src/include/serviceWindowGenerationFromCC.h | 44 -------------------------------------------- servico/src/serviceWindowGenerationFromCC.cpp | 102 ------------------------------------------------------------------------------------------------------ 40 files changed, 0 insertions(+), 3197 deletions(-) delete mode 100644 codificador/src/codificadormanager.cpp delete mode 100644 codificador/src/crc32.cpp delete mode 100644 codificador/src/include/codificadormanager.h delete mode 100644 codificador/src/include/crc32.h delete mode 100644 codificador/src/include/inmanagementdata.h delete mode 100644 codificador/src/include/librascontrolmessage.h delete mode 100644 codificador/src/include/librascontrolsection.h delete mode 100644 codificador/src/include/librasdatamessage.h delete mode 100644 codificador/src/include/librassection.h delete mode 100644 codificador/src/include/recebeglosa.h delete mode 100644 codificador/src/inmanagementdata.cpp delete mode 100644 codificador/src/librascontrolmessage.cpp delete mode 100644 codificador/src/librascontrolsection.cpp delete mode 100644 codificador/src/librasdatamessage.cpp delete mode 100644 codificador/src/librassection.cpp delete mode 100644 codificador/src/recebeglosa.cpp delete mode 100644 demux/src/bitutil_hal.cpp delete mode 100644 demux/src/demux.cpp delete mode 100644 demux/src/demuxListener.cpp delete mode 100644 demux/src/filter.cpp delete mode 100644 demux/src/include/bitutil_hal.h delete mode 100644 demux/src/include/demux.h delete mode 100644 demux/src/include/demuxListener.h delete mode 100644 demux/src/include/filter.h delete mode 100644 demux/src/include/ouvinteDemux.h delete mode 100644 demux/src/include/packet.h delete mode 100644 demux/src/include/sectionBuffer.h delete mode 100644 demux/src/include/section_hal.h delete mode 100644 demux/src/include/util.h delete mode 100644 demux/src/ouvinteDemux.cpp delete mode 100644 demux/src/packet.cpp delete mode 100644 demux/src/sectionBuffer.cpp delete mode 100644 demux/src/section_hal.cpp delete mode 100644 demux/src/util.cpp delete mode 100644 extratorCC/src/extratorCC.cpp delete mode 100644 extratorCC/src/include/extratorCC.h delete mode 100644 extratorCC/src/include/ouvinteCC.h delete mode 100644 extratorCC/src/ouvinteCC.cpp delete mode 100644 servico/src/include/serviceWindowGenerationFromCC.h delete mode 100644 servico/src/serviceWindowGenerationFromCC.cpp diff --git a/codificador/src/codificadormanager.cpp b/codificador/src/codificadormanager.cpp deleted file mode 100644 index 6abc29c..0000000 --- a/codificador/src/codificadormanager.cpp +++ /dev/null @@ -1,171 +0,0 @@ -#include -#include -#include -#include - -#include "codificadormanager.h" - -#include "librasdatamessage.h" -#include "librascontrolmessage.h" -#include "librassection.h" -#include "tspacket.h" -#include "jdatagramsocket.h" - -using namespace std; -using namespace jsocket; - -namespace Codificador { - - CodificadorManager* CodificadorManager::ccmanager = 0; - - CodificadorManager::CodificadorManager() { - cc = 0; - packets = new unsigned char[70000]; - //pid = 0x63; - version_number = 1; - } - - CodificadorManager* CodificadorManager::getInstance() { - if (ccmanager == NULL) - ccmanager = new CodificadorManager(); - return ccmanager; - } - - CodificadorManager::~CodificadorManager() { - printf("Deletando ccManager1... \n"); - if (packets) { - delete []packets; - packets = NULL; - } - - printf("Deletando ccManager2... \n"); - ccmanager == NULL; - } - - int CodificadorManager::getPid() { - return this->pid; - } - - void CodificadorManager::setPid(int pid) { - this->pid = pid; - } - - void CodificadorManager::setResolution(string resolution) { - this->resolution = resolution; - } - - void CodificadorManager::setDictionaryVersion(int dictionaryversion) { - this->dictionaryversion = dictionaryversion; - } - - void CodificadorManager::setDPH(int dph) { - this->dph = dph; - } - - void CodificadorManager::setDPV(int dpv) { - this->dpv = dpv; - } - - void CodificadorManager::setDFW(int dfw) { - this->dfw = dfw; - } - - void CodificadorManager::setDFH(int dfh) { - this->dfh = dfh; - } - - void CodificadorManager::setPortaOut(int porta) { - this->portaOut = porta; - } - - void CodificadorManager::setIp(string ip) { - this->ip = ip; - } - - unsigned char *CodificadorManager::generateSection(unsigned int type, unsigned char *msg, int n, int *numPackets) { - unsigned short len; - unsigned char *pesBytes; - LibrasSection *librSection = NULL; - - if (type == LibrasDataMessage::LIBRAS_DATA_TYPE) { - if(version_number == 32) - version_number = 1; - - LibrasDataMessage *librData = new LibrasDataMessage((unsigned char *) msg, (unsigned short) n); - - librSection = new LibrasSection(librData, type, version_number); - - pesBytes = librSection->generateBytes(&len); - - *numPackets = generateTsPacket(packets, pid, pesBytes); - - - delete librData; - } else if (type == LibrasControlMessage::LIBRAS_MGM_TYPE) { - if(version_number == 32) - version_number = 1; - - LibrasControlMessage *librctrMess = new LibrasControlMessage(); - librctrMess->setResolution(resolution); - librctrMess->setDictionaryVersion((unsigned char)dictionaryversion); - librctrMess->setDPH((unsigned short)dph); - librctrMess->setDPV((unsigned short)dpv); - librctrMess->setDFH((unsigned short)dfh); - librctrMess->setDFW((unsigned short)dfw); - - librSection = new LibrasSection(librctrMess, type, version_number); - - pesBytes = librSection->generateBytes(&len); - - /*printf("PES Packet... \n"); - for (int j = 0; j < len; j++){ - printf("%x ", pesBytes[j]); - } - printf("\n");*/ - - *numPackets = generateTsPacket(packets, pid, pesBytes); - - delete librctrMess; - } else { - return NULL; - } - version_number++; - - delete []pesBytes; - delete librSection; - return packets; - } - - int CodificadorManager::sendToOutput(unsigned char *pes, int numPackets) { - //ip do MUX - - unsigned char *pack; - pack = (unsigned char*) malloc (188); - create_ts_null_packet(pack); - - for (int i = 1; i < 7; i++) { - memcpy(pes + (i * 188), pack, 188); - } - - DatagramSocket * w_socket = NULL; - - try { - w_socket = new DatagramSocket(ip, portaOut); - - } catch (...) { - printf("\nERRO ao abrir o socket.\n"); - return 1; - } - - //for (int i = 0; i < numPackets; i++) - //w_socket->Send((char *) pes + (i * 188), 188); - w_socket->Send((char *) pes, 1316); - - w_socket->Close(); - delete w_socket; - - return 0; - - - } -} diff --git a/codificador/src/crc32.cpp b/codificador/src/crc32.cpp deleted file mode 100644 index 16e9fbb..0000000 --- a/codificador/src/crc32.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "crc32.h" - -static const unsigned int CRC32[256] = { - 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, - 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, - 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, - 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, - 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, - 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, - 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, - 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, - 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, - 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, - 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, - 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, - 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, - 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, - 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, - 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, - 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, - 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, - 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, - 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, - 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, - 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, - 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, - 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, - 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, - 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, - 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, - 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, - 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, - 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, - 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, - 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, - 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, - 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, - 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, - 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, - 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, - 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, - 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, - 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, - 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, - 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, - 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4, -}; - -unsigned int calculate_CRC_32(unsigned char *begin, unsigned count) { - unsigned crc = 0xffffffff; - - while (count > 0) { - crc = (crc << 8) ^ CRC32[(crc >> 24) ^ ((unsigned) * begin)]; - begin++; - count--; - } - return crc; -} - diff --git a/codificador/src/include/codificadormanager.h b/codificador/src/include/codificadormanager.h deleted file mode 100644 index b3684d2..0000000 --- a/codificador/src/include/codificadormanager.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _LIBRAS_MANAGER_H_ -#define _LIBRAS_MANAGER_H_ - -#include -#include "tspacket.h" - -using namespace std; - -namespace Codificador { - - class CodificadorManager { - private: - static CodificadorManager *ccmanager; - CodificadorManager(); - - int cc; - int pid; - unsigned char version_number; - unsigned char *packets; - - string resolution; - int dictionaryversion; - int dph; - int dpv; - int dfw; - int dfh; - int portaOut; - string ip; - - - public: - static CodificadorManager *getInstance(); - virtual ~CodificadorManager(); - - int getPid(); - void setPid(int pid); - void setResolution(string resolution); - void setDictionaryVersion(int dictionaryversion); - void setDPH(int dph); - void setDPV(int dph); - void setDFW(int dph); - void setDFH(int dph); - void setPortaOut(int porta); - void setIp(string ip); - - unsigned char *generateSection(unsigned int type, unsigned char *msg, int n, int *numPackets); - int sendToOutput(unsigned char *pes, int numPackets); - }; -} - -#endif diff --git a/codificador/src/include/crc32.h b/codificador/src/include/crc32.h deleted file mode 100644 index a4a8218..0000000 --- a/codificador/src/include/crc32.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _CRC32_H_ -#define _CRC32_H_ - -unsigned int calculate_CRC_32(unsigned char *, unsigned); - -#endif diff --git a/codificador/src/include/inmanagementdata.h b/codificador/src/include/inmanagementdata.h deleted file mode 100644 index 617758f..0000000 --- a/codificador/src/include/inmanagementdata.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _INPUT_MGM_DATA_H_ -#define _INPUT_MGM_DATA_H_ - -#include "jthread.h" -#include "codificadormanager.h" - - namespace Codificador { - - class InManagementData: public jthread::Thread{ - - private: - CodificadorManager *codificadorManager; - bool stopped; - - public: - static const int MAX_CC_MSG = 65536; - - InManagementData(); - virtual ~InManagementData(); - - void Run(); - void stop(); - }; - - } - -#endif diff --git a/codificador/src/include/librascontrolmessage.h b/codificador/src/include/librascontrolmessage.h deleted file mode 100644 index ad608ae..0000000 --- a/codificador/src/include/librascontrolmessage.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _LIBRAS_CONTROL_MESSAGE_H_ -#define _LIBRAS_CONTROL_MESSAGE_H_ - -#include "librascontrolsection.h" -#include - -using namespace std; - -namespace Codificador { - - class LibrasControlMessage : public LibrasControlSection { - - private: - unsigned short messagelength; - unsigned char resolution; - unsigned char dictionaryversion; - unsigned short dph; - unsigned short dpv; - unsigned short dfw; - unsigned short dfh; - unsigned char privatedatalength; - unsigned char *privateDataBytes; - - public: - static const unsigned int LIBRAS_MGM_TYPE = 0x00; - static const unsigned int MESSAGE_ID_CONTROL = 0x01; - - unsigned short getMessageLength(); - unsigned char getResolution(); - unsigned char getDictionaryVersion(); - unsigned short getDPH(); - unsigned short getDPV(); - unsigned short getDFW(); - unsigned short getDFH(); - unsigned char getPrivateDataLength(); - unsigned char *getPrivateDataBytes(); - - void setMessageLength(unsigned short messagelength); - void setResolution(string resolution); - void setDictionaryVersion(unsigned char dictionaryversion); - void setDPH(unsigned short dph); - void setDPV(unsigned short dph); - void setDFW(unsigned short dph); - void setDFH(unsigned short dph); - void setPrivateDataLength(unsigned char privatedatalength); - void setPrivateDataBytes(unsigned char *privateDataBytes, int len); - - LibrasControlMessage(); - virtual ~LibrasControlMessage(); - - - virtual unsigned char *generateBytes(unsigned short *librasLen); - }; - -} - -#endif diff --git a/codificador/src/include/librascontrolsection.h b/codificador/src/include/librascontrolsection.h deleted file mode 100644 index 3553261..0000000 --- a/codificador/src/include/librascontrolsection.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _LIBRAS_CONTROL_SECTION_H_ -#define _LIBRAS_CONTROL_SECTION_H_ - -namespace Codificador { - - class LibrasControlSection { - protected: - unsigned int type; - unsigned char timecontrolflag; - unsigned char messageid; - - public: - - LibrasControlSection(); - virtual ~LibrasControlSection(); - - unsigned char getTimeControlFlag(); - - void setTimeControlFlag(unsigned char timecontrolflag); - - virtual unsigned char *generateBytes(unsigned short *librasLen); - }; - -} - -#endif diff --git a/codificador/src/include/librasdatamessage.h b/codificador/src/include/librasdatamessage.h deleted file mode 100644 index 88522b2..0000000 --- a/codificador/src/include/librasdatamessage.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _LIBRAS_DATA_MESSAGE_H_ -#define _LIBRAS_DATA_MESSAGE_H_ - -#include "librascontrolsection.h" - -namespace Codificador { - - class LibrasDataMessage : public LibrasControlSection { - - private: - unsigned short messagelength; - unsigned int stm; - unsigned short sinaislooplength; - unsigned char glosadatalength; - unsigned char *glosaDataBytes; - - public: - static const unsigned int LIBRAS_DATA_TYPE = 0x01; - static const unsigned int MESSAGE_ID_DATA = 0x02; - - unsigned short getMessageLength(); - unsigned int getStm(); - unsigned short getSinaisLoopLength(); - unsigned char getGlosaDataLength(); - unsigned char *getGlosaDataBytes(); - - void setMessageLength(unsigned short messagelength); - void setStm(unsigned int stm); - void setSinaisLoopLength(unsigned short sinaislooplength); - void setGlosaDataLength(unsigned char glosadatalength); - void setGlosaDataBytes(unsigned char *glosaDataBytes, int len); - - LibrasDataMessage(unsigned char *data, int size); - virtual ~LibrasDataMessage(); - - virtual unsigned char *generateBytes(unsigned short *librasLen); - - }; - -} - -#endif diff --git a/codificador/src/include/librassection.h b/codificador/src/include/librassection.h deleted file mode 100644 index 612ee65..0000000 --- a/codificador/src/include/librassection.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef _SYNCRO_PES_DATA_H_ -#define _SYNCRO_PES_DATA_H_ - -#include "librascontrolsection.h" - - namespace Codificador { - - class LibrasSection{ - - private: - unsigned char tableid; - unsigned char section_syntax_indicator; - unsigned short libras_section_length; - unsigned short table_id_extension; - unsigned char version_number; - unsigned char current_next_indicator; - unsigned char section_number; - unsigned char last_section_number; - unsigned int crc32; - - LibrasControlSection *libras; - - public: - - LibrasSection(LibrasControlSection *libr, unsigned int type, unsigned char version); - virtual ~LibrasSection(); - - unsigned char getSectionSyntaxIndicator(); - unsigned short getLibrasSectionLength(); - unsigned char getTableIdExtension(); - unsigned char getVersionNumber(); - unsigned char getCurrentNextIndicator(); - unsigned char getSectionNumber(); - unsigned char getLastSectionNumber(); - unsigned int getCrc32(); - LibrasControlSection *getLibras(); - - void setSectionSyntaxIndicator(unsigned char section_syntax_indicator); - void setLibrasSectionLength(unsigned short libras_section_length); - void setTableIdExtension(unsigned short table_id_extension); - void setVersionNumber(unsigned char version_number); - void setCurrentNextIndicator(unsigned char current_next_indicator); - void setSectionNumber(unsigned char section_number); - void setLastSectionNumber(unsigned char last_section_number); - - void setLibras(LibrasControlSection *libras); - - unsigned char *generateBytes(unsigned short *syncPesLen); - }; - - } - -#endif diff --git a/codificador/src/include/recebeglosa.h b/codificador/src/include/recebeglosa.h deleted file mode 100644 index 71e6cee..0000000 --- a/codificador/src/include/recebeglosa.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * File: RecebeGlosa.h - * Author: felipe - * - * Created on 2 de Fevereiro de 2010, 09:43 - */ - -#ifndef _RECEBEGLOSA_H -#define _RECEBEGLOSA_H - -#include -#include -#include -#include "codificadormanager.h" -#include "ouvinteTradutor.h" - -using namespace std; - -namespace Codificador { - - class RecebeGlosa : public Tradutor::OuvinteTradutor { - public: - - RecebeGlosa(int pd, string rl, int vs, int dh, int dv, int dw, int df, int portOut, string ip); - ~RecebeGlosa(); - - void PreencheVector(); - virtual void codifica(std::vector * glosas); - - private: - CodificadorManager *codificadorManager; - - // Mutex para evitar mutiplas chamadas de notificadores - pthread_mutex_t *mutex; - }; -} - -#endif /* _RECEBEGLOSA_H */ - diff --git a/codificador/src/inmanagementdata.cpp b/codificador/src/inmanagementdata.cpp deleted file mode 100644 index 5e7b039..0000000 --- a/codificador/src/inmanagementdata.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include - -#include "inmanagementdata.h" -#include "codificadormanager.h" -#include "librascontrolmessage.h" - -namespace Codificador{ - - InManagementData::InManagementData(){ - stopped = false; - codificadorManager = CodificadorManager::getInstance(); - } - - InManagementData::~InManagementData(){ - } - - void InManagementData::stop(){ - stopped = true; - } - - void InManagementData::Run(){ - int numPackets; - unsigned char *pes; - - while(!stopped){ - pes = codificadorManager->generateSection(LibrasControlMessage::LIBRAS_MGM_TYPE, NULL, 0, &numPackets); - codificadorManager->sendToOutput(pes, numPackets); - printf("\nGerando Libras Control Message\n"); - sleep(2); - - } - - printf("Saiu do InputMgmData... \n"); - - } -} diff --git a/codificador/src/librascontrolmessage.cpp b/codificador/src/librascontrolmessage.cpp deleted file mode 100644 index b66f0d3..0000000 --- a/codificador/src/librascontrolmessage.cpp +++ /dev/null @@ -1,143 +0,0 @@ -#include -#include -#include - -#include "librascontrolmessage.h" - -namespace Codificador { - - LibrasControlMessage::LibrasControlMessage() : LibrasControlSection() { - type = LIBRAS_MGM_TYPE; - - messagelength = 11; - //resolution = 1; - timecontrolflag = 0; - //dictionaryversion = 1; - privatedatalength = 0; - privateDataBytes = NULL; - //dph = 0; - //dfh = 0; - //dfw = 0; - //dpv = 0; - } - - LibrasControlMessage::~LibrasControlMessage() { - - } - - unsigned short LibrasControlMessage::getMessageLength() { - return messagelength; - } - - unsigned char LibrasControlMessage::getResolution() { - return resolution; - } - - unsigned char LibrasControlMessage::getDictionaryVersion() { - return dictionaryversion; - } - - unsigned short LibrasControlMessage::getDPH() { - return dph; - } - - unsigned short LibrasControlMessage::getDPV() { - return dpv; - } - - unsigned short LibrasControlMessage::getDFW() { - return dfw; - } - - unsigned short LibrasControlMessage::getDFH() { - return dfh; - } - - unsigned char LibrasControlMessage::getPrivateDataLength() { - return privatedatalength; - } - - unsigned char *LibrasControlMessage::getPrivateDataBytes() { - return privateDataBytes; - } - - void LibrasControlMessage::setMessageLength(unsigned short messagelength) { - this->messagelength = messagelength; - } - - void LibrasControlMessage::setResolution(string resolution) { - if(resolution.compare("1920x1080") == 0) - this->resolution = 0; - if(resolution.compare("1280x720") == 0) - this->resolution = 1; - if(resolution.compare("640x480") == 0) - this->resolution = 2; - if(resolution.compare("960x540") == 0) - this->resolution = 3; - if(resolution.compare("720x480") == 0) - this->resolution = 4; - } - - void LibrasControlMessage::setDictionaryVersion(unsigned char dictionaryversion) { - this->dictionaryversion = dictionaryversion; - } - - void LibrasControlMessage::setDPH(unsigned short dph) { - this->dph = dph; - } - - void LibrasControlMessage::setDPV(unsigned short dpv) { - this->dpv = dpv; - } - - void LibrasControlMessage::setDFW(unsigned short dfw) { - this->dfw = dfw; - } - - void LibrasControlMessage::setDFH(unsigned short dfh) { - this->dfh = dfh; - } - - void LibrasControlMessage::setPrivateDataLength(unsigned char privatedatalength) { - this->privatedatalength = privatedatalength; - } - - void LibrasControlMessage::setPrivateDataBytes(unsigned char *privateDataBytes, int len) { - if (this->privateDataBytes) { - delete (this->privateDataBytes); - } - - this->privateDataBytes = new unsigned char[len]; - memcpy(this->privateDataBytes, privateDataBytes, len); - } - - unsigned char *LibrasControlMessage::generateBytes(unsigned short *librasLen) { - unsigned char *librasDataBytes; - - *librasLen = privatedatalength + messagelength + 3; - - librasDataBytes = new unsigned char[*librasLen]; - - messageid = MESSAGE_ID_CONTROL; - messagelength += privatedatalength; - - librasDataBytes[0] = messageid & 0xFF; - librasDataBytes[1] = (messagelength >> 8) & 0xFF; - librasDataBytes[2] = messagelength & 0xFF; - librasDataBytes[3] = ((resolution << 1) & 0x1E) | (timecontrolflag & 0x01); - librasDataBytes[4] = dictionaryversion & 0xFF; - librasDataBytes[5] = (dph >> 8) & 0xFF; - librasDataBytes[6] = dph & 0xFF; - librasDataBytes[7] = (dpv >> 8) & 0xFF; - librasDataBytes[8] = dpv & 0xFF; - librasDataBytes[9] = (dfw >> 8) & 0xFF; - librasDataBytes[10] = dfw & 0xFF; - librasDataBytes[11] = (dfh >> 8) & 0xFF; - librasDataBytes[12] = dfh & 0xFF; - librasDataBytes[13] = privatedatalength & 0xFF; - - memcpy(librasDataBytes + 11, privateDataBytes, privatedatalength); - - return librasDataBytes; - } -} diff --git a/codificador/src/librascontrolsection.cpp b/codificador/src/librascontrolsection.cpp deleted file mode 100644 index 73506b3..0000000 --- a/codificador/src/librascontrolsection.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "librascontrolsection.h" - -#define NULL 0 - -namespace Codificador { - - LibrasControlSection::LibrasControlSection() { - timecontrolflag = 0; - } - - LibrasControlSection::~LibrasControlSection() { - - } - - unsigned char LibrasControlSection::getTimeControlFlag() { - return timecontrolflag; - } - - void LibrasControlSection::setTimeControlFlag(unsigned char timecontrolflag) { - this->timecontrolflag = timecontrolflag; - } - - unsigned char *LibrasControlSection::generateBytes(unsigned short *librasLen) { - - return NULL; - } -} diff --git a/codificador/src/librasdatamessage.cpp b/codificador/src/librasdatamessage.cpp deleted file mode 100644 index 85cf5ae..0000000 --- a/codificador/src/librasdatamessage.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include -#include -#include - -#include "librasdatamessage.h" - -namespace Codificador { - - LibrasDataMessage::LibrasDataMessage(unsigned char *data, int size) : LibrasControlSection() { - type = LIBRAS_DATA_TYPE; - - messagelength = 4; - - glosadatalength = size; - glosaDataBytes = NULL; - //Pode mudar - sinaislooplength = 1; - - if (size > 0) { - glosaDataBytes = new unsigned char[glosadatalength]; - memcpy(glosaDataBytes, data, size); - } - } - - LibrasDataMessage::~LibrasDataMessage() { - if (glosaDataBytes) delete [] glosaDataBytes; - } - - unsigned short LibrasDataMessage::getMessageLength() { - return messagelength; - } - - unsigned int LibrasDataMessage::getStm() { - return stm; - } - - unsigned short LibrasDataMessage::getSinaisLoopLength() { - return sinaislooplength; - } - - unsigned char LibrasDataMessage::getGlosaDataLength() { - return glosadatalength; - } - - unsigned char *LibrasDataMessage::getGlosaDataBytes() { - return glosaDataBytes; - } - - void LibrasDataMessage::setMessageLength(unsigned short messagelength) { - this->messagelength = messagelength; - } - - void LibrasDataMessage::setStm(unsigned int stm) { - this->stm = stm; - } - - void LibrasDataMessage::setSinaisLoopLength(unsigned short sinaislooplength) { - this->sinaislooplength = sinaislooplength; - } - - void LibrasDataMessage::setGlosaDataLength(unsigned char glosadatalength) { - this->glosadatalength = glosadatalength; - } - - void LibrasDataMessage::setGlosaDataBytes(unsigned char *glosaDataBytes, int len) { - if (this->glosaDataBytes) { - delete [] (this->glosaDataBytes); - } - - this->glosaDataBytes = new unsigned char[len]; - memcpy(this->glosaDataBytes, glosaDataBytes, len); - } - - unsigned char *LibrasDataMessage::generateBytes(unsigned short *librasLen) { - unsigned char *librasDataBytes; - - *librasLen = glosadatalength + messagelength + 3; - sinaislooplength += glosadatalength; - - librasDataBytes = new unsigned char[*librasLen]; - - messageid = MESSAGE_ID_DATA; - messagelength += glosadatalength; - - librasDataBytes[0] = messageid & 0xFF; - librasDataBytes[1] = (messagelength >> 8) & 0xFF; - librasDataBytes[2] = messagelength & 0xFF; - librasDataBytes[3] = timecontrolflag & 0x01; - //Ajeitar pra quando tiver STM - librasDataBytes[4] = (sinaislooplength >> 8) & 0xFF; - librasDataBytes[5] = sinaislooplength & 0xFF; - librasDataBytes[6] = glosadatalength & 0xFF; - - memcpy(librasDataBytes + 7, glosaDataBytes, glosadatalength); - - return librasDataBytes; - } -} diff --git a/codificador/src/librassection.cpp b/codificador/src/librassection.cpp deleted file mode 100644 index 9d20513..0000000 --- a/codificador/src/librassection.cpp +++ /dev/null @@ -1,138 +0,0 @@ -#include -#include -#include - -#include "librassection.h" -#include "crc32.h" - -namespace Codificador{ - - LibrasSection::LibrasSection(LibrasControlSection *libr, unsigned int type, unsigned char version){ - - tableid = 145; - section_syntax_indicator = 1; - - if( type == 0 ) - table_id_extension = 0x0001; - if( type == 1) - table_id_extension = 0x0002; - - version_number = version; - current_next_indicator = 1; - section_number = 0; - last_section_number = 0; - - libras_section_length = 9; - - libras = libr; - } - - LibrasSection::~LibrasSection(){ - - } - - unsigned char LibrasSection::getSectionSyntaxIndicator(){ - return section_syntax_indicator; - } - - unsigned short LibrasSection::getLibrasSectionLength(){ - return libras_section_length; - } - - unsigned char LibrasSection::getTableIdExtension(){ - return table_id_extension; - } - - unsigned char LibrasSection::getVersionNumber(){ - return version_number; - } - - unsigned char LibrasSection::getCurrentNextIndicator(){ - return current_next_indicator; - } - - unsigned char LibrasSection::getSectionNumber(){ - return section_number; - } - - unsigned char LibrasSection::getLastSectionNumber(){ - return last_section_number; - } - - unsigned int LibrasSection::getCrc32(){ - return crc32; - } - - LibrasControlSection *LibrasSection::getLibras(){ - return libras; - } - - void LibrasSection::setSectionSyntaxIndicator(unsigned char section_syntax_indicator){ - this->section_syntax_indicator = section_syntax_indicator; - } - - void LibrasSection::setLibrasSectionLength(unsigned short libras_section_length){ - this->libras_section_length = libras_section_length; - } - - void LibrasSection::setTableIdExtension(unsigned short table_id_extension){ - this->table_id_extension = table_id_extension; - } - - void LibrasSection::setVersionNumber(unsigned char version_number){ - this->version_number = version_number; - } - - void LibrasSection::setCurrentNextIndicator(unsigned char current_next_indicator){ - this->current_next_indicator = current_next_indicator; - } - - void LibrasSection::setSectionNumber(unsigned char section_number){ - this->section_number = section_number; - } - - void LibrasSection::setLastSectionNumber(unsigned char last_section_number){ - this->last_section_number = last_section_number; - } - - void LibrasSection::setLibras(LibrasControlSection *libras){ - this->libras = libras; - } - - unsigned char *LibrasSection::generateBytes(unsigned short *librLen){ - int offset = 0; - unsigned short librasLen; - unsigned char *librSecBytes; - unsigned char *librasBytes = libras->generateBytes(&librasLen); - - *librLen = librasLen + libras_section_length + 3; - libras_section_length += librasLen; - - librSecBytes = new unsigned char[*librLen]; - - librSecBytes[0] = tableid & 0xFF; - librSecBytes[1] = (section_syntax_indicator << 7) & 0x80; - librSecBytes[1] = (libras_section_length >> 8) & 0x0F; - librSecBytes[2] = libras_section_length & 0xFF; - librSecBytes[3] = (table_id_extension >> 8) & 0xFF; - librSecBytes[4] = table_id_extension & 0xFF; - librSecBytes[5] = (version_number << 5) & 0x3E; - librSecBytes[5] = current_next_indicator & 0x01; - librSecBytes[6] = section_number & 0xFF; - librSecBytes[7] = last_section_number & 0xFF; - - memcpy(librSecBytes + 8, librasBytes, librasLen); - - crc32 = calculate_CRC_32(librSecBytes, *librLen - 4); - offset = 8 + librasLen; - - librSecBytes[offset + 0]= (crc32 >> 24) & 0xFF; - librSecBytes[offset + 1]= (crc32 >> 16) & 0xFF; - librSecBytes[offset + 2]= (crc32 >> 8) & 0xFF; - librSecBytes[offset + 3]= crc32 & 0xFF; - - delete []librasBytes; - return librSecBytes; - } -} - diff --git a/codificador/src/recebeglosa.cpp b/codificador/src/recebeglosa.cpp deleted file mode 100644 index b0a7f0c..0000000 --- a/codificador/src/recebeglosa.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * File: RecebeGlosa.cpp - * Author: felipe - * - * Created on 2 de Fevereiro de 2010, 09:43 - */ - -#include "recebeglosa.h" -#include "librasdatamessage.h" -#include "dprintf.h" -#include - -#include -#include -#include - -namespace Codificador { - - RecebeGlosa::RecebeGlosa(int pd, string rl, int vs, int dh, int dv, int dw, int df, int portOut, string ip) { - codificadorManager = CodificadorManager::getInstance(); - codificadorManager->setPid(pd); - codificadorManager->setResolution(rl); - codificadorManager->setDictionaryVersion(vs); - codificadorManager->setDPH(dh); - codificadorManager->setDPV(dv); - codificadorManager->setDFW(dw); - codificadorManager->setDFH(df); - codificadorManager->setPortaOut(portOut); - codificadorManager->setIp(ip); - // Inicia o mutex - mutex = (pthread_mutex_t *) malloc( sizeof(pthread_mutex_t) ); - pthread_mutex_init(mutex, NULL); - } - - RecebeGlosa::~RecebeGlosa() { - if (mutex) { - int ret = pthread_mutex_destroy(mutex); - if (ret) - DDDPRINTF("erro destruindo mutex\n"); - free(mutex); - } - } - - void RecebeGlosa::codifica(vector * glosas) { - // Mutex para evitar bug multiplas chamadas dos notificadores - pthread_mutex_lock(mutex); - unsigned char *nullpackets = new unsigned char [188]; - - vector::iterator it; - unsigned char *data; - string valor; - int tamanho, numPackets, contNullPackets = 0; - //FILE *arq; - - unsigned char *pes; - - //arq = fopen ("../libras.ts" , "a"); - - printf("\nGlosa recebida para codificacao: "); - printf("\033[31m"); - for (it = glosas->begin(); it < glosas->end(); it++) { - cout << *it << " "; - } - printf("\033[0m"); - printf("\n"); - - for (it = glosas->begin(); it < glosas->end(); it++) { - valor = *it; - //Gambiarra - //if(gambis == 0) { - //valor.insert(0, "dl"); - //gambis++; - //} - tamanho = valor.size(); - data = (unsigned char*) valor.c_str(); - //cout << "Glosa: " << data << endl; - - if ((tamanho>2) && data[0] == 'd' && data[1] == 'l') { - for(int i = 2; i < tamanho; i++) { - pes = codificadorManager->generateSection(LibrasDataMessage::LIBRAS_DATA_TYPE,(unsigned char*) &data[i], 1, &numPackets); - codificadorManager->sendToOutput(pes, numPackets); - //fwrite(pes , 1 , 188 , arq ); - } - - } else { - pes = codificadorManager->generateSection(LibrasDataMessage::LIBRAS_DATA_TYPE, data, tamanho, &numPackets); - codificadorManager->sendToOutput(pes, numPackets); - //fwrite(pes , 1 , 188 , arq ); - } - } - //printf("\nGerando Libras Data Message\n"); - //create_ts_null_packet(nullpackets); - - //while(contNullPackets < 30000) { - //contNullPackets++; - //fwrite(nullpackets , 1 , 188 , arq ); - //} - - //fclose(arq); - pthread_mutex_unlock(mutex); - } -} \ No newline at end of file diff --git a/demux/src/bitutil_hal.cpp b/demux/src/bitutil_hal.cpp deleted file mode 100644 index 397bd1e..0000000 --- a/demux/src/bitutil_hal.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "bitutil_hal.h" - - - const U8 bitMask[8] = { 0x80, 0x40, 0x20, 0x10, - 0x08, 0x04, 0x02, 0x01 }; - - U8 getByteAt(unsigned char * bitStream, - int byteIndex) - { - return bitStream[byteIndex]; - - } - - BOOL getBitAt(unsigned char * bitStream, int bitIndex) - { - int byteIndex = bitIndex / 8; - int bitOffset = bitIndex % 8; - - if ((bitStream[byteIndex] & bitMask[bitOffset]) != 0) - return TRUE; - else - return FALSE; - } - - U32 getIntAt(unsigned char * bitStream,int intIndex) - { - U32 * bitStream2 = (U32 *) bitStream; - return bitStream2[intIndex]; - - } - - U8 getByteAtBits(unsigned char * bitStream,int firstBitOffset, int length) - { - U8 byte = 0x00; - int lastBitOffset = firstBitOffset + length - 1; - - int i, bit; - for (bit = lastBitOffset, i = 7; - bit >= firstBitOffset; - bit--, i--){ - int byteIndex = bit / 8; - int bitOffset = bit % 8; - if ((bitStream[byteIndex] & bitMask[bitOffset]) != 0){ - byte = byte | bitMask[i]; - } - } - - return byte; - } - U32 getIntAtBits(unsigned char * bitStream,int firstBitOffset, int length) - { - U32 integer = 0x00000000; - U8 * byte = (U8 *) &integer; - int lastBitOffset = firstBitOffset + length - 1; - - int i, bit; - for (bit = lastBitOffset, i = 31; - bit >= firstBitOffset; - bit--, i--){ - int byteIndex = bit / 8; - int bitOffset = bit % 8; - if ((bitStream[byteIndex] & bitMask[bitOffset]) != 0){ - int byteIndex2 = 3 - (i / 8); - int bitOffset2 = i % 8; - byte[byteIndex2] = byte[byteIndex2] | bitMask[bitOffset2]; - } - } - - return integer; - } - diff --git a/demux/src/demux.cpp b/demux/src/demux.cpp deleted file mode 100644 index 7de5ed0..0000000 --- a/demux/src/demux.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Demux.cpp - * - * Created on: 09/10/2008 - * Author: lacet - */ - -#include "filter.h" -#include "packet.h" -#include "section_hal.h" - -#include -#include - -#include "demux.h" -#include "demuxListener.h" -#include "jmutex.h" -#include "util.h" -#define OK (0) - -//debug -#define DEBUG 0 -#define DEBUG_ARQ 0 - -FILE *file = NULL; - -Packet* myPacket = NULL; - -Mutex* mutex = new Mutex(); - -Demux::Demux(int pid) { - //mutex->Lock(); - //filters = new vector (); - filter = new Filter(pid, 0, 0); - //printf("\nFiltro Setado\n"); - mySectionBuffer = new SectionBuffer(); - mySectionBuffer->initSectionsBuffer(); - sectionSize = -1; - sectionRead = 0; - countPacotes = 0; - continuityCounter = 0; - lastContinuityCounter = 0; - flagShiftPointerField = 1; - //setDemuxListener(); - //mutex->Unlock(); -} - -Demux::Demux(int pid, DemuxListener* listener) { - //mutex->Lock(); - //filters = new vector (); - filter = new Filter(pid, 0, 0); - //printf("\nFiltro Setado\n"); - mySectionBuffer = new SectionBuffer(); - mySectionBuffer->initSectionsBuffer(); - sectionSize = -1; - sectionRead = 0; - countPacotes = 0; - continuityCounter = 0; - lastContinuityCounter = 0; - setDemuxListener(listener); - //mutex->Unlock(); - ouvintes = new list(); - - // Inicia o mutex - mutex = (pthread_mutex_t *) malloc(sizeof (pthread_mutex_t)); - pthread_mutex_init(mutex, NULL); -} - -void Demux::setDemuxListener(DemuxListener* listener) { - this->listener = listener; -} - -void Demux::chegouInput(unsigned char *pacote) { - // Mutex para evitar bug multiplas chamadas dos notificadores - pthread_mutex_lock(mutex); - Packet *mypack = new Packet(pacote); - getNextSection(pacote, mypack); - - pthread_mutex_unlock(mutex); - -} - -Demux::~Demux() { - - delete filter; - delete mySectionBuffer; - - if (ouvintes) { - // nao deleta os ouvintes mesmo, apenas a lista - ouvintes->clear(); - delete ouvintes; - } - - if (mutex) { - int ret = pthread_mutex_destroy(mutex); - if (ret) - printf("erro destruindo mutex\n"); - free(mutex); - } - - -} - -Filter* Demux::getFilter() { - return filter; -} - -int getPESSize(unsigned char* pacote) { - return getIntAtBits(pacote, 32, 16) + 6; -} -int start = 0; -//int countPacotes = 0; - -int Demux::getNextSection(unsigned char* packet, Packet *myPacket) { - //countPacotes++; - //unsigned char* packet = new unsigned char[PACKET_SIZE]; // TODO desalocar - unsigned char *payloadData; - static utils::Util util; - int packetControl = OK; - //Filter* filter; - //int packetControl; - int count1, count2; - count1 = count2 = 0; - //printf("\nPacket Notified - PID: %d\nSection Read: %d\n", myPacket->getPid(), sectionRead); - //this->flagShiftPointerField = 1; - - if (myPacket && filter) { - - if (packetControl == OK) { - - if (myPacket->getPid() != filter->getFilterPid()) { - //printf("\nRefused Packet - PID: %d\n", myPacket->getPid()); - //invalid pid - - return 0; - } else if (myPacket->getPayloadLength() < 1) { - //printf("\nEmpty Payload\n"); - return 0; - //empty payload - } else { - //cout << "Accepted Packet - PID: " << myPacket->getPid() << endl; - continuityCounter = myPacket->getContinuityCounter(); - //printf("\nContinuity Counter: %d\n", continuityCounter); - - if (start == 0) { - start = 1; - } else { - if (lastContinuityCounter == 15) { - if (continuityCounter != 0) { - //cout << "ERRO DE CONTINUIDADE!!" << endl; - //cout << "PID: " << myPacket->getPid() << endl; - //cout << "CC: " << continuityCounter << endl; - //cout << "LCC: " << lastContinuityCounter << endl; - lastContinuityCounter = continuityCounter; - sectionRead = 0; - sectionSize = -1; - return OK; - - } - } else if (continuityCounter != (lastContinuityCounter + 1)) { - //cout << "ERRO DE CONTINUIDADE!" << endl; - //cout << "PID: " << myPacket->getPid() << endl; - //cout << "CC: " << continuityCounter << endl; - //cout << "LCC: " << lastContinuityCounter << endl; - - lastContinuityCounter = continuityCounter; - sectionRead = 0; - sectionSize = -1; - return OK; - } - } - } - lastContinuityCounter = continuityCounter; - - } - } else { - //printf("\nInvalid Packet\n"); - return 0; - //invalid packet - } - - payloadData = myPacket->getPayloadCopy(); - payloadSize = myPacket->getPayloadLength(); - // TODO validate continuity_counter - if (myPacket->hasAdaptationField()) { - int tamanho = packet[4]; - payloadData = (unsigned char *) myPacket->getPayloadBeginingAtUnitStarted(); - payloadSize = myPacket->getPayloadBeginingAtUnitStartedLength(); - if (payloadData[0] == 0x00 && payloadData[1] == 0x00 && payloadData[2] == 0x01) { - //cout << "Pegou Payload Correto" << endl; - } else { - cout << "Pegou Payload Errado" << endl; - } - - } else { - - } - - if (sectionRead == 0) { - - sectionSize = getPESSize(payloadData); - - if (sectionSize > payloadSize) { - memcpy(sectionData, payloadData, payloadSize); - sectionRead += payloadSize; - } else { - memcpy(sectionData, payloadData, sectionSize); - sectionRead += sectionSize; - } - - if (sectionData[0] == 0x00 && sectionData[1] == 0x00 && sectionData[2] == 0x01) { - //cout << "Pacote PES OK!" << endl; - } else { - sectionRead = 0; - sectionSize = -1; - cout << "Pacote PES ERRADO!" << endl; - } - - } else { - - if ((sectionSize - sectionRead) > payloadSize) { - memcpy(sectionData + sectionRead, payloadData, payloadSize); - sectionRead += payloadSize; - } else { - memcpy(sectionData + sectionRead, payloadData, (sectionSize - sectionRead)); - sectionRead += (sectionSize - sectionRead); - } - - } - - if (sectionRead == sectionSize) { - sectionSize = getPESSize(sectionData); - //cout << "PES NOTIFIED - PES Size: " << sectionSize << endl; - listener->notifySection(myPacket->getPid(), sectionData, sectionSize); - sectionRead = 0; - sectionSize = -1; - - } - - delete myPacket; - return OK; -} - -void Demux::registraOuvinte(OuvinteDemux * ouvinte) { - ouvintes->push_back(ouvinte); -} - -void Demux::removeOuvinte(OuvinteDemux * ouvinte) { - ouvintes->remove(ouvinte); -} - -void Demux::notificaOuvintes(unsigned char * sec) { - for (list::iterator i = ouvintes->begin(); i != ouvintes->end(); i++) { - (*i)->chegou(sec); - } -} diff --git a/demux/src/demuxListener.cpp b/demux/src/demuxListener.cpp deleted file mode 100644 index dc77b31..0000000 --- a/demux/src/demuxListener.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "demuxListener.h" - -DemuxListener::DemuxListener() { -} - -DemuxListener::~DemuxListener() { -} diff --git a/demux/src/filter.cpp b/demux/src/filter.cpp deleted file mode 100644 index 7a90918..0000000 --- a/demux/src/filter.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Filter.cpp - * - * Created on: 08/10/2008 - * Author: lacet - */ - -#include "filter.h" -#include "packet.h" -#include "section_hal.h" - -#include -#include -#include "util.h" - -int sectionSizee; - -Filter::Filter(int FilterPID, int FilterTID, int FilterTIDx) { - // TODO Auto-generated constructor stub - this->setFilterPid(FilterPID); - this->setFilterTid(FilterTID); - this->setFilterTidx(FilterTIDx); - this->setLastSectionCRC(0); - this->setCrcErrorCount(0); -} - -Filter::Filter() { - -} - -Filter::~Filter() { - // TODO Auto-generated destructor stub -} - -int Filter::isValid(unsigned char *section, Packet* myPacket, DemuxListener* listener) { - static utils::Util util; - - if (getFilterTidx() == -1) { - //printf("->2\n"); - if (section[0] == this->getFilterTid()) { - //printf("->3\n"); - if (checkCRC32(section)) { - if (getSectionCRC(section) != this->getLastSectionCRC()) { - this->setLastSectionCRC(getSectionCRC(section)); - return 1; - } else { - //Old Version Of Section - /*analisadorSI*/listener->notifyOldSection(myPacket->getPid(), getTid( - section), getTidX(section)); - if (getTid(section) == 80) { - int a = util.getBits(section, 0, 48, 8); - if (a == 48) { - //printf("\nOld Section\n"); - } - } - return 0; - } - } else { - //return 0; - this->setCrcErrorCount(this->getCrcErrorCount() + 1); - cout << "\nERRO DE CRC no PID " << myPacket->getPid() << endl; - - sectionSizee = getSectionSize(section); - - listener->notifyErroCRC(this->getCrcErrorCount(), - myPacket->getPid(), getTid(section), getTidX(section), - section, sectionSizee); - - //return 1; - return 0; - } - - } else { - - return 0; - } - } else { - - if ((section[0] == this->getFilterTid()) && (getIntAtBits(section, 24, - 16) == this->getFilterTidx())) { - if (checkCRC32(section)) { - if (getSectionCRC(section) != this->getLastSectionCRC()) { - this->setLastSectionCRC(getSectionCRC(section)); - return 1; - } else { - //Old Version Of Section - /*analisadorSI*/listener->notifyOldSection(myPacket->getPid(), getTid( - section), getTidX(section)); - return 0; - } - } else { - this->setCrcErrorCount(this->getCrcErrorCount() + 1); - sectionSizee = getSectionSize(section); - /*analisadorSI*/listener->notifyErroCRC(this->getCrcErrorCount(), - myPacket->getPid(), getTid(section), getTidX(section), - section, sectionSizee); - cout << "\nERRO DE CRC no PID " << myPacket->getPid() << endl; - - return 0; - } - } else { - //printf("->6"); - return 0; - } - } -} - -void Filter::setLastSectionCRC(int lastSectionCRC) { - this->lastSectionCRC = lastSectionCRC; -} - -void Filter::setFilterPid(int FilterPID) { - this->FilterPID = FilterPID; -} - -void Filter::setFilterTid(int FilterTID) { - this->FilterTID = FilterTID; -} - -void Filter::setFilterTidx(int FilterTIDx) { - this->FilterTIDx = FilterTIDx; -} - -void Filter::setCrcErrorCount(int crcErrorCount) { - this->crcErrorCount = crcErrorCount; -} - -int Filter::getCrcErrorCount() { - return crcErrorCount; -} - -int Filter::getLastSectionCRC() { - return lastSectionCRC; -} - -int Filter::getFilterPid() { - return FilterPID; -} - -int Filter::getFilterTid() { - return FilterTID; -} - -int Filter::getFilterTidx() { - return FilterTIDx; -} - diff --git a/demux/src/include/bitutil_hal.h b/demux/src/include/bitutil_hal.h deleted file mode 100644 index 1eaf15a..0000000 --- a/demux/src/include/bitutil_hal.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef BITUTIL_H_ -#define BITUTIL_H_ -//#include "global_init.h" - -typedef unsigned char U8; -typedef unsigned short U16; -typedef unsigned int U32; -typedef unsigned char BOOL; - -#define TRUE (1) -#define FALSE (0) - -U8 getByteAt(unsigned char * bitStream,int byteIndex); -BOOL getBitAt(unsigned char * bitStream, int bitIndex); -U32 getIntAt(unsigned char * bitStream,int intIndex); -U8 getByteAtBits(unsigned char * bitStream,int firstBitOffset, int length); -U32 getIntAtBits(unsigned char * bitStream,int firstBitOffset, int length); - - -#endif /*BITUTIL_H_*/ diff --git a/demux/src/include/demux.h b/demux/src/include/demux.h deleted file mode 100644 index 320dc8b..0000000 --- a/demux/src/include/demux.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * demux.h - * - * Created on: 09/10/2008 - * Author: lacet - */ - -#ifndef DEMUX_H_ -#define DEMUX_H_ - -#include "filter.h" -#include -#include "jthread.h" -#include -#include "demuxListener.h" -#include "ouvinteDemux.h" -#include "ouvinteInput.h" - - -using namespace std; - -using namespace jthread; - -class Demux : public OuvinteInput { - -private: - - vector *permanentFilters; - //vector *filters; - //Filter* *filters; - //Filter* filter; - vector *addedFilter; - vector *filtersAux; - SectionBuffer* mySectionBuffer; - DemuxListener* listener; - int sectionSize; - - int sectionRead; - unsigned char section[MAX_SECTION_SIZE]; - int payloadSize; - int firstPart; - int quantity; - int remain; - int countPacotes; - unsigned char sectionData[MAX_SECTION_SIZE]; - int continuityCounter; - int lastContinuityCounter; - int flagShiftPointerField; - - std::list * ouvintes; - pthread_mutex_t *mutex; - -public: - //void setDemuxListener(); - void setDemuxListener(DemuxListener* listener); - Filter* filter; - ~Demux(); - Demux(int pid); - Demux(int pid, DemuxListener* listener); - Filter* getFilter(); - int getNextSection(unsigned char* packet, Packet *myPacket); - - virtual void chegouInput(unsigned char *pacote); - void registraOuvinte(OuvinteDemux * ouvinte); - void removeOuvinte(OuvinteDemux * ouvinte); - void notificaOuvintes(unsigned char * CC); - -}; - -#endif /* DEMUX_H_ */ diff --git a/demux/src/include/demuxListener.h b/demux/src/include/demuxListener.h deleted file mode 100644 index 6ea5cc6..0000000 --- a/demux/src/include/demuxListener.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * demuxListener.h - * - * Created on: 03/10/2008 - * Author: thales - */ - -#ifndef DEMUXLISTENER_H_ -#define DEMUXLISTENER_H_ - - -#include -#include -#include - -using namespace std; - -class DemuxListener{ -public: - DemuxListener(); - ~DemuxListener(); - virtual void notifySection(int PID, unsigned char* section, int sectionSize) = 0; - - virtual void notifyErroCRC(int numErroCRC, int PID, int tableID, int tableIDX, unsigned char* section, - int sectionSize) = 0; - - virtual void notifyOldSection(int PID, int tableID, int tableIDX) = 0; - - // virtual ~DemuxListener() = 0; - -}; - - -#endif /* IANALISADORSI_H_ */ diff --git a/demux/src/include/filter.h b/demux/src/include/filter.h deleted file mode 100644 index cef7a36..0000000 --- a/demux/src/include/filter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * filter.h - * - * Created on: 08/10/2008 - * Author: lacet - */ - -#ifndef FILTER_H_ -#define FILTER_H_ - -#include "sectionBuffer.h" -#include "bitutil_hal.h" -#include "demuxListener.h" -#include "packet.h" - - - -class Filter { - -private: - int FilterPID; - int FilterTID; - int FilterTIDx; - int lastSectionCRC; - int crcErrorCount; - -public: - Filter(int FilterPID, int FilterTID, int FilterTIDx); - Filter(); - virtual ~Filter(); - int isValid(unsigned char *section, Packet* myPacket, DemuxListener* listener); - //int getNextPacket(unsigned char *packet); - //int getNextSection(unsigned char *section, SectionBuffer *mySectionBuffer); - //int test(); - void setLastSectionCRC(int lastSectionCRC); - void setFilterPid(int FilterPID); - void setFilterTid(int FilterTID); - void setFilterTidx(int FilterTIDx); - void setCrcErrorCount(int crcErrorCount); - int getLastSectionCRC(); - int getFilterPid(); - int getFilterTid(); - int getFilterTidx(); - int getCrcErrorCount(); - -}; - -#endif /* FILTER_H_ */ diff --git a/demux/src/include/ouvinteDemux.h b/demux/src/include/ouvinteDemux.h deleted file mode 100644 index 7af2136..0000000 --- a/demux/src/include/ouvinteDemux.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * File: ouvintedemux.h - * Author: felipel - * - * Created on 12 de Julho de 2010, 15:03 - */ - -#ifndef OUVINTEDEMUX_H -#define OUVINTEDEMUX_H - -#include - -using namespace std; - -class OuvinteDemux { -public: - OuvinteDemux(); - virtual ~OuvinteDemux(); - - virtual void chegou(unsigned char * section) = 0; -private: - -}; - -#endif /* OUVINTEDEMUX_H */ - diff --git a/demux/src/include/packet.h b/demux/src/include/packet.h deleted file mode 100644 index 32380c2..0000000 --- a/demux/src/include/packet.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Modificado por: @Felipe Lacet - * Ultima Atualização: 08/10/2008 - * - * packet.h - * - */ - -#ifndef PACKET_H_ -#define PACKET_H_ -//#include "global_init.h" -#include "bitutil_hal.h" -#define PACKET_SIZE (188) - - - -class Packet{ - -public: - -Packet(unsigned char* packet); -~Packet(); -unsigned char* getPayloadBeginingAtUnitStarted(); -BOOL hasPointerField(); -BOOL hasPayload(); -U8 getPayloadLength(); -unsigned char * getPayloadCopy(); -U8 getPayloadBeginingAtUnitStartedLength(); -U8 getPointerField(); -U16 getPid(); -U8 getAdaptationFieldLength(); -U32 getContinuityCounter(); -BOOL hasAdaptationField(); -BOOL parser(); - -private: - -unsigned char* packet; - -}; - -#endif /*PACKET_H_*/ diff --git a/demux/src/include/sectionBuffer.h b/demux/src/include/sectionBuffer.h deleted file mode 100644 index 90f05c6..0000000 --- a/demux/src/include/sectionBuffer.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Modificado por: @Felipe Lacet - * Ultima Atualização: 08/10/2008 - * - * sectionBuffer.h - * - */ -#ifndef QUEUE_H_ -#define QUEUE_H_ -#include "section_hal.h" - -#define MAX_SECTIONS_COUNT (20) - -#define SECTIONS_BUFFER_SIZE (MAX_SECTIONS_COUNT*MAX_SECTION_SIZE) - -class SectionBuffer{ - -private: - unsigned char sectionsBufferData[SECTIONS_BUFFER_SIZE]; - int sectionsBufferBegin; - int sectionsBufferEnd; - int bufferSectionsCount; - -public: - SectionBuffer(); - ~SectionBuffer(); - void copyData(unsigned char *data, int *position, int size, int fromBuffer); - void initSectionsBuffer(); - int getSectionsCount(); - void addSection(unsigned char *section); - void removeSection(unsigned char *section); - -}; - -#endif //QUEUE_H_ diff --git a/demux/src/include/section_hal.h b/demux/src/include/section_hal.h deleted file mode 100644 index 2ce8761..0000000 --- a/demux/src/include/section_hal.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef SECTION_H_ -#define SECTION_H_ -#include "bitutil_hal.h" -#include - -#define SECTION_HEADER_SIZE (6) - -#define MAX_SECTION_SIZE (4096) - - -U8 getTid(unsigned char* section); -U16 getTidX(unsigned char* section); -int getSectionSize(unsigned char* payload); -U8 getSectionNumber(unsigned char *bitStream); -U32 getSectionCRC(unsigned char* section); -BOOL checkCRC32(unsigned char* section); -U32 calculateCrc(unsigned char *begin, unsigned count); - - - - -#endif /*SECTION_H_*/ diff --git a/demux/src/include/util.h b/demux/src/include/util.h deleted file mode 100644 index ade7176..0000000 --- a/demux/src/include/util.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef UTIL_H_ -#define UTIL_H_ - -#include -#include -#include -#include -#include - -using std::string; - -namespace utils -{ - -class Util -{ -public: - - /* - retorna os bits do buffer. - */ - static unsigned long long getBits(unsigned char* buf, int byte_offset, int startbit, int bitlen); - - static void stringUpper(string& string); - - static string int2str(int n); - - static int stringtoint(const char* string); - - static long long getBits48(unsigned char *buf, int byte_offset, int startbit, int bitlen); - - static unsigned long long getBits64(unsigned char *buf, int byte_offset, int startbit, int bitlen); -}; - -} - -#endif /*UTIL_H_*/ diff --git a/demux/src/ouvinteDemux.cpp b/demux/src/ouvinteDemux.cpp deleted file mode 100644 index 2cda3a7..0000000 --- a/demux/src/ouvinteDemux.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * File: ouvinteDemux.cpp - * Author: felipel - * - * Created on 12 de Julho de 2010, 15:03 - */ - -#include "ouvinteDemux.h" - -OuvinteDemux::OuvinteDemux() { -} - -OuvinteDemux::~OuvinteDemux() { -} - diff --git a/demux/src/packet.cpp b/demux/src/packet.cpp deleted file mode 100644 index 66e8b65..0000000 --- a/demux/src/packet.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* Modificado por: @Felipe Lacet - * Ultima Atualização: 08/10/2008 - * - * Packet.cpp - * - */ -#include "bitutil_hal.h" -#include "packet.h" -//#include "dprintf.h" -#include -int TS_PACKET_SIZE = 188; - -//static int payloadIndex; -using namespace std; - -Packet::Packet(unsigned char* packet) { - - this->packet = packet; - -} - -Packet::~Packet() { -}; - -unsigned char* Packet::getPayloadBeginingAtUnitStarted() { - - int payloadIndex = 4 + (hasAdaptationField() ? 1 : 0) + getAdaptationFieldLength(); - return (&packet[payloadIndex]); - -} - -BOOL Packet::hasPointerField() { - return ( getBitAt(packet, 9)); -} - -BOOL Packet::hasPayload() { - unsigned int adaptationFieldControl = getByteAtBits(packet, 26, 2); - - if ((adaptationFieldControl == 0x1) || (adaptationFieldControl == 0x3)) { - return (1); - } else { - return (0); - } -} - -U8 Packet::getPayloadLength() { - if (!hasPayload()) { - return (0); - } else { - return (TS_PACKET_SIZE - (hasAdaptationField() ? 1 : 0) - getAdaptationFieldLength() - 4); - } -} - -unsigned char* Packet::getPayloadCopy() { - int payloadIndex = 4 + (hasAdaptationField() ? 1 : 0) + getAdaptationFieldLength(); - - if (hasPayload()) { - int size = getPayloadLength(); - - /*unsigned char * payload =(unsigned char *) malloc(sizeof(unsigned char)*size);*/ - return (&packet[payloadIndex]); - - /*memcpy(payload, &packet[payloadIndex], size);*/ - /*return payload;*/ - /*return &packet[payloadIndex];*/ - } else { - return (NULL); - } -} - -U8 Packet::getPayloadBeginingAtUnitStartedLength() { - int payloadIndex = 4 + (hasAdaptationField() ? 1 : 0) + getAdaptationFieldLength(); - return TS_PACKET_SIZE - payloadIndex - 1; -} - -U8 Packet::getPointerField() { - int payloadIndex = 4 + (hasAdaptationField() ? 1 : 0) + getAdaptationFieldLength(); - - if (hasPointerField()) { - unsigned char pf = getByteAt(packet, payloadIndex); - //cout << "Poiter Field: " << pf << endl; - //printf("Poiter Field: %x\n", pf); - return ( getByteAt(packet, payloadIndex)); - } else { - return (0); - } -} - -U16 Packet::getPid() { - return ( getIntAtBits(packet, 11, 13)); -} - -U8 Packet::getAdaptationFieldLength() { - if (hasAdaptationField()) { - return ( getByteAt(packet, 4)); - } else { - return (0); - } -} - -unsigned int Packet::getContinuityCounter() { - return ( getIntAtBits(packet, 28, 4)); -} - -BOOL Packet::hasAdaptationField() { - unsigned int adaptationFieldControl = getByteAtBits(packet, 26, 2); - - if ((adaptationFieldControl == 0x2) || (adaptationFieldControl == 0x3)) { - return TRUE; - } else { - return FALSE; - } -} - -BOOL Packet::parser() { - // DPRINTF("PACOTE %X\n",packet[0]); - if (getByteAt(packet, 0) != 0x47) { - // DPRINTF("NAO PACOTE"); - return FALSE; - } - - if (getBitAt(packet, 8)) { - // DPRINTF("NAO PACOTE 2"); - - return FALSE; - } - // payloadIndex = 4 + (hasAdaptationField(packet) ? 1 : 0) + getAdaptationFieldLength(packet); - return TRUE; -} diff --git a/demux/src/sectionBuffer.cpp b/demux/src/sectionBuffer.cpp deleted file mode 100644 index d68f408..0000000 --- a/demux/src/sectionBuffer.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* Modificado por: @Felipe Lacet - * Ultima Atualização: 08/10/2008 - * - * SectionBuffer.cpp - * - */ - -//#include "queue.h" -#include -#include -//#include "dprintf.h" -#include "section_hal.h" -#include "sectionBuffer.h" - -SectionBuffer::SectionBuffer() { - initSectionsBuffer(); -} - -SectionBuffer::~SectionBuffer() { -} - -void SectionBuffer::copyData(unsigned char *data, int *position, int size, int fromBuffer) { - unsigned char *source, *target; - int rightSpace; - - rightSpace = SECTIONS_BUFFER_SIZE - *position; - if (fromBuffer) { - source = sectionsBufferData + *position; - target = data; - } else { - source = data; - target = sectionsBufferData + *position; - } - - if (size > rightSpace) { - memcpy(target, source, rightSpace); - if (fromBuffer) { - target = data + rightSpace; - source = sectionsBufferData; - } else { - target = sectionsBufferData; - source = data + rightSpace; - } - memcpy(target, source, size - rightSpace); - } else { - memcpy(target, source, size); - } - - *position = (*position + size) % SECTIONS_BUFFER_SIZE; -} - -void SectionBuffer::initSectionsBuffer() { - sectionsBufferBegin = 0; - sectionsBufferEnd = 0; - bufferSectionsCount = 0; - memset(sectionsBufferData, 0, SECTIONS_BUFFER_SIZE); -} - -//int getSectionsCount(demux_section_t *demux_section) - -int SectionBuffer::getSectionsCount() { - return bufferSectionsCount; -} - -void SectionBuffer::addSection(unsigned char *section) { - copyData(section, §ionsBufferEnd, getSectionSize(section), 0); - bufferSectionsCount++; -} - -void SectionBuffer::removeSection(unsigned char *section) { - // copy section header - copyData(section, §ionsBufferBegin, SECTION_HEADER_SIZE, 1); - // copy section body - copyData(section + SECTION_HEADER_SIZE, §ionsBufferBegin, getSectionSize(section) - SECTION_HEADER_SIZE, 1); - // update sections counter - bufferSectionsCount--; -} - -/* - -// tests - -int main() { - int i, j, k; - unsigned char section[5][8] = { - { 99, 0, 2, 99, 99, 99, 99, 99 }, - { 88, 0, 5, 88, 88, 88, 88, 88 }, - { 77, 0, 1, 77, 77, 77, 77, 77 }, - { 66, 0, 3, 66, 66, 66, 66, 66 }, - { 55, 0, 1, 55, 55, 55, 55, 55 } - }; - - initSectionsBuffer(); - DPRINTF("---------------\n"); - - for (i = 0, k = 0; i < 10; i++) { - DDPRINTF("i = %d\n", i); - if (i % 2 == 1) { - unsigned char removed[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - DDPRINTF("will REMOVE section:"); - removeSection(removed); - for (j = 0; j < getSectionSize(removed); j++) { - printf("%3d", removed[j]); - } - printf("\n"); - } else { - DDPRINTF("will ADD section %d with %d bytes\n", k, getSectionSize(section[k])); - addSection(section[k++]); - } - DPRINTF("data:"); - for (j = 0; j < SECTIONS_BUFFER_SIZE; j++) { - printf("%3d", demux_section->sectionsBufferData[j]); - } - printf("\n"); - DPRINTF(" "); - for (j = 0; j < SECTIONS_BUFFER_SIZE; j++) { - printf(demux_section->sectionsBufferBegin == j ? (demux_section->sectionsBufferEnd == j ? " be" : " b") : (demux_section->sectionsBufferEnd == j ? " e" : " ")); - } - printf("\n"); - DPRINTF("sections count = %d\n", demux_section->bufferSectionsCount); - DPRINTF("---------------\n"); - } -}*/ diff --git a/demux/src/section_hal.cpp b/demux/src/section_hal.cpp deleted file mode 100644 index a0c84f7..0000000 --- a/demux/src/section_hal.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "section_hal.h" - -int crcError; -#include -using namespace std; - - -U32 CRC32[256] = { - 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, - 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, - 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, - 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, - 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, - 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, - 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, - 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, - 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, - 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, - 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, - 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, - 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, - 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, - 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, - 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, - 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, - 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, - 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, - 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, - 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, - 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, - 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, - 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, - 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, - 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, - 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, - 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, - 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, - 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, - 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, - 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, - 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, - 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, - 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, - 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, - 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, - 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, - 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, - 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, - 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, - 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, - 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4, -}; - -U8 getTid(unsigned char* section) { - return getByteAt(section, 0); -} - -U16 getTidX(unsigned char* section) { - return getIntAtBits(section, 24, 16); -} - -int getSectionSize(unsigned char* payload) { - - return getIntAtBits(payload, 12, 12) + 3; - -} - -U8 getSectionNumber(unsigned char *bitStream) { - return getIntAtBits(bitStream, 48, 8); -} - -U32 getSectionCRC(unsigned char* section) { - U32 sectionCRC = getIntAtBits(section, (getSectionSize(section)*8) - 32, 32); - return sectionCRC; -} - -BOOL checkCRC32(unsigned char* section) { - //if (!getBitAt(section, 8)) { - // printf("\nCRC ERROR - YES\n"); - // return FALSE; - //} - U32 aux; - int i; - - U32 sectionCRC32 = getIntAtBits(section, (getSectionSize(section)*8) - 32, 32); - - aux = calculateCrc(section, (getSectionSize(section) - 4)); - - if (aux == sectionCRC32) { - //printf("\nCRC Calculado: %x\nCRC Lido:%x\n", aux, sectionCRC32); - - return TRUE; - - } - printf("\nCRC Calculado: %x\nCRC Lido:%x\n", aux, sectionCRC32); - return FALSE; -} - -U32 calculateCrc(unsigned char *begin, unsigned count) { - unsigned crc = 0xffffffff; - - while (count > 0) { - crc = (crc << 8) ^ CRC32[(crc >> 24) ^ ((unsigned) * begin)]; - begin++; - count--; - } - - return crc; -} - - diff --git a/demux/src/util.cpp b/demux/src/util.cpp deleted file mode 100644 index ba80fd6..0000000 --- a/demux/src/util.cpp +++ /dev/null @@ -1,135 +0,0 @@ -#include "util.h" - -namespace utils { - - void Util::stringUpper(string& string) { - transform(string.begin(), string.end(), string.begin(), toupper); - } - - string Util::int2str(int n) { - std::stringstream ss; - - ss << n; - return ss.str(); - } - - int Util::stringtoint(const char* string) { - return atoi(string); - } - - /* - -- get bits out of buffer (max 32 bit!!!) - -- return: value - */ - - unsigned long long Util::getBits(unsigned char* buf, int byte_offset, int startbit, int bitlen) { - unsigned char *b; - unsigned long v; - unsigned long mask; - unsigned long tmp_long; - int bitHigh; - - - b = &buf[byte_offset + (startbit >> 3)]; - startbit %= 8; - - switch ((bitlen - 1) >> 3) { - case -1 : // -- <=0 bits: always 0 - return 0L; - break; - - case 0: // -- 1..8 bit - tmp_long = (unsigned long) ( - (*(b) << 8) + *(b + 1)); - bitHigh = 16; - break; - - case 1: // -- 9..16 bit - tmp_long = (unsigned long) ( - (*(b) << 16) + (*(b + 1) << 8) + *(b + 2)); - bitHigh = 24; - break; - - case 2: // -- 17..24 bit - tmp_long = (unsigned long) ( - (*(b) << 24) + (*(b + 1) << 16) + - (*(b + 2) << 8) + *(b + 3)); - bitHigh = 32; - break; - - case 3: // -- 25..32 bit - // -- to be safe, we need 32+8 bit as shift range - return (unsigned long) Util::getBits48(b, 0, startbit, bitlen); - break; - - default: // -- 33.. bits: fail, deliver constant fail value - //printf("\nGET BITS: OUT OF BOUNDS\n"); - return getBits48(buf, byte_offset, startbit, bitlen); - break; - } - - startbit = bitHigh - startbit - bitlen; - tmp_long = tmp_long >> startbit; - mask = (1ULL << bitlen) - 1; // 1ULL !!! - v = tmp_long & mask; - - return v; - } - - /* - -- get bits out of buffer (max 48 bit) - -- extended bitrange, so it's slower - -- return: value - */ - - long long Util::getBits48(unsigned char *buf, int byte_offset, int startbit, int bitlen) { - unsigned char *b; - unsigned long long v; - unsigned long long mask; - unsigned long long tmp; - - if (bitlen > 48) { - printf("\ngetBits48() OUT OF BOUNDS\n"); - return getBits64(buf, byte_offset, startbit, bitlen); - } - - - b = &buf[byte_offset + (startbit / 8)]; - startbit %= 8; - - - // -- safe is 48 bitlen - tmp = (unsigned long long) ( - ((unsigned long long) *(b) << 48) + ((unsigned long long) *(b + 1) << 40) + - ((unsigned long long) *(b + 2) << 32) + ((unsigned long long) *(b + 3) << 24) + - (*(b + 4) << 16) + (*(b + 5) << 8) + *(b + 6)); - - startbit = 56 - startbit - bitlen; - tmp = tmp >> startbit; - mask = (1ULL << bitlen) - 1; // 1ULL !!! - v = tmp & mask; - - return v; - } - - /* - -- get bits out of buffer (max 64 bit) - -- extended bitrange, so it's slower - -- return: value - */ - - unsigned long long Util::getBits64(unsigned char *buf, int byte_offset, int startbit, int bitlen) { - unsigned long long x1, x2, x3; - - if (bitlen <= 32) { - x3 = Util::getBits(buf, byte_offset, startbit, bitlen); - } else { - x1 = Util::getBits(buf, byte_offset, startbit, 32); - x2 = Util::getBits(buf, byte_offset, startbit + 32, bitlen - 32); - x3 = (x1 << (bitlen - 32)) + x2; - } - return x3; - } - -} - diff --git a/extratorCC/src/extratorCC.cpp b/extratorCC/src/extratorCC.cpp deleted file mode 100644 index 65681c9..0000000 --- a/extratorCC/src/extratorCC.cpp +++ /dev/null @@ -1,487 +0,0 @@ -/* - * File: PacketPES.cpp - * Author: felipe - * - * Created on 19 de Outubro de 2009, 14:49 - */ - -#include "extratorCC.h" -#include -#include -#include -#include -#include - -#include "dprintf.h" - -using namespace std; - -ExtratorCC::ExtratorCC() { - ouvintes = new list(); - - PTS = 0; - - // Inicia o mutex - mutex = (pthread_mutex_t *) malloc(sizeof (pthread_mutex_t)); - pthread_mutex_init(mutex, NULL); -} - -void ExtratorCC::notifySection(int PID, unsigned char* section, int sectionSize) { - //cout << "Recebi PES com a PID: " << PID << endl; - packetPES(section); - -} - -void ExtratorCC::notifyErroCRC(int numErroCRC, int PID, int tableID, int tableIDX, unsigned char* section, int sectionSize) { - -} - -void ExtratorCC::notifyOldSection(int PID, int tableID, int tableIDX) { - -} - -ExtratorCC::~ExtratorCC() { - if (ouvintes) { - // nao deleta os ouvintes mesmo, apenas a lista - ouvintes->clear(); - delete ouvintes; - } - - if (mutex) { - int ret = pthread_mutex_destroy(mutex); - if (ret) - DDDPRINTF("erro destruindo mutex\n"); - free(mutex); - } -} - -/*void ExtratorCC::chegouInput(unsigned char *pacote) { - // Mutex para evitar bug multiplas chamadas dos notificadores - pthread_mutex_lock(mutex); - - //packetPES(pacote); - - pthread_mutex_unlock(mutex); -}*/ - - -int ExtratorCC::contemAF(unsigned char * pacote) { - return pacote[3] & 0x20; -} - -int ExtratorCC::contemDTS(unsigned char * ExtratorCC) { - return ((ExtratorCC[7] >> 6) & 0x03); -} - -int ExtratorCC::contemESCR(unsigned char * ExtratorCC) { - return ((ExtratorCC[7] >> 5) & 0x01); -} - -int ExtratorCC::contemDSM(unsigned char * ExtratorCC) { - return ((ExtratorCC[7] >> 3) & 0x01); -} - -int ExtratorCC::contemPES_extension(unsigned char * ExtratorCC) { - return ExtratorCC[7] & 0x01; -} - -int ExtratorCC::contemAdditional(unsigned char * ExtratorCC) { - return ((ExtratorCC[7] >> 2) & 0x01); -} - -int ExtratorCC::contemPES_CRC(unsigned char * ExtratorCC) { - return ((ExtratorCC[7] >> 1) & 0x01); -} - -int ExtratorCC::contemES_rate(unsigned char * ExtratorCC) { - return ((ExtratorCC[7] >> 4) & 0x01); -} - -int ExtratorCC::contemPayloadData(unsigned char *pacote) { - return pacote[3] & 0x10; -} - -int ExtratorCC::contemPayloadStartIndicator(unsigned char *pacote) { - return pacote[1] & 0x40; -} - -int ExtratorCC::contemPCR(unsigned char * pacote) { - return pacote[5] & 0x10; -} - -int ExtratorCC::contemPTS(unsigned char * ExtratorCC) { - return ((ExtratorCC[7] >> 6) & 0x02); -} - -short unsigned ExtratorCC::GetTamanhoAF(unsigned char *pacote) { - return pacote[4]; -} - -int ExtratorCC::verificaPESStartCode(unsigned char * ExtratorCC) { - // cout << "Start Code: " << ((PESPacket[0] << 16) | (PESPacket[1] << 8) | (PESPacket[2])) << endl; - return (((ExtratorCC[0] << 16) | (ExtratorCC[1] << 8) | (ExtratorCC[2])) - == 0x000001) ? 1 : 0; -} - -int ExtratorCC::verificaPESStreamID(unsigned char * ExtratorCC) { - int stream_id = ExtratorCC[3]; - - return ((stream_id != 0xBC) && (stream_id != 0xBE) && (stream_id != 0xBF) - && (stream_id != 0xF0) && (stream_id != 0xF1) && (stream_id != 0xFF) - && (stream_id != 0xF2) && (stream_id != 0xF8)); -} - -int ExtratorCC::verificaPESStreamIDSynchronized(unsigned char * ExtratorCC) { - int stream_id = ExtratorCC[3]; - - return ((stream_id == 0xBD)); -} - -/* Extrai o PTS (Presentation Time Stamp) do pacote PES e retorna um - * int64_t contendo os 33-bits extraídos */ -int64_t ExtratorCC::extractPTS(unsigned char* PESPacket) { - - int64_t pts, c1, c2, c3 = 0; - - // leitura do 1º campo do PTS[32..30] - c1 = ((PESPacket[9] & 0x0E) >> 1); // 0x0E = 00001110 - pts = c1; - - // leitura do 2º campo do PTS[29..15] - c2 = (((PESPacket[10] << 8) | (PESPacket[11])) >> 1); // >> 1 tira o marker_bit - pts = (((pts << 16) | (c2 << 1)) >> 1); - - // leitura do 3º campo do PTS[14..0] - c3 = (((PESPacket[12] << 8) | (PESPacket[13])) >> 1); - pts = (((pts << 16) | (c3 << 1)) >> 1); - - return pts; - -} - -/* Extrai o DTS 33-bits (Decoding Time Stamp) do pacote PES */ -int64_t ExtratorCC::extractDTS(unsigned char* PESPacket) { - - int64_t dts, c1, c2, c3 = 0; - - // leitura do 1º campo do DTS[32..30] - c1 = ((PESPacket[14] & 0x0E) >> 1); // 0x0E = 00001110 - dts = c1; - - // leitura do 2º campo do DTS[29..15] - c2 = (((PESPacket[15] << 8) | (PESPacket[16])) >> 1); // >> 1 tira o marker_bit - dts = (((dts << 16) | (c2 << 1)) >> 1); - - // leitura do 3º campo do DTS[14..0] - c3 = (((PESPacket[17] << 8) | (PESPacket[18])) >> 1); - dts = (((dts << 16) | (c3 << 1)) >> 1); - - return dts; - -} - -int ExtratorCC::packetPES(unsigned char *pacote) { - int N1, N2, PES_header_data_length, PES_packet_length, cont_stuffing_byte = 0, cont_PES_packet_data_byte = 0; - int pack_stuffing_length, system_header_start_code, PES_packet_data_byte; - - this->PTS = 0; - this->DTS = 0; - - - int inicioPESData = 0; - - if ((!verificaPESStartCode(pacote + inicioPESData)) || - (!verificaPESStreamIDSynchronized(pacote + inicioPESData))) { - - return -1; - } - - PES_packet_data_byte = inicioPESData + 9; - PES_packet_length = (((pacote[inicioPESData + 4] & 0xFF) << 8) | (pacote[inicioPESData + 5] & 0xFF)); - PES_header_data_length = pacote[inicioPESData + 8]; - cont_PES_packet_data_byte = 3; - - /* PTS_DTS_flags = '10' */ - if (contemPTS(pacote + inicioPESData) == 2) { - PTS = extractPTS(pacote); - PES_packet_data_byte += 5; - cont_stuffing_byte += 5; - } - - /* PTS_DTS_flags = '11' */ - if (contemDTS(pacote + inicioPESData) == 3) { - PTS = extractPTS(pacote); - DTS = extractDTS(pacote); - PES_packet_data_byte += 10; - cont_stuffing_byte += 10; - } - - if (contemESCR(pacote + inicioPESData) == 1) { - PES_packet_data_byte += 6; - cont_stuffing_byte += 6; - } - - if (contemES_rate(pacote + inicioPESData) == 1) { - PES_packet_data_byte += 3; - cont_stuffing_byte += 3; - } - - if (contemDSM(pacote + inicioPESData) == 1) { - PES_packet_data_byte += 1; - cont_stuffing_byte += 1; - } - - if (contemAdditional(pacote + inicioPESData) == 1) { - PES_packet_data_byte += 1; - cont_stuffing_byte += 1; - } - - if (contemPES_CRC(pacote + inicioPESData) == 1) { - PES_packet_data_byte += 2; - cont_stuffing_byte += 2; - } - - if (contemPES_extension(pacote + inicioPESData) == 1) { - int flag = PES_packet_data_byte; - int PES_extension_field_length, PES_private_data_flag, pack_header_field_flag; - int program_packet_sequence_counter_flag, PSTD_buffer_flag, PES_extension_flag_2; - PES_packet_data_byte += 1; - cont_stuffing_byte += 1; - - PES_private_data_flag = ((pacote[flag] >> 7) & 0x01); - if (PES_private_data_flag == 1) { - PES_packet_data_byte += 16; - cont_stuffing_byte += 16; - } - - pack_header_field_flag = ((pacote[flag] >> 6) & 0x01); - if (pack_header_field_flag == 1) { - PES_packet_data_byte += 14; - cont_stuffing_byte += 15; - pack_stuffing_length = pacote[PES_packet_data_byte] & 0x07; - PES_packet_data_byte += 1; - for (int i = 0; i < pack_stuffing_length; i++) { - PES_packet_data_byte++; - cont_stuffing_byte++; - } - system_header_start_code = (pacote[PES_packet_data_byte] << 24) | (pacote[PES_packet_data_byte + 1] << 16) | (pacote[PES_packet_data_byte + 2] << 8) | (pacote[PES_packet_data_byte + 3]); - if (system_header_start_code == 0x000001BB) { - PES_packet_data_byte += 12; - cont_stuffing_byte += 12; - while (pacote[PES_packet_data_byte] == 0x01) { - PES_packet_data_byte += 3; - cont_stuffing_byte += 3; - } - } - } - - program_packet_sequence_counter_flag = ((pacote[flag] >> 5) & 0x01); - if (program_packet_sequence_counter_flag == 1) { - PES_packet_data_byte += 2; - cont_stuffing_byte += 2; - } - - PSTD_buffer_flag = ((pacote[flag] >> 4) & 0x01); - if (PSTD_buffer_flag == 1) { - PES_packet_data_byte += 2; - cont_stuffing_byte += 2; - } - - PES_extension_flag_2 = pacote[flag] & 0x01; - if (PES_extension_flag_2 == 1) { - PES_extension_field_length = pacote[PES_packet_data_byte] & 0x7F; - PES_packet_data_byte += 1; - cont_stuffing_byte += 1; - for (int i = 0; i < PES_extension_field_length; i++) { - PES_packet_data_byte++; - cont_stuffing_byte++; - } - } - } - - N1 = PES_header_data_length - cont_stuffing_byte; - cont_PES_packet_data_byte += cont_stuffing_byte + N1; - N2 = PES_packet_length - cont_PES_packet_data_byte; - - for (int i = 0; i < N1; i++) { - PES_packet_data_byte++; - } - - synchronizedPesData(PES_packet_data_byte, pacote); - - return 0; -} - -void ExtratorCC::synchronizedPesData(int PES_packet_data_byte, unsigned char *pacote) { - int PES_data_private_data_byte; - PES_packet_data_byte += 2; - PES_data_private_data_byte = pacote[PES_packet_data_byte] & 0x0F; - PES_packet_data_byte += 1; - - for (int i = 0; i < PES_data_private_data_byte; i++) { - PES_packet_data_byte++; - } - - dataGroup(PES_packet_data_byte, pacote); -} - -void ExtratorCC::dataGroup(int PES_packet_data_byte, unsigned char *pacote) { - int data_group_id, data_group_size; - - data_group_id = (pacote[PES_packet_data_byte] >> 2) & 0x3F; - PES_packet_data_byte += 3; - data_group_size = (pacote[PES_packet_data_byte] << 8) | (pacote[PES_packet_data_byte + 1]); - PES_packet_data_byte += 2; - - captionData(PES_packet_data_byte, pacote, data_group_id); -} - -void ExtratorCC::captionData(int PES_packet_data_byte, unsigned char *pacote, int data_group_id) { - int TDM, data_unit_loop_length; - - TDM = (pacote[PES_packet_data_byte] >> 6) & 0x03; - PES_packet_data_byte += 1; - if (TDM == 1 || TDM == 2) { - PES_packet_data_byte += 5; - } - if (data_group_id > 0) { - data_unit_loop_length = (pacote[PES_packet_data_byte] << 16) | (pacote[PES_packet_data_byte + 1] << 8) | (pacote[PES_packet_data_byte + 2]); - PES_packet_data_byte += 4; - - dataUnit(PES_packet_data_byte, pacote); - } -} - -void ExtratorCC::dataUnit(int PES_packet_data_byte, unsigned char *pacote) { - int data_unit_parameter, data_unit_size, controle_CSI_count, controle_CSI, flag; - unsigned char msg[300]; // TODO ver qual eh o valor maximo que isso pode atingir - int k = 0; // contador que vai percorrer msg - - //FILE * pFile; - //stringstream st; - //string resultadoo, finall; - - //pFile = fopen ("tempo2.txt" , "a+"); - //if (pFile == NULL) perror ("Error opening file"); - - data_unit_parameter = pacote[PES_packet_data_byte]; - PES_packet_data_byte += 1; - data_unit_size = (pacote[PES_packet_data_byte] << 16) | (pacote[PES_packet_data_byte + 1] << 8) | (pacote[PES_packet_data_byte + 2]); - PES_packet_data_byte += 3; - - // printf("\nPACOTE: "); - // for (int f = 0; f < data_unit_size + 10; f++) { - // printf(" %x", pacote[f + PES_packet_data_byte]); - //} - - for (int i = 0; i < data_unit_size; i++) { - - if (pacote[PES_packet_data_byte + i] < 0x1C) { - } else - if (pacote[PES_packet_data_byte + i] == 0x1C) { - i += 2; - } else - if (pacote[PES_packet_data_byte + i] > 0x1C && pacote[PES_packet_data_byte + i] < 0x20) { - } else - if (pacote[PES_packet_data_byte + i] >= 0x80 && pacote[PES_packet_data_byte + i] <= 0x8A) { - } else - if (pacote[PES_packet_data_byte + i] == 0x8B) { - i += 1; - if (pacote[PES_packet_data_byte + i] == 0x60 || pacote[PES_packet_data_byte + i] == 0x41 || - pacote[PES_packet_data_byte + i] == 0x44 || pacote[PES_packet_data_byte + i] == 0x45 || - pacote[PES_packet_data_byte + i] == 0x6B || pacote[PES_packet_data_byte + i] == 0x64) { - } - } else - if (pacote[PES_packet_data_byte + i] == 0x90) { - if (pacote[PES_packet_data_byte + i + 1] == 0x20) - i += 2; - else - i += 1; - } else - if (pacote[PES_packet_data_byte + i] == 0x91) { - i += 1; - if (pacote[PES_packet_data_byte + i] == 0x40 || pacote[PES_packet_data_byte + i] == 0x47 || - pacote[PES_packet_data_byte + i] == 0x4F) { - } - } else - if (pacote[PES_packet_data_byte + i] == 0x92) { - if (pacote[PES_packet_data_byte + i + 1] == 0x20) - i += 2; - else - i += 1; - } else - if (pacote[PES_packet_data_byte + i] == 0x93) { - i += 1; - if (pacote[PES_packet_data_byte + i] == 0x40 || pacote[PES_packet_data_byte + i] == 0x41 || - pacote[PES_packet_data_byte + i] == 0x42) { - } - } else - if (pacote[PES_packet_data_byte + i] == 0x94) { - i += 1; - if (pacote[PES_packet_data_byte + i] == 0x40 || pacote[PES_packet_data_byte + i] == 0x44 || - pacote[PES_packet_data_byte + i] == 0x45) { - } - } else - if (pacote[PES_packet_data_byte + i] == 0x97 || pacote[PES_packet_data_byte + i] == 0x98) { - i += 1; - } else - if (pacote[PES_packet_data_byte + i] == 0x99 || pacote[PES_packet_data_byte + i] == 0x9A) { - } else - if (pacote[PES_packet_data_byte + i] == 0x9B) { - controle_CSI_count = 0; - flag = 0; - - controle_CSI = PES_packet_data_byte + i; - - while (flag == 0) { - if (pacote[controle_CSI] == 0x53 || pacote[controle_CSI] == 0x54 || pacote[controle_CSI] == 0x6E || - pacote[controle_CSI] == 0x61 || pacote[controle_CSI] == 0x56 || pacote[controle_CSI] == 0x5F || - pacote[controle_CSI] == 0x57 || pacote[controle_CSI] == 0x5B || pacote[controle_CSI] == 0x5C || - pacote[controle_CSI] == 0x58 || pacote[controle_CSI] == 0x59 || pacote[controle_CSI] == 0x42 || - pacote[controle_CSI] == 0x5D || pacote[controle_CSI] == 0x5E || pacote[controle_CSI] == 0x62 || - pacote[controle_CSI] == 0x65 || pacote[controle_CSI] == 0x63 || pacote[controle_CSI] == 0x64 || - pacote[controle_CSI] == 0x66 || pacote[controle_CSI] == 0x68 || pacote[controle_CSI] == 0x69 || - pacote[controle_CSI] == 0x6F) { - - flag = 1; - i += controle_CSI_count; - } - - controle_CSI++; - controle_CSI_count++; - } - } else { - if (pacote[PES_packet_data_byte + i] < 0x20) - msg[k++] = ' '; - else - msg[k++] = pacote[PES_packet_data_byte + i]; - } - } - - msg[k] = '\0'; - printf("\n****************************************************************************************"); - printf("\nMensagem extraida do CC: "); - printf("\033[31m"); - printf("_%s_", msg); - printf("\033[0m"); - printf("\n\n"); - - //printf("\nTEMPO DE EXTRAÇÃO: %lld\n\n", calculoFinal); - printf("PTS = %lld\n", PTS); - //printf("DTS = %lld\n", DTS); - notificaOuvintes(msg); -} - -void ExtratorCC::registraOuvinte(OuvinteCC * ouvinte) { - ouvintes->push_back(ouvinte); -} - -void ExtratorCC::removeOuvinte(OuvinteCC * ouvinte) { - ouvintes->remove(ouvinte); -} - -void ExtratorCC::notificaOuvintes(unsigned char * CC) { - for (list::iterator i = ouvintes->begin(); i != ouvintes->end(); i++) { - (*i)->notificaCC(CC, PTS); - } -} diff --git a/extratorCC/src/include/extratorCC.h b/extratorCC/src/include/extratorCC.h deleted file mode 100644 index 88b17ca..0000000 --- a/extratorCC/src/include/extratorCC.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * File: PacketPES.h - * Author: felipe - * - * Created on 19 de Outubro de 2009, 14:49 - */ - -#ifndef _EXTRATORCC_H -#define _EXTRATORCC_H - -#include -#include -#include -#include -#include -#include "ouvinteCC.h" -#include "stdint.h" -#include "ouvinteInput.h" -#include "demuxListener.h" - -using namespace std; - -class ExtratorCC : /*public OuvinteInput,*/ public DemuxListener { -public: - ExtratorCC(); - ~ExtratorCC(); - int packetPES(unsigned char *pacote); - - void synchronizedPesData(int PES_packet_data_byte, unsigned char *pacote); - void dataGroup(int PES_packet_data_byte, unsigned char *pacote); - void captionData(int PES_packet_data_byte, unsigned char *pacote, int data_group_id); - void dataUnit(int PES_packet_data_byte, unsigned char *pacote); - - int verificaPESStreamIDSynchronized(unsigned char * PESPacket); - int verificaPESStreamID(unsigned char * PESPacket); - int verificaPESStartCode(unsigned char * PESPacket); - int contemAF(unsigned char * pacote); - int contemDTS(unsigned char * PESPacket); - int contemESCR(unsigned char * PESPacket); - int contemPayloadData(unsigned char *pacote); - int contemPayloadStartIndicator(unsigned char *pacote); - int contemPCR(unsigned char * pacote); - int contemPTS(unsigned char * PESPacket); - int contemDSM(unsigned char * PESPacket); - int contemAdditional(unsigned char * PESPacket); - int contemES_rate(unsigned char * PESPacket); - int contemPES_CRC(unsigned char * PESPacket); - int contemPES_extension(unsigned char * PESPacket); - short unsigned GetTamanhoAF(unsigned char *pacote); - - int64_t extractPTS(unsigned char * PESPacket); - int64_t extractDTS(unsigned char * PESPacket); - - virtual void registraOuvinte(OuvinteCC * ouvinte); - virtual void removeOuvinte(OuvinteCC * ouvinte); - virtual void notificaOuvintes(unsigned char * CC); - - //virtual void chegouInput(unsigned char *pacote); - - virtual void notifySection(int PID, unsigned char* section, int sectionSize); - virtual void notifyErroCRC(int numErroCRC, int PID, int tableID, int tableIDX, unsigned char* section, int sectionSize); - virtual void notifyOldSection(int PID, int tableID, int tableIDX); - -private: - string ClosedCaption; - int64_t PTS, DTS; - - std::list * ouvintes; - - // Mutex para evitar mutiplas chamadas de notificadores - pthread_mutex_t *mutex; -}; - - -#endif - diff --git a/extratorCC/src/include/ouvinteCC.h b/extratorCC/src/include/ouvinteCC.h deleted file mode 100644 index a3b933f..0000000 --- a/extratorCC/src/include/ouvinteCC.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * File: ouvinteCC.h - * Author: felipe - * - * Created on 3 de Fevereiro de 2010, 19:44 - */ - -#ifndef _OUVINTECC_H -#define _OUVINTECC_H - -#include -#include - -using namespace std; - -class OuvinteCC { -public: - OuvinteCC(); - virtual ~OuvinteCC(); - - // inclusão do parâmetro "long int pts" - virtual void notificaCC(unsigned char * cc, int64_t pts) = 0; -private: - -}; - - -#endif /* _OUVINTECC_H */ - diff --git a/extratorCC/src/ouvinteCC.cpp b/extratorCC/src/ouvinteCC.cpp deleted file mode 100644 index 3a6a3f9..0000000 --- a/extratorCC/src/ouvinteCC.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * File: ouvinteCC.cpp - * Author: felipe - * - * Created on 3 de Fevereiro de 2010, 19:44 - */ - -#include "ouvinteCC.h" - -OuvinteCC::OuvinteCC() { -} - -OuvinteCC::~OuvinteCC() { -} - - diff --git a/servico/src/include/serviceWindowGenerationFromCC.h b/servico/src/include/serviceWindowGenerationFromCC.h deleted file mode 100644 index 7ad0c48..0000000 --- a/servico/src/include/serviceWindowGenerationFromCC.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SERVICEWINDOWGENERATIONFROMCC_H -#define SERVICEWINDOWGENERATIONFROMCC_H - -#include "serviceWindowGeneration.h" -#include "ouvinteCC.h" -#include -#include "inputFile.h" -#include "extratorCC.h" -#include "demux.h" -#include "stdint.h" -#include -#include "jthread.h" - -using namespace std; -using namespace jthread; - -class ServiceWindowGenerationFromCC : public ServiceWindowGeneration, public OuvinteCC, public Thread { -private: - pthread_mutex_t *mutex_serviceCC; - //LEONARDO: comentado. //InputFile *inputfile; - ExtratorCC *extratorCC; - Demux *demux; - //char* path_input; - //int numero_legendas; - - - -public: - - ServiceWindowGenerationFromCC( - char* path, int position, int size, int transparency, int _serviceType); - - ~ServiceWindowGenerationFromCC(); - //virtual void chegouCC(unsigned char * cc); - virtual void notificaCC(unsigned char * cc, int64_t pts); - void notificaTradutor(unsigned char * cc); - void notificaSincronizadorSemTradutor(unsigned char * cc, int64_t pts); - void initialize(); - void setPathInput(char* path); - void Run(); - -}; - -#endif diff --git a/servico/src/serviceWindowGenerationFromCC.cpp b/servico/src/serviceWindowGenerationFromCC.cpp deleted file mode 100644 index 06d1d5f..0000000 --- a/servico/src/serviceWindowGenerationFromCC.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "include/serviceWindowGenerationFromCC.h" - -using namespace std; - -ServiceWindowGenerationFromCC::ServiceWindowGenerationFromCC( - char* path, int position, int size, int transparency, int _serviceType) { - setPathInput(path); - numero_legendas = 0; - setPosition(position); - setSize(size); - setTransparency(transparency); - setServiceType(_serviceType); - //this->fisish = false; - //initialize(); -} - -ServiceWindowGenerationFromCC::~ServiceWindowGenerationFromCC() { - -} - -void ServiceWindowGenerationFromCC::setPathInput(char* path) { - this->path_input = path; -} - -void ServiceWindowGenerationFromCC::notificaCC(unsigned char* cc, int64_t pts) { - cout << "1-Chegou LEGENDA no ServiceFromCC\n" << endl; - printf("Glosa: %s PTS: %lld\n", cc, pts); - - if (!strcmp((const char*) cc, "Homem supermercado falar nao vender.")) { - printf("\nIGUAL\n"); - return; - } else { - //printf("\nDIFERENTE\n"); - } - - numero_legendas++; - char op = this->getRunningOption(); - - if (op == '3') { - notificaSincronizadorSemTradutor(cc, pts); - } else { - adicionaPTS(pts); - notificaTradutor(cc); - } - -} - -void ServiceWindowGenerationFromCC::notificaSincronizadorSemTradutor(unsigned char * cc, int64_t pts) { - char* pch = strtok((char*) cc, " "); - while (pch != NULL) { - string pch_string = (string) pch; - sincronizador->recebeglosa(pch_string, pts); - printf("%s\n", pch); - pch = strtok(NULL, " "); - } -} - -void ServiceWindowGenerationFromCC::notificaTradutor(unsigned char* cc) { - - const char* constchar = (const char*) cc; - char* cc_copy = new char[strlen(constchar)]; - strcpy(cc_copy, constchar); - tradutor->traduz((unsigned char*) cc_copy); - -} - -void ServiceWindowGenerationFromCC::initialize() { - - inputfile = new InputFile(this->path_input); - extratorCC = new ExtratorCC(); - monitor_pcr_base = new MonitorPCR(); - demux = new Demux(278, (DemuxListener*) extratorCC); - inputfile->registraOuvinte(demux); - extratorCC->registraOuvinte(this); - - inputfile->registraOuvinte(monitor_pcr_base); - - ServiceWindowGeneration::initialize(); - - inputfile->initialize(); - this->Start(); -} - -void ServiceWindowGenerationFromCC::Run() { - - while (true) { - - if (inputfile->isFinished()) { - - this->finish = true; - - if (getRunningOption() == '3') { - //printf("\n\n\nEncerrei\n\n\n"); - sincronizador->stop(); - - } - - } - sleep(5); - } - -} -- libgit2 0.21.2