Skip to content

Commit

Permalink
Merge fa5fb2e into 6f20723
Browse files Browse the repository at this point in the history
  • Loading branch information
kingster authored Oct 28, 2020
2 parents 6f20723 + fa5fb2e commit 1f0d035
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ build_script:
cd E:\tinyphone
sed -i 's/stampver.inf.*\$/stampver.inf $/g' tinyphone.vcxproj
cat tinyphone.vcxproj
msbuild /m tinyphone.sln /p:Configuration=$BuildMode /p:Platform=x86
if ($LastExitCode -ne 0) { $host.SetShouldExit($LastExitCode) }
Expand Down
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"metricsProto" : "UDP",
"metricsServerHosts" : ["10.32.194.187", "10.32.110.41", "10.47.192.13"],
"metricsServerPort" : 8125,
"autoDeviceRefresh" : true
"autoDeviceRefresh" : true,
"autoAnswer" : true
}
11 changes: 7 additions & 4 deletions tinyphone/account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,19 @@ namespace tp {
SIPCall *call = new SIPCall(*this, iprm.callId);
CallInfo ci = call->getInfo();
try {
CallOpParam prm;

PJ_LOG(3, (__FILENAME__, "Incoming Call: [%s] [%s]", ci.remoteUri.c_str(), ci.stateText.c_str()));

eventStream->publishEvent(ci, iprm);

calls.push_back(call);
prm.statusCode = pjsip_status_code::PJSIP_SC_OK;
call->answer(prm);
onCallEstablished(call);

if(ApplicationConfig.autoAnswer){
CallOpParam prm;
prm.statusCode = pjsip_status_code::PJSIP_SC_OK;
call->answer(prm);
onCallEstablished(call);
}
}
catch (...) {
PJ_LOG(3, (__FILENAME__, "ERROR Answering IncomingCall [%s]", ci.remoteUri.c_str()));
Expand Down
3 changes: 3 additions & 0 deletions tinyphone/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace tp {
int metricsServerPort;

bool autoDeviceRefresh;
bool autoAnswer;


std::string ua(){
Expand Down Expand Up @@ -104,6 +105,7 @@ namespace tp {
{"metricsServerHosts", p.metricsServerHosts },
{"metricsServerPort", p.metricsServerPort },
{"autoDeviceRefresh", p.autoDeviceRefresh },
{"autoAnswer", p.autoAnswer },
};
}

Expand Down Expand Up @@ -138,6 +140,7 @@ namespace tp {
j.at("metricsProto").get_to(p.metricsProto);
j.at("metricsServerPort").get_to(p.metricsServerPort);
j.at("autoDeviceRefresh").get_to(p.autoDeviceRefresh);
j.at("autoAnswer").get_to(p.autoAnswer);
}

extern appConfig ApplicationConfig;
Expand Down
25 changes: 25 additions & 0 deletions tinyphone/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,31 @@ void TinyPhoneHttpServer::Start() {
}
});


CROW_ROUTE(app, "/calls/<int>/answer")
.methods("POST"_method)
([&phone](int call_id) {
pj_thread_auto_register();

SIPCall* call = phone.CallById(call_id);
if (call == nullptr) {
return tp::response(400, {
{ "message", "Call Not Found" },
{"call_id" , call_id}
});
}
else {
CallOpParam prm;
prm.statusCode = pjsip_status_code::PJSIP_SC_OK;
call->answer(prm);
json response = {
{ "message", "Answer Triggered" },
{ "call_id" , call_id }
};
return tp::response(200, response);
}
});

CROW_ROUTE(app, "/calls/<int>/hold")
.methods("PUT"_method, "DELETE"_method)
([&phone](const crow::request& req, int call_id) {
Expand Down

0 comments on commit 1f0d035

Please sign in to comment.