[vlc-devel] [PATCH 2/2] player: fix teletext handling
Thomas Guillem
thomas at gllm.fr
Fri Feb 7 16:46:40 CET 2020
On Fri, Feb 7, 2020, at 15:08, Francois Cartegnie wrote:
> ---
> src/player/input.c | 61 ++++++++++++++++++++++++++++-----------------
> src/player/player.h | 2 +-
> 2 files changed, 39 insertions(+), 24 deletions(-)
>
> diff --git a/src/player/input.c b/src/player/input.c
> index 37a235664b..45ecb1c405 100644
> --- a/src/player/input.c
> +++ b/src/player/input.c
> @@ -355,44 +355,61 @@ vlc_player_input_HandleProgramEvent(struct
> vlc_player_input *input,
>
> static void
> vlc_player_input_HandleTeletextMenu(struct vlc_player_input *input,
> - const struct vlc_input_event_es
> *ev)
> + const struct vlc_input_event_es
> *ev,
> + const struct vlc_player_track_priv
> *trackpriv)
> {
> vlc_player_t *player = input->player;
> + const struct vlc_player_track_priv *t;
> + if(ev->fmt->i_codec != VLC_CODEC_TELETEXT)
> + return;
> switch (ev->action)
> {
> case VLC_INPUT_ES_ADDED:
> - if (input->teletext_menu)
> + if(!input->teletext_menu || trackpriv->t.selected)
> + input->teletext_menu = trackpriv;
> + vlc_vector_foreach(t, &input->spu_track_vector)
> {
> - msg_Warn(player, "Can't handle more than one teletext
> menu "
> - "track. Using the last one.");
> - vlc_player_track_priv_Delete(input->teletext_menu);
> + /* Did we have index teletext page before in spu list
> */
> + if(t->t.fmt.i_codec == VLC_CODEC_TELETEXT &&
You are already checking .i_codec == VLC_CODEC_TELETEXT at the start of the function
> + t->t.fmt.subs.teletext.i_type != 0x02 &&
> + t->t.fmt.subs.teletext.i_type != 0x05 &&
> + t != trackpriv)
> + return;
> }
> - input->teletext_menu = vlc_player_track_priv_New(ev->id,
> ev->title,
> - ev->fmt);
> - if (!input->teletext_menu)
> - return;
> -
> vlc_player_SendEvent(player, on_teletext_menu_changed,
> true);
> break;
> case VLC_INPUT_ES_DELETED:
> {
> - if (input->teletext_menu && input->teletext_menu->t.es_id
> == ev->id)
> + if (input->teletext_menu == trackpriv)
> {
> assert(!input->teletext_enabled);
> -
> - vlc_player_track_priv_Delete(input->teletext_menu);
> input->teletext_menu = NULL;
> - vlc_player_SendEvent(player, on_teletext_menu_changed,
> false);
> }
> + vlc_vector_foreach(t, &input->spu_track_vector)
> + {
> + /* Do we still have index teletext page in spu list */
> + if(t->t.fmt.i_codec == VLC_CODEC_TELETEXT &&
> + t->t.fmt.subs.teletext.i_type != 0x02 &&
> + t->t.fmt.subs.teletext.i_type != 0x05 &&
> + t != trackpriv)
> + {
> + input->teletext_menu = t;
> + return;
> + }
> + }
> + vlc_player_SendEvent(player, on_teletext_menu_changed,
> false);
> break;
> }
> case VLC_INPUT_ES_UPDATED:
> break;
> case VLC_INPUT_ES_SELECTED:
> case VLC_INPUT_ES_UNSELECTED:
> - if (input->teletext_menu->t.es_id == ev->id)
> + if(trackpriv->t.fmt.subs.teletext.i_type != 0x02 &&
> + trackpriv->t.fmt.subs.teletext.i_type != 0x05)
> {
> input->teletext_enabled = ev->action ==
> VLC_INPUT_ES_SELECTED;
> + if(input->teletext_enabled)
> + input->teletext_menu = trackpriv;
> vlc_player_SendEvent(player,
> on_teletext_enabled_changed,
> input->teletext_enabled);
> }
> @@ -408,14 +425,6 @@ vlc_player_input_HandleEsEvent(struct
> vlc_player_input *input,
> {
> assert(ev->id && ev->title && ev->fmt);
>
> - if (ev->fmt->i_cat == SPU_ES && ev->fmt->i_codec ==
> VLC_CODEC_TELETEXT
> - && (ev->fmt->subs.teletext.i_magazine == 1
> - || ev->fmt->subs.teletext.i_magazine > 8))
> - {
> - vlc_player_input_HandleTeletextMenu(input, ev);
> - return;
> - }
> -
> vlc_player_track_vector *vec =
> vlc_player_input_GetTrackVector(input, ev->fmt->i_cat);
> if (!vec)
> @@ -463,6 +472,7 @@ vlc_player_input_HandleEsEvent(struct
> vlc_player_input *input,
> input->ml.states.current_subtitle_track ==
> ev->fmt->i_id)
> vlc_player_SelectTrack(input->player,
> &trackpriv->t,
>
> VLC_PLAYER_SELECT_EXCLUSIVE);
> + vlc_player_input_HandleTeletextMenu(input, ev,
> trackpriv);
> default:
> break;
> }
> @@ -473,6 +483,8 @@ vlc_player_input_HandleEsEvent(struct
> vlc_player_input *input,
> trackpriv = vlc_player_track_vector_FindById(vec, ev->id,
> &idx);
> if (trackpriv)
> {
> + if(trackpriv->t.fmt.i_cat == SPU_ES)
> + vlc_player_input_HandleTeletextMenu(input, ev,
> trackpriv);
> vlc_player_SendEvent(player, on_track_list_changed,
> VLC_PLAYER_LIST_REMOVED,
> &trackpriv->t);
> vlc_vector_remove(vec, idx);
> @@ -513,6 +525,7 @@ vlc_player_input_HandleEsEvent(struct
> vlc_player_input *input,
> case SPU_ES:
> if (input->ml.default_subtitle_track == -2)
> input->ml.default_subtitle_track =
> ev->fmt->i_id;
> + vlc_player_input_HandleTeletextMenu(input, ev,
> trackpriv);
> break;
> default:
> break;
> @@ -526,6 +539,8 @@ vlc_player_input_HandleEsEvent(struct
> vlc_player_input *input,
> trackpriv->t.selected = false;
> vlc_player_SendEvent(player,
> on_track_selection_changed,
> trackpriv->t.es_id, NULL);
> + if(trackpriv->t.fmt.i_cat == SPU_ES)
> + vlc_player_input_HandleTeletextMenu(input, ev,
> trackpriv);
> }
> break;
> default:
> diff --git a/src/player/player.h b/src/player/player.h
> index d7e499a84e..e45cc1d510 100644
> --- a/src/player/player.h
> +++ b/src/player/player.h
> @@ -83,7 +83,7 @@ struct vlc_player_input
> vlc_player_track_vector video_track_vector;
> vlc_player_track_vector audio_track_vector;
> vlc_player_track_vector spu_track_vector;
> - struct vlc_player_track_priv *teletext_menu;
> + const struct vlc_player_track_priv *teletext_menu;
>
> struct vlc_player_title_list *titles;
So, teletext menu will be also seen as subtitle (from the player API) ? It was like that in VLC 3.0 but not in 4.0 since vlc_player.h
Like RĂ©mi said, it could need some explanations.
>
> --
> 2.24.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list