aboutsummaryrefslogtreecommitdiffstats
path: root/src/input
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-21 17:38:40 +0100
committerMax Kellermann <max@duempel.org>2013-01-21 17:50:43 +0100
commit0c9f22507f753aa9cdf68084c773c9438391fb1f (patch)
treee4cd6d5adeabf72f938387cc030930c302c10376 /src/input
parent9c870e4276157a292673fb1a21f5a9e8a60cb57f (diff)
downloadmpd-0c9f22507f753aa9cdf68084c773c9438391fb1f.tar.gz
mpd-0c9f22507f753aa9cdf68084c773c9438391fb1f.tar.xz
mpd-0c9f22507f753aa9cdf68084c773c9438391fb1f.zip
input/ffmpeg: convert to C++
Diffstat (limited to 'src/input')
-rw-r--r--src/input/FfmpegInputPlugin.cxx (renamed from src/input/ffmpeg_input_plugin.c)42
-rw-r--r--src/input/FfmpegInputPlugin.hxx (renamed from src/input/ffmpeg_input_plugin.h)6
2 files changed, 29 insertions, 19 deletions
diff --git a/src/input/ffmpeg_input_plugin.c b/src/input/FfmpegInputPlugin.cxx
index 6d339a067..53e67ef17 100644
--- a/src/input/ffmpeg_input_plugin.c
+++ b/src/input/FfmpegInputPlugin.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,14 +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 "input/ffmpeg_input_plugin.h"
+#include "FfmpegInputPlugin.hxx"
#include "input_internal.h"
#include "input_plugin.h"
+extern "C" {
#include <libavutil/avutil.h>
#include <libavformat/avio.h>
#include <libavformat/avformat.h>
+}
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "input_ffmpeg"
@@ -51,10 +56,10 @@ static inline bool
input_ffmpeg_supported(void)
{
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
- void *opaque = NULL;
- return avio_enum_protocols(&opaque, 0) != NULL;
+ void *opaque = nullptr;
+ return avio_enum_protocols(&opaque, 0) != nullptr;
#else
- return av_protocol_next(NULL) != NULL;
+ return av_protocol_next(nullptr) != nullptr;
#endif
}
@@ -87,7 +92,7 @@ input_ffmpeg_open(const char *uri,
!g_str_has_prefix(uri, "rtmp://") &&
!g_str_has_prefix(uri, "rtmpt://") &&
!g_str_has_prefix(uri, "rtmps://"))
- return NULL;
+ return nullptr;
i = g_new(struct input_ffmpeg, 1);
input_stream_init(&i->base, &input_plugin_ffmpeg, uri,
@@ -104,7 +109,7 @@ input_ffmpeg_open(const char *uri,
g_free(i);
g_set_error(error_r, ffmpeg_quark(), ret,
"libavformat failed to open the URI");
- return NULL;
+ return nullptr;
}
i->eof = false;
@@ -134,9 +139,9 @@ input_ffmpeg_read(struct input_stream *is, void *ptr, size_t size,
struct input_ffmpeg *i = (struct input_ffmpeg *)is;
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,0,0)
- int ret = avio_read(i->h, ptr, size);
+ int ret = avio_read(i->h, (unsigned char *)ptr, size);
#else
- int ret = url_read(i->h, ptr, size);
+ int ret = url_read(i->h, (unsigned char *)ptr, size);
#endif
if (ret <= 0) {
if (ret < 0)
@@ -194,11 +199,16 @@ input_ffmpeg_seek(struct input_stream *is, goffset offset, int whence,
}
const struct input_plugin input_plugin_ffmpeg = {
- .name = "ffmpeg",
- .init = input_ffmpeg_init,
- .open = input_ffmpeg_open,
- .close = input_ffmpeg_close,
- .read = input_ffmpeg_read,
- .eof = input_ffmpeg_eof,
- .seek = input_ffmpeg_seek,
+ "ffmpeg",
+ input_ffmpeg_init,
+ nullptr,
+ input_ffmpeg_open,
+ input_ffmpeg_close,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ input_ffmpeg_read,
+ input_ffmpeg_eof,
+ input_ffmpeg_seek,
};
diff --git a/src/input/ffmpeg_input_plugin.h b/src/input/FfmpegInputPlugin.hxx
index 393836ca5..d5e3a8d9b 100644
--- a/src/input/ffmpeg_input_plugin.h
+++ b/src/input/FfmpegInputPlugin.hxx
@@ -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,8 +17,8 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MPD_FFMPEG_INPUT_PLUGIN_H
-#define MPD_FFMPEG_INPUT_PLUGIN_H
+#ifndef MPD_FFMPEG_INPUT_PLUGIN_HXX
+#define MPD_FFMPEG_INPUT_PLUGIN_HXX
/**
* An input plugin based on libavformat's "avio" library.