Revision 2cecea08 src/demuxer.cpp
src/demuxer.cpp | ||
---|---|---|
41 | 41 |
|
42 | 42 |
static void set_ts_filt(int fd,uint16_t pid, dmx_pes_type_t pestype); |
43 | 43 |
|
44 |
Demuxer::Demuxer(Tuner *tuner, int pid, Demuxer::PESType pestype) |
|
44 |
Demuxer::Demuxer(Tuner *tuner, int pid, bool convertToPS, Demuxer::PESType pestype)
|
|
45 | 45 |
: tuner(tuner), pid(pid), demuxFD(-1) |
46 | 46 |
{ |
47 | 47 |
init_ipack(&packer, IPACKS, output, 1); |
... | ... | |
138 | 138 |
|
139 | 139 |
void Demuxer::receiveData(unsigned char *data, unsigned size) |
140 | 140 |
{ |
141 |
// adapted from my_ts_to_ps( uint8_t* buf, uint16_t pida, uint16_t pidv) |
|
142 |
// in dvbstream.c (Dave Chapman) |
|
143 |
|
|
144 |
uint16_t pid; |
|
145 |
ipack *p = &this->packer; |
|
146 |
uint8_t off = 0; |
|
147 |
uint8_t *buf = (uint8_t *) data; |
|
148 |
|
|
149 |
pid = get_pid(buf+1); |
|
150 |
if (!(buf[3]&0x10)) // no payload? |
|
151 |
return; |
|
152 |
|
|
153 |
// Is this our packet? |
|
154 |
if (pid != this->pid) |
|
155 |
return; |
|
156 |
|
|
157 |
if ( buf[1]&0x40) { |
|
158 |
if (p->plength == MMAX_PLENGTH-6){ |
|
159 |
p->plength = p->found-6; |
|
160 |
p->found = 0; |
|
161 |
send_ipack(p); |
|
162 |
reset_ipack(p); |
|
141 |
if (convertToPS) { |
|
142 |
// adapted from my_ts_to_ps( uint8_t* buf, uint16_t pida, uint16_t pidv) |
|
143 |
// in dvbstream.c (Dave Chapman) |
|
144 |
|
|
145 |
uint16_t pid; |
|
146 |
ipack *p = &this->packer; |
|
147 |
uint8_t off = 0; |
|
148 |
uint8_t *buf = (uint8_t *) data; |
|
149 |
|
|
150 |
pid = get_pid(buf+1); |
|
151 |
if (!(buf[3]&0x10)) // no payload? |
|
152 |
return; |
|
153 |
|
|
154 |
// Is this our packet? |
|
155 |
if (pid != this->pid) |
|
156 |
return; |
|
157 |
|
|
158 |
if ( buf[1]&0x40) { |
|
159 |
if (p->plength == MMAX_PLENGTH-6){ |
|
160 |
p->plength = p->found-6; |
|
161 |
p->found = 0; |
|
162 |
send_ipack(p); |
|
163 |
reset_ipack(p); |
|
164 |
} |
|
163 | 165 |
} |
164 |
} |
|
165 | 166 |
|
166 |
if ( buf[3] & 0x20) { // adaptation field? |
|
167 |
off = buf[4] + 1; |
|
168 |
} |
|
167 |
if ( buf[3] & 0x20) { // adaptation field?
|
|
168 |
off = buf[4] + 1;
|
|
169 |
}
|
|
169 | 170 |
|
170 |
instant_repack(buf+4+off, TS_SIZE-4-off, p); |
|
171 |
instant_repack(buf+4+off, TS_SIZE-4-off, p); |
|
172 |
} |
|
173 |
else { |
|
174 |
if (get_pid(data + 1) == pid) |
|
175 |
sendData(data, (unsigned) size); |
|
176 |
} |
|
171 | 177 |
} |
172 | 178 |
|
173 | 179 |
static void set_ts_filt(int fd,uint16_t pid, dmx_pes_type_t pestype) |
Also available in: Unified diff