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

add #EXT-X-INDEPENDENT-SEGMENTS to hls manifests #606

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions vod/hls/m3u8_builder.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// constants
static const u_char m3u8_header[] = "#EXTM3U\n";
static const u_char m3u8_footer[] = "#EXT-X-ENDLIST\n";
static const u_char m3u8_independent_segments[] = "#EXT-X-INDEPENDENT-SEGMENTS\n";
static const char m3u8_stream_inf_video[] = "#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=%uD,RESOLUTION=%uDx%uD,FRAME-RATE=%uD.%03uD,CODECS=\"%V";
static const char m3u8_stream_inf_audio[] = "#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=%uD,CODECS=\"%V";
static const char m3u8_iframe_stream_inf[] = "#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=%uD,RESOLUTION=%uDx%uD,CODECS=\"%V\",URI=\"";
Expand Down Expand Up @@ -423,6 +424,11 @@ m3u8_builder_build_index_playlist(
}
}

if (media_set->segmenter_conf->align_to_key_frames)
{
result_size += sizeof(m3u8_independent_segments) - 1;
}

// allocate the buffer
result->data = vod_alloc(request_context->pool, result_size);
if (result->data == NULL)
Expand Down Expand Up @@ -522,6 +528,11 @@ m3u8_builder_build_index_playlist(
conf->m3u8_version,
segment_durations.items[0].segment_index + 1);

if (media_set->segmenter_conf->align_to_key_frames)
{
p = vod_copy(p, m3u8_independent_segments, sizeof(m3u8_independent_segments) - 1);
}

// write the segments
for (cur_item = segment_durations.items; cur_item < last_item; cur_item++)
{
Expand Down Expand Up @@ -1008,6 +1019,11 @@ m3u8_builder_build_master_playlist(

result_size = sizeof(m3u8_header);

if (media_set->segmenter_conf->align_to_key_frames)
{
result_size += sizeof(m3u8_independent_segments) - 1;
}

max_video_stream_inf =
sizeof(m3u8_stream_inf_video) - 1 + 5 * VOD_INT32_LEN + MAX_CODEC_NAME_SIZE +
MAX_CODEC_NAME_SIZE + 1 + // 1 = ,
Expand Down Expand Up @@ -1095,6 +1111,11 @@ m3u8_builder_build_master_playlist(
// write the header
p = vod_copy(result->data, m3u8_header, sizeof(m3u8_header) - 1);

if (media_set->segmenter_conf->align_to_key_frames)
{
p = vod_copy(p, m3u8_independent_segments, sizeof(m3u8_independent_segments) - 1);
}

if (adaptation_sets.count[ADAPTATION_TYPE_AUDIO] > 1)
{
// output alternative audio
Expand Down