Sun May 20 06:37:03 2012

Asterisk developer's documentation


res_format_attr_celt.c File Reference

CELT format attribute interface. More...

#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/format.h"

Include dependency graph for res_format_attr_celt.c:

Go to the source code of this file.

Data Structures

struct  celt_attr
 CELT attribute structure. More...

Functions

static void __reg_module (void)
static void __unreg_module (void)
static enum ast_format_cmp_res celt_cmp (const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2)
static int celt_get_val (const struct ast_format_attr *fattr, int key, void *result)
static int celt_getjoint (const struct ast_format_attr *fattr1, const struct ast_format_attr *fattr2, struct ast_format_attr *result)
static int celt_isset (const struct ast_format_attr *fattr, va_list ap)
static void celt_set (struct ast_format_attr *fattr, va_list ap)
static int load_module (void)
static int unload_module (void)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "CELT Format Attribute Module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, }
static struct ast_module_infoast_module_info = &__mod_info
static struct
ast_format_attr_interface 
celt_interface


Detailed Description

CELT format attribute interface.

Author:
David Vossel <dvossel@digium.com>

Definition in file res_format_attr_celt.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 185 of file res_format_attr_celt.c.

static void __unreg_module ( void   )  [static]

Definition at line 185 of file res_format_attr_celt.c.

static enum ast_format_cmp_res celt_cmp ( const struct ast_format_attr fattr1,
const struct ast_format_attr fattr2 
) [static]

Definition at line 48 of file res_format_attr_celt.c.

References AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, and celt_attr::samplerate.

00049 {
00050    struct celt_attr *attr1 = (struct celt_attr *) fattr1;
00051    struct celt_attr *attr2 = (struct celt_attr *) fattr2;
00052 
00053    if (attr1->samplerate == attr2->samplerate) {
00054       return AST_FORMAT_CMP_EQUAL;
00055    }
00056    return AST_FORMAT_CMP_NOT_EQUAL;
00057 }

static int celt_get_val ( const struct ast_format_attr fattr,
int  key,
void *  result 
) [static]

Definition at line 59 of file res_format_attr_celt.c.

References ast_log(), CELT_ATTR_KEY_FRAME_SIZE, CELT_ATTR_KEY_MAX_BITRATE, CELT_ATTR_KEY_SAMP_RATE, celt_attr::framesize, LOG_WARNING, celt_attr::maxbitrate, and celt_attr::samplerate.

00060 {
00061    const struct celt_attr *attr = (struct celt_attr *) fattr;
00062    int *val = result;
00063 
00064    switch (key) {
00065    case CELT_ATTR_KEY_SAMP_RATE:
00066       *val = attr->samplerate;
00067       break;
00068    case CELT_ATTR_KEY_MAX_BITRATE:
00069       *val = attr->maxbitrate;
00070       break;
00071    case CELT_ATTR_KEY_FRAME_SIZE:
00072       *val = attr->framesize;
00073       break;
00074    default:
00075       ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
00076       return -1;
00077    }
00078    return 0;
00079 }

static int celt_getjoint ( const struct ast_format_attr fattr1,
const struct ast_format_attr fattr2,
struct ast_format_attr result 
) [static]

Definition at line 113 of file res_format_attr_celt.c.

References celt_attr::framesize, celt_attr::maxbitrate, MIN, and celt_attr::samplerate.

00114 {
00115    struct celt_attr *attr1 = (struct celt_attr *) fattr1;
00116    struct celt_attr *attr2 = (struct celt_attr *) fattr2;
00117    struct celt_attr *attr_res = (struct celt_attr *) result;
00118 
00119    /* sample rate is the only attribute that has any bearing on if joint capabilities exist or not */
00120    if (attr1->samplerate != attr2->samplerate) {
00121       return -1;
00122    }
00123    /* either would work, they are guaranteed the same at this point. */
00124    attr_res->samplerate = attr1->samplerate;
00125    /* Take the lowest max bitrate */
00126    attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);
00127 
00128    attr_res->framesize = attr2->framesize; /* TODO figure out what joint framesize means */
00129    return 0;
00130 }

