From 8b2ec3ddc163fe9c5216d4869d3b5f0c7efd33b1 Mon Sep 17 00:00:00 2001 From: Kennan Gumbs Date: Tue, 10 Aug 2021 19:05:36 -0400 Subject: Add VP9 and AV1 testing to standalone_e2e.py Currently the python script responsible for testing the standalone sender and receiver only tests VP8. This patch adds tests for VP9 and AV1. Change-Id: I7b348b01975484c2c58380b464494e78a8470e94 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/3086189 Commit-Queue: Jordan Bayles Reviewed-by: Jordan Bayles --- cast/standalone_e2e.py | 67 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/cast/standalone_e2e.py b/cast/standalone_e2e.py index c64ab5e7..0d8a7c98 100755 --- a/cast/standalone_e2e.py +++ b/cast/standalone_e2e.py @@ -20,12 +20,13 @@ import unittest import ssl from collections import namedtuple -from enum import IntFlag +from enum import IntEnum, IntFlag from urllib import request # Environment variables that can be overridden to set test properties. ROOT_ENVVAR = 'OPENSCREEN_ROOT_DIR' BUILD_ENVVAR = 'OPENSCREEN_BUILD_DIR' +LIBAOM_ENVVAR = 'OPENSCREEN_HAVE_LIBAOM' TEST_VIDEO_NAME = 'Contador_Glam.mp4' # NOTE: we use the HTTP protocol instead of HTTPS due to certificate issues @@ -48,11 +49,23 @@ RECEIVER_BINARY_NAME = 'cast_receiver' EXPECTED_RECEIVER_MESSAGES = [ "CastService is running.", "Found codec: opus (known to FFMPEG as opus)", - "Found codec: vp8 (known to FFMPEG as vp8)", "Successfully negotiated a session, creating SDL players.", "Receivers are currently destroying, resetting SDL players." ] +class VideoCodec(IntEnum): + """There are different messages printed by the receiver depending on the codec + chosen. """ + Vp8 = 0 + Vp9 = 1 + Av1 = 2 + +VIDEO_CODEC_SPECIFIC_RECEIVER_MESSAGES = [ + "Found codec: vp8 (known to FFMPEG as vp8)", + "Found codec: vp9 (known to FFMPEG as vp9)", + "Found codec: libaom-av1 (known to FFMPEG as av1)" +] + EXPECTED_SENDER_MESSAGES = [ "Launching Mirroring App on the Cast Receiver", "Max allowed media bitrate (audio + video) will be", @@ -74,7 +87,9 @@ working directory inside Open Screen's source directory, and uses /out/Default as the build directory. To override these, set the OPENSCREEN_ROOT_DIR and OPENSCREEN_BUILD_DIR environment variables. If the root directory is set and the build directory is not, -/out/Default will be used. +/out/Default will be used. In addition, if LibAOM is +installed, one can choose to run AV1 tests by defining the +OPENSCREEN_HAVE_LIBAOM environment variable. See below for the the help output generated by the `unittest` package.""" @@ -210,7 +225,7 @@ class StandaloneCastTest(unittest.TestCase): stdout=subprocess.PIPE, stderr=subprocess.PIPE) - def launch_sender(self, flags): + def launch_sender(self, flags, codec=None): """Launches the sender process, running the test video file once.""" logging.debug('Launching the sender application...') command = [ @@ -226,14 +241,33 @@ class StandaloneCastTest(unittest.TestCase): if TestFlags.UseRemoting in flags: command.append('-r') + # The standalone sender sends VP8 if no codec command line argument is + # passed. + if codec: + command.append('-c') + if codec == VideoCodec.Vp8: + command.append('vp8') + elif codec == VideoCodec.Vp9: + command.append('vp9') + else: + self.assertTrue(codec == VideoCodec.Av1) + command.append('av1') + #pylint: disable = consider-using-with return subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - def check_logs(self, logs): + def check_logs(self, logs, codec=None): """Checks that the outputted logs contain expected behavior.""" - for message in EXPECTED_RECEIVER_MESSAGES: + + # If a codec was not provided, we should make sure that the standalone + # sender sent VP8. + if codec == None: + codec = VideoCodec.Vp8 + + for message in (EXPECTED_RECEIVER_MESSAGES + + [VIDEO_CODEC_SPECIFIC_RECEIVER_MESSAGES[codec]]): self.assertTrue( message in logs[0], 'Missing log message: {}.\n{}'.format(message, @@ -247,12 +281,12 @@ class StandaloneCastTest(unittest.TestCase): self.assertTrue(prefix not in log, "Logs contained an error") logging.debug('Finished validating log output') - def get_output(self, flags): + def get_output(self, flags, codec=None): """Launches the sender and receiver, and handles exit output.""" receiver_process = self.launch_receiver() logging.debug('Letting the receiver start up...') time.sleep(3) - sender_process = self.launch_sender(flags) + sender_process = self.launch_sender(flags, codec) logging.debug('Launched sender PID %i and receiver PID %i...', sender_process.pid, receiver_process.pid) @@ -284,6 +318,23 @@ class StandaloneCastTest(unittest.TestCase): output = self.get_output(TestFlags.UseAndroidHack) self.check_logs(output) + def test_vp8_flag(self): + """Tests that the VP8 flag works with standard settings.""" + output = self.get_output([], VideoCodec.Vp8) + self.check_logs(output, VideoCodec.Vp8) + + def test_vp9_flag(self): + """Tests that the VP9 flag works with standard settings.""" + output = self.get_output([], VideoCodec.Vp9) + self.check_logs(output, VideoCodec.Vp9) + + @unittest.skipUnless(os.getenv(LIBAOM_ENVVAR), + 'Skipping AV1 test since LibAOM not installed.') + def test_av1_flag(self): + """Tests that the AV1 flag works with standard settings.""" + output = self.get_output([], VideoCodec.Av1) + self.check_logs(output, VideoCodec.Av1) + def parse_args(): """Parses the command line arguments and sets up the logging module.""" -- cgit v1.2.3