From 265688fcd659e0985b4089fdc67d03dbfe9ef6d8 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 16 Jul 2014 12:16:03 +0200 Subject: [PATCH] validate:launcher: Move MediaFormatCombination to baseclasses.py + Add some simple helpers --- validate/tools/launcher/apps/ges-launch.py | 10 ++-- validate/tools/launcher/apps/gst-validate.py | 2 +- validate/tools/launcher/baseclasses.py | 38 ++++++++++++-- validate/tools/launcher/utils.py | 52 -------------------- 4 files changed, 41 insertions(+), 61 deletions(-) diff --git a/validate/tools/launcher/apps/ges-launch.py b/validate/tools/launcher/apps/ges-launch.py index dd0d5c9705..a5e6ae7e29 100644 --- a/validate/tools/launcher/apps/ges-launch.py +++ b/validate/tools/launcher/apps/ges-launch.py @@ -24,7 +24,7 @@ import subprocess import utils from urllib import unquote import xml.etree.ElementTree as ET -from baseclasses import GstValidateTest, TestsManager, ScenarioManager +from baseclasses import GstValidateTest, TestsManager, ScenarioManager, MediaFormatCombination GES_DURATION_TOLERANCE = utils.GST_SECOND / 2 @@ -34,10 +34,10 @@ if "win32" in sys.platform: GES_ENCODING_TARGET_COMBINATIONS = [ - utils.MediaFormatCombination("ogg", "vorbis", "theora"), - utils.MediaFormatCombination("webm", "vorbis", "vp8"), - utils.MediaFormatCombination("mp4", "mp3", "h264"), - utils.MediaFormatCombination("mkv", "vorbis", "h264")] + MediaFormatCombination("ogg", "vorbis", "theora"), + MediaFormatCombination("webm", "vorbis", "vp8"), + MediaFormatCombination("mp4", "mp3", "h264"), + MediaFormatCombination("mkv", "vorbis", "h264")] def quote_uri(uri): diff --git a/validate/tools/launcher/apps/gst-validate.py b/validate/tools/launcher/apps/gst-validate.py index 130d1868ed..05d62d2e85 100644 --- a/validate/tools/launcher/apps/gst-validate.py +++ b/validate/tools/launcher/apps/gst-validate.py @@ -27,7 +27,7 @@ from baseclasses import GstValidateTest, TestsManager, Test, \ ScenarioManager, NamedDic, GstValidateTestsGenerator, \ GstValidateMediaDescriptor -from utils import MediaFormatCombination, path2url, DEFAULT_TIMEOUT, which, \ +from utils import path2url, DEFAULT_TIMEOUT, which, \ GST_SECOND, Result, Protocols ###################################### diff --git a/validate/tools/launcher/baseclasses.py b/validate/tools/launcher/baseclasses.py index 1e85c22447..3a6aca7814 100644 --- a/validate/tools/launcher/baseclasses.py +++ b/validate/tools/launcher/baseclasses.py @@ -478,8 +478,8 @@ class GstValidateEncodingTestInterface(object): return ret.replace("::", ":") def get_profile(self, video_restriction=None, audio_restriction=None): - vcaps = utils.FORMATS[self.combination.vcodec] - acaps = utils.FORMATS[self.combination.acodec] + vcaps = self.combination.get_video_caps() + acaps = self.combination.get_audio_caps() if self.media_descriptor is not None: if self.media_descriptor.get_num_tracks("video") == 0: vcaps = None @@ -487,7 +487,7 @@ class GstValidateEncodingTestInterface(object): if self.media_descriptor.get_num_tracks("audio") == 0: acaps = None - return self._get_profile_full(utils.FORMATS[self.combination.container], + return self._get_profile_full(self.combination.get_muxer_caps(), vcaps, acaps, video_restriction=video_restriction, audio_restriction=audio_restriction) @@ -1037,3 +1037,35 @@ class GstValidateMediaDescriptor(MediaDescriptor): n += 1 return n + + +class MediaFormatCombination(object): + _FORMATS = {"aac": "audio/mpeg,mpegversion=4", + "ac3": "audio/x-ac3", + "vorbis": "audio/x-vorbis", + "mp3": "audio/mpeg,mpegversion=1,layer=3", + "h264": "video/x-h264", + "vp8": "video/x-vp8", + "theora": "video/x-theora", + "ogg": "application/ogg", + "mkv": "video/x-matroska", + "mp4": "video/quicktime,variant=iso;", + "webm": "video/webm"} + + + def __str__(self): + return "%s and %s in %s" % (self.acodec, self.vcodec, self.container) + + def __init__(self, container, acodec, vcodec): + self.container = container + self.acodec = acodec + self.vcodec = vcodec + + def get_audio_caps(self): + return self._FORMATS[self.acodec] + + def get_video_caps(self): + return self._FORMATS[self.vcodec] + + def get_muxer_caps(self): + return self._FORMATS[self.container] diff --git a/validate/tools/launcher/utils.py b/validate/tools/launcher/utils.py index 5de7341abe..03cddef3d1 100644 --- a/validate/tools/launcher/utils.py +++ b/validate/tools/launcher/utils.py @@ -170,58 +170,6 @@ def TIME_ARGS(time): (time / GST_SECOND) % 60, time % GST_SECOND) -############################## -# Encoding related utils # -############################## -class MediaFormatCombination(object): - - def __str__(self): - return "%s and %s in %s" % (self.acodec, self.vcodec, self.container) - - def __init__(self, container, acodec, vcodec): - self.container = container - self.acodec = acodec - self.vcodec = vcodec - - -FORMATS = {"aac": "audio/mpeg,mpegversion=4", - "ac3": "audio/x-ac3", - "vorbis": "audio/x-vorbis", - "mp3": "audio/mpeg,mpegversion=1,layer=3", - "h264": "video/x-h264", - "vp8": "video/x-vp8", - "theora": "video/x-theora", - "ogg": "application/ogg", - "mkv": "video/x-matroska", - "mp4": "video/quicktime,variant=iso;", - "webm": "video/webm"} - - -def get_profile_full(muxer, venc, aenc, video_restriction=None, - audio_restriction=None, - audio_presence=0, video_presence=0): - ret = "\"" - if muxer: - ret += muxer - ret += ":" - if venc: - if video_restriction is not None: - ret = ret + video_restriction + '->' - ret += venc - if video_presence: - ret = ret + '|' + str(video_presence) - if aenc: - ret += ":" - if audio_restriction is not None: - ret = ret + audio_restriction + '->' - ret += aenc - if audio_presence: - ret = ret + '|' + str(audio_presence) - - ret += "\"" - return ret.replace("::", ":") - - ################################################## # Some utilities to parse gst-validate output # ##################################################