Commit Graph

909 Commits

Author SHA1 Message Date
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
sr90 1ca873f453
[DASH] Support signalling of last segment number (#713)
Per https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf 4.4.3.6 Signalling the last segment number in Period, there are three ways to signal the last segment number:

  a. Use the lmsg signalling as defined in clause 4.4.3.5.
  b. Use the Segment Timeline with @r value greater or equal to 0.
  c. Add a Supplemental Descriptor with @schemeIdUri set to http://dashif.org/guidelines/last-segment-number with the @value set to the last segment number.

We do not support (a). This change adds support for (c) when Segment Timeline (b) is not used, i.e. when Representation has constant duration (could be approximate).

Under flag --dash_add_last_segment_number_when_needed (disabled by default).
2020-02-24 23:12:53 -08: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
Daniel Cantarín 7aab7a8b50
Add --hls_media_sequence_number to support custom value in HLS
HLS uses the EXT-X-MEDIA-SEQUENCE tag at the start of a live playlist in
order to specify the first segment sequence number. This is because any
live playlist have a limited number of segments, and they also keep
updating with new segments while removing old ones. When a player refreshes
the playlist, this information is important for keeping track of segments
positions.

When the packager starts, it naturally starts this count from zero. However,
there are many situations where the packager may be restarted, without this
meaning starting this value from zero (but continuing a previous sequence).
The most common situations are problems in the encoder feeding the packager.

With those cases in mind, this parameter allows to set the initial
EXT-X-MEDIA-SEQUENCE value. This way, it's possible to continue the sequence
number from previous packager run.

Closes #691.
2020-01-31 10:25:19 -08:00
KongQun Yang ff5f3f3abc Call WSAStartup once for every new socket
Some users are seeing problems with only one WSAStartup call.

WSAStartup can be called more than once:
https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsastartup

Fixes #643.

Change-Id: I81e0e7979d6a586da452984a96a8557b7b3ce7f6
2019-11-20 14:00:51 -08:00
Tomohiro IKEDA 0b53b40428 Change --generate_static_mpd to --generate_static_live_mpd (#672) 2019-11-15 11:53:47 -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 1bcaf0a835 Add an end to end test for non square pixels
Issue #663.

Change-Id: Iaba52f0fc6c97d413e973f9a3d8c74cf8c83aa03
2019-10-23 18:41:18 +00: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 c80f053ba2 Roll boringssl/src fc9c67599..76918d016
Also roll_boringssl.py script is also adjusted to work with latest
boringssl.

Disable ASM compilation on Windows x64 which fails to compile. It also
means there are no HW AES on Windows x64.

Issue #198.

Change-Id: Ib7e8ff506f014c8c733f1882eeeddbe34fa28511
2019-10-23 04:32:33 +00: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 4f14a6f973 [HLS] Always set FRAME-RATE attribute
Although FRAME-RATE is optional per HLS specification, but per HLS
Authoring Specification for Apple Devices (https://apple.co/30n90DC):
  Each EXT-X-STREAM-INF tag MUST have a FRAME-RATE attribute.

Also, iOS and TVos refuse to play the content if VIDEO-RANGE is
present but FRAME-RATE is missing.

Issue #632, #634.

Change-Id: Ica282f023a7e8538f7b506094e2286840cf5c193
2019-10-09 21:20:32 +00:00
KongQun Yang b70da0ed93 Add --quiet to suppress LOG(INFO) outputs
Closes #661.

Change-Id: Ic75479fba4f8dc26146b42b85ab95af6151302b6
2019-10-08 10:20:51 -07:00
KongQun Yang ab8fa87d18 [HLS] Always signal Dolby Vision as PQ
Issue #341.

Change-Id: I9665ba032b1e069500d866281cb8569ce59876f9
2019-10-04 16:19:07 -07: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
KongQun Yang 3ec2975e36 Log socket error code on failure
Issue #643.

Change-Id: I8adfb9910e1e43294738abb7783a64645a4f42c3
2019-09-10 21:44:28 +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 9029e2d34f [HLS] Fix live chunks not deleted with $Time$ in segment template
Store and use the segment start time in the original time scale to
delete old segments, instead of storing it in seconds, as the segment
file name is generated using the time with the time scale.

Fixes #625.

Change-Id: I7524d597b1ffc081dd1399d6fb3ea47c13502881
2019-08-20 17:43:46 +00: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
Tomohiro IKEDA f810fea0ef Cleanup condition on `bind` error (#624) 2019-08-01 17:32:28 -07: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
Tomohiro IKEDA 2c51dcc601 Code cleanup: no "if return else return" (#611)
- Unify code format
- Low nest level
2019-07-15 11:03:42 -07:00
KongQun Yang 3c26dfbd53 Estimate target duration in bandwidth calculation from initial blocks
We used to use the target segment duration provided by the user.
Unfortunately that does not work for iframe only playlist which
the target duration is effectively equal to the GOP duration.

In the new approach, we estimate the target duration from the initial
few blocks (10 blocks right now).

Fixes #610.

Change-Id: Ie8bf943e157149ca7ed3b9382fe0a1088d0774e2
2019-07-11 17:45:55 -07:00
KongQun Yang 15a4f0553c Add a new utility function for XmlNode
Add AddDescriptor function to add new descriptor nodes with schemeIdUri
and value fields.

Change-Id: I423e642939fdef99764a67da74d4efd4d32aefe8
2019-07-01 20:29:11 +00: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 0a2b43939c [HLS] Replace hev1 in codec with hvc1 and avc3 with avc1
And also dvhe with dvh1.

Apple's specification does not recommend video formats with the
parameter sets stored in the samples.

It also fails mediastreamvalidator checks and some Apple devices /
platforms refused to play.

See https://apple.co/30n90DC 1.10.

Replaced with the corresponding formats with the parameter sets stored
in the sample descriptions instead.

Fixes #587.

Change-Id: Ic5d3f6fde115b1d09d1dcac32cef5fe0ad246aa0
2019-05-22 13:17:27 -07:00
KongQun Yang adc3c804a9 Support absolute file path in playlist_name
Fixes #585.

Change-Id: Icd0bc97a0b210c22a2dab716542d993a69d3d081
2019-05-13 18:13:37 -07:00
KongQun Yang ac616f36e4 SimpleHlsNotifierTest: Use value parameterized tests for rebase tests
Change-Id: Ie734624f6335b01b9bf989e1432ddb4fdf2e4b8b
2019-05-07 23:55:23 +00:00
KongQun Yang 4b8e9a662f Fix problems that target duration is not set in mpd/hls params
We have logics in bandwidth calculation to ignore segments that is
smaller than half of target duration. The logic does not have any
effect right now as the target duration in mpd/hls params is always
zero.

This change will set target duration in mpd/hls params, thus it can fix
part of issue #581 as the last segment which is less than half of
target duration.

Issue #581.
Fixes #498.

Change-Id: Ieb2dbf4da9fc72a7b9de802cda4294f1954d29b4
2019-04-30 22:41:14 +00:00
KongQun Yang b85e5c9368 Use segment duration in buffer depth calculation
Segment start,end time was used previously, which could result in
problems if there are discontinuity in the streams. E.g. if the
stream has timestamp, 10000, 10001, 10002 and then next segment
comes in with timestamp 1. With the previous logic, all the segments
would remain in the time shift buffer until after 10000 segments
even with a small time shift buffer depth of 10.

This could also happen when timestamp wraps around, which could
happen during long time of live streaming.

This change will also be useful to support multi-period live DASH.

Fixes #563.

Change-Id: Ie078d76c6e4af13ade9ad46191c8e3529069ed4d
2019-04-17 22:47:10 +00: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
KongQun Yang 57046be126 Make packager_test.py work with python 3.5
Addresses binary/str conversion problems like
'can't use a string pattern on a bytes-like object'.

With this change, packager_test.py will work with any version of python
after python2.5.

Fixes #553.

Change-Id: I02066942e4bcdddc1db1daf761abab4cc46169a9
2019-02-13 19:07:56 +00:00
KongQun Yang de534f8550 Make packager_test.py work with python 3.0
Use logging instead of print.

Fixes #553.

Change-Id: I46b9a5bb9bb5d4cb03ddd94163905aebc4b4e9dd
2019-02-01 22:52:59 +00:00
KongQun Yang 72c4797a59 Update pssh-box.py to remove external dependencies
With the update, the script needs to be launched from
out/{Debug,Release} directory.

Also updated docs to make it clear how to use the tool.

Fixes #538.

Change-Id: I37b71afc33e3b73ff5232e43d79c52ffa5859d57
2019-01-31 00:49:12 +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 6d6db76c80 Retry file deletion if it fails
The file deletion could fail if it is still held by the web server.

This CL adds retry logic to retry the deletion.

Closes #533.

Change-Id: Ib42ed8db11f32897a29e3b58c1be89d05f5dd034
2019-01-02 15:23:27 -08:00