Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Functions | Variables
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...
 

Macros

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

Functions

struct ast_format_cap__ast_format_cap_alloc (enum ast_format_cap_flags flags, const char *tag, const char *file, int line, const char *func)
 Allocate a new ast_format_cap structure. More...
 
int __ast_format_cap_append (struct ast_format_cap *cap, struct ast_format *format, unsigned int framing, const char *tag, const char *file, int line, const char *func)
 Add format capability to capabilities structure. More...
 
static const char * __ast_format_cap_get_names (const struct ast_format_cap *cap, struct ast_str **buf, int append)
 
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. More...
 
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. More...
 
const char * ast_format_cap_append_names (const struct ast_format_cap *cap, struct ast_str **buf)
 Append the names of codecs of a set of formats to an ast_str buffer. More...
 
size_t ast_format_cap_count (const struct ast_format_cap *cap)
 Get the number of formats present within the capabilities structure. More...
 
int ast_format_cap_empty (const struct ast_format_cap *cap)
 Determine if a format cap has no formats in it. More...
 
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. More...
 
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. More...
 
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. More...
 
struct ast_formatast_format_cap_get_format (const struct ast_format_cap *cap, int position)
 Get the format at a specific index. More...
 
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. More...
 
unsigned int ast_format_cap_get_framing (const struct ast_format_cap *cap)
 Get the global framing. More...
 
const char * ast_format_cap_get_names (const struct ast_format_cap *cap, struct ast_str **buf)
 Get the names of codecs of a set of formats. More...
 
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. More...
 
int ast_format_cap_identical (const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)
 Determine if two capabilities structures are identical. More...
 
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. More...
 
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. More...
 
int ast_format_cap_remove (struct ast_format_cap *cap, struct ast_format *format)
 Remove format capability from capability structure. More...
 
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. More...
 
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. More...
 
void ast_format_cap_set_framing (struct ast_format_cap *cap, unsigned int framing)
 Set the global framing. More...
 
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. More...
 
static void format_cap_destroy (void *obj)
 Destructor for format capabilities structure. More...
 
static void format_cap_framed_destroy (void *obj)
 Destructor for format capabilities framed structure. More...
 
static int format_cap_framed_init (struct format_cap_framed *framed, struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)
 
static int 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 const 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. More...
 

Detailed Description

Format Capabilities API.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file format_cap.c.

Macro Definition Documentation

◆ FORMAT_CAP_FRAMED_ELEM_CLEANUP

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

format_cap_framed vector element cleanup.

Parameters
elemElement to cleanup
Returns
Nothing

Definition at line 495 of file format_cap.c.

Referenced by ast_format_cap_remove(), and ast_format_cap_remove_by_type().

◆ FORMAT_CAP_FRAMED_ELEM_CMP

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

format_cap_framed comparator for AST_VECTOR_REMOVE_CMP_ORDERED()

Parameters
elemElement to compare against
valueValue to compare with the vector element.
Returns
0 if element does not match.
Non-zero if element matches.

Definition at line 486 of file format_cap.c.

Referenced by ast_format_cap_remove(), and ast_format_cap_remove_by_type().

Function Documentation

◆ __ast_format_cap_alloc()

struct ast_format_cap* __ast_format_cap_alloc ( enum ast_format_cap_flags  flags,
const char *  tag,
const char *  file,
int  line,
const char *  func 
)

Allocate a new ast_format_cap structure.

Parameters
flagsModifiers of struct behavior.
Return values
ast_format_capobject on success.
NULLon failure.

Definition at line 117 of file format_cap.c.

References __ao2_alloc(), AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_ref, format_cap_destroy(), format_cap_init(), and NULL.

119 {
120  struct ast_format_cap *cap;
121 
123  tag, file, line, func);
124  if (!cap) {
125  return NULL;
126  }
127 
128  if (format_cap_init(cap, flags)) {
129  ao2_ref(cap, -1);
130  return NULL;
131  }
132 
133  return cap;
134 }
void * __ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
Definition: astobj2.c:765
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
static int format_cap_init(struct ast_format_cap *cap, enum ast_format_cap_flags flags)
Definition: format_cap.c:102
static void format_cap_destroy(void *obj)
Destructor for format capabilities structure.
Definition: format_cap.c:70

◆ __ast_format_cap_append()

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

Add format capability to capabilities structure.

Parameters
capThe capabilities structure to add to.
formatThe format to add.
framingThe framing for the format (in milliseconds).
Return values
0success
-1failure
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 195 of file format_cap.c.

References __ao2_ref(), 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(), and NULL.

196 {
197  struct format_cap_framed *framed;
198 
199  ast_assert(format != NULL);
200 
201  if (format_in_format_cap(cap, format)) {
202  return 0;
203  }
204 
206  if (!framed) {
207  return -1;
208  }
209 
210  __ao2_ref(format, +1, tag, file, line, func);
211  framed->format = format;
212 
213  return format_cap_framed_init(framed, cap, format, framing);
214 }
static int format_in_format_cap(struct ast_format_cap *cap, struct ast_format *format)
Definition: format_cap.c:179
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
static void format_cap_framed_destroy(void *obj)
Destructor for format capabilities framed structure.
Definition: format_cap.c:142
unsigned int framing
The format framing size.
Definition: format_cap.c:48
int __ao2_ref(void *o, int delta, const char *tag, const char *file, int line, const char *func)
Definition: astobj2.c:498
static int format_cap_framed_init(struct format_cap_framed *framed, struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)
Definition: format_cap.c:149
static snd_pcm_format_t format
Definition: chan_alsa.c:102
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ __ast_format_cap_get_names()

