[asterisk-commits] file: branch group/media_formats r408294 - /team/group/media_formats/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Feb 18 06:45:06 CST 2014
Author: file
Date: Tue Feb 18 06:45:04 2014
New Revision: 408294
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=408294
Log:
Move chan_nbs over.
Modified:
team/group/media_formats/channels/chan_nbs.c
Modified: team/group/media_formats/channels/chan_nbs.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/channels/chan_nbs.c?view=diff&rev=408294&r1=408293&r2=408294
==============================================================================
--- team/group/media_formats/channels/chan_nbs.c (original)
+++ team/group/media_formats/channels/chan_nbs.c Tue Feb 18 06:45:04 2014
@@ -47,11 +47,9 @@
#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";
-
-/* Only linear is allowed */
-static struct ast_format prefformat;
static char context[AST_MAX_EXTENSION] = "default";
static const char type[] = "NBS";
@@ -63,7 +61,6 @@
struct ast_channel *owner; /* Channel we belong to, possibly NULL */
char app[16]; /* Our app */
char stream[80]; /* Our stream */
- struct ast_frame fr; /* "null" frame */
struct ast_module_user *u; /*! for holding a reference to this module */
};
@@ -178,37 +175,14 @@
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);
-
-
- /* Some nice norms */
- p->fr.datalen = 0;
- p->fr.samples = 0;
- p->fr.data.ptr = NULL;
- p->fr.src = type;
- p->fr.offset = 0;
- p->fr.mallocd=0;
- p->fr.delivery.tv_sec = 0;
- p->fr.delivery.tv_usec = 0;
-
- ast_debug(1, "Returning null frame on %s\n", ast_channel_name(ast));
-
- return &p->fr;
-}
-
-static int nbs_xwrite(struct ast_channel *ast, struct ast_frame *frame)
-{
- struct nbs_pvt *p = ast_channel_tech_pvt(ast);
- /* Write a frame of (presumably voice) data */
- if (frame->frametype != AST_FRAME_VOICE) {
- if (frame->frametype != AST_FRAME_IMAGE)
- ast_log(LOG_WARNING, "Don't know what to do with frame type '%d'\n", frame->frametype);
- return 0;
- }
- if (frame->subclass.format.id != (AST_FORMAT_SLINEAR)) {
- ast_log(LOG_WARNING, "Cannot handle frames in %s format\n", ast_getformatname(&frame->subclass.format));
- return 0;
- }
if (ast_channel_state(ast) != AST_STATE_UP) {
/* Don't try tos end audio on-hook */
return 0;
@@ -226,11 +200,11 @@
ast_channel_tech_set(tmp, &nbs_tech);
ast_channel_set_fd(tmp, 0, nbs_fd(i->nbs));
- ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
- ast_format_copy(ast_channel_rawreadformat(tmp), &prefformat);
- ast_format_copy(ast_channel_rawwriteformat(tmp), &prefformat);
- ast_format_copy(ast_channel_writeformat(tmp), &prefformat);
- ast_format_copy(ast_channel_readformat(tmp), &prefformat);
+ 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);
@@ -257,7 +231,7 @@
struct nbs_pvt *p;
struct ast_channel *tmp = NULL;
- if (!(ast_format_cap_iscompatible(cap, &prefformat))) {
+ if (!(ast_format_cap_iscompatible_format(cap, ast_format_slin))) {
char tmp[256];
ast_log(LOG_NOTICE, "Asked to get a channel of unsupported format '%s'\n", ast_getformatname_multiple(tmp, sizeof(tmp), cap));
return NULL;
@@ -275,17 +249,17 @@
{
/* First, take us out of the channel loop */
ast_channel_unregister(&nbs_tech);
- nbs_tech.capabilities = ast_format_cap_destroy(nbs_tech.capabilities);
+ ao2_ref(nbs_tech.capabilities, -1);
+ nbs_tech.capabilities = NULL;
return 0;
}
static int load_module(void)
{
- ast_format_set(&prefformat, AST_FORMAT_SLINEAR, 0);
- if (!(nbs_tech.capabilities = ast_format_cap_alloc(0))) {
+ if (!(nbs_tech.capabilities = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT))) {
return AST_MODULE_LOAD_FAILURE;
}
- ast_format_cap_add(nbs_tech.capabilities, &prefformat);
+ ast_format_cap_add(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);
More information about the asterisk-commits
mailing list