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
2171d2e9
Commit
2171d2e9
authored
Sep 08, 2003
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* all: clean up.
parent
e40e6065
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
151 additions
and
451 deletions
+151
-451
modules/demux/mp4/libmp4.c
modules/demux/mp4/libmp4.c
+57
-211
modules/demux/mp4/libmp4.h
modules/demux/mp4/libmp4.h
+58
-194
modules/demux/mp4/mp4.c
modules/demux/mp4/mp4.c
+32
-44
modules/demux/mp4/mp4.h
modules/demux/mp4/mp4.h
+4
-2
No files found.
modules/demux/mp4/libmp4.c
View file @
2171d2e9
This diff is collapsed.
Click to expand it.
modules/demux/mp4/libmp4.h
View file @
2171d2e9
...
...
@@ -2,7 +2,7 @@
* libmp4.h : LibMP4 library for mp4 module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: libmp4.h,v 1.1
5 2003/08/17 20:45:50
fenrir Exp $
* $Id: libmp4.h,v 1.1
6 2003/09/08 00:35:16
fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -776,35 +776,21 @@ typedef struct MP4_Box_s
}
MP4_Box_t
;
/*---------------------------------------------------------------------------*/
/* */
/****----------------------- High level functions ------------------------****/
/* */
/*---------------------------------------------------------------------------*/
/*****************************************************************************
* Function for manipulate stream easily
*****************************************************************************/
off_t
MP4_TellAbsolute
(
input_thread_t
*
p_input
);
int
MP4_SeekAbsolute
(
input_thread_t
*
p_input
,
off_t
i_pos
);
int
MP4_ReadData
(
input_thread_t
*
p_input
,
uint8_t
*
p_buff
,
int
i_size
);
/*****************************************************************************
* MP4_BoxGetRoot : Parse the entire file, and create all boxes in memory
*****************************************************************************
* The first box is a virtual box "root" and is the father for all first
* level boxes
*
* RETURN : 1 if succes and 0 if it failed
*****************************************************************************/
int
MP4_BoxGetRoot
(
input_thread_t
*
p_input
,
MP4_Box_t
*
p_roo
t
);
MP4_Box_t
*
MP4_BoxGetRoot
(
input_thread_t
*
p_inpu
t
);
/*****************************************************************************
* MP4_FreeBox : free memory allocated after read with MP4_ReadBox
* or MP4_BoxGetRoot, this means also children boxes
* XXX : all children have to be allocated by a malloc !! and
* p_box is
n't freeing
* p_box is
freed
*****************************************************************************/
void
MP4_BoxFree
(
input_thread_t
*
p_input
,
MP4_Box_t
*
p_box
);
...
...
@@ -838,125 +824,3 @@ MP4_Box_t *MP4_BoxGet( MP4_Box_t *p_box, char *psz_fmt, ... );
*****************************************************************************/
int
MP4_BoxCount
(
MP4_Box_t
*
p_box
,
char
*
psz_fmt
,
...
);
/*---------------------------------------------------------------------------*/
/* */
/****---------------------- Medium level functions -----------------------****/
/* */
/*---------------------------------------------------------------------------*/
#if 0
/*****************************************************************************
* MP4_CountBox: given a box, count how many child have the requested type
* FIXME : support GUUID
*****************************************************************************/
int MP4_CountBox( MP4_Box_t *p_box, uint32_t i_type );
#endif
/*****************************************************************************
* MP4_FindBox: find first box with i_type child of p_box
* return NULL if not found
*****************************************************************************/
MP4_Box_t
*
MP4_FindBox
(
MP4_Box_t
*
p_box
,
uint32_t
i_type
);
#if 0
/*****************************************************************************
* MP4_FindNextBox: find next box with thesame type and at the same level
* than p_box
*****************************************************************************/
MP4_Box_t *MP4_FindNextBox( MP4_Box_t *p_box );
/*****************************************************************************
* MP4_FindNbBox: find the box i_number
*****************************************************************************/
MP4_Box_t *MP4_FindNbBox( MP4_Box_t *p_box, uint32_t i_number );
#endif
/*---------------------------------------------------------------------------*/
/****----------------------- Lower level functions -----------------------****/
/**** ****/
/****------Use them only when you known what they really do and need------****/
/**** ****/
/****---------------------------------------------------------------------****/
/*---------------------------------------------------------------------------*/
/**** ------- First some function to make abstract from input -------- */
/****************************************************************************
* MP4_InputStream create an stram with an input
*
****************************************************************************/
MP4_Stream_t
*
MP4_InputStream
(
input_thread_t
*
p_input
);
/****************************************************************************
* MP4_MemoryStream create a memory stream
* if p_buffer == NULL, will allocate a buffer of i_size, else
* it uses p_buffer XXX you have to unallocate yourself !
*
****************************************************************************/
MP4_Stream_t
*
MP4_MemoryStream
(
input_thread_t
*
p_input
,
int
i_size
,
uint8_t
*
p_buffer
);
/****************************************************************************
* MP4_ReadStream read from a MP4_Stream_t
*
****************************************************************************/
int
MP4_ReadStream
(
MP4_Stream_t
*
p_stream
,
uint8_t
*
p_buff
,
int
i_size
);
/****************************************************************************
* MP4_PeekStream guess it ;)
*
****************************************************************************/
int
MP4_PeekStream
(
MP4_Stream_t
*
p_stream
,
uint8_t
**
pp_peek
,
int
i_size
);
/****************************************************************************
* MP4_TellStream give absolute position in the stream
* XXX for a memory stream give position from begining of the buffer
****************************************************************************/
off_t
MP4_TellStream
(
MP4_Stream_t
*
p_stream
);
/****************************************************************************
* MP4_SeekStream seek in a MP4_Stream_t
*
****************************************************************************/
int
MP4_SeekStream
(
MP4_Stream_t
*
p_stream
,
off_t
i_pos
);
/*****************************************************************************
* MP4_ReadBox : parse the actual box and the children if they exist
*
* RETURN : 1 if succes and 0 if it failed
*****************************************************************************/
int
MP4_ReadBox
(
MP4_Stream_t
*
p_stream
,
MP4_Box_t
*
p_box
,
MP4_Box_t
*
p_father
);
/*****************************************************************************
* MP4_ReadBoxCommon : Load only common parameters for all boxes
*****************************************************************************
* p_box need to be an already allocated MP4_Box_t, and all data
* will only be peek not read
*
* RETURN : 0 if it fail, 1 otherwise
*****************************************************************************/
int
MP4_ReadBoxCommon
(
MP4_Stream_t
*
p_stream
,
MP4_Box_t
*
p_box
);
/*****************************************************************************
* MP4_MP4_GotoBox : Go to this particular box
*****************************************************************************
* RETURN : 0 if it fail, 1 otherwise
*****************************************************************************/
int
MP4_GotoBox
(
MP4_Stream_t
*
p_stream
,
MP4_Box_t
*
p_box
);
/*****************************************************************************
* MP4_MP4_NextBox : Go to the next box wiithin p_box->p_father
*****************************************************************************
* if p_box == NULL, go to the next box in witch we are( at the begining ).
*****************************************************************************/
int
MP4_NextBox
(
MP4_Stream_t
*
p_stream
,
MP4_Box_t
*
p_box
);
modules/demux/mp4/mp4.c
View file @
2171d2e9
...
...
@@ -2,7 +2,7 @@
* mp4.c : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mp4.c,v 1.3
5 2003/09/07 22:48:29
fenrir Exp $
* $Id: mp4.c,v 1.3
6 2003/09/08 00:35:16
fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -138,21 +138,28 @@ static int Open( vlc_object_t * p_this )
p_input
->
pf_demux
=
Demux
;
p_input
->
pf_demux_control
=
Control
;
/* create our structure that will contains all data */
p_input
->
p_demux_data
=
p_demux
=
malloc
(
sizeof
(
demux_sys_t
)
);
memset
(
p_demux
,
0
,
sizeof
(
demux_sys_t
)
);
/* Create stream facilities */
if
(
(
p_demux
->
s
=
stream_OpenInput
(
p_input
)
)
==
NULL
)
{
msg_Err
(
p_input
,
"cannot create stream_t"
);
free
(
p_demux
);
return
VLC_EGENERIC
;
}
/* Now load all boxes ( except raw data ) */
if
(
!
MP4_BoxGetRoot
(
p_input
,
&
p_demux
->
box_root
)
)
if
(
(
p_demux
->
p_root
=
MP4_BoxGetRoot
(
p_input
)
)
==
NULL
)
{
msg_Warn
(
p_input
,
"MP4 plugin discarded (not a valid file)"
);
return
VLC_EGENERIC
;
goto
error
;
}
MP4_BoxDumpStructure
(
p_input
,
&
p_demux
->
box
_root
);
MP4_BoxDumpStructure
(
p_input
,
p_demux
->
p
_root
);
if
(
(
p_ftyp
=
MP4_BoxGet
(
&
p_demux
->
box
_root
,
"/ftyp"
)
)
)
if
(
(
p_ftyp
=
MP4_BoxGet
(
p_demux
->
p
_root
,
"/ftyp"
)
)
)
{
switch
(
p_ftyp
->
data
.
p_ftyp
->
i_major_brand
)
{
...
...
@@ -174,9 +181,9 @@ static int Open( vlc_object_t * p_this )
}
/* the file need to have one moov box */
if
(
MP4_BoxCount
(
&
p_demux
->
box
_root
,
"/moov"
)
<=
0
)
if
(
MP4_BoxCount
(
p_demux
->
p
_root
,
"/moov"
)
<=
0
)
{
MP4_Box_t
*
p_foov
=
MP4_BoxGet
(
&
p_demux
->
box
_root
,
"/foov"
);
MP4_Box_t
*
p_foov
=
MP4_BoxGet
(
p_demux
->
p
_root
,
"/foov"
);
if
(
!
p_foov
)
{
...
...
@@ -187,7 +194,7 @@ static int Open( vlc_object_t * p_this )
p_foov
->
i_type
=
FOURCC_moov
;
}
if
(
(
p_rmra
=
MP4_BoxGet
(
&
p_demux
->
box
_root
,
"/moov/rmra"
)
)
)
if
(
(
p_rmra
=
MP4_BoxGet
(
p_demux
->
p
_root
,
"/moov/rmra"
)
)
)
{
playlist_t
*
p_playlist
;
int
i_count
=
MP4_BoxCount
(
p_rmra
,
"rmda"
);
...
...
@@ -267,7 +274,7 @@ static int Open( vlc_object_t * p_this )
}
}
if
(
!
(
p_mvhd
=
MP4_BoxGet
(
&
p_demux
->
box
_root
,
"/moov/mvhd"
)
)
)
if
(
!
(
p_mvhd
=
MP4_BoxGet
(
p_demux
->
p
_root
,
"/moov/mvhd"
)
)
)
{
if
(
!
p_rmra
)
{
...
...
@@ -288,7 +295,7 @@ static int Open( vlc_object_t * p_this )
}
if
(
!
(
p_demux
->
i_tracks
=
MP4_BoxCount
(
&
p_demux
->
box
_root
,
"/moov/trak"
)
)
)
MP4_BoxCount
(
p_demux
->
p
_root
,
"/moov/trak"
)
)
)
{
msg_Err
(
p_input
,
"cannot find any /moov/trak"
);
goto
error
;
...
...
@@ -332,7 +339,7 @@ static int Open( vlc_object_t * p_this )
/* now process each track and extract all usefull informations */
for
(
i
=
0
;
i
<
p_demux
->
i_tracks
;
i
++
)
{
p_trak
=
MP4_BoxGet
(
&
p_demux
->
box
_root
,
"/moov/trak[%d]"
,
i
);
p_trak
=
MP4_BoxGet
(
p_demux
->
p
_root
,
"/moov/trak[%d]"
,
i
);
MP4_TrackCreate
(
p_input
,
&
p_demux
->
track
[
i
],
p_trak
);
if
(
p_demux
->
track
[
i
].
b_ok
)
...
...
@@ -391,7 +398,12 @@ static int Open( vlc_object_t * p_this )
return
VLC_SUCCESS
;
error:
Close
(
VLC_OBJECT
(
p_input
)
);
stream_Release
(
p_demux
->
s
);
if
(
p_demux
->
p_root
)
{
MP4_BoxFree
(
p_input
,
p_demux
->
p_root
);
}
free
(
p_demux
);
return
VLC_EGENERIC
;
}
...
...
@@ -491,7 +503,6 @@ static int Demux( input_thread_t *p_input )
size_t
i_size
;
off_t
i_pos
;
data_packet_t
*
p_data
;
pes_packet_t
*
p_pes
;
/* caculate size and position for this sample */
...
...
@@ -502,44 +513,20 @@ static int Demux( input_thread_t *p_input )
//msg_Dbg( p_input, "stream %d size=%6d pos=%8lld", i_track, i_size, i_pos );
/* go,go go ! */
if
(
MP4_SeekAbsolute
(
p_input
,
i_pos
)
)
if
(
stream_Seek
(
p_demux
->
s
,
i_pos
)
)
{
msg_Warn
(
p_input
,
"track[0x%x] will be disabled (eof?)"
,
track
.
i_track_ID
);
MP4_TrackUnselect
(
p_input
,
&
track
);
break
;
}
/* now create a pes */
if
(
!
(
p_pes
=
input_NewPES
(
p_input
->
p_method_data
)
)
)
/* now read pes */
if
(
(
p_pes
=
stream_PesPacket
(
p_demux
->
s
,
i_size
)
)
==
NULL
)
{
break
;
}
/* and a data packet for the data */
if
(
!
(
p_data
=
input_NewPacket
(
p_input
->
p_method_data
,
i_size
)
)
)
{
input_DeletePES
(
p_input
->
p_method_data
,
p_pes
);
break
;
}
p_data
->
p_payload_end
=
p_data
->
p_payload_start
+
i_size
;
/* initialisation of all the field */
p_pes
->
i_dts
=
p_pes
->
i_pts
=
0
;
p_pes
->
p_first
=
p_pes
->
p_last
=
p_data
;
p_pes
->
i_nb_data
=
1
;
p_pes
->
i_pes_size
=
i_size
;
if
(
i_size
>
0
)
{
if
(
MP4_ReadData
(
p_input
,
p_data
->
p_payload_start
,
i_size
)
)
{
input_DeletePES
(
p_input
->
p_method_data
,
p_pes
);
msg_Warn
(
p_input
,
"track[0x%x] will be disabled (eof?)"
,
track
.
i_track_ID
);
MP4_TrackUnselect
(
p_input
,
&
track
);
break
;
}
}
p_pes
->
i_dts
=
p_pes
->
i_pts
=
input_ClockGetTS
(
p_input
,
p_input
->
stream
.
p_selected_program
,
...
...
@@ -657,7 +644,8 @@ static void Close ( vlc_object_t * p_this )
demux_sys_t
*
p_demux
=
p_input
->
p_demux_data
;
msg_Dbg
(
p_input
,
"freeing all memory"
);
MP4_BoxFree
(
p_input
,
&
p_demux
->
box_root
);
MP4_BoxFree
(
p_input
,
p_demux
->
p_root
);
for
(
i_track
=
0
;
i_track
<
p_demux
->
i_tracks
;
i_track
++
)
{
MP4_TrackDestroy
(
p_input
,
&
p_demux
->
track
[
i_track
]
);
...
...
modules/demux/mp4/mp4.h
View file @
2171d2e9
...
...
@@ -2,7 +2,7 @@
* mp4.h : MP4 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: mp4.h,v 1.
6 2003/03/11 18:57:51
fenrir Exp $
* $Id: mp4.h,v 1.
7 2003/09/08 00:35:16
fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -127,7 +127,9 @@ typedef struct track_data_mp4_s
*****************************************************************************/
struct
demux_sys_t
{
MP4_Box_t
box_root
;
/* container for the whole file */
stream_t
*
s
;
MP4_Box_t
*
p_root
;
/* container for the whole file */
mtime_t
i_pcr
;
...
...
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