mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
validate:launcher: Add a method to create a GstValidateMediaDescriptor from a uri
This commit is contained in:
parent
265688fcd6
commit
fe9ed41d6c
3 changed files with 54 additions and 16 deletions
|
@ -63,6 +63,9 @@ class XgesProjectDescriptor(MediaDescriptor):
|
|||
def get_media_filepath(self):
|
||||
return self._xml_path
|
||||
|
||||
def get_path(self):
|
||||
return self._xml_path
|
||||
|
||||
def get_caps(self):
|
||||
raise NotImplemented
|
||||
|
||||
|
|
|
@ -463,9 +463,14 @@ not been tested and explicitely activated if you set use --wanted-tests ALL""")
|
|||
|
||||
return self.tests
|
||||
|
||||
def _check_discovering_info(self, media_info, uri=None):
|
||||
def _add_media(self, media_info, uri=None):
|
||||
self.debug("Checking %s", media_info)
|
||||
media_descriptor = GstValidateMediaDescriptor(media_info)
|
||||
if isinstance(media_info, GstValidateMediaDescriptor):
|
||||
media_descriptor = media_info
|
||||
media_info = media_descriptor.get_path()
|
||||
else:
|
||||
media_descriptor = GstValidateMediaDescriptor(media_info)
|
||||
|
||||
try:
|
||||
# Just testing that the vairous mandatory infos are present
|
||||
caps = media_descriptor.get_caps()
|
||||
|
@ -493,25 +498,16 @@ not been tested and explicitely activated if you set use --wanted-tests ALL""")
|
|||
args = G_V_DISCOVERER_COMMAND.split(" ")
|
||||
args.append(uri)
|
||||
if os.path.isfile(media_info):
|
||||
self._check_discovering_info(media_info, uri)
|
||||
self._add_media(media_info, uri)
|
||||
return True
|
||||
elif fpath.endswith(GstValidateMediaDescriptor.STREAM_INFO_EXT):
|
||||
self._check_discovering_info(fpath)
|
||||
self._add_media(fpath)
|
||||
return True
|
||||
elif self.options.generate_info:
|
||||
args.extend(["--output-file", media_info])
|
||||
else:
|
||||
elif not self.options.generate_info:
|
||||
return True
|
||||
|
||||
if self.options.generate_info:
|
||||
printc("Generating media info for %s\n"
|
||||
" Command: '%s'" % (fpath, ' '.join(args)),
|
||||
Colors.OKBLUE)
|
||||
out = subprocess.check_output(args, stderr=open(os.devnull))
|
||||
self._check_discovering_info(media_info, uri)
|
||||
|
||||
if self.options.generate_info:
|
||||
printc("Result: Passed", Colors.OKGREEN)
|
||||
media_descriptor = GstValidateMediaDescriptor.new_from_uri(uri, True)
|
||||
self._add_media(media_descriptor, uri)
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -941,6 +941,9 @@ class MediaDescriptor(Loggable):
|
|||
def __init__(self):
|
||||
Loggable.__init__(self)
|
||||
|
||||
def get_path(self):
|
||||
raise NotImplemented
|
||||
|
||||
def get_media_filepath(self):
|
||||
raise NotImplemented
|
||||
|
||||
|
@ -989,6 +992,10 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
MEDIA_INFO_EXT = "media_info"
|
||||
STREAM_INFO_EXT = "stream_info"
|
||||
|
||||
DISCOVERER_COMMAND = "gst-validate-media-check-1.0"
|
||||
if "win32" in sys.platform:
|
||||
DISCOVERER_COMMAND += ".exe"
|
||||
|
||||
def __init__(self, xml_path):
|
||||
super(GstValidateMediaDescriptor, self).__init__()
|
||||
|
||||
|
@ -999,6 +1006,38 @@ class GstValidateMediaDescriptor(MediaDescriptor):
|
|||
self.media_xml.attrib["duration"]
|
||||
self.media_xml.attrib["seekable"]
|
||||
|
||||
@staticmethod
|
||||
def new_from_uri(uri, verbose=False):
|
||||
media_path = utils.url2path(uri)
|
||||
descriptor_path = "%s.%s" % (media_path, GstValidateMediaDescriptor.MEDIA_INFO_EXT)
|
||||
args = GstValidateMediaDescriptor.DISCOVERER_COMMAND.split(" ")
|
||||
args.append(uri)
|
||||
|
||||
args.extend(["--output-file", descriptor_path])
|
||||
|
||||
if verbose:
|
||||
printc("Generating media info for %s\n"
|
||||
" Command: '%s'" % (media_path, ' '.join(args)),
|
||||
Colors.OKBLUE)
|
||||
|
||||
try:
|
||||
out = subprocess.check_output(args, stderr=open(os.devnull))
|
||||
except subprocess.CalledProcessError as e:
|
||||
if self.options.generate_info:
|
||||
printc("Result: Failed", Colors.FAIL)
|
||||
else:
|
||||
self.error("Exception: %s", e)
|
||||
return None
|
||||
|
||||
if verbose:
|
||||
printc("Result: Passed", Colors.OKGREEN)
|
||||
|
||||
|
||||
return GstValidateMediaDescriptor(descriptor_path)
|
||||
|
||||
def get_path(self):
|
||||
return self._xml_path
|
||||
|
||||
def get_media_filepath(self):
|
||||
if self.get_protocol() == Protocols.FILE:
|
||||
return self._xml_path.replace("." + self.MEDIA_INFO_EXT, "")
|
||||
|
|
Loading…
Reference in a new issue