mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
validate: launcher: Add support for running tests with a pushfile source
Introducing the `.media_info.push` media info extension, which is meant to let the launcher know that those file should run with the "pushfile://" protocol. And allow symlinking "normal" `.media_info` to their `.pushfile` variant so that both can share the exact same content.
This commit is contained in:
parent
b2e71e1404
commit
58c90448ca
4 changed files with 70 additions and 42 deletions
|
@ -96,6 +96,11 @@ testsuite_folder/
|
|||
<informalexample>
|
||||
<programlisting>gst-validate-launcher --medias-paths /path/to/sample_files/ --generate-media-info</programlisting>
|
||||
</informalexample>
|
||||
<para>
|
||||
<command>gst-validate-launcher</command> allows specifying that a local media file should also be tested in push mode.
|
||||
To do so you will need to generate (or symlink) a media info file with the extension <filename>.media_info.push</filename>.
|
||||
In that case a "pushfile" source will be used instead of the usual "filesource".
|
||||
</para>
|
||||
<para>
|
||||
For remote streams, you should use <command>gst-validate-media-check-&GST_API_VERSION;</command>. For an http stream you can for example do:
|
||||
</para>
|
||||
|
|
|
@ -833,48 +833,56 @@ not been tested and explicitely activated if you set use --wanted-tests ALL""")
|
|||
self.debug("Exception: %s for %s", e, media_info)
|
||||
|
||||
def _discover_file(self, uri, fpath):
|
||||
try:
|
||||
media_info = "%s.%s" % (
|
||||
fpath, GstValidateMediaDescriptor.MEDIA_INFO_EXT)
|
||||
args = GstValidateBaseTestManager.MEDIA_CHECK_COMMAND.split(" ")
|
||||
args.append(uri)
|
||||
if os.path.isfile(media_info) and not self.options.update_media_info:
|
||||
self._add_media(media_info, uri)
|
||||
return True
|
||||
elif fpath.endswith(GstValidateMediaDescriptor.STREAM_INFO_EXT):
|
||||
self._add_media(fpath)
|
||||
return True
|
||||
elif not self.options.generate_info and not self.options.update_media_info and not self.options.validate_uris:
|
||||
self.info(
|
||||
"%s not present. Use --generate-media-info", media_info)
|
||||
return True
|
||||
elif self.options.update_media_info and not os.path.isfile(media_info):
|
||||
self.info(
|
||||
"%s not present. Use --generate-media-info", media_info)
|
||||
return True
|
||||
for ext in (GstValidateMediaDescriptor.MEDIA_INFO_EXT,
|
||||
GstValidateMediaDescriptor.PUSH_MEDIA_INFO_EXT):
|
||||
try:
|
||||
is_push = False
|
||||
media_info = "%s.%s" % (fpath, ext)
|
||||
if ext == GstValidateMediaDescriptor.PUSH_MEDIA_INFO_EXT:
|
||||
if not os.path.exists(media_info):
|
||||
continue
|
||||
is_push = True
|
||||
uri = "push" + uri
|
||||
args = GstValidateBaseTestManager.MEDIA_CHECK_COMMAND.split(" ")
|
||||
|
||||
include_frames = 0
|
||||
if self.options.update_media_info:
|
||||
include_frames = 2
|
||||
elif self.options.generate_info_full:
|
||||
include_frames = 1
|
||||
args.append(uri)
|
||||
if os.path.isfile(media_info) and not self.options.update_media_info:
|
||||
self._add_media(media_info, uri)
|
||||
continue
|
||||
elif fpath.endswith(GstValidateMediaDescriptor.STREAM_INFO_EXT):
|
||||
self._add_media(fpath)
|
||||
continue
|
||||
elif not self.options.generate_info and not self.options.update_media_info and not self.options.validate_uris:
|
||||
continue
|
||||
elif self.options.update_media_info and not os.path.isfile(media_info):
|
||||
self.info(
|
||||
"%s not present. Use --generate-media-info", media_info)
|
||||
continue
|
||||
elif os.path.islink(media_info):
|
||||
self.info(
|
||||
"%s is a symlink, not updating and hopefully the actual file gets updated!", media_info)
|
||||
continue
|
||||
|
||||
media_descriptor = GstValidateMediaDescriptor.new_from_uri(
|
||||
uri, True,
|
||||
include_frames)
|
||||
if media_descriptor:
|
||||
self._add_media(media_descriptor, uri)
|
||||
else:
|
||||
self.warning("Could not get any descriptor for %s" % uri)
|
||||
include_frames = 0
|
||||
if self.options.update_media_info:
|
||||
include_frames = 2
|
||||
elif self.options.generate_info_full:
|
||||
include_frames = 1
|
||||
|
||||
return True
|
||||
media_descriptor = GstValidateMediaDescriptor.new_from_uri(
|
||||
uri, True, include_frames, is_push)
|
||||
if media_descriptor:
|
||||
self._add_media(media_descriptor, uri)
|
||||
else:
|
||||
self.warning("Could not get any descriptor for %s" % uri)
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
if self.options.generate_info:
|
||||
printc("Result: Failed", Colors.FAIL)
|
||||
else:
|
||||
self.error("Exception: %s", e)
|
||||
return False
|
||||
except subprocess.CalledProcessError as e:
|
||||
if self.options.generate_info:
|
||||
printc("Result: Failed", Colors.FAIL)
|
||||
else:
|
||||
self.error("Exception: %s", e)
|
||||
return False
|
||||
return True
|
||||
|
||||
def _list_uris(self):
|
||||
if self._uris:
|
||||
|
|
|
@ -2065,6 +2065,9 @@ class MediaDescriptor(Loggable):
|
|||
def get_path(self):
|
||||
raise NotImplemented
|
||||
|
||||
def has_frames(self):
|
||||
return False
|
||||
|
||||
def get_media_filepath(self):
|
||||
raise NotImplemented
|
||||
|
||||
|
@ -2153,6 +2156,7 @@ class MediaDescriptor(Loggable):
|
|||
class GstValidateMediaDescriptor(MediaDescriptor):
|
||||
# Some extension file for discovering results
|
||||
MEDIA_INFO_EXT = "media_info"
|
||||
PUSH_MEDIA_INFO_EXT = "media_info.push"
|
||||
STREAM_INFO_EXT = "stream_info"
|
||||
|
||||
def __init__(self, xml_path):
|
||||
|
@ -2174,6 +2178,9 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
def skip_parsers(self):
|
||||
return self._skip_parsers
|
||||
|
||||
def has_frames(self):
|
||||
return self._has_frames
|
||||
|
||||
def _extract_data(self, media_xml):
|
||||
# Extract the information we need from the xml
|
||||
self._caps = media_xml.findall("streams")[0].attrib["caps"]
|
||||
|
@ -2188,6 +2195,7 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
(stream.attrib["type"], stream.attrib["caps"]))
|
||||
self._uri = media_xml.attrib["uri"]
|
||||
self._skip_parsers = bool(int(media_xml.attrib.get('skip-parsers', 0)))
|
||||
self._has_frames = bool(int(media_xml.attrib["frame-detection"]))
|
||||
self._duration = int(media_xml.attrib["duration"])
|
||||
self._protocol = media_xml.get("protocol", None)
|
||||
self._is_seekable = media_xml.attrib["seekable"].lower() == "true"
|
||||
|
@ -2201,7 +2209,7 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
self._track_types.append(stream.attrib["type"])
|
||||
|
||||
@staticmethod
|
||||
def new_from_uri(uri, verbose=False, include_frames=False):
|
||||
def new_from_uri(uri, verbose=False, include_frames=False, is_push=False):
|
||||
"""
|
||||
include_frames = 0 # Never
|
||||
include_frames = 1 # always
|
||||
|
@ -2210,8 +2218,9 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
"""
|
||||
media_path = utils.url2path(uri)
|
||||
|
||||
descriptor_path = "%s.%s" % (
|
||||
media_path, GstValidateMediaDescriptor.MEDIA_INFO_EXT)
|
||||
ext = GstValidateMediaDescriptor.PUSH_MEDIA_INFO_EXT if is_push else \
|
||||
GstValidateMediaDescriptor.MEDIA_INFO_EXT
|
||||
descriptor_path = "%s.%s" % (media_path, ext)
|
||||
args = GstValidateBaseTestManager.MEDIA_CHECK_COMMAND.split(" ")
|
||||
args.append(uri)
|
||||
if include_frames == 2:
|
||||
|
@ -2262,6 +2271,8 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
def get_media_filepath(self):
|
||||
if self.get_protocol() == Protocols.FILE:
|
||||
return self._xml_path.replace("." + self.MEDIA_INFO_EXT, "")
|
||||
elif self.get_protocol() == Protocols.PUSHFILE:
|
||||
return self._xml_path.replace("." + self.PUSH_MEDIA_INFO_EXT, "")
|
||||
else:
|
||||
return self._xml_path.replace("." + self.STREAM_INFO_EXT, "")
|
||||
|
||||
|
@ -2278,7 +2289,10 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
return self._duration
|
||||
|
||||
def set_protocol(self, protocol):
|
||||
self._protocol = protocol
|
||||
if self._xml_path.endswith(GstValidateMediaDescriptor.PUSH_MEDIA_INFO_EXT):
|
||||
self._protocol = Protocols.PUSHFILE
|
||||
else:
|
||||
self._protocol = protocol
|
||||
|
||||
def get_protocol(self):
|
||||
return self._protocol
|
||||
|
|
|
@ -63,6 +63,7 @@ class Result(object):
|
|||
class Protocols(object):
|
||||
HTTP = "http"
|
||||
FILE = "file"
|
||||
PUSHFILE = "pushfile"
|
||||
HLS = "hls"
|
||||
DASH = "dash"
|
||||
RTSP = "rtsp"
|
||||
|
|
Loading…
Reference in a new issue