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
ffea273a
Commit
ffea273a
authored
13 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tag_handler: handle arbitrary name/value pairs
The new method pair() receives an arbitrary name/value pair. Support for this is being added to a few decoder plugins.
parent
1783aac4
sisyphus
0.23.15-alt1
0.23.14-alt1
0.23.13-alt1
0.23.12-alt1
0.23.11-alt1
0.23.8-alt3
0.23.8-alt2
0.23.8-alt1
0.21.24-alt1.1
0.21.24-alt1
0.20.23-alt3
0.20.23-alt2
0.20.23-alt1
0.20.21-alt1
0.20.15-alt1
0.18.14-alt1
0.18.11-alt1.1
0.18.11-alt1
0.18.10-alt1
v0.18.14
v0.18.13
v0.18.12
v0.18.11
v0.18.10
v0.18.9
v0.18.8
v0.18.7
v0.18.6
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.17.3
v0.17.2
v0.17.1
mpd/0.20.6-alt1
mpd/0.19.9-alt1
mpd/0.18.14-alt2
gb-sisyphus-task339776.6100
gb-sisyphus-task337393.100
gb-sisyphus-task337176.300
gb-sisyphus-task334590.100
gb-sisyphus-task333607.100
gb-sisyphus-task331543.2500
gb-sisyphus-task328663.4700
gb-sisyphus-task325064.100
gb-sisyphus-task319111.4000
gb-sisyphus-task313704.100
gb-sisyphus-task312885.100
gb-sisyphus-task308905.3200
gb-sisyphus-task305294.500
gb-sisyphus-task304007.100
gb-sisyphus-task303674.1700
gb-sisyphus-task298681.300
gb-sisyphus-task296051.1000
gb-sisyphus-task274827.100
gb-sisyphus-task269249.2000
gb-sisyphus-task266579.400
gb-sisyphus-task258132.600
gb-sisyphus-task254601.200
gb-sisyphus-task253310.100
gb-sisyphus-task252214.300
gb-sisyphus-task251539.6100
gb-sisyphus-task247988.7000
gb-sisyphus-task238768.6000
gb-sisyphus-task229151.100
gb-sisyphus-task227574.200
gb-sisyphus-task226762.6000
gb-sisyphus-task219546.1700
gb-sisyphus-task213491.100
gb-sisyphus-task198806.100
gb-sisyphus-task181400.100
gb-sisyphus-task141957.100
gb-sisyphus-task135039.100
gb-sisyphus-task130102.100
gb-sisyphus-task129023.100
gb-sisyphus-task127959.100
gb-sisyphus-task118591.100
gb-p9-task277538.2600
gb-c9f2-task327704.1100
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
114 additions
and
9 deletions
+114
-9
ffmpeg_metadata.c
src/decoder/ffmpeg_metadata.c
+20
-0
flac_metadata.c
src/decoder/flac_metadata.c
+13
-0
mp4ff_decoder_plugin.c
src/decoder/mp4ff_decoder_plugin.c
+2
-0
vorbis_comments.c
src/decoder/vorbis_comments.c
+13
-0
wavpack_decoder_plugin.c
src/decoder/wavpack_decoder_plugin.c
+27
-0
tag_ape.c
src/tag_ape.c
+2
-0
tag_handler.h
src/tag_handler.h
+18
-0
tag_id3.c
src/tag_id3.c
+11
-8
read_tags.c
test/read_tags.c
+8
-1
No files found.
src/decoder/ffmpeg_metadata.c
View file @
ffea273a
...
...
@@ -50,6 +50,21 @@ ffmpeg_copy_metadata(enum tag_type type,
type
,
mt
->
value
);
}
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
static
void
ffmpeg_scan_pairs
(
AVDictionary
*
dict
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
AVDictionaryEntry
*
i
=
NULL
;
while
((
i
=
av_dict_get
(
dict
,
""
,
i
,
AV_DICT_IGNORE_SUFFIX
))
!=
NULL
)
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
i
->
key
,
i
->
value
);
}
#endif
void
ffmpeg_scan_dictionary
(
AVDictionary
*
dict
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
...
...
@@ -62,4 +77,9 @@ ffmpeg_scan_dictionary(AVDictionary *dict,
i
->
name
!=
NULL
;
++
i
)
ffmpeg_copy_metadata
(
i
->
type
,
dict
,
i
->
name
,
handler
,
handler_ctx
);
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
if
(
handler
->
pair
!=
NULL
)
ffmpeg_scan_pairs
(
dict
,
handler
,
handler_ctx
);
#endif
}
This diff is collapsed.
Click to expand it.
src/decoder/flac_metadata.c
View file @
ffea273a
...
...
@@ -196,6 +196,19 @@ flac_scan_comment(const char *char_tnum,
const
FLAC__StreamMetadata_VorbisComment_Entry
*
entry
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
if
(
handler
->
pair
!=
NULL
)
{
char
*
name
=
g_strdup
((
const
char
*
)
entry
->
entry
);
char
*
value
=
strchr
(
name
,
'='
);
if
(
value
!=
NULL
&&
value
>
name
)
{
*
value
++
=
0
;
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
name
,
value
);
}
g_free
(
name
);
}
for
(
const
struct
tag_table
*
i
=
flac_tags
;
i
->
name
!=
NULL
;
++
i
)
if
(
flac_copy_comment
(
entry
,
i
->
name
,
i
->
type
,
char_tnum
,
handler
,
handler_ctx
))
...
...
This diff is collapsed.
Click to expand it.
src/decoder/mp4ff_decoder_plugin.c
View file @
ffea273a
...
...
@@ -414,6 +414,8 @@ mp4ff_scan_stream(struct input_stream *is,
mp4ff_meta_get_by_index
(
mp4fh
,
i
,
&
item
,
&
value
);
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
item
,
value
);
enum
tag_type
type
=
mp4ff_tag_name_parse
(
item
);
if
(
type
!=
TAG_NUM_OF_ITEM_TYPES
)
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
...
...
This diff is collapsed.
Click to expand it.
src/decoder/vorbis_comments.c
View file @
ffea273a
...
...
@@ -106,6 +106,19 @@ static void
vorbis_scan_comment
(
const
char
*
comment
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
if
(
handler
->
pair
!=
NULL
)
{
char
*
name
=
g_strdup
((
const
char
*
)
comment
);
char
*
value
=
strchr
(
name
,
'='
);
if
(
value
!=
NULL
&&
value
>
name
)
{
*
value
++
=
0
;
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
name
,
value
);
}
g_free
(
name
);
}
for
(
const
struct
tag_table
*
i
=
vorbis_tags
;
i
->
name
!=
NULL
;
++
i
)
if
(
vorbis_copy_comment
(
comment
,
i
->
name
,
i
->
type
,
handler
,
handler_ctx
))
...
...
This diff is collapsed.
Click to expand it.
src/decoder/wavpack_decoder_plugin.c
View file @
ffea273a
...
...
@@ -286,6 +286,19 @@ wavpack_scan_tag_item(WavpackContext *wpc, const char *name,
}
static
void
wavpack_scan_pair
(
WavpackContext
*
wpc
,
const
char
*
name
,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
char
buffer
[
1024
];
int
len
=
WavpackGetTagItem
(
wpc
,
name
,
buffer
,
sizeof
(
buffer
));
if
(
len
<=
0
||
(
unsigned
)
len
>=
sizeof
(
buffer
))
return
;
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
name
,
buffer
);
}
/*
* Reads metainfo from the specified file.
*/
...
...
@@ -313,6 +326,20 @@ wavpack_scan_file(const char *fname,
wavpack_scan_tag_item
(
wpc
,
i
->
name
,
i
->
type
,
handler
,
handler_ctx
);
if
(
handler
->
pair
!=
NULL
)
{
char
name
[
64
];
for
(
int
i
=
0
,
n
=
WavpackGetNumTagItems
(
wpc
);
i
<
n
;
++
i
)
{
int
len
=
WavpackGetTagItemIndexed
(
wpc
,
i
,
name
,
sizeof
(
name
));
if
(
len
<=
0
||
(
unsigned
)
len
>=
sizeof
(
name
))
continue
;
wavpack_scan_pair
(
wpc
,
name
,
handler
,
handler_ctx
);
}
}
WavpackCloseFile
(
wpc
);
return
true
;
...
...
This diff is collapsed.
Click to expand it.
src/tag_ape.c
View file @
ffea273a
...
...
@@ -49,6 +49,8 @@ tag_ape_import_item(unsigned long flags,
if
((
flags
&
(
0x3
<<
1
))
!=
0
)
return
;
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
key
,
value
);
enum
tag_type
type
=
tag_ape_name_parse
(
key
);
if
(
type
==
TAG_NUM_OF_ITEM_TYPES
)
return
;
...
...
This diff is collapsed.
Click to expand it.
src/tag_handler.h
View file @
ffea273a
...
...
@@ -43,6 +43,12 @@ struct tag_handler {
* invalid after returning
*/
void
(
*
tag
)(
enum
tag_type
type
,
const
char
*
value
,
void
*
ctx
);
/**
* A name-value pair has been read. It is the codec specific
* representation of tags.
*/
void
(
*
pair
)(
const
char
*
key
,
const
char
*
value
,
void
*
ctx
);
};
static
inline
void
...
...
@@ -67,6 +73,18 @@ tag_handler_invoke_tag(const struct tag_handler *handler, void *ctx,
handler
->
tag
(
type
,
value
,
ctx
);
}
static
inline
void
tag_handler_invoke_pair
(
const
struct
tag_handler
*
handler
,
void
*
ctx
,
const
char
*
name
,
const
char
*
value
)
{
assert
(
handler
!=
NULL
);
assert
(
name
!=
NULL
);
assert
(
value
!=
NULL
);
if
(
handler
->
pair
!=
NULL
)
handler
->
pair
(
name
,
value
,
ctx
);
}
/**
* This #tag_handler implementation adds tag values to a #tag object
* (casted from the context pointer).
...
...
This diff is collapsed.
Click to expand it.
src/tag_id3.c
View file @
ffea273a
...
...
@@ -282,18 +282,21 @@ tag_id3_import_musicbrainz(struct id3_tag *id3_tag,
if
(
name
==
NULL
)
continue
;
type
=
tag_id3_parse_txxx_name
((
const
char
*
)
name
);
free
(
name
);
if
(
type
==
TAG_NUM_OF_ITEM_TYPES
)
continue
;
value
=
tag_id3_getstring
(
frame
,
2
);
if
(
value
==
NULL
)
continue
;
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
type
,
(
const
char
*
)
value
);
tag_handler_invoke_pair
(
handler
,
handler_ctx
,
(
const
char
*
)
name
,
(
const
char
*
)
value
);
type
=
tag_id3_parse_txxx_name
((
const
char
*
)
name
);
free
(
name
);
if
(
type
!=
TAG_NUM_OF_ITEM_TYPES
)
tag_handler_invoke_tag
(
handler
,
handler_ctx
,
type
,
(
const
char
*
)
value
);
free
(
value
);
}
}
...
...
This diff is collapsed.
Click to expand it.
test/read_tags.c
View file @
ffea273a
...
...
@@ -145,13 +145,20 @@ print_duration(unsigned seconds, G_GNUC_UNUSED void *ctx)
static
void
print_tag
(
enum
tag_type
type
,
const
char
*
value
,
G_GNUC_UNUSED
void
*
ctx
)
{
g_print
(
"
%s
=%s
\n
"
,
tag_item_names
[
type
],
value
);
g_print
(
"
[%s]
=%s
\n
"
,
tag_item_names
[
type
],
value
);
empty
=
false
;
}
static
void
print_pair
(
const
char
*
name
,
const
char
*
value
,
G_GNUC_UNUSED
void
*
ctx
)
{
g_print
(
"
\"
%s
\"
=%s
\n
"
,
name
,
value
);
}
static
const
struct
tag_handler
print_handler
=
{
.
duration
=
print_duration
,
.
tag
=
print_tag
,
.
pair
=
print_pair
,
};
int
main
(
int
argc
,
char
**
argv
)
...
...
This diff is collapsed.
Click to expand it.
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