File: k3bmpcdecoder.cpp

package info (click to toggle)
k3b 25.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,840 kB
  • sloc: cpp: 99,202; xml: 372; sh: 84; makefile: 10
file content (100 lines) | stat: -rw-r--r-- 1,699 bytes parent folder | download | duplicates (2)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*

    SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#include "k3bmpcdecoder.h"
#include "k3bmpcwrapper.h"
#include "k3bplugin_i18n.h"

#include <config-k3b.h>

K_PLUGIN_CLASS_WITH_JSON(K3bMpcDecoderFactory, "k3bmpcdecoder.json")

K3bMpcDecoderFactory::K3bMpcDecoderFactory( QObject* parent, const QVariantList& )
    : K3b::AudioDecoderFactory( parent )
{
}


K3bMpcDecoderFactory::~K3bMpcDecoderFactory()
{
}


K3b::AudioDecoder* K3bMpcDecoderFactory::createDecoder( QObject* parent
    ) const
{
    return new K3bMpcDecoder( parent );
}


bool K3bMpcDecoderFactory::canDecode( const QUrl& url )
{
    K3bMpcWrapper w;
    return w.open( url.toLocalFile() );
}






K3bMpcDecoder::K3bMpcDecoder( QObject* parent  )
    : K3b::AudioDecoder( parent )
{
    m_mpc = new K3bMpcWrapper();
}


K3bMpcDecoder::~K3bMpcDecoder()
{
    delete m_mpc;
}


QString K3bMpcDecoder::fileType() const
{
    return i18n("Musepack");
}


bool K3bMpcDecoder::analyseFileInternal( K3b::Msf& frames, int& samplerate, int& ch )
{
    if( m_mpc->open( filename() ) ) {
        frames = m_mpc->length();
        samplerate = m_mpc->samplerate();
        ch = m_mpc->channels();

        // call addTechnicalInfo and addMetaInfo here

        return true;
    }
    else
        return false;
}


bool K3bMpcDecoder::initDecoderInternal()
{
    return m_mpc->open( filename() );
}


bool K3bMpcDecoder::seekInternal( const K3b::Msf& msf )
{
    return m_mpc->seek( msf );
}


int K3bMpcDecoder::decodeInternal( char* _data, int maxLen )
{
    return m_mpc->decode( _data, maxLen );
}


#include "k3bmpcdecoder.moc"

#include "moc_k3bmpcdecoder.cpp"