2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2013-01-26 00:37:04 +01:00
|
|
|
* Copyright (C) 2003-2013 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2008-10-17 22:27:33 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-10-17 22:27:33 +02:00
|
|
|
*/
|
|
|
|
|
2013-01-26 00:37:04 +01:00
|
|
|
/* necessary because libavutil/common.h uses UINT64_C */
|
|
|
|
#define __STDC_CONSTANT_MACROS
|
|
|
|
|
2009-01-08 21:37:02 +01:00
|
|
|
#include "config.h"
|
2013-01-26 00:37:04 +01:00
|
|
|
#include "FfmpegDecoderPlugin.hxx"
|
2009-11-12 09:12:38 +01:00
|
|
|
#include "decoder_api.h"
|
2013-01-26 00:37:04 +01:00
|
|
|
#include "FfmpegMetaData.hxx"
|
2012-02-11 19:12:02 +01:00
|
|
|
#include "tag_handler.h"
|
2013-01-24 19:14:40 +01:00
|
|
|
#include "InputStream.hxx"
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2013-01-26 00:37:04 +01:00
|
|
|
extern "C" {
|
|
|
|
#include "audio_check.h"
|
|
|
|
}
|
|
|
|
|
2009-01-01 18:09:24 +01:00
|
|
|
#include <glib.h>
|
|
|
|
|
2008-10-30 19:03:38 +01:00
|
|
|
#include <assert.h>
|
2008-10-17 22:27:33 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2013-01-26 00:37:04 +01:00
|
|
|
extern "C" {
|
2008-10-21 08:34:19 +02:00
|
|
|
#include <libavcodec/avcodec.h>
|
|
|
|
#include <libavformat/avformat.h>
|
|
|
|
#include <libavformat/avio.h>
|
2012-01-12 18:45:18 +01:00
|
|
|
#include <libavutil/avutil.h>
|
2010-02-27 19:32:59 +01:00
|
|
|
#include <libavutil/log.h>
|
2012-01-04 21:54:54 +01:00
|
|
|
#include <libavutil/mathematics.h>
|
2012-01-12 18:45:18 +01:00
|
|
|
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
|
|
|
|
#include <libavutil/dict.h>
|
|
|
|
#endif
|
2013-01-26 00:37:04 +01:00
|
|
|
}
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2008-11-21 20:13:41 +01:00
|
|
|
#undef G_LOG_DOMAIN
|
|
|
|
#define G_LOG_DOMAIN "ffmpeg"
|
|
|
|
|
2010-02-27 19:32:59 +01:00
|
|
|
static GLogLevelFlags
|
|
|
|
level_ffmpeg_to_glib(int level)
|
|
|
|
{
|
|
|
|
if (level <= AV_LOG_FATAL)
|
|
|
|
return G_LOG_LEVEL_CRITICAL;
|
|
|
|
|
|
|
|
if (level <= AV_LOG_ERROR)
|
|
|
|
return G_LOG_LEVEL_WARNING;
|
|
|
|
|
|
|
|
if (level <= AV_LOG_INFO)
|
|
|
|
return G_LOG_LEVEL_MESSAGE;
|
|
|
|
|
|
|
|
return G_LOG_LEVEL_DEBUG;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mpd_ffmpeg_log_callback(G_GNUC_UNUSED void *ptr, int level,
|
|
|
|
const char *fmt, va_list vl)
|
|
|
|
{
|
2010-04-11 19:18:30 +02:00
|
|
|
const AVClass * cls = NULL;
|
2010-03-28 19:48:57 +02:00
|
|
|
|
2010-04-11 19:18:30 +02:00
|
|
|
if (ptr != NULL)
|
|
|
|
cls = *(const AVClass *const*)ptr;
|
|
|
|
|
|
|
|
if (cls != NULL) {
|
|
|
|
char *domain = g_strconcat(G_LOG_DOMAIN, "/", cls->item_name(ptr), NULL);
|
|
|
|
g_logv(domain, level_ffmpeg_to_glib(level), fmt, vl);
|
|
|
|
g_free(domain);
|
|
|
|
}
|
2010-02-27 19:32:59 +01:00
|
|
|
}
|
|
|
|
|
2010-06-30 08:59:31 +02:00
|
|
|
struct mpd_ffmpeg_stream {
|
2008-10-17 22:27:33 +02:00
|
|
|
struct decoder *decoder;
|
2008-10-26 19:54:57 +01:00
|
|
|
struct input_stream *input;
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2011-05-09 21:16:43 +02:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
|
|
|
|
AVIOContext *io;
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
ByteIOContext *io;
|
2011-05-09 21:16:43 +02:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
unsigned char buffer[8192];
|
|
|
|
};
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2010-06-30 08:59:31 +02:00
|
|
|
static int
|
|
|
|
mpd_ffmpeg_stream_read(void *opaque, uint8_t *buf, int size)
|
2008-10-17 22:27:33 +02:00
|
|
|
{
|
2013-01-26 00:37:04 +01:00
|
|
|
struct mpd_ffmpeg_stream *stream = (struct mpd_ffmpeg_stream *)opaque;
|
2008-10-30 19:02:01 +01:00
|
|
|
|
2008-11-04 16:55:12 +01:00
|
|
|
return decoder_read(stream->decoder, stream->input,
|
|
|
|
(void *)buf, size);
|
2008-10-17 22:27:33 +02:00
|
|
|
}
|
|
|
|
|
2010-06-30 08:59:31 +02:00
|
|
|
static int64_t
|
|
|
|
mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
|
2008-10-17 22:27:33 +02:00
|
|
|
{
|
2013-01-26 00:37:04 +01:00
|
|
|
struct mpd_ffmpeg_stream *stream = (struct mpd_ffmpeg_stream *)opaque;
|
2008-11-16 20:25:31 +01:00
|
|
|
|
|
|
|
if (whence == AVSEEK_SIZE)
|
|
|
|
return stream->input->size;
|
|
|
|
|
2011-09-14 21:46:41 +02:00
|
|
|
if (!input_stream_lock_seek(stream->input, pos, whence, NULL))
|
2008-11-16 20:25:31 +01:00
|
|
|
return -1;
|
|
|
|
|
2008-11-04 16:55:11 +01:00
|
|
|
return stream->input->offset;
|
2008-10-17 22:27:33 +02:00
|
|
|
}
|
|
|
|
|
2010-06-30 08:59:31 +02:00
|
|
|
static struct mpd_ffmpeg_stream *
|
|
|
|
mpd_ffmpeg_stream_open(struct decoder *decoder, struct input_stream *input)
|
2008-10-17 22:27:33 +02:00
|
|
|
{
|
2010-06-30 08:59:31 +02:00
|
|
|
struct mpd_ffmpeg_stream *stream = g_new(struct mpd_ffmpeg_stream, 1);
|
|
|
|
stream->decoder = decoder;
|
|
|
|
stream->input = input;
|
2011-05-09 21:16:43 +02:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
|
|
|
|
stream->io = avio_alloc_context(stream->buffer, sizeof(stream->buffer),
|
|
|
|
false, stream,
|
|
|
|
mpd_ffmpeg_stream_read, NULL,
|
|
|
|
input->seekable
|
|
|
|
? mpd_ffmpeg_stream_seek : NULL);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
stream->io = av_alloc_put_byte(stream->buffer, sizeof(stream->buffer),
|
|
|
|
false, stream,
|
|
|
|
mpd_ffmpeg_stream_read, NULL,
|
|
|
|
input->seekable
|
|
|
|
? mpd_ffmpeg_stream_seek : NULL);
|
2011-05-09 21:16:43 +02:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
if (stream->io == NULL) {
|
|
|
|
g_free(stream);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return stream;
|
2008-10-17 22:27:33 +02:00
|
|
|
}
|
|
|
|
|
2011-07-18 23:31:47 +02:00
|
|
|
/**
|
|
|
|
* API compatibility wrapper for av_open_input_stream() and
|
|
|
|
* avformat_open_input().
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mpd_ffmpeg_open_input(AVFormatContext **ic_ptr,
|
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52,101,0)
|
|
|
|
AVIOContext *pb,
|
|
|
|
#else
|
|
|
|
ByteIOContext *pb,
|
|
|
|
#endif
|
|
|
|
const char *filename,
|
|
|
|
AVInputFormat *fmt)
|
|
|
|
{
|
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,1,3)
|
|
|
|
AVFormatContext *context = avformat_alloc_context();
|
|
|
|
if (context == NULL)
|
|
|
|
return AVERROR(ENOMEM);
|
|
|
|
|
|
|
|
context->pb = pb;
|
|
|
|
*ic_ptr = context;
|
|
|
|
return avformat_open_input(ic_ptr, filename, fmt, NULL);
|
|
|
|
#else
|
|
|
|
return av_open_input_stream(ic_ptr, pb, filename, fmt, NULL);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-06-30 08:59:31 +02:00
|
|
|
static void
|
|
|
|
mpd_ffmpeg_stream_close(struct mpd_ffmpeg_stream *stream)
|
|
|
|
{
|
|
|
|
av_free(stream->io);
|
|
|
|
g_free(stream);
|
|
|
|
}
|
2008-10-18 08:08:13 +02:00
|
|
|
|
2009-02-15 18:34:14 +01:00
|
|
|
static bool
|
|
|
|
ffmpeg_init(G_GNUC_UNUSED const struct config_param *param)
|
2008-10-17 22:27:33 +02:00
|
|
|
{
|
2010-02-27 19:32:59 +01:00
|
|
|
av_log_set_callback(mpd_ffmpeg_log_callback);
|
|
|
|
|
2008-10-17 22:27:33 +02:00
|
|
|
av_register_all();
|
2008-10-30 08:38:54 +01:00
|
|
|
return true;
|
2008-10-17 22:27:33 +02:00
|
|
|
}
|
|
|
|
|
2008-11-04 16:55:12 +01:00
|
|
|
static int
|
|
|
|
ffmpeg_find_audio_stream(const AVFormatContext *format_context)
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < format_context->nb_streams; ++i)
|
|
|
|
if (format_context->streams[i]->codec->codec_type ==
|
2011-05-02 20:53:15 +02:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 64, 0)
|
|
|
|
AVMEDIA_TYPE_AUDIO)
|
|
|
|
#else
|
2008-11-04 16:55:12 +01:00
|
|
|
CODEC_TYPE_AUDIO)
|
2011-05-02 20:53:15 +02:00
|
|
|
#endif
|
2008-11-04 16:55:12 +01:00
|
|
|
return i;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-01-04 22:10:38 +01:00
|
|
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,25,0)
|
2009-11-15 17:39:09 +01:00
|
|
|
/**
|
|
|
|
* On some platforms, libavcodec wants the output buffer aligned to 16
|
|
|
|
* bytes (because it uses SSE/Altivec internally). This function
|
|
|
|
* returns the aligned version of the specified buffer, and corrects
|
|
|
|
* the buffer size.
|
|
|
|
*/
|
|
|
|
static void *
|
|
|
|
align16(void *p, size_t *length_p)
|
|
|
|
{
|
|
|
|
unsigned add = 16 - (size_t)p % 16;
|
|
|
|
|
|
|
|
*length_p -= add;
|
|
|
|
return (char *)p + add;
|
|
|
|
}
|
2012-01-04 22:10:38 +01:00
|
|
|
#endif
|
2009-11-15 17:39:09 +01:00
|
|
|
|
2011-09-15 21:03:03 +02:00
|
|
|
G_GNUC_CONST
|
|
|
|
static double
|
|
|
|
time_from_ffmpeg(int64_t t, const AVRational time_base)
|
|
|
|
{
|
|
|
|
assert(t != (int64_t)AV_NOPTS_VALUE);
|
|
|
|
|
2011-09-15 21:07:32 +02:00
|
|
|
return (double)av_rescale_q(t, time_base, (AVRational){1, 1024})
|
|
|
|
/ (double)1024;
|
2011-09-15 21:03:03 +02:00
|
|
|
}
|
|
|
|
|
2011-09-15 21:12:53 +02:00
|
|
|
G_GNUC_CONST
|
|
|
|
static int64_t
|
|
|
|
time_to_ffmpeg(double t, const AVRational time_base)
|
|
|
|
{
|
|
|
|
return av_rescale_q((int64_t)(t * 1024), (AVRational){1, 1024},
|
|
|
|
time_base);
|
|
|
|
}
|
|
|
|
|
2012-01-04 22:10:38 +01:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
|
2012-10-05 16:29:40 +02:00
|
|
|
|
|
|
|
static void
|
2012-10-05 16:38:41 +02:00
|
|
|
copy_interleave_frame2(uint8_t *dest, uint8_t **src,
|
|
|
|
unsigned nframes, unsigned nchannels,
|
|
|
|
unsigned sample_size)
|
2012-10-05 16:29:40 +02:00
|
|
|
{
|
2012-10-05 16:38:41 +02:00
|
|
|
for (unsigned frame = 0; frame < nframes; ++frame) {
|
|
|
|
for (unsigned channel = 0; channel < nchannels; ++channel) {
|
|
|
|
memcpy(dest, src[channel] + frame * sample_size,
|
|
|
|
sample_size);
|
|
|
|
dest += sample_size;
|
|
|
|
}
|
2012-10-05 16:29:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-04 22:10:38 +01:00
|
|
|
/**
|
|
|
|
* Copy PCM data from a AVFrame to an interleaved buffer.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
copy_interleave_frame(const AVCodecContext *codec_context,
|
|
|
|
const AVFrame *frame,
|
|
|
|
uint8_t *buffer, size_t buffer_size)
|
|
|
|
{
|
|
|
|
int plane_size;
|
|
|
|
const int data_size =
|
|
|
|
av_samples_get_buffer_size(&plane_size,
|
|
|
|
codec_context->channels,
|
|
|
|
frame->nb_samples,
|
|
|
|
codec_context->sample_fmt, 1);
|
|
|
|
if (buffer_size < (size_t)data_size)
|
|
|
|
/* buffer is too small - shouldn't happen */
|
|
|
|
return AVERROR(EINVAL);
|
|
|
|
|
|
|
|
if (av_sample_fmt_is_planar(codec_context->sample_fmt) &&
|
|
|
|
codec_context->channels > 1) {
|
2012-10-05 16:38:41 +02:00
|
|
|
copy_interleave_frame2(buffer, frame->extended_data,
|
|
|
|
frame->nb_samples,
|
|
|
|
codec_context->channels,
|
|
|
|
av_get_bytes_per_sample(codec_context->sample_fmt));
|
2012-01-04 22:10:38 +01:00
|
|
|
} else {
|
|
|
|
memcpy(buffer, frame->extended_data[0], data_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
return data_size;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-10-30 19:03:41 +01:00
|
|
|
static enum decoder_command
|
2008-10-30 19:09:20 +01:00
|
|
|
ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
|
|
|
|
const AVPacket *packet,
|
2008-10-30 19:03:20 +01:00
|
|
|
AVCodecContext *codec_context,
|
|
|
|
const AVRational *time_base)
|
|
|
|
{
|
2012-10-05 16:35:45 +02:00
|
|
|
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE)
|
2010-01-18 13:11:04 +01:00
|
|
|
decoder_timestamp(decoder,
|
2011-09-15 21:03:03 +02:00
|
|
|
time_from_ffmpeg(packet->pts, *time_base));
|
2010-01-18 13:11:04 +01:00
|
|
|
|
2011-04-12 08:16:57 +02:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
|
|
|
|
AVPacket packet2 = *packet;
|
|
|
|
#else
|
2011-04-12 08:17:30 +02:00
|
|
|
const uint8_t *packet_data = packet->data;
|
|
|
|
int packet_size = packet->size;
|
2011-04-12 08:16:57 +02:00
|
|
|
#endif
|
2008-12-15 18:35:34 +01:00
|
|
|
|
2012-01-04 22:10:38 +01:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
|
|
|
|
uint8_t aligned_buffer[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
|
|
|
|
const size_t buffer_size = sizeof(aligned_buffer);
|
|
|
|
#else
|
|
|
|
/* libavcodec < 0.8 needs an aligned buffer */
|
2011-04-12 08:17:30 +02:00
|
|
|
uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
|
|
|
|
size_t buffer_size = sizeof(audio_buf);
|
2013-01-26 00:37:04 +01:00
|
|
|
int16_t *aligned_buffer = (int16_t *)align16(audio_buf, &buffer_size);
|
2012-01-04 22:10:38 +01:00
|
|
|
#endif
|
2009-11-15 17:39:09 +01:00
|
|
|
|
2011-04-12 08:17:30 +02:00
|
|
|
enum decoder_command cmd = DECODE_COMMAND_NONE;
|
2011-04-12 08:16:57 +02:00
|
|
|
while (
|
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
|
|
|
|
packet2.size > 0 &&
|
|
|
|
#else
|
|
|
|
packet_size > 0 &&
|
|
|
|
#endif
|
|
|
|
cmd == DECODE_COMMAND_NONE) {
|
2011-04-12 08:17:30 +02:00
|
|
|
int audio_size = buffer_size;
|
2012-01-04 22:10:38 +01:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0)
|
|
|
|
AVFrame frame;
|
|
|
|
int got_frame = 0;
|
|
|
|
int len = avcodec_decode_audio4(codec_context,
|
|
|
|
&frame, &got_frame,
|
|
|
|
&packet2);
|
|
|
|
if (len >= 0 && got_frame) {
|
|
|
|
audio_size = copy_interleave_frame(codec_context,
|
|
|
|
&frame,
|
|
|
|
aligned_buffer,
|
|
|
|
buffer_size);
|
|
|
|
if (audio_size < 0)
|
|
|
|
len = audio_size;
|
|
|
|
} else if (len >= 0)
|
|
|
|
len = -1;
|
|
|
|
#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
|
2011-04-12 08:16:57 +02:00
|
|
|
int len = avcodec_decode_audio3(codec_context,
|
|
|
|
aligned_buffer, &audio_size,
|
|
|
|
&packet2);
|
|
|
|
#else
|
2011-04-12 08:17:30 +02:00
|
|
|
int len = avcodec_decode_audio2(codec_context,
|
|
|
|
aligned_buffer, &audio_size,
|
|
|
|
packet_data, packet_size);
|
2011-04-12 08:16:57 +02:00
|
|
|
#endif
|
2008-12-15 18:35:34 +01:00
|
|
|
|
|
|
|
if (len < 0) {
|
|
|
|
/* if error, we skip the frame */
|
2012-05-22 23:40:43 +02:00
|
|
|
g_message("decoding failed, frame skipped\n");
|
2008-12-15 18:35:34 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-04-12 08:16:57 +02:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52,25,0)
|
|
|
|
packet2.data += len;
|
|
|
|
packet2.size -= len;
|
|
|
|
#else
|
2008-12-15 18:35:34 +01:00
|
|
|
packet_data += len;
|
|
|
|
packet_size -= len;
|
2011-04-12 08:16:57 +02:00
|
|
|
#endif
|
2008-12-15 18:35:34 +01:00
|
|
|
|
2009-02-03 21:44:14 +01:00
|
|
|
if (audio_size <= 0)
|
2008-12-15 18:35:34 +01:00
|
|
|
continue;
|
2009-02-03 21:44:14 +01:00
|
|
|
|
2008-12-15 18:35:34 +01:00
|
|
|
cmd = decoder_data(decoder, is,
|
2009-11-15 17:39:09 +01:00
|
|
|
aligned_buffer, audio_size,
|
2010-01-03 22:44:23 +01:00
|
|
|
codec_context->bit_rate / 1000);
|
2008-10-30 19:03:20 +01:00
|
|
|
}
|
2008-12-15 18:35:34 +01:00
|
|
|
return cmd;
|
2008-10-30 19:03:20 +01:00
|
|
|
}
|
|
|
|
|
2012-10-05 15:14:57 +02:00
|
|
|
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(52, 94, 1)
|
|
|
|
#define AVSampleFormat SampleFormat
|
|
|
|
#endif
|
|
|
|
|
|
|
|
G_GNUC_CONST
|
2009-11-10 17:11:34 +01:00
|
|
|
static enum sample_format
|
2012-10-05 15:14:57 +02:00
|
|
|
ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
|
2009-11-10 17:11:34 +01:00
|
|
|
{
|
2012-10-05 15:14:57 +02:00
|
|
|
switch (sample_fmt) {
|
2012-02-03 09:55:25 +01:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
|
|
|
|
case AV_SAMPLE_FMT_S16:
|
2012-10-05 15:27:04 +02:00
|
|
|
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
|
|
|
|
case AV_SAMPLE_FMT_S16P:
|
|
|
|
#endif
|
2012-02-03 09:55:25 +01:00
|
|
|
#else
|
2010-11-04 20:04:15 +01:00
|
|
|
case SAMPLE_FMT_S16:
|
2012-02-03 09:55:25 +01:00
|
|
|
#endif
|
2010-11-04 20:04:15 +01:00
|
|
|
return SAMPLE_FORMAT_S16;
|
2009-11-10 17:11:34 +01:00
|
|
|
|
2012-02-03 09:55:25 +01:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
|
|
|
|
case AV_SAMPLE_FMT_S32:
|
2012-10-05 15:27:04 +02:00
|
|
|
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
|
|
|
|
case AV_SAMPLE_FMT_S32P:
|
|
|
|
#endif
|
2012-02-03 09:55:25 +01:00
|
|
|
#else
|
2010-11-04 20:04:15 +01:00
|
|
|
case SAMPLE_FMT_S32:
|
2012-02-03 09:55:25 +01:00
|
|
|
#endif
|
2010-11-04 20:04:15 +01:00
|
|
|
return SAMPLE_FORMAT_S32;
|
2009-11-10 17:11:34 +01:00
|
|
|
|
2013-01-16 18:02:58 +01:00
|
|
|
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,17,0)
|
|
|
|
case AV_SAMPLE_FMT_FLTP:
|
|
|
|
return SAMPLE_FORMAT_FLOAT;
|
|
|
|
#endif
|
|
|
|
|
2010-11-04 20:04:15 +01:00
|
|
|
default:
|
2012-10-05 14:55:19 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(52, 94, 1)
|
|
|
|
char buffer[64];
|
|
|
|
const char *name = av_get_sample_fmt_string(buffer, sizeof(buffer),
|
|
|
|
sample_fmt);
|
|
|
|
if (name != NULL)
|
|
|
|
g_warning("Unsupported libavcodec SampleFormat value: %s (%d)",
|
|
|
|
name, sample_fmt);
|
|
|
|
else
|
|
|
|
#endif
|
2010-11-04 20:04:15 +01:00
|
|
|
g_warning("Unsupported libavcodec SampleFormat value: %d",
|
2012-10-05 15:14:57 +02:00
|
|
|
sample_fmt);
|
2012-10-05 14:55:19 +02:00
|
|
|
return SAMPLE_FORMAT_UNDEFINED;
|
2009-11-10 17:11:34 +01:00
|
|
|
}
|
|
|
|
|
2010-06-30 20:32:29 +02:00
|
|
|
static AVInputFormat *
|
|
|
|
ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
|
|
|
|
{
|
|
|
|
enum {
|
|
|
|
BUFFER_SIZE = 16384,
|
|
|
|
PADDING = 16,
|
|
|
|
};
|
|
|
|
|
2013-01-26 00:37:04 +01:00
|
|
|
unsigned char *buffer = (unsigned char *)g_malloc(BUFFER_SIZE);
|
2010-06-30 20:32:29 +02:00
|
|
|
size_t nbytes = decoder_read(decoder, is, buffer, BUFFER_SIZE);
|
2011-09-14 21:46:41 +02:00
|
|
|
if (nbytes <= PADDING ||
|
|
|
|
!input_stream_lock_seek(is, 0, SEEK_SET, NULL)) {
|
2010-06-30 20:32:29 +02:00
|
|
|
g_free(buffer);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* some ffmpeg parsers (e.g. ac3_parser.c) read a few bytes
|
|
|
|
beyond the declared buffer limit, which makes valgrind
|
|
|
|
angry; this workaround removes some padding from the buffer
|
|
|
|
size */
|
|
|
|
nbytes -= PADDING;
|
|
|
|
|
2013-01-26 00:37:04 +01:00
|
|
|
AVProbeData avpd;
|
|
|
|
avpd.buf = buffer;
|
|
|
|
avpd.buf_size = nbytes;
|
|
|
|
avpd.filename = is->uri;
|
2010-06-30 20:32:29 +02:00
|
|
|
|
|
|
|
AVInputFormat *format = av_probe_input_format(&avpd, true);
|
|
|
|
g_free(buffer);
|
|
|
|
|
|
|
|
return format;
|
|
|
|
}
|
|
|
|
|
2010-01-18 10:59:11 +01:00
|
|
|
static void
|
|
|
|
ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
|
2008-10-17 22:27:33 +02:00
|
|
|
{
|
2010-06-30 20:32:29 +02:00
|
|
|
AVInputFormat *input_format = ffmpeg_probe(decoder, input);
|
|
|
|
if (input_format == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_debug("detected input format '%s' (%s)",
|
|
|
|
input_format->name, input_format->long_name);
|
|
|
|
|
2010-06-30 08:59:31 +02:00
|
|
|
struct mpd_ffmpeg_stream *stream =
|
|
|
|
mpd_ffmpeg_stream_open(decoder, input);
|
|
|
|
if (stream == NULL) {
|
|
|
|
g_warning("Failed to open stream");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-18 10:59:11 +01:00
|
|
|
//ffmpeg works with ours "fileops" helper
|
2011-07-03 14:54:56 +02:00
|
|
|
AVFormatContext *format_context = NULL;
|
2011-07-18 23:31:47 +02:00
|
|
|
if (mpd_ffmpeg_open_input(&format_context, stream->io, input->uri,
|
|
|
|
input_format) != 0) {
|
2010-01-18 10:59:11 +01:00
|
|
|
g_warning("Open failed\n");
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2010-01-18 10:59:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-01-12 18:28:19 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,6,0)
|
2012-01-05 00:02:46 +01:00
|
|
|
const int find_result =
|
|
|
|
avformat_find_stream_info(format_context, NULL);
|
|
|
|
#else
|
|
|
|
const int find_result = av_find_stream_info(format_context);
|
|
|
|
#endif
|
|
|
|
if (find_result < 0) {
|
2010-01-18 10:59:11 +01:00
|
|
|
g_warning("Couldn't find stream info\n");
|
2012-01-05 00:02:46 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&format_context);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
av_close_input_stream(format_context);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2010-01-18 10:59:11 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2011-04-12 08:17:30 +02:00
|
|
|
int audio_stream = ffmpeg_find_audio_stream(format_context);
|
2010-01-18 10:59:11 +01:00
|
|
|
if (audio_stream == -1) {
|
|
|
|
g_warning("No audio stream inside\n");
|
2012-01-05 00:02:46 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&format_context);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
av_close_input_stream(format_context);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2010-01-18 10:59:11 +01:00
|
|
|
return;
|
|
|
|
}
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2011-09-15 21:14:53 +02:00
|
|
|
AVStream *av_stream = format_context->streams[audio_stream];
|
|
|
|
|
|
|
|
AVCodecContext *codec_context = av_stream->codec;
|
2010-01-18 10:59:11 +01:00
|
|
|
if (codec_context->codec_name[0] != 0)
|
|
|
|
g_debug("codec '%s'", codec_context->codec_name);
|
|
|
|
|
2011-04-12 08:17:30 +02:00
|
|
|
AVCodec *codec = avcodec_find_decoder(codec_context->codec_id);
|
2010-01-18 10:59:11 +01:00
|
|
|
|
|
|
|
if (!codec) {
|
|
|
|
g_warning("Unsupported audio codec\n");
|
2012-01-05 00:02:46 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&format_context);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
av_close_input_stream(format_context);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2010-01-18 10:59:11 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-05 14:52:30 +02:00
|
|
|
const enum sample_format sample_format =
|
2012-10-05 15:14:57 +02:00
|
|
|
ffmpeg_sample_format(codec_context->sample_fmt);
|
2012-10-05 14:52:30 +02:00
|
|
|
if (sample_format == SAMPLE_FORMAT_UNDEFINED)
|
|
|
|
return;
|
|
|
|
|
2010-01-18 10:59:11 +01:00
|
|
|
GError *error = NULL;
|
|
|
|
struct audio_format audio_format;
|
2009-11-10 19:01:38 +01:00
|
|
|
if (!audio_format_init_checked(&audio_format,
|
2009-11-10 17:11:34 +01:00
|
|
|
codec_context->sample_rate,
|
2012-10-05 14:52:30 +02:00
|
|
|
sample_format,
|
2009-11-10 19:01:38 +01:00
|
|
|
codec_context->channels, &error)) {
|
|
|
|
g_warning("%s", error->message);
|
|
|
|
g_error_free(error);
|
2012-01-05 00:02:46 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&format_context);
|
|
|
|
#else
|
2011-11-27 23:39:21 +01:00
|
|
|
av_close_input_stream(format_context);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2011-11-27 23:39:21 +01:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the audio format must be read from AVCodecContext by now,
|
|
|
|
because avcodec_open() has been demonstrated to fill bogus
|
|
|
|
values into AVCodecContext.channels - a change that will be
|
|
|
|
reverted later by avcodec_decode_audio3() */
|
|
|
|
|
2012-01-04 21:41:28 +01:00
|
|
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,6,0)
|
|
|
|
const int open_result = avcodec_open2(codec_context, codec, NULL);
|
|
|
|
#else
|
|
|
|
const int open_result = avcodec_open(codec_context, codec);
|
|
|
|
#endif
|
|
|
|
if (open_result < 0) {
|
2011-11-27 23:39:21 +01:00
|
|
|
g_warning("Could not open codec\n");
|
2012-01-05 00:02:46 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&format_context);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
av_close_input_stream(format_context);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2010-01-18 10:59:11 +01:00
|
|
|
return;
|
2008-11-21 20:27:30 +01:00
|
|
|
}
|
|
|
|
|
2010-01-18 10:59:11 +01:00
|
|
|
int total_time = format_context->duration != (int64_t)AV_NOPTS_VALUE
|
|
|
|
? format_context->duration / AV_TIME_BASE
|
|
|
|
: 0;
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2008-11-02 17:01:51 +01:00
|
|
|
decoder_initialized(decoder, &audio_format,
|
2010-01-18 10:59:11 +01:00
|
|
|
input->seekable, total_time);
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2010-01-18 10:59:11 +01:00
|
|
|
enum decoder_command cmd;
|
2008-10-17 22:27:33 +02:00
|
|
|
do {
|
2010-01-18 10:59:11 +01:00
|
|
|
AVPacket packet;
|
2008-11-04 16:55:11 +01:00
|
|
|
if (av_read_frame(format_context, &packet) < 0)
|
2008-10-30 19:03:41 +01:00
|
|
|
/* end of file */
|
|
|
|
break;
|
|
|
|
|
2010-01-18 10:59:11 +01:00
|
|
|
if (packet.stream_index == audio_stream)
|
|
|
|
cmd = ffmpeg_send_packet(decoder, input,
|
2008-11-04 16:55:11 +01:00
|
|
|
&packet, codec_context,
|
2011-09-15 21:14:53 +02:00
|
|
|
&av_stream->time_base);
|
2008-10-30 19:03:41 +01:00
|
|
|
else
|
|
|
|
cmd = decoder_get_command(decoder);
|
|
|
|
|
|
|
|
av_free_packet(&packet);
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2008-10-30 19:03:41 +01:00
|
|
|
if (cmd == DECODE_COMMAND_SEEK) {
|
2009-02-03 22:46:00 +01:00
|
|
|
int64_t where =
|
2011-09-15 21:12:53 +02:00
|
|
|
time_to_ffmpeg(decoder_seek_where(decoder),
|
|
|
|
av_stream->time_base);
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2011-09-15 21:12:53 +02:00
|
|
|
if (av_seek_frame(format_context, audio_stream, where,
|
2011-09-15 21:32:29 +02:00
|
|
|
AV_TIME_BASE) < 0)
|
2008-10-30 19:02:38 +01:00
|
|
|
decoder_seek_error(decoder);
|
2011-09-15 21:41:25 +02:00
|
|
|
else {
|
|
|
|
avcodec_flush_buffers(codec_context);
|
2008-10-30 19:02:38 +01:00
|
|
|
decoder_command_finished(decoder);
|
2011-09-15 21:41:25 +02:00
|
|
|
}
|
2008-10-17 22:27:33 +02:00
|
|
|
}
|
2008-10-30 19:03:41 +01:00
|
|
|
} while (cmd != DECODE_COMMAND_STOP);
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2010-01-18 10:59:11 +01:00
|
|
|
avcodec_close(codec_context);
|
2012-01-05 00:02:46 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&format_context);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
av_close_input_stream(format_context);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2008-10-17 22:27:33 +02:00
|
|
|
}
|
|
|
|
|
2010-01-18 10:57:57 +01:00
|
|
|
//no tag reading in ffmpeg, check if playable
|
2012-02-11 19:12:02 +01:00
|
|
|
static bool
|
|
|
|
ffmpeg_scan_stream(struct input_stream *is,
|
|
|
|
const struct tag_handler *handler, void *handler_ctx)
|
2008-10-17 22:27:33 +02:00
|
|
|
{
|
2010-06-30 20:32:29 +02:00
|
|
|
AVInputFormat *input_format = ffmpeg_probe(NULL, is);
|
|
|
|
if (input_format == NULL)
|
2012-02-11 19:12:02 +01:00
|
|
|
return false;
|
2010-06-30 20:32:29 +02:00
|
|
|
|
2010-06-30 08:59:31 +02:00
|
|
|
struct mpd_ffmpeg_stream *stream = mpd_ffmpeg_stream_open(NULL, is);
|
|
|
|
if (stream == NULL)
|
2012-02-11 19:12:02 +01:00
|
|
|
return false;
|
2010-01-18 10:57:57 +01:00
|
|
|
|
2011-07-03 14:54:56 +02:00
|
|
|
AVFormatContext *f = NULL;
|
2011-07-18 23:31:47 +02:00
|
|
|
if (mpd_ffmpeg_open_input(&f, stream->io, is->uri,
|
|
|
|
input_format) != 0) {
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2012-02-11 19:12:02 +01:00
|
|
|
return false;
|
2010-06-30 08:59:31 +02:00
|
|
|
}
|
2010-01-18 10:57:57 +01:00
|
|
|
|
2012-01-12 18:28:19 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,6,0)
|
2012-01-05 00:02:46 +01:00
|
|
|
const int find_result =
|
|
|
|
avformat_find_stream_info(f, NULL);
|
|
|
|
#else
|
|
|
|
const int find_result = av_find_stream_info(f);
|
|
|
|
#endif
|
|
|
|
if (find_result < 0) {
|
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&f);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
av_close_input_stream(f);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2012-02-11 19:12:02 +01:00
|
|
|
return false;
|
2010-01-18 10:57:57 +01:00
|
|
|
}
|
|
|
|
|
2012-02-11 19:12:02 +01:00
|
|
|
if (f->duration != (int64_t)AV_NOPTS_VALUE)
|
|
|
|
tag_handler_invoke_duration(handler, handler_ctx,
|
|
|
|
f->duration / AV_TIME_BASE);
|
2009-03-03 18:58:54 +01:00
|
|
|
|
2011-05-09 21:17:09 +02:00
|
|
|
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52,101,0)
|
2009-08-03 17:40:22 +02:00
|
|
|
av_metadata_conv(f, NULL, f->iformat->metadata_conv);
|
2011-05-09 21:17:09 +02:00
|
|
|
#endif
|
2009-08-03 17:40:22 +02:00
|
|
|
|
2012-02-11 19:12:02 +01:00
|
|
|
ffmpeg_scan_dictionary(f->metadata, handler, handler_ctx);
|
2012-02-03 09:00:19 +01:00
|
|
|
int idx = ffmpeg_find_audio_stream(f);
|
|
|
|
if (idx >= 0)
|
2012-02-11 19:12:02 +01:00
|
|
|
ffmpeg_scan_dictionary(f->streams[idx]->metadata,
|
|
|
|
handler, handler_ctx);
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2012-01-05 00:02:46 +01:00
|
|
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
|
|
|
|
avformat_close_input(&f);
|
|
|
|
#else
|
2010-06-30 08:59:31 +02:00
|
|
|
av_close_input_stream(f);
|
2012-01-05 00:02:46 +01:00
|
|
|
#endif
|
2010-06-30 08:59:31 +02:00
|
|
|
mpd_ffmpeg_stream_close(stream);
|
2008-10-17 22:27:33 +02:00
|
|
|
|
2012-02-11 19:12:02 +01:00
|
|
|
return true;
|
2008-10-17 22:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-02-23 19:48:43 +01:00
|
|
|
* A list of extensions found for the formats supported by ffmpeg.
|
|
|
|
* This list is current as of 02-23-09; To find out if there are more
|
|
|
|
* supported formats, check the ffmpeg changelog since this date for
|
|
|
|
* more formats.
|
2008-10-17 22:27:33 +02:00
|
|
|
*/
|
2008-11-04 16:55:11 +01:00
|
|
|
static const char *const ffmpeg_suffixes[] = {
|
2009-02-23 19:48:43 +01:00
|
|
|
"16sv", "3g2", "3gp", "4xm", "8svx", "aa3", "aac", "ac3", "afc", "aif",
|
|
|
|
"aifc", "aiff", "al", "alaw", "amr", "anim", "apc", "ape", "asf",
|
|
|
|
"atrac", "au", "aud", "avi", "avm2", "avs", "bap", "bfi", "c93", "cak",
|
|
|
|
"cin", "cmv", "cpk", "daud", "dct", "divx", "dts", "dv", "dvd", "dxa",
|
|
|
|
"eac3", "film", "flac", "flc", "fli", "fll", "flx", "flv", "g726",
|
2010-11-05 02:01:35 +01:00
|
|
|
"gsm", "gxf", "iss", "m1v", "m2v", "m2t", "m2ts",
|
|
|
|
"m4a", "m4b", "m4v",
|
|
|
|
"mad",
|
2009-02-23 19:48:43 +01:00
|
|
|
"mj2", "mjpeg", "mjpg", "mka", "mkv", "mlp", "mm", "mmf", "mov", "mp+",
|
|
|
|
"mp1", "mp2", "mp3", "mp4", "mpc", "mpeg", "mpg", "mpga", "mpp", "mpu",
|
|
|
|
"mve", "mvi", "mxf", "nc", "nsv", "nut", "nuv", "oga", "ogm", "ogv",
|
|
|
|
"ogx", "oma", "ogg", "omg", "psp", "pva", "qcp", "qt", "r3d", "ra",
|
|
|
|
"ram", "rl2", "rm", "rmvb", "roq", "rpl", "rvc", "shn", "smk", "snd",
|
|
|
|
"sol", "son", "spx", "str", "swf", "tgi", "tgq", "tgv", "thp", "ts",
|
|
|
|
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
|
2012-05-22 23:36:47 +02:00
|
|
|
"vp6", "vmd", "wav", "webm", "wma", "wmv", "wsaud", "wsvga", "wv",
|
|
|
|
"wve",
|
2008-10-17 22:27:33 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2008-11-04 16:55:11 +01:00
|
|
|
static const char *const ffmpeg_mime_types[] = {
|
2010-01-17 16:00:14 +01:00
|
|
|
"application/m4a",
|
2009-02-23 19:48:43 +01:00
|
|
|
"application/mp4",
|
|
|
|
"application/octet-stream",
|
|
|
|
"application/ogg",
|
|
|
|
"application/x-ms-wmz",
|
|
|
|
"application/x-ms-wmd",
|
2009-12-29 22:33:46 +01:00
|
|
|
"application/x-ogg",
|
2009-02-23 19:48:43 +01:00
|
|
|
"application/x-shockwave-flash",
|
|
|
|
"application/x-shorten",
|
|
|
|
"audio/8svx",
|
|
|
|
"audio/16sv",
|
|
|
|
"audio/aac",
|
|
|
|
"audio/ac3",
|
2010-01-17 16:00:14 +01:00
|
|
|
"audio/aiff"
|
2009-02-23 19:48:43 +01:00
|
|
|
"audio/amr",
|
|
|
|
"audio/basic",
|
|
|
|
"audio/flac",
|
2010-01-17 16:00:14 +01:00
|
|
|
"audio/m4a",
|
|
|
|
"audio/mp4",
|
2009-02-23 19:48:43 +01:00
|
|
|
"audio/mpeg",
|
|
|
|
"audio/musepack",
|
|
|
|
"audio/ogg",
|
|
|
|
"audio/qcelp",
|
|
|
|
"audio/vorbis",
|
2009-12-29 22:33:46 +01:00
|
|
|
"audio/vorbis+ogg",
|
2009-02-23 19:48:43 +01:00
|
|
|
"audio/x-8svx",
|
|
|
|
"audio/x-16sv",
|
|
|
|
"audio/x-aac",
|
|
|
|
"audio/x-ac3",
|
|
|
|
"audio/x-aiff"
|
|
|
|
"audio/x-alaw",
|
|
|
|
"audio/x-au",
|
|
|
|
"audio/x-dca",
|
|
|
|
"audio/x-eac3",
|
|
|
|
"audio/x-flac",
|
|
|
|
"audio/x-gsm",
|
|
|
|
"audio/x-mace",
|
2010-01-17 16:00:14 +01:00
|
|
|
"audio/x-matroska",
|
2009-02-23 19:48:43 +01:00
|
|
|
"audio/x-monkeys-audio",
|
|
|
|
"audio/x-mpeg",
|
2008-10-17 22:27:33 +02:00
|
|
|
"audio/x-ms-wma",
|
|
|
|
"audio/x-ms-wax",
|
2009-02-23 19:48:43 +01:00
|
|
|
"audio/x-musepack",
|
2009-12-29 22:33:46 +01:00
|
|
|
"audio/x-ogg",
|
|
|
|
"audio/x-vorbis",
|
|
|
|
"audio/x-vorbis+ogg",
|
2009-02-23 19:48:43 +01:00
|
|
|
"audio/x-pn-realaudio",
|
|
|
|
"audio/x-pn-multirate-realaudio",
|
|
|
|
"audio/x-speex",
|
|
|
|
"audio/x-tta"
|
2010-01-17 16:00:14 +01:00
|
|
|
"audio/x-voc",
|
2009-02-23 19:48:43 +01:00
|
|
|
"audio/x-wav",
|
|
|
|
"audio/x-wma",
|
|
|
|
"audio/x-wv",
|
|
|
|
"video/anim",
|
|
|
|
"video/quicktime",
|
|
|
|
"video/msvideo",
|
|
|
|
"video/ogg",
|
|
|
|
"video/theora",
|
2012-05-22 23:36:47 +02:00
|
|
|
"video/webm",
|
2009-02-23 19:48:43 +01:00
|
|
|
"video/x-dv",
|
|
|
|
"video/x-flv",
|
|
|
|
"video/x-matroska",
|
|
|
|
"video/x-mjpeg",
|
|
|
|
"video/x-mpeg",
|
|
|
|
"video/x-ms-asf",
|
|
|
|
"video/x-msvideo",
|
2008-10-17 22:27:33 +02:00
|
|
|
"video/x-ms-wmv",
|
|
|
|
"video/x-ms-wvx",
|
|
|
|
"video/x-ms-wm",
|
|
|
|
"video/x-ms-wmx",
|
2009-02-23 19:48:43 +01:00
|
|
|
"video/x-nut",
|
|
|
|
"video/x-pva",
|
|
|
|
"video/x-theora",
|
|
|
|
"video/x-vid",
|
|
|
|
"video/x-wmv",
|
|
|
|
"video/x-xvid",
|
2010-05-18 20:48:52 +02:00
|
|
|
|
|
|
|
/* special value for the "ffmpeg" input plugin: all streams by
|
|
|
|
the "ffmpeg" input plugin shall be decoded by this
|
|
|
|
plugin */
|
|
|
|
"audio/x-mpd-ffmpeg",
|
|
|
|
|
2008-10-17 22:27:33 +02:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2009-04-03 00:52:13 +02:00
|
|
|
const struct decoder_plugin ffmpeg_decoder_plugin = {
|
2013-01-26 00:37:04 +01:00
|
|
|
"ffmpeg",
|
|
|
|
ffmpeg_init,
|
|
|
|
nullptr,
|
|
|
|
ffmpeg_decode,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
ffmpeg_scan_stream,
|
|
|
|
nullptr,
|
|
|
|
ffmpeg_suffixes,
|
|
|
|
ffmpeg_mime_types
|
2008-10-17 22:27:33 +02:00
|
|
|
};
|