Commit Graph

552 Commits

Author SHA1 Message Date
KongQun Yang 0fe31423cb Multi-DRM flag refactoring
- Added flag --additional_protection_systems to specify multi-DRM
  options.
- Deprecated old multi-DRM flags: --generate_widevine_pssh
                                  --generate_playready_pssh
                                  --generate_common_pssh

Issue: #245.

Change-Id: If926bc9d481e941aa2269b6672bf2ba5411c3a50
2018-08-09 22:01:46 +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 bd98436241 Normalize crypto_period_index to 0 for negative timestamp
It is possible to see a negative timestamp if the input mp4 file
contains EditList.

Also increase the queue size for EncryptionKey to be able to handle
smaller crypto_period_duration during testing.

Change-Id: I68278bf482d6662e771d9b80f4d5409605065aac
2018-07-31 12:56:33 -07: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 9a26ec1e83 Ignore extra Ad cues at the end of the stream
They will result in empty DASH representations, which is not spec
compliant.

For text, if the cue is before the max end time, it will still be
dispatched as the text samples intercepted by the cue can be split into
two at the cue point.

Bug: 111359775.

Change-Id: I55c2025c4e9d64c88e6a685c0cf3024a0cc4a6d8
2018-07-24 18:46:30 +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
KongQun Yang b4ae6561f8 Cleanup packager_test.py
- Support decryption verification in _CheckTestResults
- Allow diff_files in _CheckTestResults
- Update all functional tests to use _CheckTestResults

Change-Id: I3f9c02f35808eba787becf9b1e5c1ce9238f943e
2018-07-16 19:13:02 +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
KongQun Yang 571ee24f3e Use PTS instead of DTS in ChunkingHandler
DTS was used in ChunkingHandler. As a result, SegmentInfo contained
timestamp in DTS. MP4Muxer has a logic to change SegmentInfo to use
PTS but not in other muxers.

Benefits of using PTS in ChunkingHandler:

- De-dup the redundant logic in MP4Muxer
- Ensure consistent behavior in different output containers
- Consistent with other timestamps, e.g. Ad Cue timestamps

Issue #413

Change-Id: Ib671badf144e0c0866d60f4ff0ac0cbbdd33817e
2018-07-02 21:58:45 +00:00
Aaron Vaage 5f072e3b08 Start Segments At First Sample in Text Chunker
We always assumed that text stream started at zero in the text chunker.
This meant that if the text stream started later than zero (like in a
live stream) we would generate a lot of empty segments.

Instead the text chunker will assume that segments should be adjusted
to align with multiple of segment duration. The text chunker will assume
that an earlier component in the pipeline (i.e. text padder) will ensure
that the first sample has the time that we want to start segments at
(even it needs to add an empty sample).

Issue #416

Change-Id: Ie45844354d6e9448787cae896841b5ab31721ed6
2018-07-02 17:57:10 +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
KongQun Yang b4256bf040 [Cleanup] Use int64_t for time for consistency
Change-Id: I408f3fe7c98320be4e43ca2a5bcb9b22cc8a2012
2018-06-29 22:53:06 +00:00
KongQun Yang d1caa29c8d Disregard trailing null bytes when locating RBSP stop bit
This is a more faithful implementation of more_rbsp_data().

There could be trailing null bytes in NAL units. This isn't valid per
H264 specification, but the referenced bug includes a sample where the
PPS in the avcC record includes a trailing null byte.

Workaround the problem so packager does not fail.

A similar problem is workarounded in Chrome:
https://codereview.chromium.org/1107593004

Closes #418

Change-Id: I28cb8a9371945dc094f766c3e559d7a66859b451
2018-06-29 20:24:15 +00:00
Aaron Vaage 0734ba998b Remove Old Cue Insertion Code
When we built the cue alignment media handler, we did not remove
the old solution.

This change removes all the code for the old solution.

Change-Id: I851b284c449c7d25aaabc2f55df5579ba7b5aad1
2018-06-21 18:47:04 +00:00
Aaron Vaage 5a9a49034b Merge Create and Dispatch in Cue Alignment Tests
Originally the create and dispatch of stream data in the cue
alignment tests were separate to improve readability. The idea was
to separate building each stream and dispatching the streams muxed
together would make it easier to understand the streams.

However, coming back to the code, this did not hold up as it took just as
long to understand the code. So merging the two together allows for the
code to be more concise.

Change-Id: I77f6bb67e7fb0ca7af0553c3baf07082770da74c
2018-06-21 18:27:01 +00:00
Aaron Vaage b5cdfee73f Update "One to many" example in Media Handler
In the media handler there is an example of what a one-to-many media
handler would be. It used the trick play handler as an example, but that
handler is now a one-to-one media handler. Changed the example to use the
replicator media handler.

