format_cap.c File Reference

Format Capabilities API. More...

#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/format.h"
#include "asterisk/format_cap.h"
#include "asterisk/format_cache.h"
#include "asterisk/codec.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/vector.h"
#include "asterisk/linkedlists.h"
#include "asterisk/utils.h"

Include dependency graph for format_cap.c:

Go to the source code of this file.

Data Structures

struct  ast_format_cap
 Format capabilities structure, holds formats + preference order + etc. More...
struct  format_cap_framed
 Structure used for capability formats, adds framing. More...
struct  format_cap_framed_list
 Linked list for formats. More...

Defines

#define FORMAT_CAP_FRAMED_ELEM_CLEANUP(elem)   ao2_cleanup((elem))
 format_cap_framed vector element cleanup.
#define FORMAT_CAP_FRAMED_ELEM_CMP(elem, value)   ((elem)->format == (value))
 format_cap_framed comparator for AST_VECTOR_REMOVE_CMP_ORDERED()

Functions

struct ast_format_cap__ast_format_cap_alloc (enum ast_format_cap_flags flags)
 Allocate a new ast_format_cap structure.
struct ast_format_cap__ast_format_cap_alloc_debug (enum ast_format_cap_flags flags, const char *tag, const char *file, int line, const char *func)
int __ast_format_cap_append (struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)
 Add format capability to capabilities structure.
int __ast_format_cap_append_debug (struct ast_format_cap *cap, struct ast_format *format, unsigned int framing, const char *tag, const char *file, int line, const char *func)
int ast_format_cap_append_by_type (struct ast_format_cap *cap, enum ast_media_type type)
 Add all codecs Asterisk knows about for a specific type to the capabilities structure.
int ast_format_cap_append_from_cap (struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
 Append the formats of provided type in src to dst.
size_t ast_format_cap_count (const struct ast_format_cap *cap)
 Get the number of formats present within the capabilities structure.
int ast_format_cap_empty (struct ast_format_cap *cap)
 Determine if a format cap has no formats in it.
struct ast_formatast_format_cap_get_best_by_type (const struct ast_format_cap *cap, enum ast_media_type type)
 Get the most preferred format for a particular media type.
int ast_format_cap_get_compatible (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2, struct ast_format_cap *result)
 Find the compatible formats between two capabilities structures.
struct ast_formatast_format_cap_get_compatible_format (const struct ast_format_cap *cap, const struct ast_format *format)
 Find if input ast_format is within the capabilities of the ast_format_cap object then return the compatible format from the capabilities structure in the result.
struct ast_formatast_format_cap_get_format (const struct ast_format_cap *cap, int position)
 Get the format at a specific index.
unsigned int ast_format_cap_get_format_framing (const struct ast_format_cap *cap, const struct ast_format *format)
 Get the framing for a format.
unsigned int ast_format_cap_get_framing (const struct ast_format_cap *cap)
 Get the global framing.
const char * ast_format_cap_get_names (struct ast_format_cap *cap, struct ast_str **buf)
 Get the names of codecs of a set of formats.
int ast_format_cap_has_type (const struct ast_format_cap *cap, enum ast_media_type type)
 Find out if the capabilities structure has any formats of a specific type.
int ast_format_cap_identical (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)
 Determine if two capabilities structures are identical.
int ast_format_cap_iscompatible (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)
 Determine if any joint capabilities exist between two capabilities structures.
enum ast_format_cmp_res ast_format_cap_iscompatible_format (const struct ast_format_cap *cap, const struct ast_format *format)
 Find if ast_format is within the capabilities of the ast_format_cap object.
int ast_format_cap_remove (struct ast_format_cap *cap, struct ast_format *format)
 Remove format capability from capability structure.
void ast_format_cap_remove_by_type (struct ast_format_cap *cap, enum ast_media_type type)
 Remove all formats matching a specific format type.
void ast_format_cap_replace_from_cap (struct ast_format_cap *dst, const struct ast_format_cap *src, enum ast_media_type type)
 Replace the formats of provided type in dst with equivalent formats from src.
void ast_format_cap_set_framing (struct ast_format_cap *cap, unsigned int framing)
 Set the global framing.
int ast_format_cap_update_by_allow_disallow (struct ast_format_cap *cap, const char *list, int allowing)
 Parse an "allow" or "deny" list and modify a format capabilities structure accordingly.
static void format_cap_destroy (void *obj)
 Destructor for format capabilities structure.
static void format_cap_framed_destroy (void *obj)
 Destructor for format capabilities framed structure.
static int format_cap_framed_init (struct format_cap_framed *framed, struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)
static void format_cap_init (struct ast_format_cap *cap, enum ast_format_cap_flags flags)
static int format_cap_replace (struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)
static int format_in_format_cap (struct ast_format_cap *cap, struct ast_format *format)
static int internal_format_cap_identical (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)

Variables

static struct
format_cap_framed_list 
format_cap_framed_list_empty = AST_LIST_HEAD_NOLOCK_INIT_VALUE
 Dummy empty list for when we are inserting a new list.


Detailed Description

Format Capabilities API.

Author:
Joshua Colp <jcolp@digium.com>

Definition in file format_cap.c.


Define Documentation

#define FORMAT_CAP_FRAMED_ELEM_CLEANUP ( elem   )     ao2_cleanup((elem))

format_cap_framed vector element cleanup.

Parameters:
elem Element to cleanup
Returns:
Nothing

Definition at line 475 of file format_cap.c.

Referenced by ast_format_cap_remove(), and ast_format_cap_remove_by_type().

#define FORMAT_CAP_FRAMED_ELEM_CMP ( elem,
value   )     ((elem)->format == (value))

format_cap_framed comparator for AST_VECTOR_REMOVE_CMP_ORDERED()

Parameters:
elem Element to compare against
value Value to compare with the vector element.
Returns:
0 if element does not match.

Non-zero if element matches.

Definition at line 466 of file format_cap.c.

Referenced by ast_format_cap_remove(), and ast_format_cap_remove_by_type().


Function Documentation

struct ast_format_cap* __ast_format_cap_alloc ( enum ast_format_cap_flags  flags  )  [read]

Allocate a new ast_format_cap structure.

Parameters:
flags Modifiers of struct behavior.
Return values:
ast_format_cap object on success.
NULL on failure.

Definition at line 106 of file format_cap.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, format_cap_destroy(), format_cap_init(), and NULL.

00107 {
00108    struct ast_format_cap *cap;
00109 
00110    cap = ao2_alloc_options(sizeof(*cap), format_cap_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
00111    if (!cap) {
00112       return NULL;
00113    }
00114 
00115    format_cap_init(cap, flags);
00116 
00117    return cap;
00118 }

struct ast_format_cap* __ast_format_cap_alloc_debug ( enum ast_format_cap_flags  flags,
const char *  tag,
const char *  file,
int  line,
const char *  func 
) [read]

Definition at line 120 of file format_cap.c.

References __ao2_alloc_debug(), AO2_ALLOC_OPT_LOCK_NOLOCK, format_cap_destroy(), format_cap_init(), NULL, and S_OR.

00121 {
00122    struct ast_format_cap *cap;
00123 
00124    cap = __ao2_alloc_debug(sizeof(*cap), format_cap_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK, S_OR(tag, "ast_format_cap_alloc"), file, line, func, 1);
00125    if (!cap) {
00126       return NULL;
00127    }
00128 
00129    format_cap_init(cap, flags);
00130 
00131    return cap;
00132 }

int __ast_format_cap_append ( struct ast_format_cap cap,
struct ast_format format,
unsigned int  framing 
)

Add format capability to capabilities structure.

Parameters:
cap The capabilities structure to add to.
format The format to add.
framing The framing for the format (in milliseconds).
Return values:
0 success
-1 failure
Note:
A reference to the format is taken and used in the capabilities structure.

The order in which add is called determines the format preference order.

If framing is specified here it overrides any global framing that has been set.

Definition at line 190 of file format_cap.c.

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ast_assert, format_cap_framed::format, format_cap_framed_destroy(), format_cap_framed_init(), format_in_format_cap(), and NULL.

00191 {
00192    struct format_cap_framed *framed;
00193 
00194    ast_assert(format != NULL);
00195 
00196    if (format_in_format_cap(cap, format)) {
00197       return 0;
00198    }
00199 
00200    framed = ao2_alloc_options(sizeof(*framed), format_cap_framed_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
00201    if (!framed) {
00202       return -1;
00203    }
00204    framed->format = ao2_bump(format);
00205 
00206    return format_cap_framed_init(framed, cap, format, framing);
00207 }

int __ast_format_cap_append_debug ( struct ast_format_cap cap,
struct ast_format format,
unsigned int  framing,
const char *  tag,
const char *  file,
int  line,
const char *  func 
)

Definition at line 209 of file format_cap.c.

References __ao2_ref_debug(), AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ast_assert, format_cap_framed::format, format_cap_framed_destroy(), format_cap_framed_init(), format_in_format_cap(), NULL, and S_OR.

00210 {
00211    struct format_cap_framed *framed;
00212 
00213    ast_assert(format != NULL);
00214 
00215    if (format_in_format_cap(cap, format)) {
00216       return 0;
00217    }
00218 
00219    framed = ao2_alloc_options(sizeof(*framed), format_cap_framed_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
00220    if (!framed) {
00221       return -1;
00222    }
00223 
00224    __ao2_ref_debug(format, +1, S_OR(tag, "ast_format_cap_append"), file, line, func);
00225    framed->format = format;
00226 
00227    return format_cap_framed_init(framed, cap, format, framing);
00228 }

int ast_format_cap_append_by_type ( struct ast_format_cap cap,
enum ast_media_type  type 
)

Add all codecs Asterisk knows about for a specific type to the capabilities structure.

Parameters:
cap The capabilities structure to add to.
type The type of formats to add.
Return values:
0 success
-1 failure
Note:
A generic format with no attributes is created using the codec.

If AST_MEDIA_TYPE_UNKNOWN is passed as the type all known codecs will be added.

Definition at line 230 of file format_cap.c.

References ao2_ref, ast_codec_get_by_id(), ast_codec_get_max(), ast_format_cap_append, ast_format_create(), AST_MEDIA_TYPE_UNKNOWN, format_cap_framed::format, id, and ast_codec::type.

Referenced by ast_format_cap_update_by_allow_disallow(), ast_local_init(), AST_TEST_DEFINE(), begin_dial_prerun(), load_module(), rec_request(), and register_channel_tech().

00231 {
00232    int id;
00233 
00234    for (id = 1; id < ast_codec_get_max(); ++id) {
00235       struct ast_codec *codec = ast_codec_get_by_id(id);
00236       struct ast_format *format;
00237       int res;
00238 
00239       if (!codec) {
00240          continue;
00241       }
00242 
00243       if ((type != AST_MEDIA_TYPE_UNKNOWN) && codec->type != type) {
00244          ao2_ref(codec, -1);
00245          continue;
00246       }
00247 
00248       format = ast_format_create(codec);
00249       ao2_ref(codec, -1);
00250 
00251       if (!format) {
00252          return -1;
00253       }
00254 
00255       /* Use the global framing or default framing of the codec */
00256       res = ast_format_cap_append(cap, format, 0);
00257       ao2_ref(format, -1);
00258 
00259       if (res) {
00260          return -1;
00261       }
00262    }
00263 
00264    return 0;
00265 }

int ast_format_cap_append_from_cap ( struct ast_format_cap dst,
const struct ast_format_cap src,
enum ast_media_type  type 
)

Append the formats of provided type in src to dst.

Parameters:
dst The destination capabilities structure
src The source capabilities structure
type The type of formats to append.
Return values:
0 success
-1 failure
Note:
If AST_MEDIA_TYPE_UNKNOWN is passed as the type all known codecs will be added.

Definition at line 267 of file format_cap.c.

References ast_format_cap_append, ast_format_get_type(), AST_MEDIA_TYPE_UNKNOWN, AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and format_cap_framed::framing.

Referenced by __sip_alloc(), add_sdp(), ast_media_get_format_cap(), ast_request(), ast_sip_session_create_outgoing(), AST_TEST_DEFINE(), ast_unreal_alloc(), build_device(), build_gateway(), build_peer(), build_user(), chan_pjsip_get_codec(), chan_pjsip_new(), chan_pjsip_set_rtp_peer(), channel_do_masquerade(), check_peer_ok(), config_device(), config_line(), create_addr_from_peer(), create_outgoing_sdp_stream(), func_channel_read(), handle_request_invite(), jingle_alloc(), jingle_call(), jingle_interpret_content(), jingle_new(), load_module(), mgcp_get_codec(), mgcp_new(), ooh323_alloc(), ooh323_get_codec(), ooh323_onReceivedSetup(), ooh323_request(), phone_new(), process_sdp(), set_caps(), set_peer_defaults(), sip_get_codec(), sip_new(), sip_request_call(), sip_rtp_read(), sip_set_rtp_peer(), skinny_new(), try_suggested_sip_codec(), unistim_line_copy(), unistim_new(), and unistim_request().

00269 {
00270    int idx, res = 0;
00271 
00272    for (idx = 0; (idx < AST_VECTOR_SIZE(&src->preference_order)) && !res; ++idx) {
00273       struct format_cap_framed *framed = AST_VECTOR_GET(&src->preference_order, idx);
00274 
00275       if (type == AST_MEDIA_TYPE_UNKNOWN || ast_format_get_type(framed->format) == type) {
00276          res = ast_format_cap_append(dst, framed->format, framed->framing);
00277       }
00278    }
00279 
00280    return res;
00281 }

size_t ast_format_cap_count ( const struct ast_format_cap cap  ) 

int ast_format_cap_empty ( struct ast_format_cap cap  ) 

Determine if a format cap has no formats in it.

Parameters:
cap The format cap to check for emptiness
Return values:
1 The format cap has zero formats or only ast_format_none
0 The format cap has at least one format

Definition at line 708 of file format_cap.c.

References ast_format_cap_count(), ast_format_none, and AST_VECTOR_GET.

Referenced by ast_translator_best_choice(), chan_pjsip_new(), and set_format().

00709 {
00710    int count = ast_format_cap_count(cap);
00711 
00712    if (count > 1) {
00713       return 0;
00714    }
00715 
00716    if (count == 0 || AST_VECTOR_GET(&cap->preference_order, 0)->format == ast_format_none) {
00717       return 1;
00718    }
00719 
00720    return 0;
00721 }

struct ast_format* ast_format_cap_get_best_by_type ( const struct ast_format_cap cap,
enum ast_media_type  type 
) [read]

Get the most preferred format for a particular media type.

Parameters:
cap The capabilities structure
type The type of media to get
Return values:
non-NULL the preferred format
NULL no media of type present
Note:
The reference count of the returned format is increased. It must be released using ao2_ref or ao2_cleanup.

Definition at line 397 of file format_cap.c.

References ao2_ref, ast_assert, ast_format_cap_get_format(), ast_format_get_type(), ast_format_none, AST_MEDIA_TYPE_UNKNOWN, AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and NULL.

Referenced by AST_TEST_DEFINE(), chan_pjsip_new(), set_format(), and sip_new().

00398 {
00399    int i;
00400 
00401    if (type == AST_MEDIA_TYPE_UNKNOWN) {
00402       return ast_format_cap_get_format(cap, 0);
00403    }
00404 
00405    for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); i++) {
00406       struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, i);
00407 
00408       if (ast_format_get_type(framed->format) == type) {
00409          ao2_ref(framed->format, +1);
00410          ast_assert(framed->format != ast_format_none);
00411          return framed->format;
00412       }
00413    }
00414 
00415    return NULL;
00416 }

int ast_format_cap_get_compatible ( const struct ast_format_cap cap1,
const struct ast_format_cap cap2,
struct ast_format_cap result 
)

Find the compatible formats between two capabilities structures.

Parameters:
cap1 The first capabilities structure
cap2 The second capabilities structure
[out] result The capabilities structure to place the results into
Return values:
0 success
-1 failure
Note:
The preference order of cap1 is respected.

If failure occurs the result format capabilities structure may contain a partial result.

Definition at line 610 of file format_cap.c.

References ao2_ref, ast_format_cap_append, ast_format_cap_get_compatible_format(), AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and format_cap_framed::framing.

Referenced by add_sdp(), ast_sip_session_create_outgoing(), ast_speech_new(), AST_TEST_DEFINE(), ast_translator_best_choice(), check_peer_ok(), create_outgoing_sdp_stream(), handle_capabilities_res_message(), iax2_request(), jingle_interpret_description(), process_sdp(), set_caps(), sip_request_call(), and skinny_register().

00612 {
00613    int idx, res = 0;
00614 
00615    for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
00616       struct format_cap_framed *framed = AST_VECTOR_GET(&cap1->preference_order, idx);
00617       struct ast_format *format;
00618 
00619       format = ast_format_cap_get_compatible_format(cap2, framed->format);
00620       if (!format) {
00621          continue;
00622       }
00623 
00624       res = ast_format_cap_append(result, format, framed->framing);
00625       ao2_ref(format, -1);
00626 
00627       if (res) {
00628          break;
00629       }
00630    }
00631 
00632    return res;
00633 }

struct ast_format* ast_format_cap_get_compatible_format ( const struct ast_format_cap cap,
const struct ast_format format 
) [read]

Find if input ast_format is within the capabilities of the ast_format_cap object then return the compatible format from the capabilities structure in the result.

Return values:
non-NULL if format is compatible
NULL if not compatible
Note:
The reference count of the returned format is increased. It must be released using ao2_ref or ao2_cleanup.

Definition at line 528 of file format_cap.c.

References ao2_cleanup, ast_assert, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_codec_id(), ast_format_joint(), AST_LIST_TRAVERSE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, format_cap_framed::format, NULL, and result.

Referenced by ast_format_cap_get_compatible(), AST_TEST_DEFINE(), ast_translate_available_formats(), and codec_choose_from_prefs().

00529 {
00530    struct format_cap_framed_list *list;
00531    struct format_cap_framed *framed;
00532    struct ast_format *result = NULL;
00533 
00534    ast_assert(format != NULL);
00535 
00536    if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
00537       return NULL;
00538    }
00539 
00540    list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
00541 
00542    AST_LIST_TRAVERSE(list, framed, entry) {
00543       enum ast_format_cmp_res res = ast_format_cmp(format, framed->format);
00544 
00545       if (res == AST_FORMAT_CMP_NOT_EQUAL) {
00546          continue;
00547       }
00548 
00549       /* Replace any current result, this one will also be a subset OR an exact match */
00550       ao2_cleanup(result);
00551 
00552       result = ast_format_joint(format, framed->format);
00553 
00554       /* If it's a match we can do no better so return asap */
00555       if (res == AST_FORMAT_CMP_EQUAL) {
00556          break;
00557       }
00558    }
00559 
00560    return result;
00561 }

struct ast_format* ast_format_cap_get_format ( const struct ast_format_cap cap,
int  position 
) [read]

Get the format at a specific index.

Parameters:
cap The capabilities structure
position The position to get
Return values:
non-NULL success
NULL failure
Note:
This is a zero based index.

Formats are returned in order of preference.

The reference count of the returned format is increased. It must be released using ao2_ref or ao2_cleanup.

Definition at line 380 of file format_cap.c.

References ao2_ref, ast_assert, ast_format_none, AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, and NULL.

Referenced by add_format_information_cb(), add_sdp(), ast_data_add_codecs(), ast_format_cap_get_best_by_type(), ast_iax2_new(), ast_openvstream(), ast_rtp_lookup_mime_multiple2(), ast_speech_new(), AST_TEST_DEFINE(), ast_translate_available_formats(), ast_translator_best_choice(), ast_unreal_new_channels(), chan_pjsip_new(), configure_local_rtp(), create_addr(), create_outgoing_sdp_stream(), function_sippeer(), handle_open_receive_channel_ack_message(), iax2_codec_pref_string(), iax2_format_compatibility_cap2bitfield(), iax2_parse_allow_disallow(), iax2_request(), internal_format_cap_identical(), jingle_add_payloads_to_description(), jingle_interpret_content(), jingle_new(), media_offer_read_av(), mgcp_new(), misdn_new(), multicast_rtp_request(), ooh323_new(), ooh323c_set_capability(), ooh323c_set_capability_for_call(), phone_new(), process_sdp(), show_sound_info_cb(), sip_new(), skinny_new(), skinny_set_rtp_peer(), start_rtp(), transmit_connect(), transmit_connect_with_sdp(), transmit_modify_request(), transmit_modify_with_sdp(), unicast_rtp_request(), and unistim_new().

00381 {
00382    struct format_cap_framed *framed;
00383 
00384    ast_assert(position < AST_VECTOR_SIZE(&cap->preference_order));
00385 
00386    if (position >= AST_VECTOR_SIZE(&cap->preference_order)) {
00387       return NULL;
00388    }
00389 
00390    framed = AST_VECTOR_GET(&cap->preference_order, position);
00391 
00392    ast_assert(framed->format != ast_format_none);
00393    ao2_ref(framed->format, +1);
00394    return framed->format;
00395 }

unsigned int ast_format_cap_get_format_framing ( const struct ast_format_cap cap,
const struct ast_format format 
)

Get the framing for a format.

Parameters:
cap The capabilities structure
format The format to retrieve
Returns:
the framing (in milliseconds)

Definition at line 423 of file format_cap.c.

References ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_codec_id(), ast_format_get_default_ms(), AST_LIST_TRAVERSE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, format_cap_framed::format, format_cap_framed::framing, NULL, and result.

Referenced by add_codec_to_sdp(), AST_TEST_DEFINE(), create_addr(), handle_open_receive_channel_ack_message(), iax2_parse_allow_disallow(), native_rtp_bridge_compatible(), ooh323c_set_capability_for_call(), process_sdp(), skinny_set_rtp_peer(), and transmit_connect().

00424 {
00425    unsigned int framing;
00426    struct format_cap_framed_list *list;
00427    struct format_cap_framed *framed, *result = NULL;
00428 
00429    if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
00430       return 0;
00431    }
00432 
00433    framing = cap->framing != UINT_MAX ? cap->framing : ast_format_get_default_ms(format);
00434    list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
00435 
00436    AST_LIST_TRAVERSE(list, framed, entry) {
00437       enum ast_format_cmp_res res = ast_format_cmp(format, framed->format);
00438 
00439       if (res == AST_FORMAT_CMP_NOT_EQUAL) {
00440          continue;
00441       }
00442 
00443       result = framed;
00444 
00445       if (res == AST_FORMAT_CMP_EQUAL) {
00446          break;
00447       }
00448    }
00449 
00450    if (result && result->framing) {
00451       framing = result->framing;
00452    }
00453 
00454    return framing;
00455 }

unsigned int ast_format_cap_get_framing ( const struct ast_format_cap cap  ) 

Get the global framing.

Parameters:
cap The capabilities structure.
Return values:
0 if no formats are in the structure and no framing has been provided
The global framing value (in milliseconds)
Note:
This will be the minimum framing allowed across all formats in the capabilities structure, or an overridden value

Definition at line 418 of file format_cap.c.

Referenced by AST_TEST_DEFINE(), check_peer_ok(), configure_local_rtp(), create_addr_from_peer(), create_outgoing_sdp_stream(), jingle_enable_video(), jingle_new(), start_rtp(), and transmit_response_with_sdp().

00419 {
00420    return (cap->framing != UINT_MAX) ? cap->framing : 0;
00421 }

