Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video call support #8

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ RM = @RM@ -fr
INSTALL = @INSTALL@
CHMOD = chmod

# -DAST_MODULE=\"$(PROJM)\" -D_THREAD_SAFE
CFLAGS = @CFLAGS@ -I$(srcdir) @CPPFLAGS@ @DEFS@ @AC_CFLAGS@
DEFS = -DASTERISK_VERSION_NUM=110000
CFLAGS = @CFLAGS@ -I$(srcdir) @CPPFLAGS@ $(DEFS) @DEFS@ @AC_CFLAGS@
LDFLAGS = @LDFLAGS@
SOLINK = @SOLINK@
LIBS = @LIBS@
Expand Down
2 changes: 1 addition & 1 deletion app.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <asterisk/app.h> /* AST_DECLARE_APP_ARGS() ... */
#include <asterisk/pbx.h> /* pbx_builtin_setvar_helper() */
#include <asterisk/module.h> /* ast_register_application2() ast_unregister_application() */
#include <asterisk/version.h> /* ASTERISK_VERSION_NUM */
#include <asterisk/ast_version.h> /* ASTERISK_VERSION_NUM */

#include "app.h" /* app_register() app_unregister() */
#include "chan_dongle.h" /* struct pvt */
Expand Down
9 changes: 6 additions & 3 deletions at_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -851,14 +851,15 @@ static int start_pbx(struct pvt* pvt, const char * number, int call_idx, call_st

return -1;
}
cpvt = channel->tech_pvt;

cpvt = ast_channel_tech_pvt(channel);
// FIXME: not execute if channel_new() failed
CPVT_SET_FLAGS(cpvt, CALL_FLAG_NEED_HANGUP);

// ast_pbx_start() usually failed if asterisk.conf minmemfree set too low, try drop buffer cache sync && echo 3 > /proc/sys/vm/drop_caches
if (ast_pbx_start (channel))
{
channel->tech_pvt = NULL;
ast_channel_tech_pvt_set(channel, NULL);
cpvt_free(cpvt);

ast_hangup (channel);
Expand Down Expand Up @@ -920,7 +921,9 @@ static int at_response_clcc (struct pvt* pvt, char* str)
if(cpvt->channel)
{
/* FIXME: unprotected channel access */
cpvt->channel->rings += pvt->rings;
int rings = ast_channel_rings(cpvt->channel);
rings += pvt->rings;
ast_channel_rings_set(cpvt->channel, rings);
pvt->rings = 0;
}
}
Expand Down
19 changes: 19 additions & 0 deletions chan_dongle.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <asterisk.h>
ASTERISK_FILE_VERSION(__FILE__, "$Rev: " PACKAGE_REVISION " $")

#include <asterisk/ast_version.h>
#include <asterisk/stringfields.h> /* AST_DECLARE_STRING_FIELDS for asterisk/manager.h */
#include <asterisk/manager.h>
#include <asterisk/dsp.h>
Expand Down Expand Up @@ -71,6 +72,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Rev: " PACKAGE_REVISION " $")

EXPORT_DEF const char * const dev_state_strs[4] = { "stop", "restart", "remove", "start" };
EXPORT_DEF public_state_t * gpublic;
EXPORT_DEF struct ast_format chan_dongle_format;
EXPORT_DEF struct ast_format_cap * chan_dongle_format_cap;


static int public_state_init(struct public_state * state);
Expand Down Expand Up @@ -1659,6 +1662,16 @@ static int public_state_init(struct public_state * state)
rv = AST_MODULE_LOAD_FAILURE;
if(discovery_restart(state) == 0)
{
#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
/* set preferred capabilities */
ast_format_set(&chan_dongle_format, AST_FORMAT_SLINEAR, 0);
if (!(channel_tech.capabilities = ast_format_cap_alloc())) {
return AST_MODULE_LOAD_FAILURE;
}
ast_format_cap_add(channel_tech.capabilities, &chan_dongle_format);
chan_dongle_format_cap = channel_tech.capabilities;
#endif

/* register our channel type */
if(ast_channel_register(&channel_tech) == 0)
{
Expand All @@ -1671,6 +1684,9 @@ static int public_state_init(struct public_state * state)
}
else
{
#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
channel_tech.capabilities = ast_format_cap_destroy(channel_tech.capabilities);
#endif
ast_log (LOG_ERROR, "Unable to register channel class %s\n", channel_tech.type);
}
discovery_stop(state);
Expand Down Expand Up @@ -1698,6 +1714,9 @@ static void public_state_fini(struct public_state * state)
{
/* First, take us out of the channel loop */
ast_channel_unregister (&channel_tech);
#if ASTERISK_VERSION_NUM >= 100000 /* 10+ */
channel_tech.capabilities = ast_format_cap_destroy(channel_tech.capabilities);
#endif

/* Unregister the CLI & APP & MANAGER */

Expand Down
3 changes: 3 additions & 0 deletions chan_dongle.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ INLINE_DECL const char * dev_state2str_msg(dev_state_t state)
return enum2str(state, states, ITEMS_OF(states));
}

/* Only linear is allowed */
EXPORT_DECL struct ast_format chan_dongle_format;
EXPORT_DECL struct ast_format_cap * chan_dongle_format_cap;

typedef enum {
RESTATE_TIME_NOW = 0,
Expand Down
Loading