siproc

A primitive SIP client that spawns processes for each call
git clone git://xatko.vsos.ethz.ch/siproc.git
Log | Files | Refs | README | LICENSE

commit 87865cacdd9f24a606050cf5e9142f48a195faee
parent aaba845392ac1d37786166ca3cde8420ac5901c4
Author: Dominik Schmidt <dominik@schm1dt.ch>
Date:   Sat, 16 Nov 2019 21:37:04 +0100

Use pjsip logging facilities throughout the code.

Diffstat:
Msrc/siproc.cpp | 22+++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/siproc.cpp b/src/siproc.cpp @@ -82,13 +82,14 @@ ssize_t readall(int fd, char **buffer, size_t *buffer_length){ offset += ret; } if(ret == -1){ - perror("read"); - printf("ADDRESS: %p, %lu\n", *buffer, *buffer_length); + PJ_LOG(1, ("Failed to read from fd: %s\n"\ + "ADDRESS: %p, %lu\n", strerror(errno), *buffer, *buffer_length)); return -1; } return offset + ret; } + EV ev_table = EV(); using namespace pj; @@ -402,7 +403,7 @@ class MyCall: public Call{ void handle_line(){ PJ_LOG(3, ("MyCall", "Handling line")); ssize_t ret = readall(c_stdout, &line, &line_length); - printf("Read %lu bytes\n", ret); + PJ_LOG(6, ("MyCall", "Read %lu bytes", ret)); if(ret < 0){ throw "Error reading from stdout"; } @@ -553,13 +554,13 @@ int main(int argc, char **argv){ } char *prio = strstr(name, ":"); if(prio == NULL){ - fprintf(stderr, "Codecs string malformed. Should be <name>:<prio>[,<name>:<prio>...]"); - break; + PJ_LOG(1, ("Main", "Codecs string malformed. Should be <name>:<prio>[,<name>:<prio>...]")); + return 1; } *prio++='\0'; int prio_i = atoi(prio); if(prio_i < 0 || prio_i > 255){ - fprintf(stderr, "Codec priority must be in [0,255]"); + PJ_LOG(1, ("Main", "Codec priority must be in [0,255]")); } ep.codecSetPriority(string(name), prio_i); } @@ -573,7 +574,7 @@ int main(int argc, char **argv){ try { ep.transportCreate(PJSIP_TRANSPORT_UDP, tcfg); } catch(Error &err){ - std::cerr << err.info() << std::endl; + PJ_LOG(1, ("Setup", "Error setting up transport: %s", err.info().c_str())); return 1; } @@ -596,9 +597,8 @@ int main(int argc, char **argv){ if(ptr == &line_length){ ssize_t bytes = getline(&line, &line_length, stdin); if(bytes > 0){ - printf("Got line with length %lu:\n", bytes); - fwrite(line, 1, bytes, stdout); line[--bytes] = '\0'; + PJ_LOG(6, ("Main", "Got line with length %lu: %s", bytes, line)); size_t cmdlen=line_length; char *args = strstr(line, " "); if(args){ @@ -610,7 +610,7 @@ int main(int argc, char **argv){ break; } else if(strncmp(line, "CALL", cmdlen) == 0){ - printf("Making call\n"); + PJ_LOG(4, ("Main", "Placing call to %s", args)); MyCall *mc = new MyCall(*acc); CallOpParam prm(true); try{ @@ -630,7 +630,7 @@ int main(int argc, char **argv){ delete acc; } catch(char const *c){ - printf("EXCEPTION: %s\n", c); + PJ_LOG(1, ("Main", "Fatal Exception: %s",c)); } return 0;