aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/decoder/ffmpeg_plugin.c32
2 files changed, 29 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 70eeb3deb..f5dcecbd9 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ ver 0.15.8 (2009/??/??)
- curl: allow rewinding with Icy-Metadata
* decoders:
- ffmpeg, flac, vorbis: added more flac/vorbis MIME types
+ - ffmpeg: enabled libavformat's file name extension detection
* dbUtils: return empty tag value only if no value was found
* decoder_thread: fix CUE track playback
* queue: don't repeat current song in consume mode
diff --git a/src/decoder/ffmpeg_plugin.c b/src/decoder/ffmpeg_plugin.c
index d2bd642fd..0e15d99c1 100644
--- a/src/decoder/ffmpeg_plugin.c
+++ b/src/decoder/ffmpeg_plugin.c
@@ -55,7 +55,7 @@ struct ffmpeg_context {
struct ffmpeg_stream {
/** hack - see url_to_struct() */
- char url[8];
+ char url[64];
struct decoder *decoder;
struct input_stream *input;
@@ -140,8 +140,28 @@ ffmpeg_find_audio_stream(const AVFormatContext *format_context)
return -1;
}
+/**
+ * Append the suffix of the original URI to the virtual stream URI.
+ * Without this, libavformat cannot detect some of the codecs
+ * (e.g. "shorten").
+ */
+static void
+append_uri_suffix(struct ffmpeg_stream *stream, const char *uri)
+{
+ assert(stream != NULL);
+ assert(uri != NULL);
+
+ char *base = g_path_get_basename(uri);
+
+ const char *suffix = strrchr(base, '.');
+ if (suffix != NULL && suffix[1] != 0)
+ g_strlcat(stream->url, suffix, sizeof(stream->url));
+
+ g_free(base);
+}
+
static bool
-ffmpeg_helper(struct input_stream *input,
+ffmpeg_helper(const char *uri, struct input_stream *input,
bool (*callback)(struct ffmpeg_context *ctx),
struct ffmpeg_context *ctx)
{
@@ -154,6 +174,9 @@ ffmpeg_helper(struct input_stream *input,
};
bool ret;
+ if (uri != NULL)
+ append_uri_suffix(&stream, uri);
+
stream.input = input;
if (ctx && ctx->decoder) {
stream.decoder = ctx->decoder; //are we in decoding loop ?
@@ -349,7 +372,8 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
ctx.input = input;
ctx.decoder = decoder;
- ffmpeg_helper(input, ffmpeg_decode_internal, &ctx);
+ ffmpeg_helper(decoder_get_uri(decoder), input,
+ ffmpeg_decode_internal, &ctx);
}
#if LIBAVFORMAT_VERSION_INT >= ((52<<16)+(31<<8)+0)
@@ -426,7 +450,7 @@ static struct tag *ffmpeg_tag(const char *file)
ctx.decoder = NULL;
ctx.tag = tag_new();
- ret = ffmpeg_helper(&input, ffmpeg_tag_internal, &ctx);
+ ret = ffmpeg_helper(file, &input, ffmpeg_tag_internal, &ctx);
if (!ret) {
tag_free(ctx.tag);
ctx.tag = NULL;