static int celt_isset ( const struct ast_format_attr fattr,
va_list  ap 
) [static]

Definition at line 81 of file res_format_attr_celt.c.

References AST_FORMAT_ATTR_END, ast_log(), CELT_ATTR_KEY_FRAME_SIZE, CELT_ATTR_KEY_MAX_BITRATE, CELT_ATTR_KEY_SAMP_RATE, celt_attr::framesize, LOG_WARNING, celt_attr::maxbitrate, and celt_attr::samplerate.

00082 {
00083    enum celt_attr_keys key;
00084    const struct celt_attr *attr = (struct celt_attr *) fattr;
00085 
00086    for (key = va_arg(ap, int);
00087       key != AST_FORMAT_ATTR_END;
00088       key = va_arg(ap, int))
00089    {
00090       switch (key) {
00091       case CELT_ATTR_KEY_SAMP_RATE:
00092          if (attr->samplerate != (va_arg(ap, int))) {
00093             return -1;
00094          }
00095          break;
00096       case CELT_ATTR_KEY_MAX_BITRATE:
00097          if (attr->maxbitrate != (va_arg(ap, int))) {
00098             return -1;
00099          }
00100          break;
00101       case CELT_ATTR_KEY_FRAME_SIZE:
00102          if (attr->framesize != (va_arg(ap, int))) {
00103             return -1;
00104          }
00105          break;
00106       default:
00107          ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
00108          return -1;
00109       }
00110    }
00111    return 0;
00112 }

static void celt_set ( struct ast_format_attr fattr,
va_list  ap 
) [static]

Definition at line 132 of file res_format_attr_celt.c.

References AST_FORMAT_ATTR_END, ast_log(), CELT_ATTR_KEY_FRAME_SIZE, CELT_ATTR_KEY_MAX_BITRATE, CELT_ATTR_KEY_SAMP_RATE, celt_attr::framesize, LOG_WARNING, celt_attr::maxbitrate, and celt_attr::samplerate.

00133 {
00134    enum celt_attr_keys key;
00135    struct celt_attr *attr = (struct celt_attr *) fattr;
00136 
00137    for (key = va_arg(ap, int);
00138       key != AST_FORMAT_ATTR_END;
00139       key = va_arg(ap, int))
00140    {
00141       switch (key) {
00142       case CELT_ATTR_KEY_SAMP_RATE:
00143          attr->samplerate = (va_arg(ap, int));
00144          break;
00145       case CELT_ATTR_KEY_MAX_BITRATE:
00146          attr->maxbitrate = (va_arg(ap, int));
00147          break;
00148       case CELT_ATTR_KEY_FRAME_SIZE:
00149          attr->framesize = (va_arg(ap, int));
00150          break;
00151       default:
00152          ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
00153       }
00154    }
00155 }

static int load_module ( void   )  [static]

Definition at line 166 of file res_format_attr_celt.c.

References ast_format_attr_reg_interface(), AST_MODULE_LOAD_DECLINE, and AST_MODULE_LOAD_SUCCESS.

00167 {
00168    if (ast_format_attr_reg_interface(&celt_interface)) {
00169       return AST_MODULE_LOAD_DECLINE;
00170    }
00171 
00172    return AST_MODULE_LOAD_SUCCESS;
00173 }

static int unload_module ( void   )  [static]

Definition at line 175 of file res_format_attr_celt.c.

References ast_format_attr_unreg_interface().

00176 {
00177    ast_format_attr_unreg_interface(&celt_interface);
00178    return 0;
00179 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "CELT Format Attribute Module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, } [static]

Definition at line 185 of file res_format_attr_celt.c.

Definition at line 185 of file res_format_attr_celt.c.

Definition at line 157 of file res_format_attr_celt.c.


Generated on Sun May 20 06:37:03 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6