Classified ads
Classes | Public Slots | Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
VoiceCallEngine Class Reference

Network-related logic for handling voice channel between nodes. More...

#include <voicecallengine.h>

Inheritance diagram for VoiceCallEngine:
Inheritance graph
[legend]
Collaboration diagram for VoiceCallEngine:
Collaboration graph
[legend]

Classes

class  VoiceCallExtension
 

Public Slots

void nodeConnectionAttemptStatus (Connection::ConnectionState aStatus, const Hash aHashOfAttemptedNode)
 
void audioFrameEncoded (quint32 aCallId, quint32 aSeqNo, const QByteArray &aEncodedVoice, Hash aForNode)
 
void frameReady (quint32 aCallId, quint32 aSeqNo, const QByteArray &aRawAudio, Hash aForNode)
 
void processCallData ()
 
void setInputLevel (float aInputLevel)
 
void setOutputLevel (float aOutputLevel)
 

Signals

void error (QTcpSocket::SocketError socketError)
 
void callStateChanged (quint32 aCallId, VoiceCallEngine::CallState aState)
 
void startProcessCallData ()
 
void inputLevel (float aInputLevel)
 
void outputLevel (float aOutputLevel)
 

Public Member Functions

 VoiceCallEngine (MController &aController, Model &aModel)
 
 ~VoiceCallEngine ()
 
virtual void installObserver (MCallStatusObserver *aObserver)
 
virtual void removeObserver (MCallStatusObserver *aObserver)
 
virtual void insertCallData (quint32 aCallId, quint32 aSeqNo, PayloadType aPayloadType, const QByteArray &aPayload, Hash &aSendingNode)
 
virtual void insertCallStatusData (const VoiceCall &aCallStatus, const Hash &aSendingNode)
 
virtual QList< quint32 > onGoingCalls () const
 
virtual CallState callStatus (quint32 aCallId) const
 
virtual void closeCall (quint32 aCallId)
 
virtual void acceptCall (quint32 aCallId)
 
QString excuseForCallCreation (const Hash &aOperator, const Hash &aNode=KNullHash) const
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 

Private Member Functions

bool setupNewOutgoingCall (VoiceCallExtension &aCall)
 
bool setupNewIncomingCall (VoiceCallExtension &aCall)
 
void sendCallStatusUpdates (quint32 aCallId, CallState aState)
 
Hash callPeerFingerPrint (const VoiceCall &aCall) const
 
void removeCallFromArray (VoiceCallExtension &aCall)
 
void addCallToArray (VoiceCallExtension &aCall)
 
void sendCallStatusUpdateToRemote (const VoiceCall &aCall, bool aDoSign=true)
 
QString callStatusString (const VoiceCallExtension &aCall) const
 
bool checkForNodeValidity (const VoiceCall &aCallStatus, const Hash &aSendingNode) const
 
bool setupLocalAudioCapture (VoiceCallExtension &aCall)
 
bool setupAudioOutput (VoiceCallExtension &aCall)
 
bool addCallToMixer (const VoiceCallExtension &aCall)
 
bool removeCallFromMixer (const VoiceCallExtension &aCall)
 

Private Attributes

MControlleriController
 
ModeliModel
 
QList< MCallStatusObserver * > iCallObservers
 
QList< VoiceCallExtensioniOnGoingCalls
 
AudioMixeriMixer
 
AudioSourceiAudioSource
 
AudioPlayeriAudioPlayer
 
QList< QPair< VoiceCall, Hash > > iCallDataPendingProcessing
 

Additional Inherited Members

- Public Types inherited from MVoiceCallEngine
enum  CallState {
  Initial, Incoming, Open, Closing,
  Closed, Error, NoCall
}
 
enum  PayloadType { Audio =1, Control =2 }
 

Detailed Description

Network-related logic for handling voice channel between nodes.

"Voice call" is a bit different from persisted content handling: It happens between, nodes, not between operators. It has realtime- requirements and does not directly store anything on data storage.

This class contains networking-related logic and audio stream handling. Separate UI must be built on top of this. This inherits QAbstractTableModel to provide easy access for UI-components to calldata.

For actual call data handling see AudioMixer and other classes in the same directory.

Constructor & Destructor Documentation

◆ VoiceCallEngine()

VoiceCallEngine::VoiceCallEngine ( MController aController,
Model aModel 
)

Constructor

Parameters
aControllerapplication controller. not owned
aModelpersistent storage.

◆ ~VoiceCallEngine()

VoiceCallEngine::~VoiceCallEngine ( )

Destructor

Member Function Documentation

◆ acceptCall()

virtual void VoiceCallEngine::acceptCall ( quint32  aCallId)
virtual

Method called as result UI-action. This accepts an incoming call.

Implements MVoiceCallEngine.

◆ addCallToArray()

