79 int pos = 0, samples = 0, res;
81 while(pos < frame->datalen) {
94 return (samples / 240) * 20;
99 .description =
"G.723.1",
112 return 160 * (frame->
datalen / 6);
117 return (samples / 160) * 6;
122 .description =
"Codec 2",
145 .description =
"<Null> codec",
168 .description =
"G.711 u-law",
182 .description =
"G.711 a-law",
196 return 160 * (frame->
datalen / 33);
201 return (samples / 160) * 33;
206 .description =
"GSM",
230 .description =
"G.726 RFC3551",
244 .description =
"G.726 AAL2",
258 .description =
"Dialogic ADPCM",
282 .description =
"16 bit Signed Linear PCM",
288 .minimum_bytes = 160,
297 .description =
"16 bit Signed Linear PCM (12kHz)",
299 .sample_rate = 12000,
303 .minimum_bytes = 240,
312 .description =
"16 bit Signed Linear PCM (16kHz)",
314 .sample_rate = 16000,
318 .minimum_bytes = 320,
327 .description =
"16 bit Signed Linear PCM (24kHz)",
329 .sample_rate = 24000,
333 .minimum_bytes = 480,
342 .description =
"16 bit Signed Linear PCM (32kHz)",
344 .sample_rate = 32000,
348 .minimum_bytes = 640,
357 .description =
"16 bit Signed Linear PCM (44kHz)",
359 .sample_rate = 44100,
363 .minimum_bytes = 882,
372 .description =
"16 bit Signed Linear PCM (48kHz)",
374 .sample_rate = 48000,
378 .minimum_bytes = 960,
387 .description =
"16 bit Signed Linear PCM (96kHz)",
389 .sample_rate = 96000,
393 .minimum_bytes = 1920,
402 .description =
"16 bit Signed Linear PCM (192kHz)",
404 .sample_rate = 192000,
408 .minimum_bytes = 3840,
417 int samples = 22 * 8;
420 samples += (((
char *)(frame->
data.
ptr))[7] & 0x1) * 8;
427 .description =
"LPC10",
450 .description =
"G.729A",
465 int rem = 8 - (bit % 8);
466 unsigned char ret = 0;
472 ret = (data[byte] << (n - rem));
473 ret |= (data[byte + 1] >> (8 - n + rem));
475 ret = (data[byte] >> (rem - n));
478 return (ret & (0xff >> (8 - n)));
483 static const int SpeexWBSubModeSz[] = {
490 if (((len * 8 - off) >= 5) &&
493 off += SpeexWBSubModeSz[
c];
495 if (((len * 8 - off) >= 5) &&
498 off += SpeexWBSubModeSz[
c];
500 if (((len * 8 - off) >= 5) &&
502 ast_log(
LOG_WARNING,
"Encountered corrupt speex frame; too many wideband frames in a row.\n");
513 static const int SpeexSubModeSz[] = {
518 static const int SpeexInBandSz[] = {
528 while ((len * 8 - bit) >= 5) {
537 if ((len * 8 - bit) < 5)
547 }
else if (c == 14) {
551 bit += SpeexInBandSz[
c];
552 }
else if (c == 13) {
564 bit += SpeexSubModeSz[
c] - 5;
578 .description =
"SpeeX",
595 .description =
"SpeeX 16khz",
597 .sample_rate = 16000,
612 .description =
"SpeeX 32khz",
614 .sample_rate = 32000,
625 const unsigned int mode = attr ? attr->
mode : 30;
627 const unsigned int octets_per_frame = (mode == 20) ? 38 : 50;
629 return samples_per_frame * frame->
datalen / octets_per_frame;
634 .description =
"iLBC",
647 .description =
"G722",
649 .sample_rate = 16000,
661 return frame->
datalen * (16000 / 4000);
666 return samples / (16000 / 4000);
671 .description =
"ITU G.722.1 (Siren7, licensed from Polycom)",
673 .sample_rate = 16000,
684 return (
int) frame->
datalen * ((float) 32000 / 6000);
689 return (
int) samples / ((float) 32000 / 6000);;
694 .description =
"ITU G.722.1 Annex C, (Siren14, licensed from Polycom)",
696 .sample_rate = 32000,
700 .minimum_bytes = 120,
707 .description =
"G.711 test-law",
721 return (
int) frame->
datalen * ((float) 48000 / 8000);
726 return (
int) samples / ((float) 48000 / 8000);
731 .description =
"ITU G.719",
733 .sample_rate = 48000,
737 .minimum_bytes = 160,
759 .description =
"Opus Codec",
761 .sample_rate = 48000,
771 .description =
"JPEG image",
777 .description =
"PNG Image",
783 .description =
"H.261 video",
790 .description =
"H.263 video",
797 .description =
"H.263+ video",
804 .description =
"H.264 video",
811 .description =
"H.265 video",
818 .description =
"MPEG4 video",
825 .description =
"VP8 video",
832 .description =
"VP9 video",
839 .description =
"T.140 Realtime Text with redundancy",
845 .description =
"Passthrough T.140 Realtime Text",
851 .description =
"T.38 UDPTL Fax",
868 .description =
"SILK Codec (8 KHz)",
874 .minimum_bytes = 160,
880 .description =
"SILK Codec (12 KHz)",
882 .sample_rate = 12000,
886 .minimum_bytes = 240,
892 .description =
"SILK Codec (16 KHz)",
894 .sample_rate = 16000,
898 .minimum_bytes = 320,
904 .description =
"SILK Codec (24 KHz)",
906 .sample_rate = 24000,
910 .minimum_bytes = 480,
914 #define CODEC_REGISTER_AND_CACHE(codec) \ 916 int __res_ ## __LINE__ = 0; \ 917 struct ast_format *__fmt_ ## __LINE__; \ 918 struct ast_codec *__codec_ ## __LINE__; \ 919 res |= __ast_codec_register_with_format(&(codec), (codec).name, NULL); \ 920 __codec_ ## __LINE__ = ast_codec_get((codec).name, (codec).type, (codec).sample_rate); \ 921 __fmt_ ## __LINE__ = __codec_ ## __LINE__ ? ast_format_create(__codec_ ## __LINE__) : NULL; \ 922 res |= ast_format_cache_set(__fmt_ ## __LINE__); \ 923 ao2_ref(__fmt_ ## __LINE__, -1); \ 924 ao2_ref(__codec_ ## __LINE__, -1); \ 925 __res_ ## __LINE__; \ 928 #define CODEC_REGISTER_AND_CACHE_NAMED(fmt_name, codec) \ 930 int __res_ ## __LINE__ = 0; \ 931 struct ast_format *__fmt_ ## __LINE__; \ 932 struct ast_codec *__codec_ ## __LINE__; \ 933 res |= __ast_codec_register_with_format(&(codec), fmt_name, NULL); \ 934 __codec_ ## __LINE__ = ast_codec_get((codec).name, (codec).type, (codec).sample_rate); \ 935 __fmt_ ## __LINE__ = ast_format_create_named((fmt_name), __codec_ ## __LINE__); \ 936 res |= ast_format_cache_set(__fmt_ ## __LINE__); \ 937 ao2_ref(__fmt_ ## __LINE__, -1); \ 938 ao2_ref(__codec_ ## __LINE__, -1); \ 939 __res_ ## __LINE__; \
static int speex_samples(unsigned char *data, int len)
static int speex8_samples(struct ast_frame *frame)
const char * name
Name for this codec.
static int g723_len(unsigned char buf)
Asterisk main include file. File version handling, generic pbx functions.
static struct ast_codec testlaw
static struct ast_codec slin8
static struct ast_codec opus
static struct ast_codec ulaw
static struct ast_codec speex8
static struct ast_codec g726aal2
static int slin_length(unsigned int samples)
static int siren14_length(unsigned int samples)
static struct ast_codec slin48
static int gsm_samples(struct ast_frame *frame)
static int g726_samples(struct ast_frame *frame)
static int siren7_length(unsigned int samples)
int ast_codec_builtin_init(void)
Initialize built-in codecs within the core.
static struct ast_codec silk12
static struct ast_codec none
static int siren7_samples(struct ast_frame *frame)
static struct ast_codec slin44
static struct ast_codec silk24
static struct ast_codec slin16
static int none_length(unsigned int samples)
#define CODEC_REGISTER_AND_CACHE_NAMED(fmt_name, codec)
static struct ast_codec h261
static struct ast_codec siren14
static int none_samples(struct ast_frame *frame)
static struct ast_codec speex16
static struct ast_codec t140red
static struct ast_codec alaw
static struct ast_codec siren7
static struct ast_codec silk16
Asterisk internal frame definitions.
#define CODEC_REGISTER_AND_CACHE(codec)
struct ast_frame_subclass subclass
static struct ast_codec codec2
int __ast_codec_register_with_format(struct ast_codec *codec, const char *format_name, struct ast_module *mod)
static struct ast_codec mpeg4
static struct ast_codec g722
static struct ast_codec silk8
static struct ast_codec t38
static struct ast_codec slin192
static unsigned char get_n_bits_at(unsigned char *data, int n, int bit)
static int speex_get_wb_sz_at(unsigned char *data, int len, int bit)
static struct ast_codec speex32
#define AST_SMOOTHER_FLAG_FORCED
static struct ast_codec jpeg
Asterisk internal frame definitions.
static int speex32_samples(struct ast_frame *frame)
static int codec2_samples(struct ast_frame *frame)
static int slin_samples(struct ast_frame *frame)
static int g723_length(unsigned int samples)
static int g726_length(unsigned int samples)
static int g719_length(unsigned int samples)
static struct ast_codec slin96
static struct ast_codec adpcm
static struct ast_codec g729a
static int g729_length(unsigned int samples)
static struct ast_codec h263
static struct ast_codec h264
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static int opus_samples(struct ast_frame *frame)
static struct ast_codec vp8
static int ilbc_samples(struct ast_frame *frame)
static struct ast_codec slin32
static struct ast_codec t140
static struct ast_codec g726rfc3551
static struct ast_codec slin24
static struct ast_codec g719
static struct ast_codec h265
Support for logging to various files, console and syslog Configuration in file logger.conf.
static int silk_samples(struct ast_frame *frame)
static int g723_samples(struct ast_frame *frame)
#define AST_SMOOTHER_FLAG_BE
static struct ast_codec lpc10
static int codec2_length(unsigned int samples)
static struct ast_codec png
static struct ast_codec g723
Data structure associated with a single frame of data.
static struct ast_codec vp9
static struct ast_codec slin12
static int lpc10_samples(struct ast_frame *frame)
static int siren14_samples(struct ast_frame *frame)
union ast_frame::@263 data
struct ast_format * format
static int speex16_samples(struct ast_frame *frame)
static struct ast_codec h263p
static struct ast_codec ilbc
static int gsm_length(unsigned int samples)
static int ulaw_samples(struct ast_frame *frame)
Represents a media codec within Asterisk.
static int ulaw_length(unsigned int samples)
static int g719_samples(struct ast_frame *frame)
static int g729_samples(struct ast_frame *frame)