Change-Id: I26908c6e27ea4a697a19c0fa0179c60842a449d2
2018-06-21 18:26:42 +00:00
Aaron Vaage 4408718b5b Move ChainHandlers to MediaHandler
Made ChainHandlers to MediaHandler::Chain so that it can be used in our
test code as well. After all it is a pretty helpful function.

Change-Id: I8d83ee184052cd9fa9b37f2741c96f3223d5ab48
2018-06-21 09:52:04 -07:00
Aaron Vaage eb2385491c Run clang-format over MediaHandler
Ran clang-format over media_handler.cc and media_handler.h so that
later changes won't update the formatting as much.

Change-Id: I2db4f9f4e8a66fca1e1418ab99b283a0e4a70e4c
2018-06-20 16:28:47 -07:00
Aaron Vaage 0efc7612ed Fixed Copy and Assign in MediaHandlerGraphTestBase
The copy and assign in MediaHandlerGraphTestBase referred to the wrong
types. This changes them to refer to the correct types.

Change-Id: I165c9a1da39b49adf41e7c35ae3e4a0b9ecfa838
2018-06-20 16:28:47 -07:00
Aaron Vaage b980cf3019 Reduce What We Check in Cue Alignment Tests
Reduce which variables we check in the cue alignment tests by replacing
the less important variables with "_".

Change-Id: Id8770b5f2045ad5c8ac6eee54d6a291d933a4b6f
2018-06-20 17:29:36 +00:00
Aaron Vaage 8d800446f3 Align Trick Play Tests With Other Media Tests
We have adopted some new standards for how we are writing the media
unit tests. This change goes through the trick play tests and
updates them to be more inline with how we are doing new media
tests.

This include using "_" for parameters that are not the focus of the
tests (used in the EXPECT calls).

This includes wrapping Dispatch calls so that the test bodies can
be more readable.

Change-Id: Iab4b1ce67666b6c8a4a821db1a8f4369cd366dc3
2018-06-19 19:48:18 +00:00
Aaron Vaage bf29257e48 Added IsVideoStreamInfo Test Matcher
Added a matcher for Video Streams. This will allow us to use a general
matcher in tests for video specific fields.

Change-Id: I91b9aebd66be37ec6d5f09b762263fafaef854c2
2018-06-19 19:48:10 +00:00
Aaron Vaage 26bb50640c Added StreamTypeToString
Added a StreamTypeToString function in StreamInfo (where stream type is
defined) so that we can print the type in a more readable way.

Change-Id: Icb1d10f5a72dca314d9bdf07e9cd0c0a185bd791
2018-06-19 10:12:47 -07:00
Aaron Vaage 740724f8cf Run 'clang-format' over stream_info
Ran 'clang-format' over stream_info.h and stream_info.cc so that
later changes can focus on the actual changes and not the formatting.

Change-Id: I8a75fe0f88db533f4a811d65dabd023033f07bda
2018-06-19 09:58:29 -07: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 440adb3086 Remove Text Time Scale Assumption From Cue Alignment
In the cue aligner, we assumed that all text will be in milliseconds.
This was the last place with that assumption. This change removes that
assumption and uses the stream info's time scale.

Issue #399

Change-Id: Ie21bf27148e020bd85111dcace0bbdff3419c1ac
2018-06-13 13:44:21 -07:00
Aaron Vaage dbce84f3ea Remove Time Scale Assumptions From Text Chunker
Before, the text chunker would assume that all text streams were in
MS, which is not a safe assumption to make.

This changes it to take the time scale from StreamInfo and work
natively with scaled time units.

This required updating the tests. While doing so the tests were
rewritten with the goal to make them easier to read.

Closes: #399

Change-Id: Ib792ad306f40d749763418cde645337913a6046b
2018-06-13 17:43:49 +00: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
KongQun Yang 6e4820eedc [Ad Insertion] Support one file per Representation per Period
Allow the output file to contain template identifiers like $Number$,
$Time$ etc. Unlike the actual template used in SegmentTemplate, the
identifiers in output will be populated before pushing to the DASH
manifest.

Issue: #384

Change-Id: Ife1caadb6fccd32167fa1bc83fe2afcb2d2ad087
2018-05-31 23:59:21 +00:00
KongQun Yang 192ef2a0ac Update MuxerListeners to support multiple OnMediaStart/End
This is needed to support one file per representation per period where
there will be multiple content files generated.

Issue: #384

Change-Id: Ib7af750edf864d99075b8da4f3640217a5a94302
2018-05-25 20:43:34 +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 b69eb49f77 Add Missing ASSERT_OK Calls in Cue Alignment Tests
The SetUpAndInitialize function returns a status. We were not
asserting that it return an OK status. This change adds the
missing ASSERT_OK calls.

Change-Id: I044f60c0450d46fc0f6495319b1ed7ef8ab6e794
2018-05-24 22:14:07 +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