Commit Graph

433 Commits

Author SHA1 Message Date
KongQun Yang 10daa39901 [MP4] Allow not to generate 'sidx' box for single-segment too
I.e. the flag --generate_sidx_in_media_segments,
--nogenerate_sidx_in_media_segments work for both single-segment
and multi-segment mode with this change.

Related to #862.

Change-Id: Icd27fd00e8e036ba0c4709b48650372429cc0351
2020-12-11 19:08:37 +00:00
KongQun Yang 516430bde1 [MP4] Truncate segment references in 'sidx' if necessary
The reference count in 'sidx' box is a uint16 field, which allows at
most 0xFFFF entries, i.e. at most 0xFFFF subsegments, which is roughly
18 hours for one second segments.

Do not fail packaging when it happens. Instead, generate a warning and
truncate the number of references to 0xFFFF instead.

Note that the actual number of mp4 fragments in the mp4 file can still
be more than 0xFFFF. The stream will not play to the end in DASH, but
it will play successfully in HLS.

Workarounds #862.

Change-Id: Ib3930418d1528df1f9ea64cda0d0ebaa78d26abb
2020-12-11 19:07:56 +00:00
Jacob Trimble c4a11aaed4 Add support for text cue heights.
Issue #832

Change-Id: Ifccbd6c6c46916d3d28ac4afaba01fc158c9c361
2020-12-10 13:26:34 -08:00
Jacob Trimble fe44b5e13c Add background image to TextSample and TTML output
Issue #832

Change-Id: I50f23223fa4362559087ada9b40488c089594450
2020-12-08 19:24:31 +00:00
Jacob Trimble 9b036b764b Add TextSample handling to MP2T parser.
This also changes the callbacks a bit to (a) avoid passing references
for already ref-counted types, and (b) don't pass PID since the
parent knows this and gives it to the child parser.

Issue #832

Change-Id: I7dd44436c8d1ad81d42a813d16f850175b85ad1a
2020-12-08 10:30:29 -08:00
Jacob Trimble a93eeca5db Add TTML-in-MP4 output support.
This changes the default MP4 output to use TTML and adds a way to
choose which one is used.  This is done with 'format=ttml+mp4' or
'format=vtt+mp4'.

This also fixes the boxes output in WebVTT in MP4.

Change-Id: Ieaa7fc44fbf4dc020a5bb70cfa3578ec10e088ce
2020-11-20 15:10:33 -08:00
Jacob Trimble 4766654b4d Add TTML text output.
This only supports TTML output; meaning the user can convert WebVTT
into TTML, but not the other way around.  This will be useful for
DVB-sub subtitles that would be better supported within TTML.

This only adds text-based output; a follow-up will add MP4 support.

Change-Id: I0944b7df95d7765e55f203fc5e9a644f5c455dd8
2020-11-19 18:03:39 +00:00
Jacob Trimble 8e85862bda Ignore unsupported H26x streams.
This adds a new path when parsing MPEG2-TS streams to ignore unsupported
streams.  This allows extracting supported streams when some of the
streams are unsupported.  For example, you can extract audio from a
file that has unsupported video.

Change-Id: I608fcb19d0a573bfd35e9272f60b0b69346ae11a
2020-11-09 18:11:07 +00:00
Jacob Trimble 10e71680a1 Parse WebVTT regions and styles.
This adds more generic settings for regions and CSS styles.  These are
global settings, so they go on the StreamInfo object.

Change-Id: Ibb76c060206152ccf8e9a067c09877226f67c927
2020-11-09 18:08:42 +00:00
Jacob Trimble 1f21cc78cd Add style support for cue fragments.
Now text cues are composed of nested fragments that can be individually
styled.  This allows portions of the cue to be bold, etc.  The
WebVTT parser doesn't parse the inputs, but the original tags are
preserved in WebVTT output.  The WebVTT output will add tags if the
style elements are present in the cue object.

Change-Id: I6abba4175e376e4f753193f7d8cac63e958d3c89
2020-10-21 10:53:59 -07:00
Jacob Trimble 414f4589c8 Parse TextSettings from WebVTT.
Now the Cue settings are a generic object that is parsed in WebVTT.
This will allow setting the settings in different parsers without having
to use WebVTT-specifics.

Change-Id: I36689bec725bd2e515af962b7174fc5977f96fa2
2020-10-20 21:50:06 +00:00
Jacob Trimble b2220eb0c6 Add text fragment and setting types.
This sets the groundwork for more generic text cues by having a more
generic object for the settings and the body.  This also changes the
TextSample to be immutable and accepts the fields in the constructor
instead of using setters.

Change-Id: I76b09ce8e8471a49e6bf447e8c187f867728a4bf
2020-10-19 10:39:17 -07:00
Jacob Trimble 56908a83a7 Convert text WebVTT output to muxer.
Now text-based WebVTT also uses the generic media pipeline.  This
converts the WebVttTextOutputHandler to a WebVttMuxer to be more
consistent with the other muxer types.

This also allows choosing between single-segment text and multi-segment.
Before, we would generate both and use single-segment for DASH and
multi-segment for HLS; but now you can choose between either and either
are supported in both DASH and HLS.

Change-Id: I6f7edda09e01b5f40e819290d3fe6e88677018d9
2020-10-19 17:24:38 +00:00
Jacob Trimble e3bc85f12d Make WebVttParser a MediaParser.
This changes it from an OriginHandler to a MediaParser and moves the
handling of it to the Demuxer.  This will allow more generic handling
of text by giving it the same abstractions as video/audio handling.

Change-Id: Ibbde3c84d228ec8e83af1ed266ea97dbc9589c24
2020-09-16 20:12:48 +00:00
Jacob Trimble ba33a63693 Add TextSample to MediaParser.
In addition to the MediaSample handling of the MediaParser, this now
adds callbacks for TextSample.  This allows reading text streams from
the media files.

Change-Id: I6c00e286e98bc9aafe05b99cf2f7ce6f89d167a9
2020-09-16 20:09:28 +00:00
Jacob Trimble 748e7e0056 Make the text readers use streams.
Instead of having the text readers reading from the file directly, they
now accept the data as a stream.

Change-Id: Id1b32c867a8058a68ae7aab5c568f77672a4401d
2020-09-16 20:06:51 +00:00
koln67 5b9fd409a5
[MP4] Change major brand from isom to mp41
This fixes warnings that 'isom' can only be a compatible instead of major brand.

Issue #755.
2020-09-08 15:45:21 -07:00
koln67 562040e000
[TS] Calculate frame rate using the second sample
Related to #751.
2020-09-02 14:27:02 -07:00
koln67 54bf394c03
[HLS] Ensure playlists with TS streams include FRAME-RATE
It fixes the FRAME-RATE missing issue in #816.
2020-08-21 12:04:24 -07:00
akata01 6298f49d9e
Don't fail if input contents contain SampleGroupDescriptionBox with 0 entries
Fixes #812.
2020-08-09 18:44:16 -07:00
sr90 11d69896c0
Write to memory file before writing to file for WebM segments generation (#803)
The change is needed to address #554.
2020-07-27 21:32:56 -07:00
koln67 a8ea7fd085
Always set ES_ID to 0 when writing ES Descriptor in mp4 (#798)
Required by ISO/IEC 14496-14:2018 and ISO/IEC 23000-19:2018.

Issue #755.
2020-07-15 14:14:15 -07:00
sr90 db5413ed7a
Write to buffer before writing to file for TS segments generation. (#790)
The refactoring is needed to address #554.
2020-07-04 15:18:30 -07:00
Weiguo Shao 540c0aaffb
Added AC-4 codec support (#795)
Closes #754.
2020-07-04 14:55:28 -07:00
Zajcev Evgeny 8913dbda85
Mpeg1 Audio: Support for iso-bmff output (#780)
Issue #779.
2020-06-06 17:18:00 -07:00
Zajcev Evgeny 98a9d1baf6
Support for MPEG-1 Audio in mpeg2ts I/O and packed-audio output (#778)
Implemented according to https://www.datavoyage.com/mpgscript/mpeghdr.htm.

Closes #779.
2020-06-02 17:32:19 -07:00
Sergio Garcia Murillo dba798798b
Prevent seg fault when finalizing empty segment (#759)
Fixes #757.
2020-04-25 14:09:48 -07:00
Joey Parrish 962baf0286 Fix reading WebVTT from a pipe
Opening a named pipe can block until both ends are open, and we cannot
control when the other end will be open.  Ideally, we would always
open files in a thread so that Packager can be used with piped inputs
from naive applications without a potential deadlock.

This change will defer opening WebVTT files until the parser Run()
method is called from a thread.  This way, WebVTT files being sent in
from a pipe will never be able to block the main thread.

Previously, files were opened on the main thread before calling the
parser constructor, passing the open file to the constructor as an
argument.  I also tried doing it in the parser's InitializeInternal()
method, but that is also called from the main thread.

Change-Id: I54cc68ed9d48a8dc697829119be84d4065b1ae1c
2020-03-19 20:25:07 -07:00
KongQun Yang 055c67888b Add an option to allow write |mvex| before |trak|
Under command line flag --mvex_before_trak.

This is needed to workaround Android MediaExtractor bug which
requires |mvex| to appear before |trak|.

Closes #711.

Change-Id: Id41d71af5c0016f59023dda6408bbf502e12ac55
2020-02-28 02:10:08 +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
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
Tomohiro IKEDA b8ee20df1d Improve ConvertToADTS function performance (#639)
Remove the extra data copying.
2019-09-10 13:15:17 -07: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
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 3f7ecd4e29 Workaround extra AUD in the access unit
VLC seems to generate access units with extra AUDs. In #526, the below
sequence is seen:

  AUD | SPS | PPS | SPS | PPS | AUD | SEI | SEI | SEI | IDR_SLICE

Previously we exit early when seeing AUD, which results in delayed
processing of the access unit.

The behavior is changed to continue processing the following NAL units
to workaround the content issue.

Closes #526.

Change-Id: I80f571c0711c6db1337eb393fce36fae5432b6c5
2018-12-15 00:32:06 +00:00
KongQun Yang 4c6059be78 Fix mpeg-ts demuxing with AC-3/E-AC-3
kFrameSizeCodeTable rows are ordered by 32kHz, 44.1kHz and 48kHz,
which is the reverse of fscod (48kHz, 44.1kHz and 32kHz).

Also updated unittests.

Fixes #487.

Change-Id: Icb0afb8bb895afde0028eee05b403bc85bf7b538
2018-11-20 22:33:40 +00:00
KongQun Yang 08aa9b6b2b Remove FairPlayPsshGenerator
This was introduced earlier to indicate FairPlay protection system. But
in fact, it is sufficient to just use the system id for the indication.

- Also updated various parts of the pipeline to support empty PSSH.
- Added an additional FairPlay end to end test using fMP4.

Change-Id: Ica48b7b5235e9a2b5a7f722bcd0fc1ef2073ac13
2018-09-21 00:49:35 +00:00
KongQun Yang 31e5f129b5 Fix incorrrect segment name with $Time$ in segment_template
The time for the previous segment was used when generating the segment
name. This resulted in the first segment being overwritten and
mismatching manifest and media files. It led to playback problems.

Issue #472.

Change-Id: Ia8130ce261585e1a2ede83b26de3e32508de087f
2018-09-13 00:56:28 +00:00
KongQun Yang d0978b3937 Compute and set VP9 Level if it is not already set
The VP9 level is computed when the container is missing a codec config
or if the level is missing from the codec config.

This fixes VP9 in ISO-BMFF files generated by FFmpeg v4.0.2 or earlier
which does not have level set in the codec config.

Fixes #469.

Change-Id: I685bfd48be16ee6b2209da1c3173f7d6bb02b36a
2018-09-13 00:37:30 +00:00
KongQun Yang 0709db4bbc Add support for AV1
Implemented per AV1 Codec ISO Media File Format Binding at
  https://aomediacodec.github.io/av1-isobmff/
And AOM AV1 codec mapping in Matroska/WebM at
  https://github.com/Matroska-Org/matroska-specification/blob/av1-mappin/codec/av1.md

Note that AV1 specific boxes are not supported in this CL, i.e.
AV1 Forward Key Frame sample group entry 'av1f', AV1 Multi-Frame
sample group entry 'av1m' etc are not supported. These boxes are optional.
We will add support later if they are useful to the clients / players.

Encryption is not supported yet.

Issue #453.

Change-Id: I630432d0a9bf82d263ffaf40e57f67fc65eee902
2018-08-31 19:16:04 +00:00
KongQun Yang 33792ca2da Workarounds TS contents with dts moving backwards
Negative duration is not allowed, so set the duration of that sample to
an arbitrary small value in case it is needed to decode future samples.

Issue #451.

Change-Id: I9250d71d163f769ea2657d56e108b6dbd583de67
2018-08-28 20:25:35 +00:00
Aaron Vaage e071710fa9 Adding Missing "// namespace"
Change-Id: I7bdb5841a8b22c59d97f120f8d83bddcc77858cb
2018-08-27 17:19:31 +00:00
KongQun Yang 40a3b42980 Fix pattern signaling in seig for key rotation with cbcs
Closes #460.
Bug: 112769382

Change-Id: Id2277edf9ac1ca637354f3a585666ad139ed8ee2
2018-08-24 23:20:06 +00:00
KongQun Yang e5b8b3ec64 Add support for seek preroll in AAC and other audio codecs
Closes #452.

Change-Id: I0f648c4fa6c861540b050a5b4e9878987c8383e5
2018-08-23 18:58:04 -07:00
KongQun Yang f49b89280c Support STYLE and REGION in WebVTT
Note that STYLE and REGION are not supported in mp4 container due to
spec limitation as 14496-30:2014 does not specify a way to signal
styles/regions inside mp4.

Closes #344.

Change-Id: I05c14df916f7b2c7ca4364ee9407e0eda4dc7a3f
2018-08-20 14:12:07 -07:00
KongQun Yang 715ed939f1 Add instructions to build on Alpine Linux
- Also fixed compilations in Alpine Linux and other flavors of Linux.
- Added container versions in docker files to always use a verified
  version.

Closes #164.

Change-Id: I949a8709e4d70c49129c9c2e8608dd78193d964c
2018-08-17 20:46:11 +00:00
KongQun Yang db076d6892 Support Fairplay in --additional_protection_systems
Issue: #245.

Change-Id: I15187c1d3463534bf5e11ff97032311bb1d0c3bf
2018-08-09 23:59:40 +00:00
KongQun Yang 36a7c7d935 Adjust timestamps in fMP4 if there is an initial composition offset
In some ISO-BMFF files, there is an initial non-zero composition offset,
but there is no EditList present.

This is against ISO-BMFF spec recommentation [1] and we believe in most
cases it is just missing the EditList.

[1] 14496-12:2015 8.6.6.1
It is recommended that such an edit be used to establish a presentation
time of 0 for the first presented sample, when composition offsets are
used.

Issue: #112.
Change-Id: I178d5ec9d8c294c9f70aac4f4dd6254c824e2255
2018-08-09 22:03:23 +00:00
KongQun Yang 416051ae65 Avoiding segmentation fault on streams without samples
An informational message is logged instead.

Fixes #446.

Change-Id: Ia3a79a16b3bdbabd5d56facf9bf011f29c9b1533
2018-08-02 17:53:17 +00:00
KongQun Yang 51d39d96a1 Add offset to tranport streams (MPEG2-TS, HLS Packed Audio)
Configurable with --transport_stream_offset_ms.

This is needed to compensate for possible negative timestamps in
inputs, which could happen on ISO-BMFF with EditLists.

Issue #112.

Change-Id: I0fce8766c9df2911b9bb859c1e54052a8ed2abfb
2018-07-26 23:20:21 +00:00
KongQun Yang 9a55d4033f Adjust timestamps in mp4 if there is an initial composition offset
In some ISO-BMFF files, there is an initial non-zero composition offset,
but there is no EditList present.

This is against ISO-BMFF spec recommentation [1] and we believe in most
cases it is just missing the EditList.

[1] 14496-12:2015 8.6.6.1
It is recommended that such an edit be used to establish a presentation
time of 0 for the first presented sample, when composition offsets are
used.

Issue: #112.
Fixes: b/110782437.

Change-Id: I23d33810ce536b09a1e22a2644828d824c1314f5
2018-07-26 23:20:21 +00:00
KongQun Yang 40ea1286b9 Add support for EditLists in ISO-BMFF
- EditLists in input files are parsed and applied to sample timestamps.
- An EditList will be inserted in the ISO-BMFF output if
  - There is an offset between the initial presentation timestamp (pts)
    and decoding timestamp (dts). Chrome, as of M67, still uses dts in
    buffered range API [1], which creates various problems when buffered
    range by pts does not align with buffered range by dts. There is
    another bug in Chrome that applies EditList to pts only [2]. This
    means that we can insert an EditList to align pts range and dts range.
  - MediaSamples have negative timestamps (e.g. for Audio Priming).

You may notice the below change on some contents:
- Some media duration is reduced by one or two frames. This is because
  EditList in the input file was ignored in the previous code, so video
  streams start with a zero dts and a non-zero pts; the smaller of dts
  and pts was used as the starting timestamp (related to the earlier
  workaround for Chrome's dts bug), so the calculated duration was
  actually a bit larger than the actual duration. Now with EditList
  applied, the initial pts is reduced to zero, so the media duration is
  also reduced to reflect the actual and correct media duration.

It may also result in negative timestamps in TS/HLS Packed Audio, which
will be addressed in a follow up CL.

Fixes #112.
Partially address b/110782437.

[1] https://crbug.com/718641, fixed but behind MseBufferByPts.
[2] https://crbug.com/354518. Chrome is planning to enable the fix for
    [1] before addressing this bug, so we are safe.

Change-Id: I59317740ad3807ca66fa74b3a18fdf7f32c96aeb
2018-07-26 23:20:21 +00:00
KongQun Yang 308b92d16e [WebVTT] support cues without payload
WebVTT cues without payload may not carry meaningful information, but it
is allowed by WebVTT specification [1]. It could also be useful
sometimes, e.g. to signal the time progression in live case.

Fixes #433.

[1] https://www.w3.org/TR/webvtt1/#types-of-webvtt-cue-payload

Change-Id: I9e31f4a3789cbdafb7667b64f4019834190ecfc0
2018-07-17 17:07:53 +00:00
Aaron Vaage a510d3aa38 Print Error and Ignore Text Samples With Bad Times
Before we had an assert that would catch if a sample had an
invalid times, however input may have bad times.

We did have a message if we saw a sample with a duration equal to
zero. This expands that check to check if the time is valid in
general and will ignore any sample that is not valid.

Fixes #425

Change-Id: I9774bfbdbd401f3016d2c345665b9973d1889db7
2018-07-09 15:25:10 -07:00
KongQun Yang 1742e03471 Drepcate --num_subsegments_per_sidx
This flag was designed for two purpose:
- Grouping fragments into subsegments, achieving three level hierarchy:
  segment < subsegment < fragment.
- Indicate whether to generate 'sidx' box in media segments (when the
  value is set to a negative number).

There are no practical use case for the first purpose. Removing it to
simplify the code and reduce the confusion.

Introduce another flag --generate_sidx_in_media_segments for the second
purpose.

Change-Id: I4be7cd42662fb324c1158b978e05768ee49dd048
2018-07-02 21:59:14 +00:00
KongQun Yang f089d1d0d4 Deprecate --mp4_use_decoding_timestamp_in_timeline
It was implemented to workaround Chromium's DTS
https://crbug.com/398130, but the workaround does not really work in
all situations.

Remove it now as we already have another workaround available.

Change-Id: I291f559d78120fb743a6679b7d927e5bbc5b6b4e
2018-07-02 21:59:01 +00:00
Aaron Vaage 1600909c4b Don't Always Start Text At Time Zero
Previously, the text padder media handler would assume that text always
started at time zero. This would work for VOD but would result with a
large pad at the start of LIVE content.

To avoid this, the text padder will use a bias to test whether or not it
thinks the content starts at zero. Right now the bias is set to be 10
minutes, but will later be configurable with a command line flag.

10 minutes was used as LIVE content will have much larger values and VOD
content should have much lower values.

Issue: #416

Change-Id: I07af15a577392fb030e36f052085cd4e667700e8
2018-06-29 23:02:22 +00:00
Aaron Vaage e0ce59aa91 Add is_key_frame in IsMediaSample Matcher
Added the key frame field to the IsMediaSample mather. All
tests that do not care about a sample being a keyframe (or not)
have been updated to use "_".

Change-Id: I44180687c58c260b6856e683d647f532227b14d5
2018-06-18 16:05:22 +00:00
Aaron Vaage fbc4952e21 Updated StreamData Matchers to Use Matchers
Updated all the stream data matcher we use in our unit tests
to allow us to use matchers in them. We are now able to use "_"
to ignore specific parameters.

With this we were able to replace the different version of
matchers for each stream data type with a single instance for
each type.

Includes updates to printing strings to the listener. Strings
now go through a "pretty" function to help make it easier to
read them in the output.

Change-Id: I146351b54fccd63ab9ec936877e6c6b30f9aa9fc
2018-06-13 15:36:22 -07:00
Aaron Vaage 30b189cb99 Make Test Util 'GetTextStreamInfo' require Time Scale
Make the text stream info factory method in media_handler_test_base
require the caller to specify the time scale.

Issue: #399
Change-Id: Ibdfb183e0aa3f4ff50edf6b58c4e9b966006c6d2
2018-06-13 17:43:35 +00:00
Aaron Vaage cc1d4b765a Set Box Definition Defaults in Header
To ensure that every variable in a box is explicitly set
every variable has been assigned a default in the header.

Change-Id: Iaa806c4058ac6621a64363a00040fbd9903c6710
2018-06-04 23:14:59 +00:00
Aaron Vaage 47f20031dd WebVtt Text to MP4 - Test That No Payloads Becomes Gaps
Text Samples with no payload should be ignored, so this adds a
test to check that samples with no payload get treated the
same as a gap.

As long as this case is true, using gaps in our other tests should
functionally be the same as using samples with no payload.

Change-Id: Ic16b240c43eda2514b537a2d938d4135638adc4e
2018-06-04 22:10:44 +00:00
Aaron Vaage e96fe3aedf WebVtt Text To MP4 - Explicitly Set Payload In Tests
Before we used the sample payload for each text sample as we were
focusing on the times rather than the contents.

As we look to add tests that rely on specific sample payloads, we
need to change the tests to explicitly set the payload for each
sample.

Change-Id: I24174686f46535cf6c2d59a18308101a3bb51c87
2018-06-04 22:10:39 +00:00
KongQun Yang 55050fe6b5 [Ad Insertion] Avoid adjusting EPT except for the first file
EPT (earliest presentation time) may be adjusted not to be lower than
the decoding timestamp (dts), but the adjustment should only be done
on the first file when there is one file per Representation per Period.
The second file and onwards should not be adjusted otherwise a GAP
would be created.

Closes #384
Closes b/78517422

Change-Id: I56771ad8fbbe6a87b832ec58854cfbf37d5f1817
2018-06-01 15:53:02 -07:00
Aaron Vaage 2c1faa71a0 WebVTT Text to Mp4 - Verify Media Sample Contents
In our text to mp4 tests, we were only checking if the times on
the samples lined-up with what we were expecting.

We want to check that text sample contents (ids, settings, and
payloads) were correctly merged into a single media sample. To
verify this, we now check if the sample ids appear in the
media sample.

Change-Id: Ica1a85a14e7b116275e3571332b2e90d7bc44c45
2018-06-01 20:43:16 +00:00
Aaron Vaage 668bae314f Add Unique Sample Ids in Text to MP4
In our text to mp4 tests, we used the same sample id for each sample,
this changes it so that each sample (within a single test) has a
unique id.

This is done in preparation to look for the ids in the created
media samples.

Change-Id: I3215a6f09279af8f40e1ce8a959e0a522a811173
2018-06-01 20:42:50 +00:00
Aaron Vaage b9dee56294 Rebuild Text WebVtt to MP4 WebVtt
The previous text to mp4 webvtt pipeline was incomplete. It
did not insert ad cues and it could only insert a segment
after a sample ended.

Now the pipeline supports ad cue insert and segment insertion
mid text sample. This required the pipeline to use the text
chunker (to split samples and insert segments) and required
a major overhaul of the text to mp4 converter.

Before the converter came before the chunker. This meant that
the converter only expected to see stream info and text samples.
Moving the converter after the cue aligner and chunker means
that the convert had to be aware of segments and cues.

The general approach is the same, however the converter will
convert the samples per-segment as the chunker will introduce
duplicate samples if a sample spans across segments.

Closes #362
Closes #382

Change-Id: I0f54a40524c36a602ad3804a0da26e80851c92fd
2018-06-01 19:49:56 +00:00
Aaron Vaage cf3fc61fbe Fix incorrect data_reference_index in TextSampleEntry
In the text sample box (for mp4) there was a value called
"data_reference_index" that was never initialized. This meant
that it took on various values can caused different results
between runs.

Change-Id: I4b18ac97ec4700f6e651b14898ef250713a4253c
2018-05-25 19:33:54 +00:00
Aaron Vaage d7dcf9c7c7 Run Clang Format on Box Definitions
Change-Id: Ibfbfe025e7b914ddfa2f7c81d419d7b4f9212554
2018-05-25 19:33:45 +00:00
Aaron Vaage 388d49cf98 Rename webvtt_output_handler files
Renamed all the files called "webvtt_output_handler*" to
"webvtt_text_output_handler*" to better reflect the class name
in them.

Change-Id: I977bab362076974a124f263bcefff716ed8b6a0f
2018-05-25 18:56:54 +00:00
Aaron Vaage b01de0bfb6 Disallow Copy and Assign WebVtt File Buffer
We should never need to copy or assign the webvtt file buffer
so this change enforces that.

Change-Id: I119865e96c0188781adbe115beb2486b1b56542a
2018-05-24 21:47:56 +00:00
Aaron Vaage d56efd147a Disallow Copy and Assign For WebVTT Output
We don't want to allow any handler to be copyable or assigned-over
so this change enforces that for the webvtt output handler.

Change-Id: Ie0d59d6dbfb7a5e00bb4dd1422cd696d1a2d6072
2018-05-24 14:46:23 -07:00
Aaron Vaage b3c148607f Simplify WebVtt Output
Before, the webvtt output handler was written so that it could
share code between a segmented and non-segmented handler. As
we are not worried about that right now, this change simplifies
the handler to just be about segmented output.

Change-Id: I29dbc4e3a4ffbeb7ea10e23db489ee74b398a6c4
2018-05-24 18:09:48 +00:00
KongQun Yang 4d8ce0ff5d Extract bitrates in ES descriptor for AAC if available
Change-Id: I1aa53b519e8751400bea6b33936cb2e7a05958dc
2018-05-22 11:59:58 -07:00
KongQun Yang 734b4161f8 Ignore unsupported audio codec in the source content
Instead of failing immediately, ignore unsupported audio codec when
parsing the source file, as there may be more than one stream in the
source file. This allows the supported streams to be packaged.

Closes #395.

Change-Id: I01005a93a19012c19065251647c9b06dd25c673a
2018-05-22 18:35:34 +00:00
KongQun Yang 317425d92f Fix TS mimetype in DASH
Change-Id: I64235d02206bda9a7c18d396b2889bb28091ab5d
2018-05-21 20:31:40 +00:00
Aaron Vaage 5bb5a58b7f Removed Unused Cue class
The Cue class was from a previous WebVTT implementation and
is not used in the current implementation. It was missed when the
other classes were removed. This change removes it.

Change-Id: I661ab3fcd80b5e5ef98b5213746b341a4028d1a1
2018-05-21 18:46:57 +00:00
Aaron Vaage df6661b93d Fixed Incorrect BOM used in WEBVTT Header
When originally implementing the webvtt parser, there was a
misunderstanding in what the BOM was suppose to be
(https://en.wikipedia.org/wiki/Byte_order_mark). This corrects the
misunderstanding.

Close #397

Change-Id: I250d392db228e5e9b86684614b57adc5d8a4e5fe
2018-05-17 17:33:31 +00:00
KongQun Yang 39beb99d6c Implemented PackedAudioWriter
Issue #342.

Change-Id: Ic1379b00e38f818460f24ad57122ca22c5b5285a
2018-05-16 21:52:18 +00:00
KongQun Yang 33c4f344e7 Implemented PackedAudioSegmenter
Per HLS specification:
https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-3.4

Issue #342.

Change-Id: Iba7fae7a9b8912bcd13ae55d25b22a5803f7f7ea
2018-05-16 21:52:11 +00:00
KongQun Yang 5965b3e136 Move TS encrypted audio setup for HLS to hls_audio_util
Change-Id: Ibbc1fe2a8013abded6df2f2f57701ec328d3e5c6
2018-05-16 01:04:14 +00:00
KongQun Yang 8333908df1 Implemented Id3Tag class to handle ID3 tag
Also switched the original code in mp4 to use the new Id3Tag class.

Change-Id: I1db2c6c6142ed98b72a432980a6a54815f1a8cc4
2018-05-16 01:04:02 +00:00
KongQun Yang b5a73fc1d5 Refactor ProtectionSystemSpecificInfo class to struct
This is in preparation of supporting entitlement license API, where
common encryption server may return concatenated PSSHs directly.

Refactored ProtectionSystemSpecificInfo into a struct containing
concatenated PSSHs. This will make it easier to pass PSSHs around.

Also, most of the time, users of ProtectionSystemSpecificInfo do
not care what is in PSSH; so moved PSSH box parsing and building out
of ProtectionSystemSpecificInfo.

b/78171767

Change-Id: I1c4d5e7e23efd2f7d4b2b9704378323112e47f00
2018-05-11 00:10:07 +00:00
KongQun Yang 2d919b5a31 Fix potential partial DASH segments during live packaging
Packager uses ThreadedIO to write media segments and manifest /
playlists. There was a possibility that media segments write being
delayed and scheduled after updating manifest / playlists.

This CL fixes the race condition.

Also added a note on how segments can be synced to cloud storage to
avoid the race condition during file sync.

Also added a live WebM test.

Fixes #386.

Change-Id: Icf9c38cdec715fa3dc2836eab1511131e129fe41
2018-05-03 09:26:23 -07:00
KongQun Yang b6f0da246f Add support for FLAC codec
Implemented according to spec:
  https://github.com/xiph/flac/blob/master/doc/isoflac.txt

Closes #345.

Change-Id: If2e277d8eac4baff5965faa0e13c44c334f6184d
2018-05-02 00:16:51 +00:00
Aaron Vaage 56c2f227ff Skip Style and Region Blocks
To ensure that we can parse content with style and region blocks,
this change updates the parser to skip those blocks so that we
can still parse the cues from a file.

Full style and region support will be added later this year.

Issue #380

Change-Id: I11b8fd862a108c27a5c67b15d4703532b44a1214
2018-04-25 20:41:10 +00:00
KongQun Yang 772aa7c93f Do not force earliest_presentation_time to 0 for VOD
Instead, the actual earliest presentation time is used except for
the first segment if there is an offset between presentation time
(pts) and decoding time (dts).

Chrome (as of v66) reports dts instead of pts in buffered ranges in
MSE API. To avoid breaking Chrome, the earliest_presentation_time
of the first segment is set to its dts as Chrome does not like negative
values for
  adjusted dts = dts + Period@start (0 for the first period)
                 - presentationTimeOffset (earliest_presentation_time).

Fixes #303.

Change-Id: I5ca80e05d5570961400499436f2bcc01f06e69e0
2018-04-09 18:39:15 +00:00
Aaron Vaage 061777db9b Add CueEvent Support To WebVtt Output
The WebVtt Output Handler did not recognize cue events. This change
allows the handler to accept the events and tell muxer listener
about them.

Issue #362

Change-Id: I7c3318b72e539adc19af587c8e213fdb0af8290b
2018-04-07 02:45:52 +00:00
Aaron Vaage 113a7d123b Don't Output Empty Text Samples
Only output text samples to webvtt text output when they have a payload.

Change-Id: I958d2b4f087209f540fa32cef002cd2cef37c65c
2018-04-03 18:29:41 +00:00
Aaron Vaage e5fe2a76d2 Created Text Padder Handler To Fill Gaps
Created a media handler to come after parsers that will handle filling
in gaps between text samples. The padder takes a min duration, and if
the samples do not cover the min duration when flushed, one last empty
sample will be injected so that the samples will go up to the min duration.

Change-Id: I88605059664d09279676edac418ff3d4990d7556
2018-04-02 23:11:26 +00:00
Aaron Vaage 8f565bf388 Change Text Sample to Use int64_t
Changed Text Sample to use int64_t so that it will use the same
type for time as Media Sample.

Change-Id: I4cfbfdc60c37bb511517993976cd1a459bdf6667
2018-03-26 20:46:58 +00:00
Aaron Vaage 2dd198a9d2 Move WebVtt Segmenter To Chunking Directory
Move the webvtt segmenter to the chunking directory so that it
can be converted to a general purpose text chunker.

Change-Id: I9ecd7ee39cb73070dab07b64f65ef24af1404813
2018-03-26 17:58:38 +00:00
Aaron Vaage 2b337e29f6 Removed WebVTT Pipeline Tests
Now that we have the end-to-end tests, we no longer need the webvtt pipeline
tests to verify that it is working.

Change-Id: I4ebec34e66eda67c40999d8802b447e2551e1fa6
2018-03-26 17:57:47 +00:00
Aaron Vaage a191c25f57 Clean Up WebVtt Parser
There were a couple of bad practices in WebVtt that needed to
be cleaned-up.

Change-Id: I0fe21e26f11141709d8d855077805fc625e6dad5
2018-03-23 14:19:52 -07:00