mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Merge branch 'master' of https://github.com/mannol1/toxcore
This commit is contained in:
commit
9d154029cb
|
@ -343,7 +343,8 @@ CodecState *codec_init_session ( uint32_t audio_bitrate,
|
|||
/*video_width = 320;
|
||||
video_height = 240; */
|
||||
} else {
|
||||
retu->capabilities |= ( 0 == init_video_encoder(retu, max_video_width, max_video_height, video_bitrate) ) ? v_encoding : 0;
|
||||
retu->capabilities |= ( 0 == init_video_encoder(retu, max_video_width, max_video_height,
|
||||
video_bitrate) ) ? v_encoding : 0;
|
||||
retu->capabilities |= ( 0 == init_video_decoder(retu) ) ? v_decoding : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -381,8 +381,8 @@ error:
|
|||
*/
|
||||
int toxav_kill_transmission ( ToxAv *av, int32_t call_index )
|
||||
{
|
||||
if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) {
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
if (cii(call_index, av->msi_session)) {
|
||||
LOGGER_WARNING("Invalid call index: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
|
@ -390,6 +390,13 @@ int toxav_kill_transmission ( ToxAv *av, int32_t call_index )
|
|||
|
||||
pthread_mutex_lock(&call->mutex);
|
||||
|
||||
if (!call->call_active) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
|
||||
call->call_active = 0;
|
||||
|
||||
rtp_terminate_session(call->crtps[audio_index], av->messenger);
|
||||
|
@ -532,15 +539,20 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out
|
|||
{
|
||||
if ( !output ) return ErrorInternal;
|
||||
|
||||
if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) {
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
if (cii(call_index, av->msi_session)) {
|
||||
LOGGER_WARNING("Invalid call index: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
|
||||
CallSpecific *call = &av->calls[call_index];
|
||||
pthread_mutex_lock(&call->mutex);
|
||||
|
||||
if (!call->call_active) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
uint8_t packet [RTP_PAYLOAD_SIZE];
|
||||
int recved_size;
|
||||
|
||||
|
@ -607,15 +619,23 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out
|
|||
*/
|
||||
inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size)
|
||||
{
|
||||
if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) {
|
||||
if (cii(call_index, av->msi_session)) {
|
||||
LOGGER_WARNING("Invalid call index: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
CallSpecific *call = &av->calls[call_index];
|
||||
pthread_mutex_lock(&call->mutex);
|
||||
|
||||
|
||||
if (!call->call_active) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
|
||||
pthread_mutex_lock(&av->calls[call_index].mutex);
|
||||
int rc = toxav_send_rtp_payload(av, call_index, TypeVideo, frame, frame_size);
|
||||
pthread_mutex_unlock(&av->calls[call_index].mutex);
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -633,8 +653,8 @@ inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *fr
|
|||
*/
|
||||
inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *dest, int dest_max, vpx_image_t *input)
|
||||
{
|
||||
if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) {
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
if (cii(call_index, av->msi_session)) {
|
||||
LOGGER_WARNING("Invalid call index: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
|
@ -642,8 +662,16 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d
|
|||
CallSpecific *call = &av->calls[call_index];
|
||||
pthread_mutex_lock(&call->mutex);
|
||||
|
||||
if (reconfigure_video_encoder_resolution(call->cs, input->d_w, input->d_h) != 0)
|
||||
if (!call->call_active) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
if (reconfigure_video_encoder_resolution(call->cs, input->d_w, input->d_h) != 0) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
return ErrorInternal;
|
||||
}
|
||||
|
||||
int rc = vpx_codec_encode(&call->cs->v_encoder, input, call->cs->frame_counter, 1, 0, MAX_ENCODE_TIME_US);
|
||||
|
||||
|
@ -691,8 +719,8 @@ inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, i
|
|||
{
|
||||
if ( !dest ) return ErrorInternal;
|
||||
|
||||
if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) {
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
if (cii(call_index, av->msi_session)) {
|
||||
LOGGER_WARNING("Invalid call index: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
|
@ -700,6 +728,13 @@ inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, i
|
|||
CallSpecific *call = &av->calls[call_index];
|
||||
pthread_mutex_lock(&call->mutex);
|
||||
|
||||
|
||||
if (!call->call_active) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
uint8_t packet [RTP_PAYLOAD_SIZE];
|
||||
|
||||
int recved_size = toxav_recv_rtp_payload(av, call_index, TypeAudio, packet);
|
||||
|
@ -747,10 +782,18 @@ inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *fr
|
|||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
CallSpecific *call = &av->calls[call_index];
|
||||
pthread_mutex_lock(&call->mutex);
|
||||
|
||||
|
||||
if (!call->call_active) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&av->calls[call_index].mutex);
|
||||
int rc = toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size);
|
||||
pthread_mutex_unlock(&av->calls[call_index].mutex);
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
@ -775,12 +818,18 @@ inline__ int toxav_prepare_audio_frame ( ToxAv *av, int32_t call_index, uint8_t
|
|||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
CallSpecific *call = &av->calls[call_index];
|
||||
pthread_mutex_lock(&call->mutex);
|
||||
|
||||
pthread_mutex_lock(&av->calls[call_index].mutex);
|
||||
|
||||
int32_t rc = opus_encode(av->calls[call_index].cs->audio_encoder, frame, frame_size, dest, dest_max);
|
||||
if (!call->call_active) {
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
LOGGER_WARNING("Action on inactive call: %d", call_index);
|
||||
return ErrorNoCall;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&av->calls[call_index].mutex);
|
||||
int32_t rc = opus_encode(call->cs->audio_encoder, frame, frame_size, dest, dest_max);
|
||||
pthread_mutex_unlock(&call->mutex);
|
||||
|
||||
if (rc < 0) {
|
||||
LOGGER_ERROR("Failed to encode payload: %s\n", opus_strerror(rc));
|
||||
|
|
Loading…
Reference in New Issue
Block a user