Remove streaming_component_t from tvhead.h

We will eventually move away from this code structure anyway.
This commit is contained in:
Andreas Öman 2009-06-01 20:09:38 +00:00
parent c9d0527711
commit fb39102578
12 changed files with 52 additions and 91 deletions

View file

@ -902,10 +902,8 @@ cwc_find_stream_by_caid(th_transport_t *t, int caid)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
th_stream_t *st;
streaming_component_t *sc;
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
if(st->st_caid == caid)
return st;
}

View file

@ -400,7 +400,6 @@ dvb_adapter_clone(th_dvb_adapter_t *dst, th_dvb_adapter_t *src)
th_dvb_mux_instance_t *tdmi_src, *tdmi_dst;
th_transport_t *t_src, *t_dst;
th_stream_t *st_src, *st_dst;
streaming_component_t *sc_src;
lock_assert(&global_lock);
@ -445,16 +444,15 @@ dvb_adapter_clone(th_dvb_adapter_t *dst, th_dvb_adapter_t *src)
pthread_mutex_lock(&t_src->tht_stream_mutex);
LIST_FOREACH(sc_src, &t_src->tht_streaming_pad.sp_components, sc_link) {
st_src = (th_stream_t *)sc_src;
LIST_FOREACH(st_src, &t_src->tht_streaming_pad.sp_components, st_link) {
st_dst = transport_add_stream(t_dst,
st_src->st_pid,
st_src->st_sc.sc_type);
st_src->st_type);
st_dst->st_tb = (AVRational){1, 90000};
memcpy(st_dst->st_sc.sc_lang, st_src->st_sc.sc_lang, 4);
memcpy(st_dst->st_lang, st_src->st_lang, 4);
st_dst->st_frame_duration = st_src->st_frame_duration;
st_dst->st_caid = st_src->st_caid;
}

View file

@ -58,7 +58,6 @@ dvb_transport_start(th_transport_t *t, unsigned int weight, int status,
int force_start)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
struct dmx_pes_filter_params dmx_param;
th_stream_t *st;
int w, fd, pid;
@ -82,9 +81,7 @@ dvb_transport_start(th_transport_t *t, unsigned int weight, int status,
}
tdmi = t->tht_dvb_mux_instance;
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
fd = open(tda->tda_demux_path, O_RDWR);
pid = st->st_pid;
@ -137,7 +134,6 @@ static void
dvb_transport_stop(th_transport_t *t)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
th_dvb_adapter_t *tda = t->tht_dvb_mux_instance->tdmi_adapter;
th_stream_t *st;
@ -147,8 +143,7 @@ dvb_transport_stop(th_transport_t *t)
LIST_REMOVE(t, tht_active_link);
pthread_mutex_unlock(&tda->tda_delivery_mutex);
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
close(st->st_demuxer_fd);
st->st_demuxer_fd = -1;
}

View file

