summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2015-06-27 19:20:52 +0200
committermannol <eniz_vukovic@hotmail.com>2015-06-27 19:20:52 +0200
commit13148d7d7c7fc6ea6ef7e592dfd8b0bf3cfd1244 (patch)
treeca5eeba5db9996157136a329225d09a3553a6283
parent2ecb71bb1e02a3542700ba9e8bcc372e203b8437 (diff)
Added support for old groupchats
-rw-r--r--toxav/Makefile.inc4
-rw-r--r--toxav/toxav.h8
-rw-r--r--toxav/toxav_old.c81
-rw-r--r--toxav/toxav_old.h66
4 files changed, 156 insertions, 3 deletions
diff --git a/toxav/Makefile.inc b/toxav/Makefile.inc
index 3907951e..79275c9b 100644
--- a/toxav/Makefile.inc
+++ b/toxav/Makefile.inc
@@ -15,7 +15,9 @@ libtoxav_la_SOURCES = ../toxav/rtp.h \
15 ../toxav/video.h \ 15 ../toxav/video.h \
16 ../toxav/video.c \ 16 ../toxav/video.c \
17 ../toxav/toxav.h \ 17 ../toxav/toxav.h \
18 ../toxav/toxav.c 18 ../toxav/toxav.c \
19 ../toxav/toxav_old.h \
20 ../toxav/toxav_old.c
19 21
20 22
21libtoxav_la_CFLAGS = -I../toxcore \ 23libtoxav_la_CFLAGS = -I../toxcore \
diff --git a/toxav/toxav.h b/toxav/toxav.h
index 8362edb3..0a25fc96 100644
--- a/toxav/toxav.h
+++ b/toxav/toxav.h
@@ -237,7 +237,8 @@ typedef enum TOXAV_ERR_CALL {
237 * 237 *
238 * It is the client's responsibility to stop ringing after a certain timeout, 238 * It is the client's responsibility to stop ringing after a certain timeout,
239 * if such behaviour is desired. If the client does not stop ringing, the 239 * if such behaviour is desired. If the client does not stop ringing, the
240 * library will not stop until the friend is disconnected. 240 * library will not stop until the friend is disconnected. Audio and video
241 * receiving are both enabled by default.
241 * 242 *
242 * @param friend_number The friend number of the friend that should be called. 243 * @param friend_number The friend number of the friend that should be called.
243 * @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable 244 * @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable
@@ -288,7 +289,8 @@ typedef enum TOXAV_ERR_ANSWER {
288 * Accept an incoming call. 289 * Accept an incoming call.
289 * 290 *
290 * If answering fails for any reason, the call will still be pending and it is 291 * If answering fails for any reason, the call will still be pending and it is
291 * possible to try and answer it later. 292 * possible to try and answer it later. Audio and video receiving are both
293 * enabled by default.
292 * 294 *
293 * @param friend_number The friend number of the friend that is calling. 295 * @param friend_number The friend number of the friend that is calling.
294 * @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable 296 * @param audio_bit_rate Audio bit rate in Kb/sec. Set this to 0 to disable
@@ -637,6 +639,8 @@ typedef void toxav_video_receive_frame_cb(ToxAV *toxAV, uint32_t friend_number,
637 */ 639 */
638void toxav_callback_video_receive_frame(ToxAV *toxAV, toxav_video_receive_frame_cb *callback, void *user_data); 640void toxav_callback_video_receive_frame(ToxAV *toxAV, toxav_video_receive_frame_cb *callback, void *user_data);
639 641
642#include "toxav_old.h"
643
640#ifdef __cplusplus 644#ifdef __cplusplus
641} 645}
642#endif 646#endif
diff --git a/toxav/toxav_old.c b/toxav/toxav_old.c
new file mode 100644
index 00000000..1f553fc3
--- /dev/null
+++ b/toxav/toxav_old.c
@@ -0,0 +1,81 @@
1/* toxav_old.h
2 *
3 * Copyright (C) 2013-2015 Tox project All Rights Reserved.
4 *
5 * This file is part of Tox.
6 *
7 * Tox is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Tox is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21/**
22 * This file contains the group chats code for the backwards compatibility.
23 */
24
25#include "toxav_old.h"
26#include "group.h"
27
28/* Create a new toxav group.
29 *
30 * return group number on success.
31 * return -1 on failure.
32 *
33 * Audio data callback format:
34 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
35 *
36 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
37 */
38int toxav_add_av_groupchat(struct Tox *tox, void (*audio_callback)(void *, int, int, const int16_t *, unsigned int,
39 uint8_t, unsigned int, void *), void *userdata)
40{
41 Messenger *m = (Messenger *)tox;
42 return add_av_groupchat(m->group_chat_object, audio_callback, userdata);
43}
44
45/* Join a AV group (you need to have been invited first.)
46 *
47 * returns group number on success
48 * returns -1 on failure.
49 *
50 * Audio data callback format (same as the one for toxav_add_av_groupchat()):
51 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
52 *
53 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
54 */
55int toxav_join_av_groupchat(struct Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length,
56 void (*audio_callback)(void *, int, int, const int16_t *, unsigned int, uint8_t, unsigned int, void *),
57 void *userdata)
58{
59 Messenger *m = (Messenger *)tox;
60 return join_av_groupchat(m->group_chat_object, friendnumber, data, length, audio_callback, userdata);
61}
62
63/* Send audio to the group chat.
64 *
65 * return 0 on success.
66 * return -1 on failure.
67 *
68 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
69 *
70 * Valid number of samples are ((sample rate) * (audio length (Valid ones are: 2.5, 5, 10, 20, 40 or 60 ms)) / 1000)
71 * Valid number of channels are 1 or 2.
72 * Valid sample rates are 8000, 12000, 16000, 24000, or 48000.
73 *
74 * Recommended values are: samples = 960, channels = 1, sample_rate = 48000
75 */
76int toxav_group_send_audio(struct Tox *tox, int groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
77 unsigned int sample_rate)
78{
79 Messenger *m = (Messenger *)tox;
80 return group_send_audio(m->group_chat_object, groupnumber, pcm, samples, channels, sample_rate);
81} \ No newline at end of file
diff --git a/toxav/toxav_old.h b/toxav/toxav_old.h
new file mode 100644
index 00000000..89fe3014
--- /dev/null
+++ b/toxav/toxav_old.h
@@ -0,0 +1,66 @@
1/* toxav_old.h
2 *
3 * Copyright (C) 2013-2015 Tox project All Rights Reserved.
4 *
5 * This file is part of Tox.
6 *
7 * Tox is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * Tox is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21/**
22 * This file contains the group chats code for the backwards compatibility.
23 */
24#include "../toxcore/tox.h"
25
26/* Create a new toxav group.
27 *
28 * return group number on success.
29 * return -1 on failure.
30 *
31 * Audio data callback format:
32 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
33 *
34 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
35 */
36int toxav_add_av_groupchat(struct Tox *tox, void (*audio_callback)(void*, int, int, const int16_t *, unsigned int, uint8_t,
37 unsigned int, void *), void *userdata);
38
39/* Join a AV group (you need to have been invited first.)
40 *
41 * returns group number on success
42 * returns -1 on failure.
43 *
44 * Audio data callback format (same as the one for toxav_add_av_groupchat()):
45 * audio_callback(Tox *tox, int groupnumber, int peernumber, const int16_t *pcm, unsigned int samples, uint8_t channels, unsigned int sample_rate, void *userdata)
46 *
47 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
48 */
49int toxav_join_av_groupchat(struct Tox *tox, int32_t friendnumber, const uint8_t *data, uint16_t length,
50 void (*audio_callback)(void*, int, int, const int16_t *, unsigned int, uint8_t, unsigned int, void *), void *userdata);
51
52/* Send audio to the group chat.
53 *
54 * return 0 on success.
55 * return -1 on failure.
56 *
57 * Note that total size of pcm in bytes is equal to (samples * channels * sizeof(int16_t)).
58 *
59 * Valid number of samples are ((sample rate) * (audio length (Valid ones are: 2.5, 5, 10, 20, 40 or 60 ms)) / 1000)
60 * Valid number of channels are 1 or 2.
61 * Valid sample rates are 8000, 12000, 16000, 24000, or 48000.
62 *
63 * Recommended values are: samples = 960, channels = 1, sample_rate = 48000
64 */
65int toxav_group_send_audio(struct Tox *tox, int groupnumber, const int16_t *pcm, unsigned int samples, uint8_t channels,
66 unsigned int sample_rate); \ No newline at end of file