Commit Graph

711 Commits

Author SHA1 Message Date
Rintaro Kuroiwa fce25acd78 Ignore Mac's .DS_store files
Change-Id: I59bd52ae860b7f7818cd431865a57fbcc42ce0b2
2016-04-13 22:00:03 +00: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
KongQun Yang a9e5a2ff4f Refactor and optimize cbc encryption/decryption
- Optimize and clean up encryption and decryption code.
- Consolidate various CBC encryption/decryption schemes into a
  common class.
- Make it a constructor argument whether cipher block chain is
  continuous across Encrypt/Decrypt calls.
- Also align protected region size as required in CENC spec.

Issue #77

Change-Id: I533d92ada3cd80933b532b9c3a1cca105ba66f8e
2016-03-30 17:22:13 -07:00
KongQun Yang a2438554f6 Fix gpylint errors on packager_test.py
Change-Id: I28074c4e9270279ebb83f64b2f9f615b4f705079
2016-03-29 17:37:58 -07:00
Jacob Trimble e7926e7ccb Fixed mac build for H.265 parser.
Another feature that the mac build does not support.  It incorrectly
uses a copy-constructor when creating new values in a std::map.  This
is incorrect and should use an in-place constructor with C++11.

Change-Id: I1e822747e97eb4ae01596d63ea05058cc383cb49
2016-03-29 15:52:03 -07:00
Jacob Trimble cdcfc4c44b Added H.265 parser.
This adds a preliminary H.265 parser.  The parser only support
reading the slice header.  This also attaches the H.265 parser to the
VideoSliceHeaderReader so H.265 frames can have unencrypted headers.

Issue #46
Closes #40

Change-Id: I8b98e1f8bb04e359d9bf896fd5b2939c326b196b
2016-03-29 20:21:46 +00:00
Jacob Trimble 6f8cbf90b9 Add packager flag to include common PSSH with Widevine.
The flag --include_common_pssh will add another PSSH box in addition
to the Widevine one which will contain the key IDs of all the keys.

Closes #88

Change-Id: Ic719b19747530f0e4856cfb36471a644d572a734
2016-03-28 22:27:51 +00:00
Rintaro Kuroiwa 94b4c52bf5 packager test should respect builddir_name
- Use 'builddir_name' environment variable to create the output
  path in test_env.py
- This allows running the packager test with different build
  configs because it doesn't use 'out', e.g. it could use 'out_clang'
  for clang builds.

Change-Id: I843343ec8e2d0a64dffbab2fdbd38aead5c97718
2016-03-26 16:42:00 -07:00
KongQun Yang 0c46943177 Improve handling of unescaped NAL units in byte stream
The new algorithm will parse NAL unit header and only starts a new
NAL unit if it is valid, otherwise it will be considered part of
the previous NAL unit.

Closes #96

Change-Id: I45f2a0f37d51841ee8345d6d0d38fcda57e0a009
2016-03-24 13:15:17 -07:00
Jacob Trimble d5cdd00ba1 Move fixed key encryption code to new FixedKeySource.
KeySource is now an abstract class that is implemented in two
types WidevineKeySource and FixedKeySource.  This also updates
fixed key encryption to use v1 PSSH boxes with the common system
ID.

This also updates the --pssh argument.  Now it accepts full PSSH
boxes rather than data.  Multiple PSSH boxes can be concatenated
together.

Issue #88

Change-Id: I4bd0290f6d8b965f7d118f075c96e0f267d7e831
2016-03-21 10:30:47 -07:00
Bei Li e39c3572af Add support for "AES 128-bit Cipher Block Chaining (CBC-128) Encryption"
- Part 1.

- Add packager command line argument "protection_scheme" to specify
  protection scheme. Plumb through packager code to enable CBC
  encryption/decryption.
- Add scheme type "cbc1" to sinf.
- Refactor AES encryptor and decryptor.
- Need more work in the subsample handling.

Issue #77

Change-Id: I3a9304d89adf5efbfb226b6e805a3077b6cb8c68
2016-03-17 16:51:04 -07:00
KongQun Yang ef81be5f7b Fix a subsample incorrect size bug in mp4 encryption
Clear size was not correctly calculated for non-video slice nal units.

Change-Id: I8371973a4ae346cbe4c1891ab274fb7a86983db8
2016-03-14 17:42:46 -07:00
Jacob Trimble 1863f5a569 Renamed SPS/PPS to Sps/Pps.
H264SPS -> H264Sps
H264PPS -> H264Pps
ParseSPS -> ParseSps
ParsePPS -> ParsePps
GetSPS -> GetSps
GetPPS -> GetPps

Change-Id: Ib658c05d78baabc698af4e52d8b4c77dbfbd6870
2016-03-14 12:44:05 -07:00
Jacob Trimble 43dc6248a3 Renamed H264BitReader to H26xBitReader.
Change-Id: I960a636541a5cadcce5f41e1a75c3ddfbbfaa803
2016-03-14 12:02:21 -07:00
Jacob Trimble 144cdc5e59 Change to use ProtectionSystemSpecificInfo.
* EncryptionKey now contains them rather than a PSSH box.
  * Outputs PSSH boxes for each entry.
  * Outputs a ContentProtection element for each entry.
* Removed SystemName and UUID from KeySource.
* Removed --scheme_id_uri packager argument.

Issue #88

Change-Id: I2651784c3220fd64f5b1773fdcd70285690cf8c0
2016-03-11 17:56:25 +00:00
Joey Parrish f3e19fc002 Split AdaptationSets by content type, container, codec, and language
This adds a new function to key AdaptationSets based on the
characteristics that require separate sets.

