File:
[DVB] /
multiplexer /
splice.c
Revision
1.1:
download - view:
text,
annotated -
select for diffs
Tue Apr 3 21:14:33 2001 UTC (23 years, 2 months ago) by
oskar
Branches:
MAIN
CVS tags:
HEAD
cleaning up.
buffer sizes now depend on split data type (video,audio,other).
new functions to unlink and remove streams from programs.
do not start dispatcher when command line is --help.
new command "crop" to remove program or stream from target.
/*
* ISO 13818 stream multiplexer
* Copyright (C) 2001 Convergence Integrated Media GmbH Berlin
* Author: Oskar Schirmer (oskar@convergence.de)
*/
/*
* Module: Splice
* Purpose: Service functions for specific Splice* modules
*
* This module provides functions needed for splicing
* which are independent from the splice type.
*/
#include "global.h"
#include "error.h"
#include "splice.h"
#include "input.h"
#include "pes.h"
stream_descr *connect_streamprog (file_descr *f,
int programnb,
int sourceid,
int streamid,
int streamtype,
stream_descr *stream,
stream_descr *mapstream,
boolean mention)
{
stream_descr *s;
prog_descr *p;
if (stream == NULL) {
s = input_openstream (f,sourceid,streamid<0?-streamid:streamid,
streamtype,FALSE,mapstream);
} else {
if (streamid < 0) {
streamid = -streamid;
warn (LWAR,"Cannot refind sid",EINP,14,1,streamid);
}
s = stream;
}
if (s != NULL) {
p = splice_openprog (programnb);
if (p != NULL) {
if (input_addprog (s,p)) {
if (splice_addstream (p,s,streamid>=0) > 0) {
/*
if (p->pcr_pid < 0) {
if (xxx) {
p->pcr_pid = s->u.d.pid;
s->u.d.has_clockref = TRUE;
s->u.d.next_clockref = msec_now () - MAX_MSEC_PCRDIST;
}
}
*/
s->endaction = ENDSTR_WAIT;
s->u.d.mention = mention;
return (s);
}
input_delprog (s,p);
}
if (p->streams <= 0) {
splice_closeprog (p);
}
}
if (stream == NULL) {
input_closestream (s);
}
}
return (stream);
}
void unlink_streamprog (stream_descr *s,
prog_descr *p)
{
splice_delstream (p,s);
input_delprog (s,p);
if (s->u.d.progs <= 0) {
file_descr *f;
f = s->fdescr;
input_closestream (s);
input_closefileifunused (f);
}
}
void remove_streamprog (stream_descr *s,
prog_descr *p)
{
int i;
i = s->u.d.progs;
while (--i >= 0) {
if (s->u.d.pdescr[i] == p) {
if (p->streams > 1) {
unlink_streamprog (s,p);
} else {
splice_closeprog (s->u.d.pdescr[i]);
}
break;
}
}
}
stream_descr *get_streamprog (prog_descr *p,
int streamid)
{
int i;
i = p->streams;
while (--i >= 0) {
stream_descr *s;
s = p->stream[i];
if (s->stream_id == streamid) {
return (s);
}
}
return (NULL);
}
int splice_findfreestreamid (prog_descr *p,
int sid)
{
int s, n;
if ((sid >= PES_CODE_AUDIO)
&& (sid < (PES_CODE_AUDIO+PES_NUMB_AUDIO))) {
s = PES_CODE_AUDIO;
n = PES_NUMB_AUDIO-1;
} else if ((sid >= PES_CODE_VIDEO)
&& (sid < (PES_CODE_VIDEO+PES_NUMB_VIDEO))) {
s = PES_CODE_VIDEO;
n = PES_NUMB_VIDEO-1;
} else {
s = sid;
n = 0;
}
while (--n >= 0) {
int i;
i = p->streams;
while ((--i >= 0)
&& (p->stream[i]->stream_id != s)) {
}
if (i < 0) {
warn (LIMP,"Found SID free",EINP,15,sid,s);
return (s);
}
s += 1;
}
warn (LIMP,"Found SID",EINP,15,sid,s);
return (s);
}
stream_descr *splice_findpcrstream (prog_descr *p)
{
int i;
pmt_descr *pmt;
warn (LIMP,"Find PCR Stream",EINP,13,0,p->program_number);
i = p->streams;
while (--i >= 0) {
if (p->stream[i]->fdescr->content == ct_transport) {
pmt = p->stream[i]->fdescr->u.ts.pat;
while (pmt != NULL) {
if (pmt->pcr_pid == p->stream[i]->sourceid) {
warn (LIMP,"Found PCR Stream",EINP,13,1,p->stream[i]->sourceid);
return (p->stream[i]);
}
pmt = pmt->next;
}
}
}
return (NULL);
}
LinuxTV legacy CVS <linuxtv.org/cvs>