version 1.1, 2003/02/21 14:50:51
|
version 1.2, 2003/08/15 22:54:37
|
Line 1
|
Line 1
|
|
/* |
|
* tiny debugging tool. |
|
* when fed with a transport stream to stdin, produces one char |
|
* per packet to stdout, and a few informative messages to stderr. |
|
* Upper case letters denote a continuity counter mismatch. |
|
* |
|
* Author: Jacob Schroeder (jacob@convergence.de) |
|
*/ |
|
|
#include <stdlib.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <unistd.h> |
#include <unistd.h> |
Line 8 int main (int argc, char **argv)
|
Line 17 int main (int argc, char **argv)
|
{ |
{ |
|
|
int pids[MAXPID+1]; |
int pids[MAXPID+1]; |
|
int ccs[MAXPID+1]; |
int pid_count = 0; |
int pid_count = 0; |
int i; |
int i; |
int count = 0; |
int count = 0; |
|
|
for (i = 0; i <= MAXPID; i++) |
for (i = 0; i <= MAXPID; i++) |
pids[i] = -1; |
{ |
|
pids[i] = -1; |
|
ccs[i] = -1; |
|
} |
|
|
while (1) |
while (1) |
{ |
{ |
Line 53 int main (int argc, char **argv)
|
Line 66 int main (int argc, char **argv)
|
int sync; |
int sync; |
int pid; |
int pid; |
int cc; |
int cc; |
|
int ccok; |
|
|
char outbuf[1]; |
char outbuf[1]; |
|
|
Line 68 int main (int argc, char **argv)
|
Line 82 int main (int argc, char **argv)
|
{ |
{ |
// TODO, skip to next package |
// TODO, skip to next package |
write (1, "#", 1); |
write (1, "#", 1); |
goto char_written; |
|
} |
} |
|
else |
pidtype = pids[pid]; |
|
|
|
if (pidtype == -1) |
|
{ |
{ |
if (pid == 0) |
pidtype = pids[pid]; |
|
|
|
if (pidtype == -1) |
{ |
{ |
fprintf (stderr, "# = pid 0x0000 (PAT)\n"); |
if (pid == 0) |
pidtype = pids[pid] = 0; |
{ |
|
fprintf (stderr, "# = pid 0x0000 (PAT)\n"); |
|
pidtype = pids[pid] = 0; |
|
} |
|
else if (pid == 0x1fff) |
|
{ |
|
fprintf (stderr, "\" ' pid 0x1fff (invalid)\n"); |
|
pidtype = pids[pid] = 0; |
|
} |
|
else |
|
{ |
|
if (pid_count < 26) |
|
pid_count++; |
|
|
|
pidtype = pids[pid] = pid_count; |
|
fprintf (stderr, "%c %c pid 0x%04x\n", |
|
0x40 + pidtype, 0x60 + pidtype, pid); |
|
} |
|
ccok = 1; |
} |
} |
else if (pid == 0x1fff) |
else |
{ |
{ |
fprintf (stderr, "\" ' pid 0x1fff (invalid)\n"); |
ccok = ccs[pid] == cc ? 1 : 0; |
pidtype = pids[pid] = 0; |
|
} |
} |
|
|
|
if (pid == 0) |
|
outbuf[0] = ccok ? '=' : '#'; |
|
else if (pid == 0x1fff) |
|
outbuf[0] = ccok ? '\'' : '"'; |
else |
else |
{ |
outbuf[0] = 0x40 + pidtype + (ccok ? 0x20 : 0); |
if (pid_count < 26) |
|
pid_count++; |
|
|
|
pidtype = pids[pid] = pid_count; |
ccs[pid] = (cc + 1) & 0x0F; |
fprintf (stderr, "%c %c pid 0x%04x\n", |
|
0x40 + pidtype, 0x60 + pidtype, pid); |
write (1, outbuf, 1); |
} |
|
} |
} |
|
|
if (pid == 0) |
|
outbuf[0] = cc ? '=' : '#'; |
|
else if (pid == 0x1fff) |
|
outbuf[0] = cc ? '\'' : '"'; |
|
else |
|
outbuf[0] = 0x40 + pidtype + (cc ? 0x20 : 0); |
|
|
|
write (1, outbuf, 1); |
|
|
|
char_written: |
|
count++; |
count++; |
if ((count % 64) == 0) |
if ((count % 64) == 0) |
write (1, "\n", 1); |
write (1, "\n", 1); |