-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyCall.cpp
72 lines (59 loc) · 2.13 KB
/
MyCall.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "MyCall.h"
#include <pjsua2.hpp>
#include <QDebug>
using namespace pj;
// Notification when call's state has changed.
void MyCall::onCallState(OnCallStateParam &prm)
{
Q_UNUSED(prm);
CallInfo ci = getInfo();
parent->emitCallStateChanged(ci.role, ci.id, ci.state, ci.lastStatusCode, QString::fromStdString(ci.remoteUri));
if(ci.state == PJSIP_INV_STATE_DISCONNECTED)
{
parent->setConnectDuration(ci.connectDuration.sec);
qDebug() << "deleting call with callId" << ci.id;
delete this;
}
}
// Notification when call's media state has changed.
void MyCall::onCallMediaState(OnCallMediaStateParam &prm)
{
Q_UNUSED(prm);
CallInfo ci = getInfo();
// Iterate all the call medias
for (unsigned i = 0; i < ci.media.size(); i++) {
if (ci.media[i].type == PJMEDIA_TYPE_AUDIO && getMedia(i)) {
audioMedia = (AudioMedia *)getMedia(i);
// Connect the call audio media to sound device
AudDevManager& mgr = Endpoint::instance().audDevManager();
audioMedia->startTransmit(mgr.getPlaybackDevMedia());
audioMedia->adjustRxLevel(1.0f);
audioMedia->adjustTxLevel(1.0f);
captureMedia = &(mgr.getCaptureDevMedia());
captureMedia->adjustRxLevel(1.0f);
captureMedia->adjustTxLevel(1.0f);
captureMedia->startTransmit(*audioMedia);
}
}
}
void MyCall::onCallTransferRequest(OnCallTransferRequestParam &prm)
{
Q_UNUSED(prm);
CallInfo ci = getInfo();
parent->emitCallStateChanged(ci.role, ci.id, ci.state, ci.lastStatusCode, QString::fromStdString(ci.remoteUri));
}
void MyCall::onCallTransferStatus(OnCallTransferStatusParam &prm)
{
Q_UNUSED(prm);
CallInfo ci = getInfo();
parent->emitCallStateChanged(ci.role, ci.id, ci.state, ci.lastStatusCode, QString::fromStdString(ci.remoteUri));
if(prm.statusCode == PJSIP_SC_OK)
{
qDebug() << "deleting call with callId" << ci.id;
delete this;
}
}
void MyCall::onCallReplaceRequest(OnCallReplaceRequestParam &prm)
{
qDebug() << "onCallReplaceRequest statusCode" << prm.statusCode;
}