Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to treat all trun boxes as version 1 #16

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/github-dev-snap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
cmake \
-DCMAKE_BUILD_TYPE="Release" \
-DBUILD_SHARED_LIBS=1 \
-DUSE_WORKAROUND_FOR_TRUN_VERSION_0=1 \
-S . \
-B build/

Expand Down
4 changes: 4 additions & 0 deletions packager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ else()
add_compile_options(-Wno-unknown-warning-option)
endif()

if(USE_WORKAROUND_FOR_TRUN_VERSION_0)
add_definitions(-DUSE_WORKAROUND_FOR_TRUN_VERSION_0=1)
endif()

# Global include paths.
# Project root, to reference internal headers as packager/foo/bar/...
include_directories(..)
Expand Down
8 changes: 8 additions & 0 deletions packager/media/formats/mp4/box_definitions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2716,6 +2716,13 @@ bool TrackFragmentRun::ReadWriteInternal(BoxBuffer* buffer) {
RCHECK(buffer->ReadWriteUInt32(&sample_flags[i]));

if (sample_composition_time_offsets_present) {
// TODO: MediaLive produces negative composition time offsets in box version 0.
// This is a workaround for that.
#ifdef USE_WORKAROUND_FOR_TRUN_VERSION_0
int32_t sample_offset = sample_composition_time_offsets[i];
RCHECK(buffer->ReadWriteInt32(&sample_offset));
sample_composition_time_offsets[i] = sample_offset;
#else
if (version == 0) {
uint32_t sample_offset = sample_composition_time_offsets[i];
RCHECK(buffer->ReadWriteUInt32(&sample_offset));
Expand All @@ -2725,6 +2732,7 @@ bool TrackFragmentRun::ReadWriteInternal(BoxBuffer* buffer) {
RCHECK(buffer->ReadWriteInt32(&sample_offset));
sample_composition_time_offsets[i] = sample_offset;
}
#endif
}
}

Expand Down
Loading