Commit 4a7e7996 authored by Thomas Guillem's avatar Thomas Guillem
Browse files

DBG: Fake clock drift

Server:
./vlc media.ext -Idummy -vv --sout "#std{access=udp,mux=ts,dst=238.1.1.1:5000}"

Client:
./vlc "udp://@238.1.1.1:5000" -vv
parent ef615ff0
......@@ -121,6 +121,8 @@ struct sout_access_out_sys_t
block_t *p_buffer;
vlc_thread_t thread;
mtime_t i_last_date;
};
#define DEFAULT_PORT 1234
......@@ -212,6 +214,7 @@ static int Open( vlc_object_t *p_this )
p_sys->p_fifo = block_FifoNew();
p_sys->p_empty_blocks = block_FifoNew();
p_sys->p_buffer = NULL;
p_sys->i_last_date = VLC_TS_INVALID;
if( vlc_clone( &p_sys->thread, ThreadWrite, p_access,
VLC_THREAD_PRIORITY_HIGHEST ) )
......@@ -425,7 +428,19 @@ static void* ThreadWrite( void *data )
i_to_send--;
if( !i_to_send || (p_pk->i_flags & BLOCK_FLAG_CLOCK) )
{
mwait( i_date );
mtime_t now = mdate();
mtime_t delay = 0;
if (p_sys->i_last_date != VLC_TS_INVALID )
{
mtime_t i_gap = now - p_sys->i_last_date;
/* fake clock drift: 100ms every seconds */
delay = - (i_gap * 100000 / CLOCK_FREQ);
}
else
p_sys->i_last_date = now;
fprintf(stderr, "wait: %"PRId64 " (delay: %"PRId64")\n", i_date - now - delay, delay);
msleep( i_date - now - delay);
i_to_send = i_group;
}
if ( send( p_sys->i_handle, p_pk->p_buffer, p_pk->i_buffer, 0 ) == -1 )
......
......@@ -432,7 +432,10 @@ int input_clock_ConvertTS( vlc_object_t *p_object, input_clock_t *cl,
/* */
if( *pi_ts0 > VLC_TS_INVALID )
{
*pi_ts0 = ClockStreamToSystem( cl, *pi_ts0 + AvgGet( &cl->drift ) );
mtime_t drift = AvgGet( &cl->drift );
if (drift != 0)
fprintf(stderr, "drift: %ld\n", drift);
*pi_ts0 = ClockStreamToSystem( cl, *pi_ts0 + drift );
if( *pi_ts0 > cl->i_ts_max )
cl->i_ts_max = *pi_ts0;
*pi_ts0 += i_ts_delay;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment