1 // Copyright 2005-2019 The Mumble Developers. All rights reserved.
2 // Use of this source code is governed by a BSD-style license
3 // that can be found in the LICENSE file at the root of the
4 // Mumble source tree or at <https://www.mumble.info/LICENSE>.
5 
6 #ifndef MUMBLE_MUMBLE_AUDIO_H_
7 #define MUMBLE_MUMBLE_AUDIO_H_
8 
9 #include <QtCore/QByteArray>
10 #include <QtCore/QMultiMap>
11 #include <QtCore/QMutex>
12 #include <QtCore/QString>
13 #include <QtCore/QTime>
14 #include <QtCore/QVariant>
15 
16 #include "ClientUser.h"
17 
18 #define SAMPLE_RATE 48000
19 
20 typedef QPair<QString,QVariant> audioDevice;
21 
22 class LoopUser : public ClientUser {
23 	private:
24 		Q_DISABLE_COPY(LoopUser)
25 	protected:
26 		QMutex qmLock;
27 		QTime qtTicker;
28 		QTime qtLastFetch;
29 		QMultiMap<float, QByteArray> qmPackets;
30 		LoopUser();
31 	public:
32 		static LoopUser lpLoopy;
33 		virtual void addFrame(const QByteArray &packet);
34 		void fetchFrames();
35 };
36 
37 class RecordUser : public LoopUser {
38 	private:
39 		Q_OBJECT
40 		Q_DISABLE_COPY(RecordUser)
41 	public:
42 		RecordUser();
43 		~RecordUser() Q_DECL_OVERRIDE;
44 		void addFrame(const QByteArray &packet) Q_DECL_OVERRIDE;
45 };
46 
47 namespace Audio {
48 	void startInput(const QString &input = QString());
49 	void stopInput();
50 
51 	void startOutput(const QString &output = QString());
52 	void stopOutput();
53 
54 	void start(const QString &input = QString(), const QString &output = QString());
55 	void stop();
56 }
57 
58 #endif
59