[Asterisk-code-review] chan_nbs: Remove deprecated module. (asterisk[master])

George Joseph asteriskteam at digium.com
Wed Aug 18 11:12:56 CDT 2021


George Joseph has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/16320 )

Change subject: chan_nbs: Remove deprecated module.
......................................................................

chan_nbs: Remove deprecated module.

ASTERISK-29595

Change-Id: Ib5c7d43a780f2fb94cee90738e4c1af211ae4a33
---
M build_tools/menuselect-deps.in
D channels/chan_nbs.c
M configure
M configure.ac
M contrib/scripts/install_prereq
A doc/UPGRADE-staging/chan_nbs_removal.txt
M include/asterisk/autoconfig.h.in
M makeopts.in
8 files changed, 6 insertions(+), 426 deletions(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index f809106..a1a2742 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -36,7 +36,6 @@
 LUA=@PBX_LUA@
 MISDN=@PBX_MISDN@
 MYSQLCLIENT=@PBX_MYSQLCLIENT@
-NBS=@PBX_NBS@
 NETSNMP=@PBX_NETSNMP@
 NEWT=@PBX_NEWT@
 NEON=@PBX_NEON@
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
deleted file mode 100644
index c7c842a..0000000
--- a/channels/chan_nbs.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2006, Digium, Inc.
- *
- * Mark Spencer <markster at digium.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
-/*! \file
- *
- * \brief Network broadcast sound support channel driver
- *
- * \author Mark Spencer <markster at digium.com>
- *
- * \ingroup channel_drivers
- */
-
-/*** MODULEINFO
-	<depend>nbs</depend>
-	<support_level>deprecated</support_level>
-	<deprecated_in>16</deprecated_in>
-	<removed_in>19</removed_in>
- ***/
-
-#include "asterisk.h"
-
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <arpa/inet.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <nbs.h>
-
-#include "asterisk/lock.h"
-#include "asterisk/channel.h"
-#include "asterisk/config.h"
-#include "asterisk/module.h"
-#include "asterisk/pbx.h"
-#include "asterisk/utils.h"
-#include "asterisk/format_cache.h"
-
-static const char tdesc[] = "Network Broadcast Sound Driver";
-
-static char context[AST_MAX_EXTENSION] = "default";
-static const char type[] = "NBS";
-
-/* NBS creates private structures on demand */
-
-struct nbs_pvt {
-	NBS *nbs;
-	struct ast_channel *owner;		/* Channel we belong to, possibly NULL */
-	char app[16];					/* Our app */
-	char stream[80];				/* Our stream */
-	struct ast_module_user *u;		/*! for holding a reference to this module */
-};
-
-static struct ast_channel *nbs_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause);
-static int nbs_call(struct ast_channel *ast, const char *dest, int timeout);
-static int nbs_hangup(struct ast_channel *ast);
-static struct ast_frame *nbs_xread(struct ast_channel *ast);
-static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame);
-
-static struct ast_channel_tech nbs_tech = {
-	.type = type,
-	.description = tdesc,
-	.requester = nbs_request,
-	.call = nbs_call,
-	.hangup = nbs_hangup,
-	.read = nbs_xread,
-	.write = nbs_xwrite,
-};
-
-static int nbs_call(struct ast_channel *ast, const char *dest, int timeout)
-{
-	struct nbs_pvt *p;
-
-	p = ast_channel_tech_pvt(ast);
-
-	if ((ast_channel_state(ast) != AST_STATE_DOWN) && (ast_channel_state(ast) != AST_STATE_RESERVED)) {
-		ast_log(LOG_WARNING, "nbs_call called on %s, neither down nor reserved\n", ast_channel_name(ast));
-		return -1;
-	}
-	/* When we call, it just works, really, there's no destination...  Just
-	   ring the phone and wait for someone to answer */
-	ast_debug(1, "Calling %s on %s\n", dest, ast_channel_name(ast));
-
-	/* If we can't connect, return congestion */
-	if (nbs_connect(p->nbs)) {
-		ast_log(LOG_WARNING, "NBS Connection failed on %s\n", ast_channel_name(ast));
-		ast_queue_control(ast, AST_CONTROL_CONGESTION);
-	} else {
-		ast_setstate(ast, AST_STATE_RINGING);
-		ast_queue_control(ast, AST_CONTROL_ANSWER);
-	}
-
-	return 0;
-}
-
-static void nbs_destroy(struct nbs_pvt *p)
-{
-	if (p->nbs)
-		nbs_delstream(p->nbs);
-	ast_module_user_remove(p->u);
-	ast_free(p);
-}
-
-static struct nbs_pvt *nbs_alloc(const char *data)
-{
-	struct nbs_pvt *p;
-	int flags = 0;
-	char stream[256];
-	char *opts;
-
-	ast_copy_string(stream, data, sizeof(stream));
-	if ((opts = strchr(stream, ':'))) {
-		*opts = '\0';
-		opts++;
-	} else
-		opts = "";
-	p = ast_calloc(1, sizeof(*p));
-	if (p) {
-		if (!ast_strlen_zero(opts)) {
-			if (strchr(opts, 'm'))
-				flags |= NBS_FLAG_MUTE;
-			if (strchr(opts, 'o'))
-				flags |= NBS_FLAG_OVERSPEAK;
-			if (strchr(opts, 'e'))
-				flags |= NBS_FLAG_EMERGENCY;
-			if (strchr(opts, 'O'))
-				flags |= NBS_FLAG_OVERRIDE;
-		} else
-			flags = NBS_FLAG_OVERSPEAK;
-
-		ast_copy_string(p->stream, stream, sizeof(p->stream));
-		p->nbs = nbs_newstream("asterisk", stream, flags);
-		if (!p->nbs) {
-			ast_log(LOG_WARNING, "Unable to allocate new NBS stream '%s' with flags %d\n", stream, flags);
-			ast_free(p);
-			p = NULL;
-		} else {
-			/* Set for 8000 hz mono, 640 samples */
-			nbs_setbitrate(p->nbs, 8000);
-			nbs_setchannels(p->nbs, 1);
-			nbs_setblocksize(p->nbs, 640);
-			nbs_setblocking(p->nbs, 0);
-		}
-	}
-	return p;
-}
-
-static int nbs_hangup(struct ast_channel *ast)
-{
-	struct nbs_pvt *p;
-	p = ast_channel_tech_pvt(ast);
-	ast_debug(1, "nbs_hangup(%s)\n", ast_channel_name(ast));
-	if (!ast_channel_tech_pvt(ast)) {
-		ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
-		return 0;
-	}
-	nbs_destroy(p);
-	ast_channel_tech_pvt_set(ast, NULL);
-	ast_setstate(ast, AST_STATE_DOWN);
-	return 0;
-}
-
-static struct ast_frame  *nbs_xread(struct ast_channel *ast)
-{
-	ast_debug(1, "Returning null frame on %s\n", ast_channel_name(ast));
-
-	return &ast_null_frame;
-}
-
-static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame)
-{
-	struct nbs_pvt *p = ast_channel_tech_pvt(ast);
-	if (ast_channel_state(ast) != AST_STATE_UP) {
-		/* Don't try tos end audio on-hook */
-		return 0;
-	}
-	if (nbs_write(p->nbs, frame->data.ptr, frame->datalen / 2) < 0)
-		return -1;
-	return 0;
-}
-
-static struct ast_channel *nbs_new(struct nbs_pvt *i, int state, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor)
-{
-	struct ast_channel *tmp;
-	tmp = ast_channel_alloc(1, state, 0, 0, "", "s", context, assignedids, requestor, 0, "NBS/%s", i->stream);
-	if (tmp) {
-		ast_channel_tech_set(tmp, &nbs_tech);
-		ast_channel_set_fd(tmp, 0, nbs_fd(i->nbs));
-
-		ast_channel_nativeformats_set(tmp, nbs_tech.capabilities);
-		ast_channel_set_rawreadformat(tmp, ast_format_slin);
-		ast_channel_set_rawwriteformat(tmp, ast_format_slin);
-		ast_channel_set_writeformat(tmp, ast_format_slin);
-		ast_channel_set_readformat(tmp, ast_format_slin);
-		if (state == AST_STATE_RING)
-			ast_channel_rings_set(tmp, 1);
-		ast_channel_tech_pvt_set(tmp, i);
-		ast_channel_context_set(tmp, context);
-		ast_channel_exten_set(tmp, "s");
-		ast_channel_language_set(tmp, "");
-		i->owner = tmp;
-		i->u = ast_module_user_add(tmp);
-		ast_channel_unlock(tmp);
-		if (state != AST_STATE_DOWN) {
-			if (ast_pbx_start(tmp)) {
-				ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ast_channel_name(tmp));
-				ast_hangup(tmp);
-			}
-		}
-	} else
-		ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
-	return tmp;
-}
-
-
-static struct ast_channel *nbs_request(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
-{
-	struct nbs_pvt *p;
-	struct ast_channel *tmp = NULL;
-
-	if (ast_format_cap_iscompatible_format(cap, ast_format_slin) == AST_FORMAT_CMP_NOT_EQUAL) {
-		struct ast_str *cap_buf = ast_str_alloca(AST_FORMAT_CAP_NAMES_LEN);
-
-		ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n",
-			ast_format_cap_get_names(cap, &cap_buf));
-		return NULL;
-	}
-	p = nbs_alloc(data);
-	if (p) {
-		tmp = nbs_new(p, AST_STATE_DOWN, assignedids, requestor);
-		if (!tmp)
-			nbs_destroy(p);
-	}
-	return tmp;
-}
-
-static int unload_module(void)
-{
-	/* First, take us out of the channel loop */
-	ast_channel_unregister(&nbs_tech);
-	ao2_ref(nbs_tech.capabilities, -1);
-	nbs_tech.capabilities = NULL;
-	return 0;
-}
-
-static int load_module(void)
-{
-	if (!(nbs_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
-		return AST_MODULE_LOAD_DECLINE;
-	}
-	ast_format_cap_append(nbs_tech.capabilities, ast_format_slin, 0);
-	/* Make sure we can register our channel type */
-	if (ast_channel_register(&nbs_tech)) {
-		ast_log(LOG_ERROR, "Unable to register channel class %s\n", type);
-		ao2_ref(nbs_tech.capabilities, -1);
-		nbs_tech.capabilities = NULL;
-		return AST_MODULE_LOAD_DECLINE;
-	}
-	return AST_MODULE_LOAD_SUCCESS;
-}
-
-AST_MODULE_INFO_STANDARD_DEPRECATED(ASTERISK_GPL_KEY, "Network Broadcast Sound Support");
diff --git a/configure b/configure
index c06dd7e..78ed454 100755
--- a/configure
+++ b/configure
@@ -1034,10 +1034,6 @@
 NEON_DIR
 NEON_INCLUDE
 NEON_LIB
-PBX_NBS
-NBS_DIR
-NBS_INCLUDE
-NBS_LIB
 PBX_MYSQLCLIENT
 MYSQLCLIENT_DIR
 MYSQLCLIENT_INCLUDE
@@ -1411,7 +1407,6 @@
 with_lua
 with_misdn
 with_mysqlclient
-with_nbs
 with_neon
 with_neon29
 with_netsnmp
@@ -2184,7 +2179,6 @@
   --with-lua=PATH         use Lua files in PATH
   --with-misdn=PATH       use mISDN user files in PATH
   --with-mysqlclient=PATH use MySQL client files in PATH
-  --with-nbs=PATH         use Network Broadcast Sound files in PATH
   --with-neon=PATH        use neon files in PATH
   --with-neon29=PATH      use neon29 files in PATH
   --with-netsnmp=PATH     use Net-SNMP files in PATH
@@ -10918,38 +10912,6 @@
 
 
 
-    NBS_DESCRIP="Network Broadcast Sound"
-    NBS_OPTION="nbs"
-    PBX_NBS=0
-
-# Check whether --with-nbs was given.
-if test "${with_nbs+set}" = set; then :
-  withval=$with_nbs;
-	case ${withval} in
-	n|no)
-	USE_NBS=no
-	# -1 is a magic value used by menuselect to know that the package
-	# was disabled, other than 'not found'
-	PBX_NBS=-1
-	;;
-	y|ye|yes)
-	ac_mandatory_list="${ac_mandatory_list} NBS"
-	;;
-	*)
-	NBS_DIR="${withval}"
-	ac_mandatory_list="${ac_mandatory_list} NBS"
-	;;
-	esac
-
-fi
-
-
-
-
-
-
-
-
     NEON_DESCRIP="neon"
     NEON_OPTION="neon"
     PBX_NEON=0
