Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
d2224eb4
Commit
d2224eb4
authored
Jan 26, 2015
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mux: ts: split ts encapsulation
parent
27634b11
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
82 deletions
+142
-82
modules/mux/Modules.am
modules/mux/Modules.am
+1
-0
modules/mux/mpeg/ts.c
modules/mux/mpeg/ts.c
+7
-82
modules/mux/mpeg/tsutil.c
modules/mux/mpeg/tsutil.c
+106
-0
modules/mux/mpeg/tsutil.h
modules/mux/mpeg/tsutil.h
+28
-0
No files found.
modules/mux/Modules.am
View file @
d2224eb4
...
@@ -24,6 +24,7 @@ mux_LTLIBRARIES += libmux_ps_plugin.la
...
@@ -24,6 +24,7 @@ mux_LTLIBRARIES += libmux_ps_plugin.la
libmux_ts_plugin_la_SOURCES = \
libmux_ts_plugin_la_SOURCES = \
mpeg/pes.c mpeg/pes.h \
mpeg/pes.c mpeg/pes.h \
mpeg/csa.c mpeg/csa.h \
mpeg/csa.c mpeg/csa.h \
mpeg/tsutil.c mpeg/tsutil.h \
mpeg/ts.c mpeg/bits.h mpeg/dvbpsi_compat.h
mpeg/ts.c mpeg/bits.h mpeg/dvbpsi_compat.h
libmux_ts_plugin_la_CFLAGS = $(AM_CFLAGS) $(DVBPSI_CFLAGS)
libmux_ts_plugin_la_CFLAGS = $(AM_CFLAGS) $(DVBPSI_CFLAGS)
libmux_ts_plugin_la_LIBADD = $(DVBPSI_LIBS)
libmux_ts_plugin_la_LIBADD = $(DVBPSI_LIBS)
...
...
modules/mux/mpeg/ts.c
View file @
d2224eb4
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
#include "bits.h"
#include "bits.h"
#include "pes.h"
#include "pes.h"
#include "csa.h"
#include "csa.h"
#include "tsutil.h"
# include <dvbpsi/dvbpsi.h>
# include <dvbpsi/dvbpsi.h>
# include <dvbpsi/demux.h>
# include <dvbpsi/demux.h>
...
@@ -1939,85 +1940,6 @@ static void TSSetPCR( block_t *p_ts, mtime_t i_dts )
...
@@ -1939,85 +1940,6 @@ static void TSSetPCR( block_t *p_ts, mtime_t i_dts )
p_ts
->
p_buffer
[
11
]
=
0
;
/* we don't set PCR extension */
p_ts
->
p_buffer
[
11
]
=
0
;
/* we don't set PCR extension */
}
}
static
void
PEStoTS
(
sout_buffer_chain_t
*
c
,
block_t
*
p_pes
,
ts_stream_t
*
p_stream
)
{
/* get PES total size */
uint8_t
*
p_data
=
p_pes
->
p_buffer
;
int
i_size
=
p_pes
->
i_buffer
;
bool
b_new_pes
=
true
;
for
(;;)
{
/* write header
* 8b 0x47 sync byte
* 1b transport_error_indicator
* 1b payload_unit_start
* 1b transport_priority
* 13b pid
* 2b transport_scrambling_control
* 2b if adaptation_field 0x03 else 0x01
* 4b continuity_counter
*/
int
i_copy
=
__MIN
(
i_size
,
184
);
bool
b_adaptation_field
=
i_size
<
184
;
block_t
*
p_ts
=
block_Alloc
(
188
);
p_ts
->
p_buffer
[
0
]
=
0x47
;
p_ts
->
p_buffer
[
1
]
=
(
b_new_pes
?
0x40
:
0x00
)
|
(
(
p_stream
->
i_pid
>>
8
)
&
0x1f
);
p_ts
->
p_buffer
[
2
]
=
p_stream
->
i_pid
&
0xff
;
p_ts
->
p_buffer
[
3
]
=
(
b_adaptation_field
?
0x30
:
0x10
)
|
p_stream
->
i_continuity_counter
;
b_new_pes
=
false
;
p_stream
->
i_continuity_counter
=
(
p_stream
->
i_continuity_counter
+
1
)
%
16
;
if
(
b_adaptation_field
)
{
int
i_stuffing
=
184
-
i_copy
;
p_ts
->
p_buffer
[
4
]
=
i_stuffing
-
1
;
if
(
i_stuffing
>
1
)
{
p_ts
->
p_buffer
[
5
]
=
0x00
;
if
(
p_stream
->
b_discontinuity
)
{
p_ts
->
p_buffer
[
5
]
|=
0x80
;
p_stream
->
b_discontinuity
=
false
;
}
for
(
int
i
=
6
;
i
<
6
+
i_stuffing
-
2
;
i
++
)
{
p_ts
->
p_buffer
[
i
]
=
0xff
;
}
}
}
/* copy payload */
memcpy
(
&
p_ts
->
p_buffer
[
188
-
i_copy
],
p_data
,
i_copy
);
p_data
+=
i_copy
;
i_size
-=
i_copy
;
BufferChainAppend
(
c
,
p_ts
);
if
(
i_size
<=
0
)
{
block_t
*
p_next
=
p_pes
->
p_next
;
p_pes
->
p_next
=
NULL
;
block_Release
(
p_pes
);
if
(
p_next
==
NULL
)
return
;
b_new_pes
=
true
;
p_pes
=
p_next
;
i_size
=
p_pes
->
i_buffer
;
p_data
=
p_pes
->
p_buffer
;
}
}
}
static
block_t
*
WritePSISection
(
dvbpsi_psi_section_t
*
p_section
)
static
block_t
*
WritePSISection
(
dvbpsi_psi_section_t
*
p_section
)
{
{
block_t
*
p_psi
,
*
p_first
=
NULL
;
block_t
*
p_psi
,
*
p_first
=
NULL
;
...
@@ -2075,7 +1997,8 @@ static void GetPAT( sout_mux_t *p_mux,
...
@@ -2075,7 +1997,8 @@ static void GetPAT( sout_mux_t *p_mux,
#endif
#endif
p_pat
=
WritePSISection
(
p_section
);
p_pat
=
WritePSISection
(
p_section
);
PEStoTS
(
c
,
p_pat
,
&
p_sys
->
pat
);
PEStoTS
(
c
,
(
PEStoTSCallback
)
BufferChainAppend
,
p_pat
,
p_sys
->
pat
.
i_pid
,
&
p_sys
->
pat
.
b_discontinuity
,
&
p_sys
->
pat
.
i_continuity_counter
);
dvbpsi_DeletePSISections
(
p_section
);
dvbpsi_DeletePSISections
(
p_section
);
dvbpsi_EmptyPAT
(
&
pat
);
dvbpsi_EmptyPAT
(
&
pat
);
...
@@ -2434,7 +2357,8 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
...
@@ -2434,7 +2357,8 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
sect
=
dvbpsi_GenPMTSections
(
&
p_sys
->
dvbpmt
[
i
]
);
sect
=
dvbpsi_GenPMTSections
(
&
p_sys
->
dvbpmt
[
i
]
);
#endif
#endif
block_t
*
pmt
=
WritePSISection
(
sect
);
block_t
*
pmt
=
WritePSISection
(
sect
);
PEStoTS
(
c
,
pmt
,
&
p_sys
->
pmt
[
i
]
);
PEStoTS
(
c
,
(
PEStoTSCallback
)
BufferChainAppend
,
pmt
,
p_sys
->
pmt
[
i
].
i_pid
,
&
p_sys
->
pmt
[
i
].
b_discontinuity
,
&
p_sys
->
pmt
[
i
].
i_continuity_counter
);
dvbpsi_DeletePSISections
(
sect
);
dvbpsi_DeletePSISections
(
sect
);
dvbpsi_EmptyPMT
(
&
p_sys
->
dvbpmt
[
i
]
);
dvbpsi_EmptyPMT
(
&
p_sys
->
dvbpmt
[
i
]
);
}
}
...
@@ -2448,7 +2372,8 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
...
@@ -2448,7 +2372,8 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
sect
=
dvbpsi_GenSDTSections
(
&
sdt
);
sect
=
dvbpsi_GenSDTSections
(
&
sdt
);
#endif
#endif
block_t
*
p_sdt
=
WritePSISection
(
sect
);
block_t
*
p_sdt
=
WritePSISection
(
sect
);
PEStoTS
(
c
,
p_sdt
,
&
p_sys
->
sdt
);
PEStoTS
(
c
,
(
PEStoTSCallback
)
BufferChainAppend
,
p_sdt
,
p_sys
->
sdt
.
i_pid
,
&
p_sys
->
sdt
.
b_discontinuity
,
&
p_sys
->
sdt
.
i_continuity_counter
);
dvbpsi_DeletePSISections
(
sect
);
dvbpsi_DeletePSISections
(
sect
);
dvbpsi_EmptySDT
(
&
sdt
);
dvbpsi_EmptySDT
(
&
sdt
);
}
}
...
...
modules/mux/mpeg/tsutil.c
0 → 100644
View file @
d2224eb4
/*****************************************************************************
* tsutil.c
*****************************************************************************
* Copyright (C) 2001-2005, 2015 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_block.h>
#include "tsutil.h"
void
PEStoTS
(
void
*
p_opaque
,
PEStoTSCallback
pf_callback
,
block_t
*
p_pes
,
int
i_pid
,
bool
*
pb_discontinuity
,
int
*
pi_continuity_counter
)
{
/* get PES total size */
uint8_t
*
p_data
=
p_pes
->
p_buffer
;
int
i_size
=
p_pes
->
i_buffer
;
bool
b_new_pes
=
true
;
for
(;;)
{
/* write header
* 8b 0x47 sync byte
* 1b transport_error_indicator
* 1b payload_unit_start
* 1b transport_priority
* 13b pid
* 2b transport_scrambling_control
* 2b if adaptation_field 0x03 else 0x01
* 4b continuity_counter
*/
int
i_copy
=
__MIN
(
i_size
,
184
);
bool
b_adaptation_field
=
i_size
<
184
;
block_t
*
p_ts
=
block_Alloc
(
188
);
p_ts
->
p_buffer
[
0
]
=
0x47
;
p_ts
->
p_buffer
[
1
]
=
(
b_new_pes
?
0x40
:
0x00
)
|
(
(
i_pid
>>
8
)
&
0x1f
);
p_ts
->
p_buffer
[
2
]
=
i_pid
&
0xff
;
p_ts
->
p_buffer
[
3
]
=
(
b_adaptation_field
?
0x30
:
0x10
)
|
*
pi_continuity_counter
;
b_new_pes
=
false
;
*
pi_continuity_counter
=
(
*
pi_continuity_counter
+
1
)
%
16
;
if
(
b_adaptation_field
)
{
int
i_stuffing
=
184
-
i_copy
;
p_ts
->
p_buffer
[
4
]
=
i_stuffing
-
1
;
if
(
i_stuffing
>
1
)
{
p_ts
->
p_buffer
[
5
]
=
0x00
;
if
(
*
pb_discontinuity
)
{
p_ts
->
p_buffer
[
5
]
|=
0x80
;
*
pb_discontinuity
=
false
;
}
for
(
int
i
=
6
;
i
<
6
+
i_stuffing
-
2
;
i
++
)
{
p_ts
->
p_buffer
[
i
]
=
0xff
;
}
}
}
/* copy payload */
memcpy
(
&
p_ts
->
p_buffer
[
188
-
i_copy
],
p_data
,
i_copy
);
p_data
+=
i_copy
;
i_size
-=
i_copy
;
pf_callback
(
p_opaque
,
p_ts
);
if
(
i_size
<=
0
)
{
block_t
*
p_next
=
p_pes
->
p_next
;
p_pes
->
p_next
=
NULL
;
block_Release
(
p_pes
);
if
(
p_next
==
NULL
)
return
;
b_new_pes
=
true
;
p_pes
=
p_next
;
i_size
=
p_pes
->
i_buffer
;
p_data
=
p_pes
->
p_buffer
;
}
}
}
modules/mux/mpeg/tsutil.h
0 → 100644
View file @
d2224eb4
/*****************************************************************************
* tsutil.h
*****************************************************************************
* Copyright (C) 2001-2005, 2015 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _TSUTIL_H
#define _TSUTIL_H 1
typedef
void
(
*
PEStoTSCallback
)(
void
*
,
block_t
*
);
void
PEStoTS
(
void
*
p_opaque
,
PEStoTSCallback
pf_callback
,
block_t
*
p_pes
,
int
i_pid
,
bool
*
pb_discontinuity
,
int
*
pi_continuity_counter
);
#endif
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