ES_OUT_SET_GROUP_PCR, /* arg1= int i_group, arg2=int64_t i_pcr(microsecond!)*/
ES_OUT_RESET_PCR, /* no arg */
+ /* Timestamp handling, convert an input timestamp to a global clock one.
+ * (shouldn't have to be used by input plugins directly) */
+ ES_OUT_GET_TS, /* arg1=int64_t i_ts(microsecond!) (using default group 0), arg2=int64_t* converted i_ts */
+
/* Try not to use this one as it is a bit hacky */
ES_OUT_SET_FMT /* arg1= es_out_id_t* arg2=es_format_t* */
};
#include <stdlib.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
+#include <vlc/input.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#define MAX_MSG_LENGTH (2 * sizeof(int64_t))
vlc_bool_t b_master = config_GetInt( p_intf, "netsync-master" );
- char *psz_master;
+ char *psz_master = NULL;
char p_data[MAX_MSG_LENGTH];
int i_socket;
}
i_socket = net_OpenUDP( p_intf, NULL,
- b_master ? NETSYNC_PORT_MASTER : NETSYNC_PORT_SLAVE,
- b_master ? NULL : psz_master,
- b_master ? 0 : NETSYNC_PORT_MASTER );
+ b_master ? NETSYNC_PORT_MASTER : NETSYNC_PORT_SLAVE,
+ b_master ? NULL : psz_master,
+ b_master ? 0 : NETSYNC_PORT_MASTER );
+
+ if( psz_master ) free( psz_master );
- if( !b_master )
- free( psz_master );
-
if( i_socket < 0 )
{
msg_Err( p_intf, "failed opening UDP socket." );
while( !p_intf->b_die )
{
- struct timeval timeout;
+ struct timeval timeout;
fd_set fds_r;
/* Update the input */
static mtime_t GetClockRef( intf_thread_t *p_intf, mtime_t i_pts )
{
input_thread_t *p_input = p_intf->p_sys->p_input;
- pgrm_descriptor_t *p_pgrm;
+ mtime_t i_ts;
- if( !p_input ) return 0;
+ if( !p_input || !p_input->p_es_out ) return 0;
-#if 0
- p_pgrm = p_input->stream.p_selected_program;
- if( p_pgrm ) return input_ClockGetTS( p_input, p_pgrm, i_pts );
-#else
-#warning "This code is currently broken. FIXME!!!"
-#endif
+ if( es_out_Control( p_input->p_es_out, ES_OUT_GET_TS, i_pts, &i_ts ) ==
+ VLC_SUCCESS )
+ {
+ return i_ts;
+ }
return 0;
}
p_block->i_rate = p_input->i_rate;
/* TODO handle mute */
- if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES || p_input->i_rate == INPUT_RATE_DEFAULT ) )
+ if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES ||
+ p_input->i_rate == INPUT_RATE_DEFAULT ) )
{
input_DecoderDecode( es->p_dec, p_block );
}
}
return VLC_SUCCESS;
+ case ES_OUT_GET_TS:
+ if( p_sys->p_pgrm )
+ {
+ int64_t i_ts = (int64_t)va_arg( args, int64_t );
+ int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * );
+ *pi_ts = input_ClockGetTS( p_sys->p_input,
+ &p_sys->p_pgrm->clock,
+ ( i_ts + 11 ) * 9 / 100 );
+ return VLC_SUCCESS;
+ }
+ return VLC_EGENERIC;
+
case ES_OUT_GET_GROUP:
pi = (int*) va_arg( args, int* );
if( p_sys->p_pgrm )