validate: Add a scenarios that switchs subtitle track

+ Make it easier and cleaner to tell that a switch is actually disabling
a track type.

And run the scenario in gst-validate-launcher by default
This commit is contained in:
Thibault Saunier 2014-04-29 19:04:46 +02:00
parent 3281add6b5
commit da42500df7
4 changed files with 27 additions and 14 deletions

View file

@ -15,6 +15,7 @@ scenarios_DATA = simple_seeks.scenario \
force_key_unit.scenario\
seek_with_stop.scenario\
switch_audio_track_while_paused.scenario\
switch_subtitle_track.scenario\
switch_audio_track.scenario
EXTRA_DIST = simple_seeks.scenario \
@ -33,4 +34,5 @@ EXTRA_DIST = simple_seeks.scenario \
force_key_unit.scenario\
seek_with_stop.scenario\
switch_audio_track_while_paused.scenario\
switch_subtitle_track.scenario\
switch_audio_track.scenario

View file

@ -0,0 +1,3 @@
description, summary="Change subtitle track at 1 second while playing back", min-subtitle-track=2, duration=5.0
switch-track, playback_time=1.0, type=text, index=(string)+1
stop, playback_time=5.0

View file

@ -62,13 +62,13 @@ class MediaDescriptor(Loggable):
return True
return False
def get_num_audio_tracks(self):
naudio = 0
def get_num_tracks(self, track_type):
n = 0
for stream in self.media_xml.findall("streams")[0].findall("stream"):
if stream.attrib["type"] == "audio":
naudio += 1
if stream.attrib["type"] == track_type:
n += 1
return naudio
return n
def is_compatible(self, scenario):
if scenario.seeks() and (not self.is_seekable() or self.is_image()):
@ -76,11 +76,13 @@ class MediaDescriptor(Loggable):
scenario, self.get_uri())
return False
if self.get_num_audio_tracks() < scenario.get_min_audio_tracks():
self.debug("%s -- %s | At least %s audio track needed < %s"
% (scenario, self.get_uri(),
scenario.get_min_audio_tracks(), self.get_num_audio_tracks()))
return False
for track_type in ['audio', 'subtitle']:
if self.get_num_tracks(track_type) < scenario.get_min_tracks(track_type):
self.debug("%s -- %s | At least %s %s track needed < %s"
% (scenario, self.get_uri(), track_type,
scenario.get_min_tracks(track_type),
self.get_num_tracks(track_type)))
return False
return True
@ -155,6 +157,7 @@ G_V_SCENARIOS = {Protocols.FILE: ["play_15s",
"seek_with_stop",
"switch_audio_track",
"switch_audio_track_while_paused",
"switch_subtitle_track",
"scrub_forward_seeking"],
Protocols.HTTP: ["play_15s",
"fast_forward",
@ -163,6 +166,7 @@ G_V_SCENARIOS = {Protocols.FILE: ["play_15s",
"seek_with_stop",
"switch_audio_track",
"switch_audio_track_while_paused",
"switch_subtitle_track",
"reverse_playback"],
Protocols.HLS: ["play_15s",
"fast_forward",
@ -170,6 +174,7 @@ G_V_SCENARIOS = {Protocols.FILE: ["play_15s",
"seek_with_stop",
"switch_audio_track",
"switch_audio_track_while_paused",
"switch_subtitle_track",
"seek_backward"],
}

View file

@ -678,11 +678,14 @@ class Scenario(object):
if hasattr(self, "reverse_playback"):
return bool(self.seek)
return False
def get_min_audio_tracks(self):
if hasattr(self, "min_audio_track"):
return int(self.min_audio_track)
return 0
def get_min_tracks(self, track_type):
try:
return int(getattr(self, "min_%s_track" % track_type))
except AttributeError:
return 0
class ScenarioManager(Loggable):