static const char* __ast_format_cap_get_names ( const struct ast_format_cap cap,
struct ast_str **  buf,
int  append 
)
static

Definition at line 702 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 ast_format_cap_append_names(), and ast_format_cap_get_names().

703 {
704  int i;
705 
706  if (!buf || !*buf) {
707  return "";
708  }
709 
710  if (append) {
711  ast_str_append(buf, 0, "(");
712  } else {
713  ast_str_set(buf, 0, "(");
714  }
715 
716  if (!cap || !AST_VECTOR_SIZE(&cap->preference_order)) {
717  ast_str_append(buf, 0, "nothing)");
718  return ast_str_buffer(*buf);
719  }
720 
721  for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); ++i) {
722  int res;
723  struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, i);
724 
725  res = ast_str_append(buf, 0, "%s%s", ast_format_get_name(framed->format),
726  i < AST_VECTOR_SIZE(&cap->preference_order) - 1 ? "|" : "");
727  if (res < 0) {
728  break;
729  }
730  }
731  ast_str_append(buf, 0, ")");
732 
733  return ast_str_buffer(*buf);
734 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1091
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1065
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_append_by_type()

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
capThe capabilities structure to add to.
typeThe type of formats to add.
Return values
0success
-1failure
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 216 of file format_cap.c.

References ao2_cleanup, ao2_ref, ast_codec_get_by_id(), ast_codec_get_max(), ast_format_cache_get_by_codec(), ast_format_cap_append, ast_format_create(), ast_format_get_codec(), ast_format_none, AST_MEDIA_TYPE_UNKNOWN, codec2, format_cap_framed::format, id, NULL, and ast_codec::type.

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

217 {
218  int id;
219 
220  for (id = 1; id < ast_codec_get_max(); ++id) {
221  struct ast_codec *codec = ast_codec_get_by_id(id);
222  struct ast_codec *codec2 = NULL;
223  struct ast_format *format;
224  int res;
225 
226  if (!codec) {
227  continue;
228  }
229 
230  if ((type != AST_MEDIA_TYPE_UNKNOWN) && codec->type != type) {
231  ao2_ref(codec, -1);
232  continue;
233  }
234 
235  format = ast_format_cache_get_by_codec(codec);
236 
237  if (format == ast_format_none) {
238  ao2_ref(format, -1);
239  ao2_ref(codec, -1);
240  continue;
241  }
242 
243  if (format) {
244  codec2 = ast_format_get_codec(format);
245  }
246  if (codec != codec2) {
247  ao2_cleanup(format);
248  format = ast_format_create(codec);
249  }
250  ao2_cleanup(codec2);
251  ao2_ref(codec, -1);
252 
253  if (!format) {
254  return -1;
255  }
256 
257  /* Use the global framing or default framing of the codec */
258  res = ast_format_cap_append(cap, format, 0);
259  ao2_ref(format, -1);
260 
261  if (res) {
262  return -1;
263  }
264  }
265 
266  return 0;
267 }
static const char type[]
Definition: chan_ooh323.c:109
struct ast_codec * ast_format_get_codec(const struct ast_format *format)
Get the codec associated with a format.
Definition: format.c:324
struct ast_format * ast_format_cache_get_by_codec(const struct ast_codec *codec)
Retrieve a format from the cache by its codec.
Definition: format_cache.c:559
struct ast_format * ast_format_create(struct ast_codec *codec)
Create a new media format.
Definition: format.c:196
struct ast_codec * ast_codec_get_by_id(int id)
Retrieve a codec given the unique identifier.
Definition: codec.c:337
Definition of a media format.
Definition: format.c:43
#define NULL
Definition: resample.c:96
struct ast_format * ast_format_none
Built-in "null" format.
Definition: format_cache.c:251
int ast_codec_get_max(void)
Retrieve the current maximum identifier for codec iteration.
Definition: codec.c:342
static struct ast_codec codec2
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
enum ast_media_type type
Type of media this codec contains.
Definition: codec.h:50
enum queue_result id
Definition: app_queue.c:1507
static snd_pcm_format_t format
Definition: chan_alsa.c:102
Represents a media codec within Asterisk.
Definition: codec.h:42

◆ ast_format_cap_append_from_cap()

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
dstThe destination capabilities structure
srcThe source capabilities structure
typeThe type of formats to append.
Return values
0success
-1failure
Note
If AST_MEDIA_TYPE_UNKNOWN is passed as the type all known codecs will be added.

Definition at line 269 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_sip_create_joint_call_cap(), ast_stream_clone(), ast_stream_create_resolved(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_get_formats_by_type(), AST_TEST_DEFINE(), build_device(), build_gateway(), build_peer(), build_user(), chan_pjsip_get_codec(), chan_pjsip_new(), chan_pjsip_read_stream(), 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(), media_offer_write_av(), mgcp_get_codec(), mgcp_new(), ooh323_alloc(), ooh323_get_codec(), ooh323_onReceivedSetup(), ooh323_request(), phone_new(), process_sdp(), request_channel(), send_direct_media_request(), 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().

271 {
272  int idx, res = 0;
273 
274  /* NOTE: The streams API is dependent on the formats being in "preference" order */
275  for (idx = 0; (idx < AST_VECTOR_SIZE(&src->preference_order)) && !res; ++idx) {
276  struct format_cap_framed *framed = AST_VECTOR_GET(&src->preference_order, idx);
277 
279  res = ast_format_cap_append(dst, framed->format, framed->framing);
280  }
281  }
282 
283  return res;
284 }
static const char type[]
Definition: chan_ooh323.c:109
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
unsigned int framing
The format framing size.
Definition: format_cap.c:48
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_append_names()

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

