# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
import argparse
+from fractions import Fraction
import os
import copy
import sys
from launcher.baseclasses import GstValidateTest, Test, \
ScenarioManager, NamedDic, GstValidateTestsGenerator, \
GstValidateMediaDescriptor, GstValidateEncodingTestInterface, \
- GstValidateBaseTestManager, MediaDescriptor, MediaFormatCombination
+ GstValidateBaseTestManager, MediaDescriptor, MediaFormatCombination, VariableFramerateMode
from launcher.utils import path2url, url2path, DEFAULT_TIMEOUT, which, \
GST_SECOND, Result, Protocols, mkdir, printc, Colors, get_data_file, \
if urllib.parse.urlparse(self.dest_file).scheme == "":
self.dest_file = path2url(self.dest_file)
- profile = self.get_profile()
+ variable_framerate = VariableFramerateMode.DISABLED
+ if self.media_descriptor.get_num_tracks("video") == 1:
+ caps, = [c for (t, c) in self.media_descriptor.get_tracks_caps() if t == 'video']
+ framerate = None
+ for struct, _ in GstCaps.new_from_str(caps):
+ framerate = struct.get("framerate", None)
+ if framerate is not None and \
+ framerate.numerator == 0 and framerate.denominator == 1:
+ variable_framerate = VariableFramerateMode.AUTO
+ break
+
+ profile = self.get_profile(variable_framerate=variable_framerate)
self.add_arguments("-o", profile)
def build_arguments(self):
""" Class representing tests and test managers. """
+from enum import Enum
import importlib.util
import json
import os
from itertools import cycle
from fractions import Fraction
-from .utils import which
+from .utils import GstCaps, which
from . import reporters
from . import loggable
from .loggable import Loggable
return result
+class VariableFramerateMode(Enum):
+ DISABLED = 1
+ ENABLED = 2
+ AUTO = 3
+
+
class GstValidateEncodingTestInterface(object):
DURATION_TOLERANCE = GST_SECOND / 4
def _get_profile_full(self, muxer, venc, aenc, video_restriction=None,
audio_restriction=None, audio_presence=0,
- video_presence=0, variable_framerate=False):
+ video_presence=0,
+ variable_framerate=VariableFramerateMode.DISABLED):
+
ret = ""
if muxer:
ret += muxer
ret += venc
props = ""
if video_presence:
- props += 'presence=%s,' % str(video_presence)
- if variable_framerate:
- props += 'variable-framerate=true,'
+ props += 'presence=%s|' % str(video_presence)
+ if variable_framerate == VariableFramerateMode.AUTO:
+ if video_restriction and "framerate" in video_restriction:
+ variable_framerate = VariableFramerateMode.DISABLED
+ else:
+ variable_framerate = VariableFramerateMode.ENABLED
+ if variable_framerate == VariableFramerateMode.ENABLED:
+ props += 'variable-framerate=true|'
if props:
ret = ret + '|' + props[:-1]
if aenc:
return ret.replace("::", ":")
def get_profile(self, video_restriction=None, audio_restriction=None,
- variable_framerate=False):
+ variable_framerate=VariableFramerateMode.DISABLED):
vcaps = self.combination.get_video_caps()
acaps = self.combination.get_audio_caps()
if video_restriction is None: