Commit 2568a24f authored by François Cartegnie's avatar François Cartegnie 🤞

mux: ts: add base support for standards compliance

parent e0b8480e
......@@ -342,6 +342,7 @@ void MissingPATPMTFixup( demux_t *p_demux )
}
BuildPMT( GetPID(p_sys, 0)->u.p_pat->handle, VLC_OBJECT(p_demux),
p_sys->standard == TS_STANDARD_ATSC ? TS_MUX_STANDARD_ATSC : TS_MUX_STANDARD_DVB,
p_program_pid, BuildPMTCallback,
0, 1,
i_pcr_pid,
......
......@@ -352,6 +352,7 @@ static inline size_t Write_AnnexA_String( uint8_t *p_dest, const char *p_src )
}
void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
ts_mux_standard standard,
void *p_opaque, PEStoTSCallback pf_callback,
int i_tsid, int i_pmt_version_number,
int i_pcr_pid,
......@@ -363,6 +364,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
if( !dvbpmt )
return;
VLC_UNUSED(standard);
dvbpsi_sdt_t sdtpsi;
uint8_t *pi_service_types = NULL;
uint8_t *pi_service_cats = NULL;
......@@ -461,6 +463,8 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
}
else if( p_stream->pes->i_codec == VLC_CODEC_EAC3 )
{
/* FIXME: ATSC AC-3 audio_stream_descriptor */
/* FIXME: DVB AC-3 descriptor */
uint8_t data[1] = { 0x00 };
dvbpsi_pmt_es_descriptor_add( p_es, 0x7a, 1, data );
}
......
......@@ -49,7 +49,14 @@ typedef struct
int i_mapped_prog;
} pes_mapped_stream_t;
typedef enum ts_mux_standard
{
TS_MUX_STANDARD_DVB = 0,
TS_MUX_STANDARD_ATSC,
} ts_mux_standard;
void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
ts_mux_standard,
void *p_opaque, PEStoTSCallback pf_callback,
int i_tsid, int i_pmt_version_number,
int i_pcr_pid,
......
......@@ -90,6 +90,13 @@ static int ActiveKeyCallback ( vlc_object_t *, char const *, vlc_value_t, vlc
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
static const char *const ts_standards_list[] =
{ "dvb", "atsc", };
static const char *const ts_standards_list_text[] =
{ "DVB", "ATSC", };
#define STANDARD_TEXT N_("Digital TV Standard")
#define VPID_TEXT N_("Video PID")
#define VPID_LONGTEXT N_("Assign a fixed PID to the video stream. The PCR " \
"PID will automatically be the video.")
......@@ -193,6 +200,8 @@ vlc_module_begin ()
set_capability( "sout mux", 120 )
add_shortcut( "ts" )
add_string( SOUT_CFG_PREFIX "standard", "dvb", STANDARD_TEXT, NULL, true )
change_string_list( ts_standards_list, ts_standards_list_text )
add_integer(SOUT_CFG_PREFIX "pid-video", 100, VPID_TEXT, VPID_LONGTEXT, true)
change_integer_range( 32, 8190 )
add_integer(SOUT_CFG_PREFIX "pid-audio", 200, APID_TEXT, APID_LONGTEXT, true)
......@@ -231,6 +240,7 @@ vlc_module_end ()
* Local data structures
*****************************************************************************/
static const char *const ppsz_sout_options[] = {
"standard",
"pid-video", "pid-audio", "pid-spu", "pid-pmt", "tsid",
"netid", "sdtdesc",
"es-id-pid", "shaping", "pcr", "bmin", "bmax", "use-key-frames",
......@@ -351,6 +361,7 @@ struct sout_mux_sys_t
bool b_data_alignment;
sdt_psi_t sdt;
ts_mux_standard standard;
/* for TS building */
int64_t i_bitrate_min;
......@@ -543,6 +554,11 @@ static int Open( vlc_object_t *p_this )
}
p_sys->p_dvbpsi->p_sys = (void *) p_mux;
char *psz_standard = var_GetString( p_mux, SOUT_CFG_PREFIX "standard" );
if( psz_standard && !strcmp("atsc", psz_standard) )
p_sys->standard = TS_MUX_STANDARD_ATSC;
free( psz_standard );
p_sys->b_es_id_pid = var_GetBool( p_mux, SOUT_CFG_PREFIX "es-id-pid" );
/*
......@@ -975,8 +991,15 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
p_stream->pes.i_stream_id = 0xc0;
break;
case VLC_CODEC_A52:
p_stream->ts.i_stream_type = 0x81;
p_stream->pes.i_stream_id = 0xbd;
if( p_sys->standard == TS_MUX_STANDARD_ATSC )
{
p_stream->ts.i_stream_type = 0x81;
}
else
{
p_stream->ts.i_stream_type = 0x06;
}
break;
case VLC_CODEC_DVD_LPCM:
p_stream->ts.i_stream_type = 0x83;
......@@ -989,9 +1012,27 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
break;
}
case VLC_CODEC_EAC3:
case VLC_CODEC_DTS:
p_stream->ts.i_stream_type = 0x06;
p_stream->pes.i_stream_id = 0xbd;
if( p_sys->standard == TS_MUX_STANDARD_ATSC )
{
/* FIXME: Mandatory EAC3 audio_descriptor */
p_stream->ts.i_stream_type = 0x87;
}
else
{
p_stream->ts.i_stream_type = 0x06;
}
break;
case VLC_CODEC_DTS:
if( p_sys->standard == TS_MUX_STANDARD_ATSC )
{
return VLC_EGENERIC;
}
else
{
p_stream->ts.i_stream_type = 0x06;
p_stream->pes.i_stream_id = 0xbd;
}
break;
case VLC_CODEC_MP4A:
/* XXX: make that configurable in some way when LOAS
......@@ -1996,7 +2037,7 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
mappeds[i_stream].ts = &p_stream->ts;
}
BuildPMT( p_sys->p_dvbpsi, VLC_OBJECT(p_mux),
BuildPMT( p_sys->p_dvbpsi, VLC_OBJECT(p_mux), p_sys->standard,
c, (PEStoTSCallback)BufferChainAppend,
p_sys->i_tsid, p_sys->i_pmt_version_number,
((sout_input_sys_t *)p_sys->p_pcr_input->p_sys)->ts.i_pid,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment