main/format_compatibility.c File Reference

Media Format Bitfield Compatibility API. More...

#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/astobj2.h"
#include "asterisk/codec.h"
#include "asterisk/format.h"
#include "asterisk/format_compatibility.h"
#include "asterisk/format_cache.h"

Include dependency graph for main/format_compatibility.c:

Go to the source code of this file.

Functions

struct ast_formatast_format_compatibility_bitfield2format (uint64_t bitfield)
 Convert a bitfield to its respective format structure.
uint64_t ast_format_compatibility_codec2bitfield (const struct ast_codec *codec)
 Convert a codec structure to its respective bitfield.
uint64_t ast_format_compatibility_format2bitfield (const struct ast_format *format)
 Convert a format structure to its respective bitfield.


Detailed Description

Media Format Bitfield Compatibility API.

Author:
Joshua Colp <jcolp@digium.com>

Definition in file main/format_compatibility.c.


Function Documentation

struct ast_format* ast_format_compatibility_bitfield2format ( uint64_t  bitfield  )  [read]

Convert a bitfield to its respective format structure.

Parameters:
bitfield The bitfield for the media format
Return values:
non-NULL success
NULL failure (The format bitfield value is not supported)
Note:
The reference count of the returned format is NOT incremented

G.723.1 compression

GSM compression

Raw mu-law data (G.711)

Raw A-law data (G.711)

ADPCM (G.726, 32kbps, AAL2 codeword packing)

ADPCM (IMA)

Raw 16-bit Signed Linear (8000 Hz) PCM

LPC10, 180 samples/frame

G.729A audio

SpeeX Free Compression

iLBC Free Compression

ADPCM (G.726, 32kbps, RFC3551 codeword packing)

G.722

G.722.1 (also known as Siren7, 32kbps assumed)

G.722.1 Annex C (also known as Siren14, 48kbps assumed)

Raw 16-bit Signed Linear (16000 Hz) PCM

G.719 (64 kbps assumed)

SpeeX Wideband (16kHz) Free Compression

Opus audio (8kHz, 16kHz, 24kHz, 48Khz)

Raw mu-law data (G.711)

H.261 Video

H.263 Video

H.263+ Video

H.264 Video

MPEG4 Video

VP8 Video

JPEG Images

PNG Images

T.140 RED Text format RFC 4103

T.140 Text format - ITU T.140, RFC 4103

Definition at line 175 of file main/format_compatibility.c.

References ast_format_adpcm, AST_FORMAT_ADPCM, ast_format_alaw, AST_FORMAT_ALAW, ast_format_g719, AST_FORMAT_G719, ast_format_g722, AST_FORMAT_G722, ast_format_g723, AST_FORMAT_G723, ast_format_g726, AST_FORMAT_G726, ast_format_g726_aal2, AST_FORMAT_G726_AAL2, ast_format_g729, AST_FORMAT_G729, ast_format_gsm, AST_FORMAT_GSM, ast_format_h261, AST_FORMAT_H261, ast_format_h263, AST_FORMAT_H263, ast_format_h263p, AST_FORMAT_H263P, ast_format_h264, AST_FORMAT_H264, ast_format_ilbc, AST_FORMAT_ILBC, ast_format_jpeg, AST_FORMAT_JPEG, ast_format_lpc10, AST_FORMAT_LPC10, ast_format_mp4, AST_FORMAT_MP4, ast_format_opus, AST_FORMAT_OPUS, ast_format_png, AST_FORMAT_PNG, ast_format_siren14, AST_FORMAT_SIREN14, ast_format_siren7, AST_FORMAT_SIREN7, ast_format_slin, AST_FORMAT_SLIN, ast_format_slin16, AST_FORMAT_SLIN16, ast_format_speex, AST_FORMAT_SPEEX, ast_format_speex16, AST_FORMAT_SPEEX16, AST_FORMAT_T140, ast_format_t140, ast_format_t140_red, AST_FORMAT_T140_RED, ast_format_testlaw, AST_FORMAT_TESTLAW, ast_format_ulaw, AST_FORMAT_ULAW, ast_format_vp8, AST_FORMAT_VP8, and NULL.

Referenced by __get_from_jb(), codec_choose_from_prefs(), decode_frame(), iax2_codec_pref_best_bitfield2cap(), iax2_codec_pref_from_bitfield(), iax2_codec_pref_index(), iax2_codec_pref_to_cap(), iax2_format_compatibility_bitfield2cap(), iax2_getformatname(), iax2_send(), socket_process_helper(), and socket_process_meta().

