diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-08-02 01:09:33 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-08-02 01:09:33 +0200 |
commit | 6c1ac97da9dd9e64cf53cb9137944f0d595698fc (patch) | |
tree | 27c57e4cff70ebe7787297db822bf337de59a3a9 | |
parent | 77df39863e8e2103bda195ec76b2a255baf1acb4 (diff) |
Added userdata pointer to audio/video callbacks
-rw-r--r-- | auto_tests/toxav_basic_test.c | 8 | ||||
-rw-r--r-- | auto_tests/toxav_many_test.c | 8 | ||||
-rw-r--r-- | toxav/toxav.c | 17 | ||||
-rw-r--r-- | toxav/toxav.h | 4 |
4 files changed, 21 insertions, 16 deletions
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index 7edb96bc..6db9f8fa 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -163,11 +163,11 @@ void callback_requ_timeout ( void *av, int32_t call_index, void *_arg ) | |||
163 | cast->Alice.status = TimedOut; | 163 | cast->Alice.status = TimedOut; |
164 | } | 164 | } |
165 | 165 | ||
166 | static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length) | 166 | static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length, void* userdata) |
167 | { | 167 | { |
168 | } | 168 | } |
169 | 169 | ||
170 | static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img) | 170 | static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img, void* userdata) |
171 | { | 171 | { |
172 | } | 172 | } |
173 | 173 | ||
@@ -187,8 +187,8 @@ void register_callbacks(ToxAv *av, void *data) | |||
187 | toxav_register_callstate_callback(av, callback_call_type_change, av_OnMediaChange, data); | 187 | toxav_register_callstate_callback(av, callback_call_type_change, av_OnMediaChange, data); |
188 | 188 | ||
189 | 189 | ||
190 | toxav_register_audio_recv_callback(av, callback_audio); | 190 | toxav_register_audio_recv_callback(av, callback_audio, NULL); |
191 | toxav_register_video_recv_callback(av, callback_video); | 191 | toxav_register_video_recv_callback(av, callback_video, NULL); |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 299e701d..d98824be 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -120,11 +120,11 @@ void callback_requ_timeout ( void *av, int32_t call_index, void *_arg ) | |||
120 | //ck_assert_msg(0, "No answer!"); | 120 | //ck_assert_msg(0, "No answer!"); |
121 | } | 121 | } |
122 | 122 | ||
123 | static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length) | 123 | static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length, void* userdata) |
124 | { | 124 | { |
125 | } | 125 | } |
126 | 126 | ||
127 | static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img) | 127 | static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img, void* userdata) |
128 | { | 128 | { |
129 | } | 129 | } |
130 | 130 | ||
@@ -143,8 +143,8 @@ void register_callbacks(ToxAv *av, void *data) | |||
143 | toxav_register_callstate_callback(av, callback_requ_timeout, av_OnRequestTimeout, data); | 143 | toxav_register_callstate_callback(av, callback_requ_timeout, av_OnRequestTimeout, data); |
144 | 144 | ||
145 | 145 | ||
146 | toxav_register_audio_recv_callback(av, callback_audio); | 146 | toxav_register_audio_recv_callback(av, callback_audio, NULL); |
147 | toxav_register_video_recv_callback(av, callback_video); | 147 | toxav_register_video_recv_callback(av, callback_video, NULL); |
148 | } | 148 | } |
149 | /*************************************************************************************************/ | 149 | /*************************************************************************************************/ |
150 | 150 | ||
diff --git a/toxav/toxav.c b/toxav/toxav.c index 3a95e445..b215b3e9 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -104,8 +104,11 @@ struct _ToxAv { | |||
104 | MSISession *msi_session; /** Main msi session */ | 104 | MSISession *msi_session; /** Main msi session */ |
105 | CallSpecific *calls; /** Per-call params */ | 105 | CallSpecific *calls; /** Per-call params */ |
106 | 106 | ||
107 | void (*audio_callback)(ToxAv *, int32_t, int16_t *, int); | 107 | void (*audio_callback)(ToxAv *, int32_t, int16_t *, int, void*); |
108 | void (*video_callback)(ToxAv *, int32_t, vpx_image_t *); | 108 | void (*video_callback)(ToxAv *, int32_t, vpx_image_t *, void*); |
109 | |||
110 | void *audio_callback_userdata; | ||
111 | void *video_callback_userdata; | ||
109 | 112 | ||
110 | uint32_t max_calls; | 113 | uint32_t max_calls; |
111 | 114 | ||
@@ -269,9 +272,10 @@ void toxav_register_callstate_callback ( ToxAv *av, ToxAVCallback callback, ToxA | |||
269 | * @param callback The callback | 272 | * @param callback The callback |
270 | * @return void | 273 | * @return void |
271 | */ | 274 | */ |
272 | void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int)) | 275 | void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int, void*), void* user_data) |
273 | { | 276 | { |
274 | av->audio_callback = callback; | 277 | av->audio_callback = callback; |
278 | av->audio_callback_userdata = user_data; | ||
275 | } | 279 | } |
276 | 280 | ||
277 | /** | 281 | /** |
@@ -280,9 +284,10 @@ void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, in | |||
280 | * @param callback The callback | 284 | * @param callback The callback |
281 | * @return void | 285 | * @return void |
282 | */ | 286 | */ |
283 | void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *)) | 287 | void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *, void*), void* user_data) |
284 | { | 288 | { |
285 | av->video_callback = callback; | 289 | av->video_callback = callback; |
290 | av->video_callback_userdata = user_data; | ||
286 | } | 291 | } |
287 | 292 | ||
288 | /** | 293 | /** |
@@ -933,7 +938,7 @@ static void decode_video(ToxAv *av, DECODE_PACKET *p) | |||
933 | img = vpx_codec_get_frame(&call->cs->v_decoder, &iter); | 938 | img = vpx_codec_get_frame(&call->cs->v_decoder, &iter); |
934 | 939 | ||
935 | if (img && av->video_callback) { | 940 | if (img && av->video_callback) { |
936 | av->video_callback(av, p->call_index, img); | 941 | av->video_callback(av, p->call_index, img, av->video_callback_userdata); |
937 | } else { | 942 | } else { |
938 | LOGGER_WARNING("Video packet dropped due to missing callback or no image!"); | 943 | LOGGER_WARNING("Video packet dropped due to missing callback or no image!"); |
939 | } | 944 | } |
@@ -961,7 +966,7 @@ static void decode_audio(ToxAv *av, DECODE_PACKET *p) | |||
961 | } | 966 | } |
962 | 967 | ||
963 | if ( av->audio_callback ) | 968 | if ( av->audio_callback ) |
964 | av->audio_callback(av, call_index, dest, dec_size); | 969 | av->audio_callback(av, call_index, dest, dec_size, av->audio_callback_userdata); |
965 | else | 970 | else |
966 | LOGGER_WARNING("Audio packet dropped due to missing callback!"); | 971 | LOGGER_WARNING("Audio packet dropped due to missing callback!"); |
967 | } | 972 | } |
diff --git a/toxav/toxav.h b/toxav/toxav.h index 4dddc9b5..0dcd2836 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h | |||
@@ -173,7 +173,7 @@ void toxav_register_callstate_callback (ToxAv *av, ToxAVCallback callback, ToxAv | |||
173 | * @param callback The callback | 173 | * @param callback The callback |
174 | * @return void | 174 | * @return void |
175 | */ | 175 | */ |
176 | void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int)); | 176 | void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, int16_t *, int, void*), void* user_data); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * @brief Register callback for recieving video data | 179 | * @brief Register callback for recieving video data |
@@ -182,7 +182,7 @@ void toxav_register_audio_recv_callback (ToxAv *av, void (*callback)(ToxAv *, in | |||
182 | * @param callback The callback | 182 | * @param callback The callback |
183 | * @return void | 183 | * @return void |
184 | */ | 184 | */ |
185 | void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *)); | 185 | void toxav_register_video_recv_callback (ToxAv *av, void (*callback)(ToxAv *, int32_t, vpx_image_t *, void*), void* user_data); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | * @brief Call user. Use its friend_id. | 188 | * @brief Call user. Use its friend_id. |