File indexing completed on 2024-05-12 04:55:36
0001 /** 0002 * \file qtfingerprintdecoder.h 0003 * Chromaprint fingerprint decoder using QAudioDecoder. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 15 Feb 2013 0008 * 0009 * Copyright (C) 2013-2018 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QtGlobal> 0030 #include "abstractfingerprintdecoder.h" 0031 0032 class QAudioDecoder; 0033 class QTimer; 0034 0035 /** 0036 * Chromaprint fingerprint decoder using QAudioDecoder. 0037 */ 0038 class QtFingerprintDecoder : public AbstractFingerprintDecoder { 0039 Q_OBJECT 0040 public: 0041 /** 0042 * Constructor. 0043 * @param parent parent object 0044 */ 0045 explicit QtFingerprintDecoder(QObject* parent = 0); 0046 0047 /** 0048 * Destructor. 0049 */ 0050 virtual ~QtFingerprintDecoder(); 0051 0052 /** 0053 * Run decoder on audio file. 0054 * @param filePath path to audio file 0055 */ 0056 virtual void start(const QString& filePath); 0057 0058 /** 0059 * Stop decoder. 0060 * Can be used to stop the decoder when an error is found after 0061 * getting bufferReady() data. 0062 */ 0063 virtual void stop(); 0064 0065 private slots: 0066 /** 0067 * Receive a buffer with decoded audio data. 0068 */ 0069 void receiveBuffer(); 0070 0071 /** 0072 * Receive an error from the decoder. 0073 */ 0074 void receiveError(); 0075 0076 /** 0077 * Receive a timeout. 0078 */ 0079 void receiveTimeout(); 0080 0081 /** 0082 * Finish decoding. 0083 */ 0084 void finishDecoding(); 0085 0086 private: 0087 QAudioDecoder* m_decoder; 0088 QTimer* m_timer; 0089 };