Commit Graph

712 Commits

Author SHA1 Message Date
KongQun Yang 055c67888b Add an option to allow write |mvex| before |trak|
Under command line flag --mvex_before_trak.

This is needed to workaround Android MediaExtractor bug which
requires |mvex| to appear before |trak|.

Closes #711.

Change-Id: Id41d71af5c0016f59023dda6408bbf502e12ac55
2020-02-28 02:10:08 +00:00
KongQun Yang 4028bf727b Allow specifying protection pattern for pattern encryption
Added --crypt_byte_block, --skip_byte_block to allow users to specify
protection pattern other than 1:9 for pattern based encryption scheme,
e.g. cbcs and cens.

Closes #710.
b/147307451

Change-Id: I9f64a7639170c737f138572689b28d17286325c7
2020-02-28 00:50:58 +00:00
KongQun Yang ce932f68a2 Change AV1 cbcs to protect all bytes of decode_tile structure
AV1-ISOBMFF spec is updated recently to use start alignment instead of
end alignment for cbcs:

for the protected scheme cbcs:
- BytesOfProtectedData SHALL start on the first byte and end on the
  last byte of the decode_tile structure (including any trailing bits).
- A subsample SHALL be created for each tile, even if its size is less
  than 16 bytes.
- ...

cenc protection scheme is not affected.

Closes #698.

Change-Id: Ic83a478fb2602d830c30daf3206a1c2d2c238a08
2020-02-11 22:15:11 +00:00
KongQun Yang 624b2ca725 Fix possible compilation errors with gcc
Remove custom constructors, which is no longer needed with C++11. Use
C++ struct zero initialization instead.

Fixes #686.

Change-Id: I512da9f23a250e8b9ebf8bb8e0a39ad0f822d0d3
2020-02-11 05:46:27 +00:00
KongQun Yang b900565a0f Support Dolby Vision backward compatible profiles
Added Dolby Vision backward compatible signalling, i.e. for Dolby Vision
profile 8, both base codec without Dolby Vision and HDR codec with Dolby
Vision are signalled.

This is achieved by using a new MuxerListener implementation
MultiCodecMuxerListener, which wraps multiple child MuxerListeners and
is able to delegate to the child MuxerListeners based on the codecs in
the stream.

Closes #341.

Change-Id: I1967bb1ed503087cdd011c364e5fb5647d516ca4
2020-02-11 05:24:09 +00:00
Daniel Cantarín 1ed7de268d
Fix timestamp truncated to 32 bits in TS segment with $Time$ in template
Fixes #701.
2020-02-01 18:37:26 -08:00
Vladimir Kazakov 981515e6c8 Generate correct PlayReady PSSH data when AES-CBC encryption is used
Fixes #602.
2019-11-15 11:48:48 -08:00
KongQun Yang cb8b27e491 Properly initialize crypto engine to enable HWAES
Call CRYPTO_library_init to properly initialize crypto engine, which
enables AES-NI (Hardware AES) if it is supported by CPU.

Also added a performance benchmark test.

Closes #198.

Change-Id: I962a2da588d2f4f6cbe00c83ecc9a832db0e6042
2019-10-22 21:37:12 -07:00
KongQun Yang 0342adb132 Fix possible packager hangs when reading mp4 from FIFO
For MP4 files, mp4 parser tries to open and read the same file again
to handle trailing MOOV box.

Open FIFO again may result in packager hang.

Update the code to only attempt to load MOOV for local regular files,
as FIFO and remote files are unseekable anyway.

Fixes #664.

Change-Id: Ib286d2876d202cd5a248ffe70b13589b3cc74bc9
2019-10-21 18:49:52 -07:00
KongQun Yang 7973c5396f Replace Dolby Vision test content
Issue #341

Change-Id: I530b0768341e352f6ee0a1326540cd5712f01638
2019-10-09 21:34:53 +00:00
KongQun Yang 0f15ce149b [HLS] Support FRAME-RATE attribute
Calculate FRAME-RATE from sample duration as in the DASH solution.

Right now calculated frame-rate may not be accurate in some scenarios,
so we avoid setting the attribute in HLS unless it is more than 30
fps. We will set it unconditionally once it is fixed.

Fixes #634.

Change-Id: I87b6e9a047d959ae88dd4dcb2b4786527ba5c9fc
2019-10-04 22:50:34 +00:00
KongQun Yang 3f909fa551 [HLS] Support HDR signaling, i.e. VIDEO-RANGE attribute
- Parse and extract transfer_characteristics from H264/H265 VUI
  parameters.
- Set VIDEO-RANGE attribute in HLS according to HLS specification:
  https://tools.ietf.org/html/draft-pantos-hls-rfc8216bis-02#section-4.4.4.2
- Also added an end to end test.

Fixes #632.

Change-Id: Iadf557d967b42ade321fb0b152e8e7b64fe9ff3e
2019-10-04 22:50:20 +00:00
KongQun Yang 8029004c6b Add HEVC Dolby Vision support
- Add relevant FOURCCs for Dolby Vision.
- Parse DOVIDecoderConfigurationRecord (dvcC, dvvC) to generate
  Dolby Vision codec string.
- Propagate Dolby Vision configs (dvcC, dvvC, hvcE) from Demuxer
  to Muxer.
- Add a Dolby Vision end to end test.

Support for backward compatibility signaling in DASH and HLS will be
added in a later CL.

Issue #341

Change-Id: If1385df5f48e04b59cb7661130bea48e26b453bf
2019-10-03 23:04:15 +00:00
Phillip Baxter 00fde07bf7 Fix non standard channel layout AAC audio with PCE encoding
Latest version of FFmpeg encodes non standard channel layout, e.g. 5.1(side), in AAC using PCE.

This is now supported with the below changes:
- Allow channel_configuration in ADTS header to be 0, as the cctual channel layout is specified 
  in PCE.
- Add GetFrameSizeWithoutParsing to determine the frame size before actually parsing the frame.
- Skip and resume later if not the whole frame is available. 
- Also ensure that the next frame starts with a proper sync word.

Fixes #598.
2019-10-01 10:15:58 -07:00
KongQun Yang a86a697d8d Add more loggings for GAPs
Fixes #474.

