validate:launcher: Move MediaFormatCombination to baseclasses.py

+ Add some simple helpers
This commit is contained in:
Thibault Saunier 2014-07-16 12:16:03 +02:00
parent f1163d61ba
commit 265688fcd6
4 changed files with 41 additions and 61 deletions

View file

@ -24,7 +24,7 @@ import subprocess
import utils import utils
from urllib import unquote from urllib import unquote
import xml.etree.ElementTree as ET 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 GES_DURATION_TOLERANCE = utils.GST_SECOND / 2
@ -34,10 +34,10 @@ if "win32" in sys.platform:
GES_ENCODING_TARGET_COMBINATIONS = [ GES_ENCODING_TARGET_COMBINATIONS = [
utils.MediaFormatCombination("ogg", "vorbis", "theora"), MediaFormatCombination("ogg", "vorbis", "theora"),
utils.MediaFormatCombination("webm", "vorbis", "vp8"), MediaFormatCombination("webm", "vorbis", "vp8"),
utils.MediaFormatCombination("mp4", "mp3", "h264"), MediaFormatCombination("mp4", "mp3", "h264"),
utils.MediaFormatCombination("mkv", "vorbis", "h264")] MediaFormatCombination("mkv", "vorbis", "h264")]
def quote_uri(uri): def quote_uri(uri):

View file

@ -27,7 +27,7 @@ from baseclasses import GstValidateTest, TestsManager, Test, \
ScenarioManager, NamedDic, GstValidateTestsGenerator, \ ScenarioManager, NamedDic, GstValidateTestsGenerator, \
GstValidateMediaDescriptor GstValidateMediaDescriptor
from utils import MediaFormatCombination, path2url, DEFAULT_TIMEOUT, which, \ from utils import path2url, DEFAULT_TIMEOUT, which, \
GST_SECOND, Result, Protocols GST_SECOND, Result, Protocols
###################################### ######################################

View file

@ -478,8 +478,8 @@ class GstValidateEncodingTestInterface(object):
return ret.replace("::", ":") return ret.replace("::", ":")
def get_profile(self, video_restriction=None, audio_restriction=None): def get_profile(self, video_restriction=None, audio_restriction=None):
vcaps = utils.FORMATS[self.combination.vcodec] vcaps = self.combination.get_video_caps()
acaps = utils.FORMATS[self.combination.acodec] acaps = self.combination.get_audio_caps()
if self.media_descriptor is not None: if self.media_descriptor is not None:
if self.media_descriptor.get_num_tracks("video") == 0: if self.media_descriptor.get_num_tracks("video") == 0:
vcaps = None vcaps = None
@ -487,7 +487,7 @@ class GstValidateEncodingTestInterface(object):
if self.media_descriptor.get_num_tracks("audio") == 0: if self.media_descriptor.get_num_tracks("audio") == 0:
acaps = None acaps = None
return self._get_profile_full(utils.FORMATS[self.combination.container], return self._get_profile_full(self.combination.get_muxer_caps(),
vcaps, acaps, vcaps, acaps,
video_restriction=video_restriction, video_restriction=video_restriction,
audio_restriction=audio_restriction) audio_restriction=audio_restriction)
@ -1037,3 +1037,35 @@ class GstValidateMediaDescriptor(MediaDescriptor):
n += 1 n += 1
return n 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]

View file

@ -170,58 +170,6 @@ def TIME_ARGS(time):
(time / GST_SECOND) % 60, (time / GST_SECOND) % 60,
time % GST_SECOND) 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 # # Some utilities to parse gst-validate output #
################################################## ##################################################