File indexing completed on 2024-05-05 04:44:40
0001 /* This file is part of the KDE project 0002 Copyright (C) 2005-2006,2008 Matthias Kretz <kretz@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Lesser General Public 0006 License as published by the Free Software Foundation; either 0007 version 2.1 of the License, or (at your option) version 3, or any 0008 later version accepted by the membership of KDE e.V. (or its 0009 successor approved by the membership of KDE e.V.), Nokia Corporation 0010 (or its successors, if any) and the KDE Free Qt Foundation, which shall 0011 act as a proxy defined in Section 6 of version 3 of the license. 0012 0013 This library is distributed in the hope that it will be useful, 0014 but WITHOUT ANY WARRANTY; without even the implied warranty of 0015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0016 Lesser General Public License for more details. 0017 0018 You should have received a copy of the GNU Lesser General Public 0019 License along with this library. If not, see <http://www.gnu.org/licenses/>. 0020 0021 */ 0022 #ifndef PHONON_X_ABSTRACTAUDIODATAOUTPUT_H 0023 #define PHONON_X_ABSTRACTAUDIODATAOUTPUT_H 0024 0025 #include "export.h" 0026 #include "../medianode.h" 0027 #include "../phonondefs.h" 0028 #include "audioformat.h" 0029 0030 #ifndef DOXYGEN_SHOULD_SKIP_THIS 0031 template<typename T> class QSet; 0032 #endif 0033 0034 namespace Phonon 0035 { 0036 namespace Experimental 0037 { 0038 0039 class Packet; 0040 class AbstractAudioDataOutputPrivate; 0041 0042 /** 0043 * \short This class gives you the audio data. 0044 * 0045 * This class implements a special AbstractAudioOutput that gives your 0046 * application the audio data. This class is usable for realtime performance. 0047 * 0048 * \author Matthias Kretz <kretz@kde.org> 0049 */ 0050 class PHONONEXPERIMENTAL_EXPORT AbstractAudioDataOutput : public Phonon::MediaNode 0051 { 0052 P_DECLARE_PRIVATE(AbstractAudioDataOutput) 0053 public: 0054 /** 0055 * Constructs an AbstractAudioDataOutput 0056 */ 0057 AbstractAudioDataOutput(); 0058 ~AbstractAudioDataOutput() override; 0059 0060 /** 0061 * Lists the formats this output is allowed to pass via frameReady. 0062 */ 0063 virtual QSet<AudioFormat> allowedFormats() const; 0064 0065 // TODO: consider to remove the following function and make the above pure virtual 0066 /** 0067 * Defaults to AudioFormat(). 0068 * I.e. 16 bit, stereo, 48000 kHz PCM data. 0069 */ 0070 void setAllowedFormats(const QSet<AudioFormat> &); 0071 0072 bool isRunning() const; 0073 0074 /** 0075 * This function is called whenever an audio packet is ready for 0076 * processing. 0077 * 0078 * \warning packetReady can get called from any thread (other than the 0079 * main thread or the thread affinity of this QObject). 0080 */ 0081 virtual void packetReady(const Packet &) = 0; 0082 0083 /** 0084 * This function is called after the last packetReady of a media was 0085 * called. 0086 */ 0087 void endOfMedia(); 0088 0089 void setRunning(bool running); 0090 void start(); 0091 void stop(); 0092 0093 protected: 0094 AbstractAudioDataOutput(AbstractAudioDataOutputPrivate &dd); 0095 }; 0096 0097 } // namespace Experimental 0098 } // namespace Phonon 0099 0100 #endif // PHONON_X_ABSTRACTAUDIODATAOUTPUT_H