[vlc-devel] Re: Doing an lseek() with VOB files ...

Jean-Paul Saman jpsaman at wxs.nl
Wed Aug 13 20:59:33 CEST 2003

John Michael Zorko wrote:
> Jean-Paul,
> Firstly, I do appreciate your input and assistance, very much.
>> Does the server set the TS discontinuity bit when doing ff/rewind on 
>> the first packet (PCR packet AFAIK) it can? Because the server needs 
>> to tell the client that a timing gap occured.

> Are you referring to vlc_root/modules/demux/mpeg/system.c, the DemuxTS() 

I do not know that part of the code well, so I can't point you to the 
exact source file and source line. I can help with pointing out things 
you need to do to get it working properly on TS header level.

> function?  OK, this is what i've done to try to narrow the problem down:
What you do here is setting/overriding the continuity counter. You can 
safely leave that alone on the server/client as long as the 
discontinuity bit is set at the server side (for every PID in the stream).

At the server side you should look in the muxer for setting the 
discontinuity bit in the TS header, I think. Where (code part) do you 
start seeking at the server side ??

>             else
>             {
>                 /* This can indicate that we missed a packet or that the
>                  * continuity_counter wrapped and we received a dup packet:

If the continuity_counter wraps (at 16) then there is no duplicate 
packet! The continuity counter always wraps at 16 !!

>                  * as we don't know, do as if we missed a packet to be sure
>                  * to recover from this situation */

Why ? This is a legal situation for TS packets

>                 msg_Warn( p_input,
>                           "packet lost by TS demux for PID %d: current 
> %d, packet %d",
>                           i_pid,
>                           p_es_demux->i_continuity_counter & 0x0f,
>                           p[3] & 0x0f );
>                 b_lost = 1;
>                 p_es_demux->i_continuity_counter = p[3] & 0x0f;
> FILE *pFile = fopen( "//Users//jmzorko//vlc_debug.txt", "a+" );
> fprintf( pFile, "* " );
> fclose( pFile );
>             } /* not continuous */
> ... I put the fopen / fprintf in system.c, and then ran the test (server 
> VLC, client VLC, telling server VLC to seek and seeing what shakes with 
> the client VLC).  The results are interesting -- the "*" only appeared 
> in the vlc_debug.txt file 7 times, though I told the server VLC to seek 
> dozens of times.  Does this indicate that the discontinuity bit isn't 
> always being set by the server VLC?
You did not even set the bit ;-) You've got it mixed up with the 
continuity counter which is another bit in the TS header.

>> From file you read a MPEG2-PS (I guess) and from the server you read 
>> an SP-TS. This SP-TS goes into the ts_dvbpsi (or ts) demuxer and then 
>> to the ps demuxer. While the file goes directly into the ps demuxer.

You've got two scenarios to get right:

1) ff/rewind when playing from file/disk. This needs code in the 
demuxers/access plugins

2) ff/rewind at the server side. This needs support at the 
muxer/stream_out module, because you need to set the right bits at 

How far are you at scenario 1 ?

And how far are you at scenario 2?

Jean-Paul Saman.

This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>

More information about the vlc-devel mailing list