--- multiplexer/splicets.c 2004/01/16 14:54:12 1.20 +++ multiplexer/splicets.c 2004/01/23 01:39:04 1.21 @@ -1,7 +1,7 @@ /* * ISO 13818 stream multiplexer * Copyright (C) 2001 Convergence Integrated Media GmbH Berlin - * Author: Oskar Schirmer (oskar@scara.com) + * Copyright (C) 2004 Oskar Schirmer (oskar@scara.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,10 +96,16 @@ void splice_setpsifrequency (t_msec freq psi_frequency_changed = TRUE; } -static int findapid (stream_descr *s) +static int findapid (stream_descr *s, int desire) { byte okness = 2; int h; + if (conservative_pid_assignment + && (desire >= 0) + && (outs[desire] == NULL) + && (input_tssiinafilerange (desire) < 0)) { + return (desire); + } do { if ((nextpid < TS_PID_SPLICELO) || (nextpid >= TS_PID_SPLICEHI)) { warn (LDEB,"Next PID",ETSC,1,okness,nextpid); @@ -167,7 +173,7 @@ void splice_addsirange (file_descr *f, if ((s != NULL) && (s != PMT_STREAM)) { if (s->streamdata == sd_data) { - i = findapid (s); + i = findapid (s, -1); if (input_tssiinafilerange (i) >= 0) { /* none free! */ outs[i] = NULL; } else { @@ -197,7 +203,7 @@ void splice_addsirange (file_descr *f, if ((r >= lower) && (r <= upper)) { int q; - q = findapid (PMT_STREAM); + q = findapid (PMT_STREAM, -1); if (input_tssiinafilerange (q) >= 0) { /* none free! */ outs[q] = NULL; } else { @@ -329,7 +335,7 @@ prog_descr *splice_openprog (int program p = splice_getprog (programnb); if (p == NULL) { if (progs < MAX_OUTPROG) { - if ((pid = findapid (PMT_STREAM)) > 0) { + if ((pid = findapid (PMT_STREAM, -1)) > 0) { if ((p = malloc(sizeof(prog_descr))) != NULL) { p->program_number = programnb; p->pcr_pid = -1; @@ -397,8 +403,7 @@ int splice_addstream (prog_descr *p, int pid = 0; warn (LIMP,"Add stream",ETSC,4,force_sid,s->stream_id); if (p->streams < MAX_STRPERPRG) { -/* YenZi */ - pid = s->sourceid; + pid = findapid (s,(s->fdescr->content == ct_transport) ? s->sourceid : -1); if (pid > 0) { if (!force_sid) { s->stream_id = splice_findfreestreamid (p,s->stream_id);