Skip to content

Commit

Permalink
initial DVB-I flute demux support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Apr 30, 2024
1 parent f9f7912 commit 9bde5ef
Show file tree
Hide file tree
Showing 8 changed files with 888 additions and 161 deletions.
3 changes: 3 additions & 0 deletions Changelog
Expand Up @@ -6,6 +6,9 @@
##Emscripten
- Fixes in UI

## Filters
- experimental DVB-I MABR flute demux

#04/2024: GPAC 2.4

## Emscripten|WebAssembly(WASM) support
Expand Down
23 changes: 21 additions & 2 deletions include/gpac/route.h
Expand Up @@ -2,10 +2,10 @@
* GPAC - Multimedia Framework C SDK
*
* Authors: Jean Le Feuvre
* Copyright (c) Telecom ParisTech 2017-2023
* Copyright (c) Telecom ParisTech 2017-2024
* All rights reserved
*
* This file is part of GPAC / ROUTE (ATSC3, DVB-I) demuxer
* This file is part of GPAC / ROUTE (ATSC3, DVB-I) and DVBI-Flute demuxer
*
* GPAC is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -185,6 +185,18 @@ GF_ROUTEDmx *gf_route_dmx_new(const char *ip, u32 port, const char *ifce, u32 so
*/
GF_ROUTEDmx *gf_route_dmx_new_ex(const char *ip, u32 port, const char *ifce, u32 sock_buffer_size, const char *netcap_id, void (*on_event)(void *udta, GF_ROUTEEventType evt, u32 evt_param, GF_ROUTEEventFileInfo *finfo), void *udta);

/*! Creates a new DVBI+Flute MABR demultiplexer
\param ip IP address of LCT session carrying the initial FDT
\param port port of LCT session carrying the initial FDT
\param ifce network interface to monitor, NULL for INADDR_ANY
\param sock_buffer_size default buffer size for the udp sockets. If 0, uses 0x2000
\param netcap_id ID of netcap configuration to use, may be null (see gpac -h netcap)
\param on_event the user callback function
\param udta the user data passed back by the callback
\return the demultiplexer created
*/
GF_ROUTEDmx *gf_dvbi_flute_dmx_new(const char *ip, u32 port, const char *ifce, u32 sock_buffer_size, const char *netcap_id, void (*on_event)(void *udta, GF_ROUTEEventType evt, u32 evt_param, GF_ROUTEEventFileInfo *finfo), void *udta);

/*! Deletes an ROUTE demultiplexer
\param routedmx the ROUTE demultiplexer to delete
*/
Expand Down Expand Up @@ -215,6 +227,13 @@ GF_Err gf_route_set_reorder(GF_ROUTEDmx *routedmx, Bool force_reorder, u32 timeo
*/
GF_Err gf_route_set_allow_progressive_dispatch(GF_ROUTEDmx *routedmx, Bool allow_progressive);

/*! Sets maximum number of object per session, mostly used for regulation when reading from pcap
\param routedmx the ROUTE demultiplexer
\param max_cache max number of objects per media stream in the session. If 0, no maximum applies
\return error code if any
*/
GF_Err gf_route_set_max_cache(GF_ROUTEDmx *routedmx, u32 max_cache);

/*! Sets the service ID to tune into for ATSC 3.0
\param routedmx the ROUTE demultiplexer
\param service_id ID of the service to tune in. 0 means no service, 0xFFFFFFFF means all services and 0xFFFFFFFE means first service found
Expand Down
2 changes: 1 addition & 1 deletion src/filters/in_http.c
Expand Up @@ -134,7 +134,7 @@ static GF_Err httpin_initialize(GF_Filter *filter)

server = strstr(ctx->src, "://");
if (server) server += 3;
if (server && strstr(server, "://")) {
if (server && strncmp(ctx->src, "http://groute", 13) && strstr(server, "://")) {
ctx->is_end = GF_TRUE;
return gf_filter_pid_raw_new(filter, server, server, NULL, NULL, NULL, 0, GF_FALSE, &ctx->pid);
}
Expand Down
22 changes: 18 additions & 4 deletions src/filters/in_route.c
Expand Up @@ -2,7 +2,7 @@
* GPAC - Multimedia Framework C SDK
*
* Authors: Jean Le Feuvre
* Copyright (c) Telecom ParisTech 2018-2023
* Copyright (c) Telecom ParisTech 2018-2024
* All rights reserved
*
* This file is part of GPAC / ROUTE (ATSC3, DVB-I) input filter
Expand Down Expand Up @@ -78,6 +78,7 @@ typedef struct

u32 nb_playing;
Bool initial_play_forced;
Bool evt_interrupt;
} ROUTEInCtx;


Expand Down Expand Up @@ -300,6 +301,7 @@ static GF_FilterProbeScore routein_probe_url(const char *url, const char *mime)
{
if (!strnicmp(url, "atsc://", 7)) return GF_FPROBE_SUPPORTED;
if (!strnicmp(url, "route://", 8)) return GF_FPROBE_SUPPORTED;
if (!strnicmp(url, "flute://", 8)) return GF_FPROBE_SUPPORTED;
return GF_FPROBE_NOT_SUPPORTED;
}

Expand Down Expand Up @@ -473,6 +475,7 @@ void routein_on_event(void *udta, GF_ROUTEEventType evt, u32 evt_param, GF_ROUTE
Bool drop_if_first = GF_FALSE;
Bool is_loop = GF_FALSE;
DownloadedCacheEntry cache_entry;
ctx->evt_interrupt = GF_TRUE;

//events without finfo
if (evt==GF_ROUTE_EVT_SERVICE_FOUND) {
Expand Down Expand Up @@ -726,6 +729,7 @@ static GF_Err routein_process(GF_Filter *filter)

if (!ctx->nb_playing)
return GF_EOS;
ctx->evt_interrupt = GF_FALSE;

while (1) {
GF_Err e = gf_route_dmx_process(ctx->route_dmx);
Expand All @@ -745,6 +749,7 @@ static GF_Err routein_process(GF_Filter *filter)
break;
} else if (!e) {
ctx->last_timeout = 0;
if (ctx->evt_interrupt) break;
} else if (e==GF_EOS) {
routein_set_eos(filter);
return e;
Expand All @@ -762,6 +767,7 @@ static GF_Err routein_process(GF_Filter *filter)
}
}


if (ctx->stats) {
u32 now = gf_sys_clock() - ctx->start_time;
if (now >= ctx->nb_stats*ctx->stats) {
Expand Down Expand Up @@ -793,12 +799,16 @@ static GF_Err routein_process(GF_Filter *filter)
static GF_Err routein_initialize(GF_Filter *filter)
{
Bool is_atsc = GF_TRUE;
Bool is_flute = GF_FALSE;
ROUTEInCtx *ctx = gf_filter_get_udta(filter);
ctx->filter = filter;

if (!ctx->src) return GF_BAD_PARAM;
if (!strncmp(ctx->src, "route://", 8)) {
is_atsc = GF_FALSE;
} else if (!strncmp(ctx->src, "flute://", 8)){
is_atsc = GF_FALSE;
is_flute = GF_TRUE;
} else if (strcmp(ctx->src, "atsc://"))
return GF_BAD_PARAM;

Expand Down Expand Up @@ -838,12 +848,16 @@ static GF_Err routein_initialize(GF_Filter *filter)
sep[0] = ':';
return GF_BAD_PARAM;
}
ctx->route_dmx = gf_route_dmx_new_ex(ctx->src+8, port, ctx->ifce, ctx->buffer, gf_filter_get_netcap_id(filter), routein_on_event, ctx);
if (is_flute)
ctx->route_dmx = gf_dvbi_flute_dmx_new(ctx->src+8, port, ctx->ifce, ctx->buffer, gf_filter_get_netcap_id(filter), routein_on_event, ctx);
else
ctx->route_dmx = gf_route_dmx_new_ex(ctx->src+8, port, ctx->ifce, ctx->buffer, gf_filter_get_netcap_id(filter), routein_on_event, ctx);
sep[0] = ':';
}
if (!ctx->route_dmx) return GF_SERVICE_ERROR;

gf_route_set_allow_progressive_dispatch(ctx->route_dmx, !ctx->fullseg);
gf_route_set_max_cache(ctx->route_dmx, ctx->nbcached);

gf_route_set_reorder(ctx->route_dmx, ctx->reorder, ctx->rtimeout);

Expand All @@ -853,8 +867,8 @@ static GF_Err routein_initialize(GF_Filter *filter)

if (ctx->tunein>0) ctx->tune_service_id = ctx->tunein;

if (is_atsc) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_ROUTE, ("[ROUTE] ATSC 3.0 Tunein started\n"));
if (is_atsc || is_flute) {
GF_LOG(GF_LOG_DEBUG, GF_LOG_ROUTE, ("[ROUTE] Tunein started\n"));
if (ctx->tune_service_id)
gf_route_atsc3_tune_in(ctx->route_dmx, ctx->tune_service_id, GF_FALSE);
else
Expand Down
9 changes: 8 additions & 1 deletion src/media_tools/dash_client.c
Expand Up @@ -751,6 +751,13 @@ static void gf_dash_group_timeline_setup_single(GF_MPD *mpd, GF_DASH_Group *grou
GF_LOG(GF_LOG_INFO, GF_LOG_DASH, ("[DASH] Waiting for ROUTE clock ...\n"));
return;
}
const char *root_url = strstr(group->dash->base_url+7, "groute/");
if (root_url) {
root_url = strchr(root_url+7, '/');
if (root_url) root_url++;
}
else root_url = group->dash->base_url;
if (!strstr(root_url, "://")) root_url = "./";

for (i=0; i<gf_list_count(dyn_period->adaptation_sets); i++) {
u64 sr, seg_dur_ms;
Expand Down Expand Up @@ -781,7 +788,7 @@ static void gf_dash_group_timeline_setup_single(GF_MPD *mpd, GF_DASH_Group *grou
continue;
}
u32 tpl_use_time=0;
gf_mpd_resolve_url(group->dash->mpd, rep, set, dyn_period, "./", 0, GF_MPD_RESOLVE_URL_MEDIA_NOSTART, 9876, 0, &seg_url, &sr, &sr, &seg_dur_ms, NULL, NULL, NULL, &tpl_use_time);
gf_mpd_resolve_url(group->dash->mpd, rep, set, dyn_period, root_url, 0, GF_MPD_RESOLVE_URL_MEDIA_NOSTART, 9876, 0, &seg_url, &sr, &sr, &seg_dur_ms, NULL, NULL, NULL, &tpl_use_time);

dyn_period->duration = dur;

Expand Down

0 comments on commit 9bde5ef

Please sign in to comment.