--- src/metadata/ffmpeg_handler.cc.orig 2010-03-25 07:58:10.000000000 -0700
+++ src/metadata/ffmpeg_handler.cc 2013-01-10 16:04:04.000000000 -0800
Ref<StringConverter> sc = StringConverter::m2i();
+ /* Tabs are 4 characters here */
+ typedef struct {const char *avname; metadata_fields_t field;} mapping_t;
+ static const mapping_t mapping[] =
+ {"comment", M_DESCRIPTION},
+ {"track", M_TRACKNUMBER},
+ if (!pFormatCtx->metadata)
+ for (const mapping_t *m = mapping; m->avname != NULL; m++)
+ AVDictionaryEntry *tag = NULL;
+ tag = av_dict_get(pFormatCtx->metadata, m->avname, NULL, 0);
+ if (tag && tag->value && tag->value[0])
+ log_debug("Added metadata %s: %s\n", m->avname, tag->value);
+ item->setMetadata(MT_KEYS[m->field].upnp, sc->convert(tag->value));
+ /* Old algorithm (doesn't work with libav >= 0.7)
if (strlen(pFormatCtx->title) > 0)
log_debug("Added metadata title: %s\n", pFormatCtx->title);
item->setMetadata(MT_KEYS[M_TRACKNUMBER].upnp,
sc->convert(String::from(pFormatCtx->track)));
for(i=0; i<pFormatCtx->nb_streams; i++)
AVStream *st = pFormatCtx->streams[i];
- if((st != NULL) && (videoset == false) && (st->codec->codec_type == CODEC_TYPE_VIDEO))
+ if((st != NULL) && (videoset == false) && (st->codec->codec_type == AVMEDIA_TYPE_VIDEO))
if (st->codec->codec_tag > 0)
- if(st->codec->codec_type == CODEC_TYPE_AUDIO)
+ if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
// Increase number of audiochannels
- if (av_open_input_file(&pFormatCtx,
- item->getLocation().c_str(), NULL, 0, NULL) != 0)
+ if (avformat_open_input(&pFormatCtx,
+ item->getLocation().c_str(), NULL, NULL) != 0)
return; // Couldn't open file
// Retrieve stream information
- if (av_find_stream_info(pFormatCtx) < 0)
+ if (avformat_find_stream_info(pFormatCtx, NULL) < 0)
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
return; // Couldn't find stream information
// Add metadata using ffmpeg library calls
addFfmpegResourceFields(item, pFormatCtx, &x, &y);
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
Ref<IOHandler> FfmpegHandler::serveContent(Ref<CdsItem> item, int resNum, off_t *data_size)