| 1 |
je_fro |
1.1 |
=== modified file 'src/metadata/ffmpeg_handler.cc'
|
| 2 |
|
|
--- old/src/metadata/ffmpeg_handler.cc 2010-08-25 17:07:03 +0000
|
| 3 |
|
|
+++ new/src/metadata/ffmpeg_handler.cc 2011-05-19 04:33:32 +0000
|
| 4 |
|
|
@@ -89,6 +89,33 @@
|
| 5 |
|
|
|
| 6 |
|
|
Ref<StringConverter> sc = StringConverter::m2i();
|
| 7 |
|
|
|
| 8 |
|
|
+ /* Tabs are 4 characters here */
|
| 9 |
|
|
+ typedef struct {const char *avname; metadata_fields_t field;} mapping_t;
|
| 10 |
|
|
+ static const mapping_t mapping[] =
|
| 11 |
|
|
+ {
|
| 12 |
|
|
+ {"title", M_TITLE},
|
| 13 |
|
|
+ {"artist", M_ARTIST},
|
| 14 |
|
|
+ {"album", M_ALBUM},
|
| 15 |
|
|
+ {"date", M_DATE},
|
| 16 |
|
|
+ {"genre", M_GENRE},
|
| 17 |
|
|
+ {"comment", M_DESCRIPTION},
|
| 18 |
|
|
+ {"track", M_TRACKNUMBER},
|
| 19 |
|
|
+ {NULL, M_MAX},
|
| 20 |
|
|
+ };
|
| 21 |
|
|
+
|
| 22 |
|
|
+ if (!pFormatCtx->metadata)
|
| 23 |
|
|
+ return;
|
| 24 |
|
|
+ for (const mapping_t *m = mapping; m->avname != NULL; m++)
|
| 25 |
|
|
+ {
|
| 26 |
|
|
+ AVMetadataTag *tag = NULL;
|
| 27 |
|
|
+ tag = av_metadata_get(pFormatCtx->metadata, m->avname, NULL, 0);
|
| 28 |
|
|
+ if (tag && tag->value && tag->value[0])
|
| 29 |
|
|
+ {
|
| 30 |
|
|
+ log_debug("Added metadata %s: %s\n", m->avname, tag->value);
|
| 31 |
|
|
+ item->setMetadata(MT_KEYS[m->field].upnp, sc->convert(tag->value));
|
| 32 |
|
|
+ }
|
| 33 |
|
|
+ }
|
| 34 |
|
|
+ /* Old algorithm (doesn't work with libav >= 0.7)
|
| 35 |
|
|
if (strlen(pFormatCtx->title) > 0)
|
| 36 |
|
|
{
|
| 37 |
|
|
log_debug("Added metadata title: %s\n", pFormatCtx->title);
|
| 38 |
|
|
@@ -131,6 +158,7 @@
|
| 39 |
|
|
item->setMetadata(MT_KEYS[M_TRACKNUMBER].upnp,
|
| 40 |
|
|
sc->convert(String::from(pFormatCtx->track)));
|
| 41 |
|
|
}
|
| 42 |
|
|
+ */
|
| 43 |
|
|
}
|
| 44 |
|
|
|
| 45 |
|
|
// ffmpeg library calls
|
| 46 |
|
|
@@ -178,7 +206,7 @@
|
| 47 |
|
|
for(i=0; i<pFormatCtx->nb_streams; i++)
|
| 48 |
|
|
{
|
| 49 |
|
|
AVStream *st = pFormatCtx->streams[i];
|
| 50 |
|
|
- if((st != NULL) && (videoset == false) && (st->codec->codec_type == CODEC_TYPE_VIDEO))
|
| 51 |
|
|
+ if((st != NULL) && (videoset == false) && (st->codec->codec_type == AVMEDIA_TYPE_VIDEO))
|
| 52 |
|
|
{
|
| 53 |
|
|
if (st->codec->codec_tag > 0)
|
| 54 |
|
|
{
|
| 55 |
|
|
@@ -209,7 +237,7 @@
|
| 56 |
|
|
*y = st->codec->height;
|
| 57 |
|
|
}
|
| 58 |
|
|
}
|
| 59 |
|
|
- if(st->codec->codec_type == CODEC_TYPE_AUDIO)
|
| 60 |
|
|
+ if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
|
| 61 |
|
|
{
|
| 62 |
|
|
// Increase number of audiochannels
|
| 63 |
|
|
audioch++;
|
| 64 |
|
|
|