void VoiceCallEngine::addCallToArray ( VoiceCallExtension aCall)
private

◆ addCallToMixer()

bool VoiceCallEngine::addCallToMixer ( const VoiceCallExtension aCall)
private

method for conditioanally adding voice streams to mixer module

◆ audioFrameEncoded

void VoiceCallEngine::audioFrameEncoded ( quint32  aCallId,
quint32  aSeqNo,
const QByteArray &  aEncodedVoice,
Hash  aForNode 
)
slot

Voice data captured from microphone and mixed with other possible streams is delivered to over-the-network recipients using this slot. In practice input into this method comes from audio encoder and this method is responsible for distributing the encoded audio frame to all call participants.

◆ callPeerFingerPrint()

Hash VoiceCallEngine::callPeerFingerPrint ( const VoiceCall aCall) const
private

Method that returns the call peer node address: either destination or originating.

◆ callStateChanged

void VoiceCallEngine::callStateChanged ( quint32  aCallId,
VoiceCallEngine::CallState  aState 
)
signal

Signal for communicating call state changes

◆ callStatus()

virtual CallState VoiceCallEngine::callStatus ( quint32  aCallId) const
virtual

method for getting status of a call

Implements MVoiceCallEngine.

◆ callStatusString()

QString VoiceCallEngine::callStatusString ( const VoiceCallExtension aCall) const
private

◆ checkForNodeValidity()

bool VoiceCallEngine::checkForNodeValidity ( const VoiceCall aCallStatus,
const Hash aSendingNode 
) const
private

Method that checks that aCallStatus can be from aSendingNode

◆ closeCall()

virtual void VoiceCallEngine::closeCall ( quint32  aCallId)
virtual

Method called as result UI-action. This terminates ongoing call.

Implements MVoiceCallEngine.

◆ columnCount()

virtual int VoiceCallEngine::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

re-implemented from QAbstractTableModel

Returns
number of columns in view

◆ data()

virtual QVariant VoiceCallEngine::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

re-implemented from QAbstractListModel

Returns
data to display in list of ongoing calls

◆ error

void VoiceCallEngine::error ( QTcpSocket::SocketError  socketError)
signal

◆ excuseForCallCreation()

QString VoiceCallEngine::excuseForCallCreation ( const Hash aOperator,
const Hash aNode = KNullHash 
) const

Method for querying for an excuse why a call can (not) be made to particular operator or node

Parameters
aOperatoridentifier of operator whose call-creation status is queried.
aNodenode of the operator, if known
Returns
String telling if voice call can be made

◆ frameReady

void VoiceCallEngine::frameReady ( quint32  aCallId,
quint32  aSeqNo,
const QByteArray &  aRawAudio,
Hash  aForNode 
)
slot

This slot is called when mixer when audio frame is ready to be sent. In practice audio mixer emits a singal to this slot once for each node that is connected to same call.

Parameters
aCallIdis identifier of the call where this frame belongs to
aSeqNosequence number of packets in stream
aRawAudiois non-encoded audio frame, as array of floats
aForNodespecifies the node that will receive this particular audio frame.

◆ headerData()

virtual QVariant VoiceCallEngine::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual

re-implemented from QAbstractListModel

Returns
strings for headers of the call list UI

◆ inputLevel

void VoiceCallEngine::inputLevel ( float  aInputLevel)
signal

signal for communicating audio input (microphone) level

◆ insertCallData()

virtual void VoiceCallEngine::insertCallData ( quint32  aCallId,
quint32  aSeqNo,
PayloadType  aPayloadType,
const QByteArray &  aPayload,
Hash aSendingNode 
)
virtual

Method for reception of call real-time data. This is called from network-parts that receive the data packet over some protocol and then feed it here to make it heard.

Called from protocol parser. Parser does not lock datamodel prior to call.

Parameters
aCallIdis call ( stream ) identifier
aSeqNois sequence number of rt data in stream
aPayloadTypetells what kind of payload it is
aPayloadactual bytes
aSendingNodenode what sent the data package

Implements MVoiceCallEngine.

◆ insertCallStatusData()

virtual void VoiceCallEngine::insertCallStatusData ( const VoiceCall aCallStatus,
const Hash aSendingNode 
)
virtual

Method for reception of call status data. This is called from network-parts that receive the data packet over some protocol and then feed it here to move the call engine to some direction

Note that the call data inserted via this method may be call that this node originally made and at the receiving end this same method is used to inject the new incoming call into the engine.

Another note to take into consideration is the handling if node-data in aCallStatus. Call status is passed as reference so the ownership of the call data object instance is not tranferred into voice call engine. Inside call data there are 2 pointers to originating and destination nodes. Ownership of content of those pointers is not tranferred either. VoiceCallEngine will make local copies (if it sees that necessary) of the node-pointer contents and caller of this method will be responsible for deleting the node-objects in call-data if they were created only for the purpose of making a voice call.

DataModel.lock() should be called before calling this method

Parameters
aCallStatuscontains information about a call.
aSendingNodeis fingerprint of the node where the DTO is coming from. May be local node also.

Implements MVoiceCallEngine.

◆ installObserver()

virtual void VoiceCallEngine::installObserver ( MCallStatusObserver aObserver)
virtual

Method for installing call state observer

Implements MVoiceCallEngine.

◆ nodeConnectionAttemptStatus

void VoiceCallEngine::nodeConnectionAttemptStatus ( Connection::ConnectionState  aStatus,
const Hash  aHashOfAttemptedNode 
)
slot

This signal is about node-connection status and closed connections will be communicated using this same signal:

◆ onGoingCalls()

virtual QList<quint32> VoiceCallEngine::onGoingCalls ( ) const
virtual

method for getting identifiers of ongoing calls

Implements MVoiceCallEngine.

◆ outputLevel

void VoiceCallEngine::outputLevel ( float  aOutputLevel)
signal

signal for communicating audio output (spekar) level

◆ processCallData

void VoiceCallEngine::processCallData ( )
slot

slot that is called for call status data processing. reason for this slot is that we want to process status data in UI thread because we create QObjects there and want to delete them also in same thread, this easier to handle in Qt this way.

In practice, the call data is put into iCallDataPendingProcessing and this slot is called in queued manner

◆ removeCallFromArray()

void VoiceCallEngine::removeCallFromArray ( VoiceCallExtension aCall)
private

◆ removeCallFromMixer()

bool VoiceCallEngine::removeCallFromMixer ( const VoiceCallExtension aCall)
private

method for conditioanally removing voice streams from mixer module

◆ removeObserver()

virtual void VoiceCallEngine::removeObserver ( MCallStatusObserver aObserver)
virtual

Method for removing call state observer

Implements MVoiceCallEngine.

◆ rowCount()

virtual int VoiceCallEngine::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Methods inherited from QAbstractTableModel: rowCount

Returns
number of ongoing calls

◆ sendCallStatusUpdates()

void VoiceCallEngine::sendCallStatusUpdates ( quint32  aCallId,
CallState  aState 
)
private

call status gossip method

◆ sendCallStatusUpdateToRemote()

void VoiceCallEngine::sendCallStatusUpdateToRemote ( const VoiceCall aCall,
bool  aDoSign = true 
)
private

◆ setInputLevel

void VoiceCallEngine::setInputLevel ( float  aInputLevel)
slot

slot for setting audio input (microphone) level

◆ setOutputLevel

void VoiceCallEngine::setOutputLevel ( float  aOutputLevel)
slot

slot for setting audio output (spekar) level

◆ setupAudioOutput()

bool VoiceCallEngine::setupAudioOutput ( VoiceCallExtension aCall)
private

Method for setting up local audio output. If call has VoiceCall::iOkToProceed set to false, then output will be torn down.

◆ setupLocalAudioCapture()

bool VoiceCallEngine::setupLocalAudioCapture ( VoiceCallExtension aCall)
private

Method for setting up local audio capture. If call has VoiceCall::iOkToProceed set to false, then capture will be torn down.

◆ setupNewIncomingCall()

bool VoiceCallEngine::setupNewIncomingCall ( VoiceCallExtension aCall)
private

Called when a new call is initiated from remote node

◆ setupNewOutgoingCall()

bool VoiceCallEngine::setupNewOutgoingCall ( VoiceCallExtension aCall)
private

Called when a new call is initiated from local node

◆ startProcessCallData

void VoiceCallEngine::startProcessCallData ( )
signal

signal for starting processCallData

Member Data Documentation

◆ iAudioPlayer

AudioPlayer* VoiceCallEngine::iAudioPlayer
private

◆ iAudioSource

AudioSource* VoiceCallEngine::iAudioSource
private

◆ iCallDataPendingProcessing

QList<QPair<VoiceCall, Hash> > VoiceCallEngine::iCallDataPendingProcessing
private

◆ iCallObservers

QList<MCallStatusObserver*> VoiceCallEngine::iCallObservers
private

◆ iController

MController& VoiceCallEngine::iController
private

application controller

◆ iMixer

AudioMixer* VoiceCallEngine::iMixer
private

Exactly one audio mixer: has list of streams to mix. Idea is that list of mixed streams does not need to be same as list of ongoing calls. At least the local microphone input is additional stream

◆ iModel

Model& VoiceCallEngine::iModel
private

persistent storage

◆ iOnGoingCalls

QList<VoiceCallExtension> VoiceCallEngine::iOnGoingCalls
private

data about calls currently handled


The documentation for this class was generated from the following file: