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
111e4939
Commit
111e4939
authored
Oct 14, 2014
by
Francois Cartegnie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
demux: libmp4: add generic string reading function
parent
602ef2d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
44 deletions
+42
-44
modules/demux/mp4/libmp4.c
modules/demux/mp4/libmp4.c
+24
-24
modules/demux/mp4/libmp4.h
modules/demux/mp4/libmp4.h
+3
-3
modules/demux/mp4/mp4.c
modules/demux/mp4/mp4.c
+15
-17
No files found.
modules/demux/mp4/libmp4.c
View file @
111e4939
...
...
@@ -2852,27 +2852,27 @@ static int MP4_ReadBox_drms( stream_t *p_stream, MP4_Box_t *p_box )
return
1
;
}
static
int
MP4_ReadBox_
name
(
stream_t
*
p_stream
,
MP4_Box_t
*
p_box
)
static
int
MP4_ReadBox_
String
(
stream_t
*
p_stream
,
MP4_Box_t
*
p_box
)
{
MP4_READBOX_ENTER
(
MP4_Box_data_
name
_t
);
MP4_READBOX_ENTER
(
MP4_Box_data_
string
_t
);
p_box
->
data
.
p_
name
->
psz_text
=
malloc
(
p_box
->
i_size
+
1
-
8
);
/* +\0, -name, -size */
if
(
p_box
->
data
.
p_
name
->
psz_text
==
NULL
)
p_box
->
data
.
p_
string
->
psz_text
=
malloc
(
p_box
->
i_size
+
1
-
8
);
/* +\0, -name, -size */
if
(
p_box
->
data
.
p_
string
->
psz_text
==
NULL
)
MP4_READBOX_EXIT
(
0
);
memcpy
(
p_box
->
data
.
p_
name
->
psz_text
,
p_peek
,
p_box
->
i_size
-
8
);
p_box
->
data
.
p_
name
->
psz_text
[
p_box
->
i_size
-
8
]
=
'\0'
;
memcpy
(
p_box
->
data
.
p_
string
->
psz_text
,
p_peek
,
p_box
->
i_size
-
8
);
p_box
->
data
.
p_
string
->
psz_text
[
p_box
->
i_size
-
8
]
=
'\0'
;
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
,
"read box:
\"
name
\"
text=`%s'"
,
p_box
->
data
.
p_
name
->
psz_text
);
msg_Dbg
(
p_stream
,
"read box:
\"
%4.4s
\"
text=`%s'"
,
(
char
*
)
&
p_box
->
i_type
,
p_box
->
data
.
p_
string
->
psz_text
);
#endif
MP4_READBOX_EXIT
(
1
);
}
static
void
MP4_FreeBox_
name
(
MP4_Box_t
*
p_box
)
static
void
MP4_FreeBox_
String
(
MP4_Box_t
*
p_box
)
{
FREENULL
(
p_box
->
data
.
p_
name
->
psz_text
);
FREENULL
(
p_box
->
data
.
p_
string
->
psz_text
);
}
static
int
MP4_ReadBox_data
(
stream_t
*
p_stream
,
MP4_Box_t
*
p_box
)
...
...
@@ -2902,9 +2902,9 @@ static int MP4_ReadBox_0xa9xxx( stream_t *p_stream, MP4_Box_t *p_box )
{
uint16_t
i16
;
MP4_READBOX_ENTER
(
MP4_Box_data_
0xa9xxx
_t
);
MP4_READBOX_ENTER
(
MP4_Box_data_
string
_t
);
p_box
->
data
.
p_
0xa9xxx
->
psz_text
=
NULL
;
p_box
->
data
.
p_
string
->
psz_text
=
NULL
;
MP4_GET2BYTES
(
i16
);
...
...
@@ -2915,20 +2915,20 @@ static int MP4_ReadBox_0xa9xxx( stream_t *p_stream, MP4_Box_t *p_box )
MP4_GET2BYTES
(
i16
);
if
(
i_length
>=
i_read
)
i_length
=
i_read
+
1
;
p_box
->
data
.
p_
0xa9xxx
->
psz_text
=
malloc
(
i_length
);
if
(
p_box
->
data
.
p_
0xa9xxx
->
psz_text
==
NULL
)
p_box
->
data
.
p_
string
->
psz_text
=
malloc
(
i_length
);
if
(
p_box
->
data
.
p_
string
->
psz_text
==
NULL
)
MP4_READBOX_EXIT
(
0
);
i_length
--
;
memcpy
(
p_box
->
data
.
p_
0xa9xxx
->
psz_text
,
memcpy
(
p_box
->
data
.
p_
string
->
psz_text
,
p_peek
,
i_length
);
p_box
->
data
.
p_
0xa9xxx
->
psz_text
[
i_length
]
=
'\0'
;
p_box
->
data
.
p_
string
->
psz_text
[
i_length
]
=
'\0'
;
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
,
"read box:
\"
c%3.3s
\"
text=`%s'"
,
((
char
*
)
&
p_box
->
i_type
+
1
),
p_box
->
data
.
p_
0xa9xxx
->
psz_text
);
p_box
->
data
.
p_
string
->
psz_text
);
#endif
}
else
...
...
@@ -2955,18 +2955,18 @@ static int MP4_ReadBox_0xa9xxx( stream_t *p_stream, MP4_Box_t *p_box )
{
// the rest is the text
i_data_len
-=
12
;
p_box
->
data
.
p_
0xa9xxx
->
psz_text
=
malloc
(
i_data_len
+
1
);
if
(
p_box
->
data
.
p_
0xa9xxx
->
psz_text
==
NULL
)
p_box
->
data
.
p_
string
->
psz_text
=
malloc
(
i_data_len
+
1
);
if
(
p_box
->
data
.
p_
string
->
psz_text
==
NULL
)
MP4_READBOX_EXIT
(
0
);
memcpy
(
p_box
->
data
.
p_
0xa9xxx
->
psz_text
,
memcpy
(
p_box
->
data
.
p_
string
->
psz_text
,
p_peek
,
i_data_len
);
p_box
->
data
.
p_
0xa9xxx
->
psz_text
[
i_data_len
]
=
'\0'
;
p_box
->
data
.
p_
string
->
psz_text
[
i_data_len
]
=
'\0'
;
#ifdef MP4_VERBOSE
msg_Dbg
(
p_stream
,
"read box:
\"
c%3.3s
\"
text=`%s'"
,
((
char
*
)
&
p_box
->
i_type
+
1
),
p_box
->
data
.
p_
0xa9xxx
->
psz_text
);
p_box
->
data
.
p_
string
->
psz_text
);
#endif
}
else
...
...
@@ -2980,7 +2980,7 @@ static int MP4_ReadBox_0xa9xxx( stream_t *p_stream, MP4_Box_t *p_box )
}
static
void
MP4_FreeBox_0xa9xxx
(
MP4_Box_t
*
p_box
)
{
FREENULL
(
p_box
->
data
.
p_
0xa9xxx
->
psz_text
);
FREENULL
(
p_box
->
data
.
p_
string
->
psz_text
);
}
/* Chapter support */
...
...
@@ -3735,7 +3735,7 @@ static const struct
{
ATOM_chpl
,
MP4_ReadBox_chpl
,
MP4_FreeBox_chpl
,
ATOM_udta
},
{
ATOM_covr
,
MP4_ReadBoxContainer
,
MP4_FreeBox_Common
,
ATOM_udta
},
{
ATOM_gnre
,
MP4_ReadBox_gnre
,
MP4_FreeBox_Common
,
ATOM_udta
},
{
ATOM_name
,
MP4_ReadBox_
name
,
MP4_FreeBox_name
,
ATOM_udta
},
{
ATOM_name
,
MP4_ReadBox_
String
,
MP4_FreeBox_String
,
ATOM_udta
},
{
ATOM_trkn
,
MP4_ReadBox_trkn
,
MP4_FreeBox_Common
,
ATOM_udta
},
/* iTunes/Quicktime meta info */
...
...
modules/demux/mp4/libmp4.h
View file @
111e4939
...
...
@@ -1007,7 +1007,7 @@ typedef struct
{
char
*
psz_text
;
}
MP4_Box_data_
name
_t
;
}
MP4_Box_data_
string
_t
;
typedef
struct
{
...
...
@@ -1382,10 +1382,8 @@ typedef union MP4_Box_data_s
MP4_Box_data_rmqu_t
*
p_rmqu
;
MP4_Box_data_rmvc_t
*
p_rmvc
;
MP4_Box_data_0xa9xxx_t
*
p_0xa9xxx
;
MP4_Box_data_chpl_t
*
p_chpl
;
MP4_Box_data_tref_generic_t
*
p_tref_generic
;
MP4_Box_data_name_t
*
p_name
;
MP4_Box_data_tfrf_t
*
p_tfrf
;
MP4_Box_data_tfxd_t
*
p_tfxd
;
...
...
@@ -1394,6 +1392,8 @@ typedef union MP4_Box_data_s
MP4_Box_data_strf_t
*
p_strf
;
/* flip4mac Little endian video config */
MP4_Box_data_ASF_t
*
p_asf
;
/* flip4mac asf streams indicator */
/* for generic handlers */
MP4_Box_data_string_t
*
p_string
;
MP4_Box_data_data_t
*
p_data
;
void
*
p_payload
;
/* for unknow type */
...
...
modules/demux/mp4/mp4.c
View file @
111e4939
...
...
@@ -1476,7 +1476,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
case
DEMUX_GET_META
:
{
vlc_meta_t
*
p_meta
=
(
vlc_meta_t
*
)
va_arg
(
args
,
vlc_meta_t
*
);
MP4_Box_t
*
p_
0xa9xxx
;
MP4_Box_t
*
p_
string
;
MP4_Box_t
*
p_covr
=
MP4_BoxGet
(
p_sys
->
p_root
,
"/moov/udta/meta/ilst/covr/data[0]"
);
if
(
p_covr
)
...
...
@@ -1492,21 +1492,21 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return
VLC_SUCCESS
;
}
for
(
p_
0xa9xxx
=
p_udta
->
p_first
;
p_0xa9xxx
!=
NULL
;
p_
0xa9xxx
=
p_0xa9xxx
->
p_next
)
for
(
p_
string
=
p_udta
->
p_first
;
p_string
!=
NULL
;
p_
string
=
p_string
->
p_next
)
{
if
(
!
p_
0xa9xxx
||
!
BOXDATA
(
p_0xa9xxx
)
)
if
(
!
p_
string
||
!
BOXDATA
(
p_string
)
)
continue
;
/* FIXME FIXME: should convert from whatever the character
* encoding of MP4 meta data is to UTF-8. */
#define SET(fct) do { char *psz_utf = strdup( BOXDATA(p_
0xa9xxx)->psz_text ? BOXDATA(p_0xa9xxx
)->psz_text : "" ); \
#define SET(fct) do { char *psz_utf = strdup( BOXDATA(p_
string)->psz_text ? BOXDATA(p_string
)->psz_text : "" ); \
if( psz_utf ) { EnsureUTF8( psz_utf ); \
fct( p_meta, psz_utf ); free( psz_utf ); } } while(0)
/* XXX Becarefull p_udta can have box that are not 0xa9xx */
switch
(
p_
0xa9xxx
->
i_type
)
switch
(
p_
string
->
i_type
)
{
case
ATOM_0xa9nam
:
/* Full name */
SET
(
vlc_meta_SetTitle
);
...
...
@@ -1531,8 +1531,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
break
;
case
ATOM_gnre
:
if
(
p_
0xa9xxx
->
data
.
p_gnre
->
i_genre
<=
NUM_GENRES
)
vlc_meta_SetGenre
(
p_meta
,
ppsz_genres
[
p_
0xa9xxx
->
data
.
p_gnre
->
i_genre
-
1
]
);
if
(
p_
string
->
data
.
p_gnre
->
i_genre
<=
NUM_GENRES
)
vlc_meta_SetGenre
(
p_meta
,
ppsz_genres
[
p_
string
->
data
.
p_gnre
->
i_genre
-
1
]
);
break
;
case
ATOM_0xa9alb
:
/* Album */
...
...
@@ -1546,12 +1546,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
{
char
psz_trck
[
11
];
snprintf
(
psz_trck
,
sizeof
(
psz_trck
),
"%i"
,
p_
0xa9xxx
->
data
.
p_trkn
->
i_track_number
);
p_
string
->
data
.
p_trkn
->
i_track_number
);
vlc_meta_SetTrackNum
(
p_meta
,
psz_trck
);
if
(
p_
0xa9xxx
->
data
.
p_trkn
->
i_track_total
>
0
)
if
(
p_
string
->
data
.
p_trkn
->
i_track_total
>
0
)
{
snprintf
(
psz_trck
,
sizeof
(
psz_trck
),
"%i"
,
p_
0xa9xxx
->
data
.
p_trkn
->
i_track_total
);
p_
string
->
data
.
p_trkn
->
i_track_total
);
vlc_meta_Set
(
p_meta
,
vlc_meta_TrackTotal
,
psz_trck
);
}
break
;
...
...
@@ -1620,9 +1620,9 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
};
for
(
unsigned
i
=
0
;
xa9typetoextrameta
[
i
].
xa9_type
;
i
++
)
{
if
(
p_
0xa9xxx
->
i_type
==
xa9typetoextrameta
[
i
].
xa9_type
)
if
(
p_
string
->
i_type
==
xa9typetoextrameta
[
i
].
xa9_type
)
{
char
*
psz_utf
=
strdup
(
BOXDATA
(
p_
0xa9xxx
)
->
psz_text
?
BOXDATA
(
p_0xa9xxx
)
->
psz_text
:
""
);
char
*
psz_utf
=
strdup
(
BOXDATA
(
p_
string
)
->
psz_text
?
BOXDATA
(
p_string
)
->
psz_text
:
""
);
if
(
psz_utf
)
{
EnsureUTF8
(
psz_utf
);
...
...
@@ -2739,12 +2739,10 @@ static void MP4_TrackCreate( demux_t *p_demux, mp4_track_t *p_track,
switch
(
p_box_iter
->
i_type
)
{
case
ATOM_0xa9nam
:
p_track
->
fmt
.
psz_description
=
strdup
(
p_box_iter
->
data
.
p_0xa9xxx
->
psz_text
);
break
;
case
ATOM_name
:
p_track
->
fmt
.
psz_description
=
strdup
(
p_box_iter
->
data
.
p_name
->
psz_text
);
strdup
(
p_box_iter
->
data
.
p_string
->
psz_text
);
default:
break
;
}
}
...
...
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