Change-Id: I32f097c8a0e8d3381a276e6a130cb888e3ddd7f6
2019-09-11 00:02:52 +00:00
Tomohiro IKEDA b8ee20df1d Improve ConvertToADTS function performance (#639)
Remove the extra data copying.
2019-09-10 13:15:17 -07:00
KongQun Yang faa9a3ea68 [HLS Packed Audio] Truncate timestamp to 33 bits
Fixes #629.

Change-Id: Iadbbb28de051bf6b8b08561c152a3c1c2014aa80
2019-08-08 14:31:05 -07:00
KongQun Yang edd776eea2 Move DerivePixelWidthHeight to video_util.cc
Change-Id: I14df8b39fb58078635f08377f4177a45e341be79
2019-08-05 11:56:20 -07:00
KongQun Yang c257113e08 Support parameter sets in stream (avc3, hev1 etc)
- Parses parameter set NAL units in the samples.
- Calculate pixel width and height from track width and height.

Fixes #621, #627.

Change-Id: Ic1e120dccbd220b01168f7bf4effeaa43f95b055
2019-08-05 17:38:34 +00:00
KongQun Yang 78941394dd Add flag FLAGS_disable_peer_verification
To allow disable peer verification.

Issue #623.

Change-Id: I0781d10dea3ef6c92f0139aa1fa4949449c5da36
2019-07-22 16:33:32 -07:00
KongQun Yang 796974d2a1 [DASH] Support custom Accessibility and Role elements
Add dash_accessibilities stream descriptor, which is a semi-colon
separated list of accessibility_scheme_id_uri=value. It is optional.

Add dash_roles stream descriptor, which is a semi-colon separated
list of strings. It is optional.

Closes #565.

Change-Id: Idb1c20bb410fdd016db07e11fe507c102a3dd8ea
2019-06-13 15:43:32 -07:00
KongQun Yang fa2c4409a6 Add a flag --video_feature for Widevine
Change-Id: Id9ab958add1239972a4f94faf5e65cffe64444be
2019-04-16 07:55:08 -07:00
KongQun Yang fa7a6d967a Allow CMAF file extensions
Extensions cmfv, cmfa, cmft are now supported and recognized as
CONTAINER_MOV.

Fixes #574.

Change-Id: I728feefaba91f862966af49c780bbac8068722f2
2019-03-26 12:27:46 -07:00
KongQun Yang 26bc55503d Allow reserved NAL units in H264/H265
This is needed for Dolby Vision as Dolby Vision uses NAL unit type 62
to carry private information.

Issue #341.

Change-Id: Ib3f06d8f36ef3d89c33162dd74c012a0c3a805e5
2019-03-18 17:40:25 -07:00
KongQun Yang d850befb72 Refactor and Cleanup Descriptor classes
- Define BaseDescriptor and generic read / write operations.

- Define descriptors: ESDescriptor, DecoderConfigDescriptor,
  DecoderSpecificInfoDescriptor, SLConfigDescriptor.
  DecoderSpecificInfoDescriptor and all other descriptors can now
  handle arbitrary length size, not limiting to 64 byte for
  DecoderSpecificInfoDescriptor, which was placed to limit
  ESDescriptor length size to one byte.

- Now DecoderConfigDescriptor is able to handle reading and writing
  of all fields including buffer_size_db, which was not handled
  earlier.

Fixes #536.

Change-Id: Ia8a775f8bf6e90e3343a85f0e643bc44cd017c7a
2019-02-27 22:26:10 +00:00
KongQun Yang fcfc843a2e Use IV from Widevine key server if available
Fixes #555.

Change-Id: Ic077f97884a0c3d26159cd44791298bdd400068d
2019-02-27 22:17:21 +00:00
srebrnyp 22af5533b1 Add crypto_period_seconds to Widevine key request (#545)
Add crypto_period_seconds to Widevine key request

When using key rotation with Widevine DRM, a key server has to know
the duration of crypto period to relate generated keys to the media
playback time. This helps the server to provide relevant keys to
a client during license request.

Closes #544.
2019-01-24 10:39:54 -08:00
KongQun Yang 3f7ecd4e29 Workaround extra AUD in the access unit
VLC seems to generate access units with extra AUDs. In #526, the below
sequence is seen:

  AUD | SPS | PPS | SPS | PPS | AUD | SEI | SEI | SEI | IDR_SLICE

Previously we exit early when seeing AUD, which results in delayed
processing of the access unit.

The behavior is changed to continue processing the following NAL units
to workaround the content issue.

Closes #526.

Change-Id: I80f571c0711c6db1337eb393fce36fae5432b6c5
2018-12-15 00:32:06 +00:00
KongQun Yang cd7640a5bd Support trick play with Ad cues
Fixes #528.

Change-Id: I558285a2fae3d2048ef7cefabcd4761e35be47a8
2018-12-13 00:27:11 +00:00
KongQun Yang 273ab09f05 Support HLS characteristics
Add hls_characteristics stream descriptor, which is a colon or semi-colon
separated list of strings. It is optional.

Fixes #430.

Change-Id: Ifcf79316e68768ff065891933de565cd0ff32ec4
2018-11-26 20:02:43 +00:00
KongQun Yang 4c6059be78 Fix mpeg-ts demuxing with AC-3/E-AC-3
kFrameSizeCodeTable rows are ordered by 32kHz, 44.1kHz and 48kHz,
which is the reverse of fscod (48kHz, 44.1kHz and 32kHz).

Also updated unittests.

Fixes #487.

Change-Id: Icb0afb8bb895afde0028eee05b403bc85bf7b538
2018-11-20 22:33:40 +00:00
KongQun Yang db3ed544f8 Add the logging for 'Container not supported' error
Dump the first 512 bytes of the buffer if container is unknown. This
can help us find out what the actual container is; and fix the
container detection bug if there is.

Closes #505.

Change-Id: I4a8fe5954d0419ef2ccbb9067ec2e9ffe1da417e
2018-11-09 10:26:33 -08:00
KongQun Yang 53aa775ea4 Omit all optional fields in AV1 codec string
The spec requires the optional fields to be mutually inclusive
(all or none).

Issue #453.

Change-Id: I6d62bb862957abe7a3517058510f614995a92dd9
2018-10-12 13:20:11 -07:00
KongQun Yang 4b19905bc2 Support subsample encryption in AV1
Closes #453.

Change-Id: I68e46fb83cbf7e62a19fa83698cb66bfc0acd98d
2018-10-11 11:35:00 -07:00
KongQun Yang 5c4d930465 Move subsample extraction out of EncryptionHandler
Created SubsampleGenerator to generate subsamples.

This is part of the EncryptionHandler clean up to make it more modular
and testable.

Change-Id: I6f4076b057027c72335beb3cbf1965341eb18031
2018-10-11 10:38:43 -07:00
KongQun Yang acaa6b9b3b Move encryptor setup out of EncryptionHandler
Created EncryptorFactory to set up the encryptors.

This is part of the EncryptionHandler clean up to make it more modular
and testable.

Change-Id: I839bcd8a84fa873396360d67afb540fef1345673
2018-10-10 19:27:28 +00:00
KongQun Yang 8d11e5ea64 Support Marlin DRM signaling in DASH
Only Marlin Adaptive Streaming Specification – Simple Profile is
supported.

Two additional updates:
- Remove FairPlay ContentProtection element from DASH mpd as FairPlay
  does not define a signaling in DASH.
- Updated end to end test to include all DRMs we support.

Closes #381.

Change-Id: Id12269b471ea34983b782cbd92f687332292ef59
2018-10-01 20:22:58 +00:00
KongQun Yang fc0c5ddf0d Implemented AV1 bitstream parser
Implemented according to bitstream spec at
https://aomediacodec.github.io/av1-spec/.

It will be used to do AV1 subsample encryption later.

Issue #453.

Change-Id: I84d8a2a780d95f2c9f430ee598838b97474cc0af
2018-09-28 18:45:44 +00:00
KongQun Yang 08aa9b6b2b Remove FairPlayPsshGenerator
This was introduced earlier to indicate FairPlay protection system. But
in fact, it is sufficient to just use the system id for the indication.

- Also updated various parts of the pipeline to support empty PSSH.
- Added an additional FairPlay end to end test using fMP4.

Change-Id: Ica48b7b5235e9a2b5a7f722bcd0fc1ef2073ac13
2018-09-21 00:49:35 +00:00
KongQun Yang 42083d205d [DASH] Fix TTML text input passthrough (regression)
Note that TTML in ISO-BMFF is not supported yet.

Also updated packager_test.py:
- Added a test using TTML passthrough.
- Computed output extension from input extension unless output_format
  is specified.

Fixes #478.

Change-Id: Ia917fc4ed3c326782791ed67601fba02ea28b11d
2018-09-19 23:27:48 +00:00
KongQun Yang 5a912815c1 Move protection system Ids to protection_system_ids.h
Change-Id: Ia22b89c38b3b1ff7ead05f8484e15edef6218953
2018-09-17 15:29:53 -07:00
KongQun Yang cb77b65117 Rename RawKeyPsshGenerator to CommonPsshGenerator
Change-Id: I59f9156ae0f13f04ba846806c661292f29339945
2018-09-17 15:10:59 -07:00
Denis Akhmetzyanov 31fc2f5135 Clear up condition in AesPatternCryptor (#476)
The condition was the same in meaning, but a bit confusing in syntax.
2018-09-13 14:04:11 -07:00
KongQun Yang 31e5f129b5 Fix incorrrect segment name with $Time$ in segment_template
The time for the previous segment was used when generating the segment
name. This resulted in the first segment being overwritten and
mismatching manifest and media files. It led to playback problems.

Issue #472.

Change-Id: Ia8130ce261585e1a2ede83b26de3e32508de087f
2018-09-13 00:56:28 +00:00
KongQun Yang d0978b3937 Compute and set VP9 Level if it is not already set
The VP9 level is computed when the container is missing a codec config
or if the level is missing from the codec config.

This fixes VP9 in ISO-BMFF files generated by FFmpeg v4.0.2 or earlier
which does not have level set in the codec config.

Fixes #469.

Change-Id: I685bfd48be16ee6b2209da1c3173f7d6bb02b36a
2018-09-13 00:37:30 +00:00
KongQun Yang 0709db4bbc Add support for AV1
Implemented per AV1 Codec ISO Media File Format Binding at
  https://aomediacodec.github.io/av1-isobmff/
And AOM AV1 codec mapping in Matroska/WebM at
  https://github.com/Matroska-Org/matroska-specification/blob/av1-mappin/codec/av1.md

Note that AV1 specific boxes are not supported in this CL, i.e.
AV1 Forward Key Frame sample group entry 'av1f', AV1 Multi-Frame
sample group entry 'av1m' etc are not supported. These boxes are optional.
We will add support later if they are useful to the clients / players.

Encryption is not supported yet.

Issue #453.

Change-Id: I630432d0a9bf82d263ffaf40e57f67fc65eee902
2018-08-31 19:16:04 +00:00
KongQun Yang 86b10b6316 Fix pattern encryption when applying to patterns other than 1:9
We used to skip all the remaining bytes if the size is less than
|crypt_byte_block| blocks.

This interpretation is incorrect. We should only leave the last partial
16-byte block un-encrypted.

Change-Id: I4f09600efa52e2fdf4d0b661dfc418dcb675f9f6
2018-08-31 19:15:43 +00:00
Aaron Vaage 60df64705b Created Test Handler CachingMediaHandler
Renamed "FakeMediaHandler" to "CachingMediaHandler" so that it
is easier to differentiate from "FakeInputMediaHandler". It will
be used as the single method to verify media handler output.

This is part of an effort to find a cleaner way to test media handlers.

Change-Id: Ie391fe23ee3389d13b012ae3093744a453106c19
2018-08-31 02:42:34 +00:00
KongQun Yang 33792ca2da Workarounds TS contents with dts moving backwards
Negative duration is not allowed, so set the duration of that sample to
an arbitrary small value in case it is needed to decode future samples.

Issue #451.

Change-Id: I9250d71d163f769ea2657d56e108b6dbd583de67
2018-08-28 20:25:35 +00:00
Aaron Vaage e071710fa9 Adding Missing "// namespace"
Change-Id: I7bdb5841a8b22c59d97f120f8d83bddcc77858cb
2018-08-27 17:19:31 +00:00
KongQun Yang 40a3b42980 Fix pattern signaling in seig for key rotation with cbcs
Closes #460.
Bug: 112769382

Change-Id: Id2277edf9ac1ca637354f3a585666ad139ed8ee2
2018-08-24 23:20:06 +00:00
KongQun Yang e5b8b3ec64 Add support for seek preroll in AAC and other audio codecs
Closes #452.

Change-Id: I0f648c4fa6c861540b050a5b4e9878987c8383e5
2018-08-23 18:58:04 -07:00
KongQun Yang f49b89280c Support STYLE and REGION in WebVTT
Note that STYLE and REGION are not supported in mp4 container due to
spec limitation as 14496-30:2014 does not specify a way to signal
styles/regions inside mp4.

Closes #344.

Change-Id: I05c14df916f7b2c7ca4364ee9407e0eda4dc7a3f
2018-08-20 14:12:07 -07:00
KongQun Yang 715ed939f1 Add instructions to build on Alpine Linux
- Also fixed compilations in Alpine Linux and other flavors of Linux.
- Added container versions in docker files to always use a verified
  version.

Closes #164.

Change-Id: I949a8709e4d70c49129c9c2e8608dd78193d964c
2018-08-17 20:46:11 +00:00
KongQun Yang 8612798de1 Change --additional_protection_systems to --protection_systems
Issue: #245.

Change-Id: Ib7da3b874207623e3ee0b1a942ecb2509e750669
2018-08-14 22:12:55 +00:00
KongQun Yang fd41ef0032 Properly handle failures when using PlayReady key source
Change-Id: I0a50ae67fcde1fa4a99b91ad7c2642bbfc90b73a
2018-08-14 21:17:45 +00:00
KongQun Yang 6f66132aa9 Support Widevine PSSH with protection scheme generation
Issue #245.

Change-Id: Ieabdd3cdc55eb5bd4b7a145c9d041cc918101f18
2018-08-10 00:00:21 +00:00
KongQun Yang db076d6892 Support Fairplay in --additional_protection_systems
Issue: #245.

Change-Id: I15187c1d3463534bf5e11ff97032311bb1d0c3bf
2018-08-09 23:59:40 +00:00
KongQun Yang 2a80c6773a Clean up PsshGenerators
Change-Id: I0940bd5a2a0a5af175088a15890ddd82602d0c7f
2018-08-09 23:59:04 +00:00
KongQun Yang 36a7c7d935 Adjust timestamps in fMP4 if there is an initial composition offset
In some ISO-BMFF files, there is an initial non-zero composition offset,
but there is no EditList present.

This is against ISO-BMFF spec recommentation [1] and we believe in most
cases it is just missing the EditList.

[1] 14496-12:2015 8.6.6.1
It is recommended that such an edit be used to establish a presentation
time of 0 for the first presented sample, when composition offsets are
used.

Issue: #112.
Change-Id: I178d5ec9d8c294c9f70aac4f4dd6254c824e2255
2018-08-09 22:03:23 +00:00
KongQun Yang 0fe31423cb Multi-DRM flag refactoring
- Added flag --additional_protection_systems to specify multi-DRM
  options.
- Deprecated old multi-DRM flags: --generate_widevine_pssh
                                  --generate_playready_pssh
                                  --generate_common_pssh

Issue: #245.

Change-Id: If926bc9d481e941aa2269b6672bf2ba5411c3a50
2018-08-09 22:01:46 +00:00
KongQun Yang 416051ae65 Avoiding segmentation fault on streams without samples
An informational message is logged instead.

Fixes #446.

Change-Id: Ia3a79a16b3bdbabd5d56facf9bf011f29c9b1533
2018-08-02 17:53:17 +00:00
KongQun Yang bd98436241 Normalize crypto_period_index to 0 for negative timestamp
It is possible to see a negative timestamp if the input mp4 file
contains EditList.

Also increase the queue size for EncryptionKey to be able to handle
smaller crypto_period_duration during testing.

Change-Id: I68278bf482d6662e771d9b80f4d5409605065aac
2018-07-31 12:56:33 -07:00
KongQun Yang 51d39d96a1 Add offset to tranport streams (MPEG2-TS, HLS Packed Audio)
Configurable with --transport_stream_offset_ms.

This is needed to compensate for possible negative timestamps in
inputs, which could happen on ISO-BMFF with EditLists.

Issue #112.

Change-Id: I0fce8766c9df2911b9bb859c1e54052a8ed2abfb
2018-07-26 23:20:21 +00:00
KongQun Yang 9a55d4033f Adjust timestamps in mp4 if there is an initial composition offset
In some ISO-BMFF files, there is an initial non-zero composition offset,
but there is no EditList present.

This is against ISO-BMFF spec recommentation [1] and we believe in most
cases it is just missing the EditList.

[1] 14496-12:2015 8.6.6.1
It is recommended that such an edit be used to establish a presentation
time of 0 for the first presented sample, when composition offsets are
used.

Issue: #112.
Fixes: b/110782437.

Change-Id: I23d33810ce536b09a1e22a2644828d824c1314f5
2018-07-26 23:20:21 +00:00
KongQun Yang 40ea1286b9 Add support for EditLists in ISO-BMFF
- EditLists in input files are parsed and applied to sample timestamps.
- An EditList will be inserted in the ISO-BMFF output if
  - There is an offset between the initial presentation timestamp (pts)
    and decoding timestamp (dts). Chrome, as of M67, still uses dts in
    buffered range API [1], which creates various problems when buffered
    range by pts does not align with buffered range by dts. There is
    another bug in Chrome that applies EditList to pts only [2]. This
    means that we can insert an EditList to align pts range and dts range.
  - MediaSamples have negative timestamps (e.g. for Audio Priming).

You may notice the below change on some contents:
- Some media duration is reduced by one or two frames. This is because
  EditList in the input file was ignored in the previous code, so video
  streams start with a zero dts and a non-zero pts; the smaller of dts
  and pts was used as the starting timestamp (related to the earlier
  workaround for Chrome's dts bug), so the calculated duration was
  actually a bit larger than the actual duration. Now with EditList
  applied, the initial pts is reduced to zero, so the media duration is
  also reduced to reflect the actual and correct media duration.

It may also result in negative timestamps in TS/HLS Packed Audio, which
will be addressed in a follow up CL.

Fixes #112.
Partially address b/110782437.

[1] https://crbug.com/718641, fixed but behind MseBufferByPts.
[2] https://crbug.com/354518. Chrome is planning to enable the fix for
    [1] before addressing this bug, so we are safe.

Change-Id: I59317740ad3807ca66fa74b3a18fdf7f32c96aeb
2018-07-26 23:20:21 +00:00
KongQun Yang 9a26ec1e83 Ignore extra Ad cues at the end of the stream
They will result in empty DASH representations, which is not spec
compliant.

For text, if the cue is before the max end time, it will still be
dispatched as the text samples intercepted by the cue can be split into
two at the cue point.

Bug: 111359775.

Change-Id: I55c2025c4e9d64c88e6a685c0cf3024a0cc4a6d8
2018-07-24 18:46:30 +00:00
KongQun Yang 308b92d16e [WebVTT] support cues without payload
WebVTT cues without payload may not carry meaningful information, but it
is allowed by WebVTT specification [1]. It could also be useful
sometimes, e.g. to signal the time progression in live case.

Fixes #433.

[1] https://www.w3.org/TR/webvtt1/#types-of-webvtt-cue-payload

Change-Id: I9e31f4a3789cbdafb7667b64f4019834190ecfc0
2018-07-17 17:07:53 +00:00
KongQun Yang b4ae6561f8 Cleanup packager_test.py
- Support decryption verification in _CheckTestResults
- Allow diff_files in _CheckTestResults
- Update all functional tests to use _CheckTestResults

Change-Id: I3f9c02f35808eba787becf9b1e5c1ce9238f943e
2018-07-16 19:13:02 +00:00
Aaron Vaage a510d3aa38 Print Error and Ignore Text Samples With Bad Times
Before we had an assert that would catch if a sample had an
invalid times, however input may have bad times.

We did have a message if we saw a sample with a duration equal to
zero. This expands that check to check if the time is valid in
general and will ignore any sample that is not valid.

Fixes #425

Change-Id: I9774bfbdbd401f3016d2c345665b9973d1889db7
2018-07-09 15:25:10 -07:00
KongQun Yang 1742e03471 Drepcate --num_subsegments_per_sidx
This flag was designed for two purpose:
- Grouping fragments into subsegments, achieving three level hierarchy:
  segment < subsegment < fragment.
- Indicate whether to generate 'sidx' box in media segments (when the
  value is set to a negative number).

There are no practical use case for the first purpose. Removing it to
simplify the code and reduce the confusion.

Introduce another flag --generate_sidx_in_media_segments for the second
purpose.

Change-Id: I4be7cd42662fb324c1158b978e05768ee49dd048
2018-07-02 21:59:14 +00:00
KongQun Yang f089d1d0d4 Deprecate --mp4_use_decoding_timestamp_in_timeline
It was implemented to workaround Chromium's DTS
https://crbug.com/398130, but the workaround does not really work in
all situations.

Remove it now as we already have another workaround available.

Change-Id: I291f559d78120fb743a6679b7d927e5bbc5b6b4e
2018-07-02 21:59:01 +00:00
KongQun Yang 571ee24f3e Use PTS instead of DTS in ChunkingHandler
DTS was used in ChunkingHandler. As a result, SegmentInfo contained
timestamp in DTS. MP4Muxer has a logic to change SegmentInfo to use
PTS but not in other muxers.

Benefits of using PTS in ChunkingHandler:

- De-dup the redundant logic in MP4Muxer
- Ensure consistent behavior in different output containers
- Consistent with other timestamps, e.g. Ad Cue timestamps

Issue #413

Change-Id: Ib671badf144e0c0866d60f4ff0ac0cbbdd33817e
2018-07-02 21:58:45 +00:00
Aaron Vaage 5f072e3b08 Start Segments At First Sample in Text Chunker
We always assumed that text stream started at zero in the text chunker.
This meant that if the text stream started later than zero (like in a
live stream) we would generate a lot of empty segments.

Instead the text chunker will assume that segments should be adjusted
to align with multiple of segment duration. The text chunker will assume
that an earlier component in the pipeline (i.e. text padder) will ensure
that the first sample has the time that we want to start segments at
(even it needs to add an empty sample).

Issue #416

Change-Id: Ie45844354d6e9448787cae896841b5ab31721ed6
2018-07-02 17:57:10 +00:00
Aaron Vaage 1600909c4b Don't Always Start Text At Time Zero
Previously, the text padder media handler would assume that text always
started at time zero. This would work for VOD but would result with a
large pad at the start of LIVE content.

To avoid this, the text padder will use a bias to test whether or not it
thinks the content starts at zero. Right now the bias is set to be 10
minutes, but will later be configurable with a command line flag.

10 minutes was used as LIVE content will have much larger values and VOD
content should have much lower values.

Issue: #416

Change-Id: I07af15a577392fb030e36f052085cd4e667700e8
2018-06-29 23:02:22 +00:00
KongQun Yang b4256bf040 [Cleanup] Use int64_t for time for consistency
Change-Id: I408f3fe7c98320be4e43ca2a5bcb9b22cc8a2012
2018-06-29 22:53:06 +00:00
KongQun Yang d1caa29c8d Disregard trailing null bytes when locating RBSP stop bit
This is a more faithful implementation of more_rbsp_data().

There could be trailing null bytes in NAL units. This isn't valid per
H264 specification, but the referenced bug includes a sample where the
PPS in the avcC record includes a trailing null byte.

Workaround the problem so packager does not fail.

A similar problem is workarounded in Chrome:
https://codereview.chromium.org/1107593004

Closes #418

Change-Id: I28cb8a9371945dc094f766c3e559d7a66859b451
2018-06-29 20:24:15 +00:00
Aaron Vaage 0734ba998b Remove Old Cue Insertion Code
When we built the cue alignment media handler, we did not remove
the old solution.

This change removes all the code for the old solution.

Change-Id: I851b284c449c7d25aaabc2f55df5579ba7b5aad1
2018-06-21 18:47:04 +00:00
Aaron Vaage 5a9a49034b Merge Create and Dispatch in Cue Alignment Tests
Originally the create and dispatch of stream data in the cue
alignment tests were separate to improve readability. The idea was
to separate building each stream and dispatching the streams muxed
together would make it easier to understand the streams.

However, coming back to the code, this did not hold up as it took just as
long to understand the code. So merging the two together allows for the
code to be more concise.

Change-Id: I77f6bb67e7fb0ca7af0553c3baf07082770da74c
2018-06-21 18:27:01 +00:00
Aaron Vaage b5cdfee73f Update "One to many" example in Media Handler
In the media handler there is an example of what a one-to-many media
handler would be. It used the trick play handler as an example, but that
handler is now a one-to-one media handler. Changed the example to use the
replicator media handler.

Change-Id: I26908c6e27ea4a697a19c0fa0179c60842a449d2
2018-06-21 18:26:42 +00:00
Aaron Vaage 4408718b5b Move ChainHandlers to MediaHandler
Made ChainHandlers to MediaHandler::Chain so that it can be used in our
test code as well. After all it is a pretty helpful function.

Change-Id: I8d83ee184052cd9fa9b37f2741c96f3223d5ab48
2018-06-21 09:52:04 -07:00
Aaron Vaage eb2385491c Run clang-format over MediaHandler
Ran clang-format over media_handler.cc and media_handler.h so that
later changes won't update the formatting as much.

Change-Id: I2db4f9f4e8a66fca1e1418ab99b283a0e4a70e4c
2018-06-20 16:28:47 -07:00
Aaron Vaage 0efc7612ed Fixed Copy and Assign in MediaHandlerGraphTestBase
The copy and assign in MediaHandlerGraphTestBase referred to the wrong
types. This changes them to refer to the correct types.

Change-Id: I165c9a1da39b49adf41e7c35ae3e4a0b9ecfa838
2018-06-20 16:28:47 -07:00
Aaron Vaage b980cf3019 Reduce What We Check in Cue Alignment Tests
Reduce which variables we check in the cue alignment tests by replacing
the less important variables with "_".

Change-Id: Id8770b5f2045ad5c8ac6eee54d6a291d933a4b6f
2018-06-20 17:29:36 +00:00
Aaron Vaage 8d800446f3 Align Trick Play Tests With Other Media Tests
We have adopted some new standards for how we are writing the media
unit tests. This change goes through the trick play tests and
updates them to be more inline with how we are doing new media
tests.

This include using "_" for parameters that are not the focus of the
tests (used in the EXPECT calls).

This includes wrapping Dispatch calls so that the test bodies can
be more readable.

Change-Id: Iab4b1ce67666b6c8a4a821db1a8f4369cd366dc3
2018-06-19 19:48:18 +00:00
Aaron Vaage bf29257e48 Added IsVideoStreamInfo Test Matcher
Added a matcher for Video Streams. This will allow us to use a general
matcher in tests for video specific fields.

Change-Id: I91b9aebd66be37ec6d5f09b762263fafaef854c2
2018-06-19 19:48:10 +00:00
Aaron Vaage 26bb50640c Added StreamTypeToString
Added a StreamTypeToString function in StreamInfo (where stream type is
defined) so that we can print the type in a more readable way.

Change-Id: Icb1d10f5a72dca314d9bdf07e9cd0c0a185bd791
2018-06-19 10:12:47 -07:00
Aaron Vaage 740724f8cf Run 'clang-format' over stream_info
Ran 'clang-format' over stream_info.h and stream_info.cc so that
later changes can focus on the actual changes and not the formatting.

Change-Id: I8a75fe0f88db533f4a811d65dabd023033f07bda
2018-06-19 09:58:29 -07:00
Aaron Vaage e0ce59aa91 Add is_key_frame in IsMediaSample Matcher
Added the key frame field to the IsMediaSample mather. All
tests that do not care about a sample being a keyframe (or not)
have been updated to use "_".

Change-Id: I44180687c58c260b6856e683d647f532227b14d5
2018-06-18 16:05:22 +00:00
Aaron Vaage fbc4952e21 Updated StreamData Matchers to Use Matchers
Updated all the stream data matcher we use in our unit tests
to allow us to use matchers in them. We are now able to use "_"
to ignore specific parameters.

With this we were able to replace the different version of
matchers for each stream data type with a single instance for
each type.

Includes updates to printing strings to the listener. Strings
now go through a "pretty" function to help make it easier to
read them in the output.

Change-Id: I146351b54fccd63ab9ec936877e6c6b30f9aa9fc
2018-06-13 15:36:22 -07:00
Aaron Vaage 440adb3086 Remove Text Time Scale Assumption From Cue Alignment
In the cue aligner, we assumed that all text will be in milliseconds.
This was the last place with that assumption. This change removes that
assumption and uses the stream info's time scale.

Issue #399

Change-Id: Ie21bf27148e020bd85111dcace0bbdff3419c1ac
2018-06-13 13:44:21 -07:00
Aaron Vaage dbce84f3ea Remove Time Scale Assumptions From Text Chunker
Before, the text chunker would assume that all text streams were in
MS, which is not a safe assumption to make.

This changes it to take the time scale from StreamInfo and work
natively with scaled time units.

This required updating the tests. While doing so the tests were
rewritten with the goal to make them easier to read.

Closes: #399

Change-Id: Ib792ad306f40d749763418cde645337913a6046b
2018-06-13 17:43:49 +00:00
Aaron Vaage 30b189cb99 Make Test Util 'GetTextStreamInfo' require Time Scale
Make the text stream info factory method in media_handler_test_base
require the caller to specify the time scale.

Issue: #399
Change-Id: Ibdfb183e0aa3f4ff50edf6b58c4e9b966006c6d2
2018-06-13 17:43:35 +00:00
Aaron Vaage cc1d4b765a Set Box Definition Defaults in Header
To ensure that every variable in a box is explicitly set
every variable has been assigned a default in the header.

Change-Id: Iaa806c4058ac6621a64363a00040fbd9903c6710
2018-06-04 23:14:59 +00:00
Aaron Vaage 47f20031dd WebVtt Text to MP4 - Test That No Payloads Becomes Gaps
Text Samples with no payload should be ignored, so this adds a
test to check that samples with no payload get treated the
same as a gap.

As long as this case is true, using gaps in our other tests should
functionally be the same as using samples with no payload.

Change-Id: Ic16b240c43eda2514b537a2d938d4135638adc4e
2018-06-04 22:10:44 +00:00
Aaron Vaage e96fe3aedf WebVtt Text To MP4 - Explicitly Set Payload In Tests
Before we used the sample payload for each text sample as we were
focusing on the times rather than the contents.

As we look to add tests that rely on specific sample payloads, we
need to change the tests to explicitly set the payload for each
sample.

Change-Id: I24174686f46535cf6c2d59a18308101a3bb51c87
2018-06-04 22:10:39 +00:00
KongQun Yang 55050fe6b5 [Ad Insertion] Avoid adjusting EPT except for the first file
EPT (earliest presentation time) may be adjusted not to be lower than
the decoding timestamp (dts), but the adjustment should only be done
on the first file when there is one file per Representation per Period.
The second file and onwards should not be adjusted otherwise a GAP
would be created.

Closes #384
Closes b/78517422

Change-Id: I56771ad8fbbe6a87b832ec58854cfbf37d5f1817
2018-06-01 15:53:02 -07:00
Aaron Vaage 2c1faa71a0 WebVTT Text to Mp4 - Verify Media Sample Contents
In our text to mp4 tests, we were only checking if the times on
the samples lined-up with what we were expecting.

We want to check that text sample contents (ids, settings, and
payloads) were correctly merged into a single media sample. To
verify this, we now check if the sample ids appear in the
media sample.

Change-Id: Ica1a85a14e7b116275e3571332b2e90d7bc44c45
2018-06-01 20:43:16 +00:00
Aaron Vaage 668bae314f Add Unique Sample Ids in Text to MP4
In our text to mp4 tests, we used the same sample id for each sample,
this changes it so that each sample (within a single test) has a
unique id.

This is done in preparation to look for the ids in the created
media samples.

Change-Id: I3215a6f09279af8f40e1ce8a959e0a522a811173
2018-06-01 20:42:50 +00:00
Aaron Vaage b9dee56294 Rebuild Text WebVtt to MP4 WebVtt
The previous text to mp4 webvtt pipeline was incomplete. It
did not insert ad cues and it could only insert a segment
after a sample ended.

Now the pipeline supports ad cue insert and segment insertion
mid text sample. This required the pipeline to use the text
chunker (to split samples and insert segments) and required
a major overhaul of the text to mp4 converter.

Before the converter came before the chunker. This meant that
the converter only expected to see stream info and text samples.
Moving the converter after the cue aligner and chunker means
that the convert had to be aware of segments and cues.

The general approach is the same, however the converter will
convert the samples per-segment as the chunker will introduce
duplicate samples if a sample spans across segments.

Closes #362
Closes #382

Change-Id: I0f54a40524c36a602ad3804a0da26e80851c92fd
2018-06-01 19:49:56 +00:00
KongQun Yang 6e4820eedc [Ad Insertion] Support one file per Representation per Period
Allow the output file to contain template identifiers like $Number$,
$Time$ etc. Unlike the actual template used in SegmentTemplate, the
identifiers in output will be populated before pushing to the DASH
manifest.

Issue: #384

Change-Id: Ife1caadb6fccd32167fa1bc83fe2afcb2d2ad087
2018-05-31 23:59:21 +00:00
KongQun Yang 192ef2a0ac Update MuxerListeners to support multiple OnMediaStart/End
This is needed to support one file per representation per period where
there will be multiple content files generated.

Issue: #384

Change-Id: Ib7af750edf864d99075b8da4f3640217a5a94302
2018-05-25 20:43:34 +00:00
Aaron Vaage cf3fc61fbe Fix incorrect data_reference_index in TextSampleEntry
In the text sample box (for mp4) there was a value called
"data_reference_index" that was never initialized. This meant
that it took on various values can caused different results
between runs.

Change-Id: I4b18ac97ec4700f6e651b14898ef250713a4253c
2018-05-25 19:33:54 +00:00
Aaron Vaage d7dcf9c7c7 Run Clang Format on Box Definitions
Change-Id: Ibfbfe025e7b914ddfa2f7c81d419d7b4f9212554
2018-05-25 19:33:45 +00:00
Aaron Vaage 388d49cf98 Rename webvtt_output_handler files
Renamed all the files called "webvtt_output_handler*" to
"webvtt_text_output_handler*" to better reflect the class name
in them.

Change-Id: I977bab362076974a124f263bcefff716ed8b6a0f
2018-05-25 18:56:54 +00:00
Aaron Vaage b69eb49f77 Add Missing ASSERT_OK Calls in Cue Alignment Tests
The SetUpAndInitialize function returns a status. We were not
asserting that it return an OK status. This change adds the
missing ASSERT_OK calls.

Change-Id: I044f60c0450d46fc0f6495319b1ed7ef8ab6e794
2018-05-24 22:14:07 +00:00
Aaron Vaage b01de0bfb6 Disallow Copy and Assign WebVtt File Buffer
We should never need to copy or assign the webvtt file buffer
so this change enforces that.

Change-Id: I119865e96c0188781adbe115beb2486b1b56542a
2018-05-24 21:47:56 +00:00
Aaron Vaage d56efd147a Disallow Copy and Assign For WebVTT Output
We don't want to allow any handler to be copyable or assigned-over
so this change enforces that for the webvtt output handler.

Change-Id: Ie0d59d6dbfb7a5e00bb4dd1422cd696d1a2d6072
2018-05-24 14:46:23 -07:00
Aaron Vaage b3c148607f Simplify WebVtt Output
Before, the webvtt output handler was written so that it could
share code between a segmented and non-segmented handler. As
we are not worried about that right now, this change simplifies
the handler to just be about segmented output.

Change-Id: I29dbc4e3a4ffbeb7ea10e23db489ee74b398a6c4
2018-05-24 18:09:48 +00:00
KongQun Yang 4d8ce0ff5d Extract bitrates in ES descriptor for AAC if available
Change-Id: I1aa53b519e8751400bea6b33936cb2e7a05958dc
2018-05-22 11:59:58 -07:00
KongQun Yang 734b4161f8 Ignore unsupported audio codec in the source content
Instead of failing immediately, ignore unsupported audio codec when
parsing the source file, as there may be more than one stream in the
source file. This allows the supported streams to be packaged.

Closes #395.

Change-Id: I01005a93a19012c19065251647c9b06dd25c673a
2018-05-22 18:35:34 +00:00
KongQun Yang 317425d92f Fix TS mimetype in DASH
Change-Id: I64235d02206bda9a7c18d396b2889bb28091ab5d
2018-05-21 20:31:40 +00:00
Aaron Vaage 5bb5a58b7f Removed Unused Cue class
The Cue class was from a previous WebVTT implementation and
is not used in the current implementation. It was missed when the
other classes were removed. This change removes it.

Change-Id: I661ab3fcd80b5e5ef98b5213746b341a4028d1a1
2018-05-21 18:46:57 +00:00
KongQun Yang 59941a101a Support entitlement license with Widevine key server
- Added a new --enable_entitlement_license flag, which sets
  'enable_entitlement_license' in Widevine CommonEncryptionRequest;
- Support 'boxes' in Widevine CommonEncryptionResponse.

b/78171767

Change-Id: Id399fc7fcb2948c571e12c8af7687cfcfcef41fe
2018-05-17 21:03:05 +00:00
Aaron Vaage df6661b93d Fixed Incorrect BOM used in WEBVTT Header
When originally implementing the webvtt parser, there was a
misunderstanding in what the BOM was suppose to be
(https://en.wikipedia.org/wiki/Byte_order_mark). This corrects the
misunderstanding.

Close #397

Change-Id: I250d392db228e5e9b86684614b57adc5d8a4e5fe
2018-05-17 17:33:31 +00:00
KongQun Yang 0af2c5cdcf Integrate PackedAudioWriter
Closes #342.

Change-Id: I2fb4a651ad90448ab226b386c92c94e11ff9f9a8
2018-05-16 18:12:42 -07:00
KongQun Yang 39beb99d6c Implemented PackedAudioWriter
Issue #342.

Change-Id: Ic1379b00e38f818460f24ad57122ca22c5b5285a
2018-05-16 21:52:18 +00:00
KongQun Yang 33c4f344e7 Implemented PackedAudioSegmenter
Per HLS specification:
https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-3.4

Issue #342.

Change-Id: Iba7fae7a9b8912bcd13ae55d25b22a5803f7f7ea
2018-05-16 21:52:11 +00:00
KongQun Yang 5965b3e136 Move TS encrypted audio setup for HLS to hls_audio_util
Change-Id: Ibbc1fe2a8013abded6df2f2f57701ec328d3e5c6
2018-05-16 01:04:14 +00:00
KongQun Yang 8333908df1 Implemented Id3Tag class to handle ID3 tag
Also switched the original code in mp4 to use the new Id3Tag class.

Change-Id: I1db2c6c6142ed98b72a432980a6a54815f1a8cc4
2018-05-16 01:04:02 +00:00
Aaron Vaage 2e9c2fe024 Fix Cue Insertion at Text Stream End
Problem : Text samples have variable length and therefore act
          more like continuous samples whereas audio and video
          act more like discrete samples. Since we use sample
          start time, a cue event could be inserted after the
          start time of the last text sample and never get
          inserted as there are no more samples.

Change : After all streams have requested flushing, we make sure
         to collect all remaining cue events from the sync point
         queue and insert them into each stream.

Issue #362

Change-Id: Id8f136f7ef53531f7a7f412613eac352324e0130
2018-05-15 22:01:09 +00:00
KongQun Yang ae82cd16f3 Remove the usage of JsonWriter in WidevineKeySource
Uses protobuf JSON util instead.

packager/base/json_writer comes from Chromium base. We are going to
replace it with abseil, which does not have a JSON library.

The code is much more cleaner now.

This is unfortunately, at the expense of increased output binary size.
packager binary increases by another 100KB.

Change-Id: I83a9217a484cad3c41147ad9a75311384347c49c
2018-05-15 20:10:43 +00:00
KongQun Yang b209aeeb7a Remove the usage of JsonWriter in SimpleHlsNotifier
Use protobuf utilities instead.

packager/base/json_writer comes from Chromium base. We are going
to switch to abseil which does not have a JSON library.

This is unfortunately, at the expense of increased output binary size.
packager binary increases by about 300KB due to:
- Protos cannot be compiled with LITE_RUNTIME any more.
- Additional protobuf library needed to convert between JSON and proto.

Change-Id: I45a497376925b42d147ffcaabcfc2fa4dbdeacc1
2018-05-15 20:06:54 +00:00
Aaron Vaage f619affb8f Store More Than One Cue
In the cue alignment handler, instead of storing just one cue, store
a full queue. This will make it easier to handle text streams that
end before audio and text.

Change-Id: Ida97008fa015639350261bd3f76f4cb901747c66
2018-05-14 22:10:07 +00:00
Aaron Vaage ff0fd500b8 Store Stream Data and Not CueEvent
In the cue aligner, instead of storing the cue event, store a
stream data so that we don't need to know the stream index when
sending the cue event downstream.

Change-Id: Ice27da021fad2872e2a23975b959630a9d43b736
2018-05-14 22:09:51 +00:00
KongQun Yang b5a73fc1d5 Refactor ProtectionSystemSpecificInfo class to struct
This is in preparation of supporting entitlement license API, where
common encryption server may return concatenated PSSHs directly.

Refactored ProtectionSystemSpecificInfo into a struct containing
concatenated PSSHs. This will make it easier to pass PSSHs around.

Also, most of the time, users of ProtectionSystemSpecificInfo do
not care what is in PSSH; so moved PSSH box parsing and building out
of ProtectionSystemSpecificInfo.

b/78171767

Change-Id: I1c4d5e7e23efd2f7d4b2b9704378323112e47f00
2018-05-11 00:10:07 +00:00
KongQun Yang 6b86b085b4 Add Widevine CommonEncryption proto
Change-Id: I18b3991604ff197d0d50f68b0528244b11125025
2018-05-10 23:16:34 +00:00
Aaron Vaage ec3bbfff16 Isolate Video and Non Video Actions In Cue Aligner
To make it easier to understand what a video stream and a non
video streams is doing in the cue aligner, each stream type is
given their own functions.

Change-Id: I8b8ca403721bcb06ca3056004420902667a30f6c
2018-05-09 13:50:49 -07:00
Aaron Vaage df19a48aa0 Use Common Hint
Use a common hint for all stream states as the hint is always
updated when we get a new cue event. Cue events are only gotten
when be pass the hint, so there should only need to be one hint.

Change-Id: I0838110b9b10325a9e99f8fca0b11f0a6b48f8a0
2018-05-09 19:48:45 +00:00
KongQun Yang 2ea347f45c Rewrite RawKeySource::GetCryptoPeriodKey
To allow generating Widevine / Playready PSSHs if the corresponding
PSSH generator is specified.

Note that Key Rotation with RawKeySource is designed to be used for
testing only.

Change-Id: Icaf9e74955c082a7b000bd6a08f4561f2e01a2e2
2018-05-09 00:00:15 +00:00
KongQun Yang a78c3d3224 Use MessageDifferencer for proto comparison
Change-Id: Ifa4c56d09a7e9c5c71a37ec70f81d546fe58f0a9
2018-05-08 21:30:50 +00:00
KongQun Yang 440ba442f6 Add BufferWriter::AppendString
Change-Id: Id8a7d09fd76eeb95600e108c70c2e38ddd18a7ab
2018-05-08 21:25:01 +00:00
Aaron Vaage 9a9f7d58b2 Update Cue Alignment Tests To Interweave Sample Data
Problem: Sending samples to the cue alignmenet handler did
         not reflect what was more likely to happen. In our
         tests we would send all the samples for one stream
         then all the samples for another stream. This created
         some special cases that would either not happen in
         reality or miss cases that would likely happen in
         reality.

Changes: Changes all tests to dispatch samples in an interlaced
         pattern that better reflects muxed content.

Change-Id: I985092154b62eb12d95499663d195ca6c103bc19
2018-05-07 16:25:10 +00:00
KongQun Yang 8767d20f38 Fix potential slice header size off by one byte in H265
In H265Parser::ParseSliceHeader, the parser does not handle
byte_alignment() from the spec. byte_alignment() reportedly contains
at least one bit, which is not handled right now.

See Section 7.3.2.12 Rec. ITU-T H.265 v3 (04/2015).

Also added a few size sanity checks in H265Parser to make sure the
code does not crash if an invalid input is provided.

Fixes #383.

Change-Id: I33b31396058fc5ba67a0fc119be5fe56ec9443b0
2018-05-03 18:13:07 +00:00
KongQun Yang 2d919b5a31 Fix potential partial DASH segments during live packaging
Packager uses ThreadedIO to write media segments and manifest /
playlists. There was a possibility that media segments write being
delayed and scheduled after updating manifest / playlists.

This CL fixes the race condition.

Also added a note on how segments can be synced to cloud storage to
avoid the race condition during file sync.

Also added a live WebM test.

Fixes #386.

Change-Id: Icf9c38cdec715fa3dc2836eab1511131e129fe41
2018-05-03 09:26:23 -07:00
KongQun Yang c7e1271f58 Support AAC with program_config_element()
Fixes #387.

Note that the output will not play in Chrome until the Chrome bug
https://crbug.com/837832 is fixed.

Change-Id: Ic3e917161cedfa773c0a18b4a5d7b1254c6f1313
2018-05-02 23:21:17 +00:00
KongQun Yang b6f0da246f Add support for FLAC codec
Implemented according to spec:
  https://github.com/xiph/flac/blob/master/doc/isoflac.txt

Closes #345.

Change-Id: If2e277d8eac4baff5965faa0e13c44c334f6184d
2018-05-02 00:16:51 +00:00
Aaron Vaage cb2ec22a06 Set Text Time Scale In Tests
Problem: The time scale for text was being set to zero in our tests
         because it was never needed.

Change: This changes it to use MS as that is what's most common and
        requires the least amount of changes.

Change-Id: Ia046ac1994b4cede079d2f801275c7f058d5bdd3
2018-05-01 22:43:13 +00:00
Haoming Chen dddbb19701 Rename Playready to PlayReady.
Change-Id: I11e0b0a0cc32aec574804e7cb02291dc3174357c
2018-04-26 11:38:31 -07:00
Haoming Chen aa4b573342 Implement multi DRM support. (Part 3)
- Allow including Widevine and Common SystemID PSSH boxes
  for PlayReadyKeySource.
- --playready_key_id and --playready_key flags are deprecated.
- --enable_raw_key_encryption already supports playready PSSH generation.

Addresses issue #245

Change-Id: I072d4f43a3239875959e4c5b1eb6854415d7367e
2018-04-26 18:14:22 +00:00
Aaron Vaage 2563ae7fe9 Add Missing Header Guards To Cue Aligner
Change-Id: I0f9e892172932dc560101865df6539736388721a
2018-04-26 17:51:02 +00:00
Aaron Vaage 56c2f227ff Skip Style and Region Blocks
To ensure that we can parse content with style and region blocks,
this change updates the parser to skip those blocks so that we
can still parse the cues from a file.

Full style and region support will be added later this year.

Issue #380

Change-Id: I11b8fd862a108c27a5c67b15d4703532b44a1214
2018-04-25 20:41:10 +00:00
KongQun Yang b2932d5a33 Fix bitrate for DASH on-demand profile too
Removed the logic in MuxerListener to estimate bandwidth from file
size and duration, since it is not compliant to the spec.

MpdBuilder will estimate bandwidth from segment size and duration
if bandwidth is not specified in MediaInfo.

Here is the statement from DASH spec (23009-1:2014):

Consider a hypothetical constant bitrate channel of
bandwidth with the value of this attribute in bits per second
(bps). Then, if the Representation is continuously delivered
at this bitrate, starting at any SAP that is indicated either by
@startwithsap or by any Segment Index box, a client can
be assured of having enough data for continuous playout
providing playout begins after @minbuffertime *
@bandwidth bits have been received (i.e. at time
@minbuffertime after the first bit is received).
For dependent Representations this value specifies the
bandwidth according to the above definition for the
aggregation of this Representation and all complementary
Representations.

Fixes #376.

Change-Id: I0fddce39e709d0cded0a4c9ae59adbbcc97ec5ea
2018-04-24 23:25:02 +00:00
KongQun Yang 60d7a4b2d5 Make MediaPlaylist accept HlsParams as contructor param
And for HlsNotifier and SimpleHlsNotifier as well.

This will make it easier to add preserve_segments_outside_live_window
param in a later CL.

Change-Id: I86d464fe247e04574158a0a76e39d8a122960ae4
2018-04-23 18:29:38 -07:00
KongQun Yang 64c2ad7d6e Support removing segments outside of live window in DASH
Issue: #223

Change-Id: Ie2d98a8f1553862532f1bdd074ca022d8904f0ea
2018-04-13 14:15:58 -07:00
KongQun Yang b6e1e5ee8b Set Widevine key request content-type to JSON
Content-Type for Widevine key request was incorrectly set to text/xml,
but it should be application/json.

Also added VLOGS for curl calls.

Fixes #372.

Change-Id: I4230795a582112c6d9c12883b5e61481b63284aa
2018-04-13 21:13:32 +00:00
KongQun Yang 772aa7c93f Do not force earliest_presentation_time to 0 for VOD
Instead, the actual earliest presentation time is used except for
the first segment if there is an offset between presentation time
(pts) and decoding time (dts).

Chrome (as of v66) reports dts instead of pts in buffered ranges in
MSE API. To avoid breaking Chrome, the earliest_presentation_time
of the first segment is set to its dts as Chrome does not like negative
values for
  adjusted dts = dts + Period@start (0 for the first period)
                 - presentationTimeOffset (earliest_presentation_time).

Fixes #303.

Change-Id: I5ca80e05d5570961400499436f2bcc01f06e69e0
2018-04-09 18:39:15 +00:00
Aaron Vaage 061777db9b Add CueEvent Support To WebVtt Output
The WebVtt Output Handler did not recognize cue events. This change
allows the handler to accept the events and tell muxer listener
about them.

Issue #362

Change-Id: I7c3318b72e539adc19af587c8e213fdb0af8290b
2018-04-07 02:45:52 +00:00
KongQun Yang ad75b9bd42 LOG an error on unsupported streams
So user knows where the problems, e.g. in #349.

Change-Id: Ie5310345d2f2c8cd83f2b6c7f96d49da94a78f4d
2018-04-06 21:45:45 +00:00
Aaron Vaage d5e820c744 Fix Spelling Mistake in Cue Alignment Handler
"bufferring" -> "buffering"

Change-Id: Ib516460295a52f0e5aa09583432868cf0efb3fe3
2018-04-06 13:16:55 -07:00