Added userdata pointer to audio/video callbacks

This commit is contained in:
mannol 2014-08-02 01:09:33 +02:00
parent 77df39863e
commit 6c1ac97da9
4 changed files with 21 additions and 16 deletions

View File

@ -163,11 +163,11 @@ void callback_requ_timeout ( void *av, int32_t call_index, void *_arg )
cast->Alice.status = TimedOut; cast->Alice.status = TimedOut;
} }
static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length) static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length, void* userdata)
{ {
} }
static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img) static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img, void* userdata)
{ {
} }
@ -187,8 +187,8 @@ void register_callbacks(ToxAv *av, void *data)
toxav_register_callstate_callback(av, callback_call_type_change, av_OnMediaChange, data); toxav_register_callstate_callback(av, callback_call_type_change, av_OnMediaChange, data);
toxav_register_audio_recv_callback(av, callback_audio); toxav_register_audio_recv_callback(av, callback_audio, NULL);
toxav_register_video_recv_callback(av, callback_video); toxav_register_video_recv_callback(av, callback_video, NULL);
} }

View File

@ -120,11 +120,11 @@ void callback_requ_timeout ( void *av, int32_t call_index, void *_arg )
//ck_assert_msg(0, "No answer!"); //ck_assert_msg(0, "No answer!");
} }
static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length) static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length, void* userdata)
{ {
} }
static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img) static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img, void* userdata)
{ {
} }
@ -143,8 +143,8 @@ void register_callbacks(ToxAv *av, void *data)
toxav_register_callstate_callback(av, callback_requ_timeout, av_OnRequestTimeout, data); toxav_register_callstate_callback(av, callback_requ_timeout, av_OnRequestTimeout, data);
toxav_register_audio_recv_callback(av, callback_audio); toxav_register_audio_recv_callback(av, callback_audio, NULL);
toxav_register_video_recv_callback(av, callback_video); toxav_register_video_recv_callback(av, callback_video, NULL);
} }
/*************************************************************************************************/ /*************************************************************************************************/

View File

@ -104,8 +104,11 @@ struct _ToxAv {
MSISession *msi_session; /** Main msi session */ MSISession *msi_session; /** Main msi session */
CallSpecific *calls; /** Per-call params */ CallSpecific *calls; /** Per-call params */
void (*audio_callback)(ToxAv *, int32_t, int16_t *, int); void (*audio_callback)(ToxAv *, int32_t, int16_t *, int, void*);
void (*video_callback)(ToxAv *, int32_t, vpx_image_t *); void (*video_callback)(ToxAv *, int32_t, vpx_image_t *, void*);
void *audio_callback_userdata;
void *video_callback_userdata;
uint32_t max_calls; uint32_t max_calls;
@ -269,9 +272,10 @@ void toxav_register_callstate_callback ( ToxAv *av, ToxAVCallback callback, ToxA
* @param callback The callback * @param callback The callback
* @return void * @return void
*/ */
void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int)) void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int, void*), void* user_data)
{ {
av->audio_callback = callback; av->audio_callback = callback;
av->audio_callback_userdata = user_data;
} }
/** /**
@ -280,9 +284,10 @@ void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, in
* @param callback The callback * @param callback The callback
* @return void * @return void
*/ */
void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *)) void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *, void*), void* user_data)
{ {
av->video_callback = callback; av->video_callback = callback;
av->video_callback_userdata = user_data;
} }
/** /**
@ -933,7 +938,7 @@ static void decode_video(ToxAv *av, DECODE_PACKET *p)
img = vpx_codec_get_frame(&call->cs->v_decoder, &iter); img = vpx_codec_get_frame(&call->cs->v_decoder, &iter);
if (img && av->video_callback) { if (img && av->video_callback) {
av->video_callback(av, p->call_index, img); av->video_callback(av, p->call_index, img, av->video_callback_userdata);
} else { } else {
LOGGER_WARNING("Video packet dropped due to missing callback or no image!"); LOGGER_WARNING("Video packet dropped due to missing callback or no image!");
} }
@ -961,7 +966,7 @@ static void decode_audio(ToxAv *av, DECODE_PACKET *p)
} }
if ( av->audio_callback ) if ( av->audio_callback )
av->audio_callback(av, call_index, dest, dec_size); av->audio_callback(av, call_index, dest, dec_size, av->audio_callback_userdata);
else else
LOGGER_WARNING("Audio packet dropped due to missing callback!"); LOGGER_WARNING("Audio packet dropped due to missing callback!");
} }

View File

@ -173,7 +173,7 @@ void toxav_register_callstate_callback (ToxAv *av, ToxAVCallback callback, ToxAv
* @param callback The callback * @param callback The callback
* @return void * @return void
*/ */
void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int)); void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int, void*), void* user_data);
/** /**
* @brief Register callback for recieving video data * @brief Register callback for recieving video data
@ -182,7 +182,7 @@ void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, in
* @param callback The callback * @param callback The callback
* @return void * @return void
*/ */
void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *)); void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *, void*), void* user_data);
/** /**
* @brief Call user. Use its friend_id. * @brief Call user. Use its friend_id.