Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
02346f2f
Commit
02346f2f
authored
Mar 17, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
metadata parsing for mp4 files is working, next need to work on AAC
git-svn-id:
https://svn.musicpd.org/mpd/trunk@270
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
290102fd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
11 deletions
+127
-11
Makefile.am
src/mp4ff/Makefile.am
+2
-0
mp4ff.h
src/mp4ff/mp4ff.h
+1
-2
tag.c
src/tag.c
+124
-9
No files found.
src/mp4ff/Makefile.am
View file @
02346f2f
...
...
@@ -5,3 +5,5 @@ noinst_HEADERS = mp4ff.h
libmp4ff_la_SOURCES
=
mp4ff.c mp4atom.c mp4meta.c mp4sample.c mp4util.c
\
mp4tagupdate.c mp4ff.h mp4ffint.h mp4ff_int_types.h
\
drms.h drms.c drmstables.h
AM_CFLAGS
=
-DUSE_TAGGING
=
1
src/mp4ff/mp4ff.h
View file @
02346f2f
...
...
@@ -125,4 +125,4 @@ int32_t mp4ff_meta_update(mp4ff_callback_t *f,const mp4ff_metadata_t * data);
}
#endif
/* __cplusplus */
#endif
\ No newline at end of file
#endif
src/tag.c
View file @
02346f2f
...
...
@@ -44,6 +44,10 @@
#include <id3tag.h>
#endif
#endif
#ifdef HAVE_FAAD
#include <faad.h>
#include "mp4ff/mp4ff.h"
#endif
void
printMpdTag
(
FILE
*
fp
,
MpdTag
*
tag
)
{
if
(
tag
->
artist
)
myfprintf
(
fp
,
"Artist: %s
\n
"
,
tag
->
artist
);
...
...
@@ -168,18 +172,129 @@ MpdTag * mp3TagDup(char * utf8file) {
#endif
#ifdef HAVE_FAAD
MpdTag
*
mp4TagDup
(
char
*
utf8file
)
{
/* copied from FAAD2 frontend */
int
mp4GetAACTrack
(
mp4ff_t
*
infile
)
{
/* find AAC track */
int
i
,
rc
;
int
numTracks
=
mp4ff_total_tracks
(
infile
);
for
(
i
=
0
;
i
<
numTracks
;
i
++
)
{
unsigned
char
*
buff
=
NULL
;
int
buff_size
=
0
;
mp4AudioSpecificConfig
mp4ASC
;
mp4ff_get_decoder_config
(
infile
,
i
,
&
buff
,
&
buff_size
);
if
(
buff
)
{
rc
=
AudioSpecificConfig
(
buff
,
buff_size
,
&
mp4ASC
);
free
(
buff
);
if
(
rc
<
0
)
continue
;
return
i
;
}
}
/* can't decode this */
return
-
1
;
}
uint32_t
mp4ReadCallback
(
void
*
user_data
,
void
*
buffer
,
uint32_t
length
)
{
return
fread
(
buffer
,
1
,
length
,
(
FILE
*
)
user_data
);
}
uint32_t
mp4SeekCallback
(
void
*
user_data
,
uint64_t
position
)
{
return
fseek
((
FILE
*
)
user_data
,
position
,
SEEK_SET
);
}
MpdTag
*
mp4DataDup
(
char
*
utf8file
,
int
*
mp4MetadataFound
)
{
MpdTag
*
ret
=
NULL
;
int
time
;
FILE
*
fh
;
mp4ff_t
*
mp4fh
;
mp4ff_callback_t
*
cb
;
int32_t
track
;
int32_t
time
;
int32_t
scale
;
#warning implement mp4 tag parsing, this includes using mp4v2 and id3
#warning getMp4TotalTime needs implementing
//time = getMp4TotalTime(rmp2amp(utf8ToFsCharset(utf8file)));
time
=
0
;
*
mp4MetadataFound
=
0
;
if
(
time
>=
0
)
{
if
(
!
ret
)
ret
=
newMpdTag
();
ret
->
time
=
time
;
blockSignals
();
fh
=
fopen
(
rmp2amp
(
utf8ToFsCharset
(
utf8file
)),
"r"
);
if
(
!
fh
)
{
unblockSignals
();
return
NULL
;
}
cb
=
malloc
(
sizeof
(
mp4ff_callback_t
));
cb
->
read
=
mp4ReadCallback
;
cb
->
seek
=
mp4SeekCallback
;
cb
->
user_data
=
fh
;
mp4fh
=
mp4ff_open_read
(
cb
);
if
(
!
mp4fh
)
{
free
(
cb
);
fclose
(
fh
);
unblockSignals
();
return
NULL
;
}
track
=
mp4GetAACTrack
(
mp4fh
);
if
(
track
<
0
)
{
mp4ff_close
(
mp4fh
);
fclose
(
fh
);
free
(
cb
);
unblockSignals
();
return
NULL
;
}
ret
=
newMpdTag
();
time
=
mp4ff_get_track_duration_use_offsets
(
mp4fh
,
track
);
scale
=
mp4ff_time_scale
(
mp4fh
,
track
);
if
(
scale
<
0
)
{
mp4ff_close
(
mp4fh
);
fclose
(
fh
);
free
(
cb
);
freeMpdTag
(
ret
);
unblockSignals
();
return
NULL
;
}
ret
->
time
=
((
float
)
time
)
/
scale
+
0
.
5
;
if
(
!
mp4ff_meta_get_artist
(
mp4fh
,
&
ret
->
artist
))
{
*
mp4MetadataFound
=
1
;
}
if
(
!
mp4ff_meta_get_album
(
mp4fh
,
&
ret
->
album
))
{
*
mp4MetadataFound
=
1
;
}
if
(
!
mp4ff_meta_get_title
(
mp4fh
,
&
ret
->
title
))
{
*
mp4MetadataFound
=
1
;
}
if
(
!
mp4ff_meta_get_track
(
mp4fh
,
&
ret
->
track
))
{
*
mp4MetadataFound
=
1
;
}
mp4ff_close
(
mp4fh
);
fclose
(
fh
);
free
(
cb
);
unblockSignals
();
return
ret
;
}
MpdTag
*
mp4TagDup
(
char
*
utf8file
)
{
MpdTag
*
ret
=
NULL
;
int
mp4MetadataFound
=
0
;
ret
=
mp4DataDup
(
utf8file
,
&
mp4MetadataFound
);
if
(
!
mp4MetadataFound
)
{
MpdTag
*
temp
=
id3Dup
(
utf8file
);
if
(
temp
)
{
temp
->
time
=
ret
->
time
;
freeMpdTag
(
ret
);
ret
=
temp
;
}
}
return
ret
;
...
...
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