const char* ast_format_cap_get_names ( struct ast_format_cap cap,
struct ast_str **  buf 
)

Get the names of codecs of a set of formats.

Parameters:
cap The capabilities structure containing the formats
buf A ast_str buffer to populate with the names of the formats
Returns:
The contents of the buffer in buf

Definition at line 682 of file format_cap.c.

References ast_format_get_name(), ast_str_append(), ast_str_buffer(), ast_str_set(), AST_VECTOR_GET, AST_VECTOR_SIZE, and format_cap_framed::format.

Referenced by _sip_show_peer(), _skinny_show_device(), _skinny_show_line(), add_sdp(), alsa_request(), ast_request(), ast_streamfile(), AST_TEST_DEFINE(), ast_write(), chan_pjsip_write(), codec_handler_fn(), console_request(), func_channel_read(), function_sippeer(), generate_status(), handle_capabilities_res_message(), handle_cli_core_show_channeltype(), handle_cli_ooh323_show_config(), handle_cli_ooh323_show_peers(), handle_cli_ooh323_show_users(), handle_showchan(), iax2_getformatname_multiple(), iax2_request(), jingle_write(), mbl_request(), mgcp_request(), mgcp_write(), native_rtp_bridge_compatible(), nbs_request(), onNewCallCreated(), ooh323_request(), ooh323_set_write_format(), ooh323_write(), oss_request(), phone_request(), process_sdp(), serialize_showchan(), set_caps(), set_format(), show_channels_cb(), sip_new(), sip_request_call(), sip_show_channel(), sip_show_settings(), sip_write(), skinny_new(), skinny_request(), skinny_write(), socket_process_helper(), start_rtp(), unistim_new(), unistim_request(), unistim_rtp_read(), unistim_show_info(), and unistim_write().

00683 {
00684    int i;
00685 
00686    ast_str_set(buf, 0, "(");
00687 
00688    if (!AST_VECTOR_SIZE(&cap->preference_order)) {
00689       ast_str_append(buf, 0, "nothing)");
00690       return ast_str_buffer(*buf);
00691    }
00692 
00693    for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); ++i) {
00694       int res;
00695       struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, i);
00696 
00697       res = ast_str_append(buf, 0, "%s%s", ast_format_get_name(framed->format),
00698          i < AST_VECTOR_SIZE(&cap->preference_order) - 1 ? "|" : "");
00699       if (res < 0) {
00700          break;
00701       }
00702    }
00703    ast_str_append(buf, 0, ")");
00704 
00705    return ast_str_buffer(*buf);
00706 }

int ast_format_cap_has_type ( const struct ast_format_cap cap,
enum ast_media_type  type 
)

Find out if the capabilities structure has any formats of a specific type.

Return values:
1 true
0 false, no formats of specific type.

Definition at line 595 of file format_cap.c.

References ast_format_get_type(), AST_VECTOR_GET, AST_VECTOR_SIZE, and format_cap_framed::format.

Referenced by add_sdp(), ast_bridge_update_talker_src_video_mode(), ast_channel_make_compatible_helper(), ast_openstream_full(), ast_openvstream(), ast_sendtext(), AST_TEST_DEFINE(), create_outgoing_sdp_stream(), dialog_initialize_rtp(), jingle_enable_video(), jingle_request(), negotiate_incoming_sdp_stream(), ooh323_request(), process_sdp(), sip_call(), sip_new(), sip_request_call(), and skinny_request().

00596 {
00597    int idx;
00598 
00599    for (idx = 0; idx < AST_VECTOR_SIZE(&cap->preference_order); ++idx) {
00600       struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, idx);
00601 
00602       if (ast_format_get_type(framed->format) == type) {
00603          return 1;
00604       }
00605    }
00606 
00607    return 0;
00608 }

int ast_format_cap_identical ( const struct ast_format_cap cap1,
const struct ast_format_cap cap2 
)

Determine if two capabilities structures are identical.

Parameters:
cap1 The first capabilities structure
cap2 The second capabilities structure
Return values:
0 capabilities are not identical
1 capabilities are identical

Definition at line 669 of file format_cap.c.

References AST_VECTOR_SIZE, and internal_format_cap_identical().

Referenced by AST_TEST_DEFINE(), chan_pjsip_set_rtp_peer(), and sip_set_rtp_peer().

00670 {
00671    if (AST_VECTOR_SIZE(&cap1->preference_order) != AST_VECTOR_SIZE(&cap2->preference_order)) {
00672       return 0; /* if they are not the same size, they are not identical */
00673    }
00674 
00675    if (!internal_format_cap_identical(cap1, cap2)) {
00676       return 0;
00677    }
00678 
00679    return internal_format_cap_identical(cap2, cap1);
00680 }

int ast_format_cap_iscompatible ( const struct ast_format_cap cap1,
const struct ast_format_cap cap2 
)

Determine if any joint capabilities exist between two capabilities structures.

Parameters:
cap1 The first capabilities structure
cap2 The second capabilities structure
Return values:
0 no joint capabilities exist
1 joint capabilities exist

Definition at line 635 of file format_cap.c.

References ast_format_cap_iscompatible_format(), AST_FORMAT_CMP_NOT_EQUAL, AST_VECTOR_GET, AST_VECTOR_SIZE, and format_cap_framed::format.

Referenced by ast_openvstream(), ast_rtp_instance_early_bridge(), ast_rtp_instance_early_bridge_make_compatible(), AST_TEST_DEFINE(), chan_pjsip_new(), console_request(), create_outgoing_sdp_stream(), mgcp_request(), native_rtp_bridge_compatible(), phone_request(), and unistim_request().

00636 {
00637    int idx;
00638 
00639    for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
00640       struct format_cap_framed *framed = AST_VECTOR_GET(&cap1->preference_order, idx);
00641 
00642       if (ast_format_cap_iscompatible_format(cap2, framed->format) != AST_FORMAT_CMP_NOT_EQUAL) {
00643          return 1;
00644       }
00645    }
00646 
00647    return 0;
00648 }

enum ast_format_cmp_res ast_format_cap_iscompatible_format ( const struct ast_format_cap cap,
const struct ast_format format 
)

Find if ast_format is within the capabilities of the ast_format_cap object.

Return values:
ast_format_cmp_res representing the result of the compatibility check between cap and format.

Definition at line 563 of file format_cap.c.

References ast_assert, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_codec_id(), AST_LIST_TRAVERSE, AST_VECTOR_GET_ADDR, AST_VECTOR_SIZE, format_cap_framed::format, and NULL.

Referenced by add_sdp(), alsa_request(), ast_format_cap_iscompatible(), ast_speech_new(), AST_TEST_DEFINE(), chan_pjsip_indicate(), chan_pjsip_write(), check_translation_path(), internal_format_cap_identical(), jingle_read(), jingle_write(), mbl_request(), mgcp_rtp_read(), mgcp_write(), nbs_request(), ooh323_rtp_read(), ooh323_write(), oss_request(), process_sdp(), sip_indicate(), sip_rtp_read(), sip_write(), skinny_rtp_read(), skinny_write(), start_rtp(), try_suggested_sip_codec(), unistim_rtp_read(), and unistim_write().

00565 {
00566    enum ast_format_cmp_res res = AST_FORMAT_CMP_NOT_EQUAL;
00567    struct format_cap_framed_list *list;
00568    struct format_cap_framed *framed;
00569 
00570    ast_assert(format != NULL);
00571 
00572    if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
00573       return AST_FORMAT_CMP_NOT_EQUAL;
00574    }
00575 
00576    list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
00577 
00578    AST_LIST_TRAVERSE(list, framed, entry) {
00579       enum ast_format_cmp_res cmp = ast_format_cmp(format, framed->format);
00580 
00581       if (cmp == AST_FORMAT_CMP_NOT_EQUAL) {
00582          continue;
00583       }
00584 
00585       res = cmp;
00586 
00587       if (res == AST_FORMAT_CMP_EQUAL) {
00588          break;
00589       }
00590    }
00591 
00592    return res;
00593 }

int ast_format_cap_remove ( struct ast_format_cap cap,
struct ast_format format 
)

Remove format capability from capability structure.

Note:
format must be an exact pointer match to remove from capabilities structure.
Return values:
0,remove was successful
-1,remove failed. Could not find format to remove

Definition at line 477 of file format_cap.c.

References ast_assert, ast_format_get_codec_id(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_VECTOR_GET_ADDR, AST_VECTOR_REMOVE_CMP_ORDERED, AST_VECTOR_SIZE, FORMAT_CAP_FRAMED_ELEM_CLEANUP, FORMAT_CAP_FRAMED_ELEM_CMP, and NULL.

Referenced by ast_format_cap_update_by_allow_disallow(), AST_TEST_DEFINE(), check_translation_path(), and phone_new().

00478 {
00479    struct format_cap_framed_list *list;
00480    struct format_cap_framed *framed;
00481 
00482    ast_assert(format != NULL);
00483 
00484    if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
00485       return -1;
00486    }
00487 
00488    list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
00489 
00490    AST_LIST_TRAVERSE_SAFE_BEGIN(list, framed, entry) {
00491       if (!FORMAT_CAP_FRAMED_ELEM_CMP(framed, format)) {
00492          continue;
00493       }
00494 
00495       AST_LIST_REMOVE_CURRENT(entry);
00496       FORMAT_CAP_FRAMED_ELEM_CLEANUP(framed);
00497       break;
00498    }
00499    AST_LIST_TRAVERSE_SAFE_END;
00500 
00501    return AST_VECTOR_REMOVE_CMP_ORDERED(&cap->preference_order, format,
00502       FORMAT_CAP_FRAMED_ELEM_CMP, FORMAT_CAP_FRAMED_ELEM_CLEANUP);
00503 }

void ast_format_cap_remove_by_type ( struct ast_format_cap cap,
enum ast_media_type  type 
)

Remove all formats matching a specific format type.

Parameters:
cap The capabilities structure
type The media type to remove formats of
Note:
All formats can be removed by using the AST_MEDIA_TYPE_UNKNOWN type.

Definition at line 505 of file format_cap.c.

References ao2_ref, ast_format_get_type(), AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_MEDIA_TYPE_UNKNOWN, AST_VECTOR_GET_ADDR, AST_VECTOR_REMOVE_CMP_ORDERED, AST_VECTOR_SIZE, format_cap_framed::format, FORMAT_CAP_FRAMED_ELEM_CLEANUP, and FORMAT_CAP_FRAMED_ELEM_CMP.

Referenced by action_originate(), ast_format_cap_update_by_allow_disallow(), ast_request(), ast_rtp_codecs_payload_formats(), AST_TEST_DEFINE(), chan_pjsip_set_rtp_peer(), check_peer_ok(), create_addr_from_peer(), format_cap_only_type(), handle_request_invite(), jingle_interpret_description(), load_module(), media_offer_write_av(), process_sdp(), reload_config(), set_caps(), sip_new(), sip_rtp_read(), sip_set_default_format_capabilities(), sip_set_rtp_peer(), skinny_session_cleanup(), transmit_modify_request(), and try_suggested_sip_codec().

00506 {
00507    int idx;
00508 
00509    for (idx = 0; idx < AST_VECTOR_SIZE(&cap->formats); ++idx) {
00510       struct format_cap_framed_list *list = AST_VECTOR_GET_ADDR(&cap->formats, idx);
00511       struct format_cap_framed *framed;
00512 
00513       AST_LIST_TRAVERSE_SAFE_BEGIN(list, framed, entry) {
00514          if ((type != AST_MEDIA_TYPE_UNKNOWN) &&
00515             ast_format_get_type(framed->format) != type) {
00516             continue;
00517          }
00518 
00519          AST_LIST_REMOVE_CURRENT(entry);
00520          AST_VECTOR_REMOVE_CMP_ORDERED(&cap->preference_order, framed->format,
00521             FORMAT_CAP_FRAMED_ELEM_CMP, FORMAT_CAP_FRAMED_ELEM_CLEANUP);
00522          ao2_ref(framed, -1);
00523       }
00524       AST_LIST_TRAVERSE_SAFE_END;
00525    }
00526 }

void ast_format_cap_replace_from_cap ( struct ast_format_cap dst,
const struct ast_format_cap src,
enum ast_media_type  type 
)

Replace the formats of provided type in dst with equivalent formats from src.

Parameters:
dst The destination capabilities structure
src The source capabilities structure
type The type of formats to replace.
Note:
If AST_MEDIA_TYPE_UNKNOWN is passed as the type all known codecs will be replaced.

Formats present in src but not dst will not be appended to dst.

Definition at line 303 of file format_cap.c.

References ast_format_get_type(), AST_MEDIA_TYPE_UNKNOWN, AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, format_cap_replace(), and format_cap_framed::framing.

Referenced by ast_sip_session_create_outgoing(), and AST_TEST_DEFINE().

00305 {
00306    int idx;
00307 
00308    for (idx = 0; (idx < AST_VECTOR_SIZE(&src->preference_order)); ++idx) {
00309       struct format_cap_framed *framed = AST_VECTOR_GET(&src->preference_order, idx);
00310 
00311       if (type == AST_MEDIA_TYPE_UNKNOWN || ast_format_get_type(framed->format) == type) {
00312          format_cap_replace(dst, framed->format, framed->framing);
00313       }
00314    }
00315 }

void ast_format_cap_set_framing ( struct ast_format_cap cap,
unsigned int  framing 
)

Set the global framing.

Parameters:
cap The capabilities structure.
framing The framing value (in milliseconds).
Note:
This is used if a format does not provide a framing itself. Note that adding subsequent formats to the ast_format_cap structure may override this value, if the framing they require is less than the value set by this function.

Definition at line 134 of file format_cap.c.

Referenced by ast_rtp_codecs_payload_formats(), AST_TEST_DEFINE(), and ooh323_set_write_format().

00135 {
00136    cap->framing = framing;
00137 }

int ast_format_cap_update_by_allow_disallow ( struct ast_format_cap cap,
const char *  list,
int  allowing 
)

Parse an "allow" or "deny" list and modify a format capabilities structure accordingly.

Parameters:
cap The capabilities structure to modify
list The list containing formats to append or remove
allowing If zero, start removing formats specified in the list. If non-zero, start appending formats specified in the list.
Return values:
0 on success
-1 on failure

Definition at line 317 of file format_cap.c.

References ao2_cleanup, ast_debug, ast_format_cache_get, ast_format_cap_append, ast_format_cap_append_by_type(), ast_format_cap_remove(), ast_format_cap_remove_by_type(), ast_log, AST_MEDIA_TYPE_UNKNOWN, ast_strdupa, ast_strlen_zero, format_cap_framed::format, LOG_WARNING, NULL, parse(), and strsep().

Referenced by action_originate(), apply_outgoing(), AST_TEST_DEFINE(), build_peer(), build_user(), codec_handler_fn(), config_parse_variables(), iax2_parse_allow_disallow(), media_offer_write_av(), reload_config(), and skinny_session_cleanup().

00318 {
00319    int res = 0, all = 0, iter_allowing;
00320    char *parse = NULL, *this = NULL, *psize = NULL;
00321 
00322    if (!allowing && ast_strlen_zero(list)) {
00323       return 0;
00324    }
00325 
00326    parse = ast_strdupa(list);
00327    while ((this = strsep(&parse, ","))) {
00328       int framems = 0;
00329       struct ast_format *format = NULL;
00330 
00331       iter_allowing = allowing;
00332       if (*this == '!') {
00333          this++;
00334          iter_allowing = !allowing;
00335       }
00336       if ((psize = strrchr(this, ':'))) {
00337          *psize++ = '\0';
00338          ast_debug(1, "Packetization for codec: %s is %s\n", this, psize);
00339          if (!sscanf(psize, "%30d", &framems) || (framems < 0)) {
00340             framems = 0;
00341             res = -1;
00342             ast_log(LOG_WARNING, "Bad packetization value for codec %s\n", this);
00343             continue;
00344          }
00345       }
00346       all = strcasecmp(this, "all") ? 0 : 1;
00347 
00348       if (!all && !(format = ast_format_cache_get(this))) {
00349          ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", iter_allowing ? "allow" : "disallow", this);
00350          res = -1;
00351          continue;
00352       }
00353 
00354       if (cap) {
00355          if (iter_allowing) {
00356             if (all) {
00357                ast_format_cap_append_by_type(cap, AST_MEDIA_TYPE_UNKNOWN);
00358             } else {
00359                ast_format_cap_append(cap, format, framems);
00360             }
00361          } else {
00362             if (all) {
00363                ast_format_cap_remove_by_type(cap, AST_MEDIA_TYPE_UNKNOWN);
00364             } else {
00365                ast_format_cap_remove(cap, format);
00366             }
00367          }
00368       }
00369 
00370       ao2_cleanup(format);
00371    }
00372    return res;
00373 }

static void format_cap_destroy ( void *  obj  )  [static]

Destructor for format capabilities structure.

Definition at line 72 of file format_cap.c.

References ao2_ref, AST_LIST_REMOVE_HEAD, AST_VECTOR_FREE, AST_VECTOR_GET, AST_VECTOR_GET_ADDR, and AST_VECTOR_SIZE.

Referenced by __ast_format_cap_alloc(), and __ast_format_cap_alloc_debug().

00073 {
00074    struct ast_format_cap *cap = obj;
00075    int idx;
00076 
00077    for (idx = 0; idx < AST_VECTOR_SIZE(&cap->formats); idx++) {
00078       struct format_cap_framed_list *list = AST_VECTOR_GET_ADDR(&cap->formats, idx);
00079       struct format_cap_framed *framed;
00080 
00081       while ((framed = AST_LIST_REMOVE_HEAD(list, entry))) {
00082          ao2_ref(framed, -1);
00083       }
00084    }
00085    AST_VECTOR_FREE(&cap->formats);
00086 
00087    for (idx = 0; idx < AST_VECTOR_SIZE(&cap->preference_order); idx++) {
00088       struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, idx);
00089 
00090       /* This will always be non-null, unlike formats */
00091       ao2_ref(framed, -1);
00092    }
00093    AST_VECTOR_FREE(&cap->preference_order);
00094 }

static void format_cap_framed_destroy ( void *  obj  )  [static]

Destructor for format capabilities framed structure.

Definition at line 140 of file format_cap.c.

References ao2_cleanup, and format_cap_framed::format.

Referenced by __ast_format_cap_append(), and __ast_format_cap_append_debug().

00141 {
00142    struct format_cap_framed *framed = obj;
00143 
00144    ao2_cleanup(framed->format);
00145 }

static int format_cap_framed_init ( struct format_cap_framed framed,
struct ast_format_cap cap,
struct ast_format format,
unsigned int  framing 
) [inline, static]

Definition at line 147 of file format_cap.c.

References ao2_ref, ast_format_get_codec_id(), ast_format_get_default_ms(), AST_LIST_INSERT_HEAD, AST_VECTOR_APPEND, AST_VECTOR_GET_ADDR, AST_VECTOR_INSERT, AST_VECTOR_SIZE, format_cap_framed_list_empty, format_cap_framed::framing, and MIN.

Referenced by __ast_format_cap_append(), and __ast_format_cap_append_debug().

00148 {
00149    struct format_cap_framed_list *list;
00150 
00151    framed->framing = framing;
00152 
00153    if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
00154       if (AST_VECTOR_INSERT(&cap->formats, ast_format_get_codec_id(format), format_cap_framed_list_empty)) {
00155          ao2_ref(framed, -1);
00156          return -1;
00157       }
00158    }
00159    list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
00160 
00161    /* Order doesn't matter for formats, so insert at the head for performance reasons */
00162    ao2_ref(framed, +1);
00163    AST_LIST_INSERT_HEAD(list, framed, entry);
00164 
00165    /* This takes the allocation reference */
00166    AST_VECTOR_APPEND(&cap->preference_order, framed);
00167 
00168    cap->framing = MIN(cap->framing, framing ? framing : ast_format_get_default_ms(format));
00169 
00170    return 0;
00171 }

static void format_cap_init ( struct ast_format_cap cap,
enum ast_format_cap_flags  flags 
) [inline, static]

Definition at line 96 of file format_cap.c.

References AST_VECTOR_INIT.

Referenced by __ast_format_cap_alloc(), and __ast_format_cap_alloc_debug().

00097 {
00098    AST_VECTOR_INIT(&cap->formats, 0);
00099 
00100    /* TODO: Look at common usage of this and determine a good starting point */
00101    AST_VECTOR_INIT(&cap->preference_order, 5);
00102 
00103    cap->framing = UINT_MAX;
00104 }

static int format_cap_replace ( struct ast_format_cap cap,
struct ast_format format,
unsigned int  framing 
) [static]

Definition at line 283 of file format_cap.c.

References ao2_t_replace, ast_assert, ast_format_get_codec_id(), AST_VECTOR_GET, AST_VECTOR_SIZE, format_cap_framed::format, format_cap_framed::framing, and NULL.

Referenced by ast_format_cap_replace_from_cap().

00284 {
00285    struct format_cap_framed *framed;
00286    int i;
00287 
00288    ast_assert(format != NULL);
00289 
00290    for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); i++) {
00291       framed = AST_VECTOR_GET(&cap->preference_order, i);
00292 
00293       if (ast_format_get_codec_id(format) == ast_format_get_codec_id(framed->format)) {
00294          ao2_t_replace(framed->format, format, "replacing with new format");
00295          framed->framing = framing;
00296          return 0;
00297       }
00298    }
00299 
00300    return -1;
00301 }

static int format_in_format_cap ( struct ast_format_cap cap,
struct ast_format format 
) [static]

Definition at line 174 of file format_cap.c.

References ast_format_get_codec_id(), AST_VECTOR_GET, AST_VECTOR_SIZE, and format_cap_framed::format.

Referenced by __ast_format_cap_append(), and __ast_format_cap_append_debug().

00175 {
00176    struct format_cap_framed *framed;
00177    int i;
00178 
00179    for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); i++) {
00180       framed = AST_VECTOR_GET(&cap->preference_order, i);
00181 
00182       if (ast_format_get_codec_id(format) == ast_format_get_codec_id(framed->format)) {
00183          return 1;
00184       }
00185    }
00186 
00187    return 0;
00188 }

static int internal_format_cap_identical ( const struct ast_format_cap cap1,
const struct ast_format_cap cap2 
) [static]

Definition at line 650 of file format_cap.c.

References ao2_ref, ast_format_cap_get_format(), ast_format_cap_iscompatible_format(), AST_FORMAT_CMP_EQUAL, AST_VECTOR_SIZE, and tmp().

Referenced by ast_format_cap_identical().

00651 {
00652    int idx;
00653    struct ast_format *tmp;
00654 
00655    for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
00656       tmp = ast_format_cap_get_format(cap1, idx);
00657 
00658       if (ast_format_cap_iscompatible_format(cap2, tmp) != AST_FORMAT_CMP_EQUAL) {
00659          ao2_ref(tmp, -1);
00660          return 0;
00661       }
00662 
00663       ao2_ref(tmp, -1);
00664    }
00665 
00666    return 1;
00667 }


Variable Documentation

struct format_cap_framed_list format_cap_framed_list_empty = AST_LIST_HEAD_NOLOCK_INIT_VALUE [static]

Dummy empty list for when we are inserting a new list.

Definition at line 69 of file format_cap.c.

Referenced by format_cap_framed_init().


Generated on Thu Apr 16 06:31:04 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6