1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 04:43:25 +01:00

Fix some new AV api changes

This commit is contained in:
Jfreegman 2015-10-20 17:59:14 -04:00
parent 462cfca175
commit abfdbfe468
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
3 changed files with 35 additions and 37 deletions

View File

@ -83,16 +83,16 @@ static int set_call(Call* call, bool start)
void call_cb ( ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data );
void callstate_cb ( ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data );
void receive_audio_frame_cb ( ToxAV *av, uint32_t friend_number, int16_t const *pcm, size_t sample_count,
void receive_audio_frame_cb ( ToxAV *av, uint32_t friend_number, int16_t const *pcm, size_t sample_count,
uint8_t channels, uint32_t sampling_rate, void *user_data );
void audio_bit_rate_status_cb( ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data );
void audio_bit_rate_status_cb( ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate,
uint32_t video_bit_rate, void *user_data );
void receive_video_frame_cb ( ToxAV *av, uint32_t friend_number,
uint16_t width, uint16_t height,
uint8_t const *y, uint8_t const *u, uint8_t const *v, uint8_t const *a,
int32_t ystride, int32_t ustride, int32_t vstride, int32_t astride,
void *user_data );
void video_bit_rate_status_cb( ToxAV *av, uint32_t friend_number,
void video_bit_rate_status_cb( ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data);
void callback_recv_invite ( uint32_t friend_number );
@ -154,7 +154,7 @@ ToxAV *init_audio(ToxWindow *self, Tox *tox)
toxav_callback_call(CallControl.av, call_cb, &CallControl);
toxav_callback_call_state(CallControl.av, callstate_cb, &CallControl);
toxav_callback_audio_receive_frame(CallControl.av, receive_audio_frame_cb, &CallControl);
toxav_callback_audio_bit_rate_status(CallControl.av, audio_bit_rate_status_cb, &CallControl);
toxav_callback_bit_rate_status(CallControl.av, audio_bit_rate_status_cb, &CallControl);
return CallControl.av;
}
@ -177,9 +177,9 @@ void read_device_callback(const int16_t* captured, uint32_t size, void* data)
uint32_t friend_number = *((uint32_t*)data); /* TODO: Or pass an array of call_idx's */
int64_t sample_count = CallControl.audio_sample_rate * CallControl.audio_frame_duration / 1000;
if ( sample_count <= 0 || toxav_audio_send_frame(CallControl.av, friend_number,
captured, sample_count,
CallControl.audio_channels,
if ( sample_count <= 0 || toxav_audio_send_frame(CallControl.av, friend_number,
captured, sample_count,
CallControl.audio_channels,
CallControl.audio_sample_rate, &error) == false )
{}
}
@ -231,7 +231,7 @@ int stop_transmission(Call *call, uint32_t friend_number)
TOXAV_ERR_CALL_CONTROL error = TOXAV_ERR_CALL_CONTROL_OK;
if ( CallControl.call_state != TOXAV_FRIEND_CALL_STATE_FINISHED )
toxav_call_control(CallControl.av, friend_number, TOXAV_CALL_CONTROL_CANCEL, &error);
toxav_call_control(CallControl.av, friend_number, TOXAV_CALL_CONTROL_CANCEL, &error);
if ( error == TOXAV_ERR_CALL_CONTROL_OK ) {
call->ttas = false;
@ -327,18 +327,17 @@ void callstate_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_
}
}
void receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
int16_t const *pcm, size_t sample_count,
void receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
int16_t const *pcm, size_t sample_count,
uint8_t channels, uint32_t sampling_rate, void *user_data)
{
write_device_callback(friend_number, pcm, frame_size);
}
void audio_bit_rate_status_cb(ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data)
void audio_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate,
uint32_t video_bit_rate, void *user_data)
{
if ( stable )
CallControl.audio_bit_rate = bit_rate;
CallControl.audio_bit_rate = audio_bit_rate;
}
@ -357,7 +356,7 @@ void callback_recv_ringing(uint32_t friend_number)
void callback_recv_starting(uint32_t friend_number)
{
ToxWindow* windows = CallControl.prompt;
int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) {
if ( windows[i].onStarting != NULL && windows[i].num == friend_number ) {
@ -397,7 +396,7 @@ void callback_call_rejected(uint32_t friend_number)
}
void callback_call_ended(uint32_t friend_number)
{
CB_BODY(friend_number, onEnd);
CB_BODY(friend_number, onEnd);
}
void callback_requ_timeout(uint32_t friend_number)
{
@ -533,7 +532,7 @@ void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
}
/* Manually send a cancel call control because call hasn't started */
toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL);
toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL);
CallControl.pending_call = false;
/* Callback will print status... */
@ -561,13 +560,13 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
#ifdef VIDEO
callback_video_end(self->num);
#endif /* VIDEO */
#endif /* VIDEO */
if ( CallControl.pending_call ) {
/* Manually send a cancel call control because call hasn't started */
toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL);
toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL);
callback_call_canceled(self->num);
}
else {

View File

@ -836,7 +836,7 @@ static int group_audio_close_out_device(int groupnum)
// return 0;
// }
static void groupchat_onWriteDevice(ToxWindow *self, Tox *m, int groupnum, int peernum, const int16_t *pcm,
static void groupchat_onWriteDevice(ToxWindow *self, Tox *m, uint32_t groupnum, int peernum, const int16_t *pcm,
unsigned int samples, uint8_t channels, unsigned int sample_rate)
{
return;

View File

@ -44,8 +44,9 @@ void receive_video_frame_cb( ToxAV *av, uint32_t friend_number,
uint8_t const *y, uint8_t const *u, uint8_t const *v,
int32_t ystride, int32_t ustride, int32_t vstride,
void *user_data );
void video_bit_rate_status_cb( ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data);
void video_bit_rate_status_cb( ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate,
uint32_t video_bit_rate, void *user_data);
static void print_err (ToxWindow *self, const char *error_str)
{
@ -73,7 +74,7 @@ ToxAV *init_video(ToxWindow *self, Tox *tox)
}
toxav_callback_video_receive_frame(CallControl.av, receive_video_frame_cb, &CallControl);
toxav_callback_video_bit_rate_status(CallControl.av, video_bit_rate_status_cb, &CallControl);
toxav_callback_bit_rate_status(CallControl.av, video_bit_rate_status_cb, &CallControl);
return CallControl.av;
}
@ -131,7 +132,7 @@ int start_video_transmission(ToxWindow *self, ToxAV *av, Call *call)
}
CallControl.video_bit_rate = default_video_bit_rate;
if ( toxav_video_bit_rate_set(CallControl.av, self->num, CallControl.video_bit_rate, true, NULL) == false ) {
if ( toxav_bit_rate_set(CallControl.av, self->num, -1, CallControl.video_bit_rate, NULL) == false ) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to set video bit rate");
return -1;
}
@ -140,7 +141,7 @@ int start_video_transmission(ToxWindow *self, ToxAV *av, Call *call)
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open input video device!");
return -1;
}
if ( register_video_device_callback(self->num, call->vin_idx, read_video_device_callback, &self->num) != vde_None )
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to register input video handler!");
@ -150,7 +151,7 @@ int start_video_transmission(ToxWindow *self, ToxAV *av, Call *call)
int stop_video_transmission(Call *call, int friend_number)
{
CallControl.video_bit_rate = 0;
toxav_video_bit_rate_set(CallControl.av, friend_number, CallControl.video_bit_rate, true, NULL);
toxav_bit_rate_set(CallControl.av, friend_number, -1, CallControl.video_bit_rate, NULL);
if ( call->vin_idx != -1 )
close_video_device(vdt_input, call->vin_idx);
@ -178,13 +179,11 @@ void receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
write_video_device_callback(friend_number, width, height, y, u, v, ystride, ustride, vstride, user_data);
}
void video_bit_rate_status_cb(ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data)
void video_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate,
uint32_t video_bit_rate, void *user_data)
{
if ( stable ) {
CallControl.video_bit_rate = bit_rate;
toxav_video_bit_rate_set(CallControl.av, friend_number, CallControl.video_bit_rate, false, NULL);
}
CallControl.video_bit_rate = video_bit_rate;
toxav_bit_rate_set(CallControl.av, friend_number, -1, CallControl.video_bit_rate, NULL);
}
void callback_recv_video_starting(uint32_t friend_number)
@ -197,7 +196,7 @@ void callback_recv_video_starting(uint32_t friend_number)
open_primary_video_device(vdt_output, &this_call->vout_idx);
}
void callback_recv_video_end(uint32_t friend_number)
{
{
Call* this_call = &CallControl.calls[friend_number];
close_video_device(vdt_output, this_call->vout_idx);
@ -274,7 +273,7 @@ void cmd_video(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
callback_video_starting(self->num);
else
callback_video_end(self->num);
return;
on_error:
print_err (self, error_str);
@ -416,4 +415,4 @@ void cmd_ccur_video_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, ch
return;
on_error:
print_err (self, error_str);
}
}