@@ -22852,103 +22814,6 @@
 fi
 
 
-if test "x${PBX_NBS}" != "x1" -a "${USE_NBS}" != "no"; then
-   pbxlibdir=""
-   # if --with-NBS=DIR has been specified, use it.
-   if test "x${NBS_DIR}" != "x"; then
-      if test -d ${NBS_DIR}/lib; then
-         pbxlibdir="-L${NBS_DIR}/lib"
-      else
-         pbxlibdir="-L${NBS_DIR}"
-      fi
-   fi
-
-      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
-      CFLAGS="${CFLAGS} "
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nbs_connect in -lnbs" >&5
-$as_echo_n "checking for nbs_connect in -lnbs... " >&6; }
-if ${ac_cv_lib_nbs_nbs_connect+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnbs ${pbxlibdir}  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char nbs_connect ();
-int
-main ()
-{
-return nbs_connect ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_nbs_nbs_connect=yes
-else
-  ac_cv_lib_nbs_nbs_connect=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nbs_nbs_connect" >&5
-$as_echo "$ac_cv_lib_nbs_nbs_connect" >&6; }
-if test "x$ac_cv_lib_nbs_nbs_connect" = xyes; then :
-  AST_NBS_FOUND=yes
-else
-  AST_NBS_FOUND=no
-fi
-
-      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
-
-
-   # now check for the header.
-   if test "${AST_NBS_FOUND}" = "yes"; then
-      NBS_LIB="${pbxlibdir} -lnbs "
-      # if --with-NBS=DIR has been specified, use it.
-      if test "x${NBS_DIR}" != "x"; then
-         NBS_INCLUDE="-I${NBS_DIR}/include"
-      fi
-      NBS_INCLUDE="${NBS_INCLUDE} "
-
-         # check for the header
-         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
-         CPPFLAGS="${CPPFLAGS} ${NBS_INCLUDE}"
-         ac_fn_c_check_header_mongrel "$LINENO" "nbs.h" "ac_cv_header_nbs_h" "$ac_includes_default"
-if test "x$ac_cv_header_nbs_h" = xyes; then :
-  NBS_HEADER_FOUND=1
-else
-  NBS_HEADER_FOUND=0
-fi
-
-
-         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
-
-      if test "x${NBS_HEADER_FOUND}" = "x0" ; then
-         NBS_LIB=""
-         NBS_INCLUDE=""
-      else
-
-         PBX_NBS=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_NBS 1
-_ACEOF
-
-      fi
-   fi
-fi
-
-
-
-
 		if test "x${PBX_NEON}" != "x1" -a "${USE_NEON}" != "no"; then
 		PBX_NEON=0
 		if test -n "$ac_tool_prefix"; then
diff --git a/configure.ac b/configure.ac
index 0a1370c..fa62e4a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -514,7 +514,6 @@
 AC_ARG_VAR([LUA_VERSIONS],[A space separated list of target lua versions to test.])
 AST_EXT_LIB_SETUP([MISDN], [mISDN user], [misdn])
 AST_EXT_LIB_SETUP([MYSQLCLIENT], [MySQL client], [mysqlclient])
-AST_EXT_LIB_SETUP([NBS], [Network Broadcast Sound], [nbs])
 AST_EXT_LIB_SETUP([NEON], [neon], [neon])
 AST_EXT_LIB_SETUP([NEON29], [neon29], [neon29])
 AST_EXT_LIB_SETUP([NETSNMP], [Net-SNMP], [netsnmp])
@@ -2300,8 +2299,6 @@
    )
 fi
 
