From: Jaroslav Kysela Date: Thu, 8 Mar 2018 16:58:28 +0000 (+0100) Subject: esstream: introduce stream_info_t X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e18f8ef04c95e790777a7df2a8b250ea92620dde;p=thirdparty%2Ftvheadend.git esstream: introduce stream_info_t --- diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index 3f5df105b..c78e4e001 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -1259,61 +1259,61 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss) continue; e = htsmsg_create_map(); - htsmsg_add_str(e, "type", streaming_component_type2txt(ssc->ssc_type)); - if (ssc->ssc_lang[0]) - htsmsg_add_str(e, "language", ssc->ssc_lang); - - if(SCT_ISAUDIO(ssc->ssc_type)) { - htsmsg_add_u32(e, "audio_type", ssc->ssc_audio_type); - if(ssc->ssc_audio_version) - htsmsg_add_u32(e, "audio_version", ssc->ssc_audio_version); - if(ssc->ssc_sri < 16) - snprintf(sr, sizeof(sr), "%d", sri_to_rate(ssc->ssc_sri)); + htsmsg_add_str(e, "type", streaming_component_type2txt(ssc->es_type)); + if (ssc->es_lang[0]) + htsmsg_add_str(e, "language", ssc->es_lang); + + if(SCT_ISAUDIO(ssc->es_type)) { + htsmsg_add_u32(e, "audio_type", ssc->es_audio_type); + if(ssc->es_audio_version) + htsmsg_add_u32(e, "audio_version", ssc->es_audio_version); + if(ssc->es_sri < 16) + snprintf(sr, sizeof(sr), "%d", sri_to_rate(ssc->es_sri)); else strcpy(sr, "?"); - if(ssc->ssc_channels == 6) + if(ssc->es_channels == 6) snprintf(ch, sizeof(ch), "5.1"); - else if(ssc->ssc_channels == 0) + else if(ssc->es_channels == 0) strcpy(ch, "?"); else - snprintf(ch, sizeof(ch), "%d", ssc->ssc_channels); + snprintf(ch, sizeof(ch), "%d", ssc->es_channels); } else { sr[0] = ch[0] = 0; } - if(SCT_ISVIDEO(ssc->ssc_type)) { - if(ssc->ssc_width && ssc->ssc_height) + if(SCT_ISVIDEO(ssc->es_type)) { + if(ssc->es_width && ssc->es_height) snprintf(res, sizeof(res), "%dx%d", - ssc->ssc_width, ssc->ssc_height); + ssc->es_width, ssc->es_height); else strcpy(res, "?"); - if(ssc->ssc_aspect_num && ssc->ssc_aspect_den) + if(ssc->es_aspect_num && ssc->es_aspect_den) snprintf(asp, sizeof(asp), "%d:%d", - ssc->ssc_aspect_num, ssc->ssc_aspect_den); + ssc->es_aspect_num, ssc->es_aspect_den); else strcpy(asp, "?"); - htsmsg_add_u32(e, "width", ssc->ssc_width); - htsmsg_add_u32(e, "height", ssc->ssc_height); - htsmsg_add_u32(e, "duration", ssc->ssc_frameduration); - htsmsg_add_u32(e, "aspect_num", ssc->ssc_aspect_num); - htsmsg_add_u32(e, "aspect_den", ssc->ssc_aspect_den); + htsmsg_add_u32(e, "width", ssc->es_width); + htsmsg_add_u32(e, "height", ssc->es_height); + htsmsg_add_u32(e, "duration", ssc->es_frame_duration); + htsmsg_add_u32(e, "aspect_num", ssc->es_aspect_num); + htsmsg_add_u32(e, "aspect_den", ssc->es_aspect_den); } else { res[0] = asp[0] = 0; } - if (SCT_ISSUBTITLE(ssc->ssc_type)) { - htsmsg_add_u32(e, "composition_id", ssc->ssc_composition_id); - htsmsg_add_u32(e, "ancillary_id", ssc->ssc_ancillary_id); + if (SCT_ISSUBTITLE(ssc->es_type)) { + htsmsg_add_u32(e, "composition_id", ssc->es_composition_id); + htsmsg_add_u32(e, "ancillary_id", ssc->es_ancillary_id); } tvhinfo(LS_DVR, "%2d %-16s %-4s %-10s %-12s %-11s %-8s %s", - ssc->ssc_index, - streaming_component_type2txt(ssc->ssc_type), - ssc->ssc_lang, + ssc->es_index, + streaming_component_type2txt(ssc->es_type), + ssc->es_lang, res, asp, sr, @@ -1495,10 +1495,10 @@ get_dts_ref(th_pkt_t *pkt, streaming_start_t *ss) return PTS_UNSET; for (i = 0; i < ss->ss_num_components; i++) { ssc = &ss->ss_components[i]; - if (ssc->ssc_index == pkt->pkt_componentindex) { - if (SCT_ISVIDEO(ssc->ssc_type)) + if (ssc->es_index == pkt->pkt_componentindex) { + if (SCT_ISVIDEO(ssc->es_type)) return pkt->pkt_dts; - if (audio == PTS_UNSET && SCT_ISAUDIO(ssc->ssc_type)) + if (audio == PTS_UNSET && SCT_ISAUDIO(ssc->es_type)) audio = pkt->pkt_dts; } } diff --git a/src/esstream.c b/src/esstream.c index c60a4c958..157e7400b 100644 --- a/src/esstream.c +++ b/src/esstream.c @@ -639,18 +639,7 @@ elementary_stream_build_start(elementary_set_t *set) n = 0; TAILQ_FOREACH(st, &set->set_filter, es_filter_link) { streaming_start_component_t *ssc = &ss->ss_components[n++]; - ssc->ssc_index = st->es_index; - ssc->ssc_type = st->es_type; - - memcpy(ssc->ssc_lang, st->es_lang, 4); - ssc->ssc_audio_type = st->es_audio_type; - ssc->ssc_audio_version = st->es_audio_version; - ssc->ssc_composition_id = st->es_composition_id; - ssc->ssc_ancillary_id = st->es_ancillary_id; - ssc->ssc_pid = st->es_pid; - ssc->ssc_width = st->es_width; - ssc->ssc_height = st->es_height; - ssc->ssc_frameduration = st->es_frame_duration; + *(elementary_info_t *)ssc = *(elementary_info_t *)st; } ss->ss_refcount = 1; diff --git a/src/esstream.h b/src/esstream.h index 2637e1ae5..14643e62f 100644 --- a/src/esstream.h +++ b/src/esstream.h @@ -30,6 +30,7 @@ typedef struct service service_t; typedef struct streaming_start streaming_start_t; typedef enum streaming_component_type streaming_component_type_t; +typedef struct elementary_info elementary_info_t; typedef struct elementary_stream elementary_stream_t; typedef struct elementary_set elementary_set_t; @@ -82,35 +83,13 @@ enum streaming_component_type { #define SCT_ISSUBTITLE(t) ((t) == SCT_TEXTSUB || (t) == SCT_DVBSUB) /** - * Stream, one media component for a service. + * Stream info, one media component for a service. */ -struct elementary_stream { - TAILQ_ENTRY(elementary_stream) es_link; - TAILQ_ENTRY(elementary_stream) es_filter_link; - - uint32_t es_position; - struct service *es_service; - - streaming_component_type_t es_type; +struct elementary_info { int es_index; - - char *es_nicename; - - /* PID related */ int16_t es_pid; - uint16_t es_parent_pid; /* For subtitle streams originating from - a teletext stream. this is the pid - of the teletext stream */ - int8_t es_pid_opened; /* PID is opened */ - int8_t es_cc; /* Last CC */ - - /* CA ID's on this stream */ - struct caid_list es_caids; + int es_type; - /* */ - int es_delete_me; /* Temporary flag for deleting streams */ - - /* Stream info */ int es_frame_duration; int es_width; @@ -122,17 +101,41 @@ struct elementary_stream { char es_lang[4]; /* ISO 639 2B 3-letter language code */ uint8_t es_audio_type; /* Audio type */ uint8_t es_audio_version; /* Audio version/layer */ + uint8_t es_sri; + uint8_t es_ext_sri; + uint16_t es_channels; uint16_t es_composition_id; uint16_t es_ancillary_id; +}; + +/** + * Stream, one media component for a service. + */ +struct elementary_stream { + elementary_info_t; + + TAILQ_ENTRY(elementary_stream) es_link; + TAILQ_ENTRY(elementary_stream) es_filter_link; + + uint32_t es_position; + struct service *es_service; + char *es_nicename; + + /* PID related */ + uint16_t es_parent_pid; /* For subtitle streams originating from + a teletext stream. this is the pid + of the teletext stream */ + int8_t es_pid_opened; /* PID is opened */ + int8_t es_cc; /* Last CC */ + int8_t es_delete_me; /* Temporary flag for deleting streams */ + + struct caid_list es_caids; /* CA ID's on this stream */ - /* Error log limiters */ - tvhlog_limit_t es_cc_log; - /* Filter temporary variable */ - uint32_t es_filter; + tvhlog_limit_t es_cc_log; /* CC error log limiter */ + uint32_t es_filter; /* Filter temporary variable */ - /* HBBTV PSI table (AIT) */ - mpegts_psi_table_t es_psi; + mpegts_psi_table_t es_psi; /* HBBTV PSI table (AIT) */ }; /* diff --git a/src/htsp_server.c b/src/htsp_server.c index b77f48e85..a9e1f9ea3 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -4097,8 +4097,8 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss) for(i = 0; i < ss->ss_num_components; i++) { const streaming_start_component_t *ssc = &ss->ss_components[i]; if (ssc->ssc_disabled) continue; - if (SCT_ISVIDEO(ssc->ssc_type)) { - if (ssc->ssc_width == 0 || ssc->ssc_height == 0) { + if (SCT_ISVIDEO(ssc->es_type)) { + if (ssc->es_width == 0 || ssc->es_height == 0) { hs->hs_wait_for_video = 1; return; } @@ -4115,43 +4115,43 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss) if(ssc->ssc_disabled) continue; c = htsmsg_create_map(); - htsmsg_add_u32(c, "index", ssc->ssc_index); - if (ssc->ssc_type == SCT_MP4A) + htsmsg_add_u32(c, "index", ssc->es_index); + if (ssc->es_type == SCT_MP4A) type = "AAC"; /* override */ else - type = streaming_component_type2txt(ssc->ssc_type); + type = streaming_component_type2txt(ssc->es_type); htsmsg_add_str(c, "type", type); - if(ssc->ssc_lang[0]) - htsmsg_add_str(c, "language", ssc->ssc_lang); + if(ssc->es_lang[0]) + htsmsg_add_str(c, "language", ssc->es_lang); - if(ssc->ssc_type == SCT_DVBSUB) { - htsmsg_add_u32(c, "composition_id", ssc->ssc_composition_id); - htsmsg_add_u32(c, "ancillary_id", ssc->ssc_ancillary_id); + if(ssc->es_type == SCT_DVBSUB) { + htsmsg_add_u32(c, "composition_id", ssc->es_composition_id); + htsmsg_add_u32(c, "ancillary_id", ssc->es_ancillary_id); } - if(SCT_ISVIDEO(ssc->ssc_type)) { - if(ssc->ssc_width) - htsmsg_add_u32(c, "width", ssc->ssc_width); - if(ssc->ssc_height) - htsmsg_add_u32(c, "height", ssc->ssc_height); - if(ssc->ssc_frameduration) - htsmsg_add_u32(c, "duration", hs->hs_90khz ? ssc->ssc_frameduration : - ts_rescale(ssc->ssc_frameduration, 1000000)); - if (ssc->ssc_aspect_num) - htsmsg_add_u32(c, "aspect_num", ssc->ssc_aspect_num); - if (ssc->ssc_aspect_den) - htsmsg_add_u32(c, "aspect_den", ssc->ssc_aspect_den); + if(SCT_ISVIDEO(ssc->es_type)) { + if(ssc->es_width) + htsmsg_add_u32(c, "width", ssc->es_width); + if(ssc->es_height) + htsmsg_add_u32(c, "height", ssc->es_height); + if(ssc->es_frame_duration) + htsmsg_add_u32(c, "duration", hs->hs_90khz ? ssc->es_frame_duration : + ts_rescale(ssc->es_frame_duration, 1000000)); + if (ssc->es_aspect_num) + htsmsg_add_u32(c, "aspect_num", ssc->es_aspect_num); + if (ssc->es_aspect_den) + htsmsg_add_u32(c, "aspect_den", ssc->es_aspect_den); } - if (SCT_ISAUDIO(ssc->ssc_type)) + if (SCT_ISAUDIO(ssc->es_type)) { - htsmsg_add_u32(c, "audio_type", ssc->ssc_audio_type); - if (ssc->ssc_audio_version) - htsmsg_add_u32(c, "audio_version", ssc->ssc_audio_version); - if (ssc->ssc_channels) - htsmsg_add_u32(c, "channels", ssc->ssc_channels); - if (ssc->ssc_sri) - htsmsg_add_u32(c, "rate", ssc->ssc_sri); + htsmsg_add_u32(c, "audio_type", ssc->es_audio_type); + if (ssc->es_audio_version) + htsmsg_add_u32(c, "audio_version", ssc->es_audio_version); + if (ssc->es_channels) + htsmsg_add_u32(c, "channels", ssc->es_channels); + if (ssc->es_sri) + htsmsg_add_u32(c, "rate", ssc->es_sri); } if (ssc->ssc_gh) diff --git a/src/muxer/muxer_audioes.c b/src/muxer/muxer_audioes.c index f9f0e072d..fb678fd7d 100644 --- a/src/muxer/muxer_audioes.c +++ b/src/muxer/muxer_audioes.c @@ -79,9 +79,9 @@ audioes_get_component(muxer_t *m, const struct streaming_start *ss) for (i = count = 0; i < ss->ss_num_components;i++) { ssc = &ss->ss_components[i]; - if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->ssc_type))) { + if ((!ssc->ssc_disabled) && (SCT_ISAUDIO(ssc->es_type))) { if (m->m_config.u.audioes.m_force_type != MC_UNKNOWN) { - mc = audioes_muxer_type(ssc->ssc_type); + mc = audioes_muxer_type(ssc->es_type); if (m->m_config.u.audioes.m_force_type != mc) continue; } @@ -108,7 +108,7 @@ audioes_muxer_mime(muxer_t *m, const struct streaming_start *ss) ssc = audioes_get_component(m, ss); if (ssc) - mc = audioes_muxer_type(ssc->ssc_type); + mc = audioes_muxer_type(ssc->es_type); return muxer_container_type2mime(mc, 0); } @@ -127,7 +127,7 @@ audioes_muxer_reconfigure(muxer_t *m, const struct streaming_start *ss) ssc = audioes_get_component(m, ss); if (ssc) - am->am_index = ssc->ssc_index; + am->am_index = ssc->es_index; return 0; } diff --git a/src/muxer/muxer_libav.c b/src/muxer/muxer_libav.c index c16e3b8f1..333e5b1c4 100644 --- a/src/muxer/muxer_libav.c +++ b/src/muxer/muxer_libav.c @@ -85,9 +85,9 @@ lav_muxer_add_stream(lav_muxer_t *lm, if (!st) return -1; - st->id = ssc->ssc_index; + st->id = ssc->es_index; c = st->codec; - c->codec_id = streaming_component_type2codec_id(ssc->ssc_type); + c->codec_id = streaming_component_type2codec_id(ssc->es_type); switch(lm->m_config.m_type) { case MC_MATROSKA: @@ -111,10 +111,10 @@ lav_muxer_add_stream(lav_muxer_t *lm, } if(ssc->ssc_gh) { - if (ssc->ssc_type == SCT_H264 || ssc->ssc_type == SCT_HEVC) { + if (ssc->es_type == SCT_H264 || ssc->es_type == SCT_HEVC) { sbuf_t hdr; sbuf_init(&hdr); - if (ssc->ssc_type == SCT_H264) { + if (ssc->es_type == SCT_H264) { isom_write_avcc(&hdr, pktbuf_ptr(ssc->ssc_gh), pktbuf_len(ssc->ssc_gh)); } else { @@ -133,12 +133,12 @@ lav_muxer_add_stream(lav_muxer_t *lm, } } - if(SCT_ISAUDIO(ssc->ssc_type)) { + if(SCT_ISAUDIO(ssc->es_type)) { c->codec_type = AVMEDIA_TYPE_AUDIO; c->sample_fmt = AV_SAMPLE_FMT_S16; - c->sample_rate = sri_to_rate(ssc->ssc_sri); - c->channels = ssc->ssc_channels; + c->sample_rate = sri_to_rate(ssc->es_sri); + c->channels = ssc->es_channels; #if 0 c->time_base.num = 1; @@ -147,18 +147,18 @@ lav_muxer_add_stream(lav_muxer_t *lm, c->time_base = st->time_base; #endif - av_dict_set(&st->metadata, "language", ssc->ssc_lang, 0); + av_dict_set(&st->metadata, "language", ssc->es_lang, 0); - } else if(SCT_ISVIDEO(ssc->ssc_type)) { + } else if(SCT_ISVIDEO(ssc->es_type)) { c->codec_type = AVMEDIA_TYPE_VIDEO; - c->width = ssc->ssc_width; - c->height = ssc->ssc_height; + c->width = ssc->es_width; + c->height = ssc->es_height; c->time_base.num = 1; c->time_base.den = 25; - c->sample_aspect_ratio.num = ssc->ssc_aspect_num; - c->sample_aspect_ratio.den = ssc->ssc_aspect_den; + c->sample_aspect_ratio.num = ssc->es_aspect_num; + c->sample_aspect_ratio.den = ssc->es_aspect_den; if (lm->m_config.m_type == MC_AVMP4) { /* this is a whole hell */ @@ -169,9 +169,9 @@ lav_muxer_add_stream(lav_muxer_t *lm, st->sample_aspect_ratio.num = c->sample_aspect_ratio.num; st->sample_aspect_ratio.den = c->sample_aspect_ratio.den; - } else if(SCT_ISSUBTITLE(ssc->ssc_type)) { + } else if(SCT_ISSUBTITLE(ssc->es_type)) { c->codec_type = AVMEDIA_TYPE_SUBTITLE; - av_dict_set(&st->metadata, "language", ssc->ssc_lang, 0); + av_dict_set(&st->metadata, "language", ssc->es_lang, 0); } if(lm->lm_oc->oformat->flags & AVFMT_GLOBALHEADER) @@ -268,11 +268,11 @@ lav_muxer_mime(muxer_t* m, const struct streaming_start *ss) if(ssc->ssc_disabled) continue; - if(!lav_muxer_support_stream(m->m_config.m_type, ssc->ssc_type)) + if(!lav_muxer_support_stream(m->m_config.m_type, ssc->es_type)) continue; - has_video |= SCT_ISVIDEO(ssc->ssc_type); - has_audio |= SCT_ISAUDIO(ssc->ssc_type); + has_video |= SCT_ISVIDEO(ssc->es_type); + has_audio |= SCT_ISAUDIO(ssc->es_type); } if(has_video) @@ -318,9 +318,9 @@ lav_muxer_init(muxer_t* m, struct streaming_start *ss, const char *name) if(ssc->ssc_disabled) continue; - if(!lav_muxer_support_stream(lm->m_config.m_type, ssc->ssc_type)) { + if(!lav_muxer_support_stream(lm->m_config.m_type, ssc->es_type)) { tvhwarn(LS_LIBAV, "%s is not supported in %s", - streaming_component_type2txt(ssc->ssc_type), + streaming_component_type2txt(ssc->es_type), muxer_container_type2txt(lm->m_config.m_type)); ssc->ssc_muxer_disabled = 1; continue; @@ -328,7 +328,7 @@ lav_muxer_init(muxer_t* m, struct streaming_start *ss, const char *name) if(lav_muxer_add_stream(lm, ssc)) { tvherror(LS_LIBAV, "Failed to add %s stream", - streaming_component_type2txt(ssc->ssc_type)); + streaming_component_type2txt(ssc->es_type)); ssc->ssc_muxer_disabled = 1; continue; } diff --git a/src/muxer/muxer_mkv.c b/src/muxer/muxer_mkv.c index e3ac60f34..f965e91a9 100644 --- a/src/muxer/muxer_mkv.c +++ b/src/muxer/muxer_mkv.c @@ -269,24 +269,24 @@ mk_build_tracks(mk_muxer_t *mk, streaming_start_t *ss) tr = &mk->tracks[i]; tr->disabled = ssc->ssc_disabled; - tr->index = ssc->ssc_index; + tr->index = ssc->es_index; if(tr->disabled) continue; - tr->type = ssc->ssc_type; - tr->channels = ssc->ssc_channels; - tr->aspect_num = ssc->ssc_aspect_num; - tr->aspect_den = ssc->ssc_aspect_den; + tr->type = ssc->es_type; + tr->channels = ssc->es_channels; + tr->aspect_num = ssc->es_aspect_num; + tr->aspect_den = ssc->es_aspect_den; tr->commercial = COMMERCIAL_UNKNOWN; - tr->sri = ssc->ssc_sri; + tr->sri = ssc->es_sri; tr->nextpts = PTS_UNSET; - if (mk->webm && ssc->ssc_type != SCT_VP8 && ssc->ssc_type != SCT_VORBIS) + if (mk->webm && ssc->es_type != SCT_VP8 && ssc->es_type != SCT_VORBIS) tvhwarn(LS_MKV, "WEBM format supports only VP8+VORBIS streams (detected %s)", - streaming_component_type2txt(ssc->ssc_type)); + streaming_component_type2txt(ssc->es_type)); - switch(ssc->ssc_type) { + switch(ssc->es_type) { case SCT_MPEG2VIDEO: tracktype = 1; codec_id = "V_MPEG2"; @@ -327,9 +327,9 @@ mk_build_tracks(mk_muxer_t *mk, streaming_start_t *ss) case SCT_MPEG2AUDIO: tracktype = 2; codec_id = "A_MPEG/L2"; - if (ssc->ssc_audio_version == 3) + if (ssc->es_audio_version == 3) codec_id = "A_MPEG/L3"; - else if (ssc->ssc_audio_version == 1) + else if (ssc->es_audio_version == 1) codec_id = "A_MPEG/L1"; break; @@ -396,10 +396,10 @@ disable: ebml_append_uint(t, 0x9c, 0); // Lacing ebml_append_string(t, 0x86, codec_id); - if(ssc->ssc_lang[0]) - ebml_append_string(t, 0x22b59c, ssc->ssc_lang); + if(ssc->es_lang[0]) + ebml_append_string(t, 0x22b59c, ssc->es_lang); - switch(ssc->ssc_type) { + switch(ssc->es_type) { case SCT_HEVC: case SCT_H264: case SCT_MPEG2VIDEO: @@ -431,7 +431,7 @@ disable: uint8_t *header_start[3]; int header_len[3]; int j; - int first_header_size = ssc->ssc_type == SCT_VORBIS ? 30 : 42; + int first_header_size = ssc->es_type == SCT_VORBIS ? 30 : 42; if(mk_split_xiph_headers(pktbuf_ptr(ssc->ssc_gh), pktbuf_len(ssc->ssc_gh), first_header_size, header_start, header_len)) { @@ -449,32 +449,32 @@ disable: break; case SCT_DVBSUB: - buf4[0] = ssc->ssc_composition_id >> 8; - buf4[1] = ssc->ssc_composition_id; - buf4[2] = ssc->ssc_ancillary_id >> 8; - buf4[3] = ssc->ssc_ancillary_id; + buf4[0] = ssc->es_composition_id >> 8; + buf4[1] = ssc->es_composition_id; + buf4[2] = ssc->es_ancillary_id >> 8; + buf4[3] = ssc->es_ancillary_id; ebml_append_bin(t, 0x63a2, buf4, 4); break; } - if(SCT_ISVIDEO(ssc->ssc_type)) { + if(SCT_ISVIDEO(ssc->es_type)) { htsbuf_queue_t *vi = htsbuf_queue_alloc(0); - if(ssc->ssc_frameduration) { - int d = ts_rescale(ssc->ssc_frameduration, 1000000000); + if(ssc->es_frame_duration) { + int d = ts_rescale(ssc->es_frame_duration, 1000000000); ebml_append_uint(t, 0x23e383, d); } - ebml_append_uint(vi, 0xb0, ssc->ssc_width); - ebml_append_uint(vi, 0xba, ssc->ssc_height); + ebml_append_uint(vi, 0xb0, ssc->es_width); + ebml_append_uint(vi, 0xba, ssc->es_height); - if (ssc->ssc_aspect_num && ssc->ssc_aspect_den) { + if (ssc->es_aspect_num && ssc->es_aspect_den) { if (mk->webm) { - ebml_append_uint(vi, 0x54b0, (ssc->ssc_height * ssc->ssc_aspect_num) / ssc->ssc_aspect_den); - ebml_append_uint(vi, 0x54ba, ssc->ssc_height); + ebml_append_uint(vi, 0x54b0, (ssc->es_height * ssc->es_aspect_num) / ssc->es_aspect_den); + ebml_append_uint(vi, 0x54ba, ssc->es_height); ebml_append_uint(vi, 0x54b2, 0); // DisplayUnit: pixels because DAR is not supported by webm } else { - ebml_append_uint(vi, 0x54b0, ssc->ssc_aspect_num); - ebml_append_uint(vi, 0x54ba, ssc->ssc_aspect_den); + ebml_append_uint(vi, 0x54b0, ssc->es_aspect_num); + ebml_append_uint(vi, 0x54ba, ssc->es_aspect_den); ebml_append_uint(vi, 0x54b2, 3); // DisplayUnit: DAR } } @@ -482,13 +482,13 @@ disable: ebml_append_master(t, 0xe0, vi); } - if(SCT_ISAUDIO(ssc->ssc_type)) { + if(SCT_ISAUDIO(ssc->es_type)) { htsbuf_queue_t *au = htsbuf_queue_alloc(0); - ebml_append_float(au, 0xb5, sri_to_rate(ssc->ssc_sri)); - if (ssc->ssc_ext_sri) - ebml_append_float(au, 0x78b5, sri_to_rate(ssc->ssc_ext_sri - 1)); - ebml_append_uint(au, 0x9f, ssc->ssc_channels); + ebml_append_float(au, 0xb5, sri_to_rate(ssc->es_sri)); + if (ssc->es_ext_sri) + ebml_append_float(au, 0x78b5, sri_to_rate(ssc->es_ext_sri - 1)); + ebml_append_uint(au, 0x9f, ssc->es_channels); if (bit_depth) ebml_append_uint(au, 0x6264, bit_depth); @@ -1299,8 +1299,8 @@ mkv_muxer_mime(muxer_t* m, const struct streaming_start *ss) if(ssc->ssc_disabled) continue; - has_video |= SCT_ISVIDEO(ssc->ssc_type); - has_audio |= SCT_ISAUDIO(ssc->ssc_type); + has_video |= SCT_ISVIDEO(ssc->es_type); + has_audio |= SCT_ISAUDIO(ssc->es_type); } if(has_video) diff --git a/src/muxer/muxer_pass.c b/src/muxer/muxer_pass.c index b2000728e..a6ea51dd1 100644 --- a/src/muxer/muxer_pass.c +++ b/src/muxer/muxer_pass.c @@ -152,7 +152,7 @@ pass_muxer_pmt_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) for (i = 0; i < pm->pm_ss->ss_num_components; i++) { ssc = &pm->pm_ss->ss_components[i]; - if (ssc->ssc_pid == pid) + if (ssc->es_pid == pid) break; } if (i < pm->pm_ss->ss_num_components) { @@ -291,8 +291,8 @@ pass_muxer_mime(muxer_t* m, const struct streaming_start *ss) if(ssc->ssc_disabled) continue; - has_video |= SCT_ISVIDEO(ssc->ssc_type); - has_audio |= SCT_ISAUDIO(ssc->ssc_type); + has_video |= SCT_ISVIDEO(ssc->es_type); + has_audio |= SCT_ISAUDIO(ssc->es_type); } if(si->si_type == S_MPEG_TS) @@ -332,13 +332,13 @@ pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss) for(i=0; i < ss->ss_num_components; i++) { ssc = &ss->ss_components[i]; - if (!SCT_ISVIDEO(ssc->ssc_type) && !SCT_ISAUDIO(ssc->ssc_type)) + if (!SCT_ISVIDEO(ssc->es_type) && !SCT_ISAUDIO(ssc->es_type)) continue; - if (ssc->ssc_pid == DVB_SDT_PID && pm->pm_rewrite_sdt) { + if (ssc->es_pid == DVB_SDT_PID && pm->pm_rewrite_sdt) { tvhwarn(LS_PASS, "SDT PID shared with A/V, rewrite disabled"); pm->pm_rewrite_sdt = 0; } - if (ssc->ssc_pid == DVB_EIT_PID && pm->pm_rewrite_eit) { + if (ssc->es_pid == DVB_EIT_PID && pm->pm_rewrite_eit) { tvhwarn(LS_PASS, "EIT PID shared with A/V, rewrite disabled"); pm->pm_rewrite_eit = 0; } @@ -673,4 +673,3 @@ pass_muxer_create(const muxer_config_t *m_cfg, return (muxer_t *)pm; } - diff --git a/src/parsers/message.c b/src/parsers/message.c index 6d091c526..ab74a2861 100644 --- a/src/parsers/message.c +++ b/src/parsers/message.c @@ -310,10 +310,10 @@ static void parser_input_start(parser_t *prs, streaming_message_t *sm) for (i = 0; i < ss->ss_num_components; i++) { pes = &prs->prs_es[i]; ssc = &ss->ss_components[i]; - parser_init_es(&prs->prs_es[i], prs, ssc->ssc_type); + parser_init_es(&prs->prs_es[i], prs, ssc->es_type); pes->es_service = prs->prs_service; - pes->es_index = ssc->ssc_index; - pes->es_pid = ssc->ssc_pid; + pes->es_index = ssc->es_index; + pes->es_pid = ssc->es_pid; if (pes->es_pid != -1) { snprintf(buf, sizeof(buf), "%s: %s @ #%d", service_nicename(prs->prs_service), diff --git a/src/plumbing/globalheaders.c b/src/plumbing/globalheaders.c index cc7f7319f..c0cd23d09 100644 --- a/src/plumbing/globalheaders.c +++ b/src/plumbing/globalheaders.c @@ -82,19 +82,19 @@ gh_flush(globalheaders_t *gh) static void apply_header(streaming_start_component_t *ssc, th_pkt_t *pkt) { - if(ssc->ssc_frameduration == 0 && pkt->pkt_duration != 0) - ssc->ssc_frameduration = pkt->pkt_duration; + if(ssc->es_frame_duration == 0 && pkt->pkt_duration != 0) + ssc->es_frame_duration = pkt->pkt_duration; - if(SCT_ISAUDIO(ssc->ssc_type) && !ssc->ssc_channels) { - ssc->ssc_channels = pkt->a.pkt_channels; - ssc->ssc_sri = pkt->a.pkt_sri; - ssc->ssc_ext_sri = pkt->a.pkt_ext_sri; + if(SCT_ISAUDIO(ssc->es_type) && !ssc->es_channels) { + ssc->es_channels = pkt->a.pkt_channels; + ssc->es_sri = pkt->a.pkt_sri; + ssc->es_ext_sri = pkt->a.pkt_ext_sri; } - if(SCT_ISVIDEO(ssc->ssc_type)) { + if(SCT_ISVIDEO(ssc->es_type)) { if(pkt->v.pkt_aspect_num && pkt->v.pkt_aspect_den) { - ssc->ssc_aspect_num = pkt->v.pkt_aspect_num; - ssc->ssc_aspect_den = pkt->v.pkt_aspect_den; + ssc->es_aspect_num = pkt->v.pkt_aspect_num; + ssc->es_aspect_den = pkt->v.pkt_aspect_den; } } @@ -107,7 +107,7 @@ apply_header(streaming_start_component_t *ssc, th_pkt_t *pkt) return; } - if (ssc->ssc_type == SCT_MP4A || ssc->ssc_type == SCT_AAC) { + if (ssc->es_type == SCT_MP4A || ssc->es_type == SCT_AAC) { ssc->ssc_gh = pktbuf_alloc(NULL, pkt->a.pkt_ext_sri ? 5 : 2); uint8_t *d = pktbuf_ptr(ssc->ssc_gh); @@ -129,22 +129,22 @@ apply_header(streaming_start_component_t *ssc, th_pkt_t *pkt) static int header_complete(streaming_start_component_t *ssc, int not_so_picky) { - int is_video = SCT_ISVIDEO(ssc->ssc_type); - int is_audio = !is_video && SCT_ISAUDIO(ssc->ssc_type); + int is_video = SCT_ISVIDEO(ssc->es_type); + int is_audio = !is_video && SCT_ISAUDIO(ssc->es_type); - if((is_audio || is_video) && ssc->ssc_frameduration == 0) + if((is_audio || is_video) && ssc->es_frame_duration == 0) return 0; if(is_video) { - if(!not_so_picky && (ssc->ssc_aspect_num == 0 || ssc->ssc_aspect_den == 0 || - ssc->ssc_width == 0 || ssc->ssc_height == 0)) + if(!not_so_picky && (ssc->es_aspect_num == 0 || ssc->es_aspect_den == 0 || + ssc->es_width == 0 || ssc->es_height == 0)) return 0; } - if(is_audio && !ssc->ssc_channels) + if(is_audio && !ssc->es_channels) return 0; - if(ssc->ssc_gh == NULL && gh_require_meta(ssc->ssc_type)) + if(ssc->ssc_gh == NULL && gh_require_meta(ssc->es_type)) return 0; return 1; @@ -169,7 +169,7 @@ gh_queue_delay(globalheaders_t *gh, int index) if (f->pr_pkt->pkt_dts != PTS_UNSET) { ssc = streaming_start_component_find_by_index (gh->gh_ss, f->pr_pkt->pkt_componentindex); - if (ssc && ssc->ssc_index == index) + if (ssc && ssc->es_index == index) break; } f = TAILQ_NEXT(f, pr_link); @@ -178,7 +178,7 @@ gh_queue_delay(globalheaders_t *gh, int index) if (l->pr_pkt->pkt_dts != PTS_UNSET) { ssc = streaming_start_component_find_by_index (gh->gh_ss, l->pr_pkt->pkt_componentindex); - if (ssc && ssc->ssc_index == index) + if (ssc && ssc->es_index == index) break; } l = TAILQ_PREV(l, th_pktref_queue, pr_link); @@ -216,8 +216,8 @@ headers_complete(globalheaders_t *gh) for(i = 0; i < ss->ss_num_components; i++) { ssc = &ss->ss_components[i]; - qd[i] = gh_is_audiovideo(ssc->ssc_type) ? - gh_queue_delay(gh, ssc->ssc_index) : 0; + qd[i] = gh_is_audiovideo(ssc->es_type) ? + gh_queue_delay(gh, ssc->es_index) : 0; if (qd[i] > qd_max) qd_max = qd[i]; } @@ -239,8 +239,8 @@ headers_complete(globalheaders_t *gh) if(threshold || (qd[i] <= 0 && qd_max > (MAX_SCAN_TIME * 90) / 2)) { ssc->ssc_disabled = 1; tvhdebug(LS_GLOBALHEADERS, "gh disable stream %d %s%s%s (PID %i) threshold %d qd %"PRId64" qd_max %"PRId64, - ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), - ssc->ssc_lang[0] ? " " : "", ssc->ssc_lang, ssc->ssc_pid, + ssc->es_index, streaming_component_type2txt(ssc->es_type), + ssc->es_lang[0] ? " " : "", ssc->es_lang, ssc->es_pid, threshold, qd[i], qd_max); } else { return 0; @@ -254,9 +254,9 @@ headers_complete(globalheaders_t *gh) for(i = 0; i < ss->ss_num_components; i++) { ssc = &ss->ss_components[i]; tvhtrace(LS_GLOBALHEADERS, "stream %d %s%s%s (PID %i) complete time %"PRId64"%s", - ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), - ssc->ssc_lang[0] ? " " : "", ssc->ssc_lang, ssc->ssc_pid, - gh_queue_delay(gh, ssc->ssc_index), + ssc->es_index, streaming_component_type2txt(ssc->es_type), + ssc->es_lang[0] ? " " : "", ssc->es_lang, ssc->es_pid, + gh_queue_delay(gh, ssc->es_index), ssc->ssc_disabled ? " disabled" : ""); } } @@ -307,7 +307,7 @@ gh_hold(globalheaders_t *gh, streaming_message_t *sm) streaming_msg_free(sm); - if(!gh_is_audiovideo(ssc->ssc_type)) + if(!gh_is_audiovideo(ssc->es_type)) break; if(!headers_complete(gh)) diff --git a/src/plumbing/tsfix.c b/src/plumbing/tsfix.c index 776389175..58ed54eaf 100644 --- a/src/plumbing/tsfix.c +++ b/src/plumbing/tsfix.c @@ -161,9 +161,9 @@ tsfix_start(tsfix_t *tf, streaming_start_t *ss) for(i = 0; i < ss->ss_num_components; i++) { const streaming_start_component_t *ssc = &ss->ss_components[i]; - tfs = tsfix_add_stream(tf, ssc->ssc_index, ssc->ssc_type); + tfs = tsfix_add_stream(tf, ssc->es_index, ssc->es_type); if (tfs->tfs_video) { - if (ssc->ssc_width == 0 || ssc->ssc_height == 0) + if (ssc->es_width == 0 || ssc->es_height == 0) /* only first video stream may be valid */ vwait = !hasvideo ? 1 : 0; hasvideo = 1; diff --git a/src/streaming.c b/src/streaming.c index 3013f3719..037c0d0d1 100644 --- a/src/streaming.c +++ b/src/streaming.c @@ -547,7 +547,7 @@ streaming_start_component_find_by_index(streaming_start_t *ss, int idx) streaming_start_component_t *ssc; int i; for(i = 0, ssc = ss->ss_components; i < ss->ss_num_components; i++, ssc++) - if(ssc->ssc_index == idx) + if(ssc->es_index == idx) return ssc; return NULL; } @@ -639,4 +639,4 @@ void streaming_done(void) pthread_mutex_lock(&global_lock); memoryinfo_unregister(&streaming_msg_memoryinfo); pthread_mutex_unlock(&global_lock); -} +} \ No newline at end of file diff --git a/src/streaming.h b/src/streaming.h index bdff51b2a..3c66304ab 100644 --- a/src/streaming.h +++ b/src/streaming.h @@ -388,28 +388,12 @@ struct source_info { * */ struct streaming_start_component { - int ssc_index; - int ssc_type; - char ssc_lang[4]; - uint8_t ssc_audio_type; - uint8_t ssc_audio_version; - uint16_t ssc_composition_id; - uint16_t ssc_ancillary_id; - uint16_t ssc_pid; - int16_t ssc_width; - int16_t ssc_height; - int16_t ssc_aspect_num; - int16_t ssc_aspect_den; - uint8_t ssc_sri; - uint8_t ssc_ext_sri; - uint8_t ssc_channels; + elementary_info_t; + uint8_t ssc_disabled; uint8_t ssc_muxer_disabled; pktbuf_t *ssc_gh; - - int ssc_frameduration; - }; diff --git a/src/timeshift/timeshift_writer.c b/src/timeshift/timeshift_writer.c index da7ee3522..092c1eca0 100644 --- a/src/timeshift/timeshift_writer.c +++ b/src/timeshift/timeshift_writer.c @@ -245,8 +245,8 @@ static void _update_smt_start ( timeshift_t *ts, streaming_start_t *ss ) /* Update video index */ for (i = 0; i < ss->ss_num_components; i++) - if (SCT_ISVIDEO(ss->ss_components[i].ssc_type)) { - ts->vididx = ss->ss_components[i].ssc_index; + if (SCT_ISVIDEO(ss->ss_components[i].es_type)) { + ts->vididx = ss->ss_components[i].es_index; break; } } diff --git a/src/transcoding/codec/profile.c b/src/transcoding/codec/profile.c index 3fd85571e..93fe8c8a9 100644 --- a/src/transcoding/codec/profile.c +++ b/src/transcoding/codec/profile.c @@ -226,7 +226,7 @@ tvh_codec_profile_is_copy(TVHCodecProfile *self, tvh_ssc_t *ssc) tvherror(LS_CODEC, "unknown type for profile '%s'", self->name); return -1; } - if (out_type == ssc->ssc_type) { + if (out_type == ssc->es_type) { idclass = (&self->idnode)->in_class; while (idclass) { codec_profile_class = (codec_profile_class_t *)idclass; diff --git a/src/transcoding/codec/profile_audio_class.c b/src/transcoding/codec/profile_audio_class.c index 3ad752597..dc3e22550 100644 --- a/src/transcoding/codec/profile_audio_class.c +++ b/src/transcoding/codec/profile_audio_class.c @@ -125,8 +125,8 @@ tvh_codec_profile_audio_is_copy(TVHAudioCodecProfile *self, tvh_ssc_t *ssc) // TODO: fix me // assuming default channel_layout (AV_CH_LAYOUT_STEREO) // and sample_rate (48kHz) for input - int ssc_channels = ssc->ssc_channels ? ssc->ssc_channels : 2; - int ssc_sr = ssc->ssc_sri ? sri_to_rate(ssc->ssc_sri) : 48000; + int ssc_channels = ssc->es_channels ? ssc->es_channels : 2; + int ssc_sr = ssc->es_sri ? sri_to_rate(ssc->es_sri) : 48000; if ((self->channel_layout && ssc_channels != av_get_channel_layout_nb_channels(self->channel_layout)) || (self->sample_rate && ssc_sr != self->sample_rate)) { diff --git a/src/transcoding/codec/profile_video_class.c b/src/transcoding/codec/profile_video_class.c index ec99f0098..6537745b8 100644 --- a/src/transcoding/codec/profile_video_class.c +++ b/src/transcoding/codec/profile_video_class.c @@ -61,12 +61,12 @@ tvh_codec_video_get_list_pix_fmts(TVHVideoCodec *self) static int tvh_codec_profile_video_setup(TVHVideoCodecProfile *self, tvh_ssc_t *ssc) { - self->size.den = ssc->ssc_height; - self->size.num = ssc->ssc_width; + self->size.den = ssc->es_height; + self->size.num = ssc->es_width; if (self->height) { self->size.den = self->height; self->size.den += self->size.den & 1; - self->size.num = self->size.den * ((double)ssc->ssc_width / ssc->ssc_height); + self->size.num = self->size.den * ((double)ssc->es_width / ssc->es_height); self->size.num += self->size.num & 1; } return 0; @@ -76,7 +76,7 @@ tvh_codec_profile_video_setup(TVHVideoCodecProfile *self, tvh_ssc_t *ssc) static int tvh_codec_profile_video_is_copy(TVHVideoCodecProfile *self, tvh_ssc_t *ssc) { - return (!self->deinterlace && (self->size.den == ssc->ssc_height)); + return (!self->deinterlace && (self->size.den == ssc->es_height)); } diff --git a/src/transcoding/transcode/log.h b/src/transcoding/transcode/log.h index 31e8974ed..335bf38a4 100644 --- a/src/transcoding/transcode/log.h +++ b/src/transcoding/transcode/log.h @@ -41,8 +41,8 @@ do { \ _stream_log((level), fmt, \ (transcoder), \ - (ssc)->ssc_index, \ - (ssc)->ssc_type, \ + (ssc)->es_index, \ + (ssc)->es_type, \ ##__VA_ARGS__); \ } while (0) diff --git a/src/transcoding/transcode/stream.c b/src/transcoding/transcode/stream.c index 2c5c6864c..cd6e7e5c6 100644 --- a/src/transcoding/transcode/stream.c +++ b/src/transcoding/transcode/stream.c @@ -36,7 +36,7 @@ tvh_stream_is_copy(TVHCodecProfile *profile, tvh_ssc_t *ssc, if (src_codecs && *src_codecs != '\0' && *src_codecs != '-') { list = htsmsg_csv_2_list(src_codecs, ','); if (list) { - txtname = streaming_component_type2txt(ssc->ssc_type); + txtname = streaming_component_type2txt(ssc->es_type); r = htsmsg_is_string_in_list(list, txtname); htsmsg_destroy(list); if (r) @@ -55,12 +55,12 @@ cont: static int tvh_stream_setup(TVHStream *self, TVHCodecProfile *profile, tvh_ssc_t *ssc) { - enum AVCodecID icodec_id = streaming_component_type2codec_id(ssc->ssc_type); + enum AVCodecID icodec_id = streaming_component_type2codec_id(ssc->es_type); AVCodec *icodec = NULL, *ocodec = NULL; if (icodec_id == AV_CODEC_ID_NONE) { tvh_stream_log(self, LOG_ERR, "unknown decoder id for '%s'", - streaming_component_type2txt(ssc->ssc_type)); + streaming_component_type2txt(ssc->es_type)); return -1; } #if ENABLE_MMAL @@ -77,7 +77,7 @@ tvh_stream_setup(TVHStream *self, TVHCodecProfile *profile, tvh_ssc_t *ssc) #endif if (!icodec && !(icodec = avcodec_find_decoder(icodec_id))) { tvh_stream_log(self, LOG_ERR, "failed to find decoder for '%s'", - streaming_component_type2txt(ssc->ssc_type)); + streaming_component_type2txt(ssc->es_type)); return -1; } if (!(ocodec = tvh_codec_profile_get_avcodec(profile))) { @@ -95,8 +95,8 @@ tvh_stream_setup(TVHStream *self, TVHCodecProfile *profile, tvh_ssc_t *ssc) icodec, ocodec, ssc->ssc_gh))) { return -1; } - self->type = ssc->ssc_type = codec_id2streaming_component_type(ocodec->id); - if (ssc->ssc_type == SCT_UNKNOWN) { + self->type = ssc->es_type = codec_id2streaming_component_type(ocodec->id); + if (ssc->es_type == SCT_UNKNOWN) { tvh_stream_log(self, LOG_ERR, "unable to translate AV type %s [%d] to SCT!", ocodec->name, ocodec->id); } ssc->ssc_gh = NULL; @@ -149,8 +149,8 @@ tvh_stream_create(TVHTranscoder *transcoder, TVHCodecProfile *profile, return NULL; } self->transcoder = transcoder; - self->id = self->index = ssc->ssc_index; - self->type = ssc->ssc_type; + self->id = self->index = ssc->es_index; + self->type = ssc->es_type; if ((is_copy = tvh_stream_is_copy(profile, ssc, src_codecs)) > 0) { self->is_copy = 1; if (ssc->ssc_gh) { diff --git a/src/transcoding/transcode/transcoder.c b/src/transcoding/transcode/transcoder.c index 3a6a4c632..902f444aa 100644 --- a/src/transcoding/transcode/transcoder.c +++ b/src/transcoding/transcode/transcoder.c @@ -35,13 +35,13 @@ ssc_get_media_type(tvh_ssc_t *ssc) if (ssc->ssc_disabled) { return AVMEDIA_TYPE_UNKNOWN; } - if (SCT_ISVIDEO(ssc->ssc_type)) { + if (SCT_ISVIDEO(ssc->es_type)) { return AVMEDIA_TYPE_VIDEO; } - if (SCT_ISAUDIO(ssc->ssc_type)) { + if (SCT_ISAUDIO(ssc->es_type)) { return AVMEDIA_TYPE_AUDIO; } - if (SCT_ISSUBTITLE(ssc->ssc_type)) { + if (SCT_ISSUBTITLE(ssc->es_type)) { return AVMEDIA_TYPE_SUBTITLE; } return AVMEDIA_TYPE_UNKNOWN; @@ -74,7 +74,7 @@ lang_match(const char *lang, tvh_ssc_t *ssc, int *index, int value) { if (*index >= 0) return 0; - if (lang && strcmp(lang, ssc->ssc_lang) == 0) { + if (lang && strcmp(lang, ssc->es_lang) == 0) { *index = value; return 1; } @@ -232,7 +232,7 @@ tvh_transcoder_start(TVHTranscoder *self, tvh_ss_t *ss_src) if (j < count) continue; ssc_src = &ss_src->ss_components[i]; - switch (ssc_src->ssc_type) { + switch (ssc_src->es_type) { case SCT_CA: case SCT_HBBTV: case SCT_TELETEXT: