File indexing completed on 2024-05-12 04:51:01

0001 /*
0002     SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef _K3B_AUDIO_FILE_H_
0007 #define _K3B_AUDIO_FILE_H_
0008 
0009 #include "k3baudiodatasource.h"
0010 
0011 #include "k3b_export.h"
0012 
0013 #include <QScopedPointer>
0014 
0015 namespace K3b {
0016     class AudioDecoder;
0017 
0018     /**
0019      * The AudioFile is the most important audio data source. It gets its data
0020      * from an audio file and uses a AudioDecoder to decode this data.
0021      *
0022      * Be aware that it is currently not possible to change the doc of an AudioFile.
0023      * The reason for this is the decoder sharing which is in place to allow gapless
0024      * splitting of audio files into several tracks.
0025      *
0026      * \see AudioDoc::createDecoderForUrl
0027      */
0028     class LIBK3B_EXPORT AudioFile : public AudioDataSource
0029     {
0030     public:
0031         /**
0032          * The AudioFile registers itself with the doc. This is part of the
0033          * decoder handling facility in AudioDoc which reuses the same decoder
0034          * for sources with the same url.
0035          *
0036          * Use AudioDoc::getDecoderForUrl to create a decoder.
0037          */
0038         AudioFile( AudioDecoder* decoder, AudioDoc* doc );
0039         AudioFile( const AudioFile& file );
0040 
0041         /**
0042          * The AudioFile deregisters itself from the doc. If it was the last file
0043          * to use the decoder the doc will take care of deleting it.
0044          */
0045         ~AudioFile() override;
0046 
0047         AudioDecoder* decoder() const;
0048 
0049         AudioDoc* doc() const;
0050 
0051         QString filename() const;
0052 
0053         /**
0054          * The complete length of the file used by this source.
0055          */
0056         Msf originalLength() const override;
0057 
0058         QString type() const override;
0059         QString sourceComment() const override;
0060 
0061         bool isValid() const override;
0062 
0063         AudioDataSource* copy() const override;
0064 
0065         QIODevice* createReader( QObject* parent = 0 ) override;
0066 
0067     private:
0068         class Private;
0069         QScopedPointer<Private> d;
0070     };
0071 }
0072 
0073 #endif