dect
/
libdect
Archived
13
0
Fork 0

example: add PP CC example

Stripped down version of cc.c for PP-only usage.

Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
Patrick McHardy 2010-09-08 19:19:12 +02:00
parent 8c4fc03f20
commit 65a5d5582c
4 changed files with 101 additions and 1 deletions

3
.gitignore vendored
View File

@ -17,3 +17,6 @@ autom4te.cache
# Debian package build temporary files
build-stamp
# vim swap files
.*.swp

1
example/.gitignore vendored
View File

@ -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

View File

@ -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

89
example/pp-cc.c Normal file
View File

@ -0,0 +1,89 @@
/*
* DECT PP Call Control example
*
* Copyright (c) 2010 Patrick McHardy <kaber@trash.net>
*
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dect/libdect.h>
#include <timer.h>
#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, &param);
}
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;
}