[vlc-devel] [RFC PATCH 05/13] clock: add 'clock-master' option to choose the master clock
Thomas Guillem
thomas at gllm.fr
Wed Jun 27 14:41:27 CEST 2018
---
src/clock/clock.h | 8 ++++++++
src/input/es_out.c | 22 +++++++++++++++++++++-
src/libvlc-module.c | 18 ++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/src/clock/clock.h b/src/clock/clock.h
index f5a4df54d0..bfc1fd78de 100644
--- a/src/clock/clock.h
+++ b/src/clock/clock.h
@@ -20,6 +20,14 @@
#ifndef LIBVLC_CLOCK_H
#define LIBVLC_CLOCK_H
+enum vlc_clock_master_source
+{
+ VLC_CLOCK_MASTER_AUDIO = 0,
+ VLC_CLOCK_MASTER_VIDEO,
+ VLC_CLOCK_MASTER_MONOTONIC,
+ VLC_CLOCK_MASTER_DEFAULT = VLC_CLOCK_MASTER_AUDIO,
+};
+
typedef struct vlc_clock_main_t vlc_clock_main_t;
typedef struct vlc_clock_t vlc_clock_t;
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 91c4911607..fb3bd8fc56 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -140,6 +140,8 @@ typedef struct
struct vlc_list programs;
es_out_pgrm_t *p_pgrm; /* Master program */
+ enum es_format_category_e i_master_source_cat;
+
/* all es */
int i_id;
struct vlc_list es;
@@ -318,6 +320,22 @@ es_out_t *input_EsOutNew( input_thread_t *p_input, int i_rate )
p_sys->i_group_id = var_GetInteger( p_input, "program" );
+ enum vlc_clock_master_source master_source =
+ var_InheritInteger( p_input, "clock-master" );
+ switch( master_source )
+ {
+ case VLC_CLOCK_MASTER_AUDIO:
+ p_sys->i_master_source_cat = AUDIO_ES;
+ break;
+ case VLC_CLOCK_MASTER_VIDEO:
+ p_sys->i_master_source_cat = VIDEO_ES;
+ break;
+ case VLC_CLOCK_MASTER_MONOTONIC:
+ default:
+ p_sys->i_master_source_cat = UNKNOWN_ES;
+ break;
+ }
+
p_sys->i_pause_date = -1;
p_sys->i_rate = i_rate;
@@ -1685,7 +1703,9 @@ static void EsCreateDecoder( es_out_t *out, es_out_id_t *p_es )
input_thread_t *p_input = p_sys->p_input;
decoder_t *dec;
- if( p_es->fmt.i_cat == AUDIO_ES && p_es->p_pgrm->p_master_clock == NULL )
+ if( p_es->fmt.i_cat != UNKNOWN_ES
+ && p_es->fmt.i_cat == p_sys->i_master_source_cat
+ && p_es->p_pgrm->p_master_clock == NULL )
p_es->p_pgrm->p_master_clock = p_es->p_clock =
vlc_clock_NewMaster( p_es->p_pgrm->p_main_clock );
else
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 285fa22341..58f2620fbd 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -46,6 +46,8 @@
#include <vlc_aout.h>
#include <vlc_vout.h>
+#include "clock/clock.h"
+
static const char *const ppsz_snap_formats[] =
{ "png", "jpg", "tiff" };
@@ -532,6 +534,19 @@ static const char *const ppsz_pos_descriptions[] =
"This defines the maximum input delay jitter that the synchronization " \
"algorithms should try to compensate (in milliseconds)." )
+#define CLOCK_MASTER_TEXT N_("Clock master source")
+
+static const int pi_clock_master_values[] = {
+ VLC_CLOCK_MASTER_AUDIO,
+ VLC_CLOCK_MASTER_VIDEO,
+ VLC_CLOCK_MASTER_MONOTONIC,
+};
+static const char *const ppsz_clock_master_descriptions[] = {
+ N_("Audio"),
+ N_("Video"),
+ N_("Monotonic")
+};
+
#define NETSYNC_TEXT N_("Network synchronisation" )
#define NETSYNC_LONGTEXT N_( "This allows you to remotely " \
"synchronise clocks for server and client. The detailed settings " \
@@ -1914,6 +1929,9 @@ vlc_module_begin ()
add_integer( "clock-jitter", 5 * CLOCK_FREQ/1000, CLOCK_JITTER_TEXT,
CLOCK_JITTER_LONGTEXT, true )
change_safe()
+ add_integer( "clock-master", VLC_CLOCK_MASTER_DEFAULT,
+ CLOCK_MASTER_TEXT, NULL, true )
+ change_integer_list( pi_clock_master_values, ppsz_clock_master_descriptions )
add_bool( "network-synchronisation", false, NETSYNC_TEXT,
NETSYNC_LONGTEXT, true )
--
2.18.0
More information about the vlc-devel
mailing list