-AST_EXT_LIB_CHECK([NBS], [nbs], [nbs_connect], [nbs.h])
-
 AST_EXT_TOOL_CHECK([NEON], [neon-config])
 
 AST_EXT_TOOL_CHECK([NEON29], [neon-config], , [--libs],
diff --git a/contrib/scripts/install_prereq b/contrib/scripts/install_prereq
index 98e9350..3d9cbcc 100755
--- a/contrib/scripts/install_prereq
+++ b/contrib/scripts/install_prereq
@@ -331,12 +331,6 @@
 }
 
 install_unpackaged() {
-	echo "*** Installing NBS (Network Broadcast Sound) ***"
-	svn co https://svn.digium.com/svn/nbs/trunk nbs-trunk
-	cd nbs-trunk
-	make all install
-	cd ..
-
 	# Only install libresample if it wasn't installed via package
 	if ! test -f /usr/include/libresample.h; then
 		echo "*** Installing libresample ***"
diff --git a/doc/UPGRADE-staging/chan_nbs_removal.txt b/doc/UPGRADE-staging/chan_nbs_removal.txt
new file mode 100644
index 0000000..46ae758
--- /dev/null
+++ b/doc/UPGRADE-staging/chan_nbs_removal.txt
@@ -0,0 +1,6 @@
+Subject: chan_nbs
+Master-Only: True
+
+This module was deprecated in Asterisk 16
+and is now being removed in accordance with
+the Asterisk Module Deprecation policy.
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index c8225e2..d61c85c 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -543,9 +543,6 @@
 /* Define to 1 if mysql/mysql.h has my_bool defined. */
 #undef HAVE_MYSQLCLIENT_MY_BOOL
 
-/* Define to 1 if you have the Network Broadcast Sound library. */
-#undef HAVE_NBS
-
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #undef HAVE_NDIR_H
 
diff --git a/makeopts.in b/makeopts.in
index 01c0da0..886a409 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -201,9 +201,6 @@
 MYSQLCLIENT_INCLUDE=@MYSQLCLIENT_INCLUDE@
 MYSQLCLIENT_LIB=@MYSQLCLIENT_LIB@
 
-NBS_INCLUDE=@NBS_INCLUDE@
-NBS_LIB=@NBS_LIB@
-
 NEON_INCLUDE=@NEON_INCLUDE@
 NEON_LIB=@NEON_LIB@
 NEON29_INCLUDE=@NEON_INCLUDE@

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16320
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Change-Id: Ib5c7d43a780f2fb94cee90738e4c1af211ae4a33
Gerrit-Change-Number: 16320
Gerrit-PatchSet: 2
Gerrit-Owner: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Sean Bright <sean at seanbright.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210818/f2d00e0f/attachment-0001.html>


More information about the asterisk-code-review mailing list