[vlc-devel] [PATCH 7/7] tests: add vlc_player teletext
Francois Cartegnie
fcvlcdev at free.fr
Tue Jun 9 10:38:52 CEST 2020
---
test/Makefile.am | 5 +
test/src/player/player.c | 297 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 298 insertions(+), 4 deletions(-)
diff --git a/test/Makefile.am b/test/Makefile.am
index 6d373bcb8e..28b950db20 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -270,6 +270,11 @@ libvlc_demux_dec_run_la_LIBADD += \
../modules/libtextst_plugin.la \
../modules/libsubstx3g_plugin.la
endif
+if WITH_ZVBI
+libvlc_demux_dec_run_la_LIBADD += ../modules/libzvbi_plugin.la
+else
+libvlc_demux_dec_run_la_LIBADD += ../modules/libtelx_plugin.la
+endif
EXTRA_LTLIBRARIES += libvlc_demux_dec_run.la
#
diff --git a/test/src/player/player.c b/test/src/player/player.c
index f465f96c0c..d43a9cf3e4 100644
--- a/test/src/player/player.c
+++ b/test/src/player/player.c
@@ -27,6 +27,12 @@
#include <vlc_player.h>
#include <vlc_vector.h>
+#ifdef ZVBI_COMPILED
+# define TELETEXT_DECODER "zvbi"
+#else
+# define TELETEXT_DECODER "telx"
+#endif
+
struct report_capabilities
{
int old_caps;
@@ -111,6 +117,10 @@ struct report_media_subitems
X(vlc_player_title_list *, on_titles_changed) \
X(size_t, on_title_selection_changed) \
X(struct report_chapter_selection, on_chapter_selection_changed) \
+ X(bool, on_teletext_menu_changed) \
+ X(bool, on_teletext_enabled_changed) \
+ X(unsigned, on_teletext_page_changed) \
+ X(bool, on_teletext_transparency_changed) \
X(struct report_category_delay, on_category_delay_changed) \
X(bool, on_recording_changed) \
X(struct report_signal, on_signal_changed) \
@@ -182,6 +192,8 @@ struct media_params
bool can_pause;
bool error;
bool null_names;
+
+ const char *config;
};
#define DEFAULT_MEDIA_PARAMS(param_length) { \
@@ -202,6 +214,7 @@ struct media_params
.can_pause = true, \
.error = false, \
.null_names = false, \
+ .config = NULL, \
}
struct ctx
@@ -425,6 +438,38 @@ player_on_chapter_selection_changed(vlc_player_t *player,
(void) chapter;
}
+static void
+player_on_teletext_menu_changed(vlc_player_t *player,
+ bool has_teletext_menu, void *data)
+{
+ struct ctx *ctx = get_ctx(player, data);
+ VEC_PUSH(on_teletext_menu_changed, has_teletext_menu);
+}
+
+static void
+player_on_teletext_enabled_changed(vlc_player_t *player,
+ bool enabled, void *data)
+{
+ struct ctx *ctx = get_ctx(player, data);
+ VEC_PUSH(on_teletext_enabled_changed, enabled);
+}
+
+static void
+player_on_teletext_page_changed(vlc_player_t *player,
+ unsigned new_page, void *data)
+{
+ struct ctx *ctx = get_ctx(player, data);
+ VEC_PUSH(on_teletext_page_changed, new_page);
+}
+
+static void
+player_on_teletext_transparency_changed(vlc_player_t *player,
+ bool enabled, void *data)
+{
+ struct ctx *ctx = get_ctx(player, data);
+ VEC_PUSH(on_teletext_transparency_changed, enabled);
+}
+
static void
player_on_category_delay_changed(vlc_player_t *player,
enum es_format_category_e cat, vlc_tick_t new_delay,
@@ -662,16 +707,18 @@ create_mock_media(const char *name, const struct media_params *params)
"sub_packetized=%d;length=%"PRId64";audio_sample_length=%"PRId64";"
"video_frame_rate=%u;video_frame_rate_base=%u;"
"title_count=%zu;chapter_count=%zu;"
- "can_seek=%d;can_pause=%d;error=%d;null_names=%d",
+ "can_seek=%d;can_pause=%d;error=%d;null_names=%d;"
+ "config=%s",
params->track_count[VIDEO_ES], params->track_count[AUDIO_ES],
params->track_count[SPU_ES], params->program_count,
params->video_packetized, params->audio_packetized,
params->sub_packetized, params->length, params->audio_sample_length,
params->video_frame_rate, params->video_frame_rate_base,
params->title_count, params->chapter_count,
- params->can_seek, params->can_pause, params->error, params->null_names);
+ params->can_seek, params->can_pause, params->error, params->null_names,
+ params->config ? params->config : "");
assert(ret != -1);
-
+printf("MOCK %s\n", url);
input_item_t *item = input_item_New(url, name);
assert(item);
free(url);
@@ -2029,7 +2076,7 @@ ctx_init(struct ctx *ctx, bool use_outputs)
"--no-media-library",
"--no-drop-late-frames",
/* Avoid leaks from various dlopen... */
- "--codec=araw,rawvideo,subsdec,none",
+ "--codec=araw,rawvideo,subsdec,"TELETEXT_DECODER",none",
"--dec-dev=none",
use_outputs ? "--vout=dummy" : "--vout=none",
use_outputs ? "--aout=dummy" : "--aout=none",
@@ -2428,6 +2475,247 @@ test_timers(struct ctx *ctx)
}
}
+static void
+test_teletext(struct ctx *ctx)
+{
+ test_log("teletext\n");
+ vlc_player_t *player = ctx->player;
+ const struct vlc_player_track *track;
+
+ struct media_params params = DEFAULT_MEDIA_PARAMS(VLC_TICK_FROM_SEC(1));
+ params.track_count[AUDIO_ES] = 0;
+ params.track_count[SPU_ES] = 3;
+ params.config = "sub[1]{format=telx,page=888}+sub[2]{format=telx,page=889}";
+ player_set_next_mock_media(ctx, "media1", ¶ms);
+
+ player_start(ctx);
+
+ /* Wait that all tracks are added */
+ {
+ vec_on_track_list_changed *vec = &ctx->report.on_track_list_changed;
+ while (vec_on_track_list_get_action_count(vec, VLC_PLAYER_LIST_ADDED)
+ != 4)
+ vlc_player_CondWait(player, &ctx->wait);
+ }
+
+ {
+ vec_on_teletext_menu_changed *vec = &ctx->report.on_teletext_menu_changed;
+ while (vec->size == 0)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(vec->size == 1);
+ assert(vec->data[0]);
+ assert(ctx->report.on_teletext_enabled_changed.size == 0);
+ assert(ctx->report.on_teletext_page_changed.size == 0);
+ assert(ctx->report.on_teletext_transparency_changed.size == 0);
+ }
+ assert(vlc_player_HasTeletextMenu(player));
+
+ /* Wait that video is selected */
+ {
+ vec_on_track_selection_changed *vec =
+ &ctx->report.on_track_selection_changed;
+ while (vec->size < 1)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(vec->size == 1);
+ track = vlc_player_GetTrack(player, vec->data[0].selected_id);
+ assert(track);
+ assert(track->fmt.i_cat == VIDEO_ES);
+ }
+
+ track = vlc_player_GetTrackAt(player, SPU_ES, 0);
+ assert(track);
+ vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
+
+ /* Wait for first subtitle to be selected */
+ {
+ vec_on_track_selection_changed *vec =
+ &ctx->report.on_track_selection_changed;
+ while (vec->size < 2)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(vec->size == 2);
+ track = vlc_player_GetTrack(player, vec->data[1].selected_id);
+ assert(track);
+ assert(track->fmt.i_cat == SPU_ES);
+ assert(track->fmt.i_codec != VLC_CODEC_TELETEXT);
+ }
+
+ assert(!vlc_player_IsTeletextEnabled(player));
+ vlc_player_SetTeletextEnabled(player, true);
+
+ /* Wait that video and sub are selected */
+ {
+ vec_on_track_selection_changed *vec =
+ &ctx->report.on_track_selection_changed;
+ while (vec->size < 4)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(vec->size == 4);
+ assert(vec->data[3].selected_id);
+ track = vlc_player_GetTrack(player, vec->data[3].selected_id);
+ assert(track);
+ assert(track->fmt.i_codec == VLC_CODEC_TELETEXT);
+ }
+
+ assert(vlc_player_IsTeletextEnabled(player));
+ track = vlc_player_GetSelectedTrack(player, SPU_ES);
+ assert(track);
+ assert(track && track->fmt.i_codec == VLC_CODEC_TELETEXT);
+
+ /* Wait for reselection on teletext ES */
+ {
+ vec_on_teletext_enabled_changed *vec = &ctx->report.on_teletext_enabled_changed;
+ while (vec->size == 0)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(vec->size == 1);
+ assert(VEC_LAST(vec));
+ }
+
+ /* Check page change event on selection */
+ {
+ vec_on_teletext_page_changed *vec = &ctx->report.on_teletext_page_changed;
+ while (vec->size == 0)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(VEC_LAST(vec) == 888);
+ }
+
+ /* Change sub track to other teletext */
+ {
+ vec_on_track_selection_changed *vec =
+ &ctx->report.on_track_selection_changed;
+ size_t prevsize = vec->size;
+ track = vlc_player_GetTrackAt(player, SPU_ES, 2);
+ assert(track);
+ assert(track->fmt.i_codec == VLC_CODEC_TELETEXT);
+ vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
+ while(!vec_on_track_selection_has_event(vec, prevsize,
+ NULL, track->es_id))
+ vlc_player_CondWait(player, &ctx->wait);
+ }
+
+ /* Check new ES page */
+ {
+ vec_on_teletext_page_changed *vec = &ctx->report.on_teletext_page_changed;
+ while (vec->size == 1)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(VEC_LAST(vec) == 889);
+ assert(vlc_player_GetTeletextPage(player) == 889);
+ }
+
+ /* Check direct page selection */
+#ifdef ZVBI_COMPILED
+ {
+ vec_on_teletext_page_changed *vec = &ctx->report.on_teletext_page_changed;
+ size_t prevsize = vec->size;
+ vlc_player_SelectTeletextPage(player, 111);
+ do
+ {
+ while (vec->size == prevsize)
+ vlc_player_CondWait(player, &ctx->wait);
+ prevsize = vec->size;
+ } while(VEC_LAST(vec) != 111);
+ assert(vlc_player_GetTeletextPage(player) == 111);
+ }
+#endif
+
+ /* Check disabling teletext through es re-selection */
+ {
+ vec_on_track_selection_changed *selvec =
+ &ctx->report.on_track_selection_changed;
+ vec_on_teletext_enabled_changed *vec =
+ &ctx->report.on_teletext_enabled_changed;
+ size_t prevselsize = selvec->size;
+ size_t prevsize = vec->size;
+ track = vlc_player_GetTrackAt(player, SPU_ES, 0);
+ assert(track);
+ assert(track->fmt.i_codec != VLC_CODEC_TELETEXT);
+ vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
+ /* Wait for re-selection */
+ while(!vec_on_track_selection_has_event(selvec, prevselsize,
+ NULL, track->es_id))
+ vlc_player_CondWait(player, &ctx->wait);
+ /* Now check changed events */
+ while (vec->size == prevsize)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(!VEC_LAST(vec));
+ assert(!vlc_player_IsTeletextEnabled(player));
+ assert(vlc_player_HasTeletextMenu(player));
+ }
+
+ /* Check re-enabling teletext through es re-selection */
+ {
+ vec_on_track_selection_changed *selvec =
+ &ctx->report.on_track_selection_changed;
+ vec_on_teletext_enabled_changed *vec =
+ &ctx->report.on_teletext_enabled_changed;
+ size_t prevselsize = selvec->size;
+ size_t prevsize = vec->size;
+ track = vlc_player_GetTrackAt(player, SPU_ES, 1);
+ assert(track);
+ assert(track->fmt.i_codec == VLC_CODEC_TELETEXT);
+ vlc_player_SelectTrack(player, track, VLC_PLAYER_SELECT_EXCLUSIVE);
+ /* Wait for re-selection */
+ while(!vec_on_track_selection_has_event(selvec, prevselsize,
+ NULL, track->es_id))
+ vlc_player_CondWait(player, &ctx->wait);
+ /* Now check changed events */
+ while (vec->size == prevsize)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(VEC_LAST(vec));
+ assert(vlc_player_IsTeletextEnabled(player));
+ assert(vlc_player_HasTeletextMenu(player));
+ }
+
+#ifdef ZVBI_COMPILED
+ /* Toggle Transparency tests */
+ {
+ vec_on_teletext_transparency_changed *vec =
+ &ctx->report.on_teletext_transparency_changed;
+ size_t prevsize = vec->size;
+ assert(!vlc_player_IsTeletextTransparent(player));
+ vlc_player_SetTeletextTransparency(player, true);
+ do
+ {
+ while (vec->size == prevsize)
+ vlc_player_CondWait(player, &ctx->wait);
+ prevsize = vec->size;
+ } while(!VEC_LAST(vec));
+ prevsize = vec->size;
+ vlc_player_SetTeletextTransparency(player, false);
+ do
+ {
+ while (vec->size == prevsize)
+ vlc_player_CondWait(player, &ctx->wait);
+ prevsize = vec->size;
+ } while(VEC_LAST(vec));
+ assert(!vlc_player_IsTeletextTransparent(player));
+ assert(!VEC_LAST(vec));
+ }
+#endif
+
+ /* Check disabling teletext through API */
+ {
+ assert(track); /* from previous sel test */
+ vec_on_track_selection_changed *selvec =
+ &ctx->report.on_track_selection_changed;
+ vec_on_teletext_enabled_changed *vec =
+ &ctx->report.on_teletext_enabled_changed;
+ size_t prevselsize = selvec->size;
+ size_t prevsize = vec->size;
+ vlc_player_SetTeletextEnabled(player, false);
+ /* Wait for deselection */
+ while(!vec_on_track_selection_has_event(selvec, prevselsize,
+ track->es_id, NULL))
+ vlc_player_CondWait(player, &ctx->wait);
+ /* Now check changed events */
+ while (vec->size == prevsize)
+ vlc_player_CondWait(player, &ctx->wait);
+ assert(!VEC_LAST(vec));
+ assert(!vlc_player_IsTeletextEnabled(player));
+ assert(vlc_player_HasTeletextMenu(player));
+ }
+
+ test_end(ctx);
+}
+
int
main(void)
{
@@ -2458,6 +2746,7 @@ main(void)
test_tracks_ids(&ctx);
test_programs(&ctx);
test_timers(&ctx);
+ test_teletext(&ctx);
test_delete_while_playback(VLC_OBJECT(ctx.vlc->p_libvlc_int), true);
test_delete_while_playback(VLC_OBJECT(ctx.vlc->p_libvlc_int), false);
--
2.25.4
More information about the vlc-devel
mailing list