synchronizer.h
3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef SYNCHRONIZER_H
#define SYNCHRONIZER_H
#include "jthread.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <fstream>
#include "jmutex.h"
#include <signal.h>
#include "ouvinteSynchronizer.h"
#include "listenerMonitorPCRBase.h"
#include <vector>
#include <list>
using namespace jthread;
using namespace std;
class Synchronizer : public jthread::Thread, public ListenerMonitorPCRBase {
private:
bool hastext;
bool stopped;
int taxa;
int filefd;
vector <char*> *videos;
int devicetv;
uint64_t pcrBaseGeral;
uint64_t ultimoPCRBase;
uint64_t ultimoPCRBaseMod;
int mediaDiferencaPCR;
int contagemPCR;
ofstream escreveAux;
char* extensao;
char* baseDir;
int64_t pcr_inicial;
int64_t tempo_poseneutra;
vector <int64_t> *vector_pts;
int flagPrimeiroArquivo;
bool acabou;
list<OuvinteSynchronizer*> * ouvintes;
char* path_libras;
Mutex* mutex_sync;
int transparency;
/* Usado no teste de Eduardo! */
int count_tasks;
bool service_running;
public:
Synchronizer();
Synchronizer(/*int64_t pcr_inicial, */char*baseDir, char* extensao, char* path_libras, int transparency);
virtual ~Synchronizer();
virtual void notifyPCRBase(uint64_t pcr_base);
void setPCRBase(uint64_t pcr_base);
//em fase de teste
void soletraGlosa(string glosa, int64_t pts);
void Run();
void stop();
void recebeglosa(char * video, int tam, int64_t pts);
void recebeglosa(string glosa, int64_t pts);
char * getproximoarquivo();
bool isRunning();
void msleep(long tsleep, long *desconto);
int gettaxa();
int64_t getMilisegundos();
void settaxa(int taxa);
bool finished();
vector <char*> * getVideos();
void analisaPCR(unsigned char * pacote);
void analisaPTSDTS(unsigned char *pacote);
int getPid(unsigned char *pacote);
bool contemAF(unsigned char *pacote);
int getTamanhoAF(unsigned char *pacote);
bool contemPCR(unsigned char *pacote);
uint64_t retornaPCRBase(unsigned char *pacote);
void setPCRBase(unsigned char *pacote, uint64_t pcrbase);
bool contemPayloadStartIndicator(unsigned char *pacote);
bool contemPayloadData(unsigned char *pacote);
bool verificaPESStartCode(unsigned char *PESPacket);
bool verificaPESStreamID(unsigned char *PESPacket);
bool contemPTS(unsigned char *PESPacket);
bool contemDTS(unsigned char *PESPacket);
uint64_t retornaPTS(unsigned char *PESPacket);
uint64_t retornaDTS(unsigned char *PESPacket);
void setNovoPTS(unsigned char *pacote, uint64_t PTS);
void setNovoDTS(unsigned char *pacote, uint64_t DTS);
void escrevePacote(char *pacote);
int escrevePacote(int * descritor, char *pacote, int size);
void encerrouLegendas();
virtual void registraOuvinte(OuvinteSynchronizer * ouvinte);
virtual void removeOuvinte(OuvinteSynchronizer * ouvinte);
virtual void notificaOuvintes();
void hasText(bool);
};
#endif /* SYNCHRONIZER_H */