2014-07-16 20:47:57 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
#
|
|
|
|
# Copyright 2014 Google Inc. All Rights Reserved.
|
|
|
|
#
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file or at
|
|
|
|
# https://developers.google.com/open-source/licenses/bsd
|
|
|
|
"""Tests utilizing the sample packager binary."""
|
|
|
|
|
2015-09-25 22:58:18 +00:00
|
|
|
import filecmp
|
2018-03-01 00:38:51 +00:00
|
|
|
import glob
|
2019-02-01 02:33:25 +00:00
|
|
|
import logging
|
2014-07-16 20:47:57 +00:00
|
|
|
import os
|
2015-09-25 22:58:18 +00:00
|
|
|
import re
|
2014-07-16 20:47:57 +00:00
|
|
|
import shutil
|
2015-09-25 22:58:18 +00:00
|
|
|
import subprocess
|
2014-07-16 20:47:57 +00:00
|
|
|
import tempfile
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
import packager_app
|
|
|
|
import test_env
|
|
|
|
|
2017-04-04 23:35:25 +00:00
|
|
|
_TEST_FAILURE_COMMAND_LINE_MESSAGE = """
|
|
|
|
!!! To reproduce the failure, change the output files to an !!!
|
|
|
|
!!! existing directory, e.g. output artifacts to current !!!
|
|
|
|
!!! directory by removing /tmp/something/ in the following !!!
|
|
|
|
!!! command line. !!!
|
|
|
|
The test executed the following command line:
|
2018-02-07 17:51:20 +00:00
|
|
|
""".strip()
|
2017-04-04 23:35:25 +00:00
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
|
2018-02-07 01:34:35 +00:00
|
|
|
class StreamDescriptor(object):
|
|
|
|
"""Basic class used to build stream descriptor commands."""
|
|
|
|
|
|
|
|
def __init__(self, input_file):
|
2018-07-16 21:53:28 +00:00
|
|
|
self._buffer = 'input=%s' % input_file
|
|
|
|
self._output_file_name_base = os.path.splitext(
|
|
|
|
os.path.basename(input_file))[0]
|
2018-02-07 01:34:35 +00:00
|
|
|
|
|
|
|
def Append(self, key, value):
|
2018-07-16 21:53:28 +00:00
|
|
|
self._buffer += ',%s=%s' % (key, value)
|
|
|
|
|
|
|
|
# Generate an unique |_output_file_name_base| from some of the keys.
|
|
|
|
# We do not need all the keys as it is sufficient with the below keys.
|
|
|
|
if key == 'stream':
|
|
|
|
self._output_file_name_base += '-%s' % value
|
|
|
|
elif key == 'trick_play_factor':
|
|
|
|
self._output_file_name_base += '-trick_play_factor_%d' % value
|
|
|
|
elif key == 'skip_encryption':
|
|
|
|
self._output_file_name_base += '-skip_encryption'
|
|
|
|
|
2018-02-07 01:34:35 +00:00
|
|
|
return self
|
|
|
|
|
2018-07-16 21:53:28 +00:00
|
|
|
def GetOutputFileNameBase(self, output_file_prefix):
|
|
|
|
if output_file_prefix:
|
|
|
|
return '%s-%s' % (output_file_prefix, self._output_file_name_base)
|
|
|
|
else:
|
|
|
|
return self._output_file_name_base
|
|
|
|
|
2018-02-07 01:34:35 +00:00
|
|
|
def __str__(self):
|
2018-07-16 21:53:28 +00:00
|
|
|
return self._buffer
|
2018-02-07 01:34:35 +00:00
|
|
|
|
|
|
|
|
2018-07-11 18:57:21 +00:00
|
|
|
class DiffFilesPolicy(object):
|
2018-07-16 21:32:55 +00:00
|
|
|
"""Class for handling files comparison.
|
2018-07-11 18:57:21 +00:00
|
|
|
|
|
|
|
Attributes:
|
2018-07-16 21:32:55 +00:00
|
|
|
_allowed_diff_files: The list of files allowed to be different.
|
|
|
|
_exact: The actual list of diff_files must match the above list exactly,
|
|
|
|
i.e. all the files in the above list must be different.
|
|
|
|
_allow_updating_golden_files: When set to false, golden files will not be
|
|
|
|
updated for this test even if updating_golden_files is requested. This
|
|
|
|
is useful for tests generating different outputs in each run, which is
|
|
|
|
often used together when _allowed_diff_files is not empty.
|
2018-07-11 18:57:21 +00:00
|
|
|
"""
|
|
|
|
|
2018-07-16 21:32:55 +00:00
|
|
|
def __init__(self,
|
|
|
|
allowed_diff_files=None,
|
|
|
|
exact=True,
|
|
|
|
allow_updating_golden_files=True):
|
|
|
|
if allowed_diff_files:
|
|
|
|
self._allowed_diff_files = allowed_diff_files
|
|
|
|
else:
|
|
|
|
self._allowed_diff_files = []
|
|
|
|
self._exact = exact
|
|
|
|
self._allow_updating_golden_files = allow_updating_golden_files
|
|
|
|
|
|
|
|
def ProcessDiff(self, out_dir, gold_dir):
|
|
|
|
"""Compare test outputs with golden files.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
out_dir: The test output directory.
|
|
|
|
gold_dir: The golden directory to be compared with.
|
|
|
|
Returns:
|
|
|
|
A list of diff messages when the files do not match; An empty list
|
|
|
|
otherwise or in update mode.
|
|
|
|
"""
|
|
|
|
if test_env.options.test_update_golden_files:
|
|
|
|
if self._allow_updating_golden_files:
|
|
|
|
self._UpdateGold(out_dir, gold_dir)
|
|
|
|
return []
|
|
|
|
else:
|
|
|
|
return self._DiffDir(out_dir, gold_dir)
|
|
|
|
|
|
|
|
def _DiffDir(self, out_dir, gold_dir):
|
|
|
|
# Get a list of the files and dirs that are different between the two top
|
|
|
|
# level directories.
|
|
|
|
diff = filecmp.dircmp(out_dir, gold_dir)
|
|
|
|
|
|
|
|
# Create a list of all the details about the failure. The list will be
|
|
|
|
# joined together when sent out.
|
|
|
|
failure_messages = []
|
|
|
|
|
|
|
|
missing = diff.left_only
|
|
|
|
if missing:
|
|
|
|
failure_messages += [
|
|
|
|
'Missing %d files: %s' % (len(missing), str(missing))
|
|
|
|
]
|
|
|
|
|
|
|
|
extra = diff.right_only
|
|
|
|
if extra:
|
|
|
|
failure_messages += [
|
|
|
|
'Found %d unexpected files: %s' % (len(extra), str(extra))
|
|
|
|
]
|
|
|
|
|
|
|
|
# Produce nice diffs for each file that differs.
|
|
|
|
for diff_file in diff.diff_files:
|
|
|
|
if diff_file in self._allowed_diff_files:
|
|
|
|
continue
|
|
|
|
|
|
|
|
actual_file = os.path.join(out_dir, diff_file)
|
|
|
|
expected_file = os.path.join(gold_dir, diff_file)
|
|
|
|
|
|
|
|
output, error = self._GitDiff(expected_file, actual_file)
|
|
|
|
|
|
|
|
if output:
|
|
|
|
failure_messages += [output]
|
|
|
|
|
|
|
|
if error:
|
|
|
|
failure_messages += [error]
|
|
|
|
|
|
|
|
if self._exact:
|
|
|
|
for diff_file in self._allowed_diff_files:
|
|
|
|
if diff_file not in diff.diff_files:
|
|
|
|
failure_messages += ['Expecting "%s" to be different' % diff_file]
|
|
|
|
|
|
|
|
return failure_messages
|
|
|
|
|
|
|
|
def _GitDiff(self, file_a, file_b):
|
|
|
|
cmd = [
|
|
|
|
'git',
|
|
|
|
'--no-pager',
|
|
|
|
'diff',
|
|
|
|
'--color=auto',
|
|
|
|
'--no-ext-diff',
|
|
|
|
'--no-index',
|
|
|
|
file_a,
|
|
|
|
file_b
|
|
|
|
]
|
|
|
|
p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
|
|
|
return p.communicate()
|
|
|
|
|
|
|
|
def _UpdateGold(self, out_dir, gold_dir):
|
|
|
|
if os.path.exists(gold_dir):
|
|
|
|
shutil.rmtree(gold_dir)
|
|
|
|
|
|
|
|
shutil.copytree(out_dir, gold_dir)
|
2018-07-11 18:57:21 +00:00
|
|
|
|
|
|
|
|
2018-03-07 17:25:21 +00:00
|
|
|
def _UpdateMediaInfoPaths(media_info_filepath):
|
|
|
|
# Example:
|
|
|
|
# before: media_file_name: "/tmp/tmpD1h5UC/bear-640x360-audio.mp4"
|
|
|
|
# after: media_file_name: "bear-640x360-audio.mp4"
|
|
|
|
|
|
|
|
with open(media_info_filepath, 'rb') as f:
|
2019-02-13 00:45:44 +00:00
|
|
|
content = f.read().decode()
|
2018-03-07 17:25:21 +00:00
|
|
|
|
|
|
|
regex = 'media_file_name: "(.*)"'
|
|
|
|
for path in re.findall(regex, content):
|
|
|
|
short_path = os.path.basename(path)
|
|
|
|
content = content.replace(path, short_path)
|
|
|
|
|
|
|
|
with open(media_info_filepath, 'wb') as f:
|
2019-02-13 00:45:44 +00:00
|
|
|
f.write(content.encode())
|
2018-03-07 17:25:21 +00:00
|
|
|
|
|
|
|
|
2018-03-01 00:38:51 +00:00
|
|
|
def _UpdateMpdTimes(mpd_filepath):
|
|
|
|
# Take a single pattern, and replace the first match with the
|
|
|
|
# given new string.
|
|
|
|
def _Replace(str_in, pattern, new):
|
|
|
|
m = re.search(pattern, str_in)
|
|
|
|
|
|
|
|
if m:
|
|
|
|
old = m.group(0)
|
|
|
|
out = str_in.replace(old, new)
|
2019-02-01 02:33:25 +00:00
|
|
|
logging.info('Replacing "%s" with "%s"', old, new)
|
2018-03-01 00:38:51 +00:00
|
|
|
else:
|
|
|
|
out = str_in
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
with open(mpd_filepath, 'rb') as f:
|
2019-02-13 00:45:44 +00:00
|
|
|
content = f.read().decode()
|
2018-03-01 00:38:51 +00:00
|
|
|
|
|
|
|
content = _Replace(
|
|
|
|
content,
|
|
|
|
'availabilityStartTime="[^"]+"',
|
|
|
|
'availabilityStartTime="some_time"')
|
|
|
|
|
|
|
|
content = _Replace(
|
|
|
|
content,
|
|
|
|
'publishTime="[^"]+"',
|
|
|
|
'publishTime="some_time"')
|
|
|
|
|
|
|
|
with open(mpd_filepath, 'wb') as f:
|
2019-02-13 00:45:44 +00:00
|
|
|
f.write(content.encode())
|
2018-03-01 00:38:51 +00:00
|
|
|
|
|
|
|
|
2018-09-18 20:34:18 +00:00
|
|
|
def GetExtension(input_file_path, output_format):
|
2018-05-15 19:43:46 +00:00
|
|
|
if output_format:
|
|
|
|
return output_format
|
2018-09-18 20:34:18 +00:00
|
|
|
# Otherwise use the same extension as the input.
|
|
|
|
ext = os.path.splitext(input_file_path)[1]
|
|
|
|
return ext[1:] # Remove the leading '.'.
|
2018-02-07 21:46:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
def GetSegmentedExtension(base_extension):
|
|
|
|
if base_extension == 'mp4':
|
|
|
|
return 'm4s'
|
|
|
|
|
|
|
|
return base_extension
|
|
|
|
|
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
class PackagerAppTest(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
2019-02-01 02:33:25 +00:00
|
|
|
super(PackagerAppTest, self).setUp()
|
2014-07-16 20:47:57 +00:00
|
|
|
self.packager = packager_app.PackagerApp()
|
2015-09-25 22:58:18 +00:00
|
|
|
self.tmp_dir = tempfile.mkdtemp()
|
2015-10-01 23:29:52 +00:00
|
|
|
self.test_data_dir = os.path.join(test_env.SRC_DIR, 'packager', 'media',
|
|
|
|
'test', 'data')
|
|
|
|
self.golden_file_dir = os.path.join(test_env.SRC_DIR, 'packager', 'app',
|
|
|
|
'test', 'testdata')
|
2018-02-28 20:31:40 +00:00
|
|
|
self.mpd_output = os.path.join(self.tmp_dir, 'output.mpd')
|
|
|
|
self.hls_master_playlist_output = os.path.join(self.tmp_dir, 'output.m3u8')
|
2018-02-07 21:46:11 +00:00
|
|
|
self.output = []
|
2014-07-16 20:47:57 +00:00
|
|
|
|
2017-06-14 23:18:16 +00:00
|
|
|
# Test variables.
|
|
|
|
self.encryption_key_id = '31323334353637383930313233343536'
|
|
|
|
if test_env.options.encryption_key:
|
|
|
|
self.encryption_key = test_env.options.encryption_key
|
|
|
|
else:
|
|
|
|
self.encryption_key = '32333435363738393021323334353637'
|
|
|
|
if test_env.options.encryption_iv:
|
|
|
|
self.encryption_iv = test_env.options.encryption_iv
|
|
|
|
else:
|
|
|
|
self.encryption_iv = '3334353637383930'
|
|
|
|
self.widevine_content_id = '3031323334353637'
|
2018-01-10 00:04:40 +00:00
|
|
|
# TS files may have a non-zero start, which could result in the first
|
|
|
|
# segment to be less than 1 second. Set clear_lead to be less than 1
|
|
|
|
# so only the first segment is left in clear.
|
|
|
|
self.clear_lead = 0.8
|
2017-06-14 23:18:16 +00:00
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
def tearDown(self):
|
2017-03-23 18:05:22 +00:00
|
|
|
if test_env.options.remove_temp_files_after_test:
|
|
|
|
shutil.rmtree(self.tmp_dir)
|
2019-02-01 02:33:25 +00:00
|
|
|
super(PackagerAppTest, self).tearDown()
|
2014-07-16 20:47:57 +00:00
|
|
|
|
2018-02-07 21:46:11 +00:00
|
|
|
def _GetStream(self,
|
|
|
|
descriptor,
|
|
|
|
language=None,
|
2018-07-11 18:57:21 +00:00
|
|
|
output_file_prefix=None,
|
2018-02-07 21:46:11 +00:00
|
|
|
output_format=None,
|
|
|
|
segmented=False,
|
2018-09-12 21:47:20 +00:00
|
|
|
using_time_specifier=False,
|
2018-02-07 21:46:11 +00:00
|
|
|
hls=False,
|
2018-10-10 22:30:28 +00:00
|
|
|
hls_characteristics=None,
|
2019-06-13 06:01:16 +00:00
|
|
|
dash_accessibilities=None,
|
|
|
|
dash_roles=None,
|
2018-02-07 21:46:11 +00:00
|
|
|
trick_play_factor=None,
|
|
|
|
drm_label=None,
|
|
|
|
skip_encryption=None,
|
2018-04-30 22:43:58 +00:00
|
|
|
bandwidth=None,
|
2018-05-23 00:26:18 +00:00
|
|
|
split_content_on_ad_cues=False,
|
2018-03-02 17:02:38 +00:00
|
|
|
test_file=None):
|
2018-02-07 21:46:11 +00:00
|
|
|
"""Get a stream descriptor as a string.
|
|
|
|
|
|
|
|
|
|
|
|
Create the stream descriptor as a string for the given parameters so that
|
|
|
|
it can be passed as an input parameter to the packager.
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
descriptor: The name of the stream in the container that should be used as
|
|
|
|
input for the output.
|
|
|
|
language: The language override for the input stream.
|
2018-07-11 18:57:21 +00:00
|
|
|
output_file_prefix: The output file prefix. Default to empty if not
|
|
|
|
specified.
|
2018-10-10 22:30:28 +00:00
|
|
|
output_format: The format for the output.
|
2018-02-07 21:46:11 +00:00
|
|
|
segmented: Should the output use a segmented formatted. This will affect
|
|
|
|
the output extensions and manifests.
|
2018-09-12 21:47:20 +00:00
|
|
|
using_time_specifier: Use $Time$ in segment name instead of using
|
|
|
|
$Number$. This flag is only relevant if segmented is True.
|
2018-02-07 21:46:11 +00:00
|
|
|
hls: Should the output be for an HLS manifest.
|
2018-10-10 22:30:28 +00:00
|
|
|
hls_characteristics: CHARACTERISTICS attribute for the HLS stream.
|
2019-06-13 06:01:16 +00:00
|
|
|
dash_accessibilities: Accessibility element for the DASH stream.
|
|
|
|
dash_roles: Role element for the DASH stream.
|
2018-02-07 21:46:11 +00:00
|
|
|
trick_play_factor: Signals the stream is to be used for a trick play
|
|
|
|
stream and which key frames to use. A trick play factor of 0 is the
|
|
|
|
same as not specifying a trick play factor.
|
2018-10-10 22:30:28 +00:00
|
|
|
drm_label: The drm label for the stream.
|
2018-02-07 21:46:11 +00:00
|
|
|
skip_encryption: If set to true, the stream will not be encrypted.
|
2018-04-30 22:43:58 +00:00
|
|
|
bandwidth: The expected bandwidth value that should be listed in the
|
|
|
|
manifest.
|
2018-05-23 00:26:18 +00:00
|
|
|
split_content_on_ad_cues: If set to true, the output file will be split
|
|
|
|
into multiple files, with a total of NumAdCues + 1 files.
|
2018-10-10 22:30:28 +00:00
|
|
|
test_file: The input file to use. If the input file is not specified, a
|
|
|
|
default file will be used.
|
2018-02-07 21:46:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
A string that makes up a single stream descriptor for input to the
|
|
|
|
packager.
|
|
|
|
"""
|
2018-02-28 20:31:40 +00:00
|
|
|
input_file_name = test_file or 'bear-640x360.mp4'
|
|
|
|
input_file_path = os.path.join(self.test_data_dir, input_file_name)
|
2018-02-07 21:46:11 +00:00
|
|
|
|
2018-02-28 20:31:40 +00:00
|
|
|
stream = StreamDescriptor(input_file_path)
|
2018-02-07 21:46:11 +00:00
|
|
|
stream.Append('stream', descriptor)
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
if output_format:
|
2018-02-07 21:46:11 +00:00
|
|
|
stream.Append('format', output_format)
|
|
|
|
|
|
|
|
if language:
|
|
|
|
stream.Append('lang', language)
|
|
|
|
|
|
|
|
if trick_play_factor:
|
|
|
|
stream.Append('trick_play_factor', trick_play_factor)
|
|
|
|
|
|
|
|
if drm_label:
|
|
|
|
stream.Append('drm_label', drm_label)
|
|
|
|
|
|
|
|
if skip_encryption:
|
|
|
|
stream.Append('skip_encryption', 1)
|
2018-02-28 20:31:40 +00:00
|
|
|
|
2018-09-18 20:34:18 +00:00
|
|
|
base_ext = GetExtension(input_file_path, output_format)
|
2018-07-16 21:53:28 +00:00
|
|
|
output_file_name_base = stream.GetOutputFileNameBase(output_file_prefix)
|
2018-02-28 20:31:40 +00:00
|
|
|
|
2018-02-08 01:44:41 +00:00
|
|
|
if hls:
|
2018-07-16 21:53:28 +00:00
|
|
|
stream.Append('playlist_name', output_file_name_base + '.m3u8')
|
2018-02-08 01:44:41 +00:00
|
|
|
|
|
|
|
# By default, add a iframe playlist for all HLS playlists (assuming that
|
|
|
|
# the source input is supported). iframe playlists should only be for
|
|
|
|
# videos. This check will fail for numeric descriptors, but that is an
|
|
|
|
# acceptable limitation (b/73960731).
|
|
|
|
if base_ext in ['ts', 'mp4'] and descriptor == 'video':
|
2018-07-16 21:53:28 +00:00
|
|
|
stream.Append('iframe_playlist_name',
|
|
|
|
output_file_name_base + '-iframe.m3u8')
|
2018-02-08 01:44:41 +00:00
|
|
|
|
2018-10-10 22:30:28 +00:00
|
|
|
if hls_characteristics:
|
|
|
|
stream.Append('hls_characteristics', hls_characteristics)
|
|
|
|
|
2019-06-13 06:01:16 +00:00
|
|
|
if dash_accessibilities:
|
|
|
|
stream.Append('dash_accessibilities', dash_accessibilities)
|
|
|
|
if dash_roles:
|
|
|
|
stream.Append('dash_roles', dash_roles)
|
|
|
|
|
2018-05-18 00:58:34 +00:00
|
|
|
requires_init_segment = segmented and base_ext not in [
|
|
|
|
'aac', 'ac3', 'ec3', 'ts', 'vtt'
|
|
|
|
]
|
2018-02-28 20:31:40 +00:00
|
|
|
|
2018-07-16 21:53:28 +00:00
|
|
|
output_file_path = os.path.join(self.tmp_dir, output_file_name_base)
|
2018-02-28 20:31:40 +00:00
|
|
|
|
|
|
|
if requires_init_segment:
|
|
|
|
init_seg = '%s-init.%s' % (output_file_path, base_ext)
|
|
|
|
stream.Append('init_segment', init_seg)
|
|
|
|
|
|
|
|
if segmented:
|
2018-09-12 21:47:20 +00:00
|
|
|
segment_specifier = '$Time$' if using_time_specifier else '$Number$'
|
2018-02-28 20:31:40 +00:00
|
|
|
segment_ext = GetSegmentedExtension(base_ext)
|
2018-09-12 21:47:20 +00:00
|
|
|
seg_template = '%s-%s.%s' % (output_file_path, segment_specifier,
|
|
|
|
segment_ext)
|
2018-02-28 20:31:40 +00:00
|
|
|
stream.Append('segment_template', seg_template)
|
|
|
|
else:
|
2018-05-23 00:26:18 +00:00
|
|
|
if split_content_on_ad_cues:
|
|
|
|
output_file_path += '$Number$.' + base_ext
|
|
|
|
else:
|
|
|
|
output_file_path += '.' + base_ext
|
2018-02-28 20:31:40 +00:00
|
|
|
stream.Append('output', output_file_path)
|
|
|
|
|
2018-04-30 22:43:58 +00:00
|
|
|
if bandwidth:
|
|
|
|
stream.Append('bandwidth', bandwidth)
|
|
|
|
|
2018-02-28 20:31:40 +00:00
|
|
|
self.output.append(output_file_path)
|
2017-06-17 01:36:16 +00:00
|
|
|
|
2018-02-07 21:46:11 +00:00
|
|
|
return str(stream)
|
2018-02-07 21:46:11 +00:00
|
|
|
|
2018-02-07 21:46:11 +00:00
|
|
|
def _GetStreams(self, streams, test_files=None, **kwargs):
|
|
|
|
# Make sure there is a valid list that we can get the length from.
|
|
|
|
test_files = test_files or []
|
|
|
|
test_files_count = len(test_files)
|
|
|
|
|
|
|
|
out = []
|
|
|
|
|
|
|
|
if test_files_count == 0:
|
|
|
|
for stream in streams:
|
|
|
|
out.append(self._GetStream(stream, **kwargs))
|
|
|
|
else:
|
2018-03-02 17:02:38 +00:00
|
|
|
for file_name in test_files:
|
2018-02-07 21:46:11 +00:00
|
|
|
for stream in streams:
|
2018-03-02 17:02:38 +00:00
|
|
|
out.append(self._GetStream(stream, test_file=file_name, **kwargs))
|
2018-02-07 21:46:11 +00:00
|
|
|
|
|
|
|
return out
|
2018-02-07 21:46:11 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def _GetFlags(self,
|
|
|
|
strip_parameter_set_nalus=True,
|
|
|
|
encryption=False,
|
2018-09-18 00:27:02 +00:00
|
|
|
protection_systems=None,
|
2017-06-17 01:36:16 +00:00
|
|
|
protection_scheme=None,
|
|
|
|
vp9_subsample_encryption=True,
|
|
|
|
decryption=False,
|
|
|
|
random_iv=False,
|
|
|
|
widevine_encryption=False,
|
|
|
|
key_rotation=False,
|
|
|
|
include_pssh_in_stream=True,
|
|
|
|
dash_if_iop=True,
|
|
|
|
output_media_info=False,
|
2018-05-01 18:18:19 +00:00
|
|
|
output_dash=False,
|
2018-07-10 23:04:56 +00:00
|
|
|
output_hls=False,
|
2017-06-03 00:05:47 +00:00
|
|
|
hls_playlist_type=None,
|
|
|
|
time_shift_buffer_depth=0.0,
|
2018-05-01 17:47:06 +00:00
|
|
|
preserved_segments_outside_live_window=0,
|
2018-03-17 01:37:53 +00:00
|
|
|
utc_timings=None,
|
2019-11-15 19:53:47 +00:00
|
|
|
generate_static_live_mpd=False,
|
2018-01-10 00:04:40 +00:00
|
|
|
ad_cues=None,
|
2018-04-05 01:27:57 +00:00
|
|
|
default_language=None,
|
2018-05-01 17:47:06 +00:00
|
|
|
segment_duration=1.0,
|
2017-06-17 01:36:16 +00:00
|
|
|
use_fake_clock=True):
|
|
|
|
flags = []
|
|
|
|
|
|
|
|
if not strip_parameter_set_nalus:
|
|
|
|
flags += ['--strip_parameter_set_nalus=false']
|
|
|
|
|
|
|
|
if widevine_encryption:
|
|
|
|
widevine_server_url = ('https://license.uat.widevine.com/cenc'
|
|
|
|
'/getcontentkey/widevine_test')
|
|
|
|
flags += [
|
|
|
|
'--enable_widevine_encryption',
|
|
|
|
'--key_server_url=' + widevine_server_url,
|
|
|
|
'--content_id=' + self.widevine_content_id,
|
|
|
|
]
|
|
|
|
elif encryption:
|
2017-09-20 22:49:00 +00:00
|
|
|
flags += [
|
2017-10-17 23:03:08 +00:00
|
|
|
'--enable_raw_key_encryption',
|
2017-09-20 22:49:00 +00:00
|
|
|
'--keys=label=:key_id={0}:key={1}'.format(self.encryption_key_id,
|
|
|
|
self.encryption_key),
|
2018-01-10 00:04:40 +00:00
|
|
|
'--clear_lead={0}'.format(self.clear_lead)
|
2017-09-20 22:49:00 +00:00
|
|
|
]
|
2017-06-17 01:36:16 +00:00
|
|
|
|
|
|
|
if not random_iv:
|
|
|
|
flags.append('--iv=' + self.encryption_iv)
|
2017-11-12 22:56:25 +00:00
|
|
|
|
2018-09-18 00:27:02 +00:00
|
|
|
if protection_systems:
|
|
|
|
flags += ['--protection_systems=' + protection_systems]
|
|
|
|
if 'FairPlay' in protection_systems:
|
|
|
|
fairplay_key_uri = ('skd://www.license.com/getkey?'
|
|
|
|
'KeyId=31323334-3536-3738-3930-313233343536')
|
|
|
|
flags += ['--hls_key_uri=' + fairplay_key_uri]
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
if protection_scheme:
|
|
|
|
flags += ['--protection_scheme', protection_scheme]
|
|
|
|
if not vp9_subsample_encryption:
|
|
|
|
flags += ['--vp9_subsample_encryption=false']
|
|
|
|
|
|
|
|
if decryption:
|
2017-09-20 22:49:00 +00:00
|
|
|
flags += [
|
2017-10-17 23:03:08 +00:00
|
|
|
'--enable_raw_key_decryption',
|
2017-09-20 22:49:00 +00:00
|
|
|
'--keys=label=:key_id={0}:key={1}'.format(self.encryption_key_id,
|
|
|
|
self.encryption_key)
|
|
|
|
]
|
2017-06-17 01:36:16 +00:00
|
|
|
|
|
|
|
if key_rotation:
|
|
|
|
flags.append('--crypto_period_duration=1')
|
|
|
|
|
|
|
|
if not include_pssh_in_stream:
|
|
|
|
flags.append('--mp4_include_pssh_in_stream=false')
|
|
|
|
|
|
|
|
if not dash_if_iop:
|
|
|
|
flags.append('--generate_dash_if_iop_compliant_mpd=false')
|
2018-05-01 18:18:19 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
if output_media_info:
|
|
|
|
flags.append('--output_media_info')
|
2018-07-10 23:04:56 +00:00
|
|
|
if output_dash:
|
|
|
|
flags += ['--mpd_output', self.mpd_output]
|
2018-05-01 18:18:19 +00:00
|
|
|
if output_hls:
|
2017-06-17 01:36:16 +00:00
|
|
|
flags += ['--hls_master_playlist_output', self.hls_master_playlist_output]
|
2017-06-03 00:05:47 +00:00
|
|
|
if hls_playlist_type:
|
|
|
|
flags += ['--hls_playlist_type', hls_playlist_type]
|
2017-06-17 01:36:16 +00:00
|
|
|
|
2018-05-01 17:47:06 +00:00
|
|
|
if time_shift_buffer_depth != 0.0:
|
|
|
|
flags += ['--time_shift_buffer_depth={0}'.format(time_shift_buffer_depth)]
|
|
|
|
if preserved_segments_outside_live_window != 0:
|
|
|
|
flags += [
|
|
|
|
'--preserved_segments_outside_live_window={0}'.format(
|
|
|
|
preserved_segments_outside_live_window)
|
|
|
|
]
|
|
|
|
|
2018-03-17 01:37:53 +00:00
|
|
|
if utc_timings:
|
|
|
|
flags += ['--utc_timings', utc_timings]
|
|
|
|
|
2019-11-15 19:53:47 +00:00
|
|
|
if generate_static_live_mpd:
|
|
|
|
flags += ['--generate_static_live_mpd']
|
2017-06-17 01:36:16 +00:00
|
|
|
|
2018-01-10 00:04:40 +00:00
|
|
|
if ad_cues:
|
|
|
|
flags += ['--ad_cues', ad_cues]
|
|
|
|
|
2018-04-05 01:27:57 +00:00
|
|
|
if default_language:
|
|
|
|
flags += ['--default_language', default_language]
|
|
|
|
|
2018-05-01 17:47:06 +00:00
|
|
|
flags.append('--segment_duration={0}'.format(segment_duration))
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
# Use fake clock, so output can be compared.
|
|
|
|
if use_fake_clock:
|
|
|
|
flags.append('--use_fake_clock_for_muxer')
|
|
|
|
|
|
|
|
# Override packager version string for testing.
|
2018-05-30 20:16:30 +00:00
|
|
|
flags += ['--test_packager_version', '<tag>-<hash>-<test>']
|
2017-06-17 01:36:16 +00:00
|
|
|
return flags
|
|
|
|
|
2018-07-11 18:57:21 +00:00
|
|
|
def _AssertStreamInfo(self, stream, info):
|
|
|
|
stream_info = self.packager.DumpStreamInfo(stream)
|
|
|
|
self.assertIn('Found 1 stream(s).', stream_info)
|
|
|
|
self.assertIn(info, stream_info)
|
2017-06-17 01:36:16 +00:00
|
|
|
|
2018-09-18 20:34:18 +00:00
|
|
|
def _Decrypt(self, file_path):
|
2018-07-11 18:57:21 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream(
|
2018-09-18 20:34:18 +00:00
|
|
|
'0', output_file_prefix='decrypted', test_file=file_path)
|
2018-07-11 18:57:21 +00:00
|
|
|
]
|
|
|
|
self.assertPackageSuccess(streams, self._GetFlags(decryption=True))
|
|
|
|
|
|
|
|
def _CheckTestResults(self,
|
|
|
|
test_dir,
|
|
|
|
verify_decryption=False,
|
2018-07-16 21:32:55 +00:00
|
|
|
diff_files_policy=DiffFilesPolicy()):
|
2018-07-11 18:57:21 +00:00
|
|
|
"""Check test results. Updates golden files in update mode.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
test_dir: The golden directory to be compared with. It is expected to be
|
|
|
|
relative to |self.golden_file_dir|.
|
|
|
|
verify_decryption: If set to true, assumes the media files without
|
|
|
|
'skip-encryption' in name to be encrypted and tries to decrypt and
|
|
|
|
then compare these files.
|
2018-07-16 21:32:55 +00:00
|
|
|
diff_files_policy: Specifies DiffFiles policy and handles files
|
|
|
|
comparison.
|
2018-07-11 18:57:21 +00:00
|
|
|
"""
|
2018-03-01 00:38:51 +00:00
|
|
|
# Live mpd contains current availabilityStartTime and publishTime, which
|
|
|
|
# needs to be replaced before comparison. If this is not a live test, then
|
|
|
|
# this will be a no-op.
|
|
|
|
mpds = glob.glob(os.path.join(self.tmp_dir, '*.mpd'))
|
|
|
|
for manifest in mpds:
|
|
|
|
_UpdateMpdTimes(manifest)
|
|
|
|
|
2018-03-07 17:25:21 +00:00
|
|
|
# '*.media_info' outputs contain media file names, which is changing for
|
|
|
|
# every test run. These needs to be replaced for comparison.
|
|
|
|
media_infos = glob.glob(os.path.join(self.tmp_dir, '*.media_info'))
|
|
|
|
for media_info in media_infos:
|
|
|
|
_UpdateMediaInfoPaths(media_info)
|
|
|
|
|
2018-07-11 18:57:21 +00:00
|
|
|
if verify_decryption:
|
|
|
|
for file_name in os.listdir(self.tmp_dir):
|
|
|
|
if 'skip_encryption' in file_name:
|
|
|
|
continue
|
|
|
|
extension = os.path.splitext(file_name)[1][1:]
|
|
|
|
if extension not in ['mpd', 'm3u8', 'media_info']:
|
2018-09-18 20:34:18 +00:00
|
|
|
self._Decrypt(os.path.join(self.tmp_dir, file_name))
|
2018-07-11 18:57:21 +00:00
|
|
|
|
2018-02-07 17:51:20 +00:00
|
|
|
out_dir = self.tmp_dir
|
|
|
|
gold_dir = os.path.join(self.golden_file_dir, test_dir)
|
2018-07-16 21:32:55 +00:00
|
|
|
failure_messages = diff_files_policy.ProcessDiff(out_dir, gold_dir)
|
2018-02-07 17:51:20 +00:00
|
|
|
if failure_messages:
|
|
|
|
# Prepend the failure messages with the header.
|
|
|
|
failure_messages = [
|
|
|
|
_TEST_FAILURE_COMMAND_LINE_MESSAGE,
|
|
|
|
self.packager.GetCommandLine()
|
|
|
|
] + failure_messages
|
|
|
|
|
|
|
|
self.fail('\n'.join(failure_messages))
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
|
|
|
|
class PackagerFunctionalTest(PackagerAppTest):
|
|
|
|
|
|
|
|
def assertPackageSuccess(self, streams, flags=None):
|
|
|
|
self.assertEqual(self.packager.Package(streams, flags), 0)
|
|
|
|
|
2018-05-30 20:16:30 +00:00
|
|
|
def assertMpdGeneratorSuccess(self):
|
|
|
|
media_infos = glob.glob(os.path.join(self.tmp_dir, '*.media_info'))
|
|
|
|
self.assertTrue(media_infos)
|
|
|
|
|
|
|
|
flags = ['--input', ','.join(media_infos), '--output', self.mpd_output]
|
|
|
|
flags += ['--test_packager_version', '<tag>-<hash>-<test>']
|
|
|
|
self.assertEqual(self.packager.MpdGenerator(flags), 0)
|
|
|
|
|
2015-12-21 23:10:17 +00:00
|
|
|
def testVersion(self):
|
|
|
|
self.assertRegexpMatches(
|
2016-12-09 22:08:56 +00:00
|
|
|
self.packager.Version(), '^packager(.exe)? version '
|
|
|
|
r'((?P<tag>[\w\.]+)-)?(?P<hash>[a-f\d]+)-(debug|release)[\r\n]+.*$')
|
2015-12-21 23:10:17 +00:00
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
def testDumpStreamInfo(self):
|
2015-10-01 23:29:52 +00:00
|
|
|
test_file = os.path.join(self.test_data_dir, 'bear-640x360.mp4')
|
|
|
|
stream_info = self.packager.DumpStreamInfo(test_file)
|
2014-07-16 20:47:57 +00:00
|
|
|
expected_stream_info = ('Found 2 stream(s).\n'
|
2015-09-29 17:13:09 +00:00
|
|
|
'Stream [0] type: Video\n'
|
|
|
|
' codec_string: avc1.64001e\n'
|
|
|
|
' time_scale: 30000\n'
|
|
|
|
' duration: 82082 (2.7 seconds)\n'
|
|
|
|
' is_encrypted: false\n'
|
|
|
|
' codec: H264\n'
|
|
|
|
' width: 640\n'
|
|
|
|
' height: 360\n'
|
2015-12-09 23:54:02 +00:00
|
|
|
' pixel_aspect_ratio: 1:1\n'
|
2017-05-15 16:22:06 +00:00
|
|
|
' trick_play_factor: 0\n'
|
2015-09-29 17:13:09 +00:00
|
|
|
' nalu_length_size: 4\n\n'
|
|
|
|
'Stream [1] type: Audio\n'
|
2014-07-16 20:47:57 +00:00
|
|
|
' codec_string: mp4a.40.2\n'
|
|
|
|
' time_scale: 44100\n'
|
|
|
|
' duration: 121856 (2.8 seconds)\n'
|
|
|
|
' is_encrypted: false\n'
|
|
|
|
' codec: AAC\n'
|
|
|
|
' sample_bits: 16\n'
|
|
|
|
' num_channels: 2\n'
|
2015-09-25 22:58:18 +00:00
|
|
|
' sampling_frequency: 44100\n'
|
2015-09-29 17:13:09 +00:00
|
|
|
' language: und\n')
|
2016-08-14 22:28:21 +00:00
|
|
|
stream_info = stream_info.replace('\r\n', '\n')
|
2015-09-25 22:58:18 +00:00
|
|
|
self.assertIn(expected_stream_info, stream_info,
|
2016-04-21 23:27:05 +00:00
|
|
|
'\nExpecting: \n %s\n\nBut seeing: \n%s' %
|
|
|
|
(expected_stream_info, stream_info))
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testFirstStream(self):
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['0']), self._GetFlags(output_dash=True))
|
2018-02-07 18:49:15 +00:00
|
|
|
self._CheckTestResults('first-stream')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2015-11-05 01:49:35 +00:00
|
|
|
# Probably one of the most common scenarios is to package audio and video.
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideo(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetStreams(['audio', 'video']), self._GetFlags(output_dash=True))
|
2018-02-23 18:32:59 +00:00
|
|
|
self._CheckTestResults('audio-video')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2019-06-13 06:01:16 +00:00
|
|
|
def testAudioVideoWithAccessibilitiesAndRoles(self):
|
|
|
|
streams = [
|
|
|
|
self._GetStream(
|
|
|
|
'audio',
|
|
|
|
dash_accessibilities='urn:tva:metadata:cs:AudioPurposeCS:2007=1',
|
|
|
|
dash_roles='alternate'),
|
|
|
|
self._GetStream('video'),
|
|
|
|
]
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, self._GetFlags(output_dash=True))
|
|
|
|
self._CheckTestResults('audio-video-with-accessibilities-and-roles')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithTrickPlay(self):
|
2018-02-07 21:46:11 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio'),
|
|
|
|
self._GetStream('video'),
|
|
|
|
self._GetStream('video', trick_play_factor=1),
|
|
|
|
]
|
|
|
|
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(streams, self._GetFlags(output_dash=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('audio-video-with-trick-play')
|
2017-03-21 23:14:46 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithTwoTrickPlay(self):
|
2018-02-07 21:46:11 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio'),
|
|
|
|
self._GetStream('video'),
|
|
|
|
self._GetStream('video', trick_play_factor=1),
|
|
|
|
self._GetStream('video', trick_play_factor=2),
|
|
|
|
]
|
|
|
|
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(streams, self._GetFlags(output_dash=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('audio-video-with-two-trick-play')
|
2017-03-21 23:14:46 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithTwoTrickPlayDecreasingRate(self):
|
2018-02-07 21:46:11 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio'),
|
|
|
|
self._GetStream('video'),
|
|
|
|
self._GetStream('video', trick_play_factor=2),
|
|
|
|
self._GetStream('video', trick_play_factor=1),
|
|
|
|
]
|
|
|
|
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(streams, self._GetFlags(output_dash=True))
|
2017-03-21 23:14:46 +00:00
|
|
|
# Since the stream descriptors are sorted in packager app, a different
|
2017-05-15 16:22:06 +00:00
|
|
|
# order of trick play factors gets the same mpd.
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('audio-video-with-two-trick-play')
|
2017-03-21 23:14:46 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithLanguageOverride(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], language='por', hls=True),
|
|
|
|
self._GetFlags(default_language='por', output_dash=True,
|
|
|
|
output_hls=True))
|
2018-04-05 01:27:57 +00:00
|
|
|
self._CheckTestResults('audio-video-with-language-override')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithLanguageOverrideUsingMixingCode(self):
|
2018-04-05 01:27:57 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], language='por', hls=True),
|
|
|
|
self._GetFlags(default_language='pt', output_dash=True,
|
|
|
|
output_hls=True))
|
2018-04-05 01:27:57 +00:00
|
|
|
self._CheckTestResults('audio-video-with-language-override')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithLanguageOverrideUsingMixingCode2(self):
|
2018-04-05 01:27:57 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], language='pt', hls=True),
|
|
|
|
self._GetFlags(default_language='por', output_dash=True,
|
|
|
|
output_hls=True))
|
2018-04-05 01:27:57 +00:00
|
|
|
self._CheckTestResults('audio-video-with-language-override')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithLanguageOverrideUsingTwoCharacterCode(self):
|
2018-04-05 01:27:57 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], language='pt', hls=True),
|
|
|
|
self._GetFlags(default_language='pt', output_dash=True,
|
|
|
|
output_hls=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('audio-video-with-language-override')
|
2017-02-21 18:36:50 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithLanguageOverrideWithSubtag(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], language='por-BR', hls=True),
|
|
|
|
self._GetFlags(output_dash=True, output_hls=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('audio-video-with-language-override-with-subtag')
|
2017-04-10 20:20:45 +00:00
|
|
|
|
2019-10-18 22:15:31 +00:00
|
|
|
def testMp4TrailingMoov(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
test_files=['bear-640x360-trailing-moov.mp4']),
|
|
|
|
self._GetFlags(output_dash=True, output_hls=True))
|
|
|
|
self._CheckTestResults('mp4-trailing-moov')
|
|
|
|
|
2019-10-18 22:24:41 +00:00
|
|
|
def testVideoNonSquarePixel(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['video'],
|
|
|
|
test_files=['bear-640x360-non_square_pixel-with_pasp.mp4']),
|
|
|
|
self._GetFlags(output_dash=True, output_hls=True))
|
|
|
|
self._CheckTestResults('video-non-square-pixel')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAacHe(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-04-10 20:20:45 +00:00
|
|
|
self._GetStreams(
|
|
|
|
['audio'], test_files=['bear-640x360-aac_he-silent_right.mp4']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(output_dash=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('acc-he')
|
2017-02-21 18:36:50 +00:00
|
|
|
|
2018-09-18 20:34:18 +00:00
|
|
|
def testVideoAudioWebVTT(self):
|
|
|
|
audio_video_streams = self._GetStreams(['audio', 'video'])
|
|
|
|
text_stream = self._GetStreams(['text'], test_files=['bear-english.vtt'])
|
|
|
|
self.assertPackageSuccess(audio_video_streams + text_stream,
|
|
|
|
self._GetFlags(output_dash=True))
|
|
|
|
self._CheckTestResults('video-audio-webvtt')
|
|
|
|
|
|
|
|
def testVideoAudioTTML(self):
|
2015-11-05 01:49:35 +00:00
|
|
|
audio_video_streams = self._GetStreams(['audio', 'video'])
|
2018-09-18 20:34:18 +00:00
|
|
|
text_stream = self._GetStreams(['text'], test_files=['bear-english.ttml'])
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(audio_video_streams + text_stream,
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(output_dash=True))
|
2018-09-18 20:34:18 +00:00
|
|
|
self._CheckTestResults('video-audio-ttml')
|
2015-11-05 01:49:35 +00:00
|
|
|
|
2018-07-13 00:31:06 +00:00
|
|
|
def testVideoNoEditList(self):
|
|
|
|
stream = self._GetStream('video', test_file='bear-640x360-no_edit_list.mp4')
|
|
|
|
self.assertPackageSuccess([stream], self._GetFlags(output_dash=True))
|
|
|
|
self._CheckTestResults('video-no-edit-list')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcAacTs(self):
|
2016-04-28 22:02:55 +00:00
|
|
|
# Currently we only support live packaging for ts.
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetFlags(output_dash=True, output_hls=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('avc-aac-ts')
|
2016-04-28 22:02:55 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcAc3Ts(self):
|
2017-10-23 23:00:16 +00:00
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360-ac3.ts']),
|
2017-10-23 23:00:16 +00:00
|
|
|
self._GetFlags(output_hls=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('avc-ac3-ts')
|
2017-10-23 23:00:16 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcAc3TsToMp4(self):
|
2017-10-23 23:00:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
output_format='mp4',
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360-ac3.ts']),
|
2017-10-23 23:00:16 +00:00
|
|
|
self._GetFlags(output_hls=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('avc-ac3-ts-to-mp4')
|
2017-10-23 23:00:16 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcTsLivePlaylist(self):
|
2017-06-03 00:05:47 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2017-06-03 00:05:47 +00:00
|
|
|
self._GetFlags(
|
|
|
|
output_hls=True,
|
|
|
|
hls_playlist_type='LIVE',
|
|
|
|
time_shift_buffer_depth=0.5))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('avc-ts-live-playlist')
|
2017-06-03 00:05:47 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcTsLivePlaylistWithKeyRotation(self):
|
2017-06-20 23:30:03 +00:00
|
|
|
self.packager.Package(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2017-06-20 23:30:03 +00:00
|
|
|
self._GetFlags(
|
|
|
|
encryption=True,
|
|
|
|
key_rotation=True,
|
|
|
|
output_hls=True,
|
|
|
|
hls_playlist_type='LIVE',
|
|
|
|
time_shift_buffer_depth=0.5))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('avc-ts-live-playlist-with-key-rotation')
|
2017-06-20 23:30:03 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcTsEventPlaylist(self):
|
2017-06-03 00:05:47 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2017-06-03 00:05:47 +00:00
|
|
|
self._GetFlags(
|
|
|
|
output_hls=True,
|
|
|
|
hls_playlist_type='EVENT',
|
|
|
|
time_shift_buffer_depth=0.5))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('avc-ts-event-playlist')
|
2017-06-03 00:05:47 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcTsLivePlaylistAndDashDynamicWithSegmentDeletion(self):
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio'],
|
|
|
|
output_format='mp4',
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
|
|
|
self._GetFlags(
|
|
|
|
output_hls=True,
|
|
|
|
hls_playlist_type='LIVE',
|
|
|
|
output_dash=True,
|
|
|
|
segment_duration=0.5,
|
|
|
|
time_shift_buffer_depth=0.5,
|
|
|
|
preserved_segments_outside_live_window=1))
|
|
|
|
self._CheckTestResults(
|
|
|
|
'avc-ts-live-playlist-dash-dynamic-with-segment-deletion')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testVp8Webm(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['video'], test_files=['bear-640x360.webm']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(output_dash=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('vp8-webm')
|
2016-01-09 00:18:52 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testVp9Webm(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
test_files=['bear-320x240-vp9-opus.webm']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(output_dash=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('vp9-webm')
|
2016-01-09 00:18:52 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testVp9WebmWithBlockgroup(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['video'], test_files=['bear-vp9-blockgroup.webm']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(output_dash=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('vp9-webm-with-blockgroup')
|
2016-07-29 23:06:20 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testVorbisWebm(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-01-13 19:58:48 +00:00
|
|
|
self._GetStreams(['audio'],
|
|
|
|
test_files=['bear-320x240-audio-only.webm']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(output_dash=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('vorbis-webm')
|
2016-01-13 19:58:48 +00:00
|
|
|
|
2018-08-25 02:04:00 +00:00
|
|
|
def testAv1Mp4(self):
|
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['video'], test_files=['bear-av1.mp4']),
|
|
|
|
self._GetFlags(output_dash=True, output_hls=True))
|
2018-08-25 02:04:00 +00:00
|
|
|
self._CheckTestResults('av1-mp4')
|
|
|
|
|
|
|
|
def testAv1Mp4ToWebM(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='webm',
|
|
|
|
test_files=['bear-av1.mp4']),
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetFlags(output_dash=True, output_hls=True))
|
2018-08-25 02:04:00 +00:00
|
|
|
self._CheckTestResults('av1-mp4-to-webm')
|
|
|
|
|
|
|
|
def testAv1WebM(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='mp4',
|
|
|
|
test_files=['bear-av1.webm']),
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetFlags(output_dash=True, output_hls=True))
|
2018-08-25 02:04:00 +00:00
|
|
|
self._CheckTestResults('av1-webm')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('encryption', verify_decryption=True)
|
2017-09-20 22:49:00 +00:00
|
|
|
|
2018-09-18 00:27:02 +00:00
|
|
|
def testEncryptionWithMultiDrms(self):
|
2018-09-17 22:39:26 +00:00
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video']),
|
|
|
|
self._GetFlags(
|
2018-09-18 00:27:02 +00:00
|
|
|
encryption=True,
|
|
|
|
protection_systems='Widevine,PlayReady,FairPlay,Marlin',
|
|
|
|
output_dash=True,
|
|
|
|
output_hls=True))
|
|
|
|
self._CheckTestResults('encryption-with-multi-drms')
|
2018-09-17 22:39:26 +00:00
|
|
|
|
2017-10-17 23:03:08 +00:00
|
|
|
# Test deprecated flag --enable_fixed_key_encryption, which is still
|
|
|
|
# supported currently.
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionUsingFixedKey(self):
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(output_dash=True) + [
|
2017-10-17 23:03:08 +00:00
|
|
|
'--enable_fixed_key_encryption', '--key_id={0}'.format(
|
|
|
|
self.encryption_key_id), '--key={0}'.format(self.encryption_key),
|
2018-01-10 00:04:40 +00:00
|
|
|
'--clear_lead={0}'.format(self.clear_lead), '--iv={0}'.format(
|
|
|
|
self.encryption_iv)
|
2017-10-17 23:03:08 +00:00
|
|
|
]
|
|
|
|
self.assertPackageSuccess(self._GetStreams(['audio', 'video']), flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('encryption-using-fixed-key', verify_decryption=True)
|
2017-10-17 23:03:08 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionMultiKeys(self):
|
2017-09-20 22:49:00 +00:00
|
|
|
audio_key_id = '10111213141516171819202122232425'
|
|
|
|
audio_key = '11121314151617181920212223242526'
|
|
|
|
video_key_id = '20212223242526272829303132333435'
|
|
|
|
video_key = '21222324252627282930313233343536'
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(output_dash=True) + [
|
2017-10-17 23:03:08 +00:00
|
|
|
'--enable_raw_key_encryption',
|
2017-09-20 22:49:00 +00:00
|
|
|
'--keys=label=AUDIO:key_id={0}:key={1},label=SD:key_id={2}:key={3}'.
|
2018-01-10 00:04:40 +00:00
|
|
|
format(audio_key_id, audio_key,
|
|
|
|
video_key_id, video_key), '--clear_lead={0}'.format(
|
|
|
|
self.clear_lead), '--iv={0}'.format(self.encryption_iv)
|
2017-09-20 22:49:00 +00:00
|
|
|
]
|
|
|
|
self.assertPackageSuccess(self._GetStreams(['audio', 'video']), flags)
|
2018-03-07 19:24:52 +00:00
|
|
|
self._CheckTestResults('encryption-multi-keys')
|
2017-09-20 22:49:00 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionMultiKeysWithStreamLabel(self):
|
2017-09-20 22:49:00 +00:00
|
|
|
audio_key_id = '20212223242526272829303132333435'
|
|
|
|
audio_key = '21222324252627282930313233343536'
|
|
|
|
video_key_id = '10111213141516171819202122232425'
|
|
|
|
video_key = '11121314151617181920212223242526'
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(output_dash=True) + [
|
2017-10-17 23:03:08 +00:00
|
|
|
'--enable_raw_key_encryption',
|
2017-09-20 22:49:00 +00:00
|
|
|
'--keys=label=MyAudio:key_id={0}:key={1},label=:key_id={2}:key={3}'.
|
2018-01-10 00:04:40 +00:00
|
|
|
format(audio_key_id, audio_key,
|
|
|
|
video_key_id, video_key), '--clear_lead={0}'.format(
|
|
|
|
self.clear_lead), '--iv={0}'.format(self.encryption_iv)
|
2017-09-20 22:49:00 +00:00
|
|
|
]
|
|
|
|
# DRM label 'MyVideo' is not defined, will fall back to the key for the
|
|
|
|
# empty default label.
|
2018-02-07 21:46:11 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio', drm_label='MyAudio'),
|
|
|
|
self._GetStream('video', drm_label='MyVideo')
|
|
|
|
]
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-03-07 19:24:52 +00:00
|
|
|
self._CheckTestResults('encryption-multi-keys-with-stream-label')
|
2017-09-20 22:49:00 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionOfOnlyVideoStream(self):
|
2018-02-07 21:46:11 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio', skip_encryption=True),
|
|
|
|
self._GetStream('video')
|
|
|
|
]
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True)
|
2018-02-07 21:46:11 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'encryption-of-only-video-stream', verify_decryption=True)
|
2017-06-14 23:18:16 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndTrickPlay(self):
|
2018-02-07 21:46:11 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio'),
|
|
|
|
self._GetStream('video'),
|
|
|
|
self._GetStream('video', trick_play_factor=1),
|
|
|
|
]
|
|
|
|
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(streams,
|
|
|
|
self._GetFlags(encryption=True, output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('encryption-and-trick-play', verify_decryption=True)
|
2017-03-21 23:14:46 +00:00
|
|
|
|
|
|
|
# TODO(hmchen): Add a test case that SD and HD AdapatationSet share one trick
|
|
|
|
# play stream.
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndTwoTrickPlays(self):
|
2018-02-07 21:46:11 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio'),
|
|
|
|
self._GetStream('video'),
|
|
|
|
self._GetStream('video', trick_play_factor=1),
|
|
|
|
self._GetStream('video', trick_play_factor=2),
|
|
|
|
]
|
|
|
|
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(streams,
|
|
|
|
self._GetFlags(encryption=True, output_dash=True))
|
2018-03-07 19:24:52 +00:00
|
|
|
self._CheckTestResults('encryption-and-two-trick-plays')
|
2017-03-21 23:14:46 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndNoClearLead(self):
|
2018-03-07 19:24:52 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio'),
|
|
|
|
self._GetStream('video')
|
|
|
|
]
|
|
|
|
|
2018-01-10 00:04:40 +00:00
|
|
|
self.clear_lead = 0
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(streams,
|
|
|
|
self._GetFlags(encryption=True, output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'encryption-and-no-clear-lead', verify_decryption=True)
|
2017-05-09 22:49:01 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndNoPsshInStream(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-03-15 19:42:00 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(
|
|
|
|
encryption=True, include_pssh_in_stream=False, output_dash=True))
|
2018-03-07 19:24:52 +00:00
|
|
|
self._CheckTestResults('encryption-and-no-pssh-in-stream')
|
2017-03-15 19:42:00 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionCbc1(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-04-21 23:28:21 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(
|
|
|
|
encryption=True, protection_scheme='cbc1', output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('encryption-cbc-1', verify_decryption=True)
|
2016-04-21 23:28:21 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionCens(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-04-21 23:28:21 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(
|
|
|
|
encryption=True, protection_scheme='cens', output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('encryption-cens', verify_decryption=True)
|
2016-04-21 23:28:21 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionCbcs(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-04-21 23:28:21 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(
|
|
|
|
encryption=True, protection_scheme='cbcs', output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('encryption-cbcs', verify_decryption=True)
|
2018-01-10 00:04:40 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndAdCues(self):
|
2018-01-10 00:04:40 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], hls=True),
|
|
|
|
self._GetFlags(encryption=True, output_dash=True, output_hls=True,
|
|
|
|
ad_cues='1.5'))
|
2018-03-07 19:24:52 +00:00
|
|
|
self._CheckTestResults('encryption-and-ad-cues')
|
2016-04-21 23:28:21 +00:00
|
|
|
|
2018-12-07 02:04:55 +00:00
|
|
|
def testEncryptionAndAdCuesAndDashTrickPlay(self):
|
|
|
|
streams = [
|
|
|
|
self._GetStream('audio'),
|
|
|
|
self._GetStream('video'),
|
|
|
|
self._GetStream('video', trick_play_factor=1),
|
|
|
|
]
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
streams, self._GetFlags(
|
|
|
|
encryption=True, output_dash=True, ad_cues='1.5'))
|
|
|
|
self._CheckTestResults('encryption-and-ad-cues-and-dash-trick-play')
|
|
|
|
|
2018-05-23 00:26:18 +00:00
|
|
|
def testEncryptionAndAdCuesSplitContent(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'], hls=True, split_content_on_ad_cues=True),
|
|
|
|
self._GetFlags(
|
|
|
|
encryption=True, output_dash=True, output_hls=True, ad_cues='1.5'))
|
|
|
|
self._CheckTestResults('encryption-and-ad-cues-split-content')
|
|
|
|
|
2018-05-14 20:45:03 +00:00
|
|
|
def testHlsAudioVideoTextWithAdCues(self):
|
|
|
|
streams = [
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStream('audio', hls=True, segmented=True),
|
|
|
|
self._GetStream('video', hls=True, segmented=True),
|
|
|
|
self._GetStream(
|
|
|
|
'text', hls=True, segmented=True, test_file='bear-english.vtt')
|
2018-05-14 20:45:03 +00:00
|
|
|
]
|
|
|
|
flags = self._GetFlags(output_hls=True, ad_cues='1.5')
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
|
|
|
self._CheckTestResults('hls-audio-video-text-with-ad-cues')
|
|
|
|
|
2018-05-22 21:46:45 +00:00
|
|
|
def testVttTextToMp4WithAdCues(self):
|
|
|
|
streams = [
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStream('audio', hls=True, segmented=True),
|
|
|
|
self._GetStream('video', hls=True, segmented=True),
|
|
|
|
self._GetStream(
|
|
|
|
'text',
|
|
|
|
hls=True,
|
|
|
|
segmented=True,
|
|
|
|
test_file='bear-english.vtt',
|
|
|
|
output_format='mp4')
|
2018-05-22 21:46:45 +00:00
|
|
|
]
|
2018-07-10 23:04:56 +00:00
|
|
|
flags = self._GetFlags(output_dash=True, output_hls=True,
|
2019-11-15 19:53:47 +00:00
|
|
|
generate_static_live_mpd=True, ad_cues='1.5')
|
2018-05-22 21:46:45 +00:00
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-20 20:00:10 +00:00
|
|
|
# Mpd cannot be validated right now since we don't generate determinstic
|
|
|
|
# mpd with multiple inputs due to thread racing.
|
|
|
|
# TODO(b/73349711): Generate determinstic mpd or at least validate mpd
|
|
|
|
# schema.
|
|
|
|
self._CheckTestResults(
|
|
|
|
'vtt-text-to-mp4-with-ad-cues',
|
|
|
|
diff_files_policy=DiffFilesPolicy(
|
|
|
|
allowed_diff_files=['output.mpd'], exact=False))
|
2018-05-22 21:46:45 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testWebmSubsampleEncryption(self):
|
2018-03-07 19:24:52 +00:00
|
|
|
streams = [
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStream('video', test_file='bear-320x180-vp9-altref.webm')
|
2018-03-07 19:24:52 +00:00
|
|
|
]
|
2018-05-01 18:18:19 +00:00
|
|
|
self.assertPackageSuccess(streams,
|
|
|
|
self._GetFlags(encryption=True, output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('webm-subsample-encryption', verify_decryption=True)
|
2016-07-27 00:51:08 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testWebmVp9FullSampleEncryption(self):
|
2018-03-07 19:24:52 +00:00
|
|
|
streams = [
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStream('video', test_file='bear-320x180-vp9-altref.webm')
|
2018-03-07 19:24:52 +00:00
|
|
|
]
|
|
|
|
flags = self._GetFlags(
|
2018-05-01 18:18:19 +00:00
|
|
|
encryption=True, vp9_subsample_encryption=False, output_dash=True)
|
2018-03-07 19:24:52 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'webm-vp9-full-sample-encryption', verify_decryption=True)
|
2017-03-28 15:19:15 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcTsWithEncryption(self):
|
2016-06-30 22:25:52 +00:00
|
|
|
# Currently we only support live packaging for ts.
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2017-01-07 02:40:37 +00:00
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults('avc-ts-with-encryption')
|
2016-06-30 22:25:52 +00:00
|
|
|
|
2018-05-18 00:58:34 +00:00
|
|
|
def testAvcTsAacPackedAudioWithEncryption(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
streams = [
|
|
|
|
self._GetStream(
|
|
|
|
'audio',
|
|
|
|
output_format='aac',
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_file='bear-640x360.ts'),
|
|
|
|
self._GetStream(
|
2018-09-18 20:34:18 +00:00
|
|
|
'video', segmented=True, hls=True, test_file='bear-640x360.ts')
|
2018-05-18 00:58:34 +00:00
|
|
|
]
|
|
|
|
flags = self._GetFlags(encryption=True, output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
|
|
|
self._CheckTestResults('avc-ts-aac-packed-audio-with-encryption')
|
|
|
|
|
2018-08-07 23:01:43 +00:00
|
|
|
def testAvcTsWithEncryptionAndFairPlay(self):
|
2017-11-12 22:56:25 +00:00
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2018-09-18 00:27:02 +00:00
|
|
|
self._GetFlags(
|
|
|
|
encryption=True, protection_systems='FairPlay', output_hls=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults('avc-ts-with-encryption-and-fairplay')
|
2017-11-12 22:56:25 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcAc3TsWithEncryption(self):
|
2017-10-23 23:00:16 +00:00
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360-ac3.ts']),
|
2017-10-23 23:00:16 +00:00
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults('avc-ac3-ts-with-encryption')
|
2017-10-23 23:00:16 +00:00
|
|
|
|
2018-05-18 00:58:34 +00:00
|
|
|
def testAvcTsAc3PackedAudioWithEncryption(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
streams = [
|
|
|
|
self._GetStream(
|
|
|
|
'audio',
|
|
|
|
output_format='ac3',
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_file='bear-640x360-ac3.ts'),
|
|
|
|
self._GetStream(
|
2018-09-18 20:34:18 +00:00
|
|
|
'video', segmented=True, hls=True, test_file='bear-640x360-ac3.ts')
|
2018-05-18 00:58:34 +00:00
|
|
|
]
|
|
|
|
flags = self._GetFlags(encryption=True, output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
|
|
|
self._CheckTestResults('avc-ts-ac3-packed-audio-with-encryption')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAvcTsWithEncryptionExerciseEmulationPrevention(self):
|
2017-06-14 23:18:16 +00:00
|
|
|
self.encryption_key = 'ad7e9786def9159db6724be06dfcde7a'
|
2017-03-23 18:05:22 +00:00
|
|
|
# Currently we only support live packaging for ts.
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-03-23 18:05:22 +00:00
|
|
|
self._GetStreams(
|
|
|
|
['video'],
|
|
|
|
output_format='ts',
|
2018-02-07 21:46:11 +00:00
|
|
|
segmented=True,
|
2017-10-10 21:54:36 +00:00
|
|
|
hls=True,
|
2017-03-23 18:05:22 +00:00
|
|
|
test_files=['sintel-1024x436.mp4']),
|
|
|
|
self._GetFlags(
|
|
|
|
encryption=True,
|
|
|
|
output_hls=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'avc-ts-with-encryption-exercise-emulation-prevention')
|
2017-03-23 18:05:22 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testWebmWithEncryption(self):
|
2018-09-18 20:34:18 +00:00
|
|
|
streams = [self._GetStream('video', test_file='bear-640x360.webm')]
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True)
|
2018-03-07 19:24:52 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('webm-with-encryption', verify_decryption=True)
|
2016-01-21 00:14:24 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testHevcWithEncryption(self):
|
2018-03-07 19:24:52 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('video', test_file='bear-640x360-hevc.mp4')
|
|
|
|
]
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True)
|
2018-03-07 19:24:52 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('hevc-with-encryption', verify_decryption=True)
|
2015-10-29 00:26:29 +00:00
|
|
|
|
2019-09-23 06:24:33 +00:00
|
|
|
def testHdr10WithEncryption(self):
|
|
|
|
streams = [
|
|
|
|
self._GetStream('video', test_file='bear-640x360-hevc-hdr10.mp4')
|
|
|
|
]
|
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True, output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
|
|
|
self._CheckTestResults('hdr10-with-encryption')
|
|
|
|
|
2019-10-09 21:30:35 +00:00
|
|
|
def testDolbyVisionProfile5WithEncryption(self):
|
2019-09-21 01:02:13 +00:00
|
|
|
streams = [
|
2019-10-09 21:30:35 +00:00
|
|
|
self._GetStream('video', test_file='sparks_dovi_5.mp4')
|
2019-09-21 01:02:13 +00:00
|
|
|
]
|
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True, output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2019-10-09 21:30:35 +00:00
|
|
|
self._CheckTestResults('dolby-vision-profile-5-with-encryption')
|
2019-09-21 01:02:13 +00:00
|
|
|
|
2019-11-17 05:55:23 +00:00
|
|
|
def testDolbyVisionProfile8WithEncryption(self):
|
|
|
|
streams = [
|
|
|
|
self._GetStream('video', test_file='sparks_dovi_8.mp4')
|
|
|
|
]
|
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True, output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
|
|
|
self._CheckTestResults('dolby-vision-profile-8-with-encryption')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testVp8Mp4WithEncryption(self):
|
2018-03-07 19:24:52 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('video',
|
|
|
|
output_format='mp4',
|
|
|
|
test_file='bear-640x360.webm')
|
|
|
|
]
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True)
|
2018-03-07 19:24:52 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('vp8-mp4-with-encryption', verify_decryption=True)
|
2016-01-09 00:18:52 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testOpusVp9Mp4WithEncryption(self):
|
2018-03-07 19:24:52 +00:00
|
|
|
streams = [
|
|
|
|
self._GetStream('audio',
|
|
|
|
output_format='mp4',
|
|
|
|
test_file='bear-320x240-vp9-opus.webm'),
|
|
|
|
self._GetStream('video',
|
|
|
|
output_format='mp4',
|
|
|
|
test_file='bear-320x240-vp9-opus.webm'),
|
|
|
|
]
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True)
|
2018-03-07 19:24:52 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'opus-vp9-mp4-with-encryption', verify_decryption=True)
|
2016-01-09 00:18:52 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testFlacWithEncryption(self):
|
2018-04-25 18:27:53 +00:00
|
|
|
streams = [
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStream('audio', test_file='bear-flac.mp4'),
|
2018-04-25 18:27:53 +00:00
|
|
|
]
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(encryption=True, output_dash=True, output_hls=True)
|
2018-04-25 18:27:53 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('flac-with-encryption', verify_decryption=True)
|
2018-04-25 18:27:53 +00:00
|
|
|
|
2018-10-09 17:41:18 +00:00
|
|
|
def testAv1Mp4WithEncryption(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['video'], test_files=['bear-av1.mp4']),
|
|
|
|
self._GetFlags(encryption=True, output_dash=True, output_hls=True))
|
|
|
|
self._CheckTestResults('av1-mp4-with-encryption', verify_decryption=True)
|
|
|
|
|
|
|
|
def testAv1WebMWithEncryption(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['video'], test_files=['bear-av1.webm']),
|
|
|
|
self._GetFlags(encryption=True, output_dash=True, output_hls=True))
|
|
|
|
self._CheckTestResults('av1-webm-with-encryption', verify_decryption=True)
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testWvmInput(self):
|
2017-06-14 23:18:16 +00:00
|
|
|
self.encryption_key = '9248d245390e0a49d483ba9b43fc69c3'
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['0', '1', '2', '3'],
|
|
|
|
output_format='mp4',
|
|
|
|
test_files=['bear-multi-configs.wvm']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(decryption=True, output_dash=True))
|
2017-03-23 18:36:47 +00:00
|
|
|
# Output timescale is 90000.
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('wvm-input')
|
2017-03-23 18:36:47 +00:00
|
|
|
|
2017-05-23 02:41:26 +00:00
|
|
|
# TODO(kqyang): Fix shared_library not supporting strip_parameter_set_nalus
|
|
|
|
# problem.
|
|
|
|
@unittest.skipUnless(
|
2017-12-11 22:06:50 +00:00
|
|
|
test_env.options.libpackager_type == 'static_library',
|
2017-05-23 02:41:26 +00:00
|
|
|
'libpackager shared_library does not support '
|
|
|
|
'--strip_parameter_set_nalus flag.'
|
|
|
|
)
|
2018-05-16 22:39:05 +00:00
|
|
|
def testWvmInputWithoutStrippingParameterSetNalus(self):
|
2017-06-14 23:18:16 +00:00
|
|
|
self.encryption_key = '9248d245390e0a49d483ba9b43fc69c3'
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-09-18 20:34:18 +00:00
|
|
|
self._GetStreams(['0', '1', '2', '3'],
|
|
|
|
output_format='mp4',
|
|
|
|
test_files=['bear-multi-configs.wvm']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(
|
|
|
|
strip_parameter_set_nalus=False, decryption=True, output_dash=True))
|
2017-03-23 18:36:47 +00:00
|
|
|
# Output timescale is 90000.
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('wvm-input-without-stripping-parameters-set-nalus')
|
2017-03-23 18:36:47 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndRandomIv(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, random_iv=True, output_dash=True))
|
2015-09-25 22:58:18 +00:00
|
|
|
# The outputs are encrypted with random iv, so they are not the same as
|
|
|
|
# golden files.
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'encryption',
|
|
|
|
verify_decryption=True,
|
|
|
|
diff_files_policy=DiffFilesPolicy(
|
|
|
|
allowed_diff_files=[
|
|
|
|
'bear-640x360-audio.mp4', 'bear-640x360-video.mp4'
|
|
|
|
],
|
2018-07-16 21:32:55 +00:00
|
|
|
exact=True,
|
|
|
|
allow_updating_golden_files=False))
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndRealClock(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, output_dash=True, use_fake_clock=False))
|
2015-09-25 22:58:18 +00:00
|
|
|
# The outputs are generated with real clock, so they are not the same as
|
|
|
|
# golden files.
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'encryption',
|
|
|
|
verify_decryption=True,
|
|
|
|
diff_files_policy=DiffFilesPolicy(
|
|
|
|
allowed_diff_files=[
|
|
|
|
'bear-640x360-audio.mp4', 'bear-640x360-video.mp4'
|
|
|
|
],
|
2018-07-16 21:32:55 +00:00
|
|
|
exact=True,
|
|
|
|
allow_updating_golden_files=False))
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndNonDashIfIop(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, dash_if_iop=False, output_dash=True))
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults('encryption-and-non-dash-if-iop')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionAndOutputMediaInfo(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2016-04-21 23:27:05 +00:00
|
|
|
self._GetFlags(encryption=True, output_media_info=True))
|
2018-03-07 17:25:21 +00:00
|
|
|
self._CheckTestResults('encryption-and-output-media-info')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-30 20:16:30 +00:00
|
|
|
def testEncryptionAndOutputMediaInfoAndMpdFromMediaInfo(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
# The order is not determinstic if there are more than one
|
|
|
|
# AdaptationSets, so only one is included here.
|
|
|
|
self._GetStreams(['video']),
|
|
|
|
self._GetFlags(encryption=True, output_media_info=True))
|
|
|
|
self.assertMpdGeneratorSuccess()
|
|
|
|
self._CheckTestResults(
|
|
|
|
'encryption-and-output-media-info-and-mpd-from-media-info')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testHlsSingleSegmentMp4Encrypted(self):
|
2017-10-10 21:54:36 +00:00
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], hls=True),
|
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('hls-single-segment-mp4-encrypted')
|
2017-10-10 21:54:36 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEc3AndHlsSingleSegmentMp4Encrypted(self):
|
2018-01-21 20:21:01 +00:00
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'], hls=True, test_files=['bear-640x360-ec3.mp4']),
|
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('ec3-and-hls-single-segment-mp4-encrypted')
|
2018-01-21 20:21:01 +00:00
|
|
|
|
2018-05-18 00:58:34 +00:00
|
|
|
def testEc3PackedAudioEncrypted(self):
|
|
|
|
streams = [
|
|
|
|
self._GetStream(
|
|
|
|
'audio',
|
|
|
|
output_format='ec3',
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_file='bear-640x360-ec3.mp4'),
|
|
|
|
self._GetStream(
|
|
|
|
'video',
|
|
|
|
output_format='ts',
|
|
|
|
segmented=True,
|
|
|
|
hls=True,
|
|
|
|
test_file='bear-640x360-ec3.mp4')
|
|
|
|
]
|
|
|
|
flags = self._GetFlags(encryption=True, output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
|
|
|
self._CheckTestResults('ec3-packed-audio-encrypted')
|
|
|
|
|
2017-10-10 21:54:36 +00:00
|
|
|
# Test HLS with multi-segment mp4 and content in subdirectories.
|
2018-05-16 22:39:05 +00:00
|
|
|
def testHlsMultiSegmentMp4WithCustomPath(self):
|
2017-10-10 21:54:36 +00:00
|
|
|
test_file = os.path.join(self.test_data_dir, 'bear-640x360.mp4')
|
|
|
|
# {tmp}/audio/audio-init.mp4, {tmp}/audio/audio-1.m4s etc.
|
|
|
|
audio_output_prefix = os.path.join(self.tmp_dir, 'audio', 'audio')
|
|
|
|
# {tmp}/video/video-init.mp4, {tmp}/video/video-1.m4s etc.
|
|
|
|
video_output_prefix = os.path.join(self.tmp_dir, 'video', 'video')
|
2018-03-01 18:48:10 +00:00
|
|
|
|
2017-10-10 21:54:36 +00:00
|
|
|
self.assertPackageSuccess(
|
|
|
|
[
|
|
|
|
'input=%s,stream=audio,init_segment=%s-init.mp4,'
|
|
|
|
'segment_template=%s-$Number$.m4s,playlist_name=audio/audio.m3u8' %
|
|
|
|
(test_file, audio_output_prefix, audio_output_prefix),
|
|
|
|
'input=%s,stream=video,init_segment=%s-init.mp4,'
|
|
|
|
'segment_template=%s-$Number$.m4s,playlist_name=video/video.m3u8' %
|
|
|
|
(test_file, video_output_prefix, video_output_prefix),
|
|
|
|
],
|
|
|
|
self._GetFlags(output_hls=True))
|
2018-03-01 18:48:10 +00:00
|
|
|
|
|
|
|
self._CheckTestResults('hls-multi-segment-mp4-with-custom-path')
|
2017-10-10 21:54:36 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfile(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-03-17 01:37:53 +00:00
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
|
|
|
self._GetFlags(
|
2018-05-01 18:18:19 +00:00
|
|
|
output_dash=True,
|
|
|
|
utc_timings='urn:mpeg:dash:utc:http-xsdate:2014='
|
2018-03-17 01:37:53 +00:00
|
|
|
'http://foo.bar/my_body_is_the_current_date_and_time,'
|
|
|
|
'urn:mpeg:dash:utc:http-head:2014='
|
|
|
|
'http://foo.bar/check_me_for_the_date_header'))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults('live-profile')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfileWithWebM(self):
|
2018-09-18 20:34:18 +00:00
|
|
|
streams = self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
test_file='bear-640x360.webm')
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(output_dash=True, output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-05-01 20:16:12 +00:00
|
|
|
self._CheckTestResults('live-profile-with-webm')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveStaticProfile(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-02-07 21:46:11 +00:00
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
2019-11-15 19:53:47 +00:00
|
|
|
self._GetFlags(output_dash=True, generate_static_live_mpd=True))
|
2018-02-27 18:58:24 +00:00
|
|
|
self._CheckTestResults('live-static-profile')
|
2017-02-09 00:42:44 +00:00
|
|
|
|
2018-09-12 21:47:20 +00:00
|
|
|
def testLiveStaticProfileWithTimeInSegmentName(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
segmented=True,
|
|
|
|
using_time_specifier=True),
|
2019-11-15 19:53:47 +00:00
|
|
|
self._GetFlags(output_dash=True, generate_static_live_mpd=True))
|
2018-09-12 21:47:20 +00:00
|
|
|
self._CheckTestResults('live-static-profile-with-time-in-segment-name')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfileAndEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-02-07 21:46:11 +00:00
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, output_dash=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults('live-profile-and-encryption')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfileAndEncryptionAndNonDashIfIop(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-02-07 21:46:11 +00:00
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, dash_if_iop=False, output_dash=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'live-profile-and-encryption-and-non-dash-if-iop')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfileAndEncryptionAndMultFiles(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
2018-02-07 21:46:11 +00:00
|
|
|
segmented=True,
|
2016-06-01 23:28:56 +00:00
|
|
|
test_files=['bear-1280x720.mp4', 'bear-640x360.mp4',
|
|
|
|
'bear-320x180.mp4']),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, output_dash=True))
|
2015-10-01 23:29:52 +00:00
|
|
|
# Mpd cannot be validated right now since we don't generate determinstic
|
|
|
|
# mpd with multiple inputs due to thread racing.
|
2018-02-27 18:58:24 +00:00
|
|
|
# TODO(b/73349711): Generate determinstic mpd or at least validate mpd
|
|
|
|
# schema.
|
2018-07-11 18:57:21 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'live-profile-and-encryption-and-mult-files',
|
|
|
|
diff_files_policy=DiffFilesPolicy(
|
|
|
|
allowed_diff_files=['output.mpd'], exact=False))
|
2015-10-01 23:29:52 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfileAndKeyRotation(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-02-07 21:46:11 +00:00
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(encryption=True, key_rotation=True, output_dash=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults('live-profile-and-key-rotation')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-08-20 22:45:02 +00:00
|
|
|
def testLiveProfileAndKeyRotationCbcs(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
|
|
|
self._GetFlags(
|
|
|
|
encryption=True,
|
|
|
|
protection_scheme='cbcs',
|
|
|
|
key_rotation=True,
|
|
|
|
output_dash=True))
|
|
|
|
self._CheckTestResults('live-profile-and-key-rotation-cbcs')
|
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfileAndKeyRotationAndNoPsshInStream(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-02-07 21:46:11 +00:00
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
2017-03-15 19:42:00 +00:00
|
|
|
self._GetFlags(
|
2018-05-01 18:18:19 +00:00
|
|
|
encryption=True,
|
|
|
|
key_rotation=True,
|
|
|
|
include_pssh_in_stream=False,
|
|
|
|
output_dash=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'live-profile-and-key-rotation-and-no-pssh-in-stream')
|
2017-03-15 19:42:00 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testLiveProfileAndKeyRotationAndNonDashIfIop(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-02-07 21:46:11 +00:00
|
|
|
self._GetStreams(['audio', 'video'], segmented=True),
|
2018-05-01 18:18:19 +00:00
|
|
|
self._GetFlags(
|
|
|
|
encryption=True,
|
|
|
|
key_rotation=True,
|
|
|
|
dash_if_iop=False,
|
|
|
|
output_dash=True))
|
2018-03-01 00:38:51 +00:00
|
|
|
self._CheckTestResults(
|
|
|
|
'live-profile-and-key-rotation-and-non-dash-if-iop')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
|
|
|
@unittest.skipUnless(test_env.has_aes_flags, 'Requires AES credentials.')
|
2014-07-16 20:47:57 +00:00
|
|
|
def testWidevineEncryptionWithAes(self):
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(widevine_encryption=True, output_dash=True)
|
2017-06-14 23:18:16 +00:00
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test',
|
|
|
|
'--aes_signing_key=' + test_env.options.aes_signing_key,
|
|
|
|
'--aes_signing_iv=' + test_env.options.aes_signing_iv
|
|
|
|
]
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(self._GetStreams(['audio', 'video']), flags)
|
2015-09-25 22:58:18 +00:00
|
|
|
self._AssertStreamInfo(self.output[0], 'is_encrypted: true')
|
|
|
|
self._AssertStreamInfo(self.output[1], 'is_encrypted: true')
|
|
|
|
|
2016-12-13 23:48:54 +00:00
|
|
|
@unittest.skipUnless(test_env.has_aes_flags, 'Requires AES credentials.')
|
2017-02-09 00:47:59 +00:00
|
|
|
def testWidevineEncryptionWithAesAndMultFiles(self):
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(widevine_encryption=True, output_dash=True)
|
2017-06-14 23:18:16 +00:00
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test',
|
|
|
|
'--aes_signing_key=' + test_env.options.aes_signing_key,
|
|
|
|
'--aes_signing_iv=' + test_env.options.aes_signing_iv
|
|
|
|
]
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-12-13 23:48:54 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
test_files=['bear-1280x720.mp4', 'bear-640x360.mp4',
|
|
|
|
'bear-320x180.mp4']), flags)
|
|
|
|
with open(self.mpd_output, 'rb') as f:
|
2019-02-01 02:33:25 +00:00
|
|
|
logging.info(f.read())
|
2016-12-13 23:48:54 +00:00
|
|
|
# TODO(kqyang): Add some validations.
|
|
|
|
|
2015-09-25 22:58:18 +00:00
|
|
|
@unittest.skipUnless(test_env.has_aes_flags, 'Requires AES credentials.')
|
2014-07-16 20:47:57 +00:00
|
|
|
def testKeyRotationWithAes(self):
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(
|
|
|
|
widevine_encryption=True, key_rotation=True, output_dash=True)
|
2017-06-14 23:18:16 +00:00
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test',
|
|
|
|
'--aes_signing_key=' + test_env.options.aes_signing_key,
|
|
|
|
'--aes_signing_iv=' + test_env.options.aes_signing_iv
|
|
|
|
]
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(self._GetStreams(['audio', 'video']), flags)
|
2015-09-25 22:58:18 +00:00
|
|
|
self._AssertStreamInfo(self.output[0], 'is_encrypted: true')
|
|
|
|
self._AssertStreamInfo(self.output[1], 'is_encrypted: true')
|
|
|
|
|
|
|
|
@unittest.skipUnless(test_env.has_rsa_flags, 'Requires RSA credentials.')
|
2014-07-16 20:47:57 +00:00
|
|
|
def testWidevineEncryptionWithRsa(self):
|
2018-05-01 18:18:19 +00:00
|
|
|
flags = self._GetFlags(widevine_encryption=True, output_dash=True)
|
2017-06-14 23:18:16 +00:00
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test',
|
|
|
|
'--rsa_signing_key_path=' + test_env.options.rsa_signing_key_path
|
|
|
|
]
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(self._GetStreams(['audio', 'video']), flags)
|
2015-09-25 22:58:18 +00:00
|
|
|
self._AssertStreamInfo(self.output[0], 'is_encrypted: true')
|
|
|
|
self._AssertStreamInfo(self.output[1], 'is_encrypted: true')
|
|
|
|
|
2018-02-06 17:07:10 +00:00
|
|
|
def testHlsSegmentedWebVtt(self):
|
2018-07-03 23:52:05 +00:00
|
|
|
streams = self._GetStreams(
|
|
|
|
['audio', 'video'], output_format='ts', segmented=True)
|
2018-02-06 17:07:10 +00:00
|
|
|
streams += self._GetStreams(
|
2018-10-10 22:30:28 +00:00
|
|
|
['text'],
|
|
|
|
test_files=['bear-english.vtt'],
|
|
|
|
segmented=True,
|
|
|
|
hls_characteristics='public.accessibility.transcribes-spoken-dialog;'
|
|
|
|
'private.accessibility.widevine-special')
|
2018-02-06 17:07:10 +00:00
|
|
|
|
|
|
|
flags = self._GetFlags(output_hls=True)
|
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-02-26 20:12:59 +00:00
|
|
|
self._CheckTestResults('hls-segmented-webvtt')
|
2018-02-06 17:07:10 +00:00
|
|
|
|
2018-07-10 23:04:56 +00:00
|
|
|
def testBandwidthOverride(self):
|
2018-04-30 22:43:58 +00:00
|
|
|
streams = [
|
2018-07-10 23:04:56 +00:00
|
|
|
self._GetStream('audio', hls=True, bandwidth=11111),
|
|
|
|
self._GetStream('video', hls=True, bandwidth=44444)
|
2018-04-30 22:43:58 +00:00
|
|
|
]
|
|
|
|
|
2018-07-10 23:04:56 +00:00
|
|
|
flags = self._GetFlags(output_dash=True, output_hls=True)
|
2018-04-30 22:43:58 +00:00
|
|
|
|
|
|
|
self.assertPackageSuccess(streams, flags)
|
2018-07-10 23:04:56 +00:00
|
|
|
self._CheckTestResults('bandwidth-override')
|
2018-04-30 22:43:58 +00:00
|
|
|
|
2015-10-01 23:29:52 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
class PackagerCommandParsingTest(PackagerAppTest):
|
2017-03-23 18:36:47 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithIncorrectKeyIdLength1(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_key_id = self.encryption_key_id[0:-2]
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2017-03-23 18:36:47 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithIncorrectKeyIdLength2(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_key_id += '12'
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2016-06-30 22:25:52 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithInvalidKeyIdValue(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_key_id = self.encryption_key_id[0:-1] + 'g'
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2016-04-21 23:27:05 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithIncorrectKeyLength1(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_key = self.encryption_key[0:-2]
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2016-04-21 23:27:05 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithIncorrectKeyLength2(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_key += '12'
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithInvalidKeyValue(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_key = self.encryption_key[0:-1] + 'g'
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2017-03-15 19:42:00 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithIncorrectIvLength1(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_iv = self.encryption_iv[0:-2]
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithIncorrectIvLength2(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_iv += '12'
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2017-02-09 00:42:44 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithInvalidIvValue(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.encryption_iv = self.encryption_iv[0:-1] + 'g'
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']), self._GetFlags(encryption=True))
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-12-21 23:10:17 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithInvalidPsshValue1(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']),
|
|
|
|
self._GetFlags(encryption=True) + ['--pssh=ag'])
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testEncryptionWithInvalidPsshValue2(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['video']),
|
|
|
|
self._GetFlags(encryption=True) + ['--pssh=1122'])
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionInvalidContentId(self):
|
|
|
|
self.widevine_content_id += 'ag'
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test', '--aes_signing_key=1122',
|
|
|
|
'--aes_signing_iv=3344'
|
|
|
|
]
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionInvalidAesSigningKey(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test', '--aes_signing_key=11ag',
|
|
|
|
'--aes_signing_iv=3344'
|
|
|
|
]
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionInvalidAesSigningIv(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test', '--aes_signing_key=1122',
|
|
|
|
'--aes_signing_iv=33ag'
|
|
|
|
]
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionMissingAesSigningKey(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += ['--signer=widevine_test', '--aes_signing_iv=3344']
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2016-01-11 23:58:02 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionMissingAesSigningIv(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += ['--signer=widevine_test', '--aes_signing_key=1122']
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2016-01-11 23:58:02 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionMissingSigner1(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += ['--aes_signing_key=1122', '--aes_signing_iv=3344']
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2016-01-11 23:58:02 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionMissingSigner2(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += ['--rsa_signing_key_path=/tmp/test']
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2014-07-16 20:47:57 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionSignerOnly(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += ['--signer=widevine_test']
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2014-07-16 20:47:57 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testWidevineEncryptionAesSigningAndRsaSigning(self):
|
|
|
|
flags = self._GetFlags(widevine_encryption=True)
|
|
|
|
flags += [
|
|
|
|
'--signer=widevine_test',
|
|
|
|
'--aes_signing_key=1122',
|
|
|
|
'--aes_signing_iv=3344',
|
|
|
|
'--rsa_signing_key_path=/tmp/test',
|
|
|
|
]
|
|
|
|
packaging_result = self.packager.Package(
|
|
|
|
self._GetStreams(['audio', 'video']), flags)
|
|
|
|
self.assertEqual(packaging_result, 1)
|
2016-04-21 23:27:05 +00:00
|
|
|
|
2018-05-16 22:39:05 +00:00
|
|
|
def testAudioVideoWithNotExistText(self):
|
2018-02-06 19:47:41 +00:00
|
|
|
audio_video_stream = self._GetStreams(['audio', 'video'])
|
|
|
|
text_stream = self._GetStreams(['text'], test_files=['not-exist.vtt'])
|
|
|
|
packaging_result = self.packager.Package(audio_video_stream + text_stream,
|
|
|
|
self._GetFlags())
|
|
|
|
# Expect the test to fail but we do not expect a crash.
|
|
|
|
self.assertEqual(packaging_result, 1)
|
|
|
|
|
2018-05-15 21:55:11 +00:00
|
|
|
def testInconsistentOutputAndSegmentTemplateFormat(self):
|
|
|
|
test_file = os.path.join(self.test_data_dir, 'bear-640x360.mp4')
|
|
|
|
video_output_prefix = os.path.join(self.tmp_dir, 'video')
|
|
|
|
|
|
|
|
packaging_result = self.packager.Package([
|
|
|
|
'input=%s,stream=video,init_segment=%s-init.mp4,'
|
|
|
|
'segment_template=%s-$Number$.webm' %
|
|
|
|
(test_file, video_output_prefix, video_output_prefix),
|
|
|
|
], self._GetFlags())
|
|
|
|
# Expect the test to fail but we do not expect a crash.
|
|
|
|
self.assertEqual(packaging_result, 1)
|
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|