2014-05-16 14:20:26 +00:00
|
|
|
#!/usr/bin/env python2
|
2014-01-08 08:49:38 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2013,Thibault Saunier <thibault.saunier@collabora.com>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the
|
|
|
|
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
# Boston, MA 02110-1301, USA.
|
|
|
|
import os
|
2014-09-06 09:38:38 +00:00
|
|
|
import sys
|
2014-02-13 14:31:58 +00:00
|
|
|
import time
|
2014-01-08 08:49:38 +00:00
|
|
|
import urlparse
|
2014-01-09 08:14:27 +00:00
|
|
|
import subprocess
|
2014-01-08 08:49:38 +00:00
|
|
|
import ConfigParser
|
2014-01-08 17:51:14 +00:00
|
|
|
from loggable import Loggable
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
from baseclasses import GstValidateTest, TestsManager, Test, \
|
2014-07-16 08:10:44 +00:00
|
|
|
ScenarioManager, NamedDic, GstValidateTestsGenerator, \
|
2014-09-06 09:38:38 +00:00
|
|
|
GstValidateMediaDescriptor, GstValidateEncodingTestInterface, \
|
|
|
|
GstValidateBaseTestManager
|
2014-07-16 08:10:44 +00:00
|
|
|
|
2014-07-16 10:16:03 +00:00
|
|
|
from utils import path2url, DEFAULT_TIMEOUT, which, \
|
2014-07-16 10:03:14 +00:00
|
|
|
GST_SECOND, Result, Protocols
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
######################################
|
|
|
|
# Private global variables #
|
|
|
|
######################################
|
|
|
|
|
2014-06-18 10:51:02 +00:00
|
|
|
# definitions of commands to use
|
|
|
|
GST_VALIDATE_COMMAND = "gst-validate-1.0"
|
|
|
|
GST_VALIDATE_TRANSCODING_COMMAND = "gst-validate-transcoding-1.0"
|
|
|
|
G_V_DISCOVERER_COMMAND = "gst-validate-media-check-1.0"
|
|
|
|
if "win32" in sys.platform:
|
|
|
|
GST_VALIDATE_COMMAND += ".exe"
|
|
|
|
GST_VALIDATE_TRANSCODING_COMMAND += ".exe"
|
|
|
|
G_V_DISCOVERER_COMMAND += ".exe"
|
|
|
|
|
2014-07-16 08:09:32 +00:00
|
|
|
AUDIO_ONLY_FILE_TRANSCODING_RATIO = 5
|
2014-06-18 10:51:02 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
#################################################
|
|
|
|
# API to be used to create testsuites #
|
|
|
|
#################################################
|
2014-06-18 10:51:02 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
"""
|
|
|
|
Some info about protocols and how to handle them
|
|
|
|
"""
|
2014-08-09 14:34:09 +00:00
|
|
|
GST_VALIDATE_CAPS_TO_PROTOCOL = [("application/x-hls", Protocols.HLS),
|
|
|
|
("application/dash+xml", Protocols.DASH)]
|
2014-06-18 15:26:05 +00:00
|
|
|
GST_VALIDATE_PROTOCOL_TIMEOUTS = {Protocols.HTTP: 120,
|
2014-08-09 14:34:09 +00:00
|
|
|
Protocols.HLS: 240,
|
|
|
|
Protocols.DASH: 240}
|
2014-06-18 15:26:05 +00:00
|
|
|
|
2014-01-30 15:59:21 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
class GstValidateMediaCheckTestsGenerator(GstValidateTestsGenerator):
|
|
|
|
def __init__(self, test_manager):
|
|
|
|
GstValidateTestsGenerator.__init__(self, "media_check", test_manager)
|
2014-06-18 10:51:02 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
def populate_tests(self, uri_minfo_special_scenarios, scenarios):
|
2014-06-18 10:51:02 +00:00
|
|
|
for uri, mediainfo, special_scenarios in uri_minfo_special_scenarios:
|
|
|
|
protocol = mediainfo.media_descriptor.get_protocol()
|
|
|
|
try:
|
2014-06-18 15:26:05 +00:00
|
|
|
timeout = GST_VALIDATE_PROTOCOL_TIMEOUTS[protocol]
|
2014-06-18 10:51:02 +00:00
|
|
|
except KeyError:
|
|
|
|
timeout = DEFAULT_TIMEOUT
|
|
|
|
|
|
|
|
classname = "validate.%s.media_check.%s" % (protocol,
|
|
|
|
os.path.basename(uri).replace(".", "_"))
|
2014-06-18 15:26:05 +00:00
|
|
|
self.add_test(GstValidateMediaCheckTest(classname,
|
2014-06-26 10:42:38 +00:00
|
|
|
self.test_manager.options,
|
|
|
|
self.test_manager.reporter,
|
2014-06-18 10:51:02 +00:00
|
|
|
mediainfo.media_descriptor,
|
|
|
|
uri,
|
|
|
|
mediainfo.path,
|
|
|
|
timeout=timeout))
|
2014-01-30 15:59:21 +00:00
|
|
|
|
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
class GstValidateTranscodingTestsGenerator(GstValidateTestsGenerator):
|
|
|
|
def __init__(self, test_manager):
|
|
|
|
GstValidateTestsGenerator.__init__(self, "transcode", test_manager)
|
2014-01-30 15:59:21 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
def populate_tests(self, uri_minfo_special_scenarios, scenarios):
|
2014-06-18 10:51:02 +00:00
|
|
|
for uri, mediainfo, special_scenarios in uri_minfo_special_scenarios:
|
|
|
|
if mediainfo.media_descriptor.is_image():
|
|
|
|
continue
|
2014-01-30 15:59:21 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
for comb in self.test_manager.get_encoding_formats():
|
2014-08-19 16:06:14 +00:00
|
|
|
suffix = os.path.basename (mediainfo.media_descriptor.get_path())
|
|
|
|
suffix = suffix.replace (".media_info", "")
|
|
|
|
suffix = suffix.replace (".stream_info", "")
|
2014-06-18 10:51:02 +00:00
|
|
|
classname = "validate.%s.transcode.to_%s.%s" % (mediainfo.media_descriptor.get_protocol(),
|
|
|
|
str(comb).replace(' ', '_'),
|
2014-09-06 08:02:13 +00:00
|
|
|
suffix.replace('.', '_'))
|
2014-06-18 15:26:05 +00:00
|
|
|
self.add_test(GstValidateTranscodingTest(classname,
|
2014-06-26 10:42:38 +00:00
|
|
|
self.test_manager.options,
|
|
|
|
self.test_manager.reporter,
|
2014-06-18 15:26:05 +00:00
|
|
|
comb,
|
|
|
|
uri,
|
|
|
|
mediainfo.media_descriptor))
|
|
|
|
|
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
class GstValidatePipelineTestsGenerator(GstValidateTestsGenerator):
|
|
|
|
def __init__(self, name, test_manager, pipeline_template=None, pipelines_descriptions=None,
|
2014-06-18 15:26:05 +00:00
|
|
|
valid_scenarios=[]):
|
|
|
|
"""
|
|
|
|
@name: The name of the generator
|
|
|
|
@pipeline_template: A template pipeline to be used to generate actual pipelines
|
|
|
|
@pipelines_descriptions: A list of tuple of the form:
|
|
|
|
(test_name, pipeline_description)
|
|
|
|
@valid_scenarios: A list of scenario name that can be used with that generator
|
|
|
|
"""
|
2014-06-26 10:42:38 +00:00
|
|
|
GstValidateTestsGenerator.__init__(self, name, test_manager)
|
2014-06-18 15:26:05 +00:00
|
|
|
self._pipeline_template = pipeline_template
|
|
|
|
self._pipelines_descriptions = pipelines_descriptions
|
|
|
|
self._valid_scenarios = valid_scenarios
|
|
|
|
|
|
|
|
def get_fname(self, scenario, protocol=None, name=None):
|
|
|
|
if name is None:
|
|
|
|
name = self.name
|
|
|
|
|
|
|
|
if protocol is not None:
|
|
|
|
protocol_str = "%s." % protocol
|
|
|
|
else:
|
|
|
|
protocol_str = ""
|
|
|
|
|
|
|
|
if scenario is not None and scenario.name.lower() != "none":
|
|
|
|
return "%s.%s%s.%s" % ("validate", protocol_str, name, scenario.name)
|
2014-01-30 15:59:21 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
return "%s.%s%s" % ("validate", protocol_str, name)
|
2014-01-30 15:59:21 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
def generate_tests(self, uri_minfo_special_scenarios, scenarios):
|
2014-01-30 15:59:21 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
if self._valid_scenarios:
|
|
|
|
scenarios = [scenario for scenario in scenarios if
|
|
|
|
scenario.name in self._valid_scenarios]
|
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
return super(GstValidatePipelineTestsGenerator, self).generate_tests(
|
2014-06-18 15:26:05 +00:00
|
|
|
uri_minfo_special_scenarios, scenarios)
|
2014-01-30 15:59:21 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
def populate_tests(self, uri_minfo_special_scenarios, scenarios):
|
|
|
|
for name, pipeline in self._pipelines_descriptions:
|
|
|
|
for scenario in scenarios:
|
|
|
|
fname = self.get_fname(scenario, name=name)
|
|
|
|
self.add_test(GstValidateLaunchTest(fname,
|
2014-06-26 10:42:38 +00:00
|
|
|
self.test_manager.options,
|
|
|
|
self.test_manager.reporter,
|
2014-06-18 15:26:05 +00:00
|
|
|
pipeline,
|
|
|
|
scenario=scenario)
|
|
|
|
)
|
2014-01-14 09:32:53 +00:00
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
class GstValidatePlaybinTestsGenerator(GstValidatePipelineTestsGenerator):
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
def __init__(self, test_manager):
|
|
|
|
GstValidatePipelineTestsGenerator.__init__(self, "playback", test_manager, "playbin")
|
2014-01-30 14:40:21 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
def populate_tests(self, uri_minfo_special_scenarios, scenarios):
|
2014-06-18 10:51:02 +00:00
|
|
|
for uri, minfo, special_scenarios in uri_minfo_special_scenarios:
|
2014-06-18 15:26:05 +00:00
|
|
|
pipe = self._pipeline_template
|
2014-06-18 10:51:02 +00:00
|
|
|
protocol = minfo.media_descriptor.get_protocol()
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-06-18 10:51:02 +00:00
|
|
|
pipe += " uri=%s" % uri
|
|
|
|
for scenario in special_scenarios + scenarios:
|
2014-07-23 12:43:29 +00:00
|
|
|
cpipe = pipe
|
2014-06-18 10:51:02 +00:00
|
|
|
if not minfo.media_descriptor.is_compatible(scenario):
|
|
|
|
continue
|
2014-01-13 10:13:02 +00:00
|
|
|
|
2014-07-23 12:43:29 +00:00
|
|
|
if self.test_manager.options.mute:
|
|
|
|
if scenario.needs_clock_sync():
|
|
|
|
fakesink = "'fakesink sync=true'"
|
|
|
|
else:
|
|
|
|
fakesink = "'fakesink'"
|
|
|
|
|
|
|
|
cpipe += " audio-sink=%s video-sink=%s" %(fakesink, fakesink)
|
|
|
|
|
2014-06-18 10:51:02 +00:00
|
|
|
fname = "%s.%s" % (self.get_fname(scenario,
|
|
|
|
protocol),
|
2014-08-19 16:06:14 +00:00
|
|
|
os.path.basename(minfo.media_descriptor.get_path()).replace(".stream_info",
|
|
|
|
'').replace(".media_info", ''))
|
2014-06-18 10:51:02 +00:00
|
|
|
self.debug("Adding: %s", fname)
|
2014-02-13 14:33:25 +00:00
|
|
|
|
2014-06-18 10:51:02 +00:00
|
|
|
if scenario.does_reverse_playback() and protocol == Protocols.HTTP:
|
|
|
|
# 10MB so we can reverse playback
|
2014-07-23 12:43:29 +00:00
|
|
|
cpipe += " ring-buffer-max-size=10485760"
|
2014-05-01 09:32:42 +00:00
|
|
|
|
2014-06-18 15:26:05 +00:00
|
|
|
self.add_test(GstValidateLaunchTest(fname,
|
2014-06-26 10:42:38 +00:00
|
|
|
self.test_manager.options,
|
|
|
|
self.test_manager.reporter,
|
2014-07-23 12:43:29 +00:00
|
|
|
cpipe,
|
2014-06-18 15:26:05 +00:00
|
|
|
scenario=scenario,
|
|
|
|
media_descriptor=minfo.media_descriptor)
|
|
|
|
)
|
2014-05-01 09:32:42 +00:00
|
|
|
|
2014-01-30 11:20:33 +00:00
|
|
|
|
2014-06-26 11:01:13 +00:00
|
|
|
class GstValidateMixerTestsGenerator(GstValidatePipelineTestsGenerator):
|
|
|
|
def __init__(self, name, test_manager, mixer, media_type, converter="", num_sources=3,
|
|
|
|
mixed_srcs={}, valid_scenarios=[]):
|
|
|
|
pipe_template = "%(mixer)s name=_mixer ! " + converter + " ! %(sink)s "
|
|
|
|
self.converter = converter
|
|
|
|
self.mixer = mixer
|
|
|
|
self.media_type = media_type
|
|
|
|
self.num_sources = num_sources
|
|
|
|
self.mixed_srcs = mixed_srcs
|
|
|
|
super(GstValidateMixerTestsGenerator, self).__init__(name, test_manager, pipe_template,
|
|
|
|
valid_scenarios=valid_scenarios)
|
|
|
|
|
|
|
|
def populate_tests(self, uri_minfo_special_scenarios, scenarios):
|
|
|
|
wanted_ressources = []
|
|
|
|
for uri, minfo, special_scenarios in uri_minfo_special_scenarios:
|
|
|
|
protocol = minfo.media_descriptor.get_protocol()
|
|
|
|
if protocol == Protocols.FILE and \
|
|
|
|
minfo.media_descriptor.get_num_tracks(self.media_type) > 0:
|
|
|
|
wanted_ressources.append((uri, minfo))
|
|
|
|
|
|
|
|
if not self.mixed_srcs:
|
|
|
|
if not wanted_ressources:
|
|
|
|
return
|
|
|
|
|
|
|
|
for i in range(len(uri_minfo_special_scenarios) / self.num_sources):
|
|
|
|
can_run = True
|
|
|
|
srcs = []
|
|
|
|
name = ""
|
|
|
|
for nsource in range(self.num_sources):
|
|
|
|
uri, minfo = wanted_ressources[i + nsource]
|
|
|
|
srcs.append("uridecodebin uri=%s ! %s" % (uri, self.converter))
|
|
|
|
fname = os.path.basename(uri).replace(".", "_")
|
|
|
|
if not name:
|
|
|
|
name = fname
|
|
|
|
else:
|
|
|
|
name += "+%s" % fname
|
|
|
|
|
|
|
|
self.mixed_srcs[name] = tuple(srcs)
|
|
|
|
|
|
|
|
for name, srcs in self.mixed_srcs.iteritems():
|
|
|
|
if isinstance(srcs, dict):
|
|
|
|
pipe_arguments = {"mixer": self.mixer + " %s" % srcs["mixer_props"]}
|
|
|
|
srcs = srcs["sources"]
|
|
|
|
else:
|
|
|
|
pipe_arguments = {"mixer": self.mixer}
|
|
|
|
|
|
|
|
if self.test_manager.options.mute:
|
2014-07-16 17:38:01 +00:00
|
|
|
pipe_arguments["sink"] = "'fakesink'"
|
2014-06-26 11:01:13 +00:00
|
|
|
else:
|
|
|
|
pipe_arguments["sink"] = "auto%ssink" % self.media_type
|
|
|
|
|
|
|
|
pipe = self._pipeline_template % pipe_arguments
|
|
|
|
|
|
|
|
for src in srcs:
|
|
|
|
pipe += "%s ! _mixer. " % src
|
|
|
|
|
|
|
|
for scenario in scenarios:
|
|
|
|
fname = self.get_fname(scenario, Protocols.FILE) + "."
|
|
|
|
fname += name
|
|
|
|
|
|
|
|
self.debug("Adding: %s", fname)
|
|
|
|
|
|
|
|
self.add_test(GstValidateLaunchTest(fname,
|
|
|
|
self.test_manager.options,
|
|
|
|
self.test_manager.reporter,
|
|
|
|
pipe,
|
|
|
|
scenario=scenario)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2014-01-09 08:14:27 +00:00
|
|
|
class GstValidateLaunchTest(GstValidateTest):
|
|
|
|
def __init__(self, classname, options, reporter, pipeline_desc,
|
2014-04-25 09:31:01 +00:00
|
|
|
timeout=DEFAULT_TIMEOUT, scenario=None, media_descriptor=None):
|
2014-01-24 10:31:42 +00:00
|
|
|
try:
|
2014-06-18 15:26:05 +00:00
|
|
|
timeout = GST_VALIDATE_PROTOCOL_TIMEOUTS[media_descriptor.get_protocol()]
|
2014-01-24 10:31:42 +00:00
|
|
|
except KeyError:
|
|
|
|
pass
|
2014-06-18 10:51:02 +00:00
|
|
|
except AttributeError:
|
|
|
|
pass
|
2014-01-24 10:31:42 +00:00
|
|
|
|
2014-05-07 09:30:09 +00:00
|
|
|
duration = 0
|
|
|
|
if scenario:
|
|
|
|
duration = scenario.get_duration()
|
|
|
|
elif media_descriptor:
|
|
|
|
duration = media_descriptor.get_duration() / GST_SECOND
|
2014-01-30 14:40:21 +00:00
|
|
|
super(GstValidateLaunchTest, self).__init__(GST_VALIDATE_COMMAND, classname,
|
2014-01-09 14:20:46 +00:00
|
|
|
options, reporter,
|
2014-05-07 09:30:09 +00:00
|
|
|
duration=duration,
|
2014-01-24 12:59:56 +00:00
|
|
|
scenario=scenario,
|
|
|
|
timeout=timeout)
|
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
self.pipeline_desc = pipeline_desc
|
2014-04-25 09:31:01 +00:00
|
|
|
self.media_descriptor = media_descriptor
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
def build_arguments(self):
|
2014-01-09 08:14:27 +00:00
|
|
|
GstValidateTest.build_arguments(self)
|
2014-01-08 08:49:38 +00:00
|
|
|
self.add_arguments(self.pipeline_desc)
|
|
|
|
|
2014-01-09 08:14:27 +00:00
|
|
|
def get_current_value(self):
|
2014-02-14 15:07:51 +00:00
|
|
|
if self.scenario:
|
|
|
|
sent_eos = self.sent_eos_position()
|
|
|
|
if sent_eos is not None:
|
2014-02-19 12:07:03 +00:00
|
|
|
t = time.time()
|
|
|
|
if ((t - sent_eos)) > 30:
|
2014-04-25 09:31:01 +00:00
|
|
|
if self.media_descriptor.get_protocol() == Protocols.HLS:
|
2014-02-14 15:07:51 +00:00
|
|
|
self.set_result(Result.PASSED,
|
|
|
|
"""Got no EOS 30 seconds after sending EOS,
|
|
|
|
in HLS known and tolerated issue:
|
|
|
|
https://bugzilla.gnome.org/show_bug.cgi?id=723868""")
|
|
|
|
return Result.KNOWN_ERROR
|
|
|
|
|
2014-04-25 11:19:19 +00:00
|
|
|
self.set_result(Result.FAILED, "Pipeline did not stop 30 Seconds after sending EOS")
|
|
|
|
|
2014-02-14 15:07:51 +00:00
|
|
|
return Result.FAILED
|
|
|
|
|
2014-01-30 11:42:25 +00:00
|
|
|
return self.get_current_position()
|
2014-01-09 08:14:27 +00:00
|
|
|
|
|
|
|
|
2014-01-13 10:13:02 +00:00
|
|
|
class GstValidateMediaCheckTest(Test):
|
2014-04-25 09:31:01 +00:00
|
|
|
def __init__(self, classname, options, reporter, media_descriptor, uri, minfo_path,
|
2014-04-02 10:12:11 +00:00
|
|
|
timeout=DEFAULT_TIMEOUT):
|
2014-01-30 14:40:21 +00:00
|
|
|
super(GstValidateMediaCheckTest, self).__init__(G_V_DISCOVERER_COMMAND, classname,
|
2014-01-13 10:13:02 +00:00
|
|
|
options, reporter,
|
2014-01-24 10:41:25 +00:00
|
|
|
timeout=timeout)
|
2014-01-13 10:13:02 +00:00
|
|
|
self._uri = uri
|
2014-04-25 09:31:01 +00:00
|
|
|
self.media_descriptor = media_descriptor
|
2014-04-02 10:12:11 +00:00
|
|
|
self._media_info_path = minfo_path
|
2014-01-13 10:13:02 +00:00
|
|
|
|
|
|
|
def build_arguments(self):
|
|
|
|
self.add_arguments(self._uri, "--expected-results",
|
|
|
|
self._media_info_path)
|
|
|
|
|
|
|
|
|
2014-07-16 10:03:14 +00:00
|
|
|
class GstValidateTranscodingTest(GstValidateTest, GstValidateEncodingTestInterface):
|
2014-06-26 10:42:38 +00:00
|
|
|
scenarios_manager = ScenarioManager()
|
2014-01-09 08:14:27 +00:00
|
|
|
def __init__(self, classname, options, reporter,
|
2014-05-07 09:30:09 +00:00
|
|
|
combination, uri, media_descriptor,
|
|
|
|
timeout=DEFAULT_TIMEOUT,
|
|
|
|
scenario=None):
|
2014-01-24 12:59:56 +00:00
|
|
|
|
2014-02-13 14:31:58 +00:00
|
|
|
Loggable.__init__(self)
|
|
|
|
|
2014-04-25 09:31:01 +00:00
|
|
|
file_dur = long(media_descriptor.get_duration()) / GST_SECOND
|
2014-07-16 08:09:32 +00:00
|
|
|
if not media_descriptor.get_num_tracks("video"):
|
|
|
|
self.debug("%s audio only file applying transcoding ratio."
|
|
|
|
"File 'duration' : %s" % (classname , file_dur))
|
|
|
|
duration = file_dur / AUDIO_ONLY_FILE_TRANSCODING_RATIO
|
|
|
|
else:
|
|
|
|
duration = file_dur
|
|
|
|
|
2014-01-24 12:59:56 +00:00
|
|
|
try:
|
2014-06-18 15:26:05 +00:00
|
|
|
timeout = GST_VALIDATE_PROTOCOL_TIMEOUTS[media_descriptor.get_protocol()]
|
2014-01-24 12:59:56 +00:00
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
2014-07-16 10:03:14 +00:00
|
|
|
super(GstValidateTranscodingTest, self).__init__(GST_VALIDATE_TRANSCODING_COMMAND,
|
|
|
|
classname,
|
|
|
|
options,
|
|
|
|
reporter,
|
|
|
|
duration=duration,
|
|
|
|
timeout=timeout,
|
|
|
|
scenario=scenario)
|
|
|
|
|
|
|
|
GstValidateEncodingTestInterface.__init__(self, combination, media_descriptor)
|
2014-01-24 12:59:56 +00:00
|
|
|
|
2014-04-25 09:31:01 +00:00
|
|
|
self.media_descriptor = media_descriptor
|
2014-01-09 08:14:27 +00:00
|
|
|
self.uri = uri
|
|
|
|
|
|
|
|
def set_rendering_info(self):
|
2014-02-06 16:22:36 +00:00
|
|
|
self.dest_file = path = os.path.join(self.options.dest,
|
|
|
|
self.classname.replace(".transcode.", os.sep).
|
|
|
|
replace(".", os.sep))
|
|
|
|
utils.mkdir(os.path.dirname(urlparse.urlsplit(self.dest_file).path))
|
2014-01-09 08:14:27 +00:00
|
|
|
if urlparse.urlparse(self.dest_file).scheme == "":
|
|
|
|
self.dest_file = path2url(self.dest_file)
|
|
|
|
|
2014-07-16 10:03:14 +00:00
|
|
|
profile = self.get_profile()
|
2014-01-09 08:14:27 +00:00
|
|
|
self.add_arguments("-o", profile)
|
|
|
|
|
|
|
|
def build_arguments(self):
|
2014-01-24 10:41:25 +00:00
|
|
|
GstValidateTest.build_arguments(self)
|
2014-01-09 08:14:27 +00:00
|
|
|
self.set_rendering_info()
|
|
|
|
self.add_arguments(self.uri, self.dest_file)
|
|
|
|
|
|
|
|
def get_current_value(self):
|
2014-02-14 15:07:51 +00:00
|
|
|
if self.scenario:
|
|
|
|
sent_eos = self.sent_eos_position()
|
|
|
|
if sent_eos is not None:
|
2014-02-19 12:07:03 +00:00
|
|
|
t = time.time()
|
|
|
|
if ((t - sent_eos)) > 30:
|
2014-04-25 09:31:01 +00:00
|
|
|
if self.media_descriptor.get_protocol() == Protocols.HLS:
|
2014-02-14 15:07:51 +00:00
|
|
|
self.set_result(Result.PASSED,
|
|
|
|
"""Got no EOS 30 seconds after sending EOS,
|
|
|
|
in HLS known and tolerated issue:
|
|
|
|
https://bugzilla.gnome.org/show_bug.cgi?id=723868""")
|
|
|
|
return Result.KNOWN_ERROR
|
|
|
|
|
2014-04-25 11:19:19 +00:00
|
|
|
self.set_result(Result.FAILED, "Pipeline did not stop 30 Seconds after sending EOS")
|
2014-02-19 12:07:03 +00:00
|
|
|
|
2014-02-14 15:07:51 +00:00
|
|
|
return Result.FAILED
|
2014-02-13 14:31:58 +00:00
|
|
|
|
2014-07-16 10:03:14 +00:00
|
|
|
size = self.get_current_size()
|
|
|
|
if size is None:
|
|
|
|
return self.get_current_position()
|
|
|
|
|
|
|
|
return size
|
2014-01-09 08:14:27 +00:00
|
|
|
|
2014-01-09 14:23:38 +00:00
|
|
|
def check_results(self):
|
2014-08-05 08:59:21 +00:00
|
|
|
if self.result in [Result.FAILED, Result.TIMEOUT] or \
|
|
|
|
self.process.returncode != 0:
|
2014-01-09 14:23:38 +00:00
|
|
|
GstValidateTest.check_results(self)
|
2014-05-07 09:30:39 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
if self.scenario:
|
|
|
|
orig_duration = min(long(self.scenario.get_duration()),
|
|
|
|
long(self.media_descriptor.get_duration()))
|
|
|
|
else:
|
|
|
|
orig_duration = long(self.media_descriptor.get_duration())
|
2014-07-16 10:03:14 +00:00
|
|
|
|
|
|
|
res, msg = self.check_encoded_file()
|
2014-05-07 09:30:39 +00:00
|
|
|
self.set_result(res, msg)
|
2014-01-09 14:23:38 +00:00
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
class GstValidateTestManager(GstValidateBaseTestManager):
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
name = "validate"
|
|
|
|
|
2014-08-10 10:41:57 +00:00
|
|
|
# List of all classes to create testsuites
|
|
|
|
GstValidateMediaCheckTestsGenerator = GstValidateMediaCheckTestsGenerator
|
|
|
|
GstValidateTranscodingTestsGenerator = GstValidateTranscodingTestsGenerator
|
|
|
|
GstValidatePipelineTestsGenerator = GstValidatePipelineTestsGenerator
|
|
|
|
GstValidatePlaybinTestsGenerator = GstValidatePlaybinTestsGenerator
|
|
|
|
GstValidateMixerTestsGenerator = GstValidateMixerTestsGenerator
|
|
|
|
GstValidateLaunchTest = GstValidateLaunchTest
|
|
|
|
GstValidateMediaCheckTest = GstValidateMediaCheckTest
|
|
|
|
GstValidateTranscodingTest = GstValidateTranscodingTest
|
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
def __init__(self):
|
2014-06-26 10:42:38 +00:00
|
|
|
super(GstValidateTestManager, self).__init__()
|
2014-01-08 08:49:38 +00:00
|
|
|
self._uris = []
|
2014-04-25 09:32:04 +00:00
|
|
|
self._run_defaults = True
|
2014-06-18 15:26:05 +00:00
|
|
|
self._is_populated = False
|
2014-06-26 10:42:38 +00:00
|
|
|
execfile(os.path.join(os.path.dirname(__file__), "apps",
|
2014-06-26 11:01:13 +00:00
|
|
|
"validate", "validate_testsuite.py"), globals())
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-09 14:17:53 +00:00
|
|
|
def init(self):
|
2014-01-30 14:40:21 +00:00
|
|
|
if which(GST_VALIDATE_COMMAND) and which(GST_VALIDATE_TRANSCODING_COMMAND):
|
2014-01-09 14:17:53 +00:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2014-04-30 13:40:10 +00:00
|
|
|
def add_options(self, parser):
|
|
|
|
group = parser.add_argument_group("GstValidate tools specific options"
|
|
|
|
" and behaviours",
|
2014-06-18 15:26:05 +00:00
|
|
|
description="""When using --wanted-tests, all the scenarios can be used, even those which have
|
2014-06-19 07:38:52 +00:00
|
|
|
not been tested and explicitely activated if you set use --wanted-tests ALL""")
|
2014-04-30 13:40:10 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
def populate_testsuite(self):
|
2014-06-18 15:26:05 +00:00
|
|
|
|
|
|
|
if self._is_populated is True:
|
|
|
|
return
|
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
if not self.options.config:
|
2014-06-26 11:01:13 +00:00
|
|
|
if self._run_defaults:
|
|
|
|
self.register_defaults()
|
|
|
|
else:
|
|
|
|
self.register_all()
|
2014-06-18 15:26:05 +00:00
|
|
|
|
|
|
|
self._is_populated = True
|
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
def list_tests(self):
|
2014-04-02 17:14:30 +00:00
|
|
|
if self.tests:
|
|
|
|
return self.tests
|
|
|
|
|
2014-06-18 10:51:02 +00:00
|
|
|
if self._run_defaults:
|
2014-06-26 10:42:38 +00:00
|
|
|
scenarios = [self.scenarios_manager.get_scenario(scenario_name)
|
|
|
|
for scenario_name in self.get_scenarios()]
|
2014-06-18 10:51:02 +00:00
|
|
|
else:
|
2014-06-26 10:42:38 +00:00
|
|
|
scenarios = self.scenarios_manager.get_scenario(None)
|
2014-06-18 10:51:02 +00:00
|
|
|
uris = self._list_uris()
|
2014-01-29 16:39:14 +00:00
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
for generator in self.get_generators():
|
2014-06-18 15:26:05 +00:00
|
|
|
for test in generator.generate_tests(uris, scenarios):
|
2014-06-18 10:51:02 +00:00
|
|
|
self.add_test(test)
|
2014-01-13 10:13:02 +00:00
|
|
|
|
2014-03-26 10:00:32 +00:00
|
|
|
return self.tests
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-07-16 10:50:41 +00:00
|
|
|
def _add_media(self, media_info, uri=None):
|
2014-01-08 17:51:14 +00:00
|
|
|
self.debug("Checking %s", media_info)
|
2014-07-16 10:50:41 +00:00
|
|
|
if isinstance(media_info, GstValidateMediaDescriptor):
|
|
|
|
media_descriptor = media_info
|
|
|
|
media_info = media_descriptor.get_path()
|
|
|
|
else:
|
|
|
|
media_descriptor = GstValidateMediaDescriptor(media_info)
|
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
try:
|
|
|
|
# Just testing that the vairous mandatory infos are present
|
2014-04-25 09:31:01 +00:00
|
|
|
caps = media_descriptor.get_caps()
|
2014-01-08 08:49:38 +00:00
|
|
|
if uri is None:
|
2014-04-25 09:31:01 +00:00
|
|
|
uri = media_descriptor.get_uri()
|
|
|
|
|
|
|
|
media_descriptor.set_protocol(urlparse.urlparse(uri).scheme)
|
2014-06-18 15:26:05 +00:00
|
|
|
for caps2, prot in GST_VALIDATE_CAPS_TO_PROTOCOL:
|
2014-01-08 08:49:38 +00:00
|
|
|
if caps2 == caps:
|
2014-04-25 09:31:01 +00:00
|
|
|
media_descriptor.set_protocol(prot)
|
2014-01-08 08:49:38 +00:00
|
|
|
break
|
2014-04-30 09:06:09 +00:00
|
|
|
|
|
|
|
scenario_bname = media_descriptor.get_media_filepath()
|
2014-06-26 10:42:38 +00:00
|
|
|
special_scenarios = self.scenarios_manager.find_special_scenarios(scenario_bname)
|
2014-01-13 10:13:02 +00:00
|
|
|
self._uris.append((uri,
|
|
|
|
NamedDic({"path": media_info,
|
2014-04-30 09:06:09 +00:00
|
|
|
"media_descriptor": media_descriptor}),
|
|
|
|
special_scenarios))
|
2014-01-08 08:49:38 +00:00
|
|
|
except ConfigParser.NoOptionError as e:
|
2014-01-08 17:51:14 +00:00
|
|
|
self.debug("Exception: %s for %s", e, media_info)
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
def _discover_file(self, uri, fpath):
|
|
|
|
try:
|
2014-07-16 08:10:44 +00:00
|
|
|
media_info = "%s.%s" % (fpath, GstValidateMediaDescriptor.MEDIA_INFO_EXT)
|
2014-01-30 14:40:21 +00:00
|
|
|
args = G_V_DISCOVERER_COMMAND.split(" ")
|
2014-01-08 08:49:38 +00:00
|
|
|
args.append(uri)
|
|
|
|
if os.path.isfile(media_info):
|
2014-07-16 10:50:41 +00:00
|
|
|
self._add_media(media_info, uri)
|
2014-01-13 10:13:02 +00:00
|
|
|
return True
|
2014-07-16 08:10:44 +00:00
|
|
|
elif fpath.endswith(GstValidateMediaDescriptor.STREAM_INFO_EXT):
|
2014-07-16 10:50:41 +00:00
|
|
|
self._add_media(fpath)
|
2014-01-13 10:13:02 +00:00
|
|
|
return True
|
2014-07-16 10:50:41 +00:00
|
|
|
elif not self.options.generate_info:
|
2014-01-10 14:29:31 +00:00
|
|
|
return True
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-07-16 10:50:41 +00:00
|
|
|
media_descriptor = GstValidateMediaDescriptor.new_from_uri(uri, True)
|
|
|
|
self._add_media(media_descriptor, uri)
|
2014-06-26 10:42:38 +00:00
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
return True
|
|
|
|
|
2014-01-08 17:51:14 +00:00
|
|
|
except subprocess.CalledProcessError as e:
|
2014-06-26 10:42:38 +00:00
|
|
|
if self.options.generate_info:
|
|
|
|
printc("Result: Failed", Colors.FAIL)
|
|
|
|
else:
|
|
|
|
self.error("Exception: %s", e)
|
2014-01-08 08:49:38 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
def _list_uris(self):
|
|
|
|
if self._uris:
|
|
|
|
return self._uris
|
|
|
|
|
|
|
|
if not self.args:
|
|
|
|
if isinstance(self.options.paths, str):
|
|
|
|
self.options.paths = [os.path.join(self.options.paths)]
|
|
|
|
|
|
|
|
for path in self.options.paths:
|
|
|
|
for root, dirs, files in os.walk(path):
|
|
|
|
for f in files:
|
2014-01-08 17:51:14 +00:00
|
|
|
fpath = os.path.join(path, root, f)
|
2014-04-30 09:06:09 +00:00
|
|
|
if os.path.isdir(fpath) or \
|
2014-07-16 08:10:44 +00:00
|
|
|
fpath.endswith(GstValidateMediaDescriptor.MEDIA_INFO_EXT) or\
|
2014-04-30 09:06:09 +00:00
|
|
|
fpath.endswith(ScenarioManager.FILE_EXTENDION):
|
2014-01-08 08:49:38 +00:00
|
|
|
continue
|
|
|
|
else:
|
|
|
|
self._discover_file(path2url(fpath), fpath)
|
|
|
|
|
2014-01-08 17:51:14 +00:00
|
|
|
self.debug("Uris found: %s", self._uris)
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
return self._uris
|
|
|
|
|
2014-01-13 16:31:57 +00:00
|
|
|
def needs_http_server(self):
|
2014-03-26 10:00:32 +00:00
|
|
|
for test in self.list_tests():
|
2014-06-18 10:51:02 +00:00
|
|
|
if self._is_test_wanted(test) and test.media_descriptor is not None:
|
2014-04-25 09:31:01 +00:00
|
|
|
protocol = test.media_descriptor.get_protocol()
|
|
|
|
uri = test.media_descriptor.get_uri()
|
2014-03-26 10:00:32 +00:00
|
|
|
|
2014-08-09 14:34:09 +00:00
|
|
|
if protocol in [Protocols.HTTP, Protocols.HLS, Protocols.DASH] and \
|
2014-01-13 16:31:57 +00:00
|
|
|
"127.0.0.1:%s" % (self.options.http_server_port) in uri:
|
2014-03-26 10:00:32 +00:00
|
|
|
return True
|
|
|
|
return False
|
2014-01-30 11:20:33 +00:00
|
|
|
|
2014-04-25 09:32:04 +00:00
|
|
|
def set_settings(self, options, args, reporter):
|
2014-06-19 07:38:52 +00:00
|
|
|
if options.wanted_tests:
|
|
|
|
for i in range(len(options.wanted_tests)):
|
|
|
|
if "ALL" in options.wanted_tests[i]:
|
|
|
|
self._run_defaults = False
|
|
|
|
options.wanted_tests[i] = options.wanted_tests[i].replace("ALL", "")
|
|
|
|
try:
|
|
|
|
options.wanted_tests.remove("")
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
|
2014-06-26 10:42:38 +00:00
|
|
|
super(GstValidateTestManager, self).set_settings(options, args, reporter)
|
2014-06-18 10:51:02 +00:00
|
|
|
|
2014-06-19 14:26:43 +00:00
|
|
|
def gst_validate_checkout_element_present(element_name):
|
|
|
|
null = open(os.devnull)
|
|
|
|
return subprocess.call("gst-inspect-1.0 videmixer", shell=True, stdout=null, stderr=null)
|