@ -301,7 +301,7 @@ dvr_rec_fatal_error(dvr_entry_t *de, const char *fmt, ...)
static void
dvr_rec_start(dvr_entry_t *de, streaming_pad_t *sp)
{
streaming_component_t *sc;
th_stream_t *st;
dvr_rec_stream_t *drs;
AVOutputFormat *fmt;
AVFormatContext *fctx;
@ -363,9 +363,9 @@ dvr_rec_start(dvr_entry_t *de, streaming_pad_t *sp)
/**
* Setup each stream
*/
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
LIST_FOREACH(st, &sp->sp_components, st_link) {
switch(sc->sc_type) {
switch(st->st_type) {
default:
continue;
case SCT_MPEG2VIDEO:
@ -402,7 +402,7 @@ dvr_rec_start(dvr_entry_t *de, streaming_pad_t *sp)
}
drs = calloc(1, sizeof(dvr_rec_stream_t));
drs->drs_source_index = sc->sc_index;
drs->drs_source_index = st->st_index;
drs->drs_lavf_stream = av_new_stream(fctx, fctx->nb_streams);
@ -418,7 +418,7 @@ dvr_rec_start(dvr_entry_t *de, streaming_pad_t *sp)
continue;
}
memcpy(drs->drs_lavf_stream->language, sc->sc_lang, 4);
memcpy(drs->drs_lavf_stream->language, st->st_lang, 4);
LIST_INSERT_HEAD(&de->de_streams, drs, drs_link);
}

View file

@ -1103,9 +1103,9 @@ static void
htsp_subscription_start(htsp_connection_t *htsp, th_subscription_t *s,
streaming_pad_t *sp)
{
streaming_component_t *sc;
htsp_stream_t *hs;
htsmsg_t *m, *streams, *c;
th_stream_t *st;
assert(s->ths_st == NULL);
@ -1127,12 +1127,12 @@ htsp_subscription_start(htsp_connection_t *htsp, th_subscription_t *s,
/* Setup each stream */
streams = htsmsg_create_list();
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
LIST_FOREACH(st, &sp->sp_components, st_link) {
c = htsmsg_create_map();
htsmsg_add_u32(c, "index", sc->sc_index);
htsmsg_add_str(c, "type", streaming_component_type2txt(sc->sc_type));
if(sc->sc_lang[0])
htsmsg_add_str(c, "language", sc->sc_lang);
htsmsg_add_u32(c, "index", st->st_index);
htsmsg_add_str(c, "type", streaming_component_type2txt(st->st_type));
if(st->st_lang[0])
htsmsg_add_str(c, "language", st->st_lang);
htsmsg_add_msg(streams, NULL, c);
}

View file

@ -118,7 +118,7 @@ parse_raw_mpeg(th_transport_t *t, th_stream_t *st, uint8_t *data,
}
switch(st->st_sc.sc_type) {
switch(st->st_type) {
case SCT_MPEG2VIDEO:
parse_video(t, st, data, len, parse_mpeg2video);
break;
@ -880,7 +880,7 @@ parser_deliver(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt)
transport_signal_status(t, SUBSCRIPTION_VALID_PACKETS);
/* Forward packet */
pkt->pkt_componentindex = st->st_sc.sc_index;
pkt->pkt_componentindex = st->st_index;
streaming_pad_deliver_packet(&t->tht_streaming_pad, pkt);
/* Decrease our own reference to the packet */
@ -906,7 +906,7 @@ parser_enqueue_packet(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt)
/* Per stream type analysis */
switch(st->st_sc.sc_type) {
switch(st->st_type) {
case SCT_MPEG2VIDEO:
for(i = 0; i < pkt->pkt_payloadlen && err == 0; i++) {
sc = (sc << 8) | buf[i];

View file

@ -285,7 +285,7 @@ psi_parse_pmt(th_transport_t *t, uint8_t *ptr, int len, int chksvcid)
if(hts_stream_type != 0) {
st = transport_add_stream(t, pid, hts_stream_type);
st->st_tb = (AVRational){1, 90000};
memcpy(st->st_sc.sc_lang, lang, 4);
memcpy(st->st_lang, lang, 4);
if(st->st_frame_duration == 0)
st->st_frame_duration = frameduration;
@ -556,7 +556,6 @@ void
psi_save_transport_settings(htsmsg_t *m, th_transport_t *t)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
th_stream_t *st;
htsmsg_t *sub;
@ -566,18 +565,16 @@ psi_save_transport_settings(htsmsg_t *m, th_transport_t *t)
lock_assert(&t->tht_stream_mutex);
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
sub = htsmsg_create_map();
htsmsg_add_u32(sub, "pid", st->st_pid);
htsmsg_add_str(sub, "type", val2str(sc->sc_type, streamtypetab) ?: "?");
htsmsg_add_str(sub, "type", val2str(st->st_type, streamtypetab) ?: "?");
if(sc->sc_lang[0])
htsmsg_add_str(sub, "language", sc->sc_lang);
if(st->st_lang[0])
htsmsg_add_str(sub, "language", st->st_lang);
if(sc->sc_type == SCT_CA)
if(st->st_type == SCT_CA)
htsmsg_add_str(sub, "caid", psi_caid2name(st->st_caid));
if(st->st_frame_duration)
@ -629,7 +626,7 @@ psi_load_transport_settings(htsmsg_t *m, th_transport_t *t)
st->st_tb = (AVRational){1, 90000};
if((v = htsmsg_get_str(c, "language")) != NULL)
av_strlcpy(st->st_sc.sc_lang, v, 4);
av_strlcpy(st->st_lang, v, 4);
if(!htsmsg_get_u32(c, "frameduration", &u32))
st->st_frame_duration = u32;

View file

@ -63,8 +63,6 @@ static void
transport_stop(th_transport_t *t)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
th_descrambler_t *td;
th_stream_t *st;
@ -87,8 +85,7 @@ transport_stop(th_transport_t *t)
/**
* Clean up each stream
*/
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
if(st->st_parser != NULL)
av_parser_close(st->st_parser);
@ -213,8 +210,6 @@ int
transport_start(th_transport_t *t, unsigned int weight, int force_start)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
th_stream_t *st;
AVCodec *c;
enum CodecID id;
@ -232,9 +227,7 @@ transport_start(th_transport_t *t, unsigned int weight, int force_start)
/**
* Initialize stream
*/
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
st->st_startcond = 0xffffffff;
st->st_curdts = AV_NOPTS_VALUE;
st->st_curpts = AV_NOPTS_VALUE;
@ -249,7 +242,7 @@ transport_start(th_transport_t *t, unsigned int weight, int force_start)
st->st_pcr_recovery_fails = 0;
/* Open ffmpeg context and parser */
switch(sc->sc_type) {
switch(st->st_type) {
case SCT_MPEG2VIDEO: id = CODEC_ID_MPEG2VIDEO; break;
case SCT_MPEG2AUDIO: id = CODEC_ID_MP3; break;
case SCT_H264: id = CODEC_ID_H264; break;
@ -441,7 +434,7 @@ void
transport_destroy(th_transport_t *t)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
th_stream_t *st;
th_subscription_t *s;
lock_assert(&global_lock);
@ -470,9 +463,9 @@ transport_destroy(th_transport_t *t)
free(t->tht_chname);
free(t->tht_provider);
while((sc = LIST_FIRST(&sp->sp_components)) != NULL) {
LIST_REMOVE(sc, sc_link);
free(sc);
while((st = LIST_FIRST(&sp->sp_components)) != NULL) {
LIST_REMOVE(st, st_link);
free(st);
}
abort();// serviceprobe_delete(t);
@ -532,24 +525,21 @@ transport_add_stream(th_transport_t *t, int pid,
streaming_component_type_t type)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
th_stream_t *st;
int i = 0;
lock_assert(&t->tht_stream_mutex);
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
i++;
if(pid != -1 && st->st_pid == pid)
return st;
}
st = calloc(1, sizeof(th_stream_t));
sc = &st->st_sc;
sc->sc_index = i;
sc->sc_type = type;
LIST_INSERT_HEAD(&sp->sp_components, sc, sc_link);
st->st_index = i;
st->st_type = type;
LIST_INSERT_HEAD(&sp->sp_components, st, st_link);
st->st_pid = pid;
st->st_demuxer_fd = -1;

View file

@ -67,10 +67,8 @@ transport_find_stream_by_pid(th_transport_t *t, int pid)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
th_stream_t *st;
streaming_component_t *sc;
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
if(st->st_pid == pid)
return st;
}

View file

@ -53,7 +53,7 @@ got_section(th_transport_t *t, th_stream_t *st)
{
th_descrambler_t *td;
if(st->st_sc.sc_type == SCT_CA) {
if(st->st_type == SCT_CA) {
LIST_FOREACH(td, &t->tht_descramblers, td_transport_link)
td->td_table(td, t, st,
st->st_section->ps_data, st->st_section->ps_offset);
@ -95,7 +95,7 @@ ts_recv_packet0(th_transport_t *t, th_stream_t *st, uint8_t *tsb)
off = tsb[3] & 0x20 ? tsb[4] + 5 : 4;
pusi = tsb[1] & 0x40;
switch(st->st_sc.sc_type) {
switch(st->st_type) {
case SCT_CA:
case SCT_PAT:

View file

@ -113,8 +113,6 @@ TAILQ_HEAD(th_muxpkt_queue, th_muxpkt);
LIST_HEAD(dvr_autorec_entry_list, dvr_autorec_entry);
TAILQ_HEAD(th_pktref_queue, th_pktref);
LIST_HEAD(streaming_target_list, streaming_target);
LIST_HEAD(streaming_component_list, streaming_component);
typedef enum {
@ -129,22 +127,6 @@ typedef enum {
SCT_PMT,
} streaming_component_type_t;
/**
*
*/
typedef struct streaming_component {
LIST_ENTRY(streaming_component) sc_link;
streaming_component_type_t sc_type;
int sc_index;
char sc_lang[4]; /* ISO 639 3-letter language code */
} streaming_component_t;
/**
* A streaming pad generates data.
@ -161,7 +143,7 @@ typedef struct streaming_component {
typedef struct streaming_pad {
struct streaming_target_list sp_targets;
int sp_ntargets;
struct streaming_component_list sp_components;
struct th_stream_list sp_components;
pthread_mutex_t *sp_mutex; /* Mutex for protecting modification of
st_targets and delivery.
@ -367,7 +349,12 @@ typedef void (pid_section_callback_t)(struct th_transport *t,
*/
typedef struct th_stream {
streaming_component_t st_sc;
LIST_ENTRY(th_stream) st_link;
streaming_component_type_t st_type;
int st_index;
char st_lang[4]; /* ISO 639 3-letter language code */
uint16_t st_pid;
uint8_t st_cc; /* Last CC */

View file

@ -566,7 +566,6 @@ static htsmsg_t *
build_transport_msg(th_transport_t *t)
{
streaming_pad_t *sp = &t->tht_streaming_pad;
streaming_component_t *sc;
htsmsg_t *r = htsmsg_create_map();
th_stream_t *st;
@ -589,10 +588,9 @@ build_transport_msg(th_transport_t *t)
subtitles[0] = 0;
scrambling[0] = 0;
LIST_FOREACH(sc, &sp->sp_components, sc_link) {
st = (th_stream_t *)sc;
LIST_FOREACH(st, &sp->sp_components, st_link) {
switch(sc->sc_type) {
switch(st->st_type) {
case SCT_TELETEXT:
case SCT_SUBTITLES:
case SCT_PAT:
@ -626,9 +624,9 @@ build_transport_msg(th_transport_t *t)
"%sMPEG-2 (PID:%d", strlen(audio) > 0 ? ", " : "",
st->st_pid);
audio:
if(sc->sc_lang[0]) {
if(st->st_lang[0]) {
snprintf(audio + strlen(audio), sizeof(audio) - strlen(audio),
", languange: \"%s\")", sc->sc_lang);
", languange: \"%s\")", st->st_lang);
} else {
snprintf(audio + strlen(audio), sizeof(audio) - strlen(audio),
")");