filter.cpp
3.23 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* Filter.cpp
*
* Created on: 08/10/2008
* Author: lacet
*/
#include "filter.h"
#include "packet.h"
#include "section_hal.h"
#include <stdio.h>
#include <string.h>
#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;
}