mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Resolution of video can now be changed during call by passing it
frames with a different resolution. Added function to change bitrate of video for later use.
This commit is contained in:
parent
705fceb2e0
commit
9f164b4563
|
@ -206,6 +206,44 @@ int init_audio_decoder(CodecState *cs, uint32_t audio_channels)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int reconfigure_video_encoder_resolution(CodecState *cs, uint16_t width, uint16_t height)
|
||||
{
|
||||
vpx_codec_enc_cfg_t cfg = *cs->v_encoder.config.enc;
|
||||
|
||||
if (cfg.g_w == width && cfg.g_h == height)
|
||||
return 0;
|
||||
|
||||
LOGGER_DEBUG("New video resolution: %u %u", width, height);
|
||||
cfg.g_w = width;
|
||||
cfg.g_h = height;
|
||||
int rc = vpx_codec_enc_config_set(&cs->v_encoder, &cfg);
|
||||
|
||||
if ( rc != VPX_CODEC_OK) {
|
||||
LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int reconfigure_video_encoder_bitrate(CodecState *cs, uint32_t video_bitrate)
|
||||
{
|
||||
vpx_codec_enc_cfg_t cfg = *cs->v_encoder.config.enc;
|
||||
|
||||
if (cfg.rc_target_bitrate == video_bitrate)
|
||||
return 0;
|
||||
|
||||
LOGGER_DEBUG("New video bitrate: %u", video_bitrate);
|
||||
cfg.rc_target_bitrate = video_bitrate;
|
||||
int rc = vpx_codec_enc_config_set(&cs->v_encoder, &cfg);
|
||||
|
||||
if ( rc != VPX_CODEC_OK) {
|
||||
LOGGER_ERROR("Failed to set encoder control setting: %s", vpx_codec_err_to_string(rc));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int init_video_encoder(CodecState *cs, uint16_t width, uint16_t height, uint32_t video_bitrate)
|
||||
{
|
||||
|
|
|
@ -102,6 +102,11 @@ CodecState *codec_init_session ( uint32_t audio_bitrate,
|
|||
|
||||
void codec_terminate_session(CodecState *cs);
|
||||
|
||||
/* Reconfigure video encoder
|
||||
return 0 on success.
|
||||
return -1 on failure. */
|
||||
int reconfigure_video_encoder_resolution(CodecState *cs, uint16_t width, uint16_t height);
|
||||
int reconfigure_video_encoder_bitrate(CodecState *cs, uint32_t video_bitrate);
|
||||
|
||||
/* Calculate energy and return 1 if has voice, 0 if not */
|
||||
int energy_VAD(CodecState *cs, int16_t *PCM, uint16_t frame_size, float energy);
|
||||
|
|
|
@ -640,6 +640,7 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d
|
|||
|
||||
|
||||
CallSpecific *call = &av->calls[call_index];
|
||||
reconfigure_video_encoder_resolution(call->cs, input->d_w, input->d_h);
|
||||
|
||||
int rc = vpx_codec_encode(&call->cs->v_encoder, input, call->cs->frame_counter, 1, 0, MAX_ENCODE_TIME_US);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user