[vlc-commits] input: merge INPUT_EVENT_TELETEXT with INPUT_EVENT_ES
Thomas Guillem
git at videolan.org
Mon Aug 20 13:44:30 CEST 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Aug 16 15:33:17 2018 +0200| [7d978bef084333baa12f6f4413129da3f5121daa] | committer: Thomas Guillem
input: merge INPUT_EVENT_TELETEXT with INPUT_EVENT_ES
The INPUT_EVENT_TELETEXT event was unused (or useless for the QT case since the
same teletext code was called from INPUT_EVENT_ES).
The legacy "teletext-es" event is still triggered from input_LegacyEvents()
when processing INPUT_EVENT_ES events.
And always pass the full fmt to ES events (to enable teletext detection).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7d978bef084333baa12f6f4413129da3f5121daa
---
include/vlc_input.h | 16 ++--------
modules/gui/macosx/VLCInputManager.m | 2 --
modules/gui/qt/input_manager.cpp | 9 +-----
src/input/es_out.c | 40 +++++++------------------
src/input/event.c | 57 ++++++++++--------------------------
src/input/event.h | 13 ++++----
src/input/var.c | 50 ++++++++++++++++++-------------
7 files changed, 63 insertions(+), 124 deletions(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 1e47b96772..8911370e2b 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -355,8 +355,6 @@ typedef enum input_event_type_e
INPUT_EVENT_PROGRAM,
/* A ES has been added or removed or selected */
INPUT_EVENT_ES,
- /* "teletext-es" has changed */
- INPUT_EVENT_TELETEXT,
/* "record" has changed */
INPUT_EVENT_RECORD,
@@ -442,21 +440,11 @@ struct vlc_input_event
VLC_INPUT_ES_ADDED,
VLC_INPUT_ES_DELETED,
VLC_INPUT_ES_SELECTED,
+ VLC_INPUT_ES_UNSELECTED,
} action;
- enum es_format_category_e cat;
- int id; /**< id == -1 will unselect */
const char *title;
+ const es_format_t *fmt;
} es;
- /* INPUT_EVENT_TELETEXT */
- struct {
- enum {
- VLC_INPUT_TELETEXT_ADDED,
- VLC_INPUT_TELETEXT_DELETED,
- VLC_INPUT_TELETEXT_SELECTED,
- } action;
- int id; /**< id == -1 will unselect */
- const char *title;
- } teletext;
/* INPUT_EVENT_RECORD */
bool record;
/* INPUT_EVENT_SIGNAL */
diff --git a/modules/gui/macosx/VLCInputManager.m b/modules/gui/macosx/VLCInputManager.m
index 0fce87b2be..c4d13b5bac 100644
--- a/modules/gui/macosx/VLCInputManager.m
+++ b/modules/gui/macosx/VLCInputManager.m
@@ -100,8 +100,6 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
break;
case INPUT_EVENT_ES:
break;
- case INPUT_EVENT_TELETEXT:
- break;
case INPUT_EVENT_AOUT:
break;
case INPUT_EVENT_VOUT:
diff --git a/modules/gui/qt/input_manager.cpp b/modules/gui/qt/input_manager.cpp
index e191b0dcfc..8f9c981866 100644
--- a/modules/gui/qt/input_manager.cpp
+++ b/modules/gui/qt/input_manager.cpp
@@ -270,10 +270,6 @@ void InputManager::customEvent( QEvent *event )
break;
case IMEvent::ItemEsChanged:
UpdateTeletext();
- // We don't do anything ES related. Why ?
- break;
- case IMEvent::ItemTeletextChanged:
- UpdateTeletext();
break;
case IMEvent::InterfaceVoutUpdate:
UpdateVout();
@@ -359,9 +355,6 @@ static int InputEvent( vlc_object_t *, const char *,
case INPUT_EVENT_ES:
event = new IMEvent( IMEvent::ItemEsChanged );
break;
- case INPUT_EVENT_TELETEXT:
- event = new IMEvent( IMEvent::ItemTeletextChanged );
- break;
case INPUT_EVENT_STATISTICS:
event = new IMEvent( IMEvent::StatisticsUpdate );
@@ -426,7 +419,7 @@ static int VbiEvent( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void *param )
{
InputManager *im = (InputManager*)param;
- IMEvent *event = new IMEvent( IMEvent::ItemTeletextChanged );
+ IMEvent *event = new IMEvent( IMEvent::ItemEsChanged );
QApplication::postEvent( im, event );
return VLC_SUCCESS;
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 056c60d1ec..d119b4a5fb 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -225,10 +225,6 @@ static inline int EsOutGetClosedCaptionsChannel( const es_format_t *p_fmt )
i_channel = -1;
return i_channel;
}
-static inline bool EsFmtIsTeletext( const es_format_t *p_fmt )
-{
- return p_fmt->i_cat == SPU_ES && p_fmt->i_codec == VLC_CODEC_TELETEXT;
-}
#define foreach_es_then_es_slaves( pos ) \
for( int fetes_i=0; fetes_i<2; fetes_i++ ) \
@@ -934,10 +930,7 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id,
if( b_delete )
{
- if( EsFmtIsTeletext( fmt ) )
- input_SendEventTeletextDel( p_sys->p_input, i_id );
-
- input_SendEventEsDel( p_input, fmt->i_cat, i_id );
+ input_SendEventEsDel( p_input, fmt );
return;
}
@@ -972,16 +965,7 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, int i_id,
}
}
- input_SendEventEsAdd( p_input, fmt->i_cat, i_id, text.psz_string );
- if( EsFmtIsTeletext( fmt ) )
- {
- char psz_page[3+1];
- snprintf( psz_page, sizeof(psz_page), "%d%2.2x",
- fmt->subs.teletext.i_magazine,
- fmt->subs.teletext.i_page );
- input_SendEventTeletextAdd( p_sys->p_input,
- i_id, fmt->subs.teletext.i_magazine >= 0 ? psz_page : NULL );
- }
+ input_SendEventEsAdd( p_input, fmt, text.psz_string );
free( text.psz_string );
}
@@ -1017,9 +1001,13 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
msg_Dbg( p_input, "unselecting program id=%d", old->i_id );
foreach_es_then_es_slaves(es)
+ {
if (es->p_pgrm == old && EsIsSelected(es)
&& p_sys->i_mode != ES_OUT_MODE_ALL)
EsUnselect(out, es, true);
+ if (es->p_pgrm == old)
+ input_SendEventEsDel( p_input, &es->fmt );
+ }
p_sys->audio.p_main_es = NULL;
p_sys->video.p_main_es = NULL;
@@ -1038,10 +1026,6 @@ static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )
input_SendEventProgramSelect( p_input, p_pgrm->i_id );
/* Update "es-*" */
- input_SendEventEsDel( p_input, AUDIO_ES, -1 );
- input_SendEventEsDel( p_input, VIDEO_ES, -1 );
- input_SendEventEsDel( p_input, SPU_ES, -1 );
- input_SendEventTeletextDel( p_input, -1 );
input_SendEventProgramScrambled( p_input, p_pgrm->i_id, p_pgrm->b_scrambled );
foreach_es_then_es_slaves(es)
@@ -1792,8 +1776,7 @@ static void EsSelect( es_out_t *out, es_out_id_t *es )
}
/* Mark it as selected */
- input_SendEventEsSelect( p_input, es->fmt.i_cat, es->i_id );
- input_SendEventTeletextSelect( p_input, EsFmtIsTeletext( &es->fmt ) ? es->i_id : -1 );
+ input_SendEventEsSelect( p_input, &es->fmt );
}
static void EsDeleteCCChannels( es_out_t *out, es_out_id_t *parent )
@@ -1816,7 +1799,7 @@ static void EsDeleteCCChannels( es_out_t *out, es_out_id_t *parent )
if( i_spu_id == parent->cc.pp_es[i]->i_id )
{
/* Force unselection of the CC */
- input_SendEventEsSelect( p_input, SPU_ES, -1 );
+ input_SendEventEsUnselect( p_input, &parent->cc.pp_es[i]->fmt );
}
EsOutDelLocked( out, parent->cc.pp_es[i] );
}
@@ -1856,9 +1839,7 @@ static void EsUnselect( es_out_t *out, es_out_id_t *es, bool b_update )
return;
/* Mark it as unselected */
- input_SendEventEsSelect( p_input, es->fmt.i_cat, -1 );
- if( EsFmtIsTeletext( &es->fmt ) )
- input_SendEventTeletextSelect( p_input, -1 );
+ input_SendEventEsUnselect( p_input, &es->fmt );
}
/**
@@ -2226,8 +2207,7 @@ static void EsOutDelLocked( es_out_t *out, es_out_id_t *es )
{
if (EsIsSelected(other))
{
- input_SendEventEsSelect(p_sys->p_input, es->fmt.i_cat,
- other->i_id);
+ input_SendEventEsSelect(p_sys->p_input, &es->fmt);
if( p_esprops->p_main_es == NULL )
p_esprops->p_main_es = other;
}
diff --git a/src/input/event.c b/src/input/event.c
index d4da9ce1ab..2fe8c306b7 100644
--- a/src/input/event.c
+++ b/src/input/event.c
@@ -218,78 +218,53 @@ void input_SendEventProgramScrambled( input_thread_t *p_input, int i_group, bool
});
}
-void input_SendEventEsAdd( input_thread_t *p_input,
- enum es_format_category_e i_cat, int i_id,
- const char *psz_text )
+void input_SendEventEsAdd( input_thread_t *p_input, const es_format_t *p_fmt,
+ const char *psz_title)
{
input_thread_private_t *priv = input_priv(p_input);
- priv->i_last_es_cat = i_cat;
- priv->i_last_es_id = i_id;
+ priv->i_last_es_cat = p_fmt->i_cat;
+ priv->i_last_es_id = p_fmt->i_id;
input_SendEvent( p_input, &(struct vlc_input_event) {
.type = INPUT_EVENT_ES,
.es = {
.action = VLC_INPUT_ES_ADDED,
- .cat = i_cat,
- .id = i_id,
- .title = psz_text
+ .title = psz_title,
+ .fmt = p_fmt,
}
});
}
void input_SendEventEsDel( input_thread_t *p_input,
- enum es_format_category_e i_cat, int i_id )
+ const es_format_t *p_fmt )
{
input_SendEvent( p_input, &(struct vlc_input_event) {
.type = INPUT_EVENT_ES,
.es = {
.action = VLC_INPUT_ES_DELETED,
- .cat = i_cat,
- .id = i_id,
+ .fmt = p_fmt,
}
});
}
void input_SendEventEsSelect( input_thread_t *p_input,
- enum es_format_category_e i_cat, int i_id )
+ const es_format_t *p_fmt )
{
input_SendEvent( p_input, &(struct vlc_input_event) {
.type = INPUT_EVENT_ES,
.es = {
.action = VLC_INPUT_ES_SELECTED,
- .cat = i_cat,
- .id = i_id,
+ .fmt = p_fmt,
}
});
}
-void input_SendEventTeletextAdd( input_thread_t *p_input,
- int i_teletext, const char *psz_text )
-{
- input_SendEvent( p_input, &(struct vlc_input_event) {
- .type = INPUT_EVENT_TELETEXT,
- .teletext = {
- .action = VLC_INPUT_TELETEXT_ADDED,
- .id = i_teletext,
- .title = psz_text
- }
- });
-}
-void input_SendEventTeletextDel( input_thread_t *p_input, int i_teletext )
+void input_SendEventEsUnselect( input_thread_t *p_input,
+ const es_format_t *p_fmt )
{
input_SendEvent( p_input, &(struct vlc_input_event) {
- .type = INPUT_EVENT_TELETEXT,
- .teletext = {
- .action = VLC_INPUT_TELETEXT_DELETED,
- .id = i_teletext,
- }
- });
-}
-void input_SendEventTeletextSelect( input_thread_t *p_input, int i_teletext )
-{
- input_SendEvent( p_input, &(struct vlc_input_event) {
- .type = INPUT_EVENT_TELETEXT,
- .teletext = {
- .action = VLC_INPUT_TELETEXT_SELECTED,
- .id = i_teletext,
+ .type = INPUT_EVENT_ES,
+ .es = {
+ .action = VLC_INPUT_ES_UNSELECTED,
+ .fmt = p_fmt,
}
});
}
diff --git a/src/input/event.h b/src/input/event.h
index 4c9792d228..f1c7f7794f 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -58,14 +58,11 @@ void input_SendEventProgramDel( input_thread_t *p_input, int i_program );
void input_SendEventProgramSelect( input_thread_t *p_input, int i_program );
void input_SendEventProgramScrambled( input_thread_t *p_input, int i_group, bool b_scrambled );
-void input_SendEventEsDel( input_thread_t *p_input, enum es_format_category_e i_cat, int i_id );
-void input_SendEventEsAdd( input_thread_t *p_input, enum es_format_category_e i_cat, int i_id, const char *psz_text );
-void input_SendEventEsSelect( input_thread_t *p_input, enum es_format_category_e i_cat, int i_id ); /* i_id == -1 will unselect */
-
-void input_SendEventTeletextAdd( input_thread_t *p_input,
- int i_teletext, const char *psz_text );
-void input_SendEventTeletextDel( input_thread_t *p_input, int i_teletext );
-void input_SendEventTeletextSelect( input_thread_t *p_input, int i_teletext );
+void input_SendEventEsDel( input_thread_t *p_input, const es_format_t *fmt );
+void input_SendEventEsAdd( input_thread_t *p_input,
+ const es_format_t *fmt, const char *psz_title );
+void input_SendEventEsSelect( input_thread_t *p_input, const es_format_t *fmt );
+void input_SendEventEsUnselect( input_thread_t *p_input, const es_format_t *fmt );
/*****************************************************************************
* Event for decoder.c
diff --git a/src/input/var.c b/src/input/var.c
index 02a5770e5d..d1ebec2bca 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -240,6 +240,11 @@ static void UpdateBookmarksOption( input_thread_t *p_input )
}
}
+static inline bool EsFmtIsTeletext( const es_format_t *p_fmt )
+{
+ return p_fmt->i_cat == SPU_ES && p_fmt->i_codec == VLC_CODEC_TELETEXT;
+}
+
void input_LegacyEvents( input_thread_t *p_input, void *user_data,
const struct vlc_input_event *event )
{
@@ -324,7 +329,7 @@ void input_LegacyEvents( input_thread_t *p_input, void *user_data,
{
case VLC_INPUT_ES_ADDED:
{
- const char *varname = GetEsVarName( event->es.cat );
+ const char *varname = GetEsVarName( event->es.fmt->i_cat );
if( varname )
{
size_t count;
@@ -334,42 +339,45 @@ void input_LegacyEvents( input_thread_t *p_input, void *user_data,
/* First one, we need to add the "Disable" choice */
VarListAdd( p_input, varname, -1, _("Disable") );
}
- VarListAdd( p_input, varname, event->es.id,
+ VarListAdd( p_input, varname, event->es.fmt->i_id,
event->es.title );
}
+
+ if( EsFmtIsTeletext( event->es.fmt ) )
+ {
+ char psz_page[3+1];
+ snprintf( psz_page, sizeof(psz_page), "%d%2.2x",
+ event->es.fmt->subs.teletext.i_magazine,
+ event->es.fmt->subs.teletext.i_page );
+ VarListAdd( p_input, "teletext-es", event->es.fmt->i_id,
+ event->es.fmt->subs.teletext.i_magazine >= 0 ? psz_page : "" );
+ }
break;
}
case VLC_INPUT_ES_DELETED:
{
- const char *varname = GetEsVarName( event->es.cat );
+ const char *varname = GetEsVarName( event->es.fmt->i_cat );
if( varname )
- VarListDel( p_input, varname, event->es.id );
+ VarListDel( p_input, varname, event->es.fmt->i_id );
+
+ if( EsFmtIsTeletext( event->es.fmt ) )
+ VarListDel( p_input, "teletext-es", event->es.fmt->i_id );
break;
}
case VLC_INPUT_ES_SELECTED:
+ case VLC_INPUT_ES_UNSELECTED:
{
- const char *varname = GetEsVarName( event->es.cat );
+ int i_id = event->es.action == VLC_INPUT_ES_SELECTED
+ ? event->es.fmt->i_id : -1;
+ const char *varname = GetEsVarName( event->es.fmt->i_cat );
if( varname )
- VarListSelect( p_input, varname, event->es.id );
+ VarListSelect( p_input, varname, i_id );
+ if( EsFmtIsTeletext( event->es.fmt ) )
+ VarListSelect( p_input, "teletext-es", i_id );
break;
}
}
break;
- case INPUT_EVENT_TELETEXT:
- switch (event->teletext.action)
- {
- case VLC_INPUT_TELETEXT_ADDED:
- VarListAdd( p_input, "teletext-es", event->teletext.id,
- event->teletext.title );
- break;
- case VLC_INPUT_TELETEXT_DELETED:
- VarListDel( p_input, "teletext-es", event->teletext.id );
- break;
- case VLC_INPUT_TELETEXT_SELECTED:
- VarListSelect( p_input, "teletext-es", event->teletext.id );
- break;
- }
- break;
case INPUT_EVENT_RECORD:
val.b_bool = event->record;
var_Change( p_input, "record", VLC_VAR_SETVALUE, val );
More information about the vlc-commits
mailing list