Commit 1b441837 authored by Max Kellermann's avatar Max Kellermann

decoder/ffmpeg: append file name suffix to virtual stream URL

To allow libavformat to detect the format of the input file, append the suffix of the input file to the URL of the virtual stream. This specifically enables the "shorten" codec, which is supported by libavformat/raw.c, detected only by the suffix.
parent e43bf52c
......@@ -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
......
......@@ -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;
......
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