Skip to content

Commit

Permalink
force route clock reset while init segment is not received
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Dec 18, 2023
1 parent f0ac9b8 commit 7ff157f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
5 changes: 4 additions & 1 deletion build/xcode/gpac.xcodeproj/project.pbxproj
Expand Up @@ -2344,9 +2344,9 @@
buildRules = (
);
dependencies = (
922B0FCA2A6029AD003690BB /* PBXTargetDependency */,
92C403DF2181F1ED00331F39 /* PBXTargetDependency */,
92BD5563205AB89D007C4C06 /* PBXTargetDependency */,
922B0FCA2A6029AD003690BB /* PBXTargetDependency */,
);
name = gpac;
productName = gpac;
Expand Down Expand Up @@ -3216,6 +3216,7 @@
"-lXv",
"-lX11",
"-lXext",
"-lvvenc",
"-lcaca",
);
PRODUCT_NAME = gpac;
Expand Down Expand Up @@ -3367,6 +3368,7 @@
"-lXv",
"-lX11",
"-lXext",
"-lvvenc",
"-lcaca",
);
PRODUCT_NAME = gpac;
Expand Down Expand Up @@ -3472,6 +3474,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = " -lcaca ";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand Down
12 changes: 8 additions & 4 deletions src/filters/in_route.c
Expand Up @@ -559,7 +559,7 @@ void routein_on_event(void *udta, GF_ROUTEEventType evt, u32 evt_param, GF_ROUTE
routein_send_file(ctx, evt_param, finfo, evt);
break;
}
//fallthrough
//fallthrough

case GF_ROUTE_EVT_DYN_SEG_FRAG:
//for now we only push complete files
Expand All @@ -584,10 +584,14 @@ void routein_on_event(void *udta, GF_ROUTEEventType evt, u32 evt_param, GF_ROUTE
}
#endif

if (!ctx->clock_init_seg) {
if (!ctx->clock_init_seg
//if full seg push of previsously advertized init, reset x-route-ll header
|| ((evt==GF_ROUTE_EVT_DYN_SEG) && !strcmp(ctx->clock_init_seg, finfo->filename))
) {
DownloadedCacheEntry mpd_cache_entry = gf_route_dmx_get_service_udta(ctx->route_dmx, evt_param);
if (mpd_cache_entry) {
ctx->clock_init_seg = gf_strdup(finfo->filename);
if (!ctx->clock_init_seg)
ctx->clock_init_seg = gf_strdup(finfo->filename);
sprintf(szPath, "x-route: %d\r\nx-route-first-seg: %s\r\n", evt_param, ctx->clock_init_seg);
if (evt==GF_ROUTE_EVT_DYN_SEG_FRAG)
strcat(szPath, "x-route-ll: yes\r\n");
Expand Down Expand Up @@ -650,7 +654,7 @@ void routein_on_event(void *udta, GF_ROUTEEventType evt, u32 evt_param, GF_ROUTE
}

if (evt==GF_ROUTE_EVT_DYN_SEG_FRAG) {
GF_LOG(GF_LOG_INFO, GF_LOG_ROUTE, ("[ROUTE] Pushing fragment from file %s to cache\n", finfo->filename));
GF_LOG(GF_LOG_DEBUG, GF_LOG_ROUTE, ("[ROUTE] Pushing fragment from file %s to cache\n", finfo->filename));
break;
}

Expand Down
9 changes: 9 additions & 0 deletions src/media_tools/dash_client.c
Expand Up @@ -4960,6 +4960,15 @@ static GF_Err gf_dash_download_init_segment(GF_DashClient *dash, GF_DASH_Group *
group->download_segment_index++;
}
}
//if init seg failed at tune-in, re-estimate route clock - this ensures we are always bootstraping on the last correct state
//otherwise we could init clock at segN in low latency but tune-in at segN+1, hence having one extra segment delay
else if (dash->initial_period_tunein) {
group->timeline_setup = GF_FALSE;
group->force_timeline_reeval = GF_TRUE;
dash->utc_drift_estimate = 0;
dash->route_clock_state = 1;
dash->route_low_latency = 0;
}
gf_free(base_init_url);
return e;
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/downloader.c
Expand Up @@ -2940,7 +2940,7 @@ static GF_DownloadSession *gf_dm_sess_new_internal(GF_DownloadManager * dm, cons

*e = gf_dm_sess_setup_from_url(sess, url, GF_FALSE);
if (*e) {
GF_LOG(GF_LOG_ERROR, GF_LOG_HTTP, ("[Downloader] failed to create session for %s: %s\n", url, gf_error_to_string(*e)));
GF_LOG(GF_LOG_INFO, GF_LOG_HTTP, ("[Downloader] failed to create session for %s: %s\n", url, gf_error_to_string(*e)));
gf_dm_sess_del(sess);
return NULL;
}
Expand Down

0 comments on commit 7ff157f

Please sign in to comment.