Append the names of codecs of a set of formats to an ast_str buffer.

Since
18
Parameters
capThe capabilities structure containing the formats
bufA ast_str buffer to append the names of the formats to
Returns
The contents of the buffer in buf

Definition at line 741 of file format_cap.c.

References __ast_format_cap_get_names().

Referenced by ast_stream_create_resolved(), and ast_stream_to_str().

742 {
743  return __ast_format_cap_get_names(cap, buf, 1);
744 }
static const char * __ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf, int append)
Definition: format_cap.c:702

◆ ast_format_cap_count()

size_t ast_format_cap_count ( const struct ast_format_cap cap)

Get the number of formats present within the capabilities structure.

Parameters
capThe capabilities structure
Returns
the number of formats

Definition at line 395 of file format_cap.c.

References AST_VECTOR_SIZE.

Referenced by add_format_information_cb(), add_sdp(), apply_cap_to_bundled(), ast_format_cap_empty(), ast_iax2_new(), ast_openvstream(), ast_rtp_instance_available_formats(), ast_rtp_lookup_mime_multiple2(), ast_stream_get_format_count(), ast_stream_topology_create_from_format_cap(), ast_stream_topology_equal(), AST_TEST_DEFINE(), ast_translate_available_formats(), ast_translator_best_choice(), begin_dial_prerun(), check_peer_ok(), check_translation_path(), configure_local_rtp(), create_addr(), create_outgoing_sdp_stream(), derive_format_from_cap(), handle_request_invite(), iax2_codec_pref_string(), iax2_format_compatibility_cap2bitfield(), iax2_parse_allow_disallow(), iax2_request(), jingle_add_payloads_to_description(), jingle_interpret_description(), jingle_new(), media_offer_read_av(), mgcp_new(), native_rtp_bridge_compatible_check(), ooh323_get_codec(), ooh323_write(), ooh323c_set_capability(), ooh323c_set_capability_for_call(), process_sdp(), send_direct_media_request(), set_caps(), show_sound_info_cb(), sip_new(), sip_session_refresh(), sip_set_rtp_peer(), skinny_new(), transmit_connect(), transmit_connect_with_sdp(), transmit_modify_request(), transmit_modify_with_sdp(), and unistim_new().

396 {
397  return AST_VECTOR_SIZE(&cap->preference_order);
398 }
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ ast_format_cap_empty()

int ast_format_cap_empty ( const struct ast_format_cap cap)

Determine if a format cap has no formats in it.

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

Definition at line 746 of file format_cap.c.

References ast_format_cap_count(), ast_format_none, and AST_VECTOR_GET.

Referenced by ast_sip_create_joint_call_cap(), ast_stream_create_resolved(), ast_translator_best_choice(), chan_pjsip_new(), request_channel(), set_format(), set_incoming_call_offer_cap(), sip_call(), and sip_request_call().

747 {
748  int count = ast_format_cap_count(cap);
749 
750  if (count > 1) {
751  return 0;
752  }
753 
754  if (count == 0 || AST_VECTOR_GET(&cap->preference_order, 0)->format == ast_format_none) {
755  return 1;
756  }
757 
758  return 0;
759 }
struct ast_format * ast_format_none
Built-in "null" format.
Definition: format_cache.c:251
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
size_t ast_format_cap_count(const struct ast_format_cap *cap)
Get the number of formats present within the capabilities structure.
Definition: format_cap.c:395

◆ ast_format_cap_get_best_by_type()

struct ast_format* ast_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.

Parameters
capThe capabilities structure
typeThe type of media to get
Return values
non-NULLthe preferred format
NULLno 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 417 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_caps(), set_format(), sip_new(), and sip_session_response_cb().

418 {
419  int i;
420 
421  if (type == AST_MEDIA_TYPE_UNKNOWN) {
422  return ast_format_cap_get_format(cap, 0);
423  }
424 
425  for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); i++) {
426  struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, i);
427 
428  if (ast_format_get_type(framed->format) == type) {
429  ao2_ref(framed->format, +1);
430  ast_assert(framed->format != ast_format_none);
431  return framed->format;
432  }
433  }
434 
435  return NULL;
436 }
static const char type[]
Definition: chan_ooh323.c:109
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
struct ast_format * ast_format_none
Built-in "null" format.
Definition: format_cache.c:251
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_get_compatible()

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
cap1The first capabilities structure
cap2The second capabilities structure
[out]resultThe capabilities structure to place the results into
Return values
0success
-1failure
Note
The preference order of cap1 is respected.
If failure occurs the result format capabilities structure may contain a partial result.

Definition at line 630 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_create_joint_call_cap(), ast_speech_new(), ast_stream_create_resolved(), 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(), sip_session_refresh(), and skinny_register().

