summaryrefslogtreecommitdiffstats
path: root/akode/plugins/xiph_decoder/xiph_decoder.cpp
blob: 841656dbca202004afbdd85999a186d68c60b135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*  aKode: Xiph-Format

    Copyright (C) 2004 Allan Sandfeld Jensen <kde@carewolf.com>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This library 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
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the src COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#include "akodelib.h"

#include "file.h"
#include "audioframe.h"
#include "decoder.h"

#include "xiph_decoder.h"
#include "flac_decoder.h"
#include "vorbis_decoder.h"
#include "speex_decoder.h"

namespace aKode {

bool XiphDecoderPlugin::canDecode(File* src) {
#if defined(HAVE_LIBFLAC) || defined(HAVE_LIBFLAC113)
    if (flac_decoder.canDecode(src))
        return true;
    else
#endif
#ifdef HAVE_LIBOGGFLAC
    if (oggflac_decoder.canDecode(src))
        return true;
    else
#endif
#ifdef HAVE_OGG_VORBIS
    if (vorbis_decoder.canDecode(src))
        return true;
    else
#endif
#ifdef HAVE_SPEEX
    if (speex_decoder.canDecode(src))
        return true;
    else
#endif
        return false;
}

Decoder* XiphDecoderPlugin::openDecoder(File* src) {
#if defined(HAVE_LIBFLAC) || defined(HAVE_LIBFLAC113)
    if (flac_decoder.canDecode(src))
        return flac_decoder.openDecoder(src);
    else
#endif
#ifdef HAVE_LIBOGGFLAC
    if (oggflac_decoder.canDecode(src))
        return oggflac_decoder.openDecoder(src);
    else
#endif
#ifdef HAVE_OGG_VORBIS
    if (vorbis_decoder.canDecode(src))
        return vorbis_decoder.openDecoder(src);
    else
#endif
#ifdef HAVE_SPEEX
    if (speex_decoder.canDecode(src))
        return speex_decoder.openDecoder(src);
    else
#endif
        return 0;
}

extern "C" { XiphDecoderPlugin xiph_decoder; }

} // namespace