2014-01-08 08:49:38 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# 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-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-04-25 08:23:21 +00:00
|
|
|
import xml.etree.ElementTree as ET
|
2014-01-08 17:51:14 +00:00
|
|
|
from loggable import Loggable
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-02-12 10:18:14 +00:00
|
|
|
from baseclasses import GstValidateTest, TestsManager, Test, ScenarioManager, NamedDic
|
2014-01-09 08:39:05 +00:00
|
|
|
from utils import MediaFormatCombination, get_profile,\
|
2014-01-30 11:42:25 +00:00
|
|
|
path2url, DEFAULT_TIMEOUT, which, GST_SECOND, Result, \
|
2014-01-30 15:58:58 +00:00
|
|
|
compare_rendered_with_original, Protocols
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-04-25 11:17:39 +00:00
|
|
|
class MediaDescriptor(Loggable):
|
2014-04-25 09:31:01 +00:00
|
|
|
def __init__(self, xml_path):
|
2014-04-25 11:17:39 +00:00
|
|
|
Loggable.__init__(self)
|
2014-04-30 09:06:09 +00:00
|
|
|
self._xml_path = xml_path
|
2014-04-25 09:31:01 +00:00
|
|
|
self.media_xml = ET.parse(xml_path).getroot()
|
|
|
|
|
|
|
|
# Sanity checks
|
|
|
|
self.media_xml.attrib["duration"]
|
|
|
|
self.media_xml.attrib["seekable"]
|
|
|
|
|
2014-04-30 09:06:09 +00:00
|
|
|
def get_media_filepath(self):
|
|
|
|
if self.get_protocol() == Protocols.FILE:
|
|
|
|
return self._xml_path.replace("." + G_V_MEDIA_INFO_EXT, "")
|
|
|
|
else:
|
|
|
|
return self._xml_path.replace("." + G_V_STREAM_INFO_EXT, "")
|
|
|
|
|
|
|
|
|
2014-04-25 09:31:01 +00:00
|
|
|
def get_caps(self):
|
|
|
|
return self.media_xml.findall("streams")[0].attrib["caps"]
|
|
|
|
|
|
|
|
def get_uri(self):
|
|
|
|
return self.media_xml.attrib["uri"]
|
|
|
|
|
|
|
|
def get_duration(self):
|
|
|
|
return self.media_xml.attrib["duration"]
|
|
|
|
|
|
|
|
def set_protocol(self, protocol):
|
|
|
|
self.media_xml.attrib["protocol"] = protocol
|
|
|
|
|
|
|
|
def get_protocol(self):
|
|
|
|
return self.media_xml.attrib["protocol"]
|
|
|
|
|
|
|
|
def is_seekable(self):
|
|
|
|
return self.media_xml.attrib["seekable"]
|
|
|
|
|
|
|
|
def is_image(self):
|
|
|
|
for stream in self.media_xml.findall("streams")[0].findall("stream"):
|
|
|
|
if stream.attrib["type"] == "image":
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2014-04-29 17:04:46 +00:00
|
|
|
def get_num_tracks(self, track_type):
|
|
|
|
n = 0
|
2014-04-25 11:17:39 +00:00
|
|
|
for stream in self.media_xml.findall("streams")[0].findall("stream"):
|
2014-04-29 17:04:46 +00:00
|
|
|
if stream.attrib["type"] == track_type:
|
|
|
|
n += 1
|
2014-04-25 09:31:01 +00:00
|
|
|
|
2014-04-29 17:04:46 +00:00
|
|
|
return n
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-04-25 11:17:39 +00:00
|
|
|
def is_compatible(self, scenario):
|
|
|
|
if scenario.seeks() and (not self.is_seekable() or self.is_image()):
|
|
|
|
self.debug("Do not run %s as %s does not support seeking",
|
|
|
|
scenario, self.get_uri())
|
|
|
|
return False
|
|
|
|
|
2014-04-29 17:04:46 +00:00
|
|
|
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
|
2014-04-25 11:17:39 +00:00
|
|
|
|
|
|
|
return True
|
|
|
|
|
2014-01-30 15:59:21 +00:00
|
|
|
class PipelineDescriptor(object):
|
|
|
|
def __init__(self, name, pipeline):
|
|
|
|
self.name = name
|
|
|
|
self._pipeline = pipeline
|
|
|
|
|
|
|
|
def needs_uri(self):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def get_pipeline(self, protocol=Protocols.FILE, uri=""):
|
|
|
|
return self._pipeline
|
|
|
|
|
|
|
|
|
|
|
|
class PlaybinDescriptor(PipelineDescriptor):
|
|
|
|
def __init__(self):
|
|
|
|
PipelineDescriptor.__init__(self, "playbin", "playbin")
|
|
|
|
|
|
|
|
def needs_uri(self):
|
|
|
|
return True
|
|
|
|
|
|
|
|
def get_pipeline(self, options, protocol, scenario, uri):
|
|
|
|
pipe = self._pipeline
|
|
|
|
if options.mute:
|
2014-04-22 08:49:10 +00:00
|
|
|
fakesink = "'fakesink sync=true'"
|
2014-01-30 15:59:21 +00:00
|
|
|
pipe += " audio-sink=%s video-sink=%s" %(fakesink, fakesink)
|
|
|
|
|
|
|
|
pipe += " uri=%s" % uri
|
|
|
|
|
2014-04-25 11:17:39 +00:00
|
|
|
if scenario.does_reverse_playback() and protocol == Protocols.HTTP:
|
2014-04-17 10:58:48 +00:00
|
|
|
# 10MB so we can reverse playback
|
|
|
|
pipe += " ring-buffer-max-size=10485760"
|
2014-01-30 15:59:21 +00:00
|
|
|
|
|
|
|
return pipe
|
|
|
|
|
2014-01-30 15:58:58 +00:00
|
|
|
# definitions of commands to use
|
2014-01-30 14:40:21 +00:00
|
|
|
GST_VALIDATE_COMMAND = "gst-validate-1.0"
|
|
|
|
GST_VALIDATE_TRANSCODING_COMMAND = "gst-validate-transcoding-1.0"
|
2014-03-28 14:01:12 +00:00
|
|
|
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-01-14 09:32:53 +00:00
|
|
|
|
2014-01-30 15:58:58 +00:00
|
|
|
# Some extension file for discovering results
|
2014-01-30 14:40:21 +00:00
|
|
|
G_V_MEDIA_INFO_EXT = "media_info"
|
|
|
|
G_V_STREAM_INFO_EXT = "stream_info"
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-30 15:58:58 +00:00
|
|
|
# Some info about protocols and how to handle them
|
|
|
|
G_V_CAPS_TO_PROTOCOL = [("application/x-hls", Protocols.HLS)]
|
2014-01-30 23:22:57 +00:00
|
|
|
G_V_PROTOCOL_TIMEOUTS = {Protocols.HTTP: 120,
|
|
|
|
Protocols.HLS: 240}
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-30 15:58:58 +00:00
|
|
|
# Tests descriptions
|
|
|
|
G_V_PLAYBACK_TESTS = [PlaybinDescriptor()]
|
2014-01-30 14:40:21 +00:00
|
|
|
|
2014-01-30 15:58:58 +00:00
|
|
|
# Description of wanted output formats for transcoding test
|
2014-01-30 14:40:21 +00:00
|
|
|
G_V_ENCODING_TARGET_COMBINATIONS = [
|
2014-01-09 08:14:27 +00:00
|
|
|
MediaFormatCombination("ogg", "vorbis", "theora"),
|
|
|
|
MediaFormatCombination("webm", "vorbis", "vp8"),
|
|
|
|
MediaFormatCombination("mp4", "mp3", "h264"),
|
|
|
|
MediaFormatCombination("mkv", "vorbis", "h264")]
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-30 15:58:58 +00:00
|
|
|
|
|
|
|
# List of scenarios to run depending on the protocol in use
|
2014-02-12 10:18:14 +00:00
|
|
|
G_V_SCENARIOS = {Protocols.FILE: ["play_15s",
|
|
|
|
"reverse_playback",
|
|
|
|
"fast_forward",
|
|
|
|
"seek_forward",
|
|
|
|
"seek_backward",
|
|
|
|
"seek_with_stop",
|
2014-04-29 16:51:54 +00:00
|
|
|
"switch_audio_track",
|
|
|
|
"switch_audio_track_while_paused",
|
2014-04-29 17:04:46 +00:00
|
|
|
"switch_subtitle_track",
|
2014-02-12 10:18:14 +00:00
|
|
|
"scrub_forward_seeking"],
|
|
|
|
Protocols.HTTP: ["play_15s",
|
|
|
|
"fast_forward",
|
|
|
|
"seek_forward",
|
|
|
|
"seek_backward",
|
|
|
|
"seek_with_stop",
|
2014-04-29 16:51:54 +00:00
|
|
|
"switch_audio_track",
|
|
|
|
"switch_audio_track_while_paused",
|
2014-04-29 17:04:46 +00:00
|
|
|
"switch_subtitle_track",
|
2014-02-12 10:18:14 +00:00
|
|
|
"reverse_playback"],
|
|
|
|
Protocols.HLS: ["play_15s",
|
|
|
|
"fast_forward",
|
|
|
|
"seek_forward",
|
|
|
|
"seek_with_stop",
|
2014-04-29 16:51:54 +00:00
|
|
|
"switch_audio_track",
|
|
|
|
"switch_audio_track_while_paused",
|
2014-04-29 17:04:46 +00:00
|
|
|
"switch_subtitle_track",
|
2014-02-12 10:18:14 +00:00
|
|
|
"seek_backward"],
|
2014-01-30 15:58:58 +00:00
|
|
|
}
|
2014-01-13 10:13:02 +00:00
|
|
|
|
2014-02-13 14:33:25 +00:00
|
|
|
G_V_PROTOCOL_VIDEO_RESTRICTION_CAPS = {
|
|
|
|
# Handle the unknown framerate in HLS samples
|
|
|
|
Protocols.HLS: "video/x-raw,framerate=25/1"
|
|
|
|
}
|
|
|
|
|
2014-01-30 23:22:57 +00:00
|
|
|
G_V_BLACKLISTED_TESTS = \
|
|
|
|
[("validate.hls.playback.fast_forward.*",
|
|
|
|
"https://bugzilla.gnome.org/show_bug.cgi?id=698155"),
|
|
|
|
("validate.hls.playback.seek_with_stop.*",
|
|
|
|
"https://bugzilla.gnome.org/show_bug.cgi?id=723268"),
|
|
|
|
("validate.*.reverse_playback.*webm$",
|
|
|
|
"https://bugzilla.gnome.org/show_bug.cgi?id=679250"),
|
2014-04-25 11:17:39 +00:00
|
|
|
("validate.*.playback.reverse_playback.*ts|validate.*.playback.reverse_playback.*MTS",
|
2014-04-25 09:31:27 +00:00
|
|
|
"https://bugzilla.gnome.org/show_bug.cgi?id=702595"),
|
2014-01-30 23:22:57 +00:00
|
|
|
("validate.http.playback.seek_with_stop.*webm",
|
|
|
|
"matroskademux.gst_matroska_demux_handle_seek_push: Seek end-time not supported in streaming mode"),
|
|
|
|
("validate.http.playback.seek_with_stop.*mkv",
|
2014-04-25 09:31:27 +00:00
|
|
|
"matroskademux.gst_matroska_demux_handle_seek_push: Seek end-time not supported in streaming mode"),
|
2014-04-30 09:20:43 +00:00
|
|
|
("validate.*Sintel.*reverse.*mkv",
|
|
|
|
"TODO in matroskademux: FIXME: We should build an index during playback or "
|
|
|
|
"when scanning that can be used here. The reverse playback code requires "
|
|
|
|
" seek_index and seek_entry to be set!")
|
2014-01-30 23:22:57 +00:00
|
|
|
]
|
2014-01-30 11:20:33 +00:00
|
|
|
|
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-04-25 09:31:01 +00:00
|
|
|
timeout = G_V_PROTOCOL_TIMEOUTS[media_descriptor.get_protocol()]
|
2014-01-24 10:31:42 +00:00
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
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-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-01-09 08:14:27 +00:00
|
|
|
class GstValidateTranscodingTest(GstValidateTest):
|
2014-02-12 10:18:14 +00:00
|
|
|
_scenarios = ScenarioManager()
|
2014-01-09 08:14:27 +00:00
|
|
|
def __init__(self, classname, options, reporter,
|
2014-04-25 09:31:01 +00:00
|
|
|
combination, uri, media_descriptor, timeout=DEFAULT_TIMEOUT,
|
2014-02-12 10:18:14 +00:00
|
|
|
scenario_name="play_15s"):
|
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-02-13 14:31:58 +00:00
|
|
|
if file_dur < 30:
|
|
|
|
self.debug("%s is short (%ds< 30 secs) playing it all" % (uri, file_dur))
|
|
|
|
scenario = None
|
|
|
|
else:
|
|
|
|
self.debug("%s is long (%ds > 30 secs) playing it all" % (uri, file_dur))
|
|
|
|
scenario = self._scenarios.get_scenario(scenario_name)
|
2014-01-24 12:59:56 +00:00
|
|
|
try:
|
2014-04-25 09:31:01 +00:00
|
|
|
timeout = G_V_PROTOCOL_TIMEOUTS[media_descriptor.get_protocol()]
|
2014-01-24 12:59:56 +00:00
|
|
|
except KeyError:
|
|
|
|
pass
|
|
|
|
|
2014-02-12 10:18:14 +00:00
|
|
|
try:
|
|
|
|
hard_timeout = 4 * int(scenario.duration) + timeout
|
|
|
|
except AttributeError:
|
2014-01-24 12:59:56 +00:00
|
|
|
hard_timeout = None
|
2014-01-09 08:14:27 +00:00
|
|
|
|
|
|
|
super(GstValidateTranscodingTest, self).__init__(
|
2014-01-30 14:40:21 +00:00
|
|
|
GST_VALIDATE_TRANSCODING_COMMAND, classname,
|
2014-01-24 12:59:56 +00:00
|
|
|
options, reporter, scenario=scenario, timeout=timeout,
|
|
|
|
hard_timeout=hard_timeout)
|
|
|
|
|
2014-04-25 09:31:01 +00:00
|
|
|
self.media_descriptor = media_descriptor
|
2014-01-09 08:14:27 +00:00
|
|
|
self.uri = uri
|
|
|
|
self.combination = combination
|
|
|
|
self.dest_file = ""
|
|
|
|
|
|
|
|
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-02-13 14:33:25 +00:00
|
|
|
try:
|
2014-04-25 09:31:01 +00:00
|
|
|
video_restriction = G_V_PROTOCOL_VIDEO_RESTRICTION_CAPS[self.media_descriptor.get_protocol()]
|
2014-02-13 14:33:25 +00:00
|
|
|
except KeyError:
|
|
|
|
video_restriction = None
|
|
|
|
|
|
|
|
profile = get_profile(self.combination, video_restriction=video_restriction)
|
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-01-30 11:42:25 +00:00
|
|
|
return self.get_current_size()
|
2014-01-09 08:14:27 +00:00
|
|
|
|
2014-01-09 14:23:38 +00:00
|
|
|
def check_results(self):
|
2014-02-14 15:07:51 +00:00
|
|
|
if self.result is Result.PASSED and not self.scenario:
|
2014-04-25 09:31:01 +00:00
|
|
|
orig_duration = long(self.media_descriptor.get_duration())
|
2014-01-09 14:23:38 +00:00
|
|
|
res, msg = compare_rendered_with_original(orig_duration, self.dest_file)
|
|
|
|
self.set_result(res, msg)
|
2014-02-13 14:31:58 +00:00
|
|
|
elif self.message == "":
|
2014-01-09 14:23:38 +00:00
|
|
|
GstValidateTest.check_results(self)
|
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-08 17:51:14 +00:00
|
|
|
class GstValidateManager(TestsManager, Loggable):
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
name = "validate"
|
2014-02-12 10:18:14 +00:00
|
|
|
_scenarios = ScenarioManager()
|
|
|
|
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
def __init__(self):
|
2014-01-08 17:51:14 +00:00
|
|
|
TestsManager.__init__(self)
|
|
|
|
Loggable.__init__(self)
|
2014-01-08 08:49:38 +00:00
|
|
|
self._uris = []
|
2014-04-25 09:32:04 +00:00
|
|
|
self._run_defaults = True
|
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-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-01-30 14:40:21 +00:00
|
|
|
for test_pipeline in G_V_PLAYBACK_TESTS:
|
2014-01-24 10:41:25 +00:00
|
|
|
self._add_playback_test(test_pipeline)
|
2014-01-09 08:14:27 +00:00
|
|
|
|
2014-04-30 09:06:09 +00:00
|
|
|
for uri, mediainfo, special_scenarios in self._list_uris():
|
2014-04-25 09:31:01 +00:00
|
|
|
protocol = mediainfo.media_descriptor.get_protocol()
|
2014-01-29 16:39:14 +00:00
|
|
|
try:
|
2014-02-13 14:34:10 +00:00
|
|
|
timeout = G_V_PROTOCOL_TIMEOUTS[protocol]
|
2014-01-29 16:39:14 +00:00
|
|
|
except KeyError:
|
|
|
|
timeout = DEFAULT_TIMEOUT
|
|
|
|
|
2014-02-13 14:34:10 +00:00
|
|
|
classname = "validate.%s.media_check.%s" % (protocol,
|
|
|
|
os.path.basename(uri).replace(".", "_"))
|
2014-01-22 23:15:54 +00:00
|
|
|
self.add_test(GstValidateMediaCheckTest(classname,
|
|
|
|
self.options,
|
|
|
|
self.reporter,
|
2014-04-25 09:31:01 +00:00
|
|
|
mediainfo.media_descriptor,
|
2014-01-24 10:41:25 +00:00
|
|
|
uri,
|
2014-04-02 10:12:11 +00:00
|
|
|
mediainfo.path,
|
2014-01-24 10:41:25 +00:00
|
|
|
timeout=timeout))
|
2014-01-13 10:13:02 +00:00
|
|
|
|
2014-04-30 09:06:09 +00:00
|
|
|
for uri, mediainfo, special_scenarios in self._list_uris():
|
2014-04-25 09:31:01 +00:00
|
|
|
if mediainfo.media_descriptor.is_image():
|
2014-01-10 11:41:30 +00:00
|
|
|
continue
|
2014-01-30 14:40:21 +00:00
|
|
|
for comb in G_V_ENCODING_TARGET_COMBINATIONS:
|
2014-04-25 09:31:01 +00:00
|
|
|
classname = "validate.%s.transcode.to_%s.%s" % (mediainfo.media_descriptor.get_protocol(),
|
2014-01-14 09:32:53 +00:00
|
|
|
str(comb).replace(' ', '_'),
|
2014-01-30 23:22:57 +00:00
|
|
|
os.path.basename(uri).replace(".", "_"))
|
2014-01-22 23:15:54 +00:00
|
|
|
self.add_test(GstValidateTranscodingTest(classname,
|
|
|
|
self.options,
|
|
|
|
self.reporter,
|
|
|
|
comb, uri,
|
2014-04-25 09:31:01 +00:00
|
|
|
mediainfo.media_descriptor))
|
2014-03-26 10:00:32 +00:00
|
|
|
return self.tests
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
def _check_discovering_info(self, media_info, uri=None):
|
2014-01-08 17:51:14 +00:00
|
|
|
self.debug("Checking %s", media_info)
|
2014-04-25 09:31:01 +00:00
|
|
|
media_descriptor = MediaDescriptor(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-01-30 14:40:21 +00:00
|
|
|
for caps2, prot in G_V_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()
|
|
|
|
special_scenarios = self._scenarios.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-01-30 14:40:21 +00:00
|
|
|
media_info = "%s.%s" % (fpath, G_V_MEDIA_INFO_EXT)
|
|
|
|
args = G_V_DISCOVERER_COMMAND.split(" ")
|
2014-01-08 08:49:38 +00:00
|
|
|
args.append(uri)
|
|
|
|
if os.path.isfile(media_info):
|
2014-01-13 10:13:02 +00:00
|
|
|
self._check_discovering_info(media_info, uri)
|
|
|
|
return True
|
2014-01-30 14:40:21 +00:00
|
|
|
elif fpath.endswith(G_V_STREAM_INFO_EXT):
|
2014-01-13 10:13:02 +00:00
|
|
|
self._check_discovering_info(fpath)
|
|
|
|
return True
|
2014-01-10 14:29:31 +00:00
|
|
|
elif self.options.generate_info:
|
2014-01-08 08:49:38 +00:00
|
|
|
args.extend(["--output-file", media_info])
|
2014-01-10 14:29:31 +00:00
|
|
|
else:
|
|
|
|
return True
|
2014-01-08 08:49:38 +00:00
|
|
|
|
|
|
|
subprocess.check_output(args)
|
|
|
|
self._check_discovering_info(media_info, uri)
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
2014-01-08 17:51:14 +00:00
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
self.debug("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 \
|
|
|
|
fpath.endswith(G_V_MEDIA_INFO_EXT) or\
|
|
|
|
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-14 09:32:53 +00:00
|
|
|
def _get_fname(self, scenario, protocol=None):
|
2014-01-24 10:41:25 +00:00
|
|
|
if scenario is not None and scenario.name.lower() != "none":
|
|
|
|
return "%s.%s.%s.%s" % ("validate", protocol, "playback", scenario.name)
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-14 09:32:53 +00:00
|
|
|
return "%s.%s.%s" % ("validate", protocol, "playback")
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-30 15:59:21 +00:00
|
|
|
def _add_playback_test(self, pipe_descriptor):
|
|
|
|
if pipe_descriptor.needs_uri():
|
2014-04-30 09:06:09 +00:00
|
|
|
for uri, minfo, special_scenarios in self._list_uris():
|
2014-04-25 09:31:01 +00:00
|
|
|
protocol = minfo.media_descriptor.get_protocol()
|
|
|
|
if self._run_defaults:
|
|
|
|
scenarios = [self._scenarios.get_scenario(scenario_name)
|
|
|
|
for scenario_name in G_V_SCENARIOS[protocol]]
|
|
|
|
else:
|
|
|
|
scenarios = self._scenarios.get_scenario(None)
|
|
|
|
|
2014-04-30 09:06:09 +00:00
|
|
|
scenarios.extend(special_scenarios)
|
2014-04-25 09:31:01 +00:00
|
|
|
for scenario in scenarios:
|
2014-04-25 11:17:39 +00:00
|
|
|
if not minfo.media_descriptor.is_compatible(scenario):
|
|
|
|
continue
|
|
|
|
|
2014-01-30 15:59:21 +00:00
|
|
|
npipe = pipe_descriptor.get_pipeline(self.options,
|
|
|
|
protocol,
|
2014-02-12 10:18:14 +00:00
|
|
|
scenario,
|
|
|
|
uri)
|
2014-01-08 08:49:38 +00:00
|
|
|
|
2014-01-24 10:41:25 +00:00
|
|
|
fname = "%s.%s" % (self._get_fname(scenario,
|
|
|
|
protocol),
|
|
|
|
os.path.basename(uri).replace(".", "_"))
|
|
|
|
self.debug("Adding: %s", fname)
|
|
|
|
|
|
|
|
self.add_test(GstValidateLaunchTest(fname,
|
|
|
|
self.options,
|
|
|
|
self.reporter,
|
2014-01-30 15:59:21 +00:00
|
|
|
npipe,
|
2014-01-24 10:41:25 +00:00
|
|
|
scenario=scenario,
|
2014-04-25 09:31:01 +00:00
|
|
|
media_descriptor=minfo.media_descriptor)
|
2014-01-08 08:49:38 +00:00
|
|
|
)
|
|
|
|
else:
|
2014-01-22 23:15:54 +00:00
|
|
|
self.add_test(GstValidateLaunchTest(self._get_fname(scenario, "testing"),
|
|
|
|
self.options,
|
|
|
|
self.reporter,
|
2014-01-30 15:59:21 +00:00
|
|
|
pipe_descriptor.get_pipeline(self.options),
|
2014-01-22 23:15:54 +00:00
|
|
|
scenario=scenario))
|
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():
|
|
|
|
if self._is_test_wanted(test):
|
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
|
|
|
|
|
|
|
if protocol == Protocols.HTTP 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
|
|
|
|
|
|
|
def get_blacklisted(self):
|
|
|
|
return G_V_BLACKLISTED_TESTS
|
2014-04-25 09:32:04 +00:00
|
|
|
|
|
|
|
def set_settings(self, options, args, reporter):
|
|
|
|
TestsManager.set_settings(self, options, args, reporter)
|
2014-04-25 11:18:41 +00:00
|
|
|
if options.wanted_tests and not [d for d in options.wanted_tests
|
|
|
|
if "defaults_only" in d]:
|
2014-04-25 09:32:04 +00:00
|
|
|
self._run_defaults = False
|