Commit Graph

735 Commits

Author SHA1 Message Date
Cosmin Stejerean 1337e86597
style: cleanup unused includes and use consistent <> for external code (#1267) 2023-10-09 16:21:41 -07:00
Cosmin Stejerean 6b68c138cc
feat: port demuxer and app to cmake (#1260)
Related to issue #1047

After this it should be possible to build a working `packager` application from the `cmake` branch. Some further logging improvements may be needed to get full parity with the `main` branch in terms of ability to do verbose debug logging, but other than that everything is expected to work.
2023-09-08 17:44:17 -07:00
Cosmin Stejerean 274c885253 Merge branch 'main' into cmake 2023-09-03 10:01:08 -07:00
Cosmin Stejerean 3afe761637
feat: port media/formats/* to cmake (#1258)
Issue #1047
2023-08-31 16:59:46 -07:00
Caitlin O'Callaghan f264befe86
feat: Write colr atom to muxed mp4 (#1261)
This PR is an extension of the full AV1 codec string feature: [PR
1205](https://github.com/shaka-project/shaka-packager/pull/1205) and
relates to [Issue
1007](https://github.com/shaka-project/shaka-packager/issues/1007) and
[Issue
1202](https://github.com/shaka-project/shaka-packager/issues/1202).

As per the AV1 spec, the codec string may contain optional color values.
These color values are critical for detecting HDR video streams - see
[Issue
1007](https://github.com/shaka-project/shaka-packager/issues/1007).
Color information is extracted from the input mp4's `colr` atom and used
to generate the full AV1 codec string. This PR preserves the color
information by writing the `colr` atom to the muxed mp4.

**References**:
- [AV1 Codec ISO Media File Format
Binding](https://aomediacodec.github.io/av1-isobmff/#codecsparam)
- [AV1 Bitstream & Decoding Process
Specification - Section 6.4.2 Color config semantics (page
117)](https://aomediacodec.github.io/av1-spec/av1-spec.pdf)
- [QuickTime File Format
Specification](https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-125526)
2023-08-29 18:46:19 -07:00
Cosmin Stejerean ab8485c5b7
feat: port HLS module to CMake (#1238)
related to issue #1047
2023-08-21 18:41:18 -07:00
Cosmin Stejerean 682ac3c990 Merge branch 'main' into cmake 2023-08-21 17:22:35 -07:00
Prakash Duggaraju dcf32258ff
fix: Fix handling of non-interleaved multi track FMP4 files (#1214)
Do not assume that each fragment contains all tracks. 
Use track id instead of index to pick the correct timestamp.

Fixes #1213
2023-08-21 16:34:32 -07:00
Cosmin Stejerean 793518c73d Merge branch 'main' into cmake 2023-08-04 22:23:26 -07:00
Cosmin Stejerean 96acd1ecfd
feat: convert mpd module to cmake (#1234)
Related to issue #1047
2023-08-04 20:45:21 -07:00
Caitlin O'Callaghan cc9a691aef
feat: Generate the entire AV1 codec string when the colr atom is present (#1205)
As per the AV1 spec, the codec string may contain optional color values.

This extracts the missing color information from the mp4 `colr` atom, if
present, and generates the full AV1 codec string. 

Closes #1007
2023-08-04 09:00:59 -07:00
Cosmin Stejerean 97cf7c0a5b Merge branch 'main' into cmake 2023-08-02 12:38:01 -07:00
Joey Parrish ba51270b0e
feat: Port app/job_manager to cmake and absl (#1249)
Issue #1047 (cmake)
Issue #346 (absl)
2023-07-21 12:41:49 +02:00
sr90 520926c27a
fix(MP4): Add compatible brand dby1 for Dolby content. (#1211)
This PR adds dby1 compatible brand to dolby content as per
https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby_vision_bitstreams_within_the_iso_base_media_file_format_dec2017.pdf
2023-07-18 19:50:33 -07:00
Joey Parrish 4515a9834d Merge branch 'main' into cmake 2023-07-18 16:20:45 -07:00
Joey Parrish 86a183a847
test: Use a random HTTP port for web server tests (#1248)
This will pick a random HTTP port for the test web server, and retry up
to 10 times if the chosen port number is in use.
2023-07-18 16:19:52 -07:00
Joey Parrish 5a2571b9bc
fix: Fix local files with UTF8 names (#1246)
This fixes our use of std::filesystem to interpret all paths names as
UTF8. Before this, UTF8 paths did not work correctly in all cases.

This also adds a new unit test to cover this case.

On Windows, it is critical that a UTF8 locale be set at runtime.
Applications linking with Packager as a library should call setlocale(),
and the Packager frontends now do this automatically after converting
wide character arguments into narrow strings.

Closes #652
2023-07-18 11:59:21 -07:00
Joey Parrish c29c03c6e3
test: Fix bad assertions in formats/mp4 and formats/mp2t tests (#1247)
PR #1242 introduced some bad assertions that went unnoticed because we
are not yet building those modules in the cmake branch. This fixes those
so that ASSERT_ macros are not used in non-void functions, and so that
assumptions about a successful parse are always after an ASSERT_ that
the data was loaded properly.

All ASSERT_ macros from #1242 were audited, and the others were all
fine.
2023-07-18 11:30:05 -07:00
Joey Parrish 868a8c5d8e
ci: Collect and report test results (#1244)
All gtest-based tests should now use add_gtest. Results from these tests
will be surfaced more prominently in GitHub Actions. Before this, it was
hard to find test failures in the log.
2023-07-17 16:11:41 -07:00
Joey Parrish 60fb057f1a
test: Avoid crashing a test executable (#1242)
LOG(FATAL) aborts the executable, which means gtest can't write any
reports it might be configured to write when tests are complete. This
will interfere with reporting.

This converts the only use of LOG(FATAL), which was in
ReadTestDataFile(), to LOG(ERROR). This also updates test cases to avoid
crashing when ReadTestDataFile() returns an empty buffer.
2023-07-17 13:16:22 -07:00
Joey Parrish 899f763dd7
test: Fix data directory computation (#1239)
The `__FILE__` macro does not always get you an absolute path, so our
assumptions about it in test_data_util.cc were flawed.

If `foo.c` references `__FILE__`, something like `gcc -c foo.c`, will
define `__FILE__` as `"foo.c"`. If you use `gcc -c /path/to/foo.c`, then
`__FILE__` will be `"/path/to/foo.c"`.

The Ninja generator for CMake only generates absolute paths for source
files in certain CMake versions. (Exact range unknown.) Rather than
require newer CMake versions and depend on CMake's Ninja generator
maintaining the latest behavior forever, set the macro TEST_DATA_DIR to
point to the test data folder. This is consistent and never depends on
unspecified behavior.

This change will allow the use of the Ninja generator with older
versions of CMake, as found in most of our Docker builds.
2023-07-17 10:06:10 -07:00
Joey Parrish 8bf2d45424
fix: Fix compilation on Arch Linux (#1233)
- Update protobuf to v23.4, to fix the cstdint error on Arch Linux, and
  make some related changes:
   - Silence additional compiler warnings for the new protobuf
- Update absl to 20230125.3, to support the protobuf update, and make
  some related changes:
   - Silence additional compiler warnings for the new protobuf
   - Replace GOOGLE_CHECK_OK with ABSL_CHECK_OK
   - Replace GUARDED_BY with ABSL_GUARDED_BY
 - Update other instances of cstdint missing in our own code
- Always pull the latest docker images, to avoid stale results when your
  workstation has pulled an older image at the same label
2023-07-14 12:40:12 -07:00
Cosmin Stejerean 86bf6cf3cd
feat: Cmake port of Media crypto (#1221)
Rebasing #1148 on top of current cmake branch

Related to #1047

---------

Co-authored-by: Bartek Zdanowski <bartek.zdanowski@gmail.com>
Co-authored-by: Joey Parrish <joeyparrish@google.com>
2023-07-14 08:19:01 -07:00
Joey Parrish af98d48726
fix: Fix flush/close semantics for HTTP files, improve testing (#1232)
All HTTP-based tests now use an embedded test server instead of
httpbin.org, which makes them much faster and more reliable.

These more reliable tests also exposed some issues that began recently
with PR #1201.  HttpFile's Flush() semantics were different than those
documented for files in general.  Flush() used to close the file for
uploading, so that no further writes were allowed, but the documentation
stated that it would only flush data to its destination.  PR #1201
brought HttpFile's Flush() in line with the docs, but gave us no way to
terminate a chunked upload.

This adds a new method to File called CloseForWriting(), which
terminates a chunked upload for HttpFile.  The only other implementation
that does anything is UdpFile, which uses the socket library function
shutdown() to terminate writes while allowing reads.

This also tweaks HttpFile::CloseWithStatus() so that it will not
generate an error if the file is closed before the HTTP response is
written to the download cache.

This modifies the test HttpFileTest.MultipleWrites so that the file is
Flushed after each chunk.  This adds test coverage for the changes
introduced in PR #1201.

Fixes #1224 (missing test coverage for HttpFile::Flush)
2023-07-13 18:55:48 -07:00
Joey Parrish d4fcfb2f4f
test: Add Mongoose embedded HTTP server (#1231)
This adds Mongoose as a third-party library, and builds on top of that
an embedded HTTP server for our unit tests.

We are using a fork of Mongoose pending the merging of this PR:
https://github.com/cesanta/mongoose/pull/2301

The embedded web server will make our HTTP-based tests independent of
httpbin.org, which will make them quick and reliable.
2023-07-13 16:36:42 -07:00
Cosmin Stejerean 8d3b2c66b6
feat: port media/event to CMake (#1222)
Rebasing #1155 and applying some fixes. Had to comment out the
`mpd_notify_muxer_listener_unittest` because it depends on
`MockMpdNotifier` from `mpd/base` which has not been ported yet. Can
bring this test back once that has been ported.

Related to #1047

---------

Co-authored-by: Carlos Bentzen <carlos.bentzen@bitmovin.com>
Co-authored-by: Joey Parrish <joeyparrish@google.com>
2023-07-13 16:25:42 -07:00
Joey Parrish 3a551f428f
test: Revert "Retry HTTP file tests on temporary httpbin failure" (#1230)
This reverts commit 2e349845c6 from PR
#1203.

We are moving away from httpbin.org for testing, and this revert will
make subsequent changes to the tests easier to read.
2023-07-13 15:55:36 -07:00
xyb dab165d3e5
fix: Fix failure on very short WebVTT files (#1216)
Fix a bug that if the webvtt file is very short, e.g. only contains one
block

    WEBVTT

    00:00:00.500 --> 00:00:02.000
    The Web is always changing

shaka packager will report error: "Packaging Error: 6 (END_OF_STREAM)".

Fixes #1217
2023-07-12 09:07:07 -07:00
Joey Parrish 98490edc5f Merge remote-tracking branch 'upstream/main' into cmake 2023-07-05 19:51:52 -07:00
Carlos Bentzen ee0922edf0
feat: port media/chunking to CMake (#1223)
Port media/chunking to CMake

Related to #1047
2023-07-05 15:18:36 -07:00
Marcus Spangenberg 494769ca86
fix: TTML generator timestamp millisecond formatting (#1179)
Fix bug where milliseconds were formatted with two digits instead of
three, resulting in incorrect timestamps in TTML cues.

Fixes #1180
2023-07-05 14:28:57 -07:00
Joey Parrish 2e349845c6
test: Retry HTTP file tests on temporary httpbin failure (#1203) 2023-05-01 16:56:46 -07:00
Bartek Zdanowski 901013c34e
feat: CMake port media/trick_play (#1146)
Issue #1047 (CMake porting)

---------

Co-authored-by: Joey Parrish <joeyparrish@google.com>
2023-05-01 14:57:40 -07:00
Carlos Bentzen 56d3304045
feat: port media/formats/webm to CMake (#1147)
Issue #1047 (CMake port)

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-12-16 21:40:00 -08:00
Carlos Bentzen e9bf0c6de4
feat: port media/codecs to CMake (#1143)
Issue #1047 (CMake port)
Issue #346 (absl port)
2022-12-15 16:53:36 -08:00
Bartek Zdanowski 14a708d009
feat: CMake port media/replicator (#1144)
Issue #1047 (CMake porting)
2022-11-30 12:01:25 -08:00
Bartek Zdanowski 5d52d5e73c
feat: CMake port media/origin (#1145)
Issue #1047 (CMake porting)
2022-11-30 09:43:58 -08:00
Joey Parrish b1095f6bc3
feat: port media/base (#1127)
This removes all chromium dependencies from media/base/ and completes
the build system in CMake.

The ClosureThread class and its classes were removed, as they were
specific to chromium base. ClosureThread has been replaced by
std::thread.

The byte-swapping utilities in network_util.cc have been removed and
replaced with absl.

generate_unique_temp_path() was split out of file_unittest.cc into
file_test_util.cc, where other test suites could make use of it.

WARN_UNUSED_RESULT was replaced with the C++ standard attribute
[[nodiscard]].

The base::Clock interface was replaced with a typedef for a function
pointer that returns the current time.

This re-enables the tests in http_key_fetcher_unittest.cc by using
httpbin.org.

Issue #1047 (CMake porting)
Issue #346 (absl porting)
2022-11-04 15:46:41 -07:00
Joey Parrish 0ee4af438d Merge branch 'main' into cmake 2022-11-03 07:58:47 -07:00
Joey Parrish afd5fec7cd
feat: Replace arraysize with std::size (#1129)
This does not depend on absl, which frees macros.h from any library deps
that would make the CMake dependency tree more complicated. This also
fixes build errors in some environments.
2022-11-03 07:21:46 -07:00
Joey Parrish 7b33f2065f
feat: Port AES and RSA crypto to mbedtls (#1119)
mbedtls works very differently from BoringSSL, and many changes had to
be made in the details of AES decryption to accomodate this.

Beyond the basic changes required for mbedtls, part of the CTS padding
implementation had to be rewritten. I believe this is because of an
assumption that held for BoringSSL, but not for mbedtls. I was unable to
determine what it was, so I rewrote the CTS decryption using reference
materials. After this, tests passed.

The deterministc PRNG I used with mbedtls in the RSA tests differs
somewhat from the old one, so the expected vectors had to be
regenerated. The old determinstic tests were also disabled, and are now
re-enabled.

Since cryptography is sensitive code, and because there were far more
changes needed here than just updating some headers and utility function
calls, this has been split into its own PR for separate review from the
rest of the media/base porting work.

Issue #1047 (CMake porting)
Issue #346 (absl porting)
2022-11-02 08:34:06 -07:00
Bartek Zdanowski b221aa9caf
fix: Parse one frame mpeg-ts video (#1015)
Closes #1013

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-10-27 20:22:17 -07:00
Bartek Zdanowski ab8ab12d09
fix: PTS diverge DTS when DTS close to 2pow33 and PTS more than 0 (#1050)
Fixes #1049

Co-authored-by: Joey Parrish <joeyparrish@users.noreply.github.com>
2022-10-27 14:21:03 -07:00
Joey Parrish a9a4f0d52c
feat: port media/test (#1116)
Rewrite test_data_util.cc to locate files relative to the source file
itself, rather than using a service from chromium `base::`.

Issue #1047 (CMake porting)
Issue #346 (absl porting)
2022-10-25 09:15:54 -07:00
Joey Parrish 64993873c4
fix: Fix status library headers and move test (#1118)
For some reason, the status util unittest was in media/base/ instead of
status/

The broken headers in the status library were not obviously broken until
media/base/ porting started, and they were used for the first time.

Issue #1047 (CMake porting)
2022-10-24 19:09:10 -07:00
Joey Parrish 7ed49d4403
feat: port media/public/ (#1117)
Issue #1047 (CMake porting)
2022-10-24 19:08:37 -07:00
Geoff Jukes 84ba4afc51 feat: Add xHE-AAC support (#1092)
Note:
* An xHE-AAC capable encoder will auto adjust the user-specified SAP/RAP
  value to the allowed grid where SAP/RAPs can occur.
e.g.: `-rapInterval 5000` (5s) may result in actual SAPs/RAPs every
4.984s.
* To ensure SAP/RAP starts a new segment, Shaka needs to executed with a
  "--segment_duration" is less than or equal to that adjusted value.
* If every SAP/RAP should trigger a new segment, just set the segment
  length to a very low value e.g.: `--segment_duration 0.1`
2022-10-18 10:16:55 -07:00
Geoff Jukes 5d998fca7f
feat: Add xHE-AAC support (#1092)
Note:
* An xHE-AAC capable encoder will auto adjust the user-specified SAP/RAP
  value to the allowed grid where SAP/RAPs can occur.
e.g.: `-rapInterval 5000` (5s) may result in actual SAPs/RAPs every
4.984s.
* To ensure SAP/RAP starts a new segment, Shaka needs to executed with a
  "--segment_duration" is less than or equal to that adjusted value.
* If every SAP/RAP should trigger a new segment, just set the segment
  length to a very low value e.g.: `--segment_duration 0.1`
2022-10-18 10:14:31 -07:00
Joey Parrish 1131bf7eea
chore: Mass-update copyright headers (#1086)
Closes #1076
2022-08-26 08:44:59 -07:00
Vishal Shah b9d477b969
fix: webvtt single cue do not fail on EOS (#1061)
While Parsing cue body check for the block size. 
If it's the last block do not error if it doesn't have a newline.

Fixes #1018
2022-06-02 09:27:47 -07:00