codec_opus: Replace res_format_attr_opus with the one from codec_opus

Preparation

Change-Id: I9f20e7cce00c32464d9a180e81283d49d199d0a3
This commit is contained in:
George Joseph
2016-07-23 13:50:37 -06:00
committed by Kevin Harwell
parent 47689998a9
commit 59f7662a93
2 changed files with 227 additions and 178 deletions

View File

@@ -18,24 +18,47 @@
/*! /*!
* \file * \file
* \brief Opus Format Attributes (http://tools.ietf.org/html/draft-ietf-payload-rtp-opus) * \brief Codec opus externals and format attributes
* *
* \author Lorenzo Miniero <lorenzo@meetecho.com> * RFC - https://tools.ietf.org/rfc/rfc7587.txt
*/ */
#ifndef _AST_FORMAT_OPUS_H_ #ifndef _AST_FORMAT_OPUS_H_
#define _AST_FORMAT_OPUS_H_ #define _AST_FORMAT_OPUS_H_
/*! Opus format attribute key value pairs, all are accessible through ast_format_get_value()*/ /*! \brief Maximum sampling rate an endpoint is capable of receiving */
enum opus_attr_keys { #define CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE "maxplaybackrate"
OPUS_ATTR_KEY_MAX_BITRATE, /*! value is an int (6000-510000 in spec). */ /*! \brief An alias for maxplaybackrate (used in older versions) */
OPUS_ATTR_KEY_MAX_PLAYRATE, /*! value is an int (8000-48000), maximum output rate the receiver can render. */ #define CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH "maxcodedaudiobandwidth"
OPUS_ATTR_KEY_MINPTIME, /*! value is an int (3-120 in spec, 10-60 in format.c), decoder's minimum length of time in milliseconds. */ /*! \brief Maximum sampling rate an endpoint is capable of sending */
OPUS_ATTR_KEY_STEREO, /*! value is an int, 1 prefer receiving stereo, 0 prefer mono. */ #define CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE "sprop-maxcapturerate"
OPUS_ATTR_KEY_CBR, /*! value is an int, 1 use constant bitrate, 0 use variable bitrate. */ /*! \brief Maximum duration of packet (in milliseconds) */
OPUS_ATTR_KEY_FEC, /*! value is an int, 1 encode with FEC, 0 do not use FEC. */ #define CODEC_OPUS_ATTR_MAX_PTIME "maxptime"
OPUS_ATTR_KEY_DTX, /*! value is an int, 1 dtx is enabled, 0 dtx not enabled. */ /*! \brief Duration of packet (in milliseconds) */
OPUS_ATTR_KEY_SPROP_CAPTURE_RATE, /*! value is an int (8000-48000), likely input rate we're going to produce. */ #define CODEC_OPUS_ATTR_PTIME "ptime"
OPUS_ATTR_KEY_SPROP_STEREO, /*! value is an int, 1 likely to send stereo, 0 likely to send mono. */ /*! \brief Maximum average received bit rate (in bits per second) */
}; #define CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE "maxaveragebitrate"
/*! \brief Decode stereo (1) vs mono (0) */
#define CODEC_OPUS_ATTR_STEREO "stereo"
/*! \brief Likeliness of sender producing stereo (1) vs mono (0) */
#define CODEC_OPUS_ATTR_SPROP_STEREO "sprop-stereo"
/*! \brief Decoder prefers a constant (1) vs variable (0) bitrate */
#define CODEC_OPUS_ATTR_CBR "cbr"
/*! \brief Use forward error correction (1) or not (0) */
#define CODEC_OPUS_ATTR_FEC "useinbandfec"
/*! \brief Use discontinuous transmission (1) or not (0) */
#define CODEC_OPUS_ATTR_DTX "usedtx"
/*! \brief Custom data object */
#define CODEC_OPUS_ATTR_DATA "data"
/*! \brief Default attribute values */
#define CODEC_OPUS_DEFAULT_SAMPLE_RATE 48000
#define CODEC_OPUS_DEFAULT_MAX_PLAYBACK_RATE 48000
#define CODEC_OPUS_DEFAULT_MAX_PTIME 120
#define CODEC_OPUS_DEFAULT_PTIME 20
#define CODEC_OPUS_DEFAULT_BITRATE -1000 /* OPUS_AUTO */
#define CODEC_OPUS_DEFAULT_CBR 0
#define CODEC_OPUS_DEFAULT_FEC 0
#define CODEC_OPUS_DEFAULT_DTX 0
#define CODEC_OPUS_DEFAULT_STEREO 0
#endif /* _AST_FORMAT_OPUS_H */ #endif /* _AST_FORMAT_OPUS_H */

View File

@@ -33,9 +33,10 @@ ASTERISK_REGISTER_FILE()
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/format.h" #include "asterisk/format.h"
#include "asterisk/logger.h" /* for ast_log, LOG_WARNING */ #include "asterisk/logger.h"
#include "asterisk/strings.h" /* for ast_str_append */ #include "asterisk/strings.h"
#include "asterisk/utils.h" /* for MIN, ast_malloc, ast_free */ #include "asterisk/utils.h"
#include "asterisk/opus.h"
/*! /*!
* \brief Opus attribute structure. * \brief Opus attribute structure.
@@ -43,32 +44,42 @@ ASTERISK_REGISTER_FILE()
* \note http://tools.ietf.org/html/rfc7587#section-6 * \note http://tools.ietf.org/html/rfc7587#section-6
*/ */
struct opus_attr { struct opus_attr {
unsigned int maxbitrate; int maxbitrate;
unsigned int maxplayrate; int maxplayrate;
unsigned int unused; /* was minptime, kept for binary compatibility */ int ptime;
unsigned int stereo; int stereo;
unsigned int cbr; int cbr;
unsigned int fec; int fec;
unsigned int dtx; int dtx;
unsigned int spropmaxcapturerate; int spropmaxcapturerate;
unsigned int spropstereo; int spropstereo;
int maxptime;
/* Note data is expected to be an ao2_object type */
void *data;
}; };
static struct opus_attr default_opus_attr = { static struct opus_attr default_opus_attr = {
.maxplayrate = 48000, .maxbitrate = CODEC_OPUS_DEFAULT_BITRATE,
.spropmaxcapturerate = 48000, .maxplayrate = CODEC_OPUS_DEFAULT_SAMPLE_RATE,
.maxbitrate = 510000, .ptime = CODEC_OPUS_DEFAULT_PTIME,
.stereo = 0, .stereo = CODEC_OPUS_DEFAULT_STEREO,
.spropstereo = 0, .cbr = CODEC_OPUS_DEFAULT_CBR,
.cbr = 0, .fec = CODEC_OPUS_DEFAULT_FEC,
.fec = 1, .dtx = CODEC_OPUS_DEFAULT_DTX,
.dtx = 0, .spropmaxcapturerate = CODEC_OPUS_DEFAULT_SAMPLE_RATE,
.spropstereo = CODEC_OPUS_DEFAULT_STEREO,
.maxptime = CODEC_OPUS_DEFAULT_MAX_PTIME
}; };
static void opus_destroy(struct ast_format *format) static void opus_destroy(struct ast_format *format)
{ {
struct opus_attr *attr = ast_format_get_attribute_data(format); struct opus_attr *attr = ast_format_get_attribute_data(format);
if (!attr) {
return;
}
ao2_cleanup(attr->data);
ast_free(attr); ast_free(attr);
} }
@@ -81,81 +92,65 @@ static int opus_clone(const struct ast_format *src, struct ast_format *dst)
return -1; return -1;
} }
if (original) { *attr = original ? *original : default_opus_attr;
*attr = *original; ao2_bump(attr->data);
} else {
*attr = default_opus_attr;
}
ast_format_set_attribute_data(dst, attr); ast_format_set_attribute_data(dst, attr);
return 0; return 0;
} }
static void sdp_fmtp_get(const char *attributes, const char *name, int *attr)
{
const char *kvp = "";
int val;
if (attributes && !(kvp = strstr(attributes, name))) {
return;
}
/*
* If the named attribute is not at the start of the given attributes, and
* the preceding character is not a space or semicolon then it's not the
* attribute we are looking for. It's an attribute with the name embedded
* within it (e.g. ptime in maxptime, stereo in sprop-stereo).
*/
if (kvp != attributes && *(kvp - 1) != ' ' && *(kvp - 1) != ';') {
/* Keep searching as it might still be in the attributes string */
sdp_fmtp_get(strchr(kvp, ';'), name, attr);
/*
* Otherwise it's a match, so retrieve the value and set the attribute.
*/
} else if (sscanf(kvp, "%*[^=]=%30d", &val) == 1) {
*attr = val;
}
}
static struct ast_format *opus_parse_sdp_fmtp(const struct ast_format *format, const char *attributes) static struct ast_format *opus_parse_sdp_fmtp(const struct ast_format *format, const char *attributes)
{ {
struct ast_format *cloned; struct ast_format *cloned;
struct opus_attr *attr; struct opus_attr *attr;
const char *kvp;
unsigned int val;
cloned = ast_format_clone(format); cloned = ast_format_clone(format);
if (!cloned) { if (!cloned) {
return NULL; return NULL;
} }
attr = ast_format_get_attribute_data(cloned); attr = ast_format_get_attribute_data(cloned);
if ((kvp = strstr(attributes, "maxplaybackrate")) && sscanf(kvp, "maxplaybackrate=%30u", &val) == 1) { sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, &attr->maxplayrate);
attr->maxplayrate = val; sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH,
} else { &attr->maxplayrate);
attr->maxplayrate = 48000; sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE,
} &attr->spropmaxcapturerate);
sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_PTIME, &attr->maxptime);
if ((kvp = strstr(attributes, "sprop-maxcapturerate")) && sscanf(kvp, "sprop-maxcapturerate=%30u", &val) == 1) { sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_PTIME, &attr->ptime);
attr->spropmaxcapturerate = val; sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, &attr->maxbitrate);
} else { sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_STEREO, &attr->stereo);
attr->spropmaxcapturerate = 48000; sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_SPROP_STEREO, &attr->spropstereo);
} sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_CBR, &attr->cbr);
sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_FEC, &attr->fec);
if ((kvp = strstr(attributes, "maxaveragebitrate")) && sscanf(kvp, "maxaveragebitrate=%30u", &val) == 1) { sdp_fmtp_get(attributes, CODEC_OPUS_ATTR_DTX, &attr->dtx);
attr->maxbitrate = val;
} else {
attr->maxbitrate = 510000;
}
if (!strncmp(attributes, "stereo=1", 8)) {
attr->stereo = 1;
} else if (strstr(attributes, " stereo=1")) {
attr->stereo = 1;
} else if (strstr(attributes, ";stereo=1")) {
attr->stereo = 1;
} else {
attr->stereo = 0;
}
if (strstr(attributes, "sprop-stereo=1")) {
attr->spropstereo = 1;
} else {
attr->spropstereo = 0;
}
if (strstr(attributes, "cbr=1")) {
attr->cbr = 1;
} else {
attr->cbr = 0;
}
if (strstr(attributes, "useinbandfec=1")) {
attr->fec = 1;
} else {
attr->fec = 0;
}
if (strstr(attributes, "usedtx=1")) {
attr->dtx = 1;
} else {
attr->dtx = 0;
}
return cloned; return cloned;
} }
@@ -163,7 +158,7 @@ static struct ast_format *opus_parse_sdp_fmtp(const struct ast_format *format, c
static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str) static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int payload, struct ast_str **str)
{ {
struct opus_attr *attr = ast_format_get_attribute_data(format); struct opus_attr *attr = ast_format_get_attribute_data(format);
int added = 0; int size;
if (!attr) { if (!attr) {
/* /*
@@ -174,79 +169,52 @@ static void opus_generate_sdp_fmtp(const struct ast_format *format, unsigned int
attr = &default_opus_attr; attr = &default_opus_attr;
} }
if (48000 != attr->maxplayrate) { size = ast_str_append(str, 0, "a=fmtp:%u ", payload);
if (added) {
ast_str_append(str, 0, ";"); if (CODEC_OPUS_DEFAULT_SAMPLE_RATE != attr->maxplayrate) {
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) { ast_str_append(str, 0, "%s=%d;",
added = 1; CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE, attr->maxplayrate);
}
ast_str_append(str, 0, "maxplaybackrate=%u", attr->maxplayrate);
} }
if (48000 != attr->spropmaxcapturerate) { if (CODEC_OPUS_DEFAULT_SAMPLE_RATE != attr->spropmaxcapturerate) {
if (added) { ast_str_append(str, 0, "%s=%d;",
ast_str_append(str, 0, ";"); CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE, attr->spropmaxcapturerate);
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
added = 1;
}
ast_str_append(str, 0, "sprop-maxcapturerate=%u", attr->spropmaxcapturerate);
} }
if (510000 != attr->maxbitrate) { if (CODEC_OPUS_DEFAULT_BITRATE != attr->maxbitrate || attr->maxbitrate > 0) {
if (added) { ast_str_append(str, 0, "%s=%d;",
ast_str_append(str, 0, ";"); CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE, attr->maxbitrate);
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
added = 1;
}
ast_str_append(str, 0, "maxaveragebitrate=%u", attr->maxbitrate);
} }
if (0 != attr->stereo) { if (CODEC_OPUS_DEFAULT_STEREO != attr->stereo) {
if (added) { ast_str_append(str, 0, "%s=%d;",
ast_str_append(str, 0, ";"); CODEC_OPUS_ATTR_STEREO, attr->stereo);
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
added = 1;
}
ast_str_append(str, 0, "stereo=%u", attr->stereo);
} }
if (0 != attr->spropstereo) { if (CODEC_OPUS_DEFAULT_STEREO != attr->spropstereo) {
if (added) { ast_str_append(str, 0, "%s=%d;",
ast_str_append(str, 0, ";"); CODEC_OPUS_ATTR_SPROP_STEREO, attr->spropstereo);
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
added = 1;
}
ast_str_append(str, 0, "sprop-stereo=%u", attr->spropstereo);
} }
if (0 != attr->cbr) { if (CODEC_OPUS_DEFAULT_CBR != attr->cbr) {
if (added) { ast_str_append(str, 0, "%s=%d;",
ast_str_append(str, 0, ";"); CODEC_OPUS_ATTR_CBR, attr->cbr);
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
added = 1;
}
ast_str_append(str, 0, "cbr=%u", attr->cbr);
} }
if (0 != attr->fec) { if (CODEC_OPUS_DEFAULT_FEC!= attr->fec) {
if (added) { ast_str_append(str, 0, "%s=%d;",
ast_str_append(str, 0, ";"); CODEC_OPUS_ATTR_FEC, attr->fec);
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
added = 1;
}
ast_str_append(str, 0, "useinbandfec=%u", attr->fec);
} }
if (0 != attr->dtx) { if (CODEC_OPUS_DEFAULT_DTX != attr->dtx) {
if (added) { ast_str_append(str, 0, "%s=%d;",
ast_str_append(str, 0, ";"); CODEC_OPUS_ATTR_DTX, attr->dtx);
} else if (0 < ast_str_append(str, 0, "a=fmtp:%u ", payload)) {
added = 1;
}
ast_str_append(str, 0, "usedtx=%u", attr->dtx);
} }
if (added) { if (size == ast_str_strlen(*str)) {
ast_str_reset(*str);
} else {
ast_str_truncate(*str, -1);
ast_str_append(str, 0, "\r\n"); ast_str_append(str, 0, "\r\n");
} }
} }
@@ -285,49 +253,68 @@ static struct ast_format *opus_getjoint(const struct ast_format *format1, const
* to receive stereo signals, it may be a waste of bandwidth. */ * to receive stereo signals, it may be a waste of bandwidth. */
attr_res->stereo = attr1->stereo && attr2->stereo ? 1 : 0; attr_res->stereo = attr1->stereo && attr2->stereo ? 1 : 0;
attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate); if (attr1->maxbitrate < 0) {
attr_res->maxbitrate = attr2->maxbitrate;
} else if (attr2->maxbitrate < 0) {
attr_res->maxbitrate = attr1->maxbitrate;
} else {
attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);
}
attr_res->spropmaxcapturerate = MIN(attr1->spropmaxcapturerate, attr2->spropmaxcapturerate); attr_res->spropmaxcapturerate = MIN(attr1->spropmaxcapturerate, attr2->spropmaxcapturerate);
attr_res->maxplayrate = MIN(attr1->maxplayrate, attr2->maxplayrate); attr_res->maxplayrate = MIN(attr1->maxplayrate, attr2->maxplayrate);
return jointformat; return jointformat;
} }
static struct ast_format *opus_set(const struct ast_format *format, const char *name, const char *value) static struct ast_format *opus_set(const struct ast_format *format,
const char *name, const char *value)
{ {
struct ast_format *cloned; struct ast_format *cloned;
struct opus_attr *attr; struct opus_attr *attr;
unsigned int val; int val;
if (sscanf(value, "%30u", &val) != 1) { if (!(cloned = ast_format_clone(format))) {
ast_log(LOG_WARNING, "Unknown value '%s' for attribute type '%s'\n",
value, name);
return NULL; return NULL;
} }
cloned = ast_format_clone(format);
if (!cloned) {
return NULL;
}
attr = ast_format_get_attribute_data(cloned); attr = ast_format_get_attribute_data(cloned);
if (!strcasecmp(name, "max_bitrate")) { if (!strcmp(name, CODEC_OPUS_ATTR_DATA)) {
attr->maxbitrate = val; ao2_cleanup(attr->data);
} else if (!strcasecmp(name, "max_playrate")) { attr->data = ao2_bump((void*)value);
return cloned;
}
if (sscanf(value, "%30d", &val) != 1) {
ast_log(LOG_WARNING, "Unknown value '%s' for attribute type '%s'\n",
value, name);
ao2_ref(cloned, -1);
return NULL;
}
if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE)) {
attr->maxplayrate = val; attr->maxplayrate = val;
} else if (!strcasecmp(name, "minptime")) { } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_CODED_AUDIO_BANDWIDTH)) {
attr->unused = val; attr->maxplayrate = val;
} else if (!strcasecmp(name, "stereo")) { } else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE)) {
attr->stereo = val;
} else if (!strcasecmp(name, "cbr")) {
attr->cbr = val;
} else if (!strcasecmp(name, "fec")) {
attr->fec = val;
} else if (!strcasecmp(name, "dtx")) {
attr->dtx = val;
} else if (!strcasecmp(name, "sprop_capture_rate")) {
attr->spropmaxcapturerate = val; attr->spropmaxcapturerate = val;
} else if (!strcasecmp(name, "sprop_stereo")) { } else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PTIME)) {
attr->maxptime = val;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_PTIME)) {
attr->ptime = val;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE)) {
attr->maxbitrate = val;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_STEREO)) {
attr->stereo = val;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_STEREO)) {
attr->spropstereo = val; attr->spropstereo = val;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_CBR)) {
attr->cbr = val;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_FEC)) {
attr->fec = val;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_DTX)) {
attr->dtx = val;
} else { } else {
ast_log(LOG_WARNING, "unknown attribute type %s\n", name); ast_log(LOG_WARNING, "unknown attribute type %s\n", name);
} }
@@ -335,6 +322,44 @@ static struct ast_format *opus_set(const struct ast_format *format, const char *
return cloned; return cloned;
} }
static const void *opus_get(const struct ast_format *format, const char *name)
{
struct opus_attr *attr = ast_format_get_attribute_data(format);
int *val = NULL;
if (!attr) {
return NULL;
}
if (!strcasecmp(name, CODEC_OPUS_ATTR_DATA)) {
return ao2_bump(attr->data);
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PLAYBACK_RATE)) {
val = &attr->maxplayrate;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_MAX_CAPTURE_RATE)) {
val = &attr->spropmaxcapturerate;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_PTIME)) {
val = &attr->maxptime;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_PTIME)) {
val = &attr->ptime;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_MAX_AVERAGE_BITRATE)) {
val = &attr->maxbitrate;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_STEREO)) {
val = &attr->stereo;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_SPROP_STEREO)) {
val = &attr->spropstereo;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_CBR)) {
val = &attr->cbr;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_FEC)) {
val = &attr->fec;
} else if (!strcasecmp(name, CODEC_OPUS_ATTR_DTX)) {
val = &attr->dtx;
} else {
ast_log(LOG_WARNING, "unknown attribute type %s\n", name);
}
return val;
}
static struct ast_format_interface opus_interface = { static struct ast_format_interface opus_interface = {
.format_destroy = opus_destroy, .format_destroy = opus_destroy,
.format_clone = opus_clone, .format_clone = opus_clone,
@@ -342,11 +367,12 @@ static struct ast_format_interface opus_interface = {
.format_attribute_set = opus_set, .format_attribute_set = opus_set,
.format_parse_sdp_fmtp = opus_parse_sdp_fmtp, .format_parse_sdp_fmtp = opus_parse_sdp_fmtp,
.format_generate_sdp_fmtp = opus_generate_sdp_fmtp, .format_generate_sdp_fmtp = opus_generate_sdp_fmtp,
.format_attribute_get = opus_get
}; };
static int load_module(void) static int load_module(void)
{ {
if (ast_format_interface_register("opus", &opus_interface)) { if (__ast_format_interface_register("opus", &opus_interface, ast_module_info->self)) {
return AST_MODULE_LOAD_DECLINE; return AST_MODULE_LOAD_DECLINE;
} }
@@ -358,9 +384,9 @@ static int unload_module(void)
return 0; return 0;
} }
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "Opus Format Attribute Module", AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Opus Format Attribute Module",
.support_level = AST_MODULE_SUPPORT_CORE, .support_level = AST_MODULE_SUPPORT_CORE,
.load = load_module, .load = load_module,
.unload = unload_module, .unload = unload_module,
.load_pri = AST_MODPRI_CHANNEL_DEPEND, .load_pri = AST_MODPRI_REALTIME_DRIVER /* Needs to load before codec_opus */
); );