libdvbpsi是VLC中用于解复用的一个库,可以在VLC的主页中下载,笔者用的是0.1.7版本。
static int ReadPacket(int i_fd, uint8_t* p_dst)
{
int i = 187;
int i_rc = 1;
p_dst[0] = 0;
while((p_dst[0] != 0x47) && (i_rc > 0))
{
i_rc = read(i_fd, p_dst, 1);
}
while((i != 0) && (i_rc > 0))
{
i_rc = read(i_fd, p_dst + 188 - i, i);
if(i_rc >= 0)
i -= i_rc;
}
return (i == 0) ? 1 : 0;
}
这里假定是188字节的TS文件(还有另外两种)。第一个while......
阅读全文