Commit Graph

61 Commits

Author SHA1 Message Date
Haoming Chen feeb7361ff Clean up #ifndef in packager/media. (#310) 2017-12-19 16:56:36 -08:00
KongQun Yang 8e96dd3b37 Address gcc build failures in some platforms
Seeing some failures on some platforms when compiled with clang
disabled:
  GYP_DEFINES="clang=0" gclient runhooks

Several changes to make it work:
1. Mark packager code with packager_code=1 in GYP definitions.
2. Disable a few checks in non-packager code, which we do not have
   direct control: dangling-else, deprecated-declarations,
                   unused-function
3. Fix the relevant errors in packager code.
4. Revert HAVE_STROPTS_H in curl config which is not available in
   all linux distributions.

Fixes #286
Fixes #293

Change-Id: I729b41f99403c5ad9487c6cc4a7dc06f6323cef8
2017-12-07 11:45:26 -08:00
KongQun Yang 0a69779f7c Fix a parsing problem with AC3 in TS
Audio samples per frame for AC3 was not specified correctly earlier.

Also the number of channels is not correct if LFE channel is on.

Issue #165

Change-Id: Ibf20aa4c7aec43c07ec7cd394d631c537cb387dd
2017-11-07 18:47:09 -08:00
KongQun Yang 2a2493ec2e Refactor EsParserAdts to handle other audio
Rename will happen in next CL

Change-Id: I28df29bb264eea7a6225b0a4a2eb38de7968f9d6
2017-10-25 23:21:35 +00:00
KongQun Yang d66d307fc2 Rename fixed_key to raw_key
Change-Id: I1ee9398387b54aa685a5bef5b8704849e62ebae3
2017-10-24 21:52:01 +00:00
KongQun Yang 92e1e39868 Update MediaSample to avoid redundent copying
Use std::shared_ptr<const uint8_t> with a custom deleter to
represent MediaSample::data_ instead of std::vector<uint8_t>.

MediaSample::data_ can be shared by multiple MediaSamples and it is
immutable. A new data instance must be created if the clients want to
modify the underlying data. The new data instance can be transferred
to MediaSample using provided MediaSample::TransferData function.
This avoids unnecessary data copying.

Change-Id: Ib59785a9e19d0abb3283179b12eb6779ee922f79
2017-09-28 14:01:30 -07:00
KongQun Yang 3bad4ca700 Move status.h under packager/
Change-Id: I4a7f34c575c1c8b9a9a275f3889cf8641cfdd471
2017-06-30 11:35:18 -07:00
KongQun Yang 1aeedd102e Use free-form strings for stream labels (track types)
Change-Id: I38489acbdfaf4bb491635fdc7f6b0cab77a53574
2017-06-13 15:04:00 -07:00
Haoming Chen da8877d8a2 Rename trick play rate to trick play factor.
- Add a "tpf" abbreviation in stream descriptor for
  trick_play_factor.

Change-Id: Ia09313bb9778456b53bdb0a8cc46d2ba8caa2ac2
2017-05-17 21:51:34 +00:00
Haoming Chen 4ba5bec660 Integrate trick play.
- Add trick play adaptation in mpd. This addresses #178.

Change-Id: Id6cc08c788eda074c261d0274768051837b84541
2017-05-09 13:33:11 -07:00
Kongqun Yang 4a47268f3d Fix avc3 codec string problem
- Added wvm decryption and demuxing test
- Added avc3 test (not strip parameter set nal units)

Change-Id: I28ff4d7f9ef539eafe45cfadfc0912cd11c72b05
2017-04-28 19:24:11 +00:00
Kongqun Yang fb0790e1d5 Refactor KeySource::FetchKeys to use EME init data types
Change-Id: I517ea992a8868d7382988a8837f4f05df9f974d7
2017-04-20 20:21:29 +00:00
Kongqun Yang 75a4b55b34 Fix AAC-HE not correctly signaled in codec string
- Also fixed a bug with dts audio in esds.

Closes #225

Change-Id: I50ca731ac81bedfec37b0e2d577c51d643b7a839
2017-04-13 23:40:23 +00:00
Kongqun Yang 277c5b23c0 Allow generating avc3 / hev1 from TS and Wvm files
Added a flag --strip_parameter_set_nalus. When enabled, parameter
set NAL units, SPS/PPS for H264 and SPS/PPS/VPS for H265, are stripped
from frames when converting NAL byte stream (AnnexB stream) to NAL
unit stream, which generates avc1/hvc1; otherwise they are not
stripped, and avc3/hev1 is generated.

Parameter set NAL units should not be stripped if they are varying
in the frames otherwise the frames may fail to be decoded.

