Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
88e8e86f
Commit
88e8e86f
authored
Feb 09, 2012
by
Rafaël Carré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TS mux: use var_* helpers
simplify CSA setup
parent
4553be8e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
92 deletions
+58
-92
modules/mux/mpeg/ts.c
modules/mux/mpeg/ts.c
+58
-92
No files found.
modules/mux/mpeg/ts.c
View file @
88e8e86f
...
@@ -478,7 +478,6 @@ static int Open( vlc_object_t *p_this )
...
@@ -478,7 +478,6 @@ static int Open( vlc_object_t *p_this )
{
{
sout_mux_t
*
p_mux
=
(
sout_mux_t
*
)
p_this
;
sout_mux_t
*
p_mux
=
(
sout_mux_t
*
)
p_this
;
sout_mux_sys_t
*
p_sys
=
NULL
;
sout_mux_sys_t
*
p_sys
=
NULL
;
vlc_value_t
val
;
config_ChainParse
(
p_mux
,
SOUT_CFG_PREFIX
,
ppsz_sout_options
,
p_mux
->
p_cfg
);
config_ChainParse
(
p_mux
,
SOUT_CFG_PREFIX
,
ppsz_sout_options
,
p_mux
->
p_cfg
);
...
@@ -508,15 +507,15 @@ static int Open( vlc_object_t *p_this )
...
@@ -508,15 +507,15 @@ static int Open( vlc_object_t *p_this )
p_sys
->
b_es_id_pid
=
var_GetBool
(
p_mux
,
SOUT_CFG_PREFIX
"es-id-pid"
);
p_sys
->
b_es_id_pid
=
var_GetBool
(
p_mux
,
SOUT_CFG_PREFIX
"es-id-pid"
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"muxpmt"
,
&
val
);
/*
/*
fetch string of pmts. Here's a sample: --sout-ts-muxpmt="0x451,0x200,0x28a,0x240,,0x450,0x201,0x28b,0x241,,0x452,0x202,0x28c,0x242"
fetch string of pmts. Here's a sample: --sout-ts-muxpmt="0x451,0x200,0x28a,0x240,,0x450,0x201,0x28b,0x241,,0x452,0x202,0x28c,0x242"
This would mean 0x451, 0x200, 0x28a, 0x240 would fall under one pmt (program), 0x450,0x201,0x28b,0x241 would fall under another
This would mean 0x451, 0x200, 0x28a, 0x240 would fall under one pmt (program), 0x450,0x201,0x28b,0x241 would fall under another
*/
*/
if
(
val
.
psz_string
!=
NULL
&&
*
val
.
psz_string
)
char
*
muxpmt
=
var_GetNonEmptyString
(
p_mux
,
SOUT_CFG_PREFIX
"muxpmt"
);
if
(
muxpmt
)
{
{
char
*
psz_next
;
char
*
psz_next
;
char
*
psz
=
val
.
psz_string
;
char
*
psz
=
muxpmt
;
uint16_t
i_pid
;
uint16_t
i_pid
;
psz_next
=
psz
;
psz_next
=
psz
;
...
@@ -556,8 +555,8 @@ static int Open( vlc_object_t *p_this )
...
@@ -556,8 +555,8 @@ static int Open( vlc_object_t *p_this )
if
(
!*
psz_next
)
if
(
!*
psz_next
)
psz
=
NULL
;
psz
=
NULL
;
}
}
free
(
muxpmt
);
}
}
free
(
val
.
psz_string
);
unsigned
short
subi
[
3
];
unsigned
short
subi
[
3
];
vlc_rand_bytes
(
subi
,
sizeof
(
subi
));
vlc_rand_bytes
(
subi
,
sizeof
(
subi
));
...
@@ -566,6 +565,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -566,6 +565,7 @@ static int Open( vlc_object_t *p_this )
p_sys
->
pat
.
i_continuity_counter
=
0
;
p_sys
->
pat
.
i_continuity_counter
=
0
;
p_sys
->
pat
.
b_discontinuity
=
false
;
p_sys
->
pat
.
b_discontinuity
=
false
;
vlc_value_t
val
;
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"tsid"
,
&
val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"tsid"
,
&
val
);
if
(
val
.
i_int
)
if
(
val
.
i_int
)
p_sys
->
i_tsid
=
val
.
i_int
;
p_sys
->
i_tsid
=
val
.
i_int
;
...
@@ -589,15 +589,14 @@ static int Open( vlc_object_t *p_this )
...
@@ -589,15 +589,14 @@ static int Open( vlc_object_t *p_this )
p_sys
->
sdt
.
i_continuity_counter
=
0
;
p_sys
->
sdt
.
i_continuity_counter
=
0
;
p_sys
->
sdt
.
b_discontinuity
=
false
;
p_sys
->
sdt
.
b_discontinuity
=
false
;
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"sdtdesc"
,
&
val
);
char
*
sdtdesc
=
var_GetNonEmptyString
(
p_mux
,
SOUT_CFG_PREFIX
"sdtdesc"
);
p_sys
->
b_sdt
=
val
.
psz_string
&&
*
val
.
psz_string
?
true
:
false
;
/* Syntax is provider_sdt1,service_name_sdt1,provider_sdt2,service_name_sdt2... */
/* Syntax is provider_sdt1,service_name_sdt1,provider_sdt2,service_name_sdt2... */
if
(
p_sys
->
b_sdt
)
if
(
sdtdesc
)
{
{
p_sys
->
b_sdt
=
true
;
char
*
psz
=
val
.
psz_string
;
char
*
psz_sdttoken
=
sdtdesc
;
char
*
psz_sdttoken
=
psz
;
for
(
int
i
=
0
;
psz_sdttoken
;
i
++
)
for
(
int
i
=
0
;
psz_sdttoken
;
i
++
)
{
{
...
@@ -619,15 +618,15 @@ static int Open( vlc_object_t *p_this )
...
@@ -619,15 +618,15 @@ static int Open( vlc_object_t *p_this )
psz_sdttoken
=
psz_end
;
psz_sdttoken
=
psz_end
;
}
}
free
(
sdtdesc
);
}
}
free
(
val
.
psz_string
);
p_sys
->
b_data_alignment
=
var_GetBool
(
p_mux
,
SOUT_CFG_PREFIX
"alignment"
);
p_sys
->
b_data_alignment
=
var_GetBool
(
p_mux
,
SOUT_CFG_PREFIX
"alignment"
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"program-pmt"
,
&
val
);
char
*
pgrpmt
=
var_GetNonEmptyString
(
p_mux
,
SOUT_CFG_PREFIX
"program-pmt"
);
if
(
val
.
psz_string
&&
*
val
.
psz_string
)
if
(
pgrpmt
)
{
{
char
*
psz
=
val
.
psz_string
;
char
*
psz
=
pgrpmt
;
char
*
psz_next
=
psz
;
char
*
psz_next
=
psz
;
for
(
int
i
=
0
;
psz
;
)
for
(
int
i
=
0
;
psz
;
)
...
@@ -649,6 +648,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -649,6 +648,7 @@ static int Open( vlc_object_t *p_this )
i
++
;
i
++
;
}
}
}
}
free
(
pgrpmt
);
}
}
else
else
{
{
...
@@ -656,19 +656,12 @@ static int Open( vlc_object_t *p_this )
...
@@ -656,19 +656,12 @@ static int Open( vlc_object_t *p_this )
for
(
int
i
=
0
;
i
<
p_sys
->
i_num_pmt
;
i
++
)
for
(
int
i
=
0
;
i
<
p_sys
->
i_num_pmt
;
i
++
)
p_sys
->
i_pmt_program_number
[
i
]
=
i
+
1
;
p_sys
->
i_pmt_program_number
[
i
]
=
i
+
1
;
}
}
free
(
val
.
psz_string
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"pid-pmt"
,
&
val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"pid-pmt"
,
&
val
);
if
(
val
.
i_int
)
if
(
!
val
.
i_int
)
/* Does this make any sense? */
{
val
.
i_int
=
0x42
;
for
(
int
i
=
0
;
i
<
p_sys
->
i_num_pmt
;
i
++
)
p_sys
->
pmt
[
i
].
i_pid
=
val
.
i_int
+
i
;
/* Does this make any sense? */
}
else
{
for
(
int
i
=
0
;
i
<
p_sys
->
i_num_pmt
;
i
++
)
for
(
int
i
=
0
;
i
<
p_sys
->
i_num_pmt
;
i
++
)
p_sys
->
pmt
[
i
].
i_pid
=
0x42
+
i
;
p_sys
->
pmt
[
i
].
i_pid
=
val
.
i_int
+
i
;
}
p_sys
->
i_pid_free
=
p_sys
->
pmt
[
p_sys
->
i_num_pmt
-
1
].
i_pid
+
1
;
p_sys
->
i_pid_free
=
p_sys
->
pmt
[
p_sys
->
i_num_pmt
-
1
].
i_pid
+
1
;
...
@@ -717,7 +710,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -717,7 +710,7 @@ static int Open( vlc_object_t *p_this )
}
}
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"shaping"
,
&
val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"shaping"
,
&
val
);
p_sys
->
i_shaping_delay
=
(
int64_t
)
val
.
i_int
*
1000
;
p_sys
->
i_shaping_delay
=
val
.
i_int
*
1000
;
if
(
p_sys
->
i_shaping_delay
<=
0
)
if
(
p_sys
->
i_shaping_delay
<=
0
)
{
{
msg_Err
(
p_mux
,
msg_Err
(
p_mux
,
...
@@ -727,7 +720,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -727,7 +720,7 @@ static int Open( vlc_object_t *p_this )
}
}
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"pcr"
,
&
val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"pcr"
,
&
val
);
p_sys
->
i_pcr_delay
=
(
int64_t
)
val
.
i_int
*
1000
;
p_sys
->
i_pcr_delay
=
val
.
i_int
*
1000
;
if
(
p_sys
->
i_pcr_delay
<=
0
||
if
(
p_sys
->
i_pcr_delay
<=
0
||
p_sys
->
i_pcr_delay
>=
p_sys
->
i_shaping_delay
)
p_sys
->
i_pcr_delay
>=
p_sys
->
i_shaping_delay
)
{
{
...
@@ -738,7 +731,7 @@ static int Open( vlc_object_t *p_this )
...
@@ -738,7 +731,7 @@ static int Open( vlc_object_t *p_this )
}
}
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"dts-delay"
,
&
val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"dts-delay"
,
&
val
);
p_sys
->
i_dts_delay
=
(
int64_t
)
val
.
i_int
*
1000
;
p_sys
->
i_dts_delay
=
val
.
i_int
*
1000
;
msg_Dbg
(
p_mux
,
"shaping=%"
PRId64
" pcr=%"
PRId64
" dts_delay=%"
PRId64
,
msg_Dbg
(
p_mux
,
"shaping=%"
PRId64
" pcr=%"
PRId64
" dts_delay=%"
PRId64
,
p_sys
->
i_shaping_delay
,
p_sys
->
i_pcr_delay
,
p_sys
->
i_dts_delay
);
p_sys
->
i_shaping_delay
,
p_sys
->
i_pcr_delay
,
p_sys
->
i_dts_delay
);
...
@@ -749,38 +742,19 @@ static int Open( vlc_object_t *p_this )
...
@@ -749,38 +742,19 @@ static int Open( vlc_object_t *p_this )
p_sys
->
i_pcr
=
0
;
p_sys
->
i_pcr
=
0
;
p_sys
->
csa
=
NULL
;
p_sys
->
csa
=
NULL
;
var_Create
(
p_mux
,
SOUT_CFG_PREFIX
"csa-ck"
,
VLC_VAR_STRING
|
VLC_VAR_DOINHERIT
|
VLC_VAR_ISCOMMAND
);
char
*
csack
=
var_CreateGetNonEmptyStringCommand
(
p_mux
,
SOUT_CFG_PREFIX
"csa-ck"
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-ck"
,
&
val
);
if
(
csack
)
if
(
val
.
psz_string
&&
*
val
.
psz_string
)
{
{
int
i_res
;
vlc_value_t
csa2
;
p_sys
->
csa
=
csa_New
();
p_sys
->
csa
=
csa_New
();
var_Create
(
p_mux
,
SOUT_CFG_PREFIX
"csa2-ck"
,
VLC_VAR_STRING
|
VLC_VAR_DOINHERIT
|
VLC_VAR_ISCOMMAND
);
if
(
!
csa_SetCW
(
p_this
,
p_sys
->
csa
,
csack
,
true
)
)
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa2-ck"
,
&
csa2
);
i_res
=
csa_SetCW
(
(
vlc_object_t
*
)
p_mux
,
p_sys
->
csa
,
val
.
psz_string
,
true
);
if
(
i_res
==
VLC_SUCCESS
&&
csa2
.
psz_string
&&
*
csa2
.
psz_string
)
{
{
if
(
csa_SetCW
(
(
vlc_object_t
*
)
p_mux
,
p_sys
->
csa
,
csa2
.
psz_string
,
false
)
!=
VLC_SUCCESS
)
char
*
csa2ck
=
var_CreateGetNonEmptyStringCommand
(
p_mux
,
SOUT_CFG_PREFIX
"csa2-ck"
);
{
if
(
!
csa2ck
||
csa_SetCW
(
p_this
,
p_sys
->
csa
,
csa2ck
,
false
)
)
csa_SetCW
(
(
vlc_object_t
*
)
p_mux
,
p_sys
->
csa
,
val
.
psz_string
,
false
);
csa_SetCW
(
p_this
,
p_sys
->
csa
,
csack
,
false
);
}
free
(
csa2ck
);
}
else
if
(
i_res
==
VLC_SUCCESS
)
{
csa_SetCW
(
(
vlc_object_t
*
)
p_mux
,
p_sys
->
csa
,
val
.
psz_string
,
false
);
}
else
{
csa_Delete
(
p_sys
->
csa
);
p_sys
->
csa
=
NULL
;
}
if
(
p_sys
->
csa
)
vlc_value_t
use_val
;
{
vlc_value_t
use_val
,
pkt_val
;
var_Create
(
p_mux
,
SOUT_CFG_PREFIX
"csa-use"
,
VLC_VAR_STRING
|
VLC_VAR_DOINHERIT
|
VLC_VAR_ISCOMMAND
);
var_Create
(
p_mux
,
SOUT_CFG_PREFIX
"csa-use"
,
VLC_VAR_STRING
|
VLC_VAR_DOINHERIT
|
VLC_VAR_ISCOMMAND
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-use"
,
&
use_val
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-use"
,
&
use_val
);
...
@@ -794,20 +768,23 @@ static int Open( vlc_object_t *p_this )
...
@@ -794,20 +768,23 @@ static int Open( vlc_object_t *p_this )
}
}
free
(
use_val
.
psz_string
);
free
(
use_val
.
psz_string
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"csa-pkt"
,
&
pkt_val
);
p_sys
->
i_csa_pkt_size
=
var_GetInteger
(
p_mux
,
SOUT_CFG_PREFIX
"csa-pkt"
);
if
(
p
kt_val
.
i_int
<
12
||
pkt_val
.
i_int
>
188
)
if
(
p
_sys
->
i_csa_pkt_size
<
12
||
p_sys
->
i_csa_pkt_size
>
188
)
{
{
msg_Err
(
p_mux
,
"wrong packet size %"
PRId64
" specified."
,
msg_Err
(
p_mux
,
"wrong packet size %d specified"
,
pkt_val
.
i_int
);
p_sys
->
i_csa_pkt_size
);
msg_Warn
(
p_mux
,
"using default packet size of 188 bytes"
);
p_sys
->
i_csa_pkt_size
=
188
;
p_sys
->
i_csa_pkt_size
=
188
;
}
}
else
p_sys
->
i_csa_pkt_size
=
pkt_val
.
i_int
;
msg_Dbg
(
p_mux
,
"encrypting %d bytes of packet"
,
msg_Dbg
(
p_mux
,
"encrypting %d bytes of packet"
,
p_sys
->
i_csa_pkt_size
);
p_sys
->
i_csa_pkt_size
);
}
}
free
(
csa2
.
psz_string
);
else
{
csa_Delete
(
p_sys
->
csa
);
p_sys
->
csa
=
NULL
;
}
free
(
csack
);
}
}
free
(
val
.
psz_string
);
p_sys
->
b_crypt_audio
=
var_GetBool
(
p_mux
,
SOUT_CFG_PREFIX
"crypt-audio"
);
p_sys
->
b_crypt_audio
=
var_GetBool
(
p_mux
,
SOUT_CFG_PREFIX
"crypt-audio"
);
...
@@ -1253,10 +1230,9 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
...
@@ -1253,10 +1230,9 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
static
int
DelStream
(
sout_mux_t
*
p_mux
,
sout_input_t
*
p_input
)
static
int
DelStream
(
sout_mux_t
*
p_mux
,
sout_input_t
*
p_input
)
{
{
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
sout_mux_sys_t
*
p_sys
=
p_mux
->
p_sys
;
ts_stream_t
*
p_stream
;
ts_stream_t
*
p_stream
=
(
ts_stream_t
*
)
p_input
->
p_sys
;
vlc_value_t
val
;
int
pid
;
p_stream
=
(
ts_stream_t
*
)
p_input
->
p_sys
;
msg_Dbg
(
p_mux
,
"removing input pid=%d"
,
p_stream
->
i_pid
);
msg_Dbg
(
p_mux
,
"removing input pid=%d"
,
p_stream
->
i_pid
);
if
(
p_sys
->
i_pcr_pid
==
p_stream
->
i_pid
)
if
(
p_sys
->
i_pcr_pid
==
p_stream
->
i_pid
)
...
@@ -1306,40 +1282,30 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
...
@@ -1306,40 +1282,30 @@ static int DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
p_sys
->
i_mpeg4_streams
--
;
p_sys
->
i_mpeg4_streams
--
;
}
}
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"pid-video"
,
&
val
);
pid
=
var_GetInteger
(
p_mux
,
SOUT_CFG_PREFIX
"pid-video"
);
if
(
val
.
i_int
>
0
)
if
(
pid
>
0
&&
pid
==
p_stream
->
i_pid
)
{
int
i_pid_video
=
val
.
i_int
;
if
(
i_pid_video
==
p_stream
->
i_pid
)
{
{
p_sys
->
i_pid_video
=
i_pid_video
;
p_sys
->
i_pid_video
=
pid
;
msg_Dbg
(
p_mux
,
"freeing video PID %d"
,
i_pid_video
);
msg_Dbg
(
p_mux
,
"freeing video PID %d"
,
pid
);
}
}
}
pid
=
var_GetInteger
(
p_mux
,
SOUT_CFG_PREFIX
"pid-audio"
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"pid-audio"
,
&
val
);
if
(
pid
>
0
&&
pid
==
p_stream
->
i_pid
)
if
(
val
.
i_int
>
0
)
{
int
i_pid_audio
=
val
.
i_int
;
if
(
i_pid_audio
==
p_stream
->
i_pid
)
{
{
p_sys
->
i_pid_audio
=
i_pid_audio
;
p_sys
->
i_pid_audio
=
pid
;
msg_Dbg
(
p_mux
,
"freeing audio PID %d"
,
i_pid_audio
);
msg_Dbg
(
p_mux
,
"freeing audio PID %d"
,
pid
);
}
}
}
pid
=
var_GetInteger
(
p_mux
,
SOUT_CFG_PREFIX
"pid-spu"
);
var_Get
(
p_mux
,
SOUT_CFG_PREFIX
"pid-spu"
,
&
val
);
if
(
pid
>
0
&&
pid
==
p_stream
->
i_pid
)
if
(
val
.
i_int
>
0
)
{
int
i_pid_spu
=
val
.
i_int
;
if
(
i_pid_spu
==
p_stream
->
i_pid
)
{
{
p_sys
->
i_pid_spu
=
i_pid_spu
;
p_sys
->
i_pid_spu
=
pid
;
msg_Dbg
(
p_mux
,
"freeing spu PID %d"
,
i_pid_spu
);
msg_Dbg
(
p_mux
,
"freeing spu PID %d"
,
pid
);
}
}
}
free
(
p_stream
);
free
(
p_stream
);
/* We only change PMT version (PAT isn't changed) */
/* We only change PMT version (PAT isn't changed) */
p_sys
->
i_pmt_version_number
++
;
p_sys
->
i_pmt_version_number
%=
32
;
p_sys
->
i_pmt_version_number
++
;
p_sys
->
i_pmt_version_number
%=
32
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment