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)
 
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, const 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
 
AudioEncoderiEncoder
 
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 ( MController aController,
Model aModel 
)

Constructor

Parameters
aControllerapplication controller. not owned
aModelpersistent storage.
VoiceCallEngine::~VoiceCallEngine ( )

Destructor

Member Function Documentation

virtual void VoiceCallEngine::acceptCall ( quint32  aCallId)
virtual

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

Implements MVoiceCallEngine.

void VoiceCallEngine::addCallToArray ( VoiceCallExtension aCall)
private
bool VoiceCallEngine::addCallToMixer ( const VoiceCallExtension aCall)
private

method for conditioanally adding voice streams to mixer module

void VoiceCallEngine::audioFrameEncoded ( quint32  aCallId,
quint32  aSeqNo,
const QByteArray &  aEncodedVoice 
)
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.

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

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

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

Signal for communicating call state changes

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

method for getting status of a call

Implements MVoiceCallEngine.

QString VoiceCallEngine::callStatusString ( const VoiceCallExtension aCall) const
private
bool VoiceCallEngine::checkForNodeValidity ( const VoiceCall aCallStatus,
const Hash aSendingNode 
) const
private

Method that checks that aCallStatus can be from aSendingNode

virtual void VoiceCallEngine::closeCall ( quint32  aCallId)
virtual

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

Implements MVoiceCallEngine.

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

re-implemented from QAbstractTableModel

Returns
number of columns in view
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
void VoiceCallEngine::error ( QTcpSocket::SocketError  socketError)
signal
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
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
void VoiceCallEngine::inputLevel ( float  aInputLevel)
signal

signal for communicating audio input (microphone) level

virtual void VoiceCallEngine::insertCallData ( quint32  aCallId,
quint32  aSeqNo,
PayloadType  aPayloadType,
const QByteArray &  aPayload,
const 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.

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.

virtual void VoiceCallEngine::installObserver ( MCallStatusObserver aObserver)
virtual

Method for installing call state observer

Implements MVoiceCallEngine.

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:

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

method for getting identifiers of ongoing calls

Implements MVoiceCallEngine.

void VoiceCallEngine::outputLevel ( float  aOutputLevel)
signal

signal for communicating audio output (spekar) level

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

void VoiceCallEngine::removeCallFromArray ( VoiceCallExtension aCall)
private
bool VoiceCallEngine::removeCallFromMixer ( const VoiceCallExtension aCall)
private

method for conditioanally removing voice streams from mixer module

virtual void VoiceCallEngine::removeObserver ( MCallStatusObserver aObserver)
virtual

Method for removing call state observer

Implements MVoiceCallEngine.

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

Methods inherited from QAbstractTableModel: rowCount

Returns
number of ongoing calls
void VoiceCallEngine::sendCallStatusUpdates ( quint32  aCallId,
CallState  aState 
)
private

call status gossip method

void VoiceCallEngine::sendCallStatusUpdateToRemote ( const VoiceCall aCall,
bool  aDoSign = true 
)
private
void VoiceCallEngine::setInputLevel ( float  aInputLevel)
slot

slot for setting audio input (microphone) level

void VoiceCallEngine::setOutputLevel ( float  aOutputLevel)
slot

slot for setting audio output (spekar) level

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.

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.

bool VoiceCallEngine::setupNewIncomingCall ( VoiceCallExtension aCall)
private

Called when a new call is initiated from remote node

bool VoiceCallEngine::setupNewOutgoingCall ( VoiceCallExtension aCall)
private

Called when a new call is initiated from local node

void VoiceCallEngine::startProcessCallData ( )
signal

signal for starting processCallData

Member Data Documentation

AudioPlayer* VoiceCallEngine::iAudioPlayer
private
AudioSource* VoiceCallEngine::iAudioSource
private
QList<QPair<VoiceCall, Hash> > VoiceCallEngine::iCallDataPendingProcessing
private
QList<MCallStatusObserver*> VoiceCallEngine::iCallObservers
private
MController& VoiceCallEngine::iController
private

application controller

AudioEncoder* VoiceCallEngine::iEncoder
private

Each node that we have call with will receive identical audio e.g. the mixer output. For this reason only one audio encoder is needed

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

Model& VoiceCallEngine::iModel
private

persistent storage

QList<VoiceCallExtension> VoiceCallEngine::iOnGoingCalls
private

data about calls currently handled


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