Skip to content

Commit

Permalink
Merge pull request #13 from Pluto-tv/feature/TRANS-5213-defaut-seg-dur
Browse files Browse the repository at this point in the history
feat: Add default segment duration to LivePackager config
  • Loading branch information
jedekar authored Jan 18, 2024
2 parents a8b55a0 + 79dae20 commit ad7c899
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
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 @@ -34,6 +34,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 @@ -256,7 +260,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;

packaging_params.mp4_output_params.include_pssh_in_stream = false;

Expand Down Expand Up @@ -317,7 +321,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;
packaging_params.mp4_output_params.include_pssh_in_stream = false;
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 @@ -43,7 +43,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 @@ -435,7 +434,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 @@ -604,7 +602,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

0 comments on commit ad7c899

Please sign in to comment.