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 default segment duration to LivePackager config #13

Merged
merged 5 commits into from
Jan 18, 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
2 changes: 0 additions & 2 deletions include/packager/live_packager.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ struct LiveConfig {

OutputFormat format;
TrackType track_type;
// TOOD: do we need non-integer durations?
double segment_duration_sec;

// TODO: should we allow for keys to be hex string?
std::vector<uint8_t> iv;
Expand Down
8 changes: 6 additions & 2 deletions packager/live_packager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ namespace {

using StreamDescriptors = std::vector<shaka::StreamDescriptor>;

// Shaka requires a non-zero value for segment duration otherwise it throws an error.
// For our use-case of packaging segments individually, this value has no effect.
constexpr double DEFAULT_SEGMENT_DURATION = 5.0;

const std::string INPUT_FNAME = "memory://input_file";
const std::string INIT_SEGMENT_FNAME = "init.mp4";

Expand Down Expand Up @@ -247,7 +251,7 @@ Status LivePackager::PackageInit(const Segment& init_segment,

shaka::PackagingParams packaging_params;
packaging_params.chunking_params.segment_duration_in_seconds =
config_.segment_duration_sec;
DEFAULT_SEGMENT_DURATION;

// in order to enable init packaging as a separate execution.
packaging_params.init_segment_only = true;
Expand Down Expand Up @@ -306,7 +310,7 @@ Status LivePackager::Package(const Segment& init_segment,

shaka::PackagingParams packaging_params;
packaging_params.chunking_params.segment_duration_in_seconds =
config_.segment_duration_sec;
DEFAULT_SEGMENT_DURATION;

packaging_params.mp4_output_params.sequence_number = config_.segment_number;

Expand Down
3 changes: 0 additions & 3 deletions packager/live_packager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const uint8_t kIv[]{
0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15,
};

const double kSegmentDurationInSeconds = 5.0;
const int kNumSegments = 10;

std::filesystem::path GetTestDataFilePath(const std::string& name) {
Expand Down Expand Up @@ -246,7 +245,6 @@ class LivePackagerBaseTest : public ::testing::Test {

void SetupLivePackagerConfig(const LiveConfig& config) {
LiveConfig new_live_config = config;
new_live_config.segment_duration_sec = kSegmentDurationInSeconds;
switch (new_live_config.protection_scheme) {
case LiveConfig::EncryptionScheme::NONE:
break;
Expand Down Expand Up @@ -369,7 +367,6 @@ TEST_F(LivePackagerBaseTest, CustomMoofSequenceNumber) {
live_config.format = LiveConfig::OutputFormat::FMP4;
live_config.track_type = LiveConfig::TrackType::VIDEO;
live_config.protection_scheme = LiveConfig::EncryptionScheme::NONE;
live_config.segment_duration_sec = kSegmentDurationInSeconds;

for (unsigned int i = 0; i < kNumSegments; i++) {
live_config.segment_number = i + 1;
Expand Down
Loading