Commit Graph

472 Commits

Author SHA1 Message Date
Rintaro Kuroiwa 593f513c83 Fix windows build
Change-Id: Ie23ebd9f18bf2151e52550bff62e2b043ac65ac2
2017-02-14 11:21:52 -08:00
Rintaro Kuroiwa 1879bca4bb Fragmenter for WebVTT
- Logic for splitting up WebVTT cues into MP4 samples.
- For any cue intervals that overlap, a new sample must be created.

Change-Id: Icf7478f42d8c5790bf6f404d512c1251dd34c405
2017-02-13 13:33:36 -08:00
Kongqun Yang 50787c605d Fix build break in win64
Also updated appveyor to build x64 first.

Change-Id: I1970e39bad559b3105ea31fb82375406d95f4a8b
2017-02-10 22:57:35 -08:00
Kongqun Yang 5f6e4a1dc1 Using std::shared_ptr instead of std::unique_ptr in stream data entry
Change-Id: Ib8c6f97c2329ba5b9431c301d85c1d61f89fc3d8
2017-02-11 02:41:49 +00:00
Kongqun Yang 9990524f98 Implement ChunkingHandler
This handler is a multi-in multi-out handler. If more than one input is
provided, there should be one and only one video stream; also, all inputs
should come from the same thread and are synchronized.
There can be multiple chunking handler running in different threads or even
different processes, we use the "consistent chunking algorithm" to make sure
the chunks in different streams are aligned without explicit communcating
with each other - which is not efficient and often difficult.

Consistent Chunking Algorithm:
 1. Find the consistent chunkable boundary
 Let the timestamps for video frames be (t1, t2, t3, ...). Then a
 consistent chunkable boundary is simply the first chunkable boundary after
 (tk / N) != (tk-1 / N), where '/' denotes integer division, and N is the
 intended chunk duration.
 2. Chunk only at the consistent chunkable boundary

This algorithm will make sure the chunks from different video streams are
aligned if they have aligned GoPs. However, this algorithm will only work
for video streams. To be able to chunk non video streams at similar
positions as video streams, ChunkingHandler is designed to accept one video
input and multiple non video inputs, the non video inputs are chunked when
the video input is chunked. If the inputs are synchronized - which is true
if the inputs come from the same demuxer, the video and non video chunks
are aligned.

Change-Id: Id3bad51ab14f311efdb8713b6cd36d36cf9e4639
2017-02-11 02:41:34 +00:00
Kongqun Yang 7a90ee70ab Implement EncryptionHandler
Change-Id: Iabedf3b02057d6124d5393ae9618490e5595ad89
2017-02-11 01:21:28 +00:00
Kongqun Yang 6235352bf4 Fix mpd duration not set in static live manifest
Closes #201

Change-Id: Ie9ab58ec58e1b135931a6576fb46145454b0f049
2017-02-11 00:52:32 +00:00
Kongqun Yang d592217761 Add a warning message when seeing unsupported stream type
Issue #202

Change-Id: If16fe7ccec5dfd869070dfbbb711240a89b2295b
2017-02-09 12:38:49 -08:00
Kongqun Yang bee59bc2fc Enable generate_dash_if_iop_compliant_mpd by default
This will move ContentProtection element from Representation
to AdaptationSet.

Shaka Player already supports AdaptationSet switching
urn:mpeg:dash:adaptation-set-switching:2016;

ExoPlayer does not support it yet. Filed
https://github.com/google/ExoPlayer/issues/2431 to track the issue.

(ExoPlayer does not like having ContentProtection in Representation
anyway)

Closes b/34691105

Change-Id: I69d0a4d0e15a912a35c8b2686620419a28e4cc99
2017-02-09 11:12:21 -08:00
Kongqun Yang 64c6821dc8 MediaHandler implementation
MediaHandler is the basic processing unit in shaka-packager 2.0.

Change-Id: I5f8d744e39adfff5cfebe0c50a29ead4d717cca4
2017-01-26 03:34:18 +00:00
Kongqun Yang 97fbaaa567 Replace scoped_refptr with std::shared_ptr
Change-Id: Ie8ea66e78c42c7387a97bb1abc331c636be11aa4
2017-01-26 02:20:47 +00:00
Yohann Connell 24b0e3031a Adding PlayReady support to Shaka packager
PlayReady Header Object Spec (PSSH Data VOD)
http://download.microsoft.com/download/2/3/8/238F67D9-1B8B-48D3-AB83-9C00112268B2/PlayReady%20Header%20Object%202015-08-13-FINAL-CL.PDF

PlayReady Live Streaming Spec (Consult Appendix for package acquisition information)
http://download.microsoft.com/download/2/D/D/2DD6B4E8-CABF-4DE9-8F61-895BE8F1ED33/ProtectingLiveTVServicesWithPlayReady_March2015.pdf

Issue #128
Change-Id: Ic5c0d6c642ceba3bdf9e8e413934f0fbcba242e6
2017-01-24 13:36:47 -08:00
Kongqun Yang 80c54a533a Update cmd flags to support static mpd with live profile
- Deprecated command line flags --profile and --single_segment.
  'segment_template' in stream descriptors implies live profile
  and non-single segment.
- Added flag --generate_static_mpd_for_live_profile to generate
  static mpd for live profile; if not set, dynamic mpd will be
  generated.

Close #142

Change-Id: I78879297ed118f0f246c4753a16ad125bd6b5e4f
2017-01-13 20:00:10 +00:00
Kongqun Yang 5aaae303e8 Part one of supporting live profile with static mpd
- Added two new fields in MpdOptions: dash_profile and mpd_type
- Updated MpdBuilder to support LiveProfile with static mpd
- Command line arguments will be updated in the next CL

Issue #142

