From 4b86d2fd200fc2a65dab0da6381f1337b892ac63 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Mon, 13 May 2013 09:27:01 +0100 Subject: [PATCH] Parse the audio_type field of the iso639_language_descriptor - this indicates if the audio stream contains audio description for the hard of hearing. Use this value when regenerating the PMT for the passthrough muxer, and also include it in the HTSP stream description messages. --- src/htsp_server.c | 1 + src/psi.c | 30 +++++++++++++++++++----------- src/service.c | 1 + src/service.h | 2 ++ src/streaming.h | 1 + 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/htsp_server.c b/src/htsp_server.c index 2a670a69..eeb15ace 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -2421,6 +2421,7 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss) if (SCT_ISAUDIO(ssc->ssc_type)) { + htsmsg_add_u32(c, "audio_type", ssc->ssc_audio_type); if (ssc->ssc_channels) htsmsg_add_u32(c, "channels", ssc->ssc_channels); if (ssc->ssc_sri) diff --git a/src/psi.c b/src/psi.c index d86519c8..dc8ec979 100644 --- a/src/psi.c +++ b/src/psi.c @@ -172,16 +172,17 @@ psi_build_pat(service_t *t, uint8_t *buf, int maxlen, int pmtpid) #define PMT_UPDATE_PCR 0x1 #define PMT_UPDATE_NEW_STREAM 0x2 #define PMT_UPDATE_LANGUAGE 0x4 -#define PMT_UPDATE_FRAME_DURATION 0x8 -#define PMT_UPDATE_COMPOSITION_ID 0x10 -#define PMT_UPDATE_ANCILLARY_ID 0x20 -#define PMT_UPDATE_STREAM_DELETED 0x40 -#define PMT_UPDATE_NEW_CA_STREAM 0x80 -#define PMT_UPDATE_NEW_CAID 0x100 -#define PMT_UPDATE_CA_PROVIDER_CHANGE 0x200 -#define PMT_UPDATE_PARENT_PID 0x400 -#define PMT_UPDATE_CAID_DELETED 0x800 -#define PMT_REORDERED 0x1000 +#define PMT_UPDATE_AUDIO_TYPE 0x8 +#define PMT_UPDATE_FRAME_DURATION 0x10 +#define PMT_UPDATE_COMPOSITION_ID 0x20 +#define PMT_UPDATE_ANCILLARY_ID 0x40 +#define PMT_UPDATE_STREAM_DELETED 0x80 +#define PMT_UPDATE_NEW_CA_STREAM 0x100 +#define PMT_UPDATE_NEW_CAID 0x200 +#define PMT_UPDATE_CA_PROVIDER_CHANGE 0x400 +#define PMT_UPDATE_PARENT_PID 0x800 +#define PMT_UPDATE_CAID_DELETED 0x1000 +#define PMT_REORDERED 0x2000 /** * Add a CA descriptor @@ -397,6 +398,7 @@ psi_parse_pmt(service_t *t, const uint8_t *ptr, int len, int chksvcid, int position = 0; int tt_position = 1000; const char *lang = NULL; + uint8_t audio_type = 0; caid_t *c, *cn; @@ -529,6 +531,7 @@ psi_parse_pmt(service_t *t, const uint8_t *ptr, int len, int chksvcid, case DVB_DESC_LANGUAGE: lang = lang_code_get2((const char*)ptr, 3); + audio_type = ptr[3]; break; case DVB_DESC_TELETEXT: @@ -601,6 +604,11 @@ psi_parse_pmt(service_t *t, const uint8_t *ptr, int len, int chksvcid, memcpy(st->es_lang, lang, 4); } + if(st->es_audio_type != audio_type) { + update |= PMT_UPDATE_AUDIO_TYPE; + st->es_audio_type = audio_type; + } + if(composition_id != -1 && st->es_composition_id != composition_id) { st->es_composition_id = composition_id; update |= PMT_UPDATE_COMPOSITION_ID; @@ -756,7 +764,7 @@ psi_build_pmt(const streaming_start_t *ss, uint8_t *buf0, int maxlen, buf[0] = DVB_DESC_LANGUAGE; buf[1] = 4; memcpy(&buf[2],ssc->ssc_lang,3); - buf[5] = 0; /* Main audio */ + buf[5] = ssc->ssc_audio_type; dlen = 6; break; case SCT_DVBSUB: diff --git a/src/service.c b/src/service.c index 7851f5c2..c6666b5f 100644 --- a/src/service.c +++ b/src/service.c @@ -908,6 +908,7 @@ service_build_stream_start(service_t *t) ssc->ssc_type = st->es_type; memcpy(ssc->ssc_lang, st->es_lang, 4); + ssc->ssc_audio_type = st->es_audio_type; ssc->ssc_composition_id = st->es_composition_id; ssc->ssc_ancillary_id = st->es_ancillary_id; ssc->ssc_pid = st->es_pid; diff --git a/src/service.h b/src/service.h index d2f8b03b..8b96156e 100644 --- a/src/service.h +++ b/src/service.h @@ -82,6 +82,8 @@ typedef struct elementary_stream { uint16_t es_aspect_den; char es_lang[4]; /* ISO 639 2B 3-letter language code */ + uint8_t es_audio_type; /* Audio type */ + uint16_t es_composition_id; uint16_t es_ancillary_id; diff --git a/src/streaming.h b/src/streaming.h index 75dc7857..855be286 100644 --- a/src/streaming.h +++ b/src/streaming.h @@ -27,6 +27,7 @@ typedef struct streaming_start_component { int ssc_index; int ssc_type; char ssc_lang[4]; + uint8_t ssc_audio_type; uint16_t ssc_composition_id; uint16_t ssc_ancillary_id; uint16_t ssc_pid;