aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-26 00:37:04 +0100
committerMax Kellermann <max@duempel.org>2013-01-26 01:17:43 +0100
commitba49f20f685d7e6d25fcbf2af60d389fedc67210 (patch)
treeaf00916b85a20bbff10b3e6863f4498300aeb4ca /src/decoder
parenta3ee26da6437dff2d065cc3fc2ad069447309ab6 (diff)
downloadmpd-ba49f20f685d7e6d25fcbf2af60d389fedc67210.tar.gz
mpd-ba49f20f685d7e6d25fcbf2af60d389fedc67210.tar.xz
mpd-ba49f20f685d7e6d25fcbf2af60d389fedc67210.zip
decoder/ffmpeg: convert to C++
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/FfmpegDecoderPlugin.cxx (renamed from src/decoder/ffmpeg_decoder_plugin.c)48
-rw-r--r--src/decoder/FfmpegDecoderPlugin.hxx25
-rw-r--r--src/decoder/FfmpegMetaData.cxx (renamed from src/decoder/ffmpeg_metadata.c)9
-rw-r--r--src/decoder/FfmpegMetaData.hxx (renamed from src/decoder/ffmpeg_metadata.h)8
4 files changed, 66 insertions, 24 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/FfmpegDecoderPlugin.cxx
index 4c4cb2b81..ac2883305 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2011 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,12 +17,19 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+/* necessary because libavutil/common.h uses UINT64_C */
+#define __STDC_CONSTANT_MACROS
+
#include "config.h"
+#include "FfmpegDecoderPlugin.hxx"
#include "decoder_api.h"
-#include "audio_check.h"
-#include "ffmpeg_metadata.h"
+#include "FfmpegMetaData.hxx"
#include "tag_handler.h"
+extern "C" {
+#include "audio_check.h"
+}
+
#include <glib.h>
#include <assert.h>
@@ -34,6 +41,7 @@
#include <sys/stat.h>
#include <unistd.h>
+extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
@@ -43,6 +51,7 @@
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#include <libavutil/dict.h>
#endif
+}
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "ffmpeg"
@@ -93,7 +102,7 @@ struct mpd_ffmpeg_stream {
static int
mpd_ffmpeg_stream_read(void *opaque, uint8_t *buf, int size)
{
- struct mpd_ffmpeg_stream *stream = opaque;
+ struct mpd_ffmpeg_stream *stream = (struct mpd_ffmpeg_stream *)opaque;
return decoder_read(stream->decoder, stream->input,
(void *)buf, size);
@@ -102,7 +111,7 @@ mpd_ffmpeg_stream_read(void *opaque, uint8_t *buf, int size)
static int64_t
mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
{
- struct mpd_ffmpeg_stream *stream = opaque;
+ struct mpd_ffmpeg_stream *stream = (struct mpd_ffmpeg_stream *)opaque;
if (whence == AVSEEK_SIZE)
return stream->input->size;
@@ -305,7 +314,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
/* libavcodec < 0.8 needs an aligned buffer */
uint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2 + 16];
size_t buffer_size = sizeof(audio_buf);
- int16_t *aligned_buffer = align16(audio_buf, &buffer_size);
+ int16_t *aligned_buffer = (int16_t *)align16(audio_buf, &buffer_size);
#endif
enum decoder_command cmd = DECODE_COMMAND_NONE;
@@ -426,7 +435,7 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
PADDING = 16,
};
- unsigned char *buffer = g_malloc(BUFFER_SIZE);
+ unsigned char *buffer = (unsigned char *)g_malloc(BUFFER_SIZE);
size_t nbytes = decoder_read(decoder, is, buffer, BUFFER_SIZE);
if (nbytes <= PADDING ||
!input_stream_lock_seek(is, 0, SEEK_SET, NULL)) {
@@ -440,11 +449,10 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
size */
nbytes -= PADDING;
- AVProbeData avpd = {
- .buf = buffer,
- .buf_size = nbytes,
- .filename = is->uri,
- };
+ AVProbeData avpd;
+ avpd.buf = buffer;
+ avpd.buf_size = nbytes;
+ avpd.filename = is->uri;
AVInputFormat *format = av_probe_input_format(&avpd, true);
g_free(buffer);
@@ -791,10 +799,14 @@ static const char *const ffmpeg_mime_types[] = {
};
const struct decoder_plugin ffmpeg_decoder_plugin = {
- .name = "ffmpeg",
- .init = ffmpeg_init,
- .stream_decode = ffmpeg_decode,
- .scan_stream = ffmpeg_scan_stream,
- .suffixes = ffmpeg_suffixes,
- .mime_types = ffmpeg_mime_types
+ "ffmpeg",
+ ffmpeg_init,
+ nullptr,
+ ffmpeg_decode,
+ nullptr,
+ nullptr,
+ ffmpeg_scan_stream,
+ nullptr,
+ ffmpeg_suffixes,
+ ffmpeg_mime_types
};
diff --git a/src/decoder/FfmpegDecoderPlugin.hxx b/src/decoder/FfmpegDecoderPlugin.hxx
new file mode 100644
index 000000000..9a637fff0
--- /dev/null
+++ b/src/decoder/FfmpegDecoderPlugin.hxx
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
+ * http://www.musicpd.org
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+#ifndef MPD_DECODER_FFMPEG_HXX
+#define MPD_DECODER_FFMPEG_HXX
+
+extern const struct decoder_plugin ffmpeg_decoder_plugin;
+
+#endif
diff --git a/src/decoder/ffmpeg_metadata.c b/src/decoder/FfmpegMetaData.cxx
index 3ef774f63..d3000591c 100644
--- a/src/decoder/ffmpeg_metadata.c
+++ b/src/decoder/FfmpegMetaData.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,8 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+/* necessary because libavutil/common.h uses UINT64_C */
+#define __STDC_CONSTANT_MACROS
+
#include "config.h"
-#include "ffmpeg_metadata.h"
+#include "FfmpegMetaData.hxx"
#include "tag_table.h"
#include "tag_handler.h"
@@ -70,7 +73,7 @@ ffmpeg_scan_dictionary(AVDictionary *dict,
const struct tag_handler *handler, void *handler_ctx)
{
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
- ffmpeg_copy_metadata(i, dict, tag_item_names[i],
+ ffmpeg_copy_metadata(tag_type(i), dict, tag_item_names[i],
handler, handler_ctx);
for (const struct tag_table *i = ffmpeg_tags;
diff --git a/src/decoder/ffmpeg_metadata.h b/src/decoder/FfmpegMetaData.hxx
index 60658f479..f76e16287 100644
--- a/src/decoder/ffmpeg_metadata.h
+++ b/src/decoder/FfmpegMetaData.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2012 The Music Player Daemon Project
+ * Copyright (C) 2003-2013 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -17,14 +17,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_FFMPEG_METADATA_H
-#define MPD_FFMPEG_METADATA_H
+#ifndef MPD_FFMPEG_METADATA_HXX
+#define MPD_FFMPEG_METADATA_HXX
+extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#include <libavutil/dict.h>
#endif
+}
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0)
#define AVDictionary AVMetadata