mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-13 08:13:22 +00:00
Sync codec_zap with the one that is in the 1.4 branch so that it can actually
build here, too. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@58101 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -44,14 +44,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include "asterisk/zapata.h"
|
#include <zaptel/zaptel.h>
|
||||||
|
|
||||||
#include "asterisk/lock.h"
|
#include "asterisk/lock.h"
|
||||||
#include "asterisk/translate.h"
|
#include "asterisk/translate.h"
|
||||||
#include "asterisk/config.h"
|
#include "asterisk/config.h"
|
||||||
#include "asterisk/options.h"
|
#include "asterisk/options.h"
|
||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/cli.h"
|
|
||||||
#include "asterisk/logger.h"
|
#include "asterisk/logger.h"
|
||||||
#include "asterisk/channel.h"
|
#include "asterisk/channel.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
@@ -60,24 +59,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#define BUFFER_SAMPLES 8000
|
#define BUFFER_SAMPLES 8000
|
||||||
|
|
||||||
static unsigned int global_useplc = 0;
|
static unsigned int global_useplc = 0;
|
||||||
static int cardsmode = 0;
|
|
||||||
|
|
||||||
static int totalchannels = 0;
|
|
||||||
static int complexinuse = 0;
|
|
||||||
static int simpleinuse = 0;
|
|
||||||
AST_MUTEX_DEFINE_STATIC(channelcount);
|
|
||||||
|
|
||||||
static const char show_transcoder_usage[] =
|
|
||||||
"Usage: show transcoder\n"
|
|
||||||
" Displays transcoder utilization.\n";
|
|
||||||
|
|
||||||
static int show_transcoder(int fd, int argc, char *argv[]);
|
|
||||||
|
|
||||||
static struct ast_cli_entry transcoder_cli[] = {
|
|
||||||
{ { "show", "transcoder", NULL},
|
|
||||||
show_transcoder, "Displays transcoder utilization.",
|
|
||||||
show_transcoder_usage }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct format_map {
|
struct format_map {
|
||||||
unsigned int map[32][32];
|
unsigned int map[32][32];
|
||||||
@@ -90,12 +71,11 @@ struct translator {
|
|||||||
AST_LIST_ENTRY(translator) entry;
|
AST_LIST_ENTRY(translator) entry;
|
||||||
};
|
};
|
||||||
|
|
||||||
static AST_LIST_HEAD_STATIC(zap_translators, translator);
|
static AST_LIST_HEAD_STATIC(translators, translator);
|
||||||
|
|
||||||
struct pvt {
|
struct pvt {
|
||||||
int fd;
|
int fd;
|
||||||
int fake;
|
int fake;
|
||||||
int inuse;
|
|
||||||
#ifdef DEBUG_TRANSCODE
|
#ifdef DEBUG_TRANSCODE
|
||||||
int totalms;
|
int totalms;
|
||||||
int lasttotalms;
|
int lasttotalms;
|
||||||
@@ -104,31 +84,6 @@ struct pvt {
|
|||||||
struct ast_frame f;
|
struct ast_frame f;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void activate_translator(int simple);
|
|
||||||
static void deactivate_translator(int simple);
|
|
||||||
|
|
||||||
|
|
||||||
static int show_transcoder(int fd, int argc, char *argv[])
|
|
||||||
{
|
|
||||||
ast_mutex_lock(&channelcount);
|
|
||||||
|
|
||||||
if (!totalchannels) {
|
|
||||||
ast_cli(fd, "No transcoder card registered\n");
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
return RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!cardsmode)
|
|
||||||
ast_cli(fd, "%d/%d encoders/decoders of %d channels (G.729a / G.723.1 5.3 kbps) are in use.\n", complexinuse, simpleinuse, totalchannels);
|
|
||||||
else if (cardsmode == 1)
|
|
||||||
ast_cli(fd, "%d/%d encoders/decoders of %d channels (G.729a) are in use.\n", complexinuse, simpleinuse, totalchannels);
|
|
||||||
else if (cardsmode == 2)
|
|
||||||
ast_cli(fd, "%d/%d encoders/decoders of %d channels (G.723.1 5.3 kbps) are in use.\n", complexinuse, simpleinuse, totalchannels);
|
|
||||||
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
return RESULT_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int zap_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
|
static int zap_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
|
||||||
{
|
{
|
||||||
struct pvt *ztp = pvt->pvt;
|
struct pvt *ztp = pvt->pvt;
|
||||||
@@ -145,12 +100,12 @@ static int zap_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
|
|||||||
/* Copy at front of buffer */
|
/* Copy at front of buffer */
|
||||||
hdr->srcoffset = 0;
|
hdr->srcoffset = 0;
|
||||||
|
|
||||||
if ((hdr->srclen + f->datalen) > sizeof(hdr->srcdata)) {
|
if (hdr->srclen + f->datalen > sizeof(hdr->srcdata)) {
|
||||||
ast_log(LOG_WARNING, "Out of space for codec translation!\n");
|
ast_log(LOG_WARNING, "Out of space for codec translation!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((hdr->srclen + f->datalen + hdr->srcoffset) > sizeof(hdr->srcdata)) {
|
if (hdr->srclen + f->datalen + hdr->srcoffset > sizeof(hdr->srcdata)) {
|
||||||
/* Very unlikely */
|
/* Very unlikely */
|
||||||
memmove(hdr->srcdata, hdr->srcdata + hdr->srcoffset, hdr->srclen);
|
memmove(hdr->srcdata, hdr->srcdata + hdr->srcoffset, hdr->srclen);
|
||||||
hdr->srcoffset = 0;
|
hdr->srcoffset = 0;
|
||||||
@@ -160,7 +115,7 @@ static int zap_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
|
|||||||
hdr->srclen += f->datalen;
|
hdr->srclen += f->datalen;
|
||||||
pvt->samples += f->samples;
|
pvt->samples += f->samples;
|
||||||
|
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct ast_frame *zap_frameout(struct ast_trans_pvt *pvt)
|
static struct ast_frame *zap_frameout(struct ast_trans_pvt *pvt)
|
||||||
@@ -173,7 +128,7 @@ static struct ast_frame *zap_frameout(struct ast_trans_pvt *pvt)
|
|||||||
ztp->fake = 1;
|
ztp->fake = 1;
|
||||||
ztp->f.frametype = AST_FRAME_VOICE;
|
ztp->f.frametype = AST_FRAME_VOICE;
|
||||||
ztp->f.subclass = 0;
|
ztp->f.subclass = 0;
|
||||||
ztp->f.samples = 240;
|
ztp->f.samples = 160;
|
||||||
ztp->f.data = NULL;
|
ztp->f.data = NULL;
|
||||||
ztp->f.offset = 0;
|
ztp->f.offset = 0;
|
||||||
ztp->f.datalen = 0;
|
ztp->f.datalen = 0;
|
||||||
@@ -186,7 +141,7 @@ static struct ast_frame *zap_frameout(struct ast_trans_pvt *pvt)
|
|||||||
#ifdef DEBUG_TRANSCODE
|
#ifdef DEBUG_TRANSCODE
|
||||||
ztp->totalms += hdr->dstsamples;
|
ztp->totalms += hdr->dstsamples;
|
||||||
if ((ztp->totalms - ztp->lasttotalms) > 8000) {
|
if ((ztp->totalms - ztp->lasttotalms) > 8000) {
|
||||||
ast_verbose("Whee %p, %d (%d to %d)\n", ztp, hdr->dstlen, ztp->lasttotalms, ztp->totalms);
|
printf("Whee %p, %d (%d to %d)\n", ztp, hdr->dstlen, ztp->lasttotalms, ztp->totalms);
|
||||||
ztp->lasttotalms = ztp->totalms;
|
ztp->lasttotalms = ztp->totalms;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -217,26 +172,8 @@ static struct ast_frame *zap_frameout(struct ast_trans_pvt *pvt)
|
|||||||
static void zap_destroy(struct ast_trans_pvt *pvt)
|
static void zap_destroy(struct ast_trans_pvt *pvt)
|
||||||
{
|
{
|
||||||
struct pvt *ztp = pvt->pvt;
|
struct pvt *ztp = pvt->pvt;
|
||||||
unsigned int x;
|
|
||||||
|
|
||||||
x = ZT_TCOP_RELEASE;
|
|
||||||
if (ioctl(ztp->fd, ZT_TRANSCODE_OP, &x))
|
|
||||||
ast_log(LOG_WARNING, "Failed to release transcoder channel: %s\n", strerror(errno));
|
|
||||||
|
|
||||||
munmap(ztp->hdr, sizeof(*ztp->hdr));
|
munmap(ztp->hdr, sizeof(*ztp->hdr));
|
||||||
if(ztp->inuse) {
|
|
||||||
ast_mutex_lock(&channelcount);
|
|
||||||
if(pvt->t->dstfmt == 8 || pvt->t->dstfmt == 0) {
|
|
||||||
if(complexinuse == totalchannels)
|
|
||||||
activate_translator(0);
|
|
||||||
complexinuse--;
|
|
||||||
} else {
|
|
||||||
if(simpleinuse == totalchannels)
|
|
||||||
activate_translator(1);
|
|
||||||
simpleinuse--;
|
|
||||||
}
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
}
|
|
||||||
close(ztp->fd);
|
close(ztp->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,19 +181,19 @@ static int zap_translate(struct ast_trans_pvt *pvt, int dest, int source)
|
|||||||
{
|
{
|
||||||
/* Request translation through zap if possible */
|
/* Request translation through zap if possible */
|
||||||
int fd;
|
int fd;
|
||||||
unsigned int x = ZT_TCOP_RESET;
|
unsigned int x = ZT_TCOP_ALLOCATE;
|
||||||
struct pvt *ztp = pvt->pvt;
|
struct pvt *ztp = pvt->pvt;
|
||||||
struct zt_transcode_header *hdr;
|
struct zt_transcode_header *hdr;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
if ((fd = open("/dev/zap/transcode", O_RDWR)) < 0)
|
if ((fd = open("/dev/zap/transcode", O_RDWR)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
flags = fcntl(fd, F_GETFL);
|
flags = fcntl(fd, F_GETFL);
|
||||||
if (flags > - 1) {
|
if (flags > - 1) {
|
||||||
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
|
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK))
|
||||||
ast_log(LOG_WARNING, "Could not set non-block mode!\n");
|
ast_log(LOG_WARNING, "Could not set non-block mode!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((hdr = mmap(NULL, sizeof(*hdr), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
|
if ((hdr = mmap(NULL, sizeof(*hdr), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) {
|
||||||
ast_log(LOG_ERROR, "Memory Map failed for transcoding (%s)\n", strerror(errno));
|
ast_log(LOG_ERROR, "Memory Map failed for transcoding (%s)\n", strerror(errno));
|
||||||
@@ -283,31 +220,6 @@ static int zap_translate(struct ast_trans_pvt *pvt, int dest, int source)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ast_mutex_lock(&channelcount);
|
|
||||||
if(pvt->t->dstfmt == 8 || pvt->t->dstfmt == 0 ) {
|
|
||||||
if (complexinuse == totalchannels) {
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
munmap(hdr, sizeof(*hdr));
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
complexinuse++;
|
|
||||||
if(complexinuse == totalchannels)
|
|
||||||
deactivate_translator(0);
|
|
||||||
} else {
|
|
||||||
if (simpleinuse == totalchannels) {
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
munmap(hdr, sizeof(*hdr));
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
simpleinuse++;
|
|
||||||
if(simpleinuse == totalchannels)
|
|
||||||
deactivate_translator(1);
|
|
||||||
}
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
ztp->inuse = 1;
|
|
||||||
|
|
||||||
ztp = pvt->pvt;
|
ztp = pvt->pvt;
|
||||||
ztp->fd = fd;
|
ztp->fd = fd;
|
||||||
ztp->hdr = hdr;
|
ztp->hdr = hdr;
|
||||||
@@ -325,7 +237,7 @@ static struct ast_frame *fakesrc_sample(void)
|
|||||||
/* Don't bother really trying to test hardware ones. */
|
/* Don't bother really trying to test hardware ones. */
|
||||||
static struct ast_frame f = {
|
static struct ast_frame f = {
|
||||||
.frametype = AST_FRAME_VOICE,
|
.frametype = AST_FRAME_VOICE,
|
||||||
.samples = 240,
|
.samples = 160,
|
||||||
.src = __PRETTY_FUNCTION__
|
.src = __PRETTY_FUNCTION__
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -339,8 +251,7 @@ static int register_translator(int dst, int src)
|
|||||||
|
|
||||||
if (!(zt = ast_calloc(1, sizeof(*zt))))
|
if (!(zt = ast_calloc(1, sizeof(*zt))))
|
||||||
return -1;
|
return -1;
|
||||||
if (!((cardsmode == 1 && (dst == 8 || src == 8)) || (cardsmode == 2 && (dst == 0 || src == 0)) || (cardsmode == 0)))
|
|
||||||
return -1;
|
|
||||||
snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s",
|
snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s",
|
||||||
ast_getformatname((1 << src)), ast_getformatname((1 << dst)));
|
ast_getformatname((1 << src)), ast_getformatname((1 << dst)));
|
||||||
zt->t.srcfmt = (1 << src);
|
zt->t.srcfmt = (1 << src);
|
||||||
@@ -358,9 +269,9 @@ static int register_translator(int dst, int src)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
AST_LIST_LOCK(&zap_translators);
|
AST_LIST_LOCK(&translators);
|
||||||
AST_LIST_INSERT_HEAD(&zap_translators, zt, entry);
|
AST_LIST_INSERT_HEAD(&translators, zt, entry);
|
||||||
AST_LIST_UNLOCK(&zap_translators);
|
AST_LIST_UNLOCK(&translators);
|
||||||
|
|
||||||
global_format_map.map[dst][src] = 1;
|
global_format_map.map[dst][src] = 1;
|
||||||
|
|
||||||
@@ -371,83 +282,40 @@ static void drop_translator(int dst, int src)
|
|||||||
{
|
{
|
||||||
struct translator *cur;
|
struct translator *cur;
|
||||||
|
|
||||||
AST_LIST_LOCK(&zap_translators);
|
AST_LIST_LOCK(&translators);
|
||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&zap_translators, cur, entry) {
|
AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) {
|
||||||
if (cur->t.srcfmt != src)
|
if (cur->t.srcfmt != src)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (cur->t.dstfmt != dst)
|
if (cur->t.dstfmt != dst)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AST_LIST_REMOVE_CURRENT(&zap_translators, entry);
|
AST_LIST_REMOVE_CURRENT(&translators, entry);
|
||||||
ast_unregister_translator(&cur->t);
|
ast_unregister_translator(&cur->t);
|
||||||
free(cur);
|
free(cur);
|
||||||
global_format_map.map[dst][src] = 0;
|
global_format_map.map[dst][src] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AST_LIST_TRAVERSE_SAFE_END;
|
AST_LIST_TRAVERSE_SAFE_END;
|
||||||
AST_LIST_UNLOCK(&zap_translators);
|
AST_LIST_UNLOCK(&translators);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unregister_translators(void)
|
static void unregister_translators(void)
|
||||||
{
|
{
|
||||||
struct translator *cur;
|
struct translator *cur;
|
||||||
|
|
||||||
AST_LIST_LOCK(&zap_translators);
|
AST_LIST_LOCK(&translators);
|
||||||
while ((cur = AST_LIST_REMOVE_HEAD(&zap_translators, entry))) {
|
while ((cur = AST_LIST_REMOVE_HEAD(&translators, entry))) {
|
||||||
ast_unregister_translator(&cur->t);
|
ast_unregister_translator(&cur->t);
|
||||||
free(cur);
|
free(cur);
|
||||||
}
|
}
|
||||||
AST_LIST_UNLOCK(&zap_translators);
|
AST_LIST_UNLOCK(&translators);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void activate_translator(int simple)
|
|
||||||
{
|
|
||||||
struct translator *cur;
|
|
||||||
|
|
||||||
AST_LIST_LOCK(&zap_translators);
|
|
||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&zap_translators, cur, entry) {
|
|
||||||
if(!simple) {
|
|
||||||
if (cur->t.dstfmt == 0 || cur->t.dstfmt == 8) {
|
|
||||||
ast_translator_activate(&cur->t);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(cur->t.dstfmt == 2 || cur->t.dstfmt == 3) {
|
|
||||||
ast_translator_activate(&cur->t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AST_LIST_TRAVERSE_SAFE_END;
|
|
||||||
AST_LIST_UNLOCK(&zap_translators);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void deactivate_translator(int simple)
|
|
||||||
{
|
|
||||||
struct translator *cur;
|
|
||||||
|
|
||||||
AST_LIST_LOCK(&zap_translators);
|
|
||||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&zap_translators, cur, entry) {
|
|
||||||
if(!simple) {
|
|
||||||
if (cur->t.dstfmt == 0 || cur->t.dstfmt == 8) {
|
|
||||||
ast_translator_deactivate(&cur->t);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(cur->t.dstfmt == 2 || cur->t.dstfmt == 3) {
|
|
||||||
ast_translator_deactivate(&cur->t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AST_LIST_TRAVERSE_SAFE_END;
|
|
||||||
AST_LIST_UNLOCK(&zap_translators);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_config(void)
|
static void parse_config(void)
|
||||||
{
|
{
|
||||||
struct ast_variable *var;
|
struct ast_variable *var;
|
||||||
struct ast_config *cfg = ast_config_load("codecs.conf");
|
struct ast_config *cfg = ast_config_load("codecs.conf");
|
||||||
cardsmode = 0;
|
|
||||||
|
|
||||||
if (!cfg)
|
if (!cfg)
|
||||||
return;
|
return;
|
||||||
@@ -460,21 +328,11 @@ static void parse_config(void)
|
|||||||
global_useplc ? "" : "not ");
|
global_useplc ? "" : "not ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (var = ast_variable_browse(cfg, "transcoder_card"); var; var = var->next) {
|
|
||||||
if (!strcasecmp(var->name, "mode")) {
|
|
||||||
if(strstr(var->value, "g729"))
|
|
||||||
cardsmode = 1;
|
|
||||||
else if(strstr(var->value, "g723"))
|
|
||||||
cardsmode = 2;
|
|
||||||
else if(strstr(var->value, "mixed"))
|
|
||||||
cardsmode = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ast_config_destroy(cfg);
|
ast_config_destroy(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts)
|
static void build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts)
|
||||||
{
|
{
|
||||||
unsigned int src, dst;
|
unsigned int src, dst;
|
||||||
|
|
||||||
@@ -491,11 +349,8 @@ static int build_translators(struct format_map *map, unsigned int dstfmts, unsig
|
|||||||
|
|
||||||
if (!register_translator(dst, src))
|
if (!register_translator(dst, src))
|
||||||
map->map[dst][src] = 1;
|
map->map[dst][src] = 1;
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_transcoders(void)
|
static int find_transcoders(void)
|
||||||
@@ -513,12 +368,7 @@ static int find_transcoders(void)
|
|||||||
for (info.tcnum = 0; !(res = ioctl(fd, ZT_TRANSCODE_OP, &info)); info.tcnum++) {
|
for (info.tcnum = 0; !(res = ioctl(fd, ZT_TRANSCODE_OP, &info)); info.tcnum++) {
|
||||||
if (option_verbose > 1)
|
if (option_verbose > 1)
|
||||||
ast_verbose(VERBOSE_PREFIX_2 "Found transcoder '%s'.\n", info.name);
|
ast_verbose(VERBOSE_PREFIX_2 "Found transcoder '%s'.\n", info.name);
|
||||||
|
build_translators(&map, info.dstfmts, info.srcfmts);
|
||||||
if(build_translators(&map, info.dstfmts, info.srcfmts)) {
|
|
||||||
ast_mutex_lock(&channelcount);
|
|
||||||
totalchannels += info.numchannels;
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@@ -531,9 +381,7 @@ static int find_transcoders(void)
|
|||||||
drop_translator(x, y);
|
drop_translator(x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast_mutex_lock(&channelcount);
|
|
||||||
totalchannels = totalchannels/2;
|
|
||||||
ast_mutex_unlock(&channelcount);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,10 +392,10 @@ static int reload(void)
|
|||||||
parse_config();
|
parse_config();
|
||||||
find_transcoders();
|
find_transcoders();
|
||||||
|
|
||||||
AST_LIST_LOCK(&zap_translators);
|
AST_LIST_LOCK(&translators);
|
||||||
AST_LIST_TRAVERSE(&zap_translators, cur, entry)
|
AST_LIST_TRAVERSE(&translators, cur, entry)
|
||||||
cur->t.useplc = global_useplc;
|
cur->t.useplc = global_useplc;
|
||||||
AST_LIST_UNLOCK(&zap_translators);
|
AST_LIST_UNLOCK(&translators);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -555,17 +403,15 @@ static int reload(void)
|
|||||||
static int unload_module(void)
|
static int unload_module(void)
|
||||||
{
|
{
|
||||||
unregister_translators();
|
unregister_translators();
|
||||||
ast_cli_unregister_multiple(transcoder_cli, sizeof(transcoder_cli) / sizeof(struct ast_cli_entry));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_module(void)
|
static int load_module(void)
|
||||||
{
|
{
|
||||||
ast_mutex_init(&channelcount);
|
|
||||||
parse_config();
|
parse_config();
|
||||||
|
|
||||||
find_transcoders();
|
find_transcoders();
|
||||||
ast_cli_register_multiple(transcoder_cli, sizeof(transcoder_cli) / sizeof(struct ast_cli_entry));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user