The flag is enabled by default as we don't usually see varying
SPS/PPS/VPS and it is more space efficient with them stripped.

Set --strip_parameter_set_nalus=false to disable the flag if there
are varying SPS/PPS/VPS in the frames. This addresses #206.

Change-Id: I34bde6f33069f9f77d51a510b39f58a0f0e141aa
2017-03-23 13:53:14 -07:00
KongQun Yang 3d7635d5de Integrate EncryptionHandler
Change-Id: I639e5707994a6601ee02078cd6f77cb38b481585
2017-03-23 18:25:59 +00:00
Kongqun Yang 97fbaaa567 Replace scoped_refptr with std::shared_ptr
Change-Id: Ie8ea66e78c42c7387a97bb1abc331c636be11aa4
2017-01-26 02:20:47 +00: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
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
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
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
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 4f9c8ea781 Rename top level namespace to shaka
Issue #103

Change-Id: I67945c8ec6d2c178494d3b5400e5ec0170e9d115
2016-05-24 21:55:55 +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
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 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
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
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
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 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 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
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
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 8fc7f51d81 Move AVCDecoderConfiguration parsing to media/filters
Change-Id: I7daa616e53bdef2206ce145f907b8f55cde87740
2015-10-28 00:31:43 +00:00
Thomas Inskip 05f80f961c Fix for race condition when flushing ThreadedIoFile.
Change-Id: I46f26fa9fddf53ca5231c31d6442053ab5202ade
2015-10-20 16:44:15 +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
Thomas Inskip a9b6fcedd7 Added fallback to computed AVCDecoderConfigurationRecord if the one
stored in the WVM metadata is invalid.

Change-Id: I9e3c7ba4677f1ac7c19ec4d51f600d28bb427acb
2015-10-14 09:46:14 -07:00
Thomas Inskip cb7173d280 Added support for multiple audio & video configurations in WVM parser.
BUG=24614172

Change-Id: I197a0ebdfa6df90abc27358762cae041e4f8fd45
2015-10-13 10:42:49 -07:00
KongQun Yang 93e6c4fc92 Reduce test file sizes and remove unused test files
Change-Id: I7e3b24e92b2a16de857e0424c85232cc31444182
2015-10-12 20:16:03 +00:00
Thomas Inskip d0fb8ced4b Use default audio and video PES stream IDs (0xc0 and 0xe0 respectively)
if not specified in the WVM metadata.

BUG=24753064

Change-Id: I4c4cd0b30f0e153d46639382682da13b127dd305
2015-10-08 13:16:00 -07:00
Kongqun Yang 3a5fdd2d9c Fix incorrect width/height in VisualSampleEntry for mp2t stream with cropping
Cropping is necessary if width/height are not exactly disivible by 16 due
to 16x16 macroblock size.

The width and height fields in VisualSampleEntry must correctly document
the cropped frame dimentions (visual presentation size) of the AVC stream
that is described by that entry.

Also fixes width/height in input mp4 and wvm streams if the values in
VisualSampleEntry / metadata do not match with the values in
AVCDecoderConfigurationRecord (SPS).

Issue: 39

Change-Id: Id55c5acf245bee3f4e66302b2042eb7d9c488c19
2015-09-18 17:42:52 +00:00
Kongqun Yang 2a95367dd4 Move SAR extraction out of video_stream_info.cc
This fixes a circular dependency of media_base depends on filter and
filter depends on media_base.

Also added code to extract sar in WvmMediaParser if it is not yet
extracted when setting extra_data.

Change-Id: I1b5aef2444e4134c9b6663911ac5e5c4c220404a
2015-08-24 23:16:49 +00:00
Rintaro Kuroiwa c3c971ebd9 Add pixel_{width,height} to VideoStreamInfo
- Added logic to container parsers to extract pixel width and height.
- If the container doesn't contain the pixel width and height of the
  stream and the stream is H264, this parses the SPS to get the
  sar_width and sar_height.
- If extracted sar_width and sar_height are 0s then they imply 1s.
- Add hb2_v_frag.mp4 for test media. This does not have a
  'pasp' box and has sar_width = 8 sar_height = 9.

Change-Id: I4a06ce95582547bec19adb7905e7612c5a1f359e
2015-06-29 11:17:28 -07:00
Thomas Inskip a14ea461fb Added trick_play_rate to VideoStreamInfo.
Added ability to query the Demuxer for the container name (type).

Change-Id: I328215f7c5badfe117c5419dd42f5262c568112a
2015-06-02 22:54:13 +00:00
Ramji Chandramouli a99af5a015 Modify WVM media parser to support encrypted media sample.
Change-Id: I8e696527a09fcec22b6c9713e0d1d3096720ce9c
2015-01-14 00:30:14 +00:00