00176 {
00177    switch (bitfield) {
00178    /*! G.723.1 compression */
00179    case AST_FORMAT_G723:
00180       return ast_format_g723;
00181    /*! GSM compression */
00182    case AST_FORMAT_GSM:
00183       return ast_format_gsm;
00184    /*! Raw mu-law data (G.711) */
00185    case AST_FORMAT_ULAW:
00186       return ast_format_ulaw;
00187    /*! Raw A-law data (G.711) */
00188    case AST_FORMAT_ALAW:
00189       return ast_format_alaw;
00190    /*! ADPCM (G.726, 32kbps, AAL2 codeword packing) */
00191    case AST_FORMAT_G726_AAL2:
00192       return ast_format_g726_aal2;
00193    /*! ADPCM (IMA) */
00194    case AST_FORMAT_ADPCM:
00195       return ast_format_adpcm;
00196    /*! Raw 16-bit Signed Linear (8000 Hz) PCM */
00197    case AST_FORMAT_SLIN:
00198       return ast_format_slin;
00199    /*! LPC10, 180 samples/frame */
00200    case AST_FORMAT_LPC10:
00201       return ast_format_lpc10;
00202    /*! G.729A audio */
00203    case AST_FORMAT_G729:
00204       return ast_format_g729;
00205    /*! SpeeX Free Compression */
00206    case AST_FORMAT_SPEEX:
00207       return ast_format_speex;
00208    /*! iLBC Free Compression */
00209    case AST_FORMAT_ILBC:
00210       return ast_format_ilbc;
00211    /*! ADPCM (G.726, 32kbps, RFC3551 codeword packing) */
00212    case AST_FORMAT_G726:
00213       return ast_format_g726;
00214    /*! G.722 */
00215    case AST_FORMAT_G722:
00216       return ast_format_g722;
00217    /*! G.722.1 (also known as Siren7, 32kbps assumed) */
00218    case AST_FORMAT_SIREN7:
00219       return ast_format_siren7;
00220    /*! G.722.1 Annex C (also known as Siren14, 48kbps assumed) */
00221    case AST_FORMAT_SIREN14:
00222       return ast_format_siren14;
00223    /*! Raw 16-bit Signed Linear (16000 Hz) PCM */
00224    case AST_FORMAT_SLIN16:
00225       return ast_format_slin16;
00226    /*! G.719 (64 kbps assumed) */
00227    case AST_FORMAT_G719:
00228       return ast_format_g719;
00229    /*! SpeeX Wideband (16kHz) Free Compression */
00230    case AST_FORMAT_SPEEX16:
00231       return ast_format_speex16;
00232    /*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */
00233    case AST_FORMAT_OPUS:
00234       return ast_format_opus;
00235    /*! Raw mu-law data (G.711) */
00236    case AST_FORMAT_TESTLAW:
00237       return ast_format_testlaw;
00238 
00239    /*! H.261 Video */
00240    case AST_FORMAT_H261:
00241       return ast_format_h261;
00242    /*! H.263 Video */
00243    case AST_FORMAT_H263:
00244       return ast_format_h263;
00245    /*! H.263+ Video */
00246    case AST_FORMAT_H263P:
00247       return ast_format_h263p;
00248    /*! H.264 Video */
00249    case AST_FORMAT_H264:
00250       return ast_format_h264;
00251    /*! MPEG4 Video */
00252    case AST_FORMAT_MP4:
00253       return ast_format_mp4;
00254    /*! VP8 Video */
00255    case AST_FORMAT_VP8:
00256       return ast_format_vp8;
00257 
00258    /*! JPEG Images */
00259    case AST_FORMAT_JPEG:
00260       return ast_format_jpeg;
00261    /*! PNG Images */
00262    case AST_FORMAT_PNG:
00263       return ast_format_png;
00264 
00265    /*! T.140 RED Text format RFC 4103 */
00266    case AST_FORMAT_T140_RED:
00267       return ast_format_t140;
00268    /*! T.140 Text format - ITU T.140, RFC 4103 */
00269    case AST_FORMAT_T140:
00270       return ast_format_t140_red;
00271    }
00272    return NULL;
00273 }

uint64_t ast_format_compatibility_codec2bitfield ( const struct ast_codec codec  ) 

Convert a codec structure to its respective bitfield.

