Commit Graph

89 Commits

Author SHA1 Message Date
Kongqun Yang f63385926b 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-22 12:38:50 -07:00
Kongqun Yang 7dc674b3a2 Remove top level box check in BoxReader
Change-Id: I3d0e5865851030264d7174031a98031b413e90ce
2016-06-22 12:36:12 -07:00
Kongqun Yang e9ad85c945 VPCodecConfiguration box should inherit from FullBox instead of Box
Change-Id: If53c6cab009bdeadc37a1bac34272056a2b7d1dc
2016-06-22 12:27:59 -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
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
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
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 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 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 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
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 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 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
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 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
Jacob Trimble 890c601dce Split NALU enumeration into its own class.
Removed the code for NALU splitting in the H.264 parser and moved
it to its own class.  Also added support for length-prefixed
NALU splitting for use with the encrypting fragmenter.

Change-Id: I1e91266681f1b117fb2382cf80590651efc06619
2016-02-17 00:59:38 +00:00
Bei Li 9ddf9276ce MPD signaling for Dolby Enhanced AC3 audio.
Parse channel layout value from dec3 box. Pass it through audio stream
info. MPD builder forms audio channel configuration to signal ec-3
codec.
Specs: 1) ETSI TS 102 366 V1.3.1 Digital Audio Compression (AC-3,
Enhanced AC-3) Standard E.1.3.1.8.
2) DASH-IF Interoperability Points v3.0 9.2.1.2.

Issue #64

Change-Id: Ia2c22dd3d82e757ba5a88ba1de35c5d593f5005e
2016-02-08 16:22:01 -08:00
KongQun Yang 38c30bd7a1 Allow other text sample entries than wvtt
Before this change, the media file will fail to be parsed if it contains
non-wvtt text streams. This change allows demuxing of video and audio
streams in these media files even though the text stream is ignored.

Fixes #74.

Change-Id: I7ef108a51125c4965fe48c39efe9638f3a0e4759
2016-02-04 11:36:44 -08:00
Anders Hasselqvist db7bebe3fa MacOSX: Solve libbase.a conflict link error
On Linux the generated ninja files use path/libbase.a as target name.
In the Mac ninja file the target is just libbase.a.
As we have two libbase.a (base/base.gyp and media/base/media_base.gyp) the linking stage fails to include both libs.

Solve by renaming media_base.gyp's base target to media_base
2016-01-22 18:50:05 -08:00
KongQun Yang 2c3aed4842 Handle possible NewSampleEvent before ParserInitEvent
For WebM contents, it is possible that we may receive some NewSampleEvent
before receiving ParserInitEvent. This is because init event is fired
after analyzing a video block which could come after an audio block.

Also modified Flush() function to return a bool to indicate whether the
the flush is successful and whether the samples are handled correctly.

And added macro to ensure Flush() and Parse() results are handled.

Fixes #71

Change-Id: I2294d6f529f54e4578344916559bb1bc116c745a
2016-01-22 17:50:54 -08:00
KongQun Yang 22498e125a Add WebM decryption support
- Also refactor decryptor management code out of mp4_media_parser.cc
- Move decryptor managment logic to DecryptorSource class to make it
  available for webm as well
- Remove data_offset member from DecryptConfig which is not useful
- Add widevine_pssh_data.proto file

Closes #72

Change-Id: I1d32baf4013ebd3382b5372c7433fae5033a260e
2016-01-21 16:59:58 -08:00
Bei Li 8563db4cff Support Dolby audio Enhanced AC3 in ISO BMFF (Part 2)
- Box definitions for box type DEC3.
- Parser/muxer changes to support Enhanced-AC3 audio codecs.
- MPD signaling will come in Part 3.

Issue #64

Change-Id: Ifcd5efa1f61b470ec225127925631e4329853259
2016-01-15 14:44:06 -08:00
KongQun Yang a040fb711c Handle side data properly in webm
Change-Id: Ic8c81154ea66374df62a4a46d66c45b3035a7829
2016-01-09 00:32:08 +00:00
Bei Li 58b95fd3d5 Support Dolby audio AC3 in ISO BMFF (Part 1)
- Box definitions for box type DAC3.
- Parser/muxer changes to support AC3 audio codecs.
- EC3 audio sample entry will come in Part 2.
- MPD signaling will come in Part 3.

Issue #64

Change-Id: I790b46ae8179b933bb8f7da9cdd38591fe8da43d
2016-01-08 15:56:48 -08:00
KongQun Yang e0040a4910 Add version information in generated outputs
For mp4 outputs, a metadata box with version information is added to
moov box.

For mpd outputs, a text comment with version information is added in
the beginning of mpd file.

Issue #60

Change-Id: I783ba370781c0a8f77c910ff1172bad2e7edff75
2016-01-08 19:08:56 +00:00
KongQun Yang 458d376343 Block align frames in superframe for vp9 cenc
Change-Id: I065151c05d55c993ffbd0c30f2aa521e8476833c
2016-01-07 20:08:03 +00:00
KongQun Yang b3e85ff810 Enable '-Wimplicit-fallthrough' and fix issues
Change-Id: I9e1e09f3924dcd8f59af2fbc952456b81e2d7c4e
2016-01-06 17:12:49 -08:00
Bei Li bb073cef51 Add support for DTS in ESDS. Needed to handle DTS audio generated by FFMPEG.
Issue #52

