[vlc-commits] [Git][videolan/vlc][master] 4 commits: mux: ts: tag PID transport with scrambling
François Cartegnie (@fcartegnie)
gitlab at videolan.org
Sat Dec 23 13:18:06 UTC 2023
François Cartegnie pushed to branch master at VideoLAN / VLC
Commits:
1befe288 by François Cartegnie at 2023-12-23T13:01:21+00:00
mux: ts: tag PID transport with scrambling
- - - - -
cde6d046 by François Cartegnie at 2023-12-23T13:01:21+00:00
mux: ts: add mandatory scrambling_descriptor
- - - - -
23995f89 by François Cartegnie at 2023-12-23T13:01:21+00:00
mux: ts: use struct for gathering service infos
- - - - -
b85cb032 by François Cartegnie at 2023-12-23T13:01:21+00:00
mux: mpeg: tag SDT with scrambling info
- - - - -
3 changed files:
- modules/mux/mpeg/streams.h
- modules/mux/mpeg/tables.c
- modules/mux/mpeg/ts.c
Changes:
=====================================
modules/mux/mpeg/streams.h
=====================================
@@ -27,6 +27,7 @@ typedef struct
uint8_t i_stream_type;
uint8_t i_continuity_counter;
bool b_discontinuity;
+ bool b_scramble;
} tsmux_stream_t;
=====================================
modules/mux/mpeg/tables.c
=====================================
@@ -317,11 +317,20 @@ static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
dvbpsi_pmt_descriptor_add(&p_dvbpmt[0], 0x1d, bits.i_data, bits.p_data);
}
-static void UpdateServiceType( uint8_t *pi_service_cat, uint8_t *pi_service_type,
+struct service_info
+{
+ uint8_t cat;
+ uint8_t type;
+ bool b_scrambled;
+};
+
+static void UpdateServiceType( struct service_info *info,
const tsmux_stream_t *p_ts, const es_format_t *fmt )
{
uint8_t i_type = 0x00;
+ info->b_scrambled |= p_ts->b_scramble;
+
switch( p_ts->i_stream_type )
{
case 0x01: /* MPEG1 */
@@ -355,15 +364,15 @@ static void UpdateServiceType( uint8_t *pi_service_cat, uint8_t *pi_service_type
if( i_type != 0x00 )
{
- if( *pi_service_cat != VIDEO_ES || i_type > *pi_service_type )
+ if( info->cat != VIDEO_ES || i_type > info->type )
{
- *pi_service_type = i_type;
- *pi_service_cat = VIDEO_ES;
+ info->type = i_type;
+ info->cat = VIDEO_ES;
}
return;
}
- if( *pi_service_cat != VIDEO_ES ) /* Don't overwrite video */
+ if( info->cat != VIDEO_ES ) /* Don't overwrite video */
{
/* Not video, try audio */
switch( p_ts->i_stream_type )
@@ -384,8 +393,8 @@ static void UpdateServiceType( uint8_t *pi_service_cat, uint8_t *pi_service_type
break;
}
- if( i_type > *pi_service_type )
- *pi_service_type = i_type;
+ if( i_type > info->type )
+ info->type = i_type;
}
}
@@ -434,18 +443,16 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
VLC_UNUSED(standard);
dvbpsi_sdt_t sdtpsi;
- uint8_t *pi_service_types = NULL;
- uint8_t *pi_service_cats = NULL;
+ struct service_info *p_service_infos = NULL;
if( p_sdt )
{
dvbpsi_sdt_init( &sdtpsi, 0x42, i_tsid, 1, true, p_sdt->i_netid );
- pi_service_types = calloc( i_programs * 2, sizeof *pi_service_types );
- if( !pi_service_types )
+ p_service_infos = calloc( i_programs, sizeof(*p_service_infos) );
+ if( !p_service_infos )
{
free( dvbpmt );
return;
}
- pi_service_cats = &pi_service_types[i_programs];
}
for (unsigned i = 0; i < i_programs; i++ )
@@ -663,10 +670,19 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
p_stream->pes->lang);
}
+ if( p_stream->ts->b_scramble )
+ {
+ if( standard == TS_MUX_STANDARD_DVB )
+ {
+ /* scrambling_descriptor() */
+ uint8_t data[1] = { 0x01 /* CSA1 */ };
+ dvbpsi_pmt_es_descriptor_add( p_es, 0x65, 1, data );
+ }
+ }
+
if( p_sdt )
{
- UpdateServiceType( &pi_service_cats[p_stream->i_mapped_prog],
- &pi_service_types[p_stream->i_mapped_prog],
+ UpdateServiceType( &p_service_infos[p_stream->i_mapped_prog],
p_stream->ts, p_stream->fmt );
}
}
@@ -697,7 +713,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
false, /* eit schedule */
false, /* eit present */
4, /* running status ("4=RUNNING") */
- false ); /* free ca */
+ p_service_infos[i].b_scrambled ); /* free ca */
const char *psz_sdtprov = p_sdt->desc[i].psz_provider;
const char *psz_sdtserv = p_sdt->desc[i].psz_service_name;
@@ -706,7 +722,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
size_t i_sdt_desc = 0;
/* mapped service type according to es types */
- p_sdt_desc[i_sdt_desc++] = pi_service_types[i];
+ p_sdt_desc[i_sdt_desc++] = p_service_infos[i].type;
/* service provider name length */
i_sdt_desc += Write_AnnexA_String( &p_sdt_desc[i_sdt_desc], psz_sdtprov );
@@ -716,7 +732,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
dvbpsi_sdt_service_descriptor_add( p_service, 0x48, i_sdt_desc, p_sdt_desc );
}
- free( pi_service_types );
+ free( p_service_infos );
dvbpsi_psi_section_t *sect = dvbpsi_sdt_sections_generate( p_dvbpsi, &sdtpsi );
if( likely(sect) )
=====================================
modules/mux/mpeg/ts.c
=====================================
@@ -920,6 +920,20 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
/* Update pcr_pid */
SelectPCRStream( p_mux, NULL );
+ /* Set scramble flag / mode (CSA for now) */
+ switch( p_input->p_fmt->i_cat )
+ {
+ case VIDEO_ES:
+ p_stream->ts.b_scramble = p_sys->b_crypt_video && p_sys->csa;
+ break;
+ case AUDIO_ES:
+ p_stream->ts.b_scramble = p_sys->b_crypt_audio && p_sys->csa;
+ break;
+ default:
+ p_stream->ts.b_scramble = false;
+ break;
+ }
+
return VLC_SUCCESS;
oom:
@@ -1478,12 +1492,9 @@ static int MuxStreams( sout_mux_t *p_mux )
/* Build the TS packet */
block_t *p_ts = TSNew( p_mux, p_stream, b_pcr );
- if( p_sys->csa != NULL &&
- (p_input->p_fmt->i_cat != AUDIO_ES || p_sys->b_crypt_audio) &&
- (p_input->p_fmt->i_cat != VIDEO_ES || p_sys->b_crypt_video) )
- {
+ if( p_stream->ts.b_scramble )
p_ts->i_flags |= BLOCK_FLAG_SCRAMBLED;
- }
+
i_packet_pos++;
/* Write PAT/PMT before every keyframe if use-key-frames is enabled,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/50c3fc636aef9b95c78644e726ebc724c213305c...b85cb032dbb66112af4baccf9d5366461c92f738
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/50c3fc636aef9b95c78644e726ebc724c213305c...b85cb032dbb66112af4baccf9d5366461c92f738
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list