-#define MAX_PIDS 64
- int pids[MAX_PIDS];
- int pididx=-1;
- int r = ::read( fd, buf, 256*1024 );
- if ( r <= 0 )
- break;
- rd+=r;
- int cnt=0;
- while(cnt < r)
- {
- while ( (buf[cnt] != 0x47) && ((cnt+188) < r) && (buf[cnt+188] != 0x47) )
- {
-// eDebug("search sync byte %02x %02x, %d %d", buf[cnt], buf[cnt+188], cnt+188, r);
- cnt++;
- }
- if ( buf[cnt] == 0x47 )
- {
- int pid = ((buf[cnt+1]&0x3F) << 8) | buf[cnt+2];
- int idx=0;
- while(idx <= pididx) // check if we already have this pid
- {
- if ( pids[idx] == pid )
- break;
- ++idx;
- }
- if (idx > pididx && (pididx+1) < MAX_PIDS)
- {
- eDebug("found pid %04x", pid);
- pids[++pididx]=pid;
- }
- cnt+=188;
- }
- else
- break;
- }
- while(pididx > -1 && pmtpid == -1)