From 65a5d5582c876e9538816deb80ebdf22bc3293e1 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Wed, 8 Sep 2010 19:19:12 +0200 Subject: [PATCH] example: add PP CC example Stripped down version of cc.c for PP-only usage. Signed-off-by: Patrick McHardy --- .gitignore | 3 ++ example/.gitignore | 1 + example/Makefile.in | 9 ++++- example/pp-cc.c | 89 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 example/pp-cc.c diff --git a/.gitignore b/.gitignore index bb67d8b..ef61a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ autom4te.cache # Debian package build temporary files build-stamp + +# vim swap files +.*.swp diff --git a/example/.gitignore b/example/.gitignore index 201baa6..f87aec3 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -10,6 +10,7 @@ pp-access-rights-terminate pp-location-update pp-detach pp-info-request +pp-cc pp-list-access pp-clms pp-wait-page diff --git a/example/Makefile.in b/example/Makefile.in index b431ce6..7bd6527 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -3,7 +3,8 @@ LDFLAGS += -Wl,-rpath $(PWD)/src -Lsrc -ldect $(EVENT_LDFLAGS) PROGRAMS += cc ss hijack PROGRAMS += fp-mm fp-clms fp-broadcast-page PROGRAMS += pp-access-rights pp-access-rights-terminate pp-location-update -PROGRAMS += pp-detach pp-info-request pp-list-access pp-clms pp-wait-page +PROGRAMS += pp-detach pp-info-request pp-cc pp-list-access pp-clms +PROGRAMS += pp-wait-page destdir := usr/share/dect/examples @@ -52,6 +53,12 @@ pp-info-request-destdir := $(destdir) pp-info-request-obj += $(pp-common-obj) pp-info-request-obj += pp-info-request.o +pp-cc-destdir := $(destdir) +pp-cc-obj += $(pp-common-obj) +pp-cc-obj += audio.o +pp-cc-obj += pp-cc.o +pp-cc-ldflags += -lSDL + pp-list-access-destdir := $(destdir) pp-list-access-obj += $(pp-common-obj) pp-list-access-obj += pp-list-access.o diff --git a/example/pp-cc.c b/example/pp-cc.c new file mode 100644 index 0000000..e23d82c --- /dev/null +++ b/example/pp-cc.c @@ -0,0 +1,89 @@ +/* + * DECT PP Call Control example + * + * Copyright (c) 2010 Patrick McHardy + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include + +#include +#include +#include "common.h" + +struct call { + struct dect_audio_handle *audio; +}; + +static void dect_mncc_reject_ind(struct dect_handle *dh, struct dect_call *call, + struct dect_mncc_release_param *param) +{ + dect_event_loop_stop(); +} + +static void dect_mncc_release_ind(struct dect_handle *dh, struct dect_call *call, + struct dect_mncc_release_param *param) +{ + dect_mncc_release_res(dh, call, param); + dect_event_loop_stop(); +} + +static void dect_open_call(struct dect_handle *dh, const struct dect_ipui *ipui) +{ + struct dect_ie_basic_service basic_service; + struct dect_mncc_setup_param param = { + .basic_service = &basic_service, + }; + struct dect_call *call; + struct call *priv; + + call = dect_call_alloc(dh); + if (call == NULL) + return; + priv = dect_call_priv(call); + + priv->audio = dect_audio_open(); + if (priv->audio == NULL) + return; + + basic_service.class = DECT_CALL_CLASS_NORMAL; + basic_service.service = DECT_SERVICE_BASIC_SPEECH_DEFAULT; + + dect_mncc_setup_req(dh, call, ipui, ¶m); +} + +static void dect_dl_u_data_ind(struct dect_handle *dh, struct dect_call *call, + struct dect_msg_buf *mb) +{ + struct call *priv = dect_call_priv(call); + + dect_dl_u_data_req(dh, call, mb); + dect_audio_queue(priv->audio, mb); +} + +static struct dect_cc_ops cc_ops = { + .priv_size = sizeof(struct call), + .mncc_reject_ind = dect_mncc_reject_ind, + .mncc_release_ind = dect_mncc_release_ind, + .dl_u_data_ind = dect_dl_u_data_ind, +}; + +static struct dect_ops ops = { + .cc_ops = &cc_ops, +}; + +int main(int argc, char **argv) +{ + dect_pp_common_options(argc, argv); + dect_pp_common_init(&ops, cluster, &ipui); + + dect_open_call(dh, &ipui); + + dect_event_loop(); + dect_common_cleanup(dh); + return 0; +}