Parameters:
codec The media codec
Return values:
non-zero success
zero format not supported

Definition at line 108 of file main/format_compatibility.c.

References AST_FORMAT_ADPCM, ast_format_adpcm, AST_FORMAT_ALAW, ast_format_alaw, AST_FORMAT_G719, ast_format_g719, AST_FORMAT_G722, ast_format_g722, AST_FORMAT_G723, ast_format_g723, AST_FORMAT_G726, ast_format_g726, AST_FORMAT_G726_AAL2, ast_format_g726_aal2, AST_FORMAT_G729, ast_format_g729, ast_format_get_codec_id(), AST_FORMAT_GSM, ast_format_gsm, AST_FORMAT_H261, ast_format_h261, AST_FORMAT_H263, ast_format_h263, AST_FORMAT_H263P, ast_format_h263p, AST_FORMAT_H264, ast_format_h264, AST_FORMAT_ILBC, ast_format_ilbc, AST_FORMAT_JPEG, ast_format_jpeg, AST_FORMAT_LPC10, ast_format_lpc10, AST_FORMAT_MP4, ast_format_mp4, AST_FORMAT_OPUS, ast_format_opus, AST_FORMAT_PNG, ast_format_png, AST_FORMAT_SIREN14, ast_format_siren14, AST_FORMAT_SIREN7, ast_format_siren7, AST_FORMAT_SLIN, ast_format_slin, AST_FORMAT_SLIN16, ast_format_slin16, AST_FORMAT_SPEEX, ast_format_speex, AST_FORMAT_SPEEX16, ast_format_speex16, AST_FORMAT_T140, ast_format_t140, AST_FORMAT_T140_RED, ast_format_t140_red, AST_FORMAT_TESTLAW, ast_format_testlaw, AST_FORMAT_ULAW, ast_format_ulaw, AST_FORMAT_VP8, ast_format_vp8, and ast_codec::id.

00109 {
00110    if (codec->id == ast_format_get_codec_id(ast_format_g723)) {
00111       return AST_FORMAT_G723;
00112    } else if (codec->id == ast_format_get_codec_id(ast_format_gsm)) {
00113       return AST_FORMAT_GSM;
00114    } else if (codec->id == ast_format_get_codec_id(ast_format_ulaw)) {
00115       return AST_FORMAT_ULAW;
00116    } else if (codec->id == ast_format_get_codec_id(ast_format_alaw)) {
00117       return AST_FORMAT_ALAW;
00118    } else if (codec->id == ast_format_get_codec_id(ast_format_g726_aal2)) {
00119       return AST_FORMAT_G726_AAL2;
00120    } else if (codec->id == ast_format_get_codec_id(ast_format_adpcm)) {
00121       return AST_FORMAT_ADPCM;
00122    } else if (codec->id == ast_format_get_codec_id(ast_format_slin)) {
00123       return AST_FORMAT_SLIN;
00124    } else if (codec->id == ast_format_get_codec_id(ast_format_lpc10)) {
00125       return AST_FORMAT_LPC10;
00126    } else if (codec->id == ast_format_get_codec_id(ast_format_g729)) {
00127       return AST_FORMAT_G729;
00128    } else if (codec->id == ast_format_get_codec_id(ast_format_speex)) {
00129       return AST_FORMAT_SPEEX;
00130    } else if (codec->id == ast_format_get_codec_id(ast_format_ilbc)) {
00131       return AST_FORMAT_ILBC;
00132    } else if (codec->id == ast_format_get_codec_id(ast_format_g726)) {
00133       return AST_FORMAT_G726;
00134    } else if (codec->id == ast_format_get_codec_id(ast_format_g722)) {
00135       return AST_FORMAT_G722;
00136    } else if (codec->id == ast_format_get_codec_id(ast_format_siren7)) {
00137       return AST_FORMAT_SIREN7;
00138    } else if (codec->id == ast_format_get_codec_id(ast_format_siren14)) {
00139       return AST_FORMAT_SIREN14;
00140    } else if (codec->id == ast_format_get_codec_id(ast_format_slin16)) {
00141       return AST_FORMAT_SLIN16;
00142    } else if (codec->id == ast_format_get_codec_id(ast_format_g719)) {
00143       return AST_FORMAT_G719;
00144    } else if (codec->id == ast_format_get_codec_id(ast_format_speex16)) {
00145       return AST_FORMAT_SPEEX16;
00146    } else if (codec->id == ast_format_get_codec_id(ast_format_opus)) {
00147       return AST_FORMAT_OPUS;
00148    } else if (codec->id == ast_format_get_codec_id(ast_format_testlaw)) {
00149       return AST_FORMAT_TESTLAW;
00150    } else if (codec->id == ast_format_get_codec_id(ast_format_h261)) {
00151       return AST_FORMAT_H261;
00152    } else if (codec->id == ast_format_get_codec_id(ast_format_h263)) {
00153       return AST_FORMAT_H263;
00154    } else if (codec->id == ast_format_get_codec_id(ast_format_h263p)) {
00155       return AST_FORMAT_H263P;
00156    } else if (codec->id == ast_format_get_codec_id(ast_format_h264)) {
00157       return AST_FORMAT_H264;
00158    } else if (codec->id == ast_format_get_codec_id(ast_format_mp4)) {
00159       return AST_FORMAT_MP4;
00160    } else if (codec->id == ast_format_get_codec_id(ast_format_vp8)) {
00161       return AST_FORMAT_VP8;
00162    } else if (codec->id == ast_format_get_codec_id(ast_format_jpeg)) {
00163       return AST_FORMAT_JPEG;
00164    } else if (codec->id == ast_format_get_codec_id(ast_format_png)) {
00165       return AST_FORMAT_PNG;
00166    } else if (codec->id == ast_format_get_codec_id(ast_format_t140_red)) {
00167       return AST_FORMAT_T140_RED;
00168    } else if (codec->id == ast_format_get_codec_id(ast_format_t140)) {
00169       return AST_FORMAT_T140;
00170    }
00171 
00172    return 0;
00173 }

uint64_t ast_format_compatibility_format2bitfield ( const struct ast_format format  ) 

Convert a format structure to its respective bitfield.

Parameters:
format The media format
Return values:
non-zero success
zero format not supported

Definition at line 41 of file main/format_compatibility.c.

References AST_FORMAT_ADPCM, ast_format_adpcm, AST_FORMAT_ALAW, ast_format_alaw, ast_format_cmp(), AST_FORMAT_CMP_EQUAL, AST_FORMAT_G719, ast_format_g719, AST_FORMAT_G722, ast_format_g722, AST_FORMAT_G723, ast_format_g723, AST_FORMAT_G726, ast_format_g726, AST_FORMAT_G726_AAL2, ast_format_g726_aal2, AST_FORMAT_G729, ast_format_g729, AST_FORMAT_GSM, ast_format_gsm, AST_FORMAT_H261, ast_format_h261, AST_FORMAT_H263, ast_format_h263, AST_FORMAT_H263P, ast_format_h263p, AST_FORMAT_H264, ast_format_h264, AST_FORMAT_ILBC, ast_format_ilbc, AST_FORMAT_JPEG, ast_format_jpeg, AST_FORMAT_LPC10, ast_format_lpc10, AST_FORMAT_MP4, ast_format_mp4, AST_FORMAT_OPUS, ast_format_opus, AST_FORMAT_PNG, ast_format_png, AST_FORMAT_SIREN14, ast_format_siren14, AST_FORMAT_SIREN7, ast_format_siren7, AST_FORMAT_SLIN, ast_format_slin, AST_FORMAT_SLIN16, ast_format_slin16, AST_FORMAT_SPEEX, ast_format_speex, AST_FORMAT_SPEEX16, ast_format_speex16, AST_FORMAT_T140, ast_format_t140, AST_FORMAT_T140_RED, ast_format_t140_red, AST_FORMAT_TESTLAW, ast_format_testlaw, AST_FORMAT_ULAW, ast_format_ulaw, AST_FORMAT_VP8, and ast_format_vp8.

Referenced by conf_run(), iax2_codec_choose(), iax2_codec_pref_append(), iax2_codec_pref_prepend(), iax2_format_compatibility_cap2bitfield(), iax2_send(), iax_template_parse(), phone_write(), and socket_process_helper().

00042 {
00043    if (ast_format_cmp(format, ast_format_g723) == AST_FORMAT_CMP_EQUAL) {
00044       return AST_FORMAT_G723;
00045    } else if (ast_format_cmp(format, ast_format_gsm) == AST_FORMAT_CMP_EQUAL) {
00046       return AST_FORMAT_GSM;
00047    } else if (ast_format_cmp(format, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
00048       return AST_FORMAT_ULAW;
00049    } else if (ast_format_cmp(format, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
00050       return AST_FORMAT_ALAW;
00051    } else if (ast_format_cmp(format, ast_format_g726_aal2) == AST_FORMAT_CMP_EQUAL) {
00052       return AST_FORMAT_G726_AAL2;
00053    } else if (ast_format_cmp(format, ast_format_adpcm) == AST_FORMAT_CMP_EQUAL) {
00054       return AST_FORMAT_ADPCM;
00055    } else if (ast_format_cmp(format, ast_format_slin) == AST_FORMAT_CMP_EQUAL) {
00056       return AST_FORMAT_SLIN;
00057    } else if (ast_format_cmp(format, ast_format_lpc10) == AST_FORMAT_CMP_EQUAL) {
00058       return AST_FORMAT_LPC10;
00059    } else if (ast_format_cmp(format, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
00060       return AST_FORMAT_G729;
00061    } else if (ast_format_cmp(format, ast_format_speex) == AST_FORMAT_CMP_EQUAL) {
00062       return AST_FORMAT_SPEEX;
00063    } else if (ast_format_cmp(format, ast_format_ilbc) == AST_FORMAT_CMP_EQUAL) {
00064       return AST_FORMAT_ILBC;
00065    } else if (ast_format_cmp(format, ast_format_g726) == AST_FORMAT_CMP_EQUAL) {
00066       return AST_FORMAT_G726;
00067    } else if (ast_format_cmp(format, ast_format_g722) == AST_FORMAT_CMP_EQUAL) {
00068       return AST_FORMAT_G722;
00069    } else if (ast_format_cmp(format, ast_format_siren7) == AST_FORMAT_CMP_EQUAL) {
00070       return AST_FORMAT_SIREN7;
00071    } else if (ast_format_cmp(format, ast_format_siren14) == AST_FORMAT_CMP_EQUAL) {
00072       return AST_FORMAT_SIREN14;
00073    } else if (ast_format_cmp(format, ast_format_slin16) == AST_FORMAT_CMP_EQUAL) {
00074       return AST_FORMAT_SLIN16;
00075    } else if (ast_format_cmp(format, ast_format_g719) == AST_FORMAT_CMP_EQUAL) {
00076       return AST_FORMAT_G719;
00077    } else if (ast_format_cmp(format, ast_format_speex16) == AST_FORMAT_CMP_EQUAL) {
00078       return AST_FORMAT_SPEEX16;
00079    } else if (ast_format_cmp(format, ast_format_opus) == AST_FORMAT_CMP_EQUAL) {
00080       return AST_FORMAT_OPUS;
00081    } else if (ast_format_cmp(format, ast_format_testlaw) == AST_FORMAT_CMP_EQUAL) {
00082       return AST_FORMAT_TESTLAW;
00083    } else if (ast_format_cmp(format, ast_format_h261) == AST_FORMAT_CMP_EQUAL) {
00084       return AST_FORMAT_H261;
00085    } else if (ast_format_cmp(format, ast_format_h263) == AST_FORMAT_CMP_EQUAL) {
00086       return AST_FORMAT_H263;
00087    } else if (ast_format_cmp(format, ast_format_h263p) == AST_FORMAT_CMP_EQUAL) {
00088       return AST_FORMAT_H263P;
00089    } else if (ast_format_cmp(format, ast_format_h264) == AST_FORMAT_CMP_EQUAL) {
00090       return AST_FORMAT_H264;
00091    } else if (ast_format_cmp(format, ast_format_mp4) == AST_FORMAT_CMP_EQUAL) {
00092       return AST_FORMAT_MP4;
00093    } else if (ast_format_cmp(format, ast_format_vp8) == AST_FORMAT_CMP_EQUAL) {
00094       return AST_FORMAT_VP8;
00095    } else if (ast_format_cmp(format, ast_format_jpeg) == AST_FORMAT_CMP_EQUAL) {
00096       return AST_FORMAT_JPEG;
00097    } else if (ast_format_cmp(format, ast_format_png) == AST_FORMAT_CMP_EQUAL) {
00098       return AST_FORMAT_PNG;
00099    } else if (ast_format_cmp(format, ast_format_t140_red) == AST_FORMAT_CMP_EQUAL) {
00100       return AST_FORMAT_T140_RED;
00101    } else if (ast_format_cmp(format, ast_format_t140) == AST_FORMAT_CMP_EQUAL) {
00102       return AST_FORMAT_T140;
00103    }
00104 
00105    return 0;
00106 }


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