Commit c46239af authored by Max Kellermann's avatar Max Kellermann

Merge branch 'v0.16.x'

Conflicts: src/decoder/ffmpeg_decoder_plugin.c test/read_tags.c test/run_decoder.c
parents ef5cf40f 48eb3ff8
...@@ -36,7 +36,8 @@ ver 0.16.7 (2011/??/??) ...@@ -36,7 +36,8 @@ ver 0.16.7 (2011/??/??)
* input: * input:
- ffmpeg: support libavformat 0.7 - ffmpeg: support libavformat 0.7
* decoder: * decoder:
- ffmpeg: support libavformat 0.8, libavcodec 0.8 - ffmpeg: support libavformat 0.8, libavcodec 0.9
- ffmpeg: support all MPD tags
* output: * output:
- httpd: fix excessive buffering - httpd: fix excessive buffering
- openal: force 16 bit playback, as 8 bit doesn't work - openal: force 16 bit playback, as 8 bit doesn't work
......
...@@ -359,10 +359,18 @@ static enum sample_format ...@@ -359,10 +359,18 @@ static enum sample_format
ffmpeg_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context) ffmpeg_sample_format(G_GNUC_UNUSED const AVCodecContext *codec_context)
{ {
switch (codec_context->sample_fmt) { switch (codec_context->sample_fmt) {
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
case AV_SAMPLE_FMT_S16:
#else
case SAMPLE_FMT_S16: case SAMPLE_FMT_S16:
#endif
return SAMPLE_FORMAT_S16; return SAMPLE_FORMAT_S16;
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
case AV_SAMPLE_FMT_S32:
#else
case SAMPLE_FMT_S32: case SAMPLE_FMT_S32:
#endif
return SAMPLE_FORMAT_S32; return SAMPLE_FORMAT_S32;
default: default:
...@@ -571,48 +579,44 @@ typedef struct ffmpeg_tag_map { ...@@ -571,48 +579,44 @@ typedef struct ffmpeg_tag_map {
} ffmpeg_tag_map; } ffmpeg_tag_map;
static const ffmpeg_tag_map ffmpeg_tag_maps[] = { static const ffmpeg_tag_map ffmpeg_tag_maps[] = {
{ TAG_TITLE, "title" }, #if LIBAVFORMAT_VERSION_INT < ((52<<16)+(50<<8))
#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(50<<8))
{ TAG_ARTIST, "artist" },
{ TAG_DATE, "date" },
#else
{ TAG_ARTIST, "author" }, { TAG_ARTIST, "author" },
{ TAG_DATE, "year" }, { TAG_DATE, "year" },
#endif #endif
{ TAG_ALBUM, "album" },
{ TAG_COMMENT, "comment" },
{ TAG_GENRE, "genre" },
{ TAG_TRACK, "track" },
{ TAG_ARTIST_SORT, "author-sort" }, { TAG_ARTIST_SORT, "author-sort" },
{ TAG_ALBUM_ARTIST, "album_artist" }, { TAG_ALBUM_ARTIST, "album_artist" },
{ TAG_ALBUM_ARTIST_SORT, "album_artist-sort" }, { TAG_ALBUM_ARTIST_SORT, "album_artist-sort" },
{ TAG_COMPOSER, "composer" },
{ TAG_PERFORMER, "performer" }, /* sentinel */
{ TAG_DISC, "disc" }, { TAG_NUM_OF_ITEM_TYPES, NULL }
}; };
static bool #if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0)
ffmpeg_copy_metadata(struct tag *tag, #define AVDictionary AVMetadata
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,1,0) #define AVDictionaryEntry AVMetadataTag
AVDictionary *m, #define av_dict_get av_metadata_get
#else
AVMetadata *m,
#endif #endif
const ffmpeg_tag_map tag_map)
static void
ffmpeg_copy_metadata(struct tag *tag, enum tag_type type,
AVDictionary *m, const char *name)
{ {
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
AVDictionaryEntry *mt = NULL; AVDictionaryEntry *mt = NULL;
while ((mt = av_dict_get(m, tag_map.name, mt, 0)) != NULL) while ((mt = av_dict_get(m, name, mt, 0)) != NULL)
tag_add_item(tag, tag_map.type, mt->value); tag_add_item(tag, type, mt->value);
#else }
AVMetadataTag *mt = NULL;
while ((mt = av_metadata_get(m, tag_map.name, mt, 0)) != NULL) static void
tag_add_item(tag, tag_map.type, mt->value); ffmpeg_copy_dictionary(struct tag *tag, AVDictionary *dict)
#endif {
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
ffmpeg_copy_metadata(tag, i,
dict, tag_item_names[i]);
return mt != NULL; for (const struct ffmpeg_tag_map *i = ffmpeg_tag_maps;
i->name != NULL; ++i)
ffmpeg_copy_metadata(tag, i->type, dict, i->name);
} }
//no tag reading in ffmpeg, check if playable //no tag reading in ffmpeg, check if playable
...@@ -660,12 +664,10 @@ ffmpeg_stream_tag(struct input_stream *is) ...@@ -660,12 +664,10 @@ ffmpeg_stream_tag(struct input_stream *is)
av_metadata_conv(f, NULL, f->iformat->metadata_conv); av_metadata_conv(f, NULL, f->iformat->metadata_conv);
#endif #endif
for (unsigned i = 0; i < sizeof(ffmpeg_tag_maps)/sizeof(ffmpeg_tag_map); i++) { ffmpeg_copy_dictionary(tag, f->metadata);
int idx = ffmpeg_find_audio_stream(f); int idx = ffmpeg_find_audio_stream(f);
ffmpeg_copy_metadata(tag, f->metadata, ffmpeg_tag_maps[i]); if (idx >= 0)
if (idx >= 0) ffmpeg_copy_dictionary(tag, f->streams[idx]->metadata);
ffmpeg_copy_metadata(tag, f->streams[idx]->metadata, ffmpeg_tag_maps[i]);
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0) #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&f); avformat_close_input(&f);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "io_thread.h" #include "io_thread.h"
#include "decoder_list.h" #include "decoder_list.h"
#include "decoder_api.h" #include "decoder_api.h"
#include "tag_pool.h"
#include "input_init.h" #include "input_init.h"
#include "input_stream.h" #include "input_stream.h"
#include "audio_format.h" #include "audio_format.h"
...@@ -190,6 +191,8 @@ int main(int argc, char **argv) ...@@ -190,6 +191,8 @@ int main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
tag_pool_init();
if (!input_stream_global_init(&error)) { if (!input_stream_global_init(&error)) {
g_warning("%s", error->message); g_warning("%s", error->message);
g_error_free(error); g_error_free(error);
...@@ -245,5 +248,7 @@ int main(int argc, char **argv) ...@@ -245,5 +248,7 @@ int main(int argc, char **argv)
return 1; return 1;
} }
tag_pool_deinit();
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment