| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 # | 3 # |
| 4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
| 5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
| 6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
| 7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
| 8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
| 9 | 9 |
| 10 """ | 10 """ |
| 11 This script is the wrapper that starts a loopback call with stubbed video in | 11 This script is the wrapper that starts a loopback call with stubbed video in |
| 12 and out. It then analyses the video quality of the output video against the | 12 and out. It then analyses the video quality of the output video against the |
| 13 reference input video. | 13 reference input video. |
| 14 | 14 |
| 15 It expect to be given the webrtc output build directory as the first argument | 15 It expect to be given the webrtc output build directory as the first argument |
| 16 all other arguments are optional. | 16 all other arguments are optional. |
| 17 | 17 |
| 18 It assumes you have a Android device plugged in. | 18 It assumes you have a Android device plugged in. |
| 19 """ | 19 """ |
| 20 | 20 |
| 21 import argparse | 21 import argparse |
| 22 import json |
| 22 import logging | 23 import logging |
| 23 import os | 24 import os |
| 24 import shutil | 25 import shutil |
| 25 import subprocess | 26 import subprocess |
| 26 import sys | 27 import sys |
| 27 import tempfile | 28 import tempfile |
| 28 import time | 29 import time |
| 29 | 30 |
| 30 | 31 |
| 31 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 32 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 32 SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, | 33 SRC_DIR = os.path.normpath(os.path.join(SCRIPT_DIR, os.pardir, os.pardir, |
| 33 os.pardir)) | 34 os.pardir)) |
| 35 BAD_DEVICES_JSON = os.path.join(SRC_DIR, |
| 36 os.environ.get('CHROMIUM_OUT_DIR', 'out'), |
| 37 'bad_devices.json') |
| 34 | 38 |
| 35 | 39 |
| 36 class Error(Exception): | 40 class Error(Exception): |
| 37 pass | 41 pass |
| 38 | 42 |
| 39 | 43 |
| 40 class VideoQualityTestError(Error): | 44 class VideoQualityTestError(Error): |
| 41 pass | 45 pass |
| 42 | 46 |
| 43 | 47 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 download_tools_script = os.path.join(tools_dir, 'download_tools.py') | 106 download_tools_script = os.path.join(tools_dir, 'download_tools.py') |
| 103 _RunCommand([sys.executable, download_tools_script, toolchain_dir]) | 107 _RunCommand([sys.executable, download_tools_script, toolchain_dir]) |
| 104 | 108 |
| 105 testing_tools_dir = os.path.join(SRC_DIR, 'webrtc', 'tools', 'testing') | 109 testing_tools_dir = os.path.join(SRC_DIR, 'webrtc', 'tools', 'testing') |
| 106 | 110 |
| 107 # Download, extract and build AppRTC. | 111 # Download, extract and build AppRTC. |
| 108 setup_apprtc_script = os.path.join(testing_tools_dir, 'setup_apprtc.py') | 112 setup_apprtc_script = os.path.join(testing_tools_dir, 'setup_apprtc.py') |
| 109 _RunCommand([sys.executable, setup_apprtc_script, temp_dir]) | 113 _RunCommand([sys.executable, setup_apprtc_script, temp_dir]) |
| 110 | 114 |
| 111 # Select an Android device in case multiple are connected | 115 # Select an Android device in case multiple are connected |
| 116 try: |
| 117 with open(BAD_DEVICES_JSON) as bad_devices_file: |
| 118 bad_devices = json.load(bad_devices_file) |
| 119 except IOError: |
| 120 if os.environ.get('CHROME_HEADLESS'): |
| 121 logging.warning('Cannot read %r', BAD_DEVICES_JSON) |
| 122 bad_devices = {} |
| 123 |
| 112 for line in _RunCommandWithOutput([adb_path, 'devices']).splitlines(): | 124 for line in _RunCommandWithOutput([adb_path, 'devices']).splitlines(): |
| 113 if line.endswith('\tdevice'): | 125 if line.endswith('\tdevice'): |
| 114 android_device = line.split('\t')[0] | 126 android_device = line.split('\t')[0] |
| 115 break | 127 if android_device not in bad_devices: |
| 128 break |
| 116 else: | 129 else: |
| 117 raise VideoQualityTestError('Cannot find any connected Android device.') | 130 raise VideoQualityTestError('Cannot find any connected Android device.') |
| 118 | 131 |
| 119 processes = [] | 132 processes = [] |
| 120 try: | 133 try: |
| 121 # Start AppRTC Server | 134 # Start AppRTC Server |
| 122 dev_appserver = os.path.join(temp_dir, 'apprtc', 'temp', 'google-cloud-sdk', | 135 dev_appserver = os.path.join(temp_dir, 'apprtc', 'temp', 'google-cloud-sdk', |
| 123 'bin', 'dev_appserver.py') | 136 'bin', 'dev_appserver.py') |
| 124 appengine_dir = os.path.join(temp_dir, 'apprtc', 'out', 'app_engine') | 137 appengine_dir = os.path.join(temp_dir, 'apprtc', 'out', 'app_engine') |
| 125 processes.append(_RunBackgroundCommand([ | 138 processes.append(_RunBackgroundCommand([ |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 if process: | 209 if process: |
| 197 process.terminate() | 210 process.terminate() |
| 198 process.wait() | 211 process.wait() |
| 199 | 212 |
| 200 shutil.rmtree(temp_dir) | 213 shutil.rmtree(temp_dir) |
| 201 | 214 |
| 202 | 215 |
| 203 if __name__ == '__main__': | 216 if __name__ == '__main__': |
| 204 sys.exit(main()) | 217 sys.exit(main()) |
| 205 | 218 |
| OLD | NEW |