int g7221_decode_update(struct audec_state **adsp, const struct aucodec *ac, const char *fmtp) { const struct g7221_aucodec *g7221 = (struct g7221_aucodec *)ac; struct audec_state *ads; (void)fmtp; if (!adsp || !ac) return EINVAL; ads = *adsp; if (ads) return 0; ads = mem_alloc(sizeof(*ads), NULL); if (!ads) return ENOMEM; if (!g722_1_decode_init(&ads->dec, g7221->bitrate, ac->srate)) { mem_deref(ads); return EPROTO; } *adsp = ads; return 0; }
static switch_status_t switch_siren_init(switch_codec_t *codec, switch_codec_flag_t flags, const switch_codec_settings_t *codec_settings) { struct siren_context *context = NULL; int encoding = (flags & SWITCH_CODEC_FLAG_ENCODE); int decoding = (flags & SWITCH_CODEC_FLAG_DECODE); int bit_rate = codec->implementation->bits_per_second; if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) { return SWITCH_STATUS_FALSE; } codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "bitrate=%d", bit_rate); if (encoding) { g722_1_encode_init(&context->encoder_object, bit_rate, codec->implementation->samples_per_second); } if (decoding) { g722_1_decode_init(&context->decoder_object, bit_rate, codec->implementation->samples_per_second); } codec->private_info = context; return SWITCH_STATUS_SUCCESS; }
static void * G7221DecoderCreate(const struct PluginCodec_Definition * defn) { return g722_1_decode_init(NULL, defn->bitsPerSec, defn->sampleRate); }