Change-Id: Ibd97054bce0b7ccb344f4bb34370399b8e051f30
2016-01-06 22:30:52 +00:00
KongQun Yang 098e087459 Implement SampleEncryption box parsing and generation
Issue #41

Change-Id: Ic57436b6e6c8b58fc264037fd81c98627c525932
2016-01-05 01:56:06 +00:00
Jacob Trimble c0df6b3239 Cleaned up Status class.
Change-Id: I1ff470410b38d32ad828618f756487585660a272
2016-01-05 01:02:34 +00:00
KongQun Yang 0c870b7c02 Define SampleEncryption 'senc' box
Issue #41

Change-Id: Ib28c079209f3a58ecd8d7b86d720a1c8c774b669
2015-12-31 01:26:18 +00:00
KongQun Yang 814d2414e3 Implement vp8 bit stream parser.
Change-Id: I8b7997ceb8e7484399442f7c1072f4d5aa33ff4e
2015-12-30 21:40:10 +00:00
KongQun Yang 94401d750a VP9 codec string from bitstream and subsample encryption support
- Parse vp9 bitstream to get vpx codec configuration
- Add subsample encryption for vp9
- Also fixed a bug in VP9 parser if segmentation update_map is enabled

Change-Id: I69dc97088aa38c94c6d37fdbcf3d9cfc942a3df6
2015-12-30 21:39:34 +00:00
Rintaro Kuroiwa 09d1c2ce9f Box definitions for WebVTT
Change-Id: I94d38bef918eed18df7cd312126e2d589aadf9c7
2015-12-22 14:05:50 -08:00
KongQun Yang c8e3345959 Some code clean ups in box definitions
- Add Box::WriteHeader and Box::HeaderSize methods. The concrete
  box implementations should not need care about whether it is a
  Box or FullBox normally.
- Rename Box::ReadWrite to Box::ReadWriteInternal to make it clear
  that it is an internal methods. Make it private so it cannot be
  incorrectly called in box implementions.
- Make an internal implementation of ComputeSizeInternal to compute
  box size. |atom_size| is updated in ComputeSize, which wraps
  ComputeSizeInternal.

Change-Id: I3fbcf8c527581b676d9d13f1ac1dd798da7c4d5f
2015-12-21 18:40:05 +00:00
Bei Li aa805b9632 Support DTS audio in MP4 - Part 2
Issue #52

Change-Id: Ib71077c5063aced23f9d060b35facbf8e6eb0a3a
2015-12-10 20:49:13 +00:00
Bei Li 2806dffb47 Support DTS audio in MP4 - Part 1
Issue #52

Change-Id: I5061e2a674d5c1b039a49729e53d4d15a4120a5c
2015-12-08 23:06:52 +00:00
Bei Li c647c25d5f Revert "Support DTS audio in MP4 - Part 1"
This reverts commit 9b0d4abece.

Change-Id: I3897fffde2ab162638876df1eafa7a4058573e49
2015-12-07 19:35:11 +00:00
Bei Li 9b0d4abece Support DTS audio in MP4 - Part 1
Change-Id: I4464f869552f5cd0cb77d1b3e97c8efc4b00c552
2015-12-04 16:03:16 -08:00
KongQun Yang 4c10755d40 Support HEVC in mp4 parser and muxer
Issue #46

Change-Id: I36bf8418a335181ad71509e6e0cccdce210467f0
2015-11-04 17:18:41 -08:00
KongQun Yang c577e6132f Implement initial support for vpx in iso-bmff
Also update the code to generate CompressorName in VideoSampleEntry
for both AVC1 and various VP codecs.

Change-Id: I2355f8008a72806e852aa1ec6c80e9141b97d963
2015-11-04 00:34:00 +00:00
KongQun Yang 8fc7f51d81 Move AVCDecoderConfiguration parsing to media/filters
Change-Id: I7daa616e53bdef2206ce145f907b8f55cde87740
2015-10-28 00:31:43 +00:00
KongQun Yang 95d2dbf68d Relax requirement on reserved bits when parsing AVCC
Issue #44

Change-Id: I84235a4d94225e2bf1777443611ad19429b958d4
2015-10-22 19:09:40 +00:00
Kongqun Yang 9c0ae378bc Switch to boringssl. Also update curl accordingly.
Boringssl and yasm gyp and patches will follow in a separate cl.

Bug: 22463853

Change-Id: I87b91ac089866db58ac433def006fe9ac4744bd6
2015-10-16 20:10:38 +00:00
Kongqun Yang 47c79d08ce Update code to resolve problems due to base updates.
Notably deprecate of OVERRIDE, to be replaced with C++11 override.

Bug: 22463130
Bug: 22664127

Change-Id: I12c82e092e9e8eb0870da4363307c3563a3531b7
2015-10-16 20:09:56 +00:00