commit 09adab9729c47d6107d0c632dd02663223b28939
parent 337acc7327641a9d511019dfacb4955c9f277e88
Author: FRIGN <dev@frign.de>
Date: Sun, 12 Oct 2014 19:14:45 +0200
Further simplify call-start-callbacks
using the udata-void pointers to pass data as a source of information.
Diffstat:
M | ratox.c | | | 37 | ++++++++----------------------------- |
1 file changed, 8 insertions(+), 29 deletions(-)
diff --git a/ratox.c b/ratox.c
@@ -214,10 +214,9 @@ static void logmsg(const char *, ...);
static void fiforeset(int, int *, struct file);
static ssize_t fiforead(int, int *, struct file, void *, size_t);
static void cbcallinvite(void *, int32_t, void *);
-static void cbcallstarted(void *, int32_t, void *);
+static void cbcallstart(void *, int32_t, void *);
static void cbcallterminate(void *, int32_t, void *);
static void preparetxcall(struct friend *);
-static void cbcallstarting(void *, int32_t, void *);
static void cbpeertimeout(void *, int32_t, void *);
static void cbcalltypechange(void *, int32_t, void *);
static void cbcalldata(ToxAv *, int32_t, int16_t *, int, void *);
@@ -390,7 +389,7 @@ cbcallinvite(void *av, int32_t cnum, void *udata)
}
static void
-cbcallstarted(void *av, int32_t cnum, void *udata)
+cbcallstart(void *av, int32_t cnum, void *type)
{
struct friend *f;
int r;
@@ -401,13 +400,15 @@ cbcallstarted(void *av, int32_t cnum, void *udata)
if (!f)
return;
+ if(!strncmp(type, "Tx", 2))
+ preparetxcall(f);
r = toxav_prepare_transmission(toxav, cnum, av_jbufdc, av_VADd, 0);
if (r < 0) {
- weprintf("Failed to prepare Rx AV transmission\n");
+ weprintf("Failed to prepare %s AV transmission\n", type);
cancelcall(f, "Failed");
return;
}
- logmsg(": %s : Rx AV > Started\n", f->name);
+ logmsg(": %s : %s AV > Started\n", f->name, type);
}
static void
@@ -436,28 +437,6 @@ preparetxcall(struct friend *f)
}
static void
-cbcallstarting(void *av, int32_t cnum, void *udata)
-{
- struct friend *f;
- int r;
-
- TAILQ_FOREACH(f, &friendhead, entry)
- if (f->av.num == cnum)
- break;
- if (!f)
- return;
-
- preparetxcall(f);
- r = toxav_prepare_transmission(toxav, cnum, av_jbufdc, av_VADd, 0);
- if (r < 0) {
- weprintf("Failed to prepare Tx AV transmission\n");
- cancelcall(f, "Failed");
- return;
- }
- logmsg(": %s : Tx AV > Started\n", f->name);
-}
-
-static void
cbpeertimeout(void *av, int32_t cnum, void *udata)
{
struct friend *f;
@@ -1217,12 +1196,12 @@ toxinit(void)
tox_callback_file_data(tox, cbfiledata, NULL);
toxav_register_callstate_callback(toxav, cbcallinvite, av_OnInvite, NULL);
- toxav_register_callstate_callback(toxav, cbcallstarted, av_OnStart, NULL);
+ toxav_register_callstate_callback(toxav, cbcallstart, av_OnStart, "Rx");
toxav_register_callstate_callback(toxav, cbcallterminate, av_OnEnd, "Ended");
toxav_register_callstate_callback(toxav, cbcallterminate, av_OnCancel, "Cancelled");
toxav_register_callstate_callback(toxav, cbcallterminate, av_OnReject, "Rejected");
- toxav_register_callstate_callback(toxav, cbcallstarting, av_OnStarting, NULL);
+ toxav_register_callstate_callback(toxav, cbcallstart, av_OnStarting, "Tx");
toxav_register_callstate_callback(toxav, cbcallterminate, av_OnEnding, "Ending");
toxav_register_callstate_callback(toxav, cbcallterminate, av_OnRequestTimeout, "Request timeout");