PageRenderTime 246ms CodeModel.GetById 123ms app.highlight 8ms RepoModel.GetById 113ms app.codeStats 0ms

/thirdparty/liblastfm2/src/fingerprint/contrib/AacSource_p.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 94 lines | 61 code | 10 blank | 23 comment | 0 complexity | 1cc0aa0942d72998dec86247e279e02a MD5 | raw file
 1/*
 2   Copyright 2009 Last.fm Ltd. 
 3   Copyright 2009 John Stamp <jstamp@users.sourceforge.net>
 4
 5   This file is part of liblastfm.
 6
 7   liblastfm is free software: you can redistribute it and/or modify
 8   it under the terms of the GNU General Public License as published by
 9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   liblastfm is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
19*/
20#include <faad.h>
21#include <mp4ff.h>
22
23class AAC_File
24{
25public:
26    AAC_File(const QString&, int headerType);
27    virtual ~AAC_File();
28    virtual void getInfo( int& lengthSecs, int& samplerate, int& bitrate, int& nchannels ) = 0;
29    virtual bool init() = 0;
30    //virtual QString getMbid() = 0;
31    virtual void skip( const int mSecs ) = 0;
32    virtual void postDecode(unsigned long) = 0;
33
34    enum HeaderType
35    {
36        AAC_UNKNOWN = 0,
37        AAC_ADIF,
38        AAC_ADTS,
39        AAC_MP4
40    };
41
42    QString m_fileName;
43    unsigned char *m_inBuf;
44    size_t m_inBufSize;
45    NeAACDecHandle m_decoder;
46    unsigned char *m_overflow;
47    size_t m_overflowSize;
48    int m_header;
49};
50
51
52class AAC_MP4_File : public AAC_File
53{
54public:
55    AAC_MP4_File(const QString&, int headerType = AAC_MP4 );
56    ~AAC_MP4_File();
57    virtual void getInfo( int& lengthSecs, int& samplerate, int& bitrate, int& nchannels );
58    virtual bool init();
59    //virtual QString getMbid();
60    virtual void skip( const int mSecs );
61    virtual void postDecode(unsigned long);
62    int32_t readSample();
63
64private:
65    bool commonSetup( NeAACDecHandle& handle, mp4ff_callback_t*& cb, FILE*& fp, mp4ff_t*& mp4, int32_t& audioTrack );
66    virtual int32_t getTrack( const mp4ff_t* f );
67    int m_mp4AudioTrack;
68    uint32_t m_mp4SampleId;
69    mp4ff_t *m_mp4File;
70    mp4ff_callback_t *m_mp4cb;
71};
72
73
74class AAC_ADTS_File : public AAC_File
75{
76public:
77    AAC_ADTS_File( const QString& fileName, int headerType );
78    ~AAC_ADTS_File();
79    virtual void getInfo( int& lengthSecs, int& samplerate, int& bitrate, int& nchannels );
80    virtual bool init();
81    //virtual QString getMbid();
82    virtual void skip( const int mSecs );
83    virtual void postDecode(unsigned long bytesconsumed );
84
85private:
86    int32_t commonSetup( FILE*& fp, NeAACDecHandle& decoder, unsigned char*& buf, size_t& bufSize, uint32_t& samplerate, uint8_t& channels );
87    void parse( FILE*& fp, unsigned char*& buf, size_t& bufSize, int &bitrate, double &length );
88    void fillBuffer( FILE*& fp, unsigned char*& buf, size_t& bufSize, const size_t m_bytesConsumed );
89
90    FILE* m_file;
91    // These two only needed for skipping AAC ADIF files
92    uint32_t m_adifSamplerate;
93    int m_adifChannels;
94};