632 {
633  int idx, res = 0;
634 
635  for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
636  struct format_cap_framed *framed = AST_VECTOR_GET(&cap1->preference_order, idx);
637  struct ast_format *format;
638 
639  format = ast_format_cap_get_compatible_format(cap2, framed->format);
640  if (!format) {
641  continue;
642  }
643 
644  res = ast_format_cap_append(result, format, framed->framing);
645  ao2_ref(format, -1);
646 
647  if (res) {
648  break;
649  }
650  }
651 
652  return res;
653 }
Definition of a media format.
Definition: format.c:43
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
unsigned int framing
The format framing size.
Definition: format_cap.c:48
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
struct ast_format * ast_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 comp...
Definition: format_cap.c:548
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
static snd_pcm_format_t format
Definition: chan_alsa.c:102
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_get_compatible_format()

struct ast_format* ast_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.

Return values
non-NULLif format is compatible
NULLif 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 548 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().

549 {
550  struct format_cap_framed_list *list;
551  struct format_cap_framed *framed;
552  struct ast_format *result = NULL;
553 
554  ast_assert(format != NULL);
555 
556  if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
557  return NULL;
558  }
559 
560  list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
561 
562  AST_LIST_TRAVERSE(list, framed, entry) {
563  enum ast_format_cmp_res res = ast_format_cmp(format, framed->format);
564 
565  if (res == AST_FORMAT_CMP_NOT_EQUAL) {
566  continue;
567  }
568 
569  /* Replace any current result, this one will also be a subset OR an exact match */
570  ao2_cleanup(result);
571 
572  result = ast_format_joint(format, framed->format);
573 
574  /* If it's a match we can do no better so return asap */
575  if (res == AST_FORMAT_CMP_EQUAL) {
576  break;
577  }
578  }
579 
580  return result;
581 }
Definition of a media format.
Definition: format.c:43
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
struct ast_format * ast_format_joint(const struct ast_format *format1, const struct ast_format *format2)
Get a common joint capability between two formats.
Definition: format.c:226
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
ast_format_cmp_res
Format comparison results.
Definition: format.h:34
Linked list for formats.
Definition: format_cap.c:64
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static PGresult * result
Definition: cel_pgsql.c:88
Definition: search.h:40
unsigned int ast_format_get_codec_id(const struct ast_format *format)
Get the codec identifier associated with a format.
Definition: format.c:329
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_get_format()

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

Get the format at a specific index.

Parameters
capThe capabilities structure
positionThe position to get
Return values
non-NULLsuccess
NULLfailure
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 400 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(), apply_cap_to_bundled(), ast_format_cap_get_best_by_type(), ast_iax2_new(), ast_openvstream(), ast_rtp_lookup_mime_multiple2(), ast_sip_create_joint_call_cap(), ast_speech_new(), ast_stream_create_resolved(), AST_TEST_DEFINE(), ast_translate_available_formats(), ast_translator_best_choice(), ast_unreal_new_channels(), audiosocket_request(), chan_pjsip_new(), check_translation_path(), configure_local_rtp(), create_addr(), create_outgoing_sdp_stream(), derive_format_from_cap(), 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(), mp3_exec(), ooh323_new(), ooh323c_set_capability(), ooh323c_set_capability_for_call(), phone_new(), process_sdp(), set_caps(), 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(), and unistim_new().

401 {
402  struct format_cap_framed *framed;
403 
404  ast_assert(position < AST_VECTOR_SIZE(&cap->preference_order));
405 
406  if (position >= AST_VECTOR_SIZE(&cap->preference_order)) {
407  return NULL;
408  }
409 
410  framed = AST_VECTOR_GET(&cap->preference_order, position);
411 
412  ast_assert(framed->format != ast_format_none);
413  ao2_ref(framed->format, +1);
414  return framed->format;
415 }
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
struct ast_format * ast_format_none
Built-in "null" format.
Definition: format_cache.c:251
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_get_format_framing()

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
capThe capabilities structure
formatThe format to retrieve
Returns
the framing (in milliseconds)

Definition at line 443 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_check(), ooh323c_set_capability_for_call(), process_sdp(), sip_new(), skinny_set_rtp_peer(), and transmit_connect().

444 {
445  unsigned int framing;
446  struct format_cap_framed_list *list;
447  struct format_cap_framed *framed, *result = NULL;
448 
449  if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
450  return 0;
451  }
452 
453  framing = cap->framing != UINT_MAX ? cap->framing : ast_format_get_default_ms(format);
454  list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
455 
456  AST_LIST_TRAVERSE(list, framed, entry) {
457  enum ast_format_cmp_res res = ast_format_cmp(format, framed->format);
458 
459  if (res == AST_FORMAT_CMP_NOT_EQUAL) {
460  continue;
461  }
462 
463  result = framed;
464 
465  if (res == AST_FORMAT_CMP_EQUAL) {
466  break;
467  }
468  }
469 
470  if (result && result->framing) {
471  framing = result->framing;
472  }
473 
474  return framing;
475 }
#define NULL
Definition: resample.c:96
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
unsigned int framing
The format framing size.
Definition: format_cap.c:48
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
ast_format_cmp_res
Format comparison results.
Definition: format.h:34
Linked list for formats.
Definition: format_cap.c:64
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
unsigned int ast_format_get_default_ms(const struct ast_format *format)
Get the default framing size (in milliseconds) for a format.
Definition: format.c:359
static PGresult * result
Definition: cel_pgsql.c:88
Definition: search.h:40
unsigned int ast_format_get_codec_id(const struct ast_format *format)
Get the codec identifier associated with a format.
Definition: format.c:329
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_get_framing()

unsigned int ast_format_cap_get_framing ( const struct ast_format_cap cap)

Get the global framing.

Parameters
capThe capabilities structure.
Return values
0if no formats are in the structure and no framing has been provided
Theglobal 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 438 of file format_cap.c.

Referenced by ast_stream_create_resolved(), ast_stream_topology_create_from_format_cap(), AST_TEST_DEFINE(), check_peer_ok(), configure_local_rtp(), create_addr_from_peer(), create_outgoing_sdp_stream(), jingle_enable_video(), jingle_new(), set_caps(), and start_rtp().

439 {
440  return (cap->framing != UINT_MAX) ? cap->framing : 0;
441 }

◆ ast_format_cap_get_names()

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

Get the names of codecs of a set of formats.

Parameters
capThe capabilities structure containing the formats
bufA ast_str buffer to populate with the names of the formats
Returns
The contents of the buffer in buf

Definition at line 736 of file format_cap.c.

References __ast_format_cap_get_names().

Referenced by _sip_show_peer(), _skinny_show_device(), _skinny_show_line(), add_sdp(), alsa_request(), ast_channel_nativeformats_set(), ast_streamfile(), AST_TEST_DEFINE(), ast_write_stream(), chan_pjsip_get_codec(), chan_pjsip_set_rtp_peer(), chan_pjsip_write_stream(), codec_handler_fn(), compatible_formats_exist(), 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_key_rotate(), iax2_request(), jingle_write(), local_request_with_stream_topology(), log_caps(), mbl_request(), mgcp_request(), mgcp_write(), native_rtp_bridge_compatible_check(), nbs_request(), onNewCallCreated(), ooh323_request(), ooh323_set_write_format(), ooh323_write(), oss_request(), phone_request(), process_sdp(), request_channel(), 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(), test_create_joint(), unistim_new(), unistim_request(), unistim_rtp_read(), unistim_show_info(), and unistim_write().

737 {
738  return __ast_format_cap_get_names(cap, buf, 0);
739 }
static const char * __ast_format_cap_get_names(const struct ast_format_cap *cap, struct ast_str **buf, int append)
Definition: format_cap.c:702

◆ ast_format_cap_has_type()

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
1true
0false, no formats of specific type.

Definition at line 615 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_data(), ast_stream_topology_create_from_format_cap(), AST_TEST_DEFINE(), dialog_initialize_rtp(), jingle_enable_video(), jingle_request(), negotiate_incoming_sdp_stream(), ooh323_request(), process_sdp(), sip_call(), sip_new(), and skinny_request().

616 {
617  int idx;
618 
619  for (idx = 0; idx < AST_VECTOR_SIZE(&cap->preference_order); ++idx) {
620  struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, idx);
621 
622  if (ast_format_get_type(framed->format) == type) {
623  return 1;
624  }
625  }
626 
627  return 0;
628 }
static const char type[]
Definition: chan_ooh323.c:109
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_identical()

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
cap1The first capabilities structure
cap2The second capabilities structure
Return values
0capabilities are not identical
1capabilities are identical

Definition at line 689 of file format_cap.c.

References AST_VECTOR_SIZE, and internal_format_cap_identical().

Referenced by ast_stream_topology_equal(), AST_TEST_DEFINE(), iax2_key_rotate(), send_direct_media_request(), sip_set_rtp_peer(), and validate_stream().

690 {
691  if (AST_VECTOR_SIZE(&cap1->preference_order) != AST_VECTOR_SIZE(&cap2->preference_order)) {
692  return 0; /* if they are not the same size, they are not identical */
693  }
694 
695  if (!internal_format_cap_identical(cap1, cap2)) {
696  return 0;
697  }
698 
699  return internal_format_cap_identical(cap2, cap1);
700 }
static int internal_format_cap_identical(const struct ast_format_cap *cap1, const struct ast_format_cap *cap2)
Definition: format_cap.c:670
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ ast_format_cap_iscompatible()

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
cap1The first capabilities structure
cap2The second capabilities structure
Return values
0no joint capabilities exist
1joint capabilities exist

Definition at line 655 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(), compatible_formats_exist(), console_request(), mgcp_request(), native_rtp_bridge_compatible_check(), phone_request(), and unistim_request().

656 {
657  int idx;
658 
659  for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
660  struct format_cap_framed *framed = AST_VECTOR_GET(&cap1->preference_order, idx);
661 
663  return 1;
664  }
665  }
666 
667  return 0;
668 }
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
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.
Definition: format_cap.c:583
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_iscompatible_format()

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_resrepresenting the result of the compatibility check between cap and format.

Definition at line 583 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_read_stream(), chan_pjsip_write_stream(), check_translation_path(), internal_format_cap_identical(), is_compatible_format(), 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().

585 {
587  struct format_cap_framed_list *list;
588  struct format_cap_framed *framed;
589 
590  ast_assert(format != NULL);
591 
592  if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
594  }
595 
596  list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
597 
598  AST_LIST_TRAVERSE(list, framed, entry) {
599  enum ast_format_cmp_res cmp = ast_format_cmp(format, framed->format);
600 
601  if (cmp == AST_FORMAT_CMP_NOT_EQUAL) {
602  continue;
603  }
604 
605  res = cmp;
606 
607  if (res == AST_FORMAT_CMP_EQUAL) {
608  break;
609  }
610  }
611 
612  return res;
613 }
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
ast_format_cmp_res
Format comparison results.
Definition: format.h:34
Linked list for formats.
Definition: format_cap.c:64
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
Definition: search.h:40
unsigned int ast_format_get_codec_id(const struct ast_format *format)
Get the codec identifier associated with a format.
Definition: format.c:329
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_remove()

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,removewas successful
-1,removefailed. Could not find format to remove

Definition at line 497 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().

498 {
499  struct format_cap_framed_list *list;
500  struct format_cap_framed *framed;
501 
502  ast_assert(format != NULL);
503 
504  if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
505  return -1;
506  }
507 
508  list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
509 
510  AST_LIST_TRAVERSE_SAFE_BEGIN(list, framed, entry) {
511  if (!FORMAT_CAP_FRAMED_ELEM_CMP(framed, format)) {
512  continue;
513  }
514 
517  break;
518  }
520 
521  return AST_VECTOR_REMOVE_CMP_ORDERED(&cap->preference_order, format,
523 }
#define FORMAT_CAP_FRAMED_ELEM_CLEANUP(elem)
format_cap_framed vector element cleanup.
Definition: format_cap.c:495
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
Linked list for formats.
Definition: format_cap.c:64
#define FORMAT_CAP_FRAMED_ELEM_CMP(elem, value)
format_cap_framed comparator for AST_VECTOR_REMOVE_CMP_ORDERED()
Definition: format_cap.c:486
#define AST_VECTOR_REMOVE_CMP_ORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison while maintaining order...
Definition: vector.h:540
Definition: search.h:40
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
unsigned int ast_format_get_codec_id(const struct ast_format *format)
Get the codec identifier associated with a format.
Definition: format.c:329
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_remove_by_type()

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
capThe capabilities structure
typeThe media type to remove formats of
Note
All formats can be removed by using the AST_MEDIA_TYPE_UNKNOWN type.

Definition at line 525 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_rtp_codecs_payload_formats(), ast_sip_create_joint_call_cap(), ast_stream_create_resolved(), AST_TEST_DEFINE(), build_peer(), chan_pjsip_read_stream(), check_peer_ok(), create_addr_from_peer(), handle_request_invite(), jingle_interpret_description(), load_module(), media_offer_write_av(), originate_exec(), process_sdp(), reload_config(), request_channel(), send_direct_media_request(), 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().

526 {
527  int idx;
528 
529  for (idx = 0; idx < AST_VECTOR_SIZE(&cap->formats); ++idx) {
530  struct format_cap_framed_list *list = AST_VECTOR_GET_ADDR(&cap->formats, idx);
531  struct format_cap_framed *framed;
532 
533  AST_LIST_TRAVERSE_SAFE_BEGIN(list, framed, entry) {
534  if ((type != AST_MEDIA_TYPE_UNKNOWN) &&
535  ast_format_get_type(framed->format) != type) {
536  continue;
537  }
538 
540  AST_VECTOR_REMOVE_CMP_ORDERED(&cap->preference_order, framed->format,
542  ao2_ref(framed, -1);
543  }
545  }
546 }
static const char type[]
Definition: chan_ooh323.c:109
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
#define FORMAT_CAP_FRAMED_ELEM_CLEANUP(elem)
format_cap_framed vector element cleanup.
Definition: format_cap.c:495
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:614
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:556
#define ao2_ref(o, delta)
Definition: astobj2.h:464
Linked list for formats.
Definition: format_cap.c:64
#define FORMAT_CAP_FRAMED_ELEM_CMP(elem, value)
format_cap_framed comparator for AST_VECTOR_REMOVE_CMP_ORDERED()
Definition: format_cap.c:486
#define AST_VECTOR_REMOVE_CMP_ORDERED(vec, value, cmp, cleanup)
Remove an element from a vector that matches the given comparison while maintaining order...
Definition: vector.h:540
Definition: search.h:40
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:528
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_replace_from_cap()

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
dstThe destination capabilities structure
srcThe source capabilities structure
typeThe 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 306 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_TEST_DEFINE(), and try_suggested_sip_codec().

308 {
309  int idx;
310 
311  for (idx = 0; (idx < AST_VECTOR_SIZE(&src->preference_order)); ++idx) {
312  struct format_cap_framed *framed = AST_VECTOR_GET(&src->preference_order, idx);
313 
315  format_cap_replace(dst, framed->format, framed->framing);
316  }
317  }
318 }
static const char type[]
Definition: chan_ooh323.c:109
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
unsigned int framing
The format framing size.
Definition: format_cap.c:48
static int format_cap_replace(struct ast_format_cap *cap, struct ast_format *format, unsigned int framing)
Definition: format_cap.c:286
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ ast_format_cap_set_framing()

void ast_format_cap_set_framing ( struct ast_format_cap cap,
unsigned int  framing 
)

Set the global framing.

Parameters
capThe capabilities structure.
framingThe 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 136 of file format_cap.c.

References format_cap_framed::framing.

Referenced by ast_rtp_codecs_payload_formats(), ast_stream_create_resolved(), ast_stream_topology_create_from_format_cap(), AST_TEST_DEFINE(), ooh323_set_write_format(), and process_sdp_a_audio().

137 {
138  cap->framing = framing;
139 }
unsigned int framing
The format framing size.
Definition: format_cap.c:48

◆ ast_format_cap_update_by_allow_disallow()

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
capThe capabilities structure to modify
listThe list containing formats to append or remove
allowingIf zero, start removing formats specified in the list. If non-zero, start appending formats specified in the list.
Return values
0on success
-1on failure

Definition at line 320 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_strip(), ast_strlen_zero, format_cap_framed::format, LOG_WARNING, NULL, parse(), and strsep().

Referenced by action_originate(), AST_TEST_DEFINE(), build_peer(), build_topology(), build_user(), codec_handler_fn(), config_parse_variables(), iax2_parse_allow_disallow(), media_offer_write_av(), originate_exec(), parse_line(), reload_config(), skinny_session_cleanup(), test_create_joint(), and validate_stream().

321 {
322  int res = 0, all = 0, iter_allowing;
323  char *parse = NULL, *this = NULL, *psize = NULL;
324 
325  if (!allowing && ast_strlen_zero(list)) {
326  return 0;
327  }
328 
329  parse = ast_strdupa(list);
330 
331  /* If the list is being fed to us as a result of ast_format_cap_get_names,
332  * strip off the parenthesis and immediately apply the inverse of the
333  * allowing option
334  */
335  if (parse[0] == '(' && parse[strlen(parse) - 1] == ')') {
336  parse++;
337  parse[strlen(parse) - 1] = '\0';
338 
339  if (allowing) {
341  } else {
343  }
344  }
345 
346 
347  while ((this = ast_strip(strsep(&parse, ",|")))) {
348  int framems = 0;
349  struct ast_format *format = NULL;
350 
351  iter_allowing = allowing;
352  if (*this == '!') {
353  this++;
354  iter_allowing = !allowing;
355  }
356  if ((psize = strrchr(this, ':'))) {
357  *psize++ = '\0';
358  ast_debug(1, "Packetization for codec: %s is %s\n", this, psize);
359  if (!sscanf(psize, "%30d", &framems) || (framems < 0)) {
360  framems = 0;
361  res = -1;
362  ast_log(LOG_WARNING, "Bad packetization value for codec %s\n", this);
363  continue;
364  }
365  }
366  all = strcasecmp(this, "all") ? 0 : 1;
367 
368  if (!all && !(format = ast_format_cache_get(this))) {
369  ast_log(LOG_WARNING, "Cannot %s unknown format '%s'\n", iter_allowing ? "allow" : "disallow", this);
370  res = -1;
371  continue;
372  }
373 
374  if (cap) {
375  if (iter_allowing) {
376  if (all) {
378  } else {
379  ast_format_cap_append(cap, format, framems);
380  }
381  } else {
382  if (all) {
384  } else {
385  ast_format_cap_remove(cap, format);
386  }
387  }
388  }
389 
390  ao2_cleanup(format);
391  }
392  return res;
393 }
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.
Definition: format_cap.c:216
#define LOG_WARNING
Definition: logger.h:274
Definition of a media format.
Definition: format.c:43
#define NULL
Definition: resample.c:96
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.
Definition: format_cap.c:525
#define ast_format_cache_get(name)
Definition: format_cache.h:286
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:219
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define ast_format_cap_append(cap, format, framing)
Definition: format_cap.h:103
int ast_format_cap_remove(struct ast_format_cap *cap, struct ast_format *format)
Remove format capability from capability structure.
Definition: format_cap.c:497
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
char * strsep(char **str, const char *delims)
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static snd_pcm_format_t format
Definition: chan_alsa.c:102

◆ format_cap_destroy()

static void format_cap_destroy ( void *  obj)
static

Destructor for format capabilities structure.

Definition at line 70 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().

71 {
72  struct ast_format_cap *cap = obj;
73  int idx;
74 
75  for (idx = 0; idx < AST_VECTOR_SIZE(&cap->formats); idx++) {
76  struct format_cap_framed_list *list = AST_VECTOR_GET_ADDR(&cap->formats, idx);
77  struct format_cap_framed *framed;
78 
79  while ((framed = AST_LIST_REMOVE_HEAD(list, entry))) {
80  ao2_ref(framed, -1);
81  }
82  }
83  AST_VECTOR_FREE(&cap->formats);
84 
85  for (idx = 0; idx < AST_VECTOR_SIZE(&cap->preference_order); idx++) {
86  struct format_cap_framed *framed = AST_VECTOR_GET(&cap->preference_order, idx);
87 
88  /* This will always be non-null, unlike formats */
89  ao2_ref(framed, -1);
90  }
91  AST_VECTOR_FREE(&cap->preference_order);
92 }
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:832
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
Linked list for formats.
Definition: format_cap.c:64
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
Definition: search.h:40
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ format_cap_framed_destroy()

static void format_cap_framed_destroy ( void *  obj)
static

Destructor for format capabilities framed structure.

Definition at line 142 of file format_cap.c.

References ao2_cleanup, and format_cap_framed::format.

Referenced by __ast_format_cap_append().

143 {
144  struct format_cap_framed *framed = obj;
145 
146  ao2_cleanup(framed->format);
147 }
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ format_cap_framed_init()

static int format_cap_framed_init ( struct format_cap_framed framed,
struct ast_format_cap cap,
struct ast_format format,
unsigned int  framing 
)
inlinestatic

Definition at line 149 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_REPLACE, AST_VECTOR_SIZE, format_cap_framed::framing, and MIN.

Referenced by __ast_format_cap_append().

150 {
151  struct format_cap_framed_list *list;
152 
153  framed->framing = framing;
154 
155  if (ast_format_get_codec_id(format) >= AST_VECTOR_SIZE(&cap->formats)) {
157  ao2_ref(framed, -1);
158  return -1;
159  }
160  }
161  list = AST_VECTOR_GET_ADDR(&cap->formats, ast_format_get_codec_id(format));
162 
163  /* This takes the allocation reference */
164  if (AST_VECTOR_APPEND(&cap->preference_order, framed)) {
165  ao2_ref(framed, -1);
166  return -1;
167  }
168 
169  /* Order doesn't matter for formats, so insert at the head for performance reasons */
170  ao2_ref(framed, +1);
171  AST_LIST_INSERT_HEAD(list, framed, entry);
172 
173  cap->framing = MIN(cap->framing, framing ? framing : ast_format_get_default_ms(format));
174 
175  return 0;
176 }
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256
unsigned int framing
The format framing size.
Definition: format_cap.c:48
#define MIN(a, b)
Definition: utils.h:226
#define AST_VECTOR_GET_ADDR(vec, idx)
Get an address of element in a vector.
Definition: vector.h:670
#define ao2_ref(o, delta)
Definition: astobj2.h:464
Linked list for formats.
Definition: format_cap.c:64
static const struct format_cap_framed_list format_cap_framed_list_empty
Dummy empty list for when we are inserting a new list.
Definition: format_cap.c:67
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:710
unsigned int ast_format_get_default_ms(const struct ast_format *format)
Get the default framing size (in milliseconds) for a format.
Definition: format.c:359
#define AST_VECTOR_REPLACE(vec, idx, elem)
Replace an element at a specific position in a vector, growing the vector if needed.
Definition: vector.h:284
Definition: search.h:40
unsigned int ast_format_get_codec_id(const struct ast_format *format)
Get the codec identifier associated with a format.
Definition: format.c:329
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

◆ format_cap_init()

static int format_cap_init ( struct ast_format_cap cap,
enum ast_format_cap_flags  flags 
)
inlinestatic

Definition at line 102 of file format_cap.c.

References AST_VECTOR_INIT.

Referenced by __ast_format_cap_alloc().

103 {
104  if (AST_VECTOR_INIT(&cap->formats, 0)) {
105  return -1;
106  }
107 
108  /* TODO: Look at common usage of this and determine a good starting point */
109  if (AST_VECTOR_INIT(&cap->preference_order, 5)) {
110  return -1;
111  }
112 
113  cap->framing = UINT_MAX;
114  return 0;
115 }
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113

◆ format_cap_replace()

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

Definition at line 286 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().

287 {
288  struct format_cap_framed *framed;
289  int i;
290 
291  ast_assert(format != NULL);
292 
293  for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); i++) {
294  framed = AST_VECTOR_GET(&cap->preference_order, i);
295 
296  if (ast_format_get_codec_id(format) == ast_format_get_codec_id(framed->format)) {
297  ao2_t_replace(framed->format, format, "replacing with new format");
298  framed->framing = framing;
299  return 0;
300  }
301  }
302 
303  return -1;
304 }
#define ao2_t_replace(dst, src, tag)
Replace one object reference with another cleaning up the original.
Definition: astobj2.h:503
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
unsigned int framing
The format framing size.
Definition: format_cap.c:48
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
unsigned int ast_format_get_codec_id(const struct ast_format *format)
Get the codec identifier associated with a format.
Definition: format.c:329
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ format_in_format_cap()

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

Definition at line 179 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().

180 {
181  struct format_cap_framed *framed;
182  int i;
183 
184  for (i = 0; i < AST_VECTOR_SIZE(&cap->preference_order); i++) {
185  framed = AST_VECTOR_GET(&cap->preference_order, i);
186 
187  if (ast_format_get_codec_id(format) == ast_format_get_codec_id(framed->format)) {
188  return 1;
189  }
190  }
191 
192  return 0;
193 }
struct ast_format * format
A pointer to the format.
Definition: format_cap.c:46
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
unsigned int ast_format_get_codec_id(const struct ast_format *format)
Get the codec identifier associated with a format.
Definition: format.c:329
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
Structure used for capability formats, adds framing.
Definition: format_cap.c:44

◆ internal_format_cap_identical()

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

Definition at line 670 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().

671 {
672  int idx;
673  struct ast_format *tmp;
674 
675  for (idx = 0; idx < AST_VECTOR_SIZE(&cap1->preference_order); ++idx) {
676  tmp = ast_format_cap_get_format(cap1, idx);
677 
679  ao2_ref(tmp, -1);
680  return 0;
681  }
682 
683  ao2_ref(tmp, -1);
684  }
685 
686  return 1;
687 }
static int tmp()
Definition: bt_open.c:389
Definition of a media format.
Definition: format.c:43
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_format * ast_format_cap_get_format(const struct ast_format_cap *cap, int position)
Get the format at a specific index.
Definition: format_cap.c:400
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.
Definition: format_cap.c:583
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

Variable Documentation

◆ format_cap_framed_list_empty

const 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 67 of file format_cap.c.