Skip to content

Commit

Permalink
allow fragment identifiers in mp4box dash for non-isobmf input - cf #…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed May 18, 2022
1 parent 2d46b29 commit 8595ef8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
34 changes: 25 additions & 9 deletions src/media_tools/dash_segmenter.c
Expand Up @@ -160,7 +160,7 @@ void gf_dasher_clean_inputs(GF_DASHSegmenter *dasher)
{
gf_list_reset(dasher->inputs);
if (dasher->fsess) {
gf_fs_print_unused_args(dasher->fsess, "smode");
gf_fs_print_unused_args(dasher->fsess, "smode,tkid");
gf_fs_del(dasher->fsess);
dasher->fsess = NULL;
}
Expand Down Expand Up @@ -900,6 +900,7 @@ static GF_Err gf_dasher_setup(GF_DASHSegmenter *dasher)

for (i=0; i<count; i++) {
u32 j;
char szSourceID[100];
GF_Filter *src = NULL;
GF_Filter *rt = NULL;
const char *url = NULL;
Expand All @@ -921,15 +922,30 @@ static GF_Err gf_dasher_setup(GF_DASHSegmenter *dasher)
//if source is isobmf using extractors, we want to keep the extractors
e = gf_dynstrcat(&args, "smode=splitx", ":");

szSourceID[0] = 0;
if (frag) {
if (!strncmp(frag+1, "trackID=", 8)) {
sprintf(szArg, "tkid=%s", frag+9 );
} else {
sprintf(szArg, "tkid=%s", frag+1);
char *frag_val;
u32 fID = 0;
if (!strncmp(frag+1, "trackID=", 8)) frag_val = frag + 9;
else frag_val = frag + 1;

if (sscanf(frag_val, "%u", &fID)!=1)
fID=0;
//ID
if (fID) {
sprintf(szSourceID, "PID=%s", frag_val);
}
//media type
else {
sprintf(szSourceID, "%s", frag_val);
}
//we need tkid for demuxers able to fetch specific tracks (eg isobmf)
sprintf(szArg, "tkid=%s", frag_val);
e |= gf_dynstrcat(&args, szArg, ":");
} else if (di->track_id) {
sprintf(szArg, "tkid=%d", di->track_id );
sprintf(szSourceID, "PID=%d", di->track_id);
//we need tkid for isobmf
sprintf(szArg, "tkid=%d", di->track_id);
e |= gf_dynstrcat(&args, szArg, ":");
}

Expand Down Expand Up @@ -1080,7 +1096,7 @@ static GF_Err gf_dasher_setup(GF_DASHSegmenter *dasher)

if (!di->filter_chain) {
//assign this source
gf_filter_set_source(dasher->output, src, NULL);
gf_filter_set_source(dasher->output, src, szSourceID[0] ? szSourceID : NULL);
continue;
}
//create the filter chain between source (or rt if it was set) and dasher
Expand Down Expand Up @@ -1129,7 +1145,7 @@ static GF_Err gf_dasher_setup(GF_DASHSegmenter *dasher)
}
}
if (prev_filter) {
gf_filter_set_source(dasher->output, prev_filter, NULL);
gf_filter_set_source(dasher->output, prev_filter, szSourceID[0] ? szSourceID : NULL);
}
}

Expand Down Expand Up @@ -1233,7 +1249,7 @@ GF_Err gf_dasher_process(GF_DASHSegmenter *dasher)
GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("\n"));

if (dasher->no_cache) {
if (!e) gf_fs_print_unused_args(dasher->fsess, "smode");
if (!e) gf_fs_print_unused_args(dasher->fsess, "smode,tkid");
gf_fs_del(dasher->fsess);
dasher->fsess = NULL;
}
Expand Down

0 comments on commit 8595ef8

Please sign in to comment.