本文整理汇总了C++中opus_encoder_destroy函数的典型用法代码示例。如果您正苦于以下问题:C++ opus_encoder_destroy函数的具体用法?C++ opus_encoder_destroy怎么用?C++ opus_encoder_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了opus_encoder_destroy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reconfigure_audio_encoder
bool reconfigure_audio_encoder(Logger *log, OpusEncoder **e, int32_t new_br, int32_t new_sr, uint8_t new_ch,
int32_t *old_br, int32_t *old_sr, int32_t *old_ch)
{
/* Values are checked in toxav.c */
if (*old_sr != new_sr || *old_ch != new_ch) {
OpusEncoder *new_encoder = create_audio_encoder(log, new_br, new_sr, new_ch);
if (new_encoder == NULL) {
return false;
}
opus_encoder_destroy(*e);
*e = new_encoder;
} else if (*old_br == new_br) {
return true; /* Nothing changed */
}
int status = opus_encoder_ctl(*e, OPUS_SET_BITRATE(new_br));
if (status != OPUS_OK) {
LOGGER_ERROR(log, "Error while setting encoder ctl: %s", opus_strerror(status));
return false;
}
*old_br = new_br;
*old_sr = new_sr;
*old_ch = new_ch;
LOGGER_DEBUG(log, "Reconfigured audio encoder br: %d sr: %d cc:%d", new_br, new_sr, new_ch);
return true;
}
示例2: cs_kill
void cs_kill(CSSession *cs)
{
if (!cs) return;
/* queue_message will not be called since it's unregistered before cs_kill is called */
pthread_mutex_destroy(cs->queue_mutex);
if ( cs->audio_encoder )
opus_encoder_destroy(cs->audio_encoder);
if ( cs->audio_decoder )
opus_decoder_destroy(cs->audio_decoder);
if ( cs->capabilities & cs_VideoDecoding )
vpx_codec_destroy(&cs->v_decoder);
if ( cs->capabilities & cs_VideoEncoding )
vpx_codec_destroy(&cs->v_encoder);
jbuf_free(cs->j_buf);
buffer_free(cs->vbuf_raw);
free(cs->frame_buf);
LOGGER_DEBUG("Terminated codec state: %p", cs);
free(cs);
}
示例3: wait
AudioInput::~AudioInput() {
bRunning = false;
wait();
#ifdef USE_OPUS
if (opusState)
opus_encoder_destroy(opusState);
#endif
if (ceEncoder) {
cCodec->celt_encoder_destroy(ceEncoder);
}
foreach(short *buf, qlEchoFrames)
delete [] buf;
if (sppPreprocess)
speex_preprocess_state_destroy(sppPreprocess);
if (sesEcho)
speex_echo_state_destroy(sesEcho);
if (srsMic)
speex_resampler_destroy(srsMic);
if (srsEcho)
speex_resampler_destroy(srsEcho);
delete [] psMic;
delete [] psClean;
delete [] psSpeaker;
delete [] pfMicInput;
delete [] pfEchoInput;
delete [] pfOutput;
}
示例4: opus_create
long opus_create(const char* format_parameters, const char** format_parameters_out,
amci_codec_fmt_info_t** format_description) {
opus_state_t* codec_inst;
int error;
unsigned int maxbandwidth = _OPUS_RATE;
int useinbandfec = _OPUS_INBAND_FEC_;
int stereo = 0;
if (format_parameters) {
DBG("OPUS params: >>%s<<.\n", format_parameters);
decode_format_parameters(format_parameters, &maxbandwidth, &useinbandfec, &stereo);
}
codec_inst = (opus_state_t*)malloc(sizeof(opus_state_t));
if (!codec_inst)
return -1;
DBG("OPUS: creating encoder with maxbandwidth=%u, stereo=%s, useinbandfec=%s\n",
maxbandwidth, stereo?"true":"false", useinbandfec?"true":"false");
codec_inst->opus_enc = opus_encoder_create(_OPUS_RATE,1,_OPUS_APPLICATION_,&error);
if (error) {
DBG("OPUS: error %d while creating encoder state.\n", error);
return -1;
}
opus_encoder_ctl(codec_inst->opus_enc, OPUS_SET_FORCE_CHANNELS(stereo ? 2:1));
unsigned int opus_set_bw = _OPUS_RATE;
if (maxbandwidth <= 8000) {
opus_set_bw = OPUS_BANDWIDTH_NARROWBAND;
} else if (maxbandwidth <= 12000) {
opus_set_bw = OPUS_BANDWIDTH_MEDIUMBAND;
} else if (maxbandwidth <= 16000) {
opus_set_bw = OPUS_BANDWIDTH_WIDEBAND;
} else if (maxbandwidth <= 24000) {
opus_set_bw = OPUS_BANDWIDTH_SUPERWIDEBAND;
} else {
opus_set_bw = OPUS_BANDWIDTH_FULLBAND;
}
opus_encoder_ctl(codec_inst->opus_enc, OPUS_SET_MAX_BANDWIDTH(opus_set_bw));
opus_encoder_ctl(codec_inst->opus_enc, OPUS_SET_PACKET_LOSS_PERC(_OPUS_PKT_LOSS_PCT_));
opus_encoder_ctl(codec_inst->opus_enc, OPUS_SET_COMPLEXITY(_OPUS_COMPLEXITY_));
opus_encoder_ctl(codec_inst->opus_enc, OPUS_SET_INBAND_FEC(useinbandfec ? 1:0));
opus_encoder_ctl(codec_inst->opus_enc, OPUS_SET_DTX(_OPUS_DTX_));
codec_inst->opus_dec = opus_decoder_create(_OPUS_RATE,1,&error);
if (error) {
DBG("OPUS: error %d while creating decoder state.\n", error);
opus_encoder_destroy(codec_inst->opus_enc);
return -1;
}
*format_description = opus_fmt_description;
return (long)codec_inst;
}
示例5: destructor
static void destructor(void *arg)
{
struct auenc_state *aes = arg;
if (aes->enc)
opus_encoder_destroy(aes->enc);
}
示例6: opus_encoder_destroy
Opus::~Opus()
{
if (encoder_)
opus_encoder_destroy(encoder_);
if (decoder_)
opus_decoder_destroy(decoder_);
}
示例7: while
void Opus::setOptimalFormat(uint32_t sample_rate, uint8_t channels)
{
// Use a SR higher or equal to sample_rate.
// Typical case: 44.1kHz => 48kHz.
unsigned i = 0;
while (i < VALID_SAMPLING_RATE_NUM - 1 and VALID_SAMPLING_RATE[i] < sample_rate)
i++;
sample_rate = VALID_SAMPLING_RATE[i];
// Opus supports 1 or 2 channels.
channels = std::max(std::min(channels, (uint8_t) 2), (uint8_t) 1);
if (not (!encoder_ || !decoder_ || sample_rate != clockRateCur_ || channels != channelsCur_))
return;
clockRateCur_ = sample_rate;
channelsCur_ = channels;
int err;
if (encoder_)
opus_encoder_destroy(encoder_);
encoder_ = opus_encoder_create(sample_rate, channels, OPUS_APPLICATION_VOIP, &err);
if (err)
throw std::runtime_error("opus: could not create encoder");
if (decoder_)
opus_decoder_destroy(decoder_);
lastDecodedFrameSize_ = 0;
decoder_ = opus_decoder_create(sample_rate, channels, &err);
if (err)
throw std::runtime_error("opus: could not create decoder");
}
示例8: cleanupRecorder
void cleanupRecorder() {
if (_encoder) {
opus_encoder_destroy(_encoder);
_encoder = 0;
}
ogg_stream_clear(&os);
if (_packet) {
free(_packet);
_packet = 0;
}
if (_fileOs) {
fclose(_fileOs);
_fileOs = 0;
}
_packetId = -1;
bytes_written = 0;
pages_out = 0;
total_samples = 0;
enc_granulepos = 0;
size_segments = 0;
last_segments = 0;
last_granulepos = 0;
memset(&os, 0, sizeof(ogg_stream_state));
memset(&inopt, 0, sizeof(oe_enc_opt));
memset(&header, 0, sizeof(OpusHeader));
memset(&op, 0, sizeof(ogg_packet));
memset(&og, 0, sizeof(ogg_page));
}
示例9: audio_encoder_terminate
static void audio_encoder_terminate()
{
if (opus_enc) {
opus_encoder_destroy(opus_enc);
opus_enc = NULL;
}
}
示例10: Destroy
void Destroy(OpusEncoder* Encoder) const
{
#if USE_UE4_MEM_ALLOC
FMemory::Free(Encoder);
#else
opus_encoder_destroy(Encoder);
#endif
}
示例11: kill_group_av
static void kill_group_av(Group_AV *group_av)
{
if (group_av->audio_encoder) {
opus_encoder_destroy(group_av->audio_encoder);
}
free(group_av);
}
示例12: PLG_FREE_V1
CODEC_API int PLG_FREE_V1(opus_48000)(void* opaqueCodecContext, int isDecoder)
{
int status = RPLG_INVALID_ARGUMENT;
assert(opaqueCodecContext);
if(opaqueCodecContext)
{
struct MpCodecOpusCodecState* codecContext = (struct MpCodecOpusCodecState*) opaqueCodecContext;
if(isDecoder)
{
assert(codecContext->mCodecType == CODEC_DECODE);
assert(codecContext->mpDecoderContext);
if(codecContext->mpDecoderContext)
{
opus_encoder_destroy(codecContext->mpDecoderContext);
status = RPLG_BAD_HANDLE;
codecContext->mpDecoderContext = NULL;
}
else
{
status = RPLG_BAD_HANDLE;
}
}
else
{
assert(codecContext->mCodecType == CODEC_ENCODE);
assert(codecContext->mpEncoderContext);
if(codecContext->mpEncoderContext)
{
opus_decoder_destroy(codecContext->mpEncoderContext);
status = RPLG_BAD_HANDLE;
codecContext->mpEncoderContext = NULL;
}
else
{
status = RPLG_BAD_HANDLE;
}
}
if(codecContext->mFmtp)
{
free(codecContext->mFmtp);
codecContext->mFmtp = NULL;
}
free(codecContext);
codecContext = NULL;
opaqueCodecContext = NULL;
}
return(status);
}
示例13: opus_encoder_destroy
void FVoiceEncoderOpus::Destroy()
{
#if USE_UE4_MEM_ALLOC
FMemory::Free(Encoder);
#else
opus_encoder_destroy(Encoder);
#endif
Encoder = NULL;
}
示例14: opus_encoder_destroy
OpusTrackEncoder::~OpusTrackEncoder()
{
if (mEncoder) {
opus_encoder_destroy(mEncoder);
}
if (mResampler) {
speex_resampler_destroy(mResampler);
mResampler = nullptr;
}
}
示例15: opus_destroy
void opus_destroy(long h_inst) {
opus_state_t* codec_inst;
if (h_inst) {
codec_inst = (opus_state_t*)h_inst;
opus_encoder_destroy(codec_inst->opus_enc);
opus_decoder_destroy(codec_inst->opus_dec);
free(codec_inst);
}
}