[vlc-devel] [PATCH] input: merge INPUT_EVENT_TELETEXT with INPUT_EVENT_ES
Thomas Guillem
thomas at gllm.fr
Fri Aug 17 15:43:40 CEST 2018
The INPUT_EVENT_TELETEXT event was unused (or useless for the QT case since the
same teletext code was called from INPUT_EVENT_ES).
Add a 'is_teletext' bool to the INPUT_EVENT_ES event and fix the legacy
"teletext-es" variable.
---
include/vlc_input.h | 13 +-------
modules/gui/macosx/VLCInputManager.m | 2 --
modules/gui/qt/input_manager.cpp | 9 +-----
src/input/es_out.c | 37 +++++++++++----------
src/input/event.c | 48 ++++++----------------------
src/input/event.h | 18 +++++------
src/input/var.c | 32 ++++++++++---------
7 files changed, 55 insertions(+), 104 deletions(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 020589a297..e809e258c3 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,
@@ -444,6 +442,7 @@ struct vlc_input_event
VLC_INPUT_ES_DELETED,
VLC_INPUT_ES_SELECTED,
} action;
+ bool is_teletext;
union
{
struct {
@@ -463,16 +462,6 @@ struct vlc_input_event
} selected;
};
} 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
@@ -269,10 +269,6 @@ void InputManager::customEvent( QEvent *event )
UpdateRate();
break;
case IMEvent::ItemEsChanged:
- UpdateTeletext();
- // We don't do anything ES related. Why ?
- break;
- case IMEvent::ItemTeletextChanged:
UpdateTeletext();
break;
case IMEvent::InterfaceVoutUpdate:
@@ -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 59e1735947..c36ba4e52c 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -932,10 +932,8 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, const es_format_t *fmt,
if( b_delete )
{
- if( EsFmtIsTeletext( fmt ) )
- input_SendEventTeletextDel( p_sys->p_input, fmt->i_id );
-
- input_SendEventEsDel( p_input, fmt->i_cat, fmt->i_id );
+ input_SendEventEsDel( p_input, EsFmtIsTeletext( fmt ), fmt->i_cat,
+ fmt->i_id );
return;
}
@@ -970,16 +968,18 @@ static void EsOutESVarUpdateGeneric( es_out_t *out, const es_format_t *fmt,
}
}
- input_SendEventEsAdd( p_input, text.psz_string, fmt );
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, fmt->i_id,
- fmt->subs.teletext.i_magazine >= 0 ? psz_page : NULL );
+ input_SendEventEsAdd( p_input, true,
+ fmt->subs.teletext.i_magazine >= 0 ? psz_page : "",
+ fmt );
}
+ else
+ input_SendEventEsAdd( p_input, false, text.psz_string, fmt );
free( text.psz_string );
}
@@ -1035,10 +1035,10 @@ 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_SendEventEsDel( p_input, false, AUDIO_ES, -1 );
+ input_SendEventEsDel( p_input, false, VIDEO_ES, -1 );
+ input_SendEventEsDel( p_input, false, SPU_ES, -1 );
+ input_SendEventEsDel( p_input, true, SPU_ES, -1 );
input_SendEventProgramScrambled( p_input, p_pgrm->i_id, p_pgrm->b_scrambled );
foreach_es_then_es_slaves(es)
@@ -1788,8 +1788,8 @@ 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->fmt.i_id );
- input_SendEventTeletextSelect( p_input, EsFmtIsTeletext( &es->fmt ) ? es->fmt.i_id : -1 );
+ input_SendEventEsSelect( p_input, EsFmtIsTeletext( &es->fmt ),
+ es->fmt.i_cat, es->fmt.i_id );
}
static void EsDeleteCCChannels( es_out_t *out, es_out_id_t *parent )
@@ -1812,7 +1812,7 @@ static void EsDeleteCCChannels( es_out_t *out, es_out_id_t *parent )
if( i_spu_id == parent->cc.pp_es[i]->fmt.i_id )
{
/* Force unselection of the CC */
- input_SendEventEsSelect( p_input, SPU_ES, -1 );
+ input_SendEventEsSelect( p_input, false, SPU_ES, -1 );
}
EsOutDelLocked( out, parent->cc.pp_es[i] );
}
@@ -1852,9 +1852,8 @@ 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_SendEventEsSelect( p_input, EsFmtIsTeletext( &es->fmt ),
+ es->fmt.i_cat, -1 );
}
/**
@@ -2222,7 +2221,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,
+ input_SendEventEsSelect(p_sys->p_input, false, es->fmt.i_cat,
es->fmt.i_id);
if( p_esprops->p_main_es == NULL )
p_esprops->p_main_es = other;
@@ -3172,7 +3171,7 @@ static void EsOutUpdateInfo( es_out_t *out, es_out_id_t *es, const es_format_t *
update.i_extra = 0;
update.p_extra = NULL;
- input_SendEventEsUpdate(p_input, &update);
+ input_SendEventEsUpdate(p_input, EsFmtIsTeletext( &update ), &update);
input_item_UpdateTracksInfo(input_GetItem(p_input), &update);
}
diff --git a/src/input/event.c b/src/input/event.c
index e1fed167c8..9b681a27b2 100644
--- a/src/input/event.c
+++ b/src/input/event.c
@@ -218,8 +218,8 @@ void input_SendEventProgramScrambled( input_thread_t *p_input, int i_group, bool
});
}
-void input_SendEventEsAdd( input_thread_t *p_input, const char *psz_title,
- const es_format_t *p_fmt )
+void input_SendEventEsAdd( input_thread_t *p_input, bool is_teletext,
+ const char *psz_title, const es_format_t *p_fmt )
{
input_thread_private_t *priv = input_priv(p_input);
priv->i_last_es_cat = p_fmt->i_cat;
@@ -229,6 +229,7 @@ void input_SendEventEsAdd( input_thread_t *p_input, const char *psz_title,
.type = INPUT_EVENT_ES,
.es = {
.action = VLC_INPUT_ES_ADDED,
+ .is_teletext = is_teletext,
.added = {
.title = psz_title,
.fmt = p_fmt,
@@ -236,25 +237,28 @@ void input_SendEventEsAdd( input_thread_t *p_input, const char *psz_title,
}
});
}
-void input_SendEventEsUpdate( input_thread_t *p_input, const es_format_t *p_fmt )
+void input_SendEventEsUpdate( input_thread_t *p_input, bool is_teletext,
+ const es_format_t *p_fmt )
{
input_SendEvent( p_input, &(struct vlc_input_event) {
.type = INPUT_EVENT_ES,
.es = {
.action = VLC_INPUT_ES_UPDATED,
+ .is_teletext = is_teletext,
.updated = {
.fmt = p_fmt,
}
}
});
}
-void input_SendEventEsDel( input_thread_t *p_input,
+void input_SendEventEsDel( input_thread_t *p_input, bool is_teletext,
enum es_format_category_e i_cat, int i_id )
{
input_SendEvent( p_input, &(struct vlc_input_event) {
.type = INPUT_EVENT_ES,
.es = {
.action = VLC_INPUT_ES_DELETED,
+ .is_teletext = is_teletext,
.deleted = {
.cat = i_cat,
.id = i_id,
@@ -262,13 +266,14 @@ void input_SendEventEsDel( input_thread_t *p_input,
}
});
}
-void input_SendEventEsSelect( input_thread_t *p_input,
+void input_SendEventEsSelect( input_thread_t *p_input, bool is_teletext,
enum es_format_category_e i_cat, int i_id )
{
input_SendEvent( p_input, &(struct vlc_input_event) {
.type = INPUT_EVENT_ES,
.es = {
.action = VLC_INPUT_ES_SELECTED,
+ .is_teletext = is_teletext,
.selected = {
.cat = i_cat,
.id = i_id,
@@ -277,39 +282,6 @@ void input_SendEventEsSelect( input_thread_t *p_input,
});
}
-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 )
-{
- 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,
- }
- });
-}
-
void input_SendEventVout( input_thread_t *p_input )
{
input_SendEvent( p_input, &(struct vlc_input_event) {
diff --git a/src/input/event.h b/src/input/event.h
index 0252b7f90e..6d1ade2783 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -58,16 +58,14 @@ 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, const char *psz_title,
- const es_format_t *fmt );
-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_SendEventEsUpdate( input_thread_t *p_input, const es_format_t *fmt );
-
-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, bool is_teletext,
+ enum es_format_category_e i_cat, int i_id );
+void input_SendEventEsAdd( input_thread_t *p_input, bool is_teletext,
+ const char *psz_title, const es_format_t *fmt );
+void input_SendEventEsSelect( input_thread_t *p_input, bool is_teletext,
+ enum es_format_category_e i_cat, int i_id ); /* i_id == -1 will unselect */
+void input_SendEventEsUpdate( input_thread_t *p_input, bool is_teletext,
+ const es_format_t *fmt );
/*****************************************************************************
* Event for decoder.c
diff --git a/src/input/var.c b/src/input/var.c
index 4cbc9a3ec6..827321c26b 100644
--- a/src/input/var.c
+++ b/src/input/var.c
@@ -324,6 +324,12 @@ void input_LegacyEvents( input_thread_t *p_input, void *user_data,
{
case VLC_INPUT_ES_ADDED:
{
+ if (event->es.is_teletext)
+ {
+ VarListAdd( p_input, "teletext-es", event->es.added.fmt->i_id,
+ event->es.added.title );
+ break;
+ }
const char *varname = GetEsVarName( event->es.added.fmt->i_cat );
if( varname )
{
@@ -341,6 +347,11 @@ void input_LegacyEvents( input_thread_t *p_input, void *user_data,
}
case VLC_INPUT_ES_DELETED:
{
+ if (event->es.is_teletext)
+ {
+ VarListDel( p_input, "teletext-es", event->es.deleted.id );
+ break;
+ }
const char *varname = GetEsVarName( event->es.deleted.cat );
if( varname )
VarListDel( p_input, varname, event->es.deleted.id );
@@ -348,26 +359,17 @@ void input_LegacyEvents( input_thread_t *p_input, void *user_data,
}
case VLC_INPUT_ES_SELECTED:
{
+ if (event->es.is_teletext)
+ {
+ VarListSelect( p_input, "teletext-es", event->es.selected.id );
+ break;
+ }
const char *varname = GetEsVarName( event->es.selected.cat );
if( varname )
VarListSelect( p_input, varname, event->es.selected.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;
+ case VLC_INPUT_ES_UPDATED: break;
}
break;
case INPUT_EVENT_RECORD:
--
2.18.0
More information about the vlc-devel
mailing list