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
|
2014-07-16 20:47:57 +00:00
|
|
|
import os
|
2016-08-14 22:28:21 +00:00
|
|
|
import platform
|
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:
|
|
|
|
"""
|
|
|
|
|
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):
|
|
|
|
self.buffer = 'input=%s' % input_file
|
|
|
|
|
|
|
|
def Append(self, key, value):
|
|
|
|
self.buffer += ',%s=%s' % (key, value)
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.buffer
|
|
|
|
|
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
class PackagerAppTest(unittest.TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
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')
|
2015-09-25 22:58:18 +00:00
|
|
|
self.output_prefix = os.path.join(self.tmp_dir, 'output')
|
|
|
|
self.mpd_output = self.output_prefix + '.mpd'
|
2016-06-30 22:25:52 +00:00
|
|
|
self.hls_master_playlist_output = self.output_prefix + '.m3u8'
|
2015-11-05 01:49:35 +00:00
|
|
|
self.output = None
|
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)
|
2014-07-16 20:47:57 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def _GetStreams(self,
|
|
|
|
stream_descriptors,
|
|
|
|
language_override=None,
|
|
|
|
output_format=None,
|
|
|
|
live=False,
|
2017-10-10 21:54:36 +00:00
|
|
|
hls=False,
|
2017-06-17 01:36:16 +00:00
|
|
|
test_files=None):
|
|
|
|
if test_files is None:
|
|
|
|
test_files = ['bear-640x360.mp4']
|
|
|
|
streams = []
|
|
|
|
if not self.output:
|
|
|
|
self.output = []
|
|
|
|
|
|
|
|
for test_file_index, test_file_name in enumerate(test_files):
|
|
|
|
test_file = os.path.join(self.test_data_dir, test_file_name)
|
|
|
|
for stream_descriptor in stream_descriptors:
|
|
|
|
if len(test_files) == 1:
|
|
|
|
output_prefix = '%s_%s' % (self.output_prefix, stream_descriptor)
|
|
|
|
else:
|
|
|
|
output_prefix = '%s_%d_%s' % (self.output_prefix, test_file_index,
|
|
|
|
stream_descriptor)
|
|
|
|
# Replace ',', '=' with '_' to make it more like a filename, also
|
|
|
|
# avoid potential illegal charactors for a filename.
|
|
|
|
for ch in [',', '=']:
|
|
|
|
output_prefix = output_prefix.replace(ch, '_')
|
|
|
|
|
2018-02-07 01:34:35 +00:00
|
|
|
stream = StreamDescriptor(test_file)
|
|
|
|
stream.Append('stream', stream_descriptor)
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
if live:
|
|
|
|
if output_format == 'ts':
|
2018-02-07 01:34:35 +00:00
|
|
|
stream.Append('segment_template', output_prefix + '-$Number$.ts')
|
2017-06-17 01:36:16 +00:00
|
|
|
else:
|
2018-02-07 01:34:35 +00:00
|
|
|
stream.Append('init_segment', output_prefix + '-init.mp4')
|
|
|
|
stream.Append('segment_template', output_prefix + '-$Number$.m4s')
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
self.output.append(output_prefix)
|
|
|
|
else:
|
|
|
|
output = '%s.%s' % (
|
|
|
|
output_prefix,
|
|
|
|
self._GetExtension(stream_descriptor, output_format))
|
2018-02-07 01:34:35 +00:00
|
|
|
stream.Append('output', output)
|
2017-06-17 01:36:16 +00:00
|
|
|
self.output.append(output)
|
2018-02-07 01:34:35 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
if output_format:
|
2018-02-07 01:34:35 +00:00
|
|
|
stream.Append('format', output_format)
|
2017-06-17 01:36:16 +00:00
|
|
|
if language_override:
|
2018-02-07 01:34:35 +00:00
|
|
|
stream.Append('lang', language_override)
|
2017-10-10 21:54:36 +00:00
|
|
|
if hls:
|
2018-02-07 01:34:35 +00:00
|
|
|
stream.Append('playlist_name', stream_descriptor + '.m3u8')
|
|
|
|
|
|
|
|
streams.append(str(stream))
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
return streams
|
|
|
|
|
|
|
|
def _GetExtension(self, stream_descriptor, output_format):
|
|
|
|
# TODO(rkuroiwa): Support ttml.
|
|
|
|
if stream_descriptor == 'text':
|
|
|
|
return 'vtt'
|
|
|
|
if output_format:
|
|
|
|
return output_format
|
|
|
|
# Default to mp4.
|
|
|
|
return 'mp4'
|
|
|
|
|
|
|
|
def _GetFlags(self,
|
|
|
|
strip_parameter_set_nalus=True,
|
|
|
|
encryption=False,
|
2017-11-12 22:56:25 +00:00
|
|
|
fairplay=False,
|
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,
|
|
|
|
output_hls=False,
|
2017-06-03 00:05:47 +00:00
|
|
|
hls_playlist_type=None,
|
|
|
|
time_shift_buffer_depth=0.0,
|
2017-06-17 01:36:16 +00:00
|
|
|
generate_static_mpd=False,
|
2018-01-10 00:04:40 +00:00
|
|
|
ad_cues=None,
|
2018-04-05 01:27:57 +00:00
|
|
|
default_language=None,
|
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
|
|
|
|
|
|
|
if fairplay:
|
|
|
|
fairplay_pssh = ('000000207073736800000000'
|
|
|
|
'29701FE43CC74A348C5BAE90C7439A4700000000')
|
|
|
|
fairplay_key_uri = ('skd://www.license.com/'
|
|
|
|
'getkey?KeyId=31323334-3536-3738-3930-313233343536')
|
|
|
|
flags += [
|
|
|
|
'--pssh=' + fairplay_pssh, '--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')
|
|
|
|
if output_media_info:
|
|
|
|
flags.append('--output_media_info')
|
|
|
|
elif output_hls:
|
|
|
|
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]
|
|
|
|
if time_shift_buffer_depth != 0.0:
|
|
|
|
flags += [
|
|
|
|
'--time_shift_buffer_depth={0}'.format(time_shift_buffer_depth)
|
|
|
|
]
|
2017-06-17 01:36:16 +00:00
|
|
|
else:
|
|
|
|
flags += ['--mpd_output', self.mpd_output]
|
|
|
|
|
|
|
|
if generate_static_mpd:
|
|
|
|
flags += ['--generate_static_mpd']
|
|
|
|
|
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]
|
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
flags.append('--segment_duration=1')
|
|
|
|
# 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.
|
|
|
|
flags += ['--override_version', '--test_version', '<tag>-<hash>-<test>']
|
|
|
|
return flags
|
|
|
|
|
|
|
|
def _CompareWithGold(self, test_output, golden_file_name):
|
|
|
|
golden_file = os.path.join(self.golden_file_dir, golden_file_name)
|
|
|
|
return filecmp.cmp(test_output, golden_file)
|
|
|
|
|
|
|
|
def _DiffGold(self, test_output, golden_file_name):
|
|
|
|
golden_file = os.path.join(self.golden_file_dir, golden_file_name)
|
|
|
|
if test_env.options.test_update_golden_files:
|
|
|
|
if not os.path.exists(golden_file) or not filecmp.cmp(test_output,
|
|
|
|
golden_file):
|
|
|
|
print 'Updating golden file: ', golden_file_name
|
|
|
|
shutil.copyfile(test_output, golden_file)
|
|
|
|
else:
|
|
|
|
match = filecmp.cmp(test_output, golden_file)
|
|
|
|
if not match:
|
|
|
|
p = subprocess.Popen(['git', '--no-pager', 'diff', '--color=auto',
|
|
|
|
'--no-ext-diff', '--no-index', golden_file,
|
|
|
|
test_output],
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE)
|
|
|
|
output, error = p.communicate()
|
|
|
|
command_line = self.packager.GetCommandLine()
|
|
|
|
failure_message = (output + error + '\n' +
|
|
|
|
_TEST_FAILURE_COMMAND_LINE_MESSAGE +
|
|
|
|
command_line)
|
|
|
|
self.fail(failure_message)
|
|
|
|
|
|
|
|
# '*.media_info' outputs contain media file names, which is changing for
|
|
|
|
# every test run. These needs to be replaced for comparison.
|
|
|
|
def _DiffMediaInfoGold(self, test_output, golden_file_name):
|
|
|
|
if platform.system() == 'Windows':
|
|
|
|
test_output = test_output.replace('\\', '\\\\')
|
|
|
|
media_info_output = test_output + '.media_info'
|
|
|
|
# Replaces filename, which is changing for every test run.
|
|
|
|
with open(media_info_output, 'rb') as f:
|
|
|
|
content = f.read()
|
|
|
|
with open(media_info_output, 'wb') as f:
|
|
|
|
f.write(content.replace(test_output, 'place_holder'))
|
|
|
|
self._DiffGold(media_info_output, golden_file_name + '.media_info')
|
|
|
|
|
|
|
|
def _DiffLiveGold(self,
|
|
|
|
test_output_prefix,
|
|
|
|
golden_file_name_prefix,
|
|
|
|
output_format='mp4'):
|
|
|
|
# Compare init and the first three segments.
|
|
|
|
if output_format == 'ts':
|
|
|
|
for i in range(1, 4):
|
|
|
|
self._DiffGold('%s-%d.ts' % (test_output_prefix, i),
|
|
|
|
'%s-%d.ts' % (golden_file_name_prefix, i))
|
|
|
|
else:
|
|
|
|
self._DiffGold(test_output_prefix + '-init.mp4',
|
|
|
|
golden_file_name_prefix + '-init.mp4')
|
|
|
|
for i in range(1, 4):
|
|
|
|
self._DiffGold('%s-%d.m4s' % (test_output_prefix, i),
|
|
|
|
'%s-%d.m4s' % (golden_file_name_prefix, i))
|
|
|
|
|
|
|
|
# Live mpd contains current availabilityStartTime and publishTime, which
|
|
|
|
# needs to be replaced for comparison.
|
|
|
|
def _DiffLiveMpdGold(self, test_output, golden_file_name):
|
|
|
|
with open(test_output, 'rb') as f:
|
|
|
|
content = f.read()
|
|
|
|
|
|
|
|
# Extract availabilityStartTime.
|
|
|
|
m = re.search('availabilityStartTime="[^"]+"', content)
|
|
|
|
self.assertIsNotNone(m)
|
|
|
|
availability_start_time = m.group(0)
|
|
|
|
print availability_start_time
|
|
|
|
|
|
|
|
# Extract publishTime.
|
|
|
|
m = re.search('publishTime="[^"]+"', content)
|
|
|
|
self.assertIsNotNone(m)
|
|
|
|
publish_time = m.group(0)
|
|
|
|
print publish_time
|
|
|
|
with open(test_output, 'wb') as f:
|
|
|
|
f.write(content.replace(
|
|
|
|
availability_start_time,
|
|
|
|
'availabilityStartTime="some_availability_start_time"').replace(
|
|
|
|
publish_time, 'publishTime="some_publish_time"'))
|
|
|
|
|
|
|
|
self._DiffGold(test_output, golden_file_name)
|
|
|
|
|
|
|
|
|
|
|
|
class PackagerFunctionalTest(PackagerAppTest):
|
|
|
|
|
|
|
|
def assertPackageSuccess(self, streams, flags=None):
|
|
|
|
self.assertEqual(self.packager.Package(streams, 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
|
|
|
|
|
|
|
def testPackageFirstStream(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(self._GetStreams(['0']), self._GetFlags())
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-v-golden.mpd')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2015-11-05 01:49:35 +00:00
|
|
|
def testPackageText(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-04-21 23:27:05 +00:00
|
|
|
self._GetStreams(['text'], test_files=['subtitle-english.vtt']),
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetFlags())
|
2015-11-05 01:49:35 +00:00
|
|
|
self._DiffGold(self.output[0], 'subtitle-english-golden.vtt')
|
|
|
|
self._DiffGold(self.mpd_output, 'subtitle-english-vtt-golden.mpd')
|
|
|
|
|
|
|
|
# Probably one of the most common scenarios is to package audio and video.
|
|
|
|
def testPackageAudioVideo(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']), self._GetFlags())
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-golden.mpd')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-03-21 23:14:46 +00:00
|
|
|
def testPackageAudioVideoWithTrickPlay(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-05-15 16:22:06 +00:00
|
|
|
self._GetStreams(['audio', 'video', 'video,trick_play_factor=1']),
|
2017-03-21 23:14:46 +00:00
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'bear-640x360-v-trick-1-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-trick-1-golden.mpd')
|
|
|
|
|
|
|
|
def testPackageAudioVideoWithTwoTrickPlay(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-05-15 16:22:06 +00:00
|
|
|
self._GetStreams(['audio', 'video', 'video,trick_play_factor=1',
|
|
|
|
'video,trick_play_factor=2']),
|
2017-03-21 23:14:46 +00:00
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'bear-640x360-v-trick-1-golden.mp4')
|
|
|
|
self._DiffGold(self.output[3], 'bear-640x360-v-trick-2-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output,
|
|
|
|
'bear-640x360-av-trick-1-trick-2-golden.mpd')
|
|
|
|
|
|
|
|
def testPackageAudioVideoWithTwoTrickPlayDecreasingRate(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-05-15 16:22:06 +00:00
|
|
|
self._GetStreams(['audio', 'video', 'video,trick_play_factor=2',
|
|
|
|
'video,trick_play_factor=1']),
|
2017-03-21 23:14:46 +00:00
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'bear-640x360-v-trick-2-golden.mp4')
|
|
|
|
self._DiffGold(self.output[3], 'bear-640x360-v-trick-1-golden.mp4')
|
|
|
|
# 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.
|
2017-03-21 23:14:46 +00:00
|
|
|
self._DiffGold(self.mpd_output,
|
|
|
|
'bear-640x360-av-trick-1-trick-2-golden.mpd')
|
|
|
|
|
2017-02-21 18:36:50 +00:00
|
|
|
def testPackageAudioVideoWithLanguageOverride(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-04-05 01:27:57 +00:00
|
|
|
self._GetStreams(['audio', 'video'], language_override='por'),
|
|
|
|
self._GetFlags(default_language='por'))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-por-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-por-golden.mpd')
|
|
|
|
|
|
|
|
def testPackageAudioVideoWithLanguageOverrideUsingMixingCode(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], language_override='por'),
|
|
|
|
self._GetFlags(default_language='pt'))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-por-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-por-golden.mpd')
|
|
|
|
|
|
|
|
def testPackageAudioVideoWithLanguageOverrideUsingMixingCode2(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], language_override='pt'),
|
|
|
|
self._GetFlags(default_language='por'))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-por-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-por-golden.mpd')
|
|
|
|
|
|
|
|
def testPackageAudioVideoWithLanguageOverrideUsingTwoCharacterCode(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], language_override='pt'),
|
|
|
|
self._GetFlags(default_language='pt'))
|
2017-02-21 18:36:50 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-por-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-por-golden.mpd')
|
|
|
|
|
|
|
|
def testPackageAudioVideoWithLanguageOverrideWithSubtag(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-02-21 18:36:50 +00:00
|
|
|
self._GetStreams(['audio', 'video'], language_override='por-BR'),
|
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-por-BR-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-por-BR-golden.mpd')
|
2017-04-10 20:20:45 +00:00
|
|
|
|
|
|
|
def testPackageAacHe(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']),
|
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0],
|
|
|
|
'bear-640x360-aac_he-silent_right-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output,
|
|
|
|
'bear-640x360-aac_he-silent_right-golden.mpd')
|
2017-02-21 18:36:50 +00:00
|
|
|
|
2015-11-05 01:49:35 +00:00
|
|
|
# Package all video, audio, and text.
|
|
|
|
def testPackageVideoAudioText(self):
|
|
|
|
audio_video_streams = self._GetStreams(['audio', 'video'])
|
2015-10-01 23:29:52 +00:00
|
|
|
text_stream = self._GetStreams(['text'],
|
|
|
|
test_files=['subtitle-english.vtt'])
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(audio_video_streams + text_stream,
|
|
|
|
self._GetFlags())
|
2015-11-05 01:49:35 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'subtitle-english-golden.vtt')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-avt-golden.mpd')
|
|
|
|
|
2017-10-23 23:00:16 +00:00
|
|
|
def testPackageAvcAacTs(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(
|
2017-10-10 21:54:36 +00:00
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2017-01-07 02:40:37 +00:00
|
|
|
self._GetFlags(output_hls=True))
|
2016-04-28 22:02:55 +00:00
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-a-golden',
|
2016-06-30 22:25:52 +00:00
|
|
|
output_format='ts')
|
2016-04-28 22:02:55 +00:00
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-golden',
|
2016-06-30 22:25:52 +00:00
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'), 'bear-640x360-a-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'), 'bear-640x360-v-golden.m3u8')
|
2016-04-28 22:02:55 +00:00
|
|
|
|
2018-04-05 01:27:57 +00:00
|
|
|
def testPackageAvcAacTsLanguage(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
|
|
|
hls=True,
|
|
|
|
language_override='por',
|
|
|
|
test_files=['bear-640x360.ts']),
|
|
|
|
self._GetFlags(output_hls=True, default_language='por'))
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-por-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'), 'bear-640x360-a-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'), 'bear-640x360-v-golden.m3u8')
|
|
|
|
|
|
|
|
def testPackageAvcAacTsLanguageUsingTwoCharacterCode(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
|
|
|
hls=True,
|
|
|
|
language_override='pt',
|
|
|
|
test_files=['bear-640x360.ts']),
|
|
|
|
self._GetFlags(output_hls=True, default_language='pt'))
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-por-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'), 'bear-640x360-a-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'), 'bear-640x360-v-golden.m3u8')
|
|
|
|
|
2017-10-23 23:00:16 +00:00
|
|
|
def testPackageAvcAc3Ts(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360-ac3.ts']),
|
|
|
|
self._GetFlags(output_hls=True))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-ac3-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-ac3-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-ac3-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'), 'bear-640x360-v-golden.m3u8')
|
|
|
|
|
|
|
|
def testPackageAvcAc3TsToMp4(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'], hls=True, test_files=['bear-640x360-ac3.ts']),
|
|
|
|
self._GetFlags(output_hls=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-ac3-from-ts-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-from-ts-golden.mp4')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-ac3-ts-to-mp4-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-ac3-ts-to-mp4-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-ts-to-mp4-golden.m3u8')
|
|
|
|
|
2017-06-03 00:05:47 +00:00
|
|
|
def testPackageAvcTsLivePlaylist(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
2017-10-10 21:54:36 +00:00
|
|
|
hls=True,
|
2017-06-03 00:05:47 +00:00
|
|
|
test_files=['bear-640x360.ts']),
|
|
|
|
self._GetFlags(
|
|
|
|
output_hls=True,
|
|
|
|
hls_playlist_type='LIVE',
|
|
|
|
time_shift_buffer_depth=0.5))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-a-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-live-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-live-golden.m3u8')
|
|
|
|
|
2017-06-20 23:30:03 +00:00
|
|
|
def testPackageAvcTsLivePlaylistWithKeyRotation(self):
|
|
|
|
self.packager.Package(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
2017-10-10 21:54:36 +00:00
|
|
|
hls=True,
|
2017-06-20 23:30:03 +00:00
|
|
|
test_files=['bear-640x360.ts']),
|
|
|
|
self._GetFlags(
|
|
|
|
encryption=True,
|
|
|
|
key_rotation=True,
|
|
|
|
output_hls=True,
|
|
|
|
hls_playlist_type='LIVE',
|
|
|
|
time_shift_buffer_depth=0.5))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-a-enc-rotation-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-enc-rotation-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-live-enc-rotation-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-live-enc-rotation-golden.m3u8')
|
|
|
|
|
2017-06-03 00:05:47 +00:00
|
|
|
def testPackageAvcTsEventPlaylist(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
2017-10-10 21:54:36 +00:00
|
|
|
hls=True,
|
2017-06-03 00:05:47 +00:00
|
|
|
test_files=['bear-640x360.ts']),
|
|
|
|
self._GetFlags(
|
|
|
|
output_hls=True,
|
|
|
|
hls_playlist_type='EVENT',
|
|
|
|
time_shift_buffer_depth=0.5))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-a-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-event-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-event-golden.m3u8')
|
|
|
|
|
2016-01-09 00:18:52 +00:00
|
|
|
def testPackageVp8Webm(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-01-09 00:18:52 +00:00
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='webm',
|
|
|
|
test_files=['bear-640x360.webm']),
|
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-vp8-golden.webm')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-vp8-webm-golden.mpd')
|
|
|
|
|
|
|
|
def testPackageVp9Webm(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
output_format='webm',
|
|
|
|
test_files=['bear-320x240-vp9-opus.webm']),
|
2016-01-09 00:18:52 +00:00
|
|
|
self._GetFlags())
|
2016-05-05 22:26:48 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-320x240-opus-golden.webm')
|
|
|
|
self._DiffGold(self.output[1], 'bear-320x240-vp9-golden.webm')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-320x240-vp9-opus-webm-golden.mpd')
|
2016-01-09 00:18:52 +00:00
|
|
|
|
2016-07-29 23:06:20 +00:00
|
|
|
def testPackageVp9WebmWithBlockgroup(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-07-29 23:06:20 +00:00
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='webm',
|
|
|
|
test_files=['bear-vp9-blockgroup.webm']),
|
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0], 'bear-vp9-blockgroup-golden.webm')
|
|
|
|
|
2016-01-13 19:58:48 +00:00
|
|
|
def testPackageVorbisWebm(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-01-13 19:58:48 +00:00
|
|
|
self._GetStreams(['audio'],
|
|
|
|
output_format='webm',
|
|
|
|
test_files=['bear-320x240-audio-only.webm']),
|
|
|
|
self._GetFlags())
|
|
|
|
self._DiffGold(self.output[0], 'bear-320x240-vorbis-golden.webm')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-320x240-vorbis-webm-golden.mpd')
|
|
|
|
|
2015-09-25 22:58:18 +00:00
|
|
|
def testPackageWithEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
|
|
|
self._GetFlags(encryption=True))
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2016-04-21 23:27:05 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
2017-09-20 22:49:00 +00:00
|
|
|
|
2017-10-17 23:03:08 +00:00
|
|
|
# Test deprecated flag --enable_fixed_key_encryption, which is still
|
|
|
|
# supported currently.
|
|
|
|
def testPackageWithEncryptionUsingFixedKey(self):
|
|
|
|
flags = self._GetFlags() + [
|
|
|
|
'--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)
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2017-10-17 23:03:08 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
2017-09-20 22:49:00 +00:00
|
|
|
def testPackageWithEncryptionMultiKeys(self):
|
|
|
|
audio_key_id = '10111213141516171819202122232425'
|
|
|
|
audio_key = '11121314151617181920212223242526'
|
|
|
|
video_key_id = '20212223242526272829303132333435'
|
|
|
|
video_key = '21222324252627282930313233343536'
|
|
|
|
flags = self._GetFlags() + [
|
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)
|
|
|
|
|
|
|
|
self.encryption_key_id = audio_key_id
|
|
|
|
self.encryption_key = audio_key
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2017-09-20 22:49:00 +00:00
|
|
|
self.encryption_key_id = video_key_id
|
|
|
|
self.encryption_key = video_key
|
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
|
|
|
def testPackageWithEncryptionMultiKeysWithStreamLabel(self):
|
|
|
|
audio_key_id = '20212223242526272829303132333435'
|
|
|
|
audio_key = '21222324252627282930313233343536'
|
|
|
|
video_key_id = '10111213141516171819202122232425'
|
|
|
|
video_key = '11121314151617181920212223242526'
|
|
|
|
flags = self._GetFlags() + [
|
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.
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio,drm_label=MyAudio',
|
|
|
|
'video,drm_label=MyVideo']), flags)
|
|
|
|
|
|
|
|
self.encryption_key_id = audio_key_id
|
|
|
|
self.encryption_key = audio_key
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2017-09-20 22:49:00 +00:00
|
|
|
self.encryption_key_id = video_key_id
|
|
|
|
self.encryption_key = video_key
|
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionOfOnlyVideoStream(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio,skip_encryption=1', 'video']),
|
|
|
|
self._GetFlags(encryption=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-a-clear-v-cenc-golden.mpd')
|
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
2017-06-14 23:18:16 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionAndTrickPlay(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video', 'video,trick_play_factor=1']),
|
|
|
|
self._GetFlags(encryption=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'bear-640x360-v-trick-1-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-trick-1-cenc-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2017-06-17 01:36:16 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._VerifyDecryption(self.output[2], 'bear-640x360-v-trick-1-golden.mp4')
|
2017-03-21 23:14:46 +00:00
|
|
|
|
|
|
|
# TODO(hmchen): Add a test case that SD and HD AdapatationSet share one trick
|
|
|
|
# play stream.
|
|
|
|
def testPackageWithEncryptionAndTwoTrickPlays(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-05-15 16:22:06 +00:00
|
|
|
self._GetStreams(['audio', 'video', 'video,trick_play_factor=1',
|
|
|
|
'video,trick_play_factor=2']),
|
2017-03-21 23:14:46 +00:00
|
|
|
self._GetFlags(encryption=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'bear-640x360-v-trick-1-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[3], 'bear-640x360-v-trick-2-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output,
|
|
|
|
'bear-640x360-av-trick-1-trick-2-cenc-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2017-03-21 23:14:46 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
self._VerifyDecryption(self.output[2], 'bear-640x360-v-trick-1-golden.mp4')
|
|
|
|
self._VerifyDecryption(self.output[3], 'bear-640x360-v-trick-2-golden.mp4')
|
|
|
|
|
2017-05-09 22:49:01 +00:00
|
|
|
def testPackageWithEncryptionAndNoClearLead(self):
|
2018-01-10 00:04:40 +00:00
|
|
|
self.clear_lead = 0
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2018-01-10 00:04:40 +00:00
|
|
|
self._GetStreams(['audio', 'video']), self._GetFlags(encryption=True))
|
2017-05-09 22:49:01 +00:00
|
|
|
self._DiffGold(self.output[0],
|
|
|
|
'bear-640x360-a-cenc-no-clear-lead-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1],
|
|
|
|
'bear-640x360-v-cenc-no-clear-lead-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output,
|
|
|
|
'bear-640x360-av-cenc-no-clear-lead-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2017-05-09 22:49:01 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
2017-03-15 19:42:00 +00:00
|
|
|
def testPackageWithEncryptionAndNoPsshInStream(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-03-15 19:42:00 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
|
|
|
self._GetFlags(encryption=True, include_pssh_in_stream=False))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-no-pssh-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-no-pssh-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-no-pssh-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2017-03-15 19:42:00 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
2016-04-21 23:28:21 +00:00
|
|
|
def testPackageWithEncryptionCbc1(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-04-21 23:28:21 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
|
|
|
self._GetFlags(encryption=True,
|
|
|
|
protection_scheme='cbc1'))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cbc1-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cbc1-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cbc1-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2016-04-21 23:28:21 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
|
|
|
def testPackageWithEncryptionCens(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-04-21 23:28:21 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
|
|
|
self._GetFlags(encryption=True,
|
|
|
|
protection_scheme='cens'))
|
2016-05-26 22:44:37 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cens-golden.mp4')
|
2016-04-21 23:28:21 +00:00
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cens-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cens-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2016-04-21 23:28:21 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
|
|
|
def testPackageWithEncryptionCbcs(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-04-21 23:28:21 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
|
|
|
self._GetFlags(encryption=True,
|
|
|
|
protection_scheme='cbcs'))
|
2016-05-26 22:44:37 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cbcs-golden.mp4')
|
2016-04-21 23:28:21 +00:00
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cbcs-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cbcs-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
|
|
|
def testPackageWithEncryptionAndAdCues(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video']),
|
|
|
|
self._GetFlags(encryption=True, ad_cues='1.5'))
|
2018-03-20 17:12:18 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-ad_cues-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-ad_cues-golden.mp4')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-ad_cues-golden.mpd')
|
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2016-04-21 23:28:21 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
|
|
|
|
2016-07-27 00:51:08 +00:00
|
|
|
def testPackageWithWebmSubsampleEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-07-27 00:51:08 +00:00
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='webm',
|
2017-04-25 19:02:08 +00:00
|
|
|
test_files=['bear-320x180-vp9-altref.webm']),
|
2016-07-27 00:51:08 +00:00
|
|
|
self._GetFlags(encryption=True))
|
2017-04-25 19:02:08 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-320x180-vp9-altref-enc-golden.webm')
|
2016-07-27 00:51:08 +00:00
|
|
|
self._VerifyDecryption(self.output[0],
|
2017-04-25 19:02:08 +00:00
|
|
|
'bear-320x180-vp9-altref-dec-golden.webm')
|
2016-07-27 00:51:08 +00:00
|
|
|
|
2017-03-28 15:19:15 +00:00
|
|
|
def testPackageWithWebmVp9FullSampleEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-03-28 15:19:15 +00:00
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='webm',
|
2017-04-25 19:02:08 +00:00
|
|
|
test_files=['bear-320x180-vp9-altref.webm']),
|
2017-03-28 15:19:15 +00:00
|
|
|
self._GetFlags(encryption=True, vp9_subsample_encryption=False))
|
|
|
|
self._DiffGold(self.output[0],
|
2017-04-25 19:02:08 +00:00
|
|
|
'bear-320x180-vp9-fullsample-enc-golden.webm')
|
2017-03-28 15:19:15 +00:00
|
|
|
self._VerifyDecryption(self.output[0],
|
2017-04-25 19:02:08 +00:00
|
|
|
'bear-320x180-vp9-altref-dec-golden.webm')
|
2017-03-28 15:19:15 +00:00
|
|
|
|
2016-06-30 22:25:52 +00:00
|
|
|
def testPackageAvcTsWithEncryption(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-10-10 21:54:36 +00:00
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
2017-01-07 02:40:37 +00:00
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
2016-06-30 22:25:52 +00:00
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-a-enc-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-enc-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
2017-06-20 23:30:03 +00:00
|
|
|
'bear-640x360-av-master-golden.m3u8')
|
2016-06-30 22:25:52 +00:00
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-enc-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-enc-golden.m3u8')
|
|
|
|
|
2017-11-12 22:56:25 +00:00
|
|
|
def testPackageAvcTsWithEncryptionAndFairplay(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360.ts']),
|
|
|
|
self._GetFlags(encryption=True, output_hls=True, fairplay=True))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-a-enc-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-enc-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-fairplay-enc-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-fairplay-enc-golden.m3u8')
|
|
|
|
|
2017-10-23 23:00:16 +00:00
|
|
|
def testPackageAvcAc3TsWithEncryption(self):
|
|
|
|
# Currently we only support live packaging for ts.
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'],
|
|
|
|
output_format='ts',
|
|
|
|
live=True,
|
|
|
|
hls=True,
|
|
|
|
test_files=['bear-640x360-ac3.ts']),
|
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-ac3-enc-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-enc-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-ac3-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-ac3-enc-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-enc-golden.m3u8')
|
|
|
|
|
2017-03-23 18:05:22 +00:00
|
|
|
def testPackageAvcTsWithEncryptionExerciseEmulationPrevention(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',
|
|
|
|
live=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))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'sintel-1024x436-v-enc-golden',
|
|
|
|
output_format='ts')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'sintel-1024x436-v-enc-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'sintel-1024x436-v-enc-golden.m3u8')
|
|
|
|
|
2016-01-21 00:14:24 +00:00
|
|
|
def testPackageWebmWithEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-01-21 00:14:24 +00:00
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='webm',
|
|
|
|
test_files=['bear-640x360.webm']),
|
|
|
|
self._GetFlags(encryption=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-vp8-cenc-golden.webm')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-vp8-cenc-webm-golden.mpd')
|
2016-04-21 23:27:05 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-vp8-golden.webm')
|
2016-01-21 00:14:24 +00:00
|
|
|
|
2015-10-29 00:26:29 +00:00
|
|
|
def testPackageHevcWithEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['video'],
|
|
|
|
test_files=['bear-640x360-hevc.mp4']),
|
|
|
|
self._GetFlags(encryption=True))
|
2016-04-21 23:27:05 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-hevc-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-hevc-cenc-golden.mpd')
|
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-hevc-golden.mp4')
|
2015-10-29 00:26:29 +00:00
|
|
|
|
2016-01-09 00:18:52 +00:00
|
|
|
def testPackageVp8Mp4WithEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-01-09 00:18:52 +00:00
|
|
|
self._GetStreams(['video'],
|
|
|
|
output_format='mp4',
|
|
|
|
test_files=['bear-640x360.webm']),
|
|
|
|
self._GetFlags(encryption=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-vp8-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-vp8-cenc-golden.mpd')
|
2016-04-21 23:27:05 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-vp8-golden.mp4')
|
2016-01-09 00:18:52 +00:00
|
|
|
|
2016-06-01 23:28:56 +00:00
|
|
|
def testPackageOpusVp9Mp4WithEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
2016-01-09 00:18:52 +00:00
|
|
|
output_format='mp4',
|
2016-05-05 22:26:48 +00:00
|
|
|
test_files=['bear-320x240-vp9-opus.webm']),
|
2016-01-09 00:18:52 +00:00
|
|
|
self._GetFlags(encryption=True))
|
2016-06-01 23:28:56 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-320x240-opus-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-320x240-vp9-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-320x240-opus-vp9-cenc-golden.mpd')
|
|
|
|
self._VerifyDecryption(self.output[0], 'bear-320x240-opus-golden.mp4')
|
|
|
|
self._VerifyDecryption(self.output[1], 'bear-320x240-vp9-golden.mp4')
|
2016-01-09 00:18:52 +00:00
|
|
|
|
2017-03-23 18:36:47 +00:00
|
|
|
def testPackageWvmInput(self):
|
2017-06-14 23:18:16 +00:00
|
|
|
self.encryption_key = '9248d245390e0a49d483ba9b43fc69c3'
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-03-23 18:36:47 +00:00
|
|
|
self._GetStreams(
|
|
|
|
['0', '1', '2', '3'], test_files=['bear-multi-configs.wvm']),
|
2017-06-14 23:18:16 +00:00
|
|
|
self._GetFlags(decryption=True))
|
2017-03-23 18:36:47 +00:00
|
|
|
# Output timescale is 90000.
|
|
|
|
self._DiffGold(self.output[0], 'bear-320x180-v-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-320x180-a-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'bear-640x360-v-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.output[3], 'bear-640x360-a-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-wvm-golden.mpd')
|
|
|
|
|
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.'
|
|
|
|
)
|
2017-03-23 18:36:47 +00:00
|
|
|
def testPackageWvmInputWithoutStrippingParameterSetNalus(self):
|
2017-06-14 23:18:16 +00:00
|
|
|
self.encryption_key = '9248d245390e0a49d483ba9b43fc69c3'
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-03-23 18:36:47 +00:00
|
|
|
self._GetStreams(
|
|
|
|
['0', '1', '2', '3'], test_files=['bear-multi-configs.wvm']),
|
2017-06-14 23:18:16 +00:00
|
|
|
self._GetFlags(strip_parameter_set_nalus=False, decryption=True))
|
2017-03-23 18:36:47 +00:00
|
|
|
# Output timescale is 90000.
|
|
|
|
self._DiffGold(self.output[0], 'bear-320x180-avc3-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-320x180-a-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.output[2], 'bear-640x360-avc3-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.output[3], 'bear-640x360-a-wvm-golden.mp4')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-avc3-wvm-golden.mpd')
|
|
|
|
|
2015-09-25 22:58:18 +00:00
|
|
|
def testPackageWithEncryptionAndRandomIv(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, random_iv=True))
|
2015-09-25 22:58:18 +00:00
|
|
|
self._AssertStreamInfo(self.output[0], 'is_encrypted: true')
|
|
|
|
self._AssertStreamInfo(self.output[1], 'is_encrypted: true')
|
|
|
|
# The outputs are encrypted with random iv, so they are not the same as
|
|
|
|
# golden files.
|
2015-10-01 23:29:52 +00:00
|
|
|
self.assertFalse(self._CompareWithGold(self.output[0],
|
|
|
|
'bear-640x360-a-cenc-golden.mp4'))
|
|
|
|
self.assertFalse(self._CompareWithGold(self.output[1],
|
|
|
|
'bear-640x360-v-cenc-golden.mp4'))
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2016-04-21 23:27:05 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
|
|
|
def testPackageWithEncryptionAndRealClock(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, use_fake_clock=False))
|
2015-09-25 22:58:18 +00:00
|
|
|
self._AssertStreamInfo(self.output[0], 'is_encrypted: true')
|
|
|
|
self._AssertStreamInfo(self.output[1], 'is_encrypted: true')
|
|
|
|
# The outputs are generated with real clock, so they are not the same as
|
|
|
|
# golden files.
|
2015-10-01 23:29:52 +00:00
|
|
|
self.assertFalse(self._CompareWithGold(self.output[0],
|
|
|
|
'bear-640x360-a-cenc-golden.mp4'))
|
|
|
|
self.assertFalse(self._CompareWithGold(self.output[1],
|
|
|
|
'bear-640x360-v-cenc-golden.mp4'))
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-golden.mpd')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._VerifyDecryption(self.output[0], 'bear-640x360-a-demuxed-golden.mp4')
|
2016-04-21 23:27:05 +00:00
|
|
|
self._VerifyDecryption(self.output[1], 'bear-640x360-v-golden.mp4')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-02-09 00:47:59 +00:00
|
|
|
def testPackageWithEncryptionAndNonDashIfIop(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetStreams(['audio', 'video']),
|
2017-02-09 00:47:59 +00:00
|
|
|
self._GetFlags(encryption=True, dash_if_iop=False))
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
2017-02-09 00:47:59 +00:00
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-cenc-non-iop-golden.mpd')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
|
|
|
def testPackageWithEncryptionAndOutputMediaInfo(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))
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
|
|
|
self._DiffMediaInfoGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffMediaInfoGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-10-10 21:54:36 +00:00
|
|
|
def testPackageWithHlsSingleSegmentMp4Encrypted(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], hls=True),
|
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-mp4-master-cenc-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-mp4-cenc-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-mp4-cenc-golden.m3u8')
|
|
|
|
|
2018-01-21 20:21:01 +00:00
|
|
|
def testPackageWithEc3AndHlsSingleSegmentMp4Encrypted(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(
|
|
|
|
['audio', 'video'], hls=True, test_files=['bear-640x360-ec3.mp4']),
|
|
|
|
self._GetFlags(encryption=True, output_hls=True))
|
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-ec3-a-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-ec3-v-cenc-golden.mp4')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-ec3-av-mp4-master-cenc-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-ec3-a-mp4-cenc-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-ec3-v-mp4-cenc-golden.m3u8')
|
|
|
|
|
2018-01-10 00:04:40 +00:00
|
|
|
def testPackageWithHlsSingleSegmentMp4EncryptedAndAdCues(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], hls=True),
|
|
|
|
self._GetFlags(encryption=True, output_hls=True, ad_cues='1.5'))
|
2018-03-20 17:12:18 +00:00
|
|
|
self._DiffGold(self.output[0], 'bear-640x360-a-cenc-ad_cues-golden.mp4')
|
|
|
|
self._DiffGold(self.output[1], 'bear-640x360-v-cenc-ad_cues-golden.mp4')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
2018-03-20 17:12:18 +00:00
|
|
|
'bear-640x360-av-mp4-master-cenc-ad_cues-golden.m3u8')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-mp4-cenc-ad_cues-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video.m3u8'),
|
|
|
|
'bear-640x360-v-mp4-cenc-ad_cues-golden.m3u8')
|
|
|
|
|
2017-10-10 21:54:36 +00:00
|
|
|
# Test HLS with multi-segment mp4 and content in subdirectories.
|
|
|
|
def testPackageWithHlsMultiSegmentMp4WithCustomPath(self):
|
|
|
|
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')
|
|
|
|
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))
|
|
|
|
self._DiffLiveGold(audio_output_prefix, 'bear-640x360-a-live-golden')
|
|
|
|
self._DiffLiveGold(video_output_prefix, 'bear-640x360-v-live-golden')
|
|
|
|
self._DiffGold(self.hls_master_playlist_output,
|
|
|
|
'bear-640x360-av-mp4-master-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'audio', 'audio.m3u8'),
|
|
|
|
'bear-640x360-a-mp4-golden.m3u8')
|
|
|
|
self._DiffGold(
|
|
|
|
os.path.join(self.tmp_dir, 'video', 'video.m3u8'),
|
|
|
|
'bear-640x360-v-mp4-golden.m3u8')
|
|
|
|
|
2015-09-25 22:58:18 +00:00
|
|
|
def testPackageWithLiveProfile(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-01-07 02:40:37 +00:00
|
|
|
self._GetStreams(['audio', 'video'], live=True), self._GetFlags())
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffLiveGold(self.output[0], 'bear-640x360-a-live-golden')
|
|
|
|
self._DiffLiveGold(self.output[1], 'bear-640x360-v-live-golden')
|
|
|
|
self._DiffLiveMpdGold(self.mpd_output, 'bear-640x360-av-live-golden.mpd')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-02-09 00:42:44 +00:00
|
|
|
def testPackageWithLiveStaticProfile(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-02-09 00:42:44 +00:00
|
|
|
self._GetStreams(['audio', 'video'], live=True),
|
|
|
|
self._GetFlags(generate_static_mpd=True))
|
|
|
|
self._DiffLiveGold(self.output[0], 'bear-640x360-a-live-golden')
|
|
|
|
self._DiffLiveGold(self.output[1], 'bear-640x360-v-live-golden')
|
|
|
|
self._DiffGold(self.mpd_output, 'bear-640x360-av-live-static-golden.mpd')
|
|
|
|
|
2018-01-10 00:04:40 +00:00
|
|
|
def testPackageWithLiveStaticProfileAndAdCues(self):
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['audio', 'video'], live=True),
|
|
|
|
self._GetFlags(generate_static_mpd=True, ad_cues='1.5'))
|
2018-03-20 17:12:18 +00:00
|
|
|
self._DiffLiveGold(self.output[0], 'bear-640x360-a-live-ad_cues-golden')
|
|
|
|
self._DiffLiveGold(self.output[1], 'bear-640x360-v-live-ad_cues-golden')
|
2018-01-10 00:04:40 +00:00
|
|
|
self._DiffGold(self.mpd_output,
|
|
|
|
'bear-640x360-av-live-static-ad_cues-golden.mpd')
|
|
|
|
|
2015-09-25 22:58:18 +00:00
|
|
|
def testPackageWithLiveProfileAndEncryption(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], live=True),
|
2017-01-07 02:40:37 +00:00
|
|
|
self._GetFlags(encryption=True))
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffLiveGold(self.output[0], 'bear-640x360-a-live-cenc-golden')
|
|
|
|
self._DiffLiveGold(self.output[1], 'bear-640x360-v-live-cenc-golden')
|
2015-09-25 22:58:18 +00:00
|
|
|
self._DiffLiveMpdGold(self.mpd_output,
|
2015-09-29 17:13:09 +00:00
|
|
|
'bear-640x360-av-live-cenc-golden.mpd')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-02-09 00:47:59 +00:00
|
|
|
def testPackageWithLiveProfileAndEncryptionAndNonDashIfIop(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], live=True),
|
2017-02-09 00:47:59 +00:00
|
|
|
self._GetFlags(encryption=True, dash_if_iop=False))
|
2015-09-29 17:13:09 +00:00
|
|
|
self._DiffLiveGold(self.output[0], 'bear-640x360-a-live-cenc-golden')
|
|
|
|
self._DiffLiveGold(self.output[1], 'bear-640x360-v-live-cenc-golden')
|
2015-09-25 22:58:18 +00:00
|
|
|
self._DiffLiveMpdGold(self.mpd_output,
|
2017-02-09 00:47:59 +00:00
|
|
|
'bear-640x360-av-live-cenc-non-iop-golden.mpd')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-02-09 00:47:59 +00:00
|
|
|
def testPackageWithLiveProfileAndEncryptionAndMultFiles(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'],
|
|
|
|
live=True,
|
|
|
|
test_files=['bear-1280x720.mp4', 'bear-640x360.mp4',
|
|
|
|
'bear-320x180.mp4']),
|
2017-02-09 00:47:59 +00:00
|
|
|
self._GetFlags(encryption=True))
|
2015-10-01 23:29:52 +00:00
|
|
|
self._DiffLiveGold(self.output[2], 'bear-640x360-a-live-cenc-golden')
|
|
|
|
self._DiffLiveGold(self.output[3], 'bear-640x360-v-live-cenc-golden')
|
|
|
|
# Mpd cannot be validated right now since we don't generate determinstic
|
|
|
|
# mpd with multiple inputs due to thread racing.
|
|
|
|
# TODO(kqyang): Generate determinstic mpd or at least validate mpd schema.
|
|
|
|
|
2015-09-25 22:58:18 +00:00
|
|
|
def testPackageWithLiveProfileAndKeyRotation(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], live=True),
|
2017-01-07 02:40:37 +00:00
|
|
|
self._GetFlags(encryption=True, key_rotation=True))
|
2015-09-25 22:58:18 +00:00
|
|
|
self._DiffLiveGold(self.output[0],
|
2015-09-29 17:13:09 +00:00
|
|
|
'bear-640x360-a-live-cenc-rotation-golden')
|
2015-09-25 22:58:18 +00:00
|
|
|
self._DiffLiveGold(self.output[1],
|
2015-09-29 17:13:09 +00:00
|
|
|
'bear-640x360-v-live-cenc-rotation-golden')
|
2015-09-25 22:58:18 +00:00
|
|
|
self._DiffLiveMpdGold(self.mpd_output,
|
2015-09-29 17:13:09 +00:00
|
|
|
'bear-640x360-av-live-cenc-rotation-golden.mpd')
|
2015-09-25 22:58:18 +00:00
|
|
|
|
2017-03-15 19:42:00 +00:00
|
|
|
def testPackageWithLiveProfileAndKeyRotationAndNoPsshInStream(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2017-03-15 19:42:00 +00:00
|
|
|
self._GetStreams(['audio', 'video'], live=True),
|
|
|
|
self._GetFlags(
|
|
|
|
encryption=True, key_rotation=True, include_pssh_in_stream=False))
|
|
|
|
self._DiffLiveGold(self.output[0],
|
|
|
|
'bear-640x360-a-live-cenc-rotation-no-pssh-golden')
|
|
|
|
self._DiffLiveGold(self.output[1],
|
|
|
|
'bear-640x360-v-live-cenc-rotation-no-pssh-golden')
|
|
|
|
self._DiffLiveMpdGold(
|
|
|
|
self.mpd_output,
|
|
|
|
'bear-640x360-av-live-cenc-rotation-no-pssh-golden.mpd')
|
|
|
|
|
2017-02-09 00:47:59 +00:00
|
|
|
def testPackageWithLiveProfileAndKeyRotationAndNonDashIfIop(self):
|
2017-06-17 01:36:16 +00:00
|
|
|
self.assertPackageSuccess(
|
2016-06-01 23:28:56 +00:00
|
|
|
self._GetStreams(['audio', 'video'], live=True),
|
2015-10-01 23:29:52 +00:00
|
|
|
self._GetFlags(encryption=True,
|
|
|
|
key_rotation=True,
|
2017-02-09 00:47:59 +00:00
|
|
|
dash_if_iop=False))
|
2015-09-25 22:58:18 +00:00
|
|
|
self._DiffLiveGold(self.output[0],
|
2015-09-29 17:13:09 +00:00
|
|
|
'bear-640x360-a-live-cenc-rotation-golden')
|
2015-09-25 22:58:18 +00:00
|
|
|
self._DiffLiveGold(self.output[1],
|
2015-09-29 17:13:09 +00:00
|
|
|
'bear-640x360-v-live-cenc-rotation-golden')
|
2017-02-09 00:47:59 +00:00
|
|
|
self._DiffLiveMpdGold(
|
|
|
|
self.mpd_output,
|
|
|
|
'bear-640x360-av-live-cenc-rotation-non-iop-golden.mpd')
|
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):
|
2015-09-25 22:58:18 +00:00
|
|
|
flags = self._GetFlags(widevine_encryption=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):
|
|
|
|
flags = self._GetFlags(widevine_encryption=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:
|
|
|
|
print f.read()
|
|
|
|
# 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):
|
2015-09-25 22:58:18 +00:00
|
|
|
flags = self._GetFlags(widevine_encryption=True, key_rotation=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):
|
2015-09-25 22:58:18 +00:00
|
|
|
flags = self._GetFlags(widevine_encryption=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')
|
|
|
|
|
2017-06-17 01:36:16 +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-03-21 23:14:46 +00:00
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def _VerifyDecryption(self, test_encrypted_file, golden_clear_file):
|
|
|
|
output_extension = os.path.splitext(golden_clear_file)[1][1:]
|
|
|
|
self.assertPackageSuccess(
|
|
|
|
self._GetStreams(['0'],
|
|
|
|
output_format=output_extension,
|
|
|
|
test_files=[test_encrypted_file]),
|
|
|
|
self._GetFlags(decryption=True))
|
|
|
|
self._DiffGold(self.output[-1], golden_clear_file)
|
2015-09-25 22:58:18 +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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithIncorrectKeyIdLength1(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithIncorrectKeyIdLength2(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithInvalidKeyIdValue(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithIncorrectKeyLength1(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithIncorrectKeyLength2(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithInvalidKeyValue(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithIncorrectIvLength1(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithIncorrectIvLength2(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithInvalidIvValue(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithInvalidPsshValue1(self):
|
|
|
|
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
|
|
|
|
2017-06-17 01:36:16 +00:00
|
|
|
def testPackageWithEncryptionWithInvalidPsshValue2(self):
|
|
|
|
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-02-06 19:47:41 +00:00
|
|
|
def testPackageAudioVideoWithNotExistText(self):
|
|
|
|
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)
|
|
|
|
|
2014-07-16 20:47:57 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|