Skip to content

Commit

Permalink
refined commits d178fe4 and 7dc0aca
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlf committed Apr 13, 2024
1 parent 875ab93 commit 7a3eca9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
7 changes: 4 additions & 3 deletions src/filter_core/filter.c
Expand Up @@ -3855,16 +3855,17 @@ static void gf_filter_remove_local(GF_Filter *filter, GF_FSTask *task)
if (!filter) return;

gf_mx_p(filter->tasks_mx);
//check the sources for filter does not have any pending PID init task or PID configure task
//this avoids deleting the filter before a new filter is inserted at the same source, triggering
//destruction of the chain
//we don't check for any other pending connections at the session level
for (i=0; i<filter->num_input_pids; i++) {
GF_FilterPidInst *pidi = gf_list_get(filter->input_pids, i);
if (pidi->pid->init_task_pending || pidi->pid->filter->out_pid_connection_pending) {
has_pending=GF_TRUE;
break;
}
}
if (!has_pending) {
has_pending = gf_filter_connections_pending(filter);
}

if (has_pending) {
if (task) {
Expand Down
7 changes: 7 additions & 0 deletions src/filter_core/filter_pid.c
Expand Up @@ -1207,6 +1207,13 @@ static GF_Err gf_filter_pid_configure(GF_Filter *filter, GF_FilterPid *pid, GF_P
}
if (remove_filter && !filter->sticky)
gf_filter_post_remove(filter);
//we injected a filter to adapt on an already playing PID, move pid instance to playing
if (filter->is_pid_adaptation_filter && pid->is_playing)
pidinst->is_playing = GF_TRUE;

//new pid instance creating a fanout on an already playing pid: force discarding input packets until we have a PLAY
if (new_pid_inst && !filter->is_pid_adaptation_filter && pid->is_playing && pid->nb_pck_sent && (pid->num_destinations>1))
pidinst->discard_inputs = GF_TRUE;
}
//once all pid have been (re)connected, update any internal caps
gf_filter_pid_update_caps(pid);
Expand Down
13 changes: 2 additions & 11 deletions src/filters/ff_enc.c
Expand Up @@ -52,7 +52,6 @@ typedef struct _gf_ffenc_ctx

//internal data
Bool gen_dsi;
Bool playing;
u32 gop_size;
u32 target_rate;

Expand Down Expand Up @@ -1353,9 +1352,7 @@ static GF_Err ffenc_process_audio(GF_Filter *filter, struct _gf_ffenc_ctx *ctx)
static GF_Err ffenc_process(GF_Filter *filter)
{
GF_FFEncodeCtx *ctx = (GF_FFEncodeCtx *) gf_filter_get_udta(filter);
if (!ctx->out_pid || gf_filter_pid_would_block(ctx->out_pid)
//make sure we receive a play event
|| !ctx->playing)
if (!ctx->out_pid || gf_filter_pid_would_block(ctx->out_pid))
return GF_OK;
return ctx->process(filter, ctx);
}
Expand Down Expand Up @@ -2178,13 +2175,7 @@ static GF_Err ffenc_update_arg(GF_Filter *filter, const char *arg_name, const GF
static Bool ffenc_process_event(GF_Filter *filter, const GF_FilterEvent *evt)
{
GF_FFEncodeCtx *ctx = gf_filter_get_udta(filter);
if (evt->base.type==GF_FEVT_PLAY) {
ctx->playing = GF_TRUE;
}
else if (evt->base.type==GF_FEVT_PLAY) {
ctx->playing = GF_FALSE;
}
else if (evt->base.type==GF_FEVT_ENCODE_HINTS) {
if (evt->base.type==GF_FEVT_ENCODE_HINTS) {
if (evt->encode_hints.gen_dsi_only) {
ctx->generate_dsi_only = GF_TRUE;
}
Expand Down

0 comments on commit 7a3eca9

Please sign in to comment.