With this, we are now able to package multi-codec assets at once
(AVC1/MP4 and VP9/WebM in the same manifest, but in different
AdaptationSets).

Fixes b/27534371

Change-Id: Ie82fd096d2ef99fd23e323d60fd0849b1e8d7500
2016-03-10 15:53:17 -08:00
Joey Parrish b6718a37c5 Accept language subtags
When normalizing language tags to their shortest form, we need to
split off subtags and treat them as separate components that do not
get changed.

Furthermore, MP4 can only store language tags without subtags.  So
only store the main language in MP4 output.

Fixes b/27533973

Change-Id: I96049e274aae9841e321c53039ef6464a2e61574
2016-03-09 23:23:12 +00:00
Jacob Trimble 591650e61d Removed the use of emplace_back.
This does not currently work on our mac builds, so this replaces it
with push_back.

Change-Id: Iecd292969daac059bdd23d1ad937ff4366a7943f
2016-03-09 10:51:57 -08:00
Jacob Trimble c4246d04fd Change FetchKey usages.
Add another overload to fetch by key ID directly, used by WebM.
Changed the one using PSSH data in favor of the entire PSSH box.

This also moves the Widevine proto to media base.  Now, the
Widevine key source handles creating the Widevine specific PSSH
data.

Change-Id: I6f4633facad39207809ffbad970635d1f9d70983
2016-03-08 21:45:05 +00:00
Rintaro Kuroiwa 90731d79df Unit stream to byte stream converter
Change-Id: Iafe1989019e306281f17d80faa348262043cd3b8
2016-03-07 19:10:42 -08:00
Jacob Trimble 9d67f545ed Add support for v1 PSSH boxes.
This moves pssh parsing to its own class in media base.  This type
can be used to parse and generate pssh boxes.  This new type also
supports both v0 an v1 boxes.

This also modifies the pssh box definition to only have the |raw_box|
and moves all pssh parsing and handling into mp4 media parser.

A follow-up change will replace the remaining usages of 'raw' pssh
box data with the new type.

Issue #88

Change-Id: Ic2436ecb5df8b3558b81e600dc095b0efd122ab1
2016-03-07 14:45:01 -08:00
Jacob Trimble 0ca1160474 Moved common code out of H264Parser.
This moves common parsing code out of the H.264 parser.  This is in
preparation for the H.265 parser to use.

Change-Id: Id05b55f6adc2ea31e97c8a9f22023e851808a8a7
2016-03-04 13:25:54 -08:00
Jacob Trimble 0803e31836 Read SPS/PPS Nalus from decoder configurations.
Now the AVCDecoderConfiguration and HEVCDecoderConfiguration classes
will read the Nalu from the blocks, meaning they will store a
vector of Nalu objects for the data.

Also added H.265 to the Nalu class and added argument to NaluReader
to read H.264 vs H.265 Nalus.

Change-Id: I8d8194a90fd72a30af66e9776e01379f8428542c
2016-03-04 18:41:50 +00:00
KongQun Yang b318eb40f7 [Travis CI] Upload release build binary to Github release automatically
Change-Id: I23fa6d75db04e1649ba0fbf5191591ffa0038257
2016-03-04 18:30:55 +00:00
KongQun Yang 91b43773fd Update hevc test file to have more than one key frames
This is needed to test encryption in end to end test since the video
is segmented in gop boundary by default. Due to the existence of clear
lead, the first segment is always left in clear.

Change-Id: Ie8d37a1740f9061515298cb9fb7b58983592cc5b
2016-03-03 17:34:24 -08:00
KongQun Yang cef1729652 Replace vector_as_array(...) with vector::data()
vector::data() introduced in C++11 does exactly what vector_as_array does.

Change-Id: Iab436b6f1ce7db7678bd240256d9ae80208be07b
2016-03-02 10:22:15 -08:00
KongQun Yang 583f1f3352 Don't fetch git histories in docker
Change-Id: I02e5db18d49d1978960ee3d66cb48d681e5e858e
2016-03-02 18:01:36 +00:00
Jacob Trimble 53e6d2d149 Renamed Nalu |data_size| to |payload_size|.
This member refers to the size of the payload (the data after the
header).  Since the pointer is called |data|, calling this size
|data_size| is confusing.

Change-Id: I9174cf6c5c402beddaebbce7c16514470ba0c3da
2016-02-26 16:11:30 -08:00
Jacob Trimble e0e0925b31 Add error messages for when a WebM Cluster is too large.
Issue #90

Change-Id: I7fe8393df931a12e999724e3604648b97de24da7
2016-02-26 19:21:52 +00:00
KongQun Yang a01b07fbfd Log an error when PushSample fails
Change-Id: I7911881a42af0edac10b36ad82158e103418714a
2016-02-24 12:44:10 -08:00
Jacob Trimble 0d3951ff74 Moved Nalu data pointer position.
Now the Nalu data pointer points to the start of the NALU header
rather than pointing to the start code.  Added a new method on
NaluReader to check whether the stream starts with a start code.

Change-Id: Ifaecbe0c911aa5cffdf0a966028e6cada8621cc3
2016-02-23 10:48:14 -08:00
Jacob Trimble 96abd90ca2 Only encrypt video slice NAL units.
For non-video slices, the data is not encrypted.  This also skips the
frame headers for H.264; support for H.265 will be added later.

Issue #40

Change-Id: Id0cb0fb9ddb6adedf63ef4aef6b3a26260a21654
2016-02-22 21:52:05 +00:00
KongQun Yang 74951e3405 Add Travis configuration for continous testing
Closes #81

Change-Id: I448420568b26a5335b6780289e9118fcf3ef7828
2016-02-18 22:07:55 +00:00