Change-Id: Ibd35e5c9e1b1ef98043392e3f04a0af4700135c1
2017-01-13 19:59:49 +00:00
Chun-da Chen ce23fbacc4 Add support for udp_file in Windows. (#185)
Add support for udp_file in Windows
2017-01-10 10:05:28 -08:00
Haoming Chen 15dacf6288 Fix signed/unsigned mismatch on Windows.
Issue #168
2017-01-06 17:29:53 -08:00
Haoming Chen 93fe5457bf Fix x64 build on Windows.
- Fix integer conversion warnings.
- Fix #168.

Change-Id: Ie9aadea86a293b49e0854d6549800083143c79df
2017-01-05 14:19:35 -08:00
Rintaro Kuroiwa 655fe7b699 Add gitignores for msvs files
- Add MSVS related patterns to gitignore.
- Removed encryption_modes.h from media_base.gyp. It doesn't exist.

Change-Id: I44bc86ff7e79daf6f7bc61c21a558937530d8e66
2016-12-19 21:26:26 +00:00
Kongqun Yang af0904e428 Fix AdaptationSet switching signaling
Current mechanism of using AdaptationSet @group is not spec compliant.

The spec compliant mechanism is to use supplemental descriptor with
schemeIdUri: urn:mpeg:dash:adaptation-set-switching:2016 as specified
in ISO/IEC 23009-1:2014/Amd.4:2016.

Fixes #156

Change-Id: I4d97648547a23315ba9c09dcadb14e18c99a45fc
2016-12-19 20:12:27 +00:00
Rintaro Kuroiwa 7a4a40acb8 Change values for slice header attributes
- nalu_data points to the beginning of the nalu, instead of
  beginning of the slice header which excluded the nalu
  header.
- nalu_size is the size of the whole nalu.
- header_bit_size calculation is corrected. The size used to exclude
  emulation prevention bytes.

Change-Id: Ic00f42caeddf7b4701f3948e6ef8a3537fd7f770
2016-12-15 17:07:17 -08:00
Kyle Alexander 0c2ee4c844 Add support for 4K and 8K content.
Adds UHD1 and UHD2 track types to support 4K and 8K content.

Bug: Closes #163
Change-Id: I8fd893725cae88e9944244a48607cbaab591b401
2016-12-13 19:24:22 +00:00
Kongqun Yang d8d94da250 Fix packager_test break in Windows
Change-Id: Id43e4bd0e2067fd9ad74f8c5c60df7ddba75e840
2016-12-09 19:11:04 -08:00
Kongqun Yang c8ffa54d35 Fix --version in drive programs
Fixes #176

Change-Id: Ib092f81e1af49dfee43f7b01c0008a1b40c9098b
2016-12-08 14:45:05 -08:00
Kongqun Yang eab7910029 Fix crash when seeing unsupported es descriptor data
Addresses #175

Change-Id: Ia9c2f0c7a8c17a6614db0fe478892bd3c5efd5b0
2016-11-29 23:27:22 +00:00
Haoming Chen 9ed8303a06 Use Windows native ssl instead of openssl.
Fixes #147

Change-Id: I41193adbab5cd979ca958131cd4f148dde5e1f2e
2016-11-09 14:08:52 -08:00
Rintaro Kuroiwa e7c0dbf09d Ensure some method calls NotifyEncryptionStart()
- If OnEncryptionStart() is called OnMediaStart(), someone should be
  calling NotifyEncrytionStart().

Fixes #169

Change-Id: I597f317d2ddeb3091b7e9d238eb9695b4cc9c69d
2016-11-08 15:56:28 -08:00
Kongqun Yang 458fadc6a8 Add udp options support
Three options are supported right now:
- reuse=1|0
  Allow or disallow reusing UDP sockets. Default 0.
- interface=a.b.c.d
  Address of the interface over which to receive UDP multicast
  streams.
- timeout=microseconds
  Timeout in microseconds. Default to unlimited.

A UDP url should be of the form udp://ip:port[?options], here
is an example:
  udp://224.1.2.30:88?reuse=1&interface=10.11.12.13&timeout=12345

Also deprecate --udp_interface_address flag in favor udp options.

Closes #133

Change-Id: I962d35bfedc1779d67ba20ed910207c66b7c1a15
2016-10-31 18:40:40 +00:00
Kongqun Yang 4c6e5f4fa6 Improve support for decryption of full sample encrypted cbcs
1. Allow encryption pattern of 0:0, which is treated as 1:0;
2. Remove the special handling of pattern 1:0 in pattern cryptor
   which may not always be correct;
3. Allow senc/saio/saiz boxes to be absent.

Change-Id: I372e61182ec577107e39cb601c3aed80616b036d
2016-10-14 00:07:46 +00:00
Kongqun Yang e7393fcc22 Fix build break in Windows
Change-Id: I49815abdaa360e11e62a3193bc58d4d7d77fc8a8
2016-10-13 15:54:32 -07:00
Kongqun Yang 6dbcf27f82 [WebM] Use system temp directory if temp_dir is not specified
The original code creates temporary file in the current directory,
which may not always be writable.

Change-Id: Icc278dd5db6be6206ae29defbb7423bae39cc978
2016-10-13 21:48:00 +00:00
Kongqun Yang 472fae24f2 [pssh] Support widevine pssh generation with protection_scheme
- Also import the version of the protobuf bundled in packager first,
  this avoids importing the installed version of the protobuf, which
  may not be compatible with this script.
- Print help if no argument is supplied.

Fixes #162

Change-Id: I1b5e87ba7fb51e81b0d4dd3791aaeb37ee0fd6ce
2016-10-10 10:39:41 -07:00
sammirata 4f9bbe3769 Do not require exclusive bind of udp sockets (#154) 2016-10-04 15:51:45 -07:00
Kongqun Yang 97fc9828f0 [WebM] Move index segment after init segment
Cues used to be generated in the end of the file; if http range
request is not supported, clients have to download the whole
file to get to the cues.

This CL updated TwoPassSingleSegmentSegmenter to write cues
after writing webm header.

This CL also updates libwebm dependency to latest.

Closes #159

Change-Id: Ic73548e1b872e6b13a37627707e7d0ff3e556877
2016-10-01 00:34:56 +00:00
Kongqun Yang ac1d2692cf [WebM] Fix corner case segment generation problem
The original code accumulates sample durations in seconds (double)
and then generates new segment / cluster by comparing the accumulated
value with configured value.

There may be loss of precision when accumulating values in double.
For example, with a GOP of 96 frames and frame rate of 24 fps; the
accumulated frame duration for 96 frames is 3.999999999999, which is
very close to 4.0 but not 4.0. Problem would arise if segment
duration is set to 4. The created segments would have a duration of
8 seconds instead of 4 seconds.

The new code accumulates sample durations in uint64_t relative to
input time scale; the configured segment duration will be converted to
timescale for comparison. This avoids loss of precision.

Change-Id: I3ae24be82a7ce45f923a6f90fea495b8b6b2e7ef
2016-09-30 21:45:27 +00:00
Kongqun Yang f5dc908a0d Implement utility function DoubleToString
Implement our own DoubleToString as base::DoubleToString uses
third_party library dmg_fp.

Change-Id: I0d3d706cfd3de4f833b201110954419e585a21dd
2016-09-30 21:36:11 +00:00
Joey Parrish cda495fb57 Add default_language flag
Setting this flag will tag any matching tracks with kRoleMain.
The player will then know which tracks should be default when there
is not a language match.

Closes #155

Change-Id: I827304c49e345d07b1e76f7a46421b60f228f0ba
2016-09-29 22:59:34 +00:00
Joey Parrish 07c4b4f3bd Drop the DCHECK for language size 3
Language tags can have subtags, such as "por-BR".  While the base tag
should be 3 characters, the entire tag can be longer.  Rather than
parse out the base tag and check that it is size 3 without the subtag,
we can just trust the ISO tag converter to do the right thing.

Change-Id: I2a186b5c8db0f373ee82ef68245ecc33cb068581
2016-09-29 16:37:16 +00:00
Joey Parrish 275e60e5a9 Detect .webvtt as WebVTT files
Some subtitle files use .webvtt instead of .vtt, probably because
ffmpeg uses -f webvtt when converting from some other format.

Change-Id: If88e8d2b90e5dea6751409568d5191e923dec4aa
2016-09-28 15:02:27 -07:00
Kongqun Yang 5edd290694 Fix WebM not encrypted when clear lead is set to 0
- Also regenerated test content to insert an iframe every one
  second: ffmpeg -i source.webm -auto-alt-ref 1 -g 30 out.webm
  This makes sure the content is actually encrypted with one
  second clear lead in end to end test.

Change-Id: I488143c148e2d6c45ba1586f6d0d835dc46db86e
2016-09-28 18:17:09 +00:00
Kongqun Yang 47363dd06a Remove unused vorbis test files
Change-Id: Ifede6faac7e17dcd60d36c1e9e7c9a025f95fbdf
2016-09-13 22:06:38 +00:00
Haoming Chen 03d7a81c83 Fix a precision conversion problem.
- This causes a compilation error on Windows.

Change-Id: I53c03841565be00ebaa3acbfe621bb145f8f1ca2
2016-09-12 08:46:16 -07:00
Haoming Chen 28828b8a15 Add encryption information in demuxer.
- Add decrypt_config in media sample and stream.
  - Update subsamples when converting NAL unit to bytestream.

Change-Id: I7b8975a453f81b22cf74bee3c9a58b7e458cbaae
2016-09-08 17:13:36 +00:00
Kongqun Yang 90e3ec3f9a Some misc cleanup
- Replace DCHECK_EQ with DCHECK for compatiblity
- Add ASSERT_FILE_CONTAINS
- Remove unnecessary release on unique_ptrs

Change-Id: I2ec22c52e47cb451479ae9a59818b9df20f62e63
2016-09-07 10:15:50 -07:00
Kongqun Yang c3d1dc1733 Deprecate STLDeleter and string_as_array
1. Replace STLDeleter with unique_ptr in container, which is
   supported in C++11
2. Replace string_as_array with &string[0] which is guaranteed
   to work in C++11

Change-Id: I7f39c0e51fc8a3fcbb41313094a0ca6b33db7bf3
2016-09-01 17:39:11 +00:00
Kongqun Yang ba2a649c00 LOG_TO_SYSTEM_DEBUG_LOG instead of a file
The current behavior of logging to a file in the same directory
as the binary will break if the binary does not have write access
to that directory.

Fixes Issue #139

Change-Id: I11adfaec676fc9bbef2a5caa3261889d1fba3b88
2016-08-31 14:50:23 -07:00
Kongqun Yang 09891dcd9e Fix access unit detection problem for H264
In H264, there may be multiple consecutive video slice NAL units
in the same frame. The original code assigns a new access unit
for every video slice NAL unit, which is incorrect.

Fixes #134.

Change-Id: I4d44271df48cb08867ddd02f7494fb3573af3356
2016-08-29 11:19:52 -07:00
Kongqun Yang 52cbcb321d Add appveyor config for Windows CI
Also fixes additional Windows build failures.

Closes #22

Change-Id: I8bc416f1a44810c438f095ec137d0d102f4e08a5
2016-08-23 12:24:34 -07:00
Kongqun Yang de9667080f Do not partially encrypt a segment
Mimic iso-bmff behavior: either all the samples in a segment are encrypted
or all the samples are clear.

Change-Id: I03bdbbf5a4b690f4d87c4dceb0f8155e6fae941e
2016-08-19 14:22:40 -07:00
Kongqun Yang 23f2913248 Update DEPS to fix mac build failure
Change-Id: I1cf95d5da8e3b950300cd61cd9286e957ef653ce
2016-08-19 13:49:41 -07:00
Kongqun Yang 644629c616 Replace scoped_ptr with std::unique_ptr
Change-Id: I1ed18bf876b6154d08a1f7913aa7e76c525451f9
2016-08-18 17:12:36 -07:00
Kongqun Yang d501b457d0 Fix WebM keyframe detection in BlockGroup
The right way to detect the presence of a keyframe in a BlockGroup
is to look for the absence of the ReferenceBlock element [1].

Closes b/30433206

[1] https://matroska.org/technical/specs/index.html#ReferenceBlock

Change-Id: I2b3c8704cbabcd5cbee38448e5528425865561a4
2016-08-18 23:20:40 +00:00
Thomas Inskip db92c9a22b Implemented WebM VP9 subsample encryption and decryption.
Change-Id: I98f02c05ec8bcc976e01ff41478e92b8809c0076
2016-08-18 13:55:36 -07:00
Thomas Inskip 336ea5cb34 Windows build working
Change-Id: I6d9cfa0a310c4c6125c839e4d6a085903e981c9c
2016-08-18 08:30:26 -07:00
Thomas Inskip 224747db0b libcurl build for Windows
Change-Id: Ie14613d36509b3f45220092c5c196b14fd4b0a10
2016-08-03 16:05:40 -07:00
Thomas Inskip d059b27a69 Updated third_party/gflags.
WebRTC portion (gyp build) now checked in because separate repository is no longer available due to transition to git.

Change-Id: I56436cbbc3f02a5f77112917d6229aea69f21d97
2016-08-03 07:52:16 -07:00
Thomas Inskip f169bccdc9 Updated libxml.
Change-Id: I4f2315f10227e6b8c2545b81ea1adcf388c37cee
2016-08-02 19:11:17 -07:00
Thomas Inskip 1fbc410489 Updated protobuf library.
Change-Id: I09705df523ba4d0954925845a1619b25d70fd90f
2016-08-02 19:11:17 -07:00
Kongqun Yang 16d8583735 Update boringssl and curl(v7.50.0)
Change-Id: I89b40cf03d1aab9a13b0df449e540ab73d03451e
2016-08-02 12:00:19 -07:00
Gabe Kopley 081b6994d6 Fix broken link to "cenc" Init Data Format spec 2016-07-26 14:52:08 -07:00
Kongqun Yang 01e53ee946 [pssh script] Fix invalid hex_16_bytes error on lower case input
Change-Id: I274634f9076500156527c04bc9cbb9f86da3c6bd
2016-07-25 17:58:03 -07:00
Kongqun Yang ad95b9d8de Fix text formats not recognized problem
Also updated packager_test not to fill in output_format by default,
which will help catch these kinds of bugs.

Closes #130

Change-Id: I77157317de822d3f543f7e27d94bb4df7a1649d2
2016-07-22 20:51:16 +00:00
Kongqun Yang 2cdd54b6f7 Remove restriction on sample duration to be 0 for mp4
0 sample duration is seen occasionally in the contents in the wild.

Closes #127

Change-Id: I48b9fac4add79f39a83fc571502bedb9f0be71df
2016-07-19 18:56:45 +00:00
Kongqun Yang fae7874c4c Add a runtime flag to use dts in timeline for mp4
This flag is needed to workaround the Chromium bug
https://crbug.com/398130, which uses decoding timestamp
in buffered range.

Closes #113

Change-Id: Ib8f18be7165dd968bdc36c18ce29f694235c0c26
2016-07-19 18:56:08 +00:00
Kongqun Yang a80995538d Remove restriction on sps:gaps_in_frame_num_value_allowed_flag
Packager should not care about this flag, whether it is supported
is up to the decoder.

Closes #126

Change-Id: I5e05d291eab01375f7f11c951b9dc93c1358c38a
2016-07-18 20:25:40 +00:00
Kongqun Yang cf778f7149 Update CHANGELOG for v1.5.0
- Also updated a few wording in README and in the code.

Change-Id: I9adf297c00aee92e61e87effa3bdcfaf402638e5
2016-07-12 12:25:48 -07:00
Kongqun Yang f3d35b730c Add version information to generated HLS manifests
- Also refactor the existing version code.

Change-Id: Ib409630c4f87965a37b1d6a1bcec68178a704ce6
2016-07-11 23:26:36 +00:00
Rintaro Kuroiwa db70721e35 Fix HLS packaging failure with clear lead = 0
- Add MuxerListener::OnEncryptionStart() for notifying that further
  segments are encrypted.

b/29621230

Change-Id: I881b29d55baaf3d04e005a3b95d898071c3f272b
2016-07-11 20:43:01 +00:00
Kongqun Yang e0c5874d31 Update encrypted testing content to use common system id
- Also fix a bug in fixed key rotation with empty pssh_data.

Change-Id: I1110b839fc821c5c4778854c0b29032d3ee2d384
2016-07-11 20:10:31 +00:00
Kongqun Yang ad3c1768bb Fix dependency in hls.gyp
Seeing occasional build breaks when building hls_builder, e.g.
https://travis-ci.org/google/shaka-packager/jobs/143445907
Although hls_builder is dependent on widevine_pssh_data_proto
indirectly (through media_base), it does not work all the time.
Looks like the proto has to be a direct dependency.

Change-Id: Id4d9d0b9e669df0967cc767132ef29717243a722
2016-07-08 14:48:47 -07:00
Kongqun Yang 5f0d138ec9 Adjust hls descriptor validation
- Try to determine container name from segment_template if output is
  not specified
- segment_template descriptor is required for TS
- output descriptor should not be specified for TS
- Generate hls_playlist_name from stream number if not specified
- Update packager_test.py to include playlist validation

b/29551186

Change-Id: Ide7169f1c26c85a6e38272dda0e1af77135b4d90
2016-07-01 14:14:24 -07:00
Rintaro Kuroiwa 1095b73a44 Fix TS and Media Playlist with clear lead
- Cannot include PMT for following encrypted segments in the clear lead.
  Some players consider them as conflicting codecs.
- Add EXT-X-DISCONTINUITY in front of first EXT-X-KEY to notify that the
  codec is switching from e.g. "avc1" to "zavc".

b/29621230

Change-Id: I45c74813630c229d66245e992eb3a5117326bb14
2016-07-01 10:43:11 -07:00
Rintaro Kuroiwa 50fe17fa9f Use max bitrate for MediaPlaylist bandwidth calculation
- HLS expects max for VOD.

Change-Id: I91e9e07a27abe7167efeefc99aaada2acbed9314
2016-06-30 21:58:33 +00:00
Jacob Trimble f9bf197f2b Fix bug in VPx codec configuration.
Before, we converted the WebM configuration to MP4 in the video
client, however this lead to a bug when fields were missing.  So
now don't convert until the cluster parser so the extra info from
the stream can be added.

This also fixes a bug where the value was not printed in the warning
logs.

b/29580732

Change-Id: If0a1a4d135f98292cdaae15a11027f42d844e85d
2016-06-30 19:51:09 +00:00
Kongqun Yang f27960e00d Add fixed key support for HLS sample-aes encryption
Change-Id: I5a18e014f697561e0741b043e91f70fe2f11d2ce
2016-06-30 19:47:00 +00:00
Rintaro Kuroiwa dad07c95d7 Set MediaPlaylist version to 5
- Required for KEYFORMAT and KEYFORAMTVERSIONS attributes.

Change-Id: I834cde6e475e4f1192db0c93c4b88e2ab838532e
2016-06-29 10:15:46 -07:00
Jacob Trimble abb1abf5c5 Rename StreamInfo::extra_data to codec_config.
Since the |extra_data| field contains codec-specific configuration
data, it makes sense to call it |codec_config|.

Change-Id: If9e35165a00fe82628cf931df397a8ef06505b0d
2016-06-27 13:16:47 -07:00
Rintaro Kuroiwa b07adaeae7 Warn user when single segment and segment template are used
Change-Id: I4b85f50aa0890fb54a642c38520225df9bdbbbef
2016-06-22 15:59:00 -07:00
Jacob Trimble 6550868574 Add codec private data to VP9 in WebM.
b/29009350

Change-Id: Iaafc87340043eff77c3ef7e1c1135d8c4c4287ae
2016-06-22 16:43:57 +00:00
Kongqun Yang 47a3fb977d Fix 'senc' bug when encrypting mp4:vp9 with superframe
Although superframe index is not encrypted, it should still be inserted
into subsamples list (with cipher_bytes as 0).

Change-Id: I06b38f8333a22a31a71cd67e0412218dd3aaa5c3
2016-06-21 17:17:49 +00:00
Kongqun Yang 0a9de96eb2 Update mp4 container check function to be more robust
Consider the file in iso-bmff format if seeing two known
mp4 boxes.

Closes Issue #110

Change-Id: Ifdc76b6c8b7e26a0988ab4f8d4968e1320cb180c
2016-06-21 17:17:03 +00:00
Rintaro Kuroiwa 60419f26d0 Add driver program flags for HLS
- Add flags and stream descriptor fields for HLS.
- Remove fields from MuxerOptions. Instead pass them directly to
  HlsNotifyMuxerListener.
- Rebase segment names to the master playlist's path where it makes
  sense.

Change-Id: If4f54bc56ff46dc6140859a79ed66f7b99112ed7
2016-06-13 18:30:24 -07:00
Rintaro Kuroiwa 565affe7fb Pass hls_name and hls_group to HlsNotifyMuxerListener constructor
- Also don't Flush the notifier OnMediaEnd().

Change-Id: I2ffbbfacda74bb88678ac4e32b1f28c3e64eb85d
2016-06-13 14:36:39 -07:00
Rintaro Kuroiwa d06a9cd17c Allow encrypted TS without clear lead
Change-Id: Icc4268af94c11b004f020cfb4dd9f5f16a9169af
2016-06-13 20:49:23 +00:00
Jacob Trimble cb3b277575 Optimize the MPEG2-TS demuxer.
Change-Id: I5836fc8503fe22a3d73241dda00c36d0ffb26e65
2016-06-08 21:43:15 +00:00
Kongqun Yang d08f6ae0cc Fix cbcs/cens behavior when applied to non video tracks
- Tracks other than video are protected using whole-block full-sample
  encryption as specified in ISO/IEC 23001-7:2016(E) 9.7, which is
  equivalent to a pattern of 1:0. This is different to the non pattern
  encryption counterparts.
- Also updated the code to allow the existence of other protection
  schemes in the original content, which will simply be ignored.
- The internal cryptor used by AesPatternCryptor should not use
  constant iv, add a DCHECK for that.
- Optimize AesPatternCryptor handling on the special pattern 1:0.

Change-Id: Idc704e7bc6b347741336f38c6d3620fc19392960
2016-06-08 17:02:26 +00:00
Kongqun Yang 84f3911985 Remove top level box check in BoxReader
Change-Id: I3d0e5865851030264d7174031a98031b413e90ce
2016-06-08 00:54:11 +00:00
Kongqun Yang bd1328500c Allow uuid to be a valid top level box
Change-Id: Iec241781321a30fa8eece6a7fc6674d78a02c90f
2016-06-08 00:53:35 +00:00
Kongqun Yang 579678d6a6 Fixed a Opus in Mp4 parsing problem
- Also added end to end test in packager_test.py

Closes Issue #83

Change-Id: I7a8e695a36e654507b75d558710db1ce8867a916
2016-06-01 23:52:33 +00:00
Kongqun Yang 32482c0bce Rename filters directory to codecs
Also move codecs related classes in mp4 to codecs directory.

Change-Id: I83db2bcf9e66b405fcceed78918b762b26cd7fce
2016-05-27 16:13:19 -07:00
Kongqun Yang 6d281c6676 Rename XxxConfiguration to XxxConfigurationRecord
These are really configuration records.

Change-Id: I0d081c2e14f19bcdf8eb52dc094a1e7c096b5f98
2016-05-27 16:11:11 -07:00
Kongqun Yang 68aa1397b0 VPCodecConfiguration box should inherit from FullBox instead of Box
Change-Id: If53c6cab009bdeadc37a1bac34272056a2b7d1dc
2016-05-25 23:59:16 +00:00
Kongqun Yang 7e533ec5ca More cleanup in proto usage
Change-Id: If35f95dbff47bc9e8c1c42cb56d75719367abfc0
2016-05-25 16:57:39 +00:00
Kongqun Yang 4f9c8ea781 Rename top level namespace to shaka
Issue #103

Change-Id: I67945c8ec6d2c178494d3b5400e5ec0170e9d115
2016-05-24 21:55:55 +00:00
Kongqun Yang 72c3a76699 Update repo url in version string
Issue #103

Change-Id: Iec7db3d155c81cf989f1078ed32692f8e037aa65
2016-05-24 21:55:45 +00:00
Kongqun Yang bbcca29013 Move all code inside top level namespace
Change-Id: I83bc081f523dbc5071796a79c2d89b7367ed8d27
2016-05-24 21:55:21 +00:00
Kongqun Yang a217cdce29 Misc cleanup in MediaInfo proto usage
- Replaces SerializeToString with SerializeAsString.
- Construct StringPiece instead of doing implicit conversion when
  doing Base64Encode.

Change-Id: I9a9d4a138b0d949447396387adc599c7cde0b9f4
2016-05-17 13:28:22 -07:00
Kongqun Yang c923cb283a Fix unittest failures in previous cl
Change-Id: Ib44a8d0a2907083281a5afdd5b5277a0a0fc35c7
2016-05-16 17:09:06 -07:00
Kongqun Yang 940cc43de2 Add support for AudioRollRecoveryEntry
This is part of the effort to support Opus in iso-bmff #83.

Changes in this CL:
- Add support for multiple SampleGroupDescription and SampleToGroup
  boxes in TrackFragment box;
- Add support for SampleGroupDescription and SampleToGroup boxes
  in SampleTable box;
- Add support for AudioRollRecoveryEntry in Sample Group and 'roll'
  sample grouping type;
- Also fix a bug that default length was not set correctly in
  SampleGroupDescription when constant iv is used.

Change-Id: I7e31386ea6cd17a8ee5e1dca4c1a90937d51368f
2016-05-16 22:25:38 +00:00
Kongqun Yang cf4a2447c1 Add support for Opus specific box in iso-bmff
This is part of the effort to support Opus in iso-bmff #83.

Change-Id: Ib3678b9cb74eac76372ed83ad48ce1f203ba0c35
2016-05-16 22:25:32 +00:00
Kongqun Yang 26cb91e29b Handle preroll and codec_delay when tranmuxing opus
Closes Issue #102

Change-Id: I26aa56a63c17c85298311cc17963dd26f26e501e
2016-05-16 14:51:51 -07:00
Rintaro Kuroiwa d4e2f3c098 hls_builder should depend on widevine_pssh_data
- There is a race condition during build. hls_builder should depend on
  widevine_pssh_data to remove the race condition.

Change-Id: If9fa8895104a774b8ecc7545a57323ae49274936
2016-05-13 11:41:07 -07:00
Rintaro Kuroiwa e422b4eb0e Handle encryption in TsSegmenter
- Move GetTrackTypeForEncryption() to muxer_util.h.

Change-Id: I315957cb8983f4e7c4acff6907dfdd6ad6907c82
2016-05-11 16:21:05 -07:00
Rintaro Kuroiwa 0ba35147c8 SAMPLE-AES encryption in PesPacketGenerator
- Allow setting a key on PesPacketGenerator.
- Add SAMPLE AES mode to AesPatternCryptor.

Change-Id: Iace2381b4cd3bbce63cd5bdb4cdf3a7cea47537a
2016-05-11 09:56:36 -07:00
Rintaro Kuroiwa 7d8322377e PMT writers for H264 and AAC
- For encrypted segments, PMT specified by SAMPLE-AES specification is
  generated.
- Remove time_scale_ field from TsWriter. It is not used.
- Move ContinuityCounter to a separate file.
- Add ProgramMapTableWriter and implementations.
- continuity_counter is incremented for PAT and PMT.

Change-Id: If0dd0990203cb6990f39a6832048bdc3ff08decd
2016-05-05 15:56:54 -07:00
Jacob Trimble 9bb6c5d8d2 Add more unit tests for EsParserH26x.
This add several unit tests for EsParserH26x to test the various
NAL unit orders and access unit contents.  Some tests are disabled
and will be fixed in another patch.

Change-Id: Id5e3291e22f1fe17ada2c03c42e2cdfe226abcb2
2016-05-05 09:41:31 -07:00
Jacob Trimble 86369efc30 Add support for H.265 in MPEG2-TS demuxer.
This also changes the H.264 parser to correctly determine access
units.

Closes #46
Issue #47

Change-Id: I69a8c47ebf4fe35cef0592997460158b3131084e
2016-05-03 15:08:04 -07:00
Kongqun Yang 2abc7c60b7 Add end to end test for transport stream
- Also replaces resolution to 640x360, to reduce file size.

Change-Id: I030ceaa0c67c2b8f060d1864e2c3150f5d28b612
2016-04-29 17:21:08 -07:00
Kongqun Yang 3ff74398df Fix two bugs in 'cbcs' and 'cens' handling and add tests
- BytesOfProtectedData in 'cens' SHALL also be 16-byte aligned
- Fix an incorrect box definition bug w.r.t to 'cbcs' and 'cens'
- Also add various protection scheme tests

Close #77
Close #78

Change-Id: I63c8d8b01ce16ed60affa97ec95fc62bc2da06df
2016-04-26 17:27:26 +00:00
Kongqun Yang 976bf69294 Add decryption verification tests
Change-Id: I735dc14c618537bc4a69fcfbe2bc634bfe2a2166
2016-04-26 17:27:13 +00:00
Kongqun Yang 855d1b028f Correctly generate ContentProtection value for non-cenc protection schemes
Change-Id: Ie5469a7f192cc6167f029befd9cca7f9ab0d1f27
2016-04-26 17:27:04 +00:00
Rintaro Kuroiwa 67e0f9f31b Pass playlist type to MediaPlaylist
- The current implementation only handles VOD.
- Add #EXT-X-PLATLIST-TYPE.
- For VOD Add #EXT-X-ENDLIST at the end.
- Append comma at the end of EXTINF.

Change-Id: I16f01da66f8bbf0229395cb380fa125ffd9328a8
2016-04-25 12:36:11 -07:00
Kongqun Yang 25305b6aa3 Clarify that WVM format always uses all zero IV
Close b/22894397

Change-Id: I9f2295130d32ea5135ef0143ec7758df1114b18d
2016-04-22 13:42:37 -07:00
Kongqun Yang 797ae3e639 Copy packager_test.py to out directory on build
- Disallow packager_test.py to be executed from source directory
- Remove the building of packager target from packager_test.py. User
  need to make sure packager builds successfully before running
  the test.
- Remove build_type parameter which is no longer needed

Change-Id: I479d3c39b8d45730e5388d194069f1320fa5cd75
2016-04-22 18:16:33 +00:00
Kongqun Yang ba42fed9e5 Suppress warning messages when determining containers
- These warning messages are not useful since the code needs to
  loop through various container types to find a matching one.

Change-Id: I1d8eca563faf24e485ac71cce32e09515c174bf2
2016-04-22 09:46:21 -07:00
Jacob Trimble a789dc6d3c Replace Nalu::InitializeFrom* with Initialize.
Replaces the InitializeFromH264 and InitializeFromH265 methods with
a single Initialize method that accepts a CodecType.  Also moves the
CodecType enum from NaluReader to Nalu.

Change-Id: Ie33aa9c0d772a7f3c6a2e9c867e25be3edfe7828
2016-04-21 13:35:49 -07:00
Kongqun Yang 77fc3f6988 Fix an unintended warning message
The warning message was included accidentally for audio encryption
during rebase.

Change-Id: I105f2f01cb9016fc6c57494708ba6d9cbb2ff53c
2016-04-21 19:11:01 +00:00
Rintaro Kuroiwa f3ed07a64e Use MuxerListener in TsMuxer
- MuxerListener is used in TsMuxer so that a listener can be used to
  e.g. generate manifests.

Change-Id: I11c745e1c2b71d5ec901387fe42713d4ad69dc03
2016-04-21 10:45:43 -07:00
KongQun Yang 13202f91b6 Fix a few problems in AesCryptor classes
- CBC cryptors should accept IV of size 8 bytes - it will be zero
  extended to 16 bytes.
- Fixed iv() not updated problem in AesPatternCryptor.
- Replace kChainAcrossCalls with ConstantIvFlag enum flags.

Change-Id: I3fb4de0e8abbe891e6271e779373ba53f8df660d
2016-04-20 14:14:04 -07:00
Rintaro Kuroiwa 66b82f87dd Add HlsNotifyMuxerListener
- A MuxerListener implementation that uses HlsNotifier.

Issue #85

Change-Id: I4c94c025be112d2bd02a78123da3f275e09c3a06
2016-04-19 18:19:11 -07:00
Rintaro Kuroiwa 102f3f7062 Scale sample duration in TsSegmenter
- Sample duration wasn't scaled in TsSegmenter to calculate the current
  segment's length. So segmenting length did not always respect
  segment_duration.

Change-Id: I1ef4747dbd12bde7852ffcbceb971f2775aa18b3
2016-04-19 23:21:16 +00:00
Jacob Trimble bbf9c6849b Parse vui_parameters in H.265.
Parsing vui_parameters in the SPS is required to be able to extract
the resolution of the video.  This also adds a method to extract
the resolution to the H.265 parser.

Issue #46

Change-Id: Idf498d2afdb36a689490151a4ae6baef0b6b73f6
2016-04-19 23:15:34 +00:00
Rintaro Kuroiwa 2756902934 Fix small bugs in HLS playlist generation
- Media Playlist that is non-VERSION 1 must have EXT-X-VERSION.
- Attribute for EXTINF should be CODECS instead of CODEC.
- BANDWIDTH attribute expects bitrate (not bytes per second).
- Removed unnecessary check if MediaInfo has media_info_name, in
  SimpleHlsNotifier::NotifyNewStream().

Change-Id: Ia63cfa59e5e2ec24bbf1b784164e6e41176fc589
2016-04-18 17:14:26 -07:00
Jacob Trimble a80e16bab0 Close files in Finalize for WebM segmenters.
Now Finalize() will close all the files used by the segmenters.  This
is important to allow WebMMuxer::FireOnMediaEndEvent to get the
correct size of the media file.

This also changes the WebM muxer to use 64-bit numbers for the init
and index ranges to correctly support >4GB files.

b/28194272

Change-Id: Ia84e4a4b0756f89644efea99a1a51968b22a1338
2016-04-18 21:28:09 +00:00
Rintaro Kuroiwa a50b5787dc Use TsMuxer in driver program
- The driver program can output ts files.

Change-Id: I190ba17ded91a0be48cc0a1a8b15e44d20800eec
2016-04-18 19:13:50 +00:00
Rintaro Kuroiwa 300c23104e MuxerOptions and MuxerListener change for HLS
- Add hls_name and hls_group_id fields to MuxerOptions. This is used to
  pass the NAME and GROUP-ID values for EXT-X-MEDIA tag to
  MuxerListener.
- Change MuxerListener::OnEncryptionInfoReady() to take an
  initialization vector.
- Change MuxerListener::OnNewSegment() to take segment name.
- Reworded and formatted MuxerListener comments to Doxygen style.

Issue #85

Change-Id: Iea06e68552a56ae180177ffd6ca315a7cf39456c
2016-04-18 11:40:10 -07:00
Rintaro Kuroiwa 16ba8da295 Map to raw pointer instead of scoped_ptr
- Fixes Mac build.
- Mapping to scoped_ptr doesn't work, instead use raw pointer and
  STLValueDeleter.

Change-Id: If17e43d9d4aba8c92a76d2b1ca99a64c6a2b0e84
2016-04-17 00:12:10 -07:00
Rintaro Kuroiwa a6646841b7 HlsNotifier and implementation
- HlsNotifier interface, similar to MpdNotifier.
- SimpleHlsNotifier class can generate playlists.
  It can also handle encrypted media with Widevine encryption.

Issue #85

Change-Id: I9305ddf42796370d3e5df360633c80997c909365
2016-04-16 16:22:35 -07:00
KongQun Yang c6445b749c Change AesCbcEncryptor/AesCbcDecryptor kNoPadding behavior
Leave unaligned residual block in clear in stead of rejecting it.

Change-Id: Id5452f32f6147e26ac68d9cddb948e8b4f77d107
2016-04-15 13:31:09 -07:00
KongQun Yang e253747453 Add support for 'cbcs' and 'cens' protection schemes
Issue #78

Change-Id: I9f71b9a92067e2f6b388092494a7d6a84986cdc0
2016-04-14 15:31:11 -07:00
KongQun Yang c8819cb257 Add mp4 box fields for pattern encryption
- crypt_byte_block and skip_byte_block for pattern-based encryption.
- constant_iv for constant iv (used by 'cbcs' protection scheme).
- Also renamed iv_size to per_sample_iv_size.
- Also changed "bool is_encrypted" to "uint8_t is_protected" to align
  with CENC spec.

Issue #78

Change-Id: I2878a91e0ebe536a08a3e3109daf157fe4440e27
2016-04-14 20:06:19 +00:00
Rintaro Kuroiwa 4391f247ac Fix CRC for PMT and PAT
- CRC for PMT and PAT should be CRC-32/MPEG2.

Change-Id: I9fafdbd6df46fc960c4f0e205f70be701bf7629f
2016-04-14 18:25:18 +00:00
Rintaro Kuroiwa 49e87a34a3 Expose memory file system prefix
- Memory file system prefix should be exposed for testing.

Change-Id: Id284d77084b98c8175cdd485480f2fc49241e137
2016-04-13 23:17:42 -07:00
Jacob Trimble 404660cbdb Add H.265 byte to unit stream converter.
Also renames NaluReader::NaluType to CodecType.

Issue #46

Change-Id: I37d21fcb1109659f14baf43308a94c5e2d9ac2d1
2016-04-13 10:21:52 -07:00
Rintaro Kuroiwa f1e4f74a14 HLS MasterPlaylist class
- Class to generate Master Playlist.
- Takes multiple Media Playlists to generate all the playlists.

Issue #85

Change-Id: I3e2be8763cc771d468245f64753e8a38b0746686
2016-04-12 23:55:21 +00:00
KongQun Yang 2ac57bf9b9 Use FOURCC as protection scheme parameter
- Remove EncryptionMode enums
- Remove AesEncryptor::InitializeWithRandomIv, replaced with
  a static function AesCryptor::GenerateRandomIv, which should
  be called to generate the iv if the iv is empty.

This change is to prepare support for CBCS and CENS pattern-based
protection schemes.

Issue #77

Change-Id: Icba35089d6e451cbea7ebbf5dd5674079f206390
2016-04-12 16:06:49 -07:00
KongQun Yang 0218d9c690 Move fourccs.h and rcheck.h to media/base
- FOURCC is not a mp4 only concept. It is also used elsewhere.
- RCHECK has been used outside formats/mp4.

Also updated the FOURCC enum names to match the actual fourcc code, e.g.
FOURCC_mdat for "mdat".

Change-Id: I5be02f12695882c0fb41d359305fb8ec01303a06
2016-04-12 21:28:37 +00:00
Rintaro Kuroiwa ce55fbcae2 Fix build
- Use list of raw pointers instead of scoped_ptrs.
- Use base::is_same instead of std::is_same.

Change-Id: I0eea539584acf1f34da2b1ba069ba94e53bfa785
2016-04-12 11:04:46 -07:00
KongQun Yang 1d74988159 Implement AesPatternCryptor for pattern encryption/decryption
Issue #78

Change-Id: If0fadf6f83ef67dd39af29080bab6ed71fb35290
2016-04-12 17:09:25 +00:00
Rintaro Kuroiwa 2adaf1712d HLS MediaPlaylist class
- A class to generate Media Playlists.

Issue #85

Change-Id: I689e97c767049bc21de279c743cbabf4ca4711be
2016-04-11 20:53:47 -07:00
KongQun Yang 5fc09763ce More cleanups in AesEncryptor and AesDecryptor
- Create AesCryptor class as the common base
- AesCryptor::Crypt function will serve as an Encrypt function for
  encryptor and a Decrypt function for Decryptor.

Change-Id: Ie91fb14964b5091786705bf510656f40d73af160
2016-04-11 23:30:32 +00:00
Rintaro Kuroiwa e92556658e Add TsMuxer class
- Simple implementation of MPEG2 TS muxer.
- This does not take MuxerListener so a manifest cannot be generated.
- Encryption is not supported.

Issue #84

Change-Id: I117b772dbbce5437398defbd564883ad758916d5
2016-04-11 00:41:24 -07:00
Rintaro Kuroiwa 49d1563965 Only segment before key frames
- Segmenter should not finish a segment unless the next sample is a key
  frame.
- Renamed PesPacketGenerator::Finalize() to Flush().
- Use duration from the sample instead of the one copied to PesPacket.
- Remove duration field from PesPacket.

Issue #84

Change-Id: Icd90e65fd63fdeb955e7abac3473b0b54db6ac4a
2016-04-11 00:37:10 -07:00
Rintaro Kuroiwa ccc2dc46d8 Add TsSegmenter class
- Multi-file segmenter implementation.
- The samples are passed to PesPacketGenerator to generate PesPackets.
  PesPackets are passed to TsWriter to write them to file.

Issue #84

Change-Id: Ia4cae2abe2e7df46016dcdb791baaab2818aea03
2016-04-11 00:15:45 -07:00
Rintaro Kuroiwa 25a3fec213 Add TsWriter class
- Creates PAT and PMT from StreamInfo.
- Takes PES packets and write them to file.

Issue #84

Change-Id: Id0a95e66f126cc2b0fbb6b2169a391d64e49b06a
2016-04-11 07:05:24 +00:00
KongQun Yang b7f457e368 Update CHANGELOG for v1.4.0
Change-Id: Ib4fe35fc47ce34aaae9176d8379bd01704c6bd99
2016-04-08 19:12:03 +00:00
Rintaro Kuroiwa 8ea5df820e Use list of raw pointers rather than scoped_ptr
- Containers with scoped_ptrs break mac builds.

Change-Id: Id4b9aa735511bf27c83aa8465f64a627fb7fa1d2
2016-04-07 12:28:08 -07:00
Rintaro Kuroiwa cfd782ff40 Add PES packet related classes
- Define PesPacket class.
- PesPacketGenerator creates PesPackets from samples.

Change-Id: Icfd3656b498e0075f83ff3c789f95658f98c6144
2016-04-06 18:25:17 -07:00
Jacob Trimble 40e1cc87d1 Fix bug in WebM SeekHead.
The positions in the SeekHead element should be relative to the
Segment payload, not the start of the file.  Also added entries for
Tracks and SegmentInfo.

Change-Id: Id692da25fffc27d78e9f1a06d061431aeb6f1e7c
2016-04-04 15:50:55 -07:00
Jacob Trimble fe6775a509 Fixed off-by-one bug in WebM muxer
There was a bug in the single-segment WebM muxer where the index
range was incorrect.

Closes #99

Change-Id: I7cde98f9b5e88615fcf0ab406b22f65f0b14e15f
2016-04-01 16:26:41 -07:00
Jacob Trimble c9645bc21b Add a utility script used to generate/parse PSSH boxes.
This script can be used to parse and generate PSSH boxes.  This
serves two purposes:

* Parse PSSH boxes into a human readable format.
* Take several arguments to generate PSSH boxes.

This is also able to parse Widevine and PlayReady PSSH data and will
print the parsed data instead of the data as binary.  This can also
generate Widevine PSSH data instead of having the PSSH data passed
as an argument.

Change-Id: I245bd9abf79a259f6fda01d1fc0489b4a4a73db5
2016-04-01 16:19:45 +00:00