Classified ads
audiomixer.h
Go to the documentation of this file.
1 /* -*-C++-*- -*-coding: utf-8-unix;-*-
2  Classified Ads is Copyright (c) Antti Järvinen 2015.
3 
4  This file is part of Classified Ads.
5 
6  Classified Ads is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  Classified Ads is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with Classified Ads; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 
21 #ifndef AUDIO_MIXER_H
22 #define AUDIO_MIXER_H
23 
24 #include <QObject>
25 #include <QByteArray>
26 #include <QQueue>
27 
28 class Model ;
29 
44 class AudioMixer : public QObject {
45  Q_OBJECT
46 
47 public:
51  AudioMixer(Model& aModel) ;
52  ~AudioMixer() ;
53 
58  void insertStream (quint32 aCallId,
59  quint32 aStartingSeq,
60  bool aIsLocallyCaptured ) ;
65  void removeStream (quint32 aCallId) ;
66 signals:
68  void frameReadyForLocalSpeaker(const QByteArray& aFrame) ;
70  void frameReadyForRemoteSend(quint32 aCallId,
71  quint32 aSeqNo,
72  const QByteArray& aFrame) ;
73 public slots:
89  void insertCapturedAudioFrame ( const QByteArray& aFrame,
90  quint32 aSeqNo );
91 
111  void insertReceivedAudioFrame ( quint32 aCallId,
112  quint32 aSeqNo,
113  const QByteArray& aFrame );
114 
115 private: // methods
121  void tryMixFrames(quint32 aCallId,
122  quint32 aSeqNo) ;
127  void configureMixedStreams() ;
134  void doInsertAudioFrame ( const QByteArray& aFrame,
135  bool aIsLocallyCaptured,
136  quint32 aSeqNo,
137  quint32 aCallId );
142  void clip ( QByteArray& aBuffer ) ;
143 
144 private: // members
145  typedef struct AudioFrameStruct {
146  quint32 iCallId ;
147  quint32 iSeqNo ;
149  QByteArray iFrame ;
150  } AudioFrame ;
151  typedef struct AudioStreamMetadata {
152  quint32 iCallId ;
153  quint32 iStartingSeq ;
160  quint32 iMaxSeqSeen;
168  QList<QQueue<AudioFrame> > iAudioDataBuffer ;
170  QList<AudioFrameMetadata> iStreams ;
176 } ;
177 #endif
void frameReadyForRemoteSend(quint32 aCallId, quint32 aSeqNo, const QByteArray &aFrame)
struct AudioMixer::AudioFrameStruct AudioFrame
Class for mixing together 0-n audio streams.
Definition: audiomixer.h:44
Definition: audiomixer.h:145
void clip(QByteArray &aBuffer)
QList< int > iIndexesToMixForRemoteOutput
Definition: audiomixer.h:174
AudioMixer(Model &aModel)
void doInsertAudioFrame(const QByteArray &aFrame, bool aIsLocallyCaptured, quint32 aSeqNo, quint32 aCallId)
QList< QQueue< AudioFrame > > iAudioDataBuffer
Definition: audiomixer.h:168
void configureMixedStreams()
struct AudioMixer::AudioStreamMetadata AudioFrameMetadata
bool iIsLocallyCaptured
Definition: audiomixer.h:161
quint32 iSeqNo
Definition: audiomixer.h:147
void insertReceivedAudioFrame(quint32 aCallId, quint32 aSeqNo, const QByteArray &aFrame)
QList< int > iIndexesToMixForLocalSpeaker
Definition: audiomixer.h:172
quint32 iMaxSeqSeen
Definition: audiomixer.h:160
Model & iModel
Definition: audiomixer.h:175
M of the MVC pattern. Handles permanent storage.
Definition: model.h:48
void insertCapturedAudioFrame(const QByteArray &aFrame, quint32 aSeqNo)
void frameReadyForLocalSpeaker(const QByteArray &aFrame)
Definition: audiomixer.h:151
QList< AudioFrameMetadata > iStreams
Definition: audiomixer.h:170
quint32 iCallId
Definition: audiomixer.h:146
void tryMixFrames(quint32 aCallId, quint32 aSeqNo)
quint32 iStartingSeq
Definition: audiomixer.h:153
void insertStream(quint32 aCallId, quint32 aStartingSeq, bool aIsLocallyCaptured)
void removeStream(quint32 aCallId)
QByteArray iFrame
Definition: audiomixer.h:149
bool iIsLocallyCaptured
Definition: audiomixer.h:148
quint32 iCallId
Definition: audiomixer.h:152