Sat Apr 26 2014 22:03:10

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_sdp_generate (const struct ast_format_attr *format_attr, unsigned int payload, struct ast_str **str)
static int celt_sdp_parse (struct ast_format_attr *format_attr, const char *attributes)
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 210 of file res_format_attr_celt.c.

static void __unreg_module ( void  ) [static]

Definition at line 210 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 71 of file res_format_attr_celt.c.

References AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, and celt_attr::samplerate.

{
   struct celt_attr *attr1 = (struct celt_attr *) fattr1;
   struct celt_attr *attr2 = (struct celt_attr *) fattr2;

   if (attr1->samplerate == attr2->samplerate) {
      return AST_FORMAT_CMP_EQUAL;
   }
   return AST_FORMAT_CMP_NOT_EQUAL;
}
static int celt_get_val ( const struct ast_format_attr fattr,
int  key,
void *  result 
) [static]

Definition at line 82 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.

{
   const struct celt_attr *attr = (struct celt_attr *) fattr;
   int *val = result;

   switch (key) {
   case CELT_ATTR_KEY_SAMP_RATE:
      *val = attr->samplerate;
      break;
   case CELT_ATTR_KEY_MAX_BITRATE:
      *val = attr->maxbitrate;
      break;
   case CELT_ATTR_KEY_FRAME_SIZE:
      *val = attr->framesize;
      break;
   default:
      ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
      return -1;
   }
   return 0;
}
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 136 of file res_format_attr_celt.c.

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

{
   struct celt_attr *attr1 = (struct celt_attr *) fattr1;
   struct celt_attr *attr2 = (struct celt_attr *) fattr2;
   struct celt_attr *attr_res = (struct celt_attr *) result;

   /* sample rate is the only attribute that has any bearing on if joint capabilities exist or not */
   if (attr1->samplerate != attr2->samplerate) {
      return -1;
   }
   /* either would work, they are guaranteed the same at this point. */
   attr_res->samplerate = attr1->samplerate;
   /* Take the lowest max bitrate */
   attr_res->maxbitrate = MIN(attr1->maxbitrate, attr2->maxbitrate);

   attr_res->framesize = attr2->framesize; /* TODO figure out what joint framesize means */
   return 0;
}
static int celt_isset ( const struct ast_format_attr fattr,
va_list  ap 
) [static]

Definition at line 104 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.

{
   enum celt_attr_keys key;
   const struct celt_attr *attr = (struct celt_attr *) fattr;

   for (key = va_arg(ap, int);
      key != AST_FORMAT_ATTR_END;
      key = va_arg(ap, int))
   {
      switch (key) {
      case CELT_ATTR_KEY_SAMP_RATE:
         if (attr->samplerate != (va_arg(ap, int))) {
            return -1;
         }
         break;
      case CELT_ATTR_KEY_MAX_BITRATE:
         if (attr->maxbitrate != (va_arg(ap, int))) {
            return -1;
         }
         break;
      case CELT_ATTR_KEY_FRAME_SIZE:
         if (attr->framesize != (va_arg(ap, int))) {
            return -1;
         }
         break;
      default:
         ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
         return -1;
      }
   }
   return 0;
}
static void celt_sdp_generate ( const struct ast_format_attr format_attr,
unsigned int  payload,
struct ast_str **  str 
) [static]

Definition at line 60 of file res_format_attr_celt.c.

References ast_str_append(), and celt_attr::framesize.

{
   struct celt_attr *attr = (struct celt_attr *) format_attr;

   if (!attr->framesize) {
      return;
   }

   ast_str_append(str, 0, "a=fmtp:%d framesize=%d\r\n", payload, attr->framesize);
}
static int celt_sdp_parse ( struct ast_format_attr format_attr,
const char *  attributes 
) [static]

Definition at line 48 of file res_format_attr_celt.c.

References celt_attr::framesize.

{
   struct celt_attr *attr = (struct celt_attr *) format_attr;
   unsigned int val;

   if (sscanf(attributes, "framesize=%30u", &val) == 1) {
      attr->framesize = val;
   }

   return 0;
}
static void celt_set ( struct ast_format_attr fattr,
va_list  ap 
) [static]

Definition at line 155 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.

{
   enum celt_attr_keys key;
   struct celt_attr *attr = (struct celt_attr *) fattr;

   for (key = va_arg(ap, int);
      key != AST_FORMAT_ATTR_END;
      key = va_arg(ap, int))
   {
      switch (key) {
      case CELT_ATTR_KEY_SAMP_RATE:
         attr->samplerate = (va_arg(ap, int));
         break;
      case CELT_ATTR_KEY_MAX_BITRATE:
         attr->maxbitrate = (va_arg(ap, int));
         break;
      case CELT_ATTR_KEY_FRAME_SIZE:
         attr->framesize = (va_arg(ap, int));
         break;
      default:
         ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
      }
   }
}
static int unload_module ( void  ) [static]

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 210 of file res_format_attr_celt.c.

Definition at line 210 of file res_format_attr_celt.c.

Definition at line 180 of file res_format_attr_celt.c.