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
8be0e1ae
Commit
8be0e1ae
authored
Sep 13, 2008
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added demux_Packetizer* helpers.
parent
e4a1bb5b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
108 additions
and
119 deletions
+108
-119
include/vlc_demux.h
include/vlc_demux.h
+15
-33
modules/demux/flac.c
modules/demux/flac.c
+9
-17
modules/demux/mpeg/es.c
modules/demux/mpeg/es.c
+3
-35
modules/demux/mpeg/h264.c
modules/demux/mpeg/h264.c
+12
-10
modules/demux/mpeg/m4v.c
modules/demux/mpeg/m4v.c
+10
-11
modules/demux/mpeg/mpgv.c
modules/demux/mpeg/mpgv.c
+8
-5
modules/demux/vc1.c
modules/demux/vc1.c
+11
-8
src/input/demux.c
src/input/demux.c
+38
-0
src/libvlccore.sym
src/libvlccore.sym
+2
-0
No files found.
include/vlc_demux.h
View file @
8be0e1ae
...
...
@@ -174,6 +174,21 @@ static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name )
return
true
;
}
/**
* This function will create a packetizer suitable for a demuxer that parses
* elementary stream.
*
* The provided es_format_t will be cleaned on error or by
* demux_PacketizerDestroy.
*/
VLC_EXPORT
(
decoder_t
*
,
demux_PacketizerNew
,
(
demux_t
*
p_demux
,
es_format_t
*
p_fmt
,
const
char
*
psz_msg
)
);
/**
* This function will destroy a packetizer create by demux_PacketizerNew.
*/
VLC_EXPORT
(
void
,
demux_PacketizerDestroy
,
(
decoder_t
*
p_packetizer
)
);
/* */
#define DEMUX_INIT_COMMON() do { \
p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \
...
...
@@ -218,39 +233,6 @@ static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name )
#define POKE( peek, stuff, size ) (strncasecmp( (const char *)peek, stuff, size )==0)
#define COMMON_INIT_PACKETIZER( location ) \
location = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER ); \
location->pf_decode_audio = 0; \
location->pf_decode_video = 0; \
location->pf_decode_sub = 0; \
location->pf_packetize = 0; \
#define INIT_APACKETIZER( location, a,b,c,d ) \
COMMON_INIT_PACKETIZER(location ); \
es_format_Init( &location->fmt_in, AUDIO_ES, \
VLC_FOURCC( a, b, c, d ) );
#define INIT_VPACKETIZER( location, a,b,c,d ) \
COMMON_INIT_PACKETIZER(location ); \
es_format_Init( &location->fmt_in, VIDEO_ES, \
VLC_FOURCC( a, b, c, d ) );
/* BEWARE ! This can lead to memory leaks ! */
#define LOAD_PACKETIZER_OR_FAIL( location, msg ) \
location->p_module = \
module_Need( location, "packetizer", NULL, 0 ); \
if( location->p_module == NULL ) \
{ \
vlc_object_release( location ); \
msg_Err( p_demux, "cannot find packetizer for " # msg ); \
free( p_sys ); \
return VLC_EGENERIC; \
}
#define DESTROY_PACKETIZER( location ) \
if( location->p_module ) module_Unneed( location, location->p_module ); \
vlc_object_release( location );
/**
* @}
*/
...
...
modules/demux/flac.c
View file @
8be0e1ae
...
...
@@ -103,6 +103,7 @@ static int Open( vlc_object_t * p_this )
const
uint8_t
*
p_peek
;
uint8_t
*
p_streaminfo
;
int
i_streaminfo
;
es_format_t
fmt
;
/* Have a peep at the show. */
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
4
)
<
4
)
return
VLC_EGENERIC
;
...
...
@@ -140,21 +141,16 @@ static int Open( vlc_object_t * p_this )
}
/* Load the FLAC packetizer */
INIT_APACKETIZER
(
p_sys
->
p_packetizer
,
'f'
,
'l'
,
'a'
,
'c'
);
/* Store STREAMINFO for the decoder and packetizer */
p_streaminfo
[
4
]
|=
0x80
;
/* Fake this as the last metadata block */
p_sys
->
p_packetizer
->
fmt_in
.
i_extra
=
i_streaminfo
;
p_sys
->
p_packetizer
->
fmt_in
.
p_extra
=
p_streaminfo
;
es_format_Init
(
&
fmt
,
AUDIO_ES
,
VLC_FOURCC
(
'f'
,
'l'
,
'a'
,
'c'
)
);
fmt
.
i_extra
=
i_streaminfo
;
fmt
.
p_extra
=
p_streaminfo
;
p_sys
->
p_packetizer
->
p_module
=
module_Need
(
p_sys
->
p_packetizer
,
"packetizer"
,
NULL
,
0
);
if
(
!
p_sys
->
p_packetizer
->
p_module
)
p_sys
->
p_packetizer
=
demux_PacketizerNew
(
p_demux
,
&
fmt
,
"flac"
);
if
(
!
p_sys
->
p_packetizer
)
{
free
(
p_sys
->
p_packetizer
->
fmt_in
.
p_extra
);
vlc_object_release
(
p_sys
->
p_packetizer
);
msg_Err
(
p_demux
,
"cannot find flac packetizer"
);
free
(
p_sys
);
return
VLC_EGENERIC
;
}
...
...
@@ -186,13 +182,9 @@ static void Close( vlc_object_t * p_this )
free
(
p_sys
->
attachments
[
i
]
);
TAB_CLEAN
(
p_sys
->
i_attachments
,
p_sys
->
attachments
);
/* Unneed module */
module_Unneed
(
p_sys
->
p_packetizer
,
p_sys
->
p_packetizer
->
p_module
);
free
(
p_sys
->
p_packetizer
->
fmt_in
.
p_extra
);
/* Delete the decoder */
vlc_object_release
(
p_sys
->
p_packetizer
);
demux_PacketizerDestroy
(
p_sys
->
p_packetizer
);
if
(
p_sys
->
p_meta
)
vlc_meta_Delete
(
p_sys
->
p_meta
);
free
(
p_sys
);
...
...
modules/demux/mpeg/es.c
View file @
8be0e1ae
...
...
@@ -131,39 +131,6 @@ static const codec_t p_codec[] = {
{
0
,
false
,
NULL
,
NULL
,
NULL
}
};
static
inline
decoder_t
*
demux_PacketizerNew
(
demux_t
*
p_demux
,
int
i_cat
,
vlc_fourcc_t
i_codec
,
const
char
*
psz_msg
)
{
decoder_t
*
p_packetizer
=
vlc_object_create
(
p_demux
,
VLC_OBJECT_PACKETIZER
);
if
(
!
p_packetizer
)
return
NULL
;
p_packetizer
->
pf_decode_audio
=
NULL
;
p_packetizer
->
pf_decode_video
=
NULL
;
p_packetizer
->
pf_decode_sub
=
NULL
;
p_packetizer
->
pf_packetize
=
NULL
;
es_format_Init
(
&
p_packetizer
->
fmt_in
,
i_cat
,
i_codec
);
es_format_Init
(
&
p_packetizer
->
fmt_out
,
UNKNOWN_ES
,
0
);
p_packetizer
->
p_module
=
module_Need
(
p_packetizer
,
"packetizer"
,
NULL
,
0
);
if
(
!
p_packetizer
->
p_module
)
{
vlc_object_release
(
p_packetizer
);
msg_Err
(
p_demux
,
"cannot find packetizer for %s"
,
psz_msg
);
return
NULL
;
}
return
p_packetizer
;
}
static
inline
void
demux_PacketizerDestroy
(
decoder_t
*
p_packetizer
)
{
if
(
p_packetizer
->
p_module
)
module_Unneed
(
p_packetizer
,
p_packetizer
->
p_module
);
vlc_object_release
(
p_packetizer
);
}
/*****************************************************************************
* Open: initializes demux structures
*****************************************************************************/
...
...
@@ -172,6 +139,7 @@ static int Open( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
es_format_t
fmt
;
int64_t
i_offset
;
int
i_index
;
...
...
@@ -209,8 +177,8 @@ static int Open( vlc_object_t * p_this )
msg_Dbg
(
p_demux
,
"detected format %4.4s"
,
(
const
char
*
)
&
p_sys
->
codec
.
i_codec
);
/* Load the audio packetizer */
p_sys
->
p_packetizer
=
demux_PacketizerNew
(
p_demux
,
AUDIO_ES
,
p_sys
->
codec
.
i_codec
,
p_sys
->
codec
.
psz_name
);
es_format_Init
(
&
fmt
,
AUDIO_ES
,
p_sys
->
codec
.
i_codec
);
p_sys
->
p_packetizer
=
demux_PacketizerNew
(
p_demux
,
&
fmt
,
p_sys
->
codec
.
psz_name
);
if
(
!
p_sys
->
p_packetizer
)
{
free
(
p_sys
);
...
...
modules/demux/mpeg/h264.c
View file @
8be0e1ae
...
...
@@ -80,7 +80,7 @@ static int Open( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
const
uint8_t
*
p_peek
;
vlc_value_t
val
;
es_format_t
fmt
;
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
5
)
<
5
)
return
VLC_EGENERIC
;
...
...
@@ -103,16 +103,19 @@ static int Open( vlc_object_t * p_this )
p_demux
->
p_sys
=
p_sys
=
malloc
(
sizeof
(
demux_sys_t
)
);
p_sys
->
p_es
=
NULL
;
p_sys
->
i_dts
=
1
;
var_Create
(
p_demux
,
"h264-fps"
,
VLC_VAR_FLOAT
|
VLC_VAR_DOINHERIT
);
var_Get
(
p_demux
,
"h264-fps"
,
&
val
);
p_sys
->
f_fps
=
val
.
f_float
;
if
(
val
.
f_float
<
0
.
001
)
p_sys
->
f_fps
=
0
.
001
;
p_sys
->
f_fps
=
var_CreateGetFloat
(
p_demux
,
"h264-fps"
);
if
(
p_sys
->
f_fps
<
0
.
001
)
p_sys
->
f_fps
=
0
.
001
;
msg_Dbg
(
p_demux
,
"using %.2f fps"
,
p_sys
->
f_fps
);
/* Load the mpegvideo packetizer */
INIT_VPACKETIZER
(
p_sys
->
p_packetizer
,
'h'
,
'2'
,
'6'
,
'4'
);
es_format_Init
(
&
p_sys
->
p_packetizer
->
fmt_out
,
UNKNOWN_ES
,
0
);
LOAD_PACKETIZER_OR_FAIL
(
p_sys
->
p_packetizer
,
"H264"
);
es_format_Init
(
&
fmt
,
VIDEO_ES
,
VLC_FOURCC
(
'h'
,
'2'
,
'6'
,
'4'
)
);
p_sys
->
p_packetizer
=
demux_PacketizerNew
(
p_demux
,
&
fmt
,
"h264"
);
if
(
!
p_sys
->
p_packetizer
)
{
free
(
p_sys
);
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
...
...
@@ -125,8 +128,7 @@ static void Close( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
DESTROY_PACKETIZER
(
p_sys
->
p_packetizer
);
demux_PacketizerDestroy
(
p_sys
->
p_packetizer
);
free
(
p_sys
);
}
...
...
modules/demux/mpeg/m4v.c
View file @
8be0e1ae
...
...
@@ -80,7 +80,7 @@ static int Open( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
const
uint8_t
*
p_peek
;
vlc_value_t
val
;
es_format_t
fmt
;
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
4
)
<
4
)
return
VLC_EGENERIC
;
...
...
@@ -103,17 +103,17 @@ static int Open( vlc_object_t * p_this )
p_sys
->
i_dts
=
1
;
/* Load the mpeg4video packetizer */
INIT_VPACKETIZER
(
p_sys
->
p_packetizer
,
'm'
,
'p'
,
'4'
,
'v'
);
es_format_Init
(
&
p_sys
->
p_packetizer
->
fmt_out
,
UNKNOWN_ES
,
0
);
LOAD_PACKETIZER_OR_FAIL
(
p_sys
->
p_packetizer
,
"mpeg4 video"
);
es_format_Init
(
&
fmt
,
VIDEO_ES
,
VLC_FOURCC
(
'm'
,
'p'
,
'4'
,
'v'
)
);
p_sys
->
p_packetizer
=
demux_PacketizerNew
(
p_demux
,
&
fmt
,
"mpeg4 video"
);
if
(
!
p_sys
->
p_packetizer
)
{
free
(
p_sys
);
return
VLC_EGENERIC
;
}
/* We need to wait until we get p_extra (VOL header) from the packetizer
* before we create the output */
var_Create
(
p_demux
,
"m4v-fps"
,
VLC_VAR_FLOAT
|
VLC_VAR_DOINHERIT
);
var_Get
(
p_demux
,
"m4v-fps"
,
&
val
);
p_sys
->
f_fps
=
val
.
f_float
;
p_sys
->
f_fps
=
var_CreateGetFloat
(
p_demux
,
"m4v-fps"
);
return
VLC_SUCCESS
;
}
...
...
@@ -126,8 +126,7 @@ static void Close( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
DESTROY_PACKETIZER
(
p_sys
->
p_packetizer
)
;
demux_PacketizerDestroy
(
p_sys
->
p_packetizer
);
free
(
p_sys
);
}
...
...
modules/demux/mpeg/mpgv.c
View file @
8be0e1ae
...
...
@@ -108,9 +108,13 @@ static int Open( vlc_object_t * p_this )
p_sys
->
p_es
=
NULL
;
/* Load the mpegvideo packetizer */
INIT_VPACKETIZER
(
p_sys
->
p_packetizer
,
'm'
,
'p'
,
'g'
,
'v'
);
es_format_Init
(
&
p_sys
->
p_packetizer
->
fmt_out
,
UNKNOWN_ES
,
0
);
LOAD_PACKETIZER_OR_FAIL
(
p_sys
->
p_packetizer
,
"MPEG Video"
);
es_format_Init
(
&
fmt
,
VIDEO_ES
,
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'v'
)
);
p_sys
->
p_packetizer
=
demux_PacketizerNew
(
p_demux
,
&
fmt
,
"mpeg video"
);
if
(
!
p_sys
->
p_packetizer
)
{
free
(
p_sys
);
return
VLC_EGENERIC
;
}
/* create the output */
es_format_Init
(
&
fmt
,
VIDEO_ES
,
VLC_FOURCC
(
'm'
,
'p'
,
'g'
,
'v'
)
);
...
...
@@ -127,8 +131,7 @@ static void Close( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
DESTROY_PACKETIZER
(
p_sys
->
p_packetizer
);
demux_PacketizerDestroy
(
p_sys
->
p_packetizer
);
free
(
p_sys
);
}
...
...
modules/demux/vc1.c
View file @
8be0e1ae
...
...
@@ -79,7 +79,7 @@ static int Open( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
;
const
uint8_t
*
p_peek
;
vlc_value_t
val
;
es_format_t
fmt
;
if
(
stream_Peek
(
p_demux
->
s
,
&
p_peek
,
5
)
<
5
)
return
VLC_EGENERIC
;
...
...
@@ -103,13 +103,17 @@ static int Open( vlc_object_t * p_this )
p_sys
->
p_es
=
NULL
;
p_sys
->
i_dts
=
1
;
p_sys
->
f_fps
=
var_CreateGetFloat
(
p_demux
,
"vc1-fps"
);
if
(
val
.
f_float
<
0
.
001
)
p_sys
->
f_fps
=
0
.
0
;
if
(
p_sys
->
f_fps
<
0
.
001
)
p_sys
->
f_fps
=
0
.
0
;
/* Load the packetizer */
INIT_VPACKETIZER
(
p_sys
->
p_packetizer
,
'W'
,
'V'
,
'C'
,
'1'
);
es_format_Init
(
&
p_sys
->
p_packetizer
->
fmt_out
,
UNKNOWN_ES
,
0
);
LOAD_PACKETIZER_OR_FAIL
(
p_sys
->
p_packetizer
,
"VC-1"
);
es_format_Init
(
&
fmt
,
VIDEO_ES
,
VLC_FOURCC
(
'W'
,
'V'
,
'C'
,
'1'
)
);
p_sys
->
p_packetizer
=
demux_PacketizerNew
(
p_demux
,
&
fmt
,
"VC-1"
);
if
(
!
p_sys
->
p_packetizer
)
{
free
(
p_sys
);
return
VLC_EGENERIC
;
}
return
VLC_SUCCESS
;
}
...
...
@@ -121,8 +125,7 @@ static void Close( vlc_object_t * p_this )
demux_t
*
p_demux
=
(
demux_t
*
)
p_this
;
demux_sys_t
*
p_sys
=
p_demux
->
p_sys
;
DESTROY_PACKETIZER
(
p_sys
->
p_packetizer
);
demux_PacketizerDestroy
(
p_sys
->
p_packetizer
);
free
(
p_sys
);
}
...
...
src/input/demux.c
View file @
8be0e1ae
...
...
@@ -26,6 +26,7 @@
#endif
#include <vlc_common.h>
#include <vlc_codec.h>
#include "input_internal.h"
...
...
@@ -567,6 +568,43 @@ static void* DStreamThread( vlc_object_t* p_this )
/****************************************************************************
* Utility functions
****************************************************************************/
decoder_t
*
demux_PacketizerNew
(
demux_t
*
p_demux
,
es_format_t
*
p_fmt
,
const
char
*
psz_msg
)
{
decoder_t
*
p_packetizer
=
vlc_object_create
(
p_demux
,
VLC_OBJECT_PACKETIZER
);
if
(
!
p_packetizer
)
{
es_format_Clean
(
p_fmt
);
return
NULL
;
}
p_packetizer
->
pf_decode_audio
=
NULL
;
p_packetizer
->
pf_decode_video
=
NULL
;
p_packetizer
->
pf_decode_sub
=
NULL
;
p_packetizer
->
pf_packetize
=
NULL
;
p_packetizer
->
fmt_in
=
*
p_fmt
;
es_format_Init
(
&
p_packetizer
->
fmt_out
,
UNKNOWN_ES
,
0
);
p_packetizer
->
p_module
=
module_Need
(
p_packetizer
,
"packetizer"
,
NULL
,
0
);
if
(
!
p_packetizer
->
p_module
)
{
es_format_Clean
(
p_fmt
);
vlc_object_release
(
p_packetizer
);
msg_Err
(
p_demux
,
"cannot find packetizer for %s"
,
psz_msg
);
return
NULL
;
}
return
p_packetizer
;
}
void
demux_PacketizerDestroy
(
decoder_t
*
p_packetizer
)
{
if
(
p_packetizer
->
p_module
)
module_Unneed
(
p_packetizer
,
p_packetizer
->
p_module
);
es_format_Clean
(
&
p_packetizer
->
fmt_in
);
vlc_object_release
(
p_packetizer
);
}
static
bool
SkipID3Tag
(
demux_t
*
p_demux
)
{
const
uint8_t
*
p_peek
;
...
...
src/libvlccore.sym
View file @
8be0e1ae
...
...
@@ -91,6 +91,8 @@ decoder_SynchroReset
decoder_SynchroTrash
decode_URI
decode_URI_duplicate
demux_PacketizerDestroy
demux_PacketizerNew
demux_vaControlHelper
encode_URI_component
EndMD5
...
...
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