Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ba49f20f
Commit
ba49f20f
authored
Jan 26, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: convert to C++
parent
a3ee26da
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
28 deletions
+71
-28
Makefile.am
Makefile.am
+4
-3
FfmpegDecoderPlugin.cxx
src/decoder/FfmpegDecoderPlugin.cxx
+30
-18
FfmpegDecoderPlugin.hxx
src/decoder/FfmpegDecoderPlugin.hxx
+25
-0
FfmpegMetaData.cxx
src/decoder/FfmpegMetaData.cxx
+6
-3
FfmpegMetaData.hxx
src/decoder/FfmpegMetaData.hxx
+5
-3
decoder_list.c
src/decoder_list.c
+1
-1
No files found.
Makefile.am
View file @
ba49f20f
...
@@ -617,9 +617,10 @@ endif
...
@@ -617,9 +617,10 @@ endif
if
HAVE_FFMPEG
if
HAVE_FFMPEG
libdecoder_plugins_a_SOURCES
+=
\
libdecoder_plugins_a_SOURCES
+=
\
src/decoder/ffmpeg_metadata.c
\
src/decoder/FfmpegMetaData.cxx
\
src/decoder/ffmpeg_metadata.h
\
src/decoder/FfmpegMetaData.hxx
\
src/decoder/ffmpeg_decoder_plugin.c
src/decoder/FfmpegDecoderPlugin.cxx
\
src/decoder/FfmpegDecoderPlugin.hxx
endif
endif
if
ENABLE_SNDFILE
if
ENABLE_SNDFILE
...
...
src/decoder/
ffmpeg_decoder_plugin.c
→
src/decoder/
FfmpegDecoderPlugin.cxx
View file @
ba49f20f
/*
/*
* Copyright (C) 2003-201
1
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
* http://www.musicpd.org
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
...
@@ -17,12 +17,19 @@
...
@@ -17,12 +17,19 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 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 "config.h"
#include "FfmpegDecoderPlugin.hxx"
#include "decoder_api.h"
#include "decoder_api.h"
#include "audio_check.h"
#include "FfmpegMetaData.hxx"
#include "ffmpeg_metadata.h"
#include "tag_handler.h"
#include "tag_handler.h"
extern
"C"
{
#include "audio_check.h"
}
#include <glib.h>
#include <glib.h>
#include <assert.h>
#include <assert.h>
...
@@ -34,6 +41,7 @@
...
@@ -34,6 +41,7 @@
#include <sys/stat.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
extern
"C"
{
#include <libavcodec/avcodec.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavformat/avio.h>
...
@@ -43,6 +51,7 @@
...
@@ -43,6 +51,7 @@
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#include <libavutil/dict.h>
#include <libavutil/dict.h>
#endif
#endif
}
#undef G_LOG_DOMAIN
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "ffmpeg"
#define G_LOG_DOMAIN "ffmpeg"
...
@@ -93,7 +102,7 @@ struct mpd_ffmpeg_stream {
...
@@ -93,7 +102,7 @@ struct mpd_ffmpeg_stream {
static
int
static
int
mpd_ffmpeg_stream_read
(
void
*
opaque
,
uint8_t
*
buf
,
int
size
)
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
,
return
decoder_read
(
stream
->
decoder
,
stream
->
input
,
(
void
*
)
buf
,
size
);
(
void
*
)
buf
,
size
);
...
@@ -102,7 +111,7 @@ mpd_ffmpeg_stream_read(void *opaque, uint8_t *buf, int size)
...
@@ -102,7 +111,7 @@ mpd_ffmpeg_stream_read(void *opaque, uint8_t *buf, int size)
static
int64_t
static
int64_t
mpd_ffmpeg_stream_seek
(
void
*
opaque
,
int64_t
pos
,
int
whence
)
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
)
if
(
whence
==
AVSEEK_SIZE
)
return
stream
->
input
->
size
;
return
stream
->
input
->
size
;
...
@@ -305,7 +314,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
...
@@ -305,7 +314,7 @@ ffmpeg_send_packet(struct decoder *decoder, struct input_stream *is,
/* libavcodec < 0.8 needs an aligned buffer */
/* libavcodec < 0.8 needs an aligned buffer */
uint8_t
audio_buf
[(
AVCODEC_MAX_AUDIO_FRAME_SIZE
*
3
)
/
2
+
16
];
uint8_t
audio_buf
[(
AVCODEC_MAX_AUDIO_FRAME_SIZE
*
3
)
/
2
+
16
];
size_t
buffer_size
=
sizeof
(
audio_buf
);
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
#endif
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
enum
decoder_command
cmd
=
DECODE_COMMAND_NONE
;
...
@@ -426,7 +435,7 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
...
@@ -426,7 +435,7 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
PADDING
=
16
,
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
);
size_t
nbytes
=
decoder_read
(
decoder
,
is
,
buffer
,
BUFFER_SIZE
);
if
(
nbytes
<=
PADDING
||
if
(
nbytes
<=
PADDING
||
!
input_stream_lock_seek
(
is
,
0
,
SEEK_SET
,
NULL
))
{
!
input_stream_lock_seek
(
is
,
0
,
SEEK_SET
,
NULL
))
{
...
@@ -440,11 +449,10 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
...
@@ -440,11 +449,10 @@ ffmpeg_probe(struct decoder *decoder, struct input_stream *is)
size */
size */
nbytes
-=
PADDING
;
nbytes
-=
PADDING
;
AVProbeData
avpd
=
{
AVProbeData
avpd
;
.
buf
=
buffer
,
avpd
.
buf
=
buffer
;
.
buf_size
=
nbytes
,
avpd
.
buf_size
=
nbytes
;
.
filename
=
is
->
uri
,
avpd
.
filename
=
is
->
uri
;
};
AVInputFormat
*
format
=
av_probe_input_format
(
&
avpd
,
true
);
AVInputFormat
*
format
=
av_probe_input_format
(
&
avpd
,
true
);
g_free
(
buffer
);
g_free
(
buffer
);
...
@@ -791,10 +799,14 @@ static const char *const ffmpeg_mime_types[] = {
...
@@ -791,10 +799,14 @@ static const char *const ffmpeg_mime_types[] = {
};
};
const
struct
decoder_plugin
ffmpeg_decoder_plugin
=
{
const
struct
decoder_plugin
ffmpeg_decoder_plugin
=
{
.
name
=
"ffmpeg"
,
"ffmpeg"
,
.
init
=
ffmpeg_init
,
ffmpeg_init
,
.
stream_decode
=
ffmpeg_decode
,
nullptr
,
.
scan_stream
=
ffmpeg_scan_stream
,
ffmpeg_decode
,
.
suffixes
=
ffmpeg_suffixes
,
nullptr
,
.
mime_types
=
ffmpeg_mime_types
nullptr
,
ffmpeg_scan_stream
,
nullptr
,
ffmpeg_suffixes
,
ffmpeg_mime_types
};
};
src/decoder/FfmpegDecoderPlugin.hxx
0 → 100644
View file @
ba49f20f
/*
* 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
src/decoder/
ffmpeg_metadata.c
→
src/decoder/
FfmpegMetaData.cxx
View file @
ba49f20f
/*
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
* http://www.musicpd.org
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
...
@@ -17,8 +17,11 @@
...
@@ -17,8 +17,11 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 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 "config.h"
#include "
ffmpeg_metadata.h
"
#include "
FfmpegMetaData.hxx
"
#include "tag_table.h"
#include "tag_table.h"
#include "tag_handler.h"
#include "tag_handler.h"
...
@@ -70,7 +73,7 @@ ffmpeg_scan_dictionary(AVDictionary *dict,
...
@@ -70,7 +73,7 @@ ffmpeg_scan_dictionary(AVDictionary *dict,
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
const
struct
tag_handler
*
handler
,
void
*
handler_ctx
)
{
{
for
(
unsigned
i
=
0
;
i
<
TAG_NUM_OF_ITEM_TYPES
;
++
i
)
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
);
handler
,
handler_ctx
);
for
(
const
struct
tag_table
*
i
=
ffmpeg_tags
;
for
(
const
struct
tag_table
*
i
=
ffmpeg_tags
;
...
...
src/decoder/
ffmpeg_metadata.h
→
src/decoder/
FfmpegMetaData.hxx
View file @
ba49f20f
/*
/*
* Copyright (C) 2003-201
2
The Music Player Daemon Project
* Copyright (C) 2003-201
3
The Music Player Daemon Project
* http://www.musicpd.org
* http://www.musicpd.org
*
*
* This program is free software; you can redistribute it and/or modify
* This program is free software; you can redistribute it and/or modify
...
@@ -17,14 +17,16 @@
...
@@ -17,14 +17,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
*/
#ifndef MPD_FFMPEG_METADATA_H
#ifndef MPD_FFMPEG_METADATA_H
XX
#define MPD_FFMPEG_METADATA_H
#define MPD_FFMPEG_METADATA_H
XX
extern
"C"
{
#include <libavformat/avformat.h>
#include <libavformat/avformat.h>
#include <libavutil/avutil.h>
#include <libavutil/avutil.h>
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0)
#include <libavutil/dict.h>
#include <libavutil/dict.h>
#endif
#endif
}
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0)
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53,1,0)
#define AVDictionary AVMetadata
#define AVDictionary AVMetadata
...
...
src/decoder_list.c
View file @
ba49f20f
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "decoder/VorbisDecoderPlugin.h"
#include "decoder/VorbisDecoderPlugin.h"
#include "decoder/AdPlugDecoderPlugin.h"
#include "decoder/AdPlugDecoderPlugin.h"
#include "decoder/WavpackDecoderPlugin.hxx"
#include "decoder/WavpackDecoderPlugin.hxx"
#include "decoder/FfmpegDecoderPlugin.hxx"
#include <glib.h>
#include <glib.h>
...
@@ -47,7 +48,6 @@ extern const struct decoder_plugin mikmod_decoder_plugin;
...
@@ -47,7 +48,6 @@ extern const struct decoder_plugin mikmod_decoder_plugin;
extern
const
struct
decoder_plugin
sidplay_decoder_plugin
;
extern
const
struct
decoder_plugin
sidplay_decoder_plugin
;
extern
const
struct
decoder_plugin
wildmidi_decoder_plugin
;
extern
const
struct
decoder_plugin
wildmidi_decoder_plugin
;
extern
const
struct
decoder_plugin
fluidsynth_decoder_plugin
;
extern
const
struct
decoder_plugin
fluidsynth_decoder_plugin
;
extern
const
struct
decoder_plugin
ffmpeg_decoder_plugin
;
extern
const
struct
decoder_plugin
gme_decoder_plugin
;
extern
const
struct
decoder_plugin
gme_decoder_plugin
;
const
struct
decoder_plugin
*
const
decoder_plugins
[]
=
{
const
struct
decoder_plugin
*
const
decoder_plugins
[]
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment