本文整理汇总了C++中opus_encoder_ctl函数的典型用法代码示例。如果您正苦于以下问题:C++ opus_encoder_ctl函数的具体用法?C++ opus_encoder_ctl怎么用?C++ opus_encoder_ctl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了opus_encoder_ctl函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: tdav_codec_opus_open
static int tdav_codec_opus_open(tmedia_codec_t* self)
{
tdav_codec_opus_t* opus = (tdav_codec_opus_t*)self;
int opus_err;
if(!opus) {
TSK_DEBUG_ERROR("Invalid parameter");
return -1;
}
// Initialize the decoder
if(!opus->decoder.inst) {
TSK_DEBUG_INFO("[OPUS] Open decoder: rate=%d, channels=%d", (int)self->in.rate, (int)TMEDIA_CODEC_AUDIO(self)->in.channels);
if(!(opus->decoder.inst = opus_decoder_create((opus_int32)self->in.rate, (int)TMEDIA_CODEC_AUDIO(self)->in.channels, &opus_err)) || opus_err != OPUS_OK) {
TSK_DEBUG_ERROR("Failed to create Opus decoder(rate=%d, channels=%d) instance with error code=%d.", (int)self->in.rate, (int)TMEDIA_CODEC_AUDIO(self)->in.channels, opus_err);
return -2;
}
}
opus->decoder.last_seq = 0;
// Initialize the encoder
if(!opus->encoder.inst) {
TSK_DEBUG_INFO("[OPUS] Open encoder: rate=%d, channels=%d", (int)self->out.rate, (int)TMEDIA_CODEC_AUDIO(self)->out.channels);
if(!(opus->encoder.inst = opus_encoder_create((opus_int32)self->out.rate, (int)TMEDIA_CODEC_AUDIO(self)->out.channels, OPUS_APPLICATION_VOIP, &opus_err)) || opus_err != OPUS_OK) {
TSK_DEBUG_ERROR("Failed to create Opus decoder(rate=%d, channels=%d) instance with error code=%d.", (int)self->out.rate, (int)TMEDIA_CODEC_AUDIO(self)->out.channels, opus_err);
return -2;
}
}
#if TDAV_UNDER_MOBILE /* iOS, Android and WP8 */
opus_encoder_ctl(opus->encoder.inst, OPUS_SET_COMPLEXITY(3));
#endif
opus_encoder_ctl(opus->encoder.inst, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
return 0;
}
开发者ID:AndyUI,项目名称:doubango,代码行数:35,代码来源:tdav_codec_opus.c
示例2: init_audio_encoder
static int init_audio_encoder(CSSession *cs)
{
int rc = OPUS_OK;
cs->audio_encoder = opus_encoder_create(cs->audio_encoder_sample_rate,
cs->audio_encoder_channels, OPUS_APPLICATION_AUDIO, &rc);
if ( rc != OPUS_OK ) {
LOGGER_ERROR("Error while starting audio encoder: %s", opus_strerror(rc));
return -1;
}
rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_BITRATE(cs->audio_encoder_bitrate));
if ( rc != OPUS_OK ) {
LOGGER_ERROR("Error while setting encoder ctl: %s", opus_strerror(rc));
return -1;
}
rc = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_COMPLEXITY(10));
if ( rc != OPUS_OK ) {
LOGGER_ERROR("Error while setting encoder ctl: %s", opus_strerror(rc));
return -1;
}
return 0;
}
开发者ID:ittner,项目名称:toxcore,代码行数:27,代码来源:codec.c
示例3: apply_max_bitrate
static void apply_max_bitrate(OpusEncData *d) {
ms_message("Setting opus codec bitrate to [%i] from network bitrate [%i] with ptime [%i]", d->bitrate, d->max_network_bitrate, d->ptime);
/* give the bitrate to the encoder if exists*/
if (d->state) {
opus_int32 maxBandwidth=0;
/*tell the target bitrate, opus will choose internally the bandwidth to use*/
int error = opus_encoder_ctl(d->state, OPUS_SET_BITRATE(d->bitrate));
if (error != OPUS_OK) {
ms_error("could not set bit rate to opus encoder: %s", opus_strerror(error));
}
/* implement maxplaybackrate parameter, which is constraint on top of bitrate */
if (d->maxplaybackrate <= 8000) {
maxBandwidth = OPUS_BANDWIDTH_NARROWBAND;
} else if (d->maxplaybackrate <= 12000) {
maxBandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
} else if (d->maxplaybackrate <= 16000) {
maxBandwidth = OPUS_BANDWIDTH_WIDEBAND;
} else if (d->maxplaybackrate <= 24000) {
maxBandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
} else {
maxBandwidth = OPUS_BANDWIDTH_FULLBAND;
}
if (maxBandwidth!=0){
error = opus_encoder_ctl(d->state, OPUS_SET_MAX_BANDWIDTH(maxBandwidth));
if (error != OPUS_OK) {
ms_error("could not set max bandwidth to opus encoder: %s", opus_strerror(error));
}
}
}
}
开发者ID:xiaolds,项目名称:VideoCallVoIP,代码行数:34,代码来源:msopus.c
示例4: init_audio_encoder
int init_audio_encoder(CodecState *cs, uint32_t audio_channels)
{
int err = OPUS_OK;
cs->audio_encoder = opus_encoder_create(cs->audio_sample_rate, audio_channels, OPUS_APPLICATION_AUDIO, &err);
err = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_BITRATE(cs->audio_bitrate));
err = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_COMPLEXITY(10));
return err == OPUS_OK ? 0 : -1;
}
开发者ID:anandanwar4,项目名称:ProjectTox-Core,代码行数:10,代码来源:media.c
示例5: WebRtcOpus_EncoderInit
WebRtc_Word16 WebRtcOpus_EncoderInit(OPUS_encinst_t* encInst,
WebRtc_Word16 samplFreq,
WebRtc_Word16 mode,
WebRtc_Word16 vbrFlag){
opus_encoder_ctl(((OPUS_Enc_Inst_t*)encInst)->enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
return (0);
}
开发者ID:Gurtej,项目名称:op,代码行数:9,代码来源:opus_interface.c
示例6: opus_enc_init
int opus_enc_init(opus_enc *opus)
{
int err;
err = 0;
opus->header = (OpusHeader *)calloc(1, sizeof(OpusHeader));
opus->header_data = (unsigned char *)calloc (1, 1024);
opus->tags = (unsigned char *)calloc (1, 1024);
opus->buffer = (unsigned char *)calloc (1, 4 * 4096);
srand(time(NULL));
ogg_stream_init(&opus->os, rand());
opus->header->gain = 0;
opus->header->channels = opus->channel;
if ((opus->bitrate < 8000) || (opus->bitrate > 320000)) {
opus->bitrate = DEFAULT_OPUS_BITRATE;
}
opus->header->input_sample_rate = 48000;
opus->encoder = opus_encoder_create (opus->header->input_sample_rate, opus->channel, OPUS_APPLICATION_AUDIO, &err);
opus_encoder_ctl (opus->encoder, OPUS_SET_BITRATE(opus->bitrate));
if (opus->encoder == NULL) {
printf("Opus Encoder creation error: %s\n", opus_strerror (err));
return 1;
}
opus->last_bitrate = opus->bitrate;
opus_encoder_ctl (opus->encoder, OPUS_GET_LOOKAHEAD (&opus->header->preskip));
opus->header_size = opus_header_to_packet (opus->header, opus->header_data, 100);
opus->tags_size =
8 + 4 + strlen (opus_get_version_string ()) + 4 + 4 + strlen ("ENCODER=") + strlen (VERSION);
memcpy (opus->tags, "OpusTags", 8);
opus->tags[8] = strlen (opus_get_version_string ());
memcpy (opus->tags + 12, opus_get_version_string (), strlen (opus_get_version_string ()));
opus->tags[12 + strlen (opus_get_version_string ())] = 1;
opus->tags[12 + strlen (opus_get_version_string ()) + 4] = strlen ("ENCODER=") + strlen (VERSION);
memcpy (opus->tags + 12 + strlen (opus_get_version_string ()) + 4 + 4, "ENCODER=", strlen ("ENCODER="));
memcpy (opus->tags + 12 + strlen (opus_get_version_string ()) + 4 + 4 + strlen ("ENCODER="),
VERSION,
strlen (VERSION));
//printf("Opus Encoder Created\n");
return 0;
}
开发者ID:DragonZX,项目名称:Butt,代码行数:52,代码来源:opus_encode.cpp
示例7: opus_encoder_create
OpusEncoder *create_audio_encoder(Logger *log, int32_t bit_rate, int32_t sampling_rate, int32_t channel_count)
{
int status = OPUS_OK;
OpusEncoder *rc = opus_encoder_create(sampling_rate, channel_count, OPUS_APPLICATION_VOIP, &status);
if (status != OPUS_OK) {
LOGGER_ERROR(log, "Error while starting audio encoder: %s", opus_strerror(status));
return NULL;
}
status = opus_encoder_ctl(rc, OPUS_SET_BITRATE(bit_rate));
if (status != OPUS_OK) {
LOGGER_ERROR(log, "Error while setting encoder ctl: %s", opus_strerror(status));
goto FAILURE;
}
/* Enable in-band forward error correction in codec */
status = opus_encoder_ctl(rc, OPUS_SET_INBAND_FEC(1));
if (status != OPUS_OK) {
LOGGER_ERROR(log, "Error while setting encoder ctl: %s", opus_strerror(status));
goto FAILURE;
}
/* Make codec resistant to up to 10% packet loss
* NOTE This could also be adjusted on the fly, rather than hard-coded,
* with feedback from the receiving client.
*/
status = opus_encoder_ctl(rc, OPUS_SET_PACKET_LOSS_PERC(10));
if (status != OPUS_OK) {
LOGGER_ERROR(log, "Error while setting encoder ctl: %s", opus_strerror(status));
goto FAILURE;
}
/* Set algorithm to the highest complexity, maximizing compression */
status = opus_encoder_ctl(rc, OPUS_SET_COMPLEXITY(10));
if (status != OPUS_OK) {
LOGGER_ERROR(log, "Error while setting encoder ctl: %s", opus_strerror(status));
goto FAILURE;
}
return rc;
FAILURE:
opus_encoder_destroy(rc);
return NULL;
}
开发者ID:GrayHatter,项目名称:toxcore,代码行数:50,代码来源:audio.c
示例8: opus_encoder_ctl
int AudioInput::encodeOpusFrame(short *source, int size, EncodingOutputBuffer& buffer) {
int len = 0;
#ifdef USE_OPUS
if (!bPreviousVoice)
opus_encoder_ctl(opusState, OPUS_RESET_STATE, NULL);
opus_encoder_ctl(opusState, OPUS_SET_BITRATE(iAudioQuality));
len = opus_encode(opusState, source, size, &buffer[0], buffer.size());
const int tenMsFrameCount = (size / iFrameSize);
iBitrate = (len * 100 * 8) / tenMsFrameCount;
#endif
return len;
}
开发者ID:HackLinux,项目名称:mumble,代码行数:14,代码来源:AudioInput.cpp
示例9: UE_LOG
bool FVoiceEncoderOpus::Init(int32 InSampleRate, int32 InNumChannels)
{
UE_LOG(LogVoiceEncode, Display, TEXT("EncoderVersion: %s"), ANSI_TO_TCHAR(opus_get_version_string()));
SampleRate = InSampleRate;
NumChannels = InNumChannels;
// 20ms frame sizes are a good choice for most applications (1000ms / 20ms = 50)
FrameSize = SampleRate / NUM_OPUS_FRAMES_PER_SEC;
//MaxFrameSize = FrameSize * MAX_OPUS_FRAMES;
int32 EncError = 0;
#if USE_UE4_MEM_ALLOC
int32 EncSize = opus_encoder_get_size(NumChannels);
Encoder = (OpusEncoder*)FMemory::Malloc(EncSize);
EncError = opus_encoder_init(Encoder, SampleRate, NumChannels, OPUS_APPLICATION_VOIP);
#else
Encoder = opus_encoder_create(SampleRate, NumChannels, OPUS_APPLICATION_VOIP, &EncError);
#endif
if (EncError != OPUS_OK)
{
UE_LOG(LogVoiceEncode, Warning, TEXT("Failed to init Opus Encoder: %s"), ANSI_TO_TCHAR(opus_strerror(EncError)));
Destroy();
}
// Turn on variable bit rate encoding
int32 UseVbr = 1;
opus_encoder_ctl(Encoder, OPUS_SET_VBR(UseVbr));
// Turn off constrained VBR
int32 UseCVbr = 0;
opus_encoder_ctl(Encoder, OPUS_SET_VBR_CONSTRAINT(UseCVbr));
// Complexity (1-10)
int32 Complexity = 1;
opus_encoder_ctl(Encoder, OPUS_SET_COMPLEXITY(Complexity));
// Forward error correction
int32 InbandFEC = 0;
opus_encoder_ctl(Encoder, OPUS_SET_INBAND_FEC(InbandFEC));
#if DEBUG_OPUS
DebugEncoderInfo(Encoder);
#endif // DEBUG_OPUS
return EncError == OPUS_OK;
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:48,代码来源:VoiceCodecOpus.cpp
示例10: apply_max_bitrate
static void apply_max_bitrate(OpusEncData *d) {
ms_message("Setting opus codec bitrate to [%i] from network bitrate [%i] with ptime [%i]", d->bitrate, d->max_network_bitrate, d->ptime);
/* give the bitrate to the encoder if exists*/
if (d->state) {
opus_int32 maxBandwidth;
int error = opus_encoder_ctl(d->state, OPUS_SET_BITRATE(d->bitrate));
if (error != OPUS_OK) {
ms_error("could not set bit rate to opus encoder: %s", opus_strerror(error));
}
/* set output sampling rate according to bitrate and RFC section 3.1.1 */
if (d->bitrate<12000) {
maxBandwidth = OPUS_BANDWIDTH_NARROWBAND;
} else if (d->bitrate<20000) {
maxBandwidth = OPUS_BANDWIDTH_WIDEBAND;
} else if (d->bitrate<40000) {
maxBandwidth = OPUS_BANDWIDTH_FULLBAND;
} else if (d->bitrate<64000) {
maxBandwidth = OPUS_BANDWIDTH_FULLBAND;
} else {
maxBandwidth = OPUS_BANDWIDTH_FULLBAND;
}
/* check if selected maxBandwidth is compatible with the maxplaybackrate parameter */
if (d->maxplaybackrate < 12000) {
maxBandwidth = OPUS_BANDWIDTH_NARROWBAND;
} else if (d->maxplaybackrate < 16000) {
if (maxBandwidth != OPUS_BANDWIDTH_NARROWBAND) {
maxBandwidth = OPUS_BANDWIDTH_MEDIUMBAND;
}
} else if (d->maxplaybackrate < 24000) {
if (maxBandwidth != OPUS_BANDWIDTH_NARROWBAND) {
maxBandwidth = OPUS_BANDWIDTH_WIDEBAND;
}
} else if (d->maxplaybackrate < 48000) {
if (maxBandwidth == OPUS_BANDWIDTH_FULLBAND) {
maxBandwidth = OPUS_BANDWIDTH_SUPERWIDEBAND;
}
}
error = opus_encoder_ctl(d->state, OPUS_SET_MAX_BANDWIDTH(maxBandwidth));
if (error != OPUS_OK) {
ms_error("could not set max bandwidth to opus encoder: %s", opus_strerror(error));
}
}
}
开发者ID:biddyweb,项目名称:azfone-ios,代码行数:48,代码来源:msopus.c
示例11: 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;
}
开发者ID:GrayHatter,项目名称:toxcore,代码行数:31,代码来源:audio.c
示例12: opus_encoder_ctl
int AudioInput::encodeOpusFrame(short *source, int size, EncodingOutputBuffer& buffer) {
int len = 0;
#ifdef USE_OPUS
if (bResetEncoder) {
opus_encoder_ctl(opusState, OPUS_RESET_STATE, NULL);
bResetEncoder = false;
}
opus_encoder_ctl(opusState, OPUS_SET_BITRATE(iAudioQuality));
len = opus_encode(opusState, source, size, &buffer[0], static_cast<opus_int32>(buffer.size()));
const int tenMsFrameCount = (size / iFrameSize);
iBitrate = (len * 100 * 8) / tenMsFrameCount;
#endif
return len;
}
开发者ID:AceXare,项目名称:mumble,代码行数:16,代码来源:AudioInput.cpp
示例13: opus_encoder_create
EncodeManager::EncodeManager()
{
_enc = opus_encoder_create(SAMPLE_RATE, 2, OPUS_APPLICATION_VOIP, &_err);
_dec = opus_decoder_create(SAMPLE_RATE, 2, &_err);
opus_encoder_ctl(this->_enc, OPUS_GET_BANDWIDTH(&this->_len));
this->_len = FRAMES_PER_BUFFER;
}
开发者ID:Zaboon,项目名称:cpp_babel,代码行数:7,代码来源:EncodeManager.cpp
示例14: opus_enc_write_header
//This function needs to be called before
//every connection
void opus_enc_write_header(opus_enc *opus)
{
ogg_packet op;
ogg_stream_clear (&opus->os);
ogg_stream_init(&opus->os, rand());
opus_encoder_ctl (opus->encoder, OPUS_RESET_STATE);
opus->packetno = 0;
opus->granulepos = 0;
op.b_o_s = 1;
op.e_o_s = 0;
op.granulepos = 0;
op.packetno = opus->packetno++;
op.packet = opus->header_data;
op.bytes = opus->header_size;
ogg_stream_packetin (&opus->os, &op);
op.b_o_s = 0;
op.e_o_s = 0;
op.granulepos = 0;
op.packetno = opus->packetno++;
op.packet = opus->tags;
op.bytes = opus->tags_size;
ogg_stream_packetin (&opus->os, &op);
}
开发者ID:DragonZX,项目名称:Butt,代码行数:32,代码来源:opus_encode.cpp
示例15: ms_opus_enc_preprocess
static void ms_opus_enc_preprocess(MSFilter *f) {
int error;
OpusEncData *d = (OpusEncData *)f->data;
/* create the encoder */
d->state = opus_encoder_create(d->samplerate, d->channels, d->application, &error);
if (error != OPUS_OK) {
ms_error("Opus encoder creation failed: %s", opus_strerror(error));
return;
}
/* set complexity to 0 for single processor arm devices */
#if defined(__arm__) || defined(_M_ARM)
if (ms_factory_get_cpu_count(f->factory)==1){
opus_encoder_ctl(d->state, OPUS_SET_COMPLEXITY(0));
}else{
opus_encoder_ctl(d->state, OPUS_SET_COMPLEXITY(5));
}
#endif
error = opus_encoder_ctl(d->state, OPUS_SET_PACKET_LOSS_PERC(10));
if (error != OPUS_OK) {
ms_error("Could not set default loss percentage to opus encoder: %s", opus_strerror(error));
}
/* set the encoder parameters: VBR, IN_BAND_FEC, DTX and bitrate settings */
ms_opus_enc_set_vbr(f);
ms_opus_enc_set_inbandfec(f);
ms_opus_enc_set_dtx(f);
/* if decoder prefers mono signal, force encoder to output mono signal */
if (d->stereo == 0) {
error = opus_encoder_ctl(d->state, OPUS_SET_FORCE_CHANNELS(1));
if (error != OPUS_OK) {
ms_error("could not force mono channel to opus encoder: %s", opus_strerror(error));
}
if (d->channels == 2) ms_message("Opus encoder configured to encode mono despite it is feed with stereo.");
}else if (d->channels == 2){
ms_message("Opus encoder configured to encode stereo.");
}
ms_filter_lock(f);
// set bitrate wasn't call, compute it with the default network bitrate (36000)
if (d->bitrate==-1) {
compute_max_bitrate(d, 0);
}
apply_max_bitrate(d);
ms_filter_unlock(f);
}
开发者ID:william30101,项目名称:linphonemedia,代码行数:47,代码来源:msopus.c
示例16: init_send_audio
int init_send_audio(codec_state *cs)
{
cs->support_send_audio = 0;
const ALchar *pDeviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
int i = 0;
const ALchar *device_names[20];
if (pDeviceList) {
printf("\nAvailable Capture Devices are:\n");
while (*pDeviceList) {
device_names[i] = pDeviceList;
printf("%d) %s\n", i, device_names[i]);
pDeviceList += strlen(pDeviceList) + 1;
++i;
}
}
printf("enter capture device number: \n");
char dev[2];
fgets(dev, sizeof(dev), stdin);
cs->audio_capture_device = alcCaptureOpenDevice(device_names[dev[0] - 48], AUDIO_SAMPLE_RATE, AL_FORMAT_MONO16,
AUDIO_FRAME_SIZE * 4);
if (alcGetError(cs->audio_capture_device) != AL_NO_ERROR) {
printf("could not start capture device! %d\n", alcGetError(cs->audio_capture_device));
return 0;
}
int err = OPUS_OK;
cs->audio_bitrate = AUDIO_BITRATE;
cs->audio_encoder = opus_encoder_create(AUDIO_SAMPLE_RATE, 1, OPUS_APPLICATION_VOIP, &err);
err = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_BITRATE(cs->audio_bitrate));
err = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_COMPLEXITY(10));
err = opus_encoder_ctl(cs->audio_encoder, OPUS_SET_SIGNAL(OPUS_SIGNAL_VOICE));
opus_encoder_init(cs->audio_encoder, AUDIO_SAMPLE_RATE, 1, OPUS_APPLICATION_VOIP);
int nfo;
err = opus_encoder_ctl(cs->audio_encoder, OPUS_GET_LOOKAHEAD(&nfo));
/* printf("Encoder lookahead delay : %d\n", nfo); */
printf("init audio encoder successful\n");
return 1;
}
开发者ID:okiyama,项目名称:ProjectTox-Core,代码行数:46,代码来源:AV_codec.c
示例17: opus_encoder_ctl
JNIEXPORT jint JNICALL
Java_org_jitsi_impl_neomedia_codec_audio_opus_Opus_encoder_1set_1vbr
(JNIEnv *env, jclass clazz, jlong encoder, jint vbr)
{
opus_int32 x = vbr;
return
opus_encoder_ctl((OpusEncoder *) (intptr_t) encoder, OPUS_SET_VBR(x));
}
开发者ID:Huangzefeng,项目名称:libjitsi,代码行数:9,代码来源:org_jitsi_impl_neomedia_codec_audio_opus_Opus.c
示例18: audio_encoder_init
static void audio_encoder_init(uint32_t samplerate, int complexity,
uint32_t bitrate)
{
assert(opus_enc == NULL);
int err = 0;
/* 1 channel (mono), OPUS audio profile */
opus_enc = opus_encoder_create(samplerate, 1, OPUS_APPLICATION_AUDIO, &err);
if (!opus_enc) {
fprintf(stderr, "ERROR: opus_encoder_create() has failed - %d\n", err);
exit(EXIT_FAILURE);
}
opus_encoder_ctl(opus_enc, OPUS_SET_COMPLEXITY(complexity));
opus_encoder_ctl(opus_enc, OPUS_SET_BITRATE(bitrate));
opus_encoder_ctl(opus_enc, OPUS_SET_SIGNAL(OPUS_SIGNAL_MUSIC));
opus_encoder_ctl(opus_enc, OPUS_SET_BANDWIDTH(OPUS_BANDWIDTH_FULLBAND));
}
开发者ID:KJYoo1989,项目名称:Ubercaster,代码行数:18,代码来源:sender.c
示例19: opus_enc_encode
int opus_enc_encode(opus_enc *opus, short *pcm_buf, char *enc_buf, int size)
{
int w = 0;
ogg_packet op;
int ret;
if(size == 0)
return 0;
//printf("Opus Encoder encoding %d samples\n", size);
if (opus->encoder == NULL) {
printf("Opus Encoder NULL wtf?\n");
return 0;
}
while (ogg_stream_flush(&opus->os, &opus->og) != 0) {
memcpy(enc_buf+w, opus->og.header, opus->og.header_len);
w += opus->og.header_len;
memcpy(enc_buf+w, opus->og.body, opus->og.body_len);
w += opus->og.body_len;
}
if (opus->last_bitrate != opus->bitrate) {
if ((opus->bitrate < 9600) || (opus->bitrate > 320000)) {
opus->bitrate = DEFAULT_OPUS_BITRATE;
}
opus_encoder_ctl (opus->encoder, OPUS_SET_BITRATE(opus->bitrate));
opus->last_bitrate = opus->bitrate;
}
ret = opus_encode (opus->encoder, pcm_buf, 960, opus->buffer, 2048 * 4);
//printf("Opus Encoder encoding %d samples, got back %d bytes\n", size, ret);
op.b_o_s = 0;
op.e_o_s = 0;
op.granulepos = opus->granulepos;
op.packetno = opus->packetno++;
op.packet = opus->buffer;
op.bytes = ret;
opus->granulepos += 960;
ogg_stream_packetin (&opus->os, &op);
while (ogg_stream_flush(&opus->os, &opus->og) != 0) {
memcpy(enc_buf+w, opus->og.header, opus->og.header_len);
w += opus->og.header_len;
memcpy(enc_buf+w, opus->og.body, opus->og.body_len);
w += opus->og.body_len;
}
return w;
}
开发者ID:krad-radio,项目名称:butt-krad-opus,代码行数:57,代码来源:opus_encode.cpp
示例20: opus_encoder_create
opus_encoder::opus_encoder()
{
int err;
_opus = opus_encoder_create(SAMPLE_RATE,CHANNELS, OPUS_APPLICATION_VOIP, &err);
if(err != OPUS_OK)
{
LOG << "opus encoder create error: ";
log_opus_error(err);
}
opus_encoder_ctl(_opus, OPUS_SET_BITRATE(OPUS_AUTO));
opus_encoder_ctl(_opus, OPUS_SET_VBR(1));
opus_encoder_ctl(_opus, OPUS_SET_FORCE_CHANNELS(1)); //force mono
opus_encoder_ctl(_opus, OPUS_SET_PACKET_LOSS_PERC(2));
ENSURE(_opus);
}
开发者ID:rlankenau,项目名称:firestr,代码行数:19,代码来源:audio.cpp
注:本文中的opus_encoder_ctl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论