ffi-tox 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/ProjectTox-Core/AUTHORS +0 -0
  3. data/ProjectTox-Core/ChangeLog +0 -0
  4. data/ProjectTox-Core/INSTALL +370 -0
  5. data/ProjectTox-Core/INSTALL.md +455 -56
  6. data/ProjectTox-Core/Makefile.am +35 -0
  7. data/ProjectTox-Core/NEWS +0 -0
  8. data/ProjectTox-Core/README +43 -0
  9. data/ProjectTox-Core/README.md +34 -44
  10. data/ProjectTox-Core/auto_tests/Makefile.inc +110 -0
  11. data/ProjectTox-Core/auto_tests/TCP_test.c +519 -0
  12. data/ProjectTox-Core/auto_tests/assoc_test.c +160 -0
  13. data/ProjectTox-Core/auto_tests/crypto_test.c +302 -0
  14. data/ProjectTox-Core/auto_tests/dht_test.c +362 -0
  15. data/ProjectTox-Core/auto_tests/encryptsave_test.c +104 -0
  16. data/ProjectTox-Core/auto_tests/friends_test.c +238 -0
  17. data/ProjectTox-Core/auto_tests/helpers.h +15 -0
  18. data/ProjectTox-Core/auto_tests/messenger_test.c +365 -0
  19. data/ProjectTox-Core/auto_tests/network_test.c +171 -0
  20. data/ProjectTox-Core/auto_tests/onion_test.c +363 -0
  21. data/ProjectTox-Core/auto_tests/skeleton_test.c +49 -0
  22. data/ProjectTox-Core/auto_tests/tox_test.c +454 -0
  23. data/ProjectTox-Core/auto_tests/toxav_basic_test.c +597 -0
  24. data/ProjectTox-Core/auto_tests/toxav_many_test.c +402 -0
  25. data/ProjectTox-Core/autogen.sh +6 -0
  26. data/ProjectTox-Core/build/Makefile.am +14 -0
  27. data/ProjectTox-Core/configure.ac +694 -0
  28. data/ProjectTox-Core/dist-build/android-arm.sh +3 -0
  29. data/ProjectTox-Core/dist-build/android-armv7.sh +3 -0
  30. data/ProjectTox-Core/dist-build/android-build.sh +59 -0
  31. data/ProjectTox-Core/dist-build/android-mips.sh +3 -0
  32. data/ProjectTox-Core/dist-build/android-x86.sh +3 -0
  33. data/ProjectTox-Core/docs/Group-Chats.md +71 -0
  34. data/ProjectTox-Core/docs/Hardening.txt +60 -0
  35. data/ProjectTox-Core/docs/Hardening_docs.txt +30 -0
  36. data/ProjectTox-Core/docs/Prevent_Tracking.txt +160 -0
  37. data/ProjectTox-Core/docs/TCP_Network.txt +154 -0
  38. data/ProjectTox-Core/docs/TODO +62 -0
  39. data/ProjectTox-Core/docs/Tox_middle_level_network_protocol.txt +120 -0
  40. data/ProjectTox-Core/docs/av_api.md +194 -0
  41. data/ProjectTox-Core/libtoxav.pc.in +11 -0
  42. data/ProjectTox-Core/libtoxcore.pc.in +11 -0
  43. data/ProjectTox-Core/m4/ax_have_epoll.m4 +104 -0
  44. data/ProjectTox-Core/m4/ax_pthread.m4 +317 -0
  45. data/ProjectTox-Core/m4/pkg.m4 +199 -0
  46. data/ProjectTox-Core/other/DHT_bootstrap.c +121 -58
  47. data/ProjectTox-Core/other/DHTnodes +3 -0
  48. data/ProjectTox-Core/other/Makefile.inc +20 -0
  49. data/ProjectTox-Core/other/bootstrap_node_packets.c +65 -0
  50. data/ProjectTox-Core/other/tox.png +0 -0
  51. data/ProjectTox-Core/testing/DHT_test.c +170 -98
  52. data/ProjectTox-Core/testing/Makefile.inc +112 -0
  53. data/ProjectTox-Core/testing/Messenger_test.c +133 -69
  54. data/ProjectTox-Core/testing/dns3_test.c +115 -0
  55. data/ProjectTox-Core/testing/misc_tools.c +59 -13
  56. data/ProjectTox-Core/testing/nTox.c +1127 -264
  57. data/ProjectTox-Core/testing/nTox.h +10 -19
  58. data/ProjectTox-Core/testing/tox_shell.c +159 -0
  59. data/ProjectTox-Core/testing/tox_sync.c +299 -0
  60. data/ProjectTox-Core/tools/README +11 -0
  61. data/ProjectTox-Core/tools/astylerc +11 -0
  62. data/ProjectTox-Core/tools/pre-commit +17 -0
  63. data/ProjectTox-Core/toxav/Makefile.inc +36 -0
  64. data/ProjectTox-Core/toxav/codec.c +357 -0
  65. data/ProjectTox-Core/toxav/codec.h +116 -0
  66. data/ProjectTox-Core/toxav/msi.c +1949 -0
  67. data/ProjectTox-Core/toxav/msi.h +267 -0
  68. data/ProjectTox-Core/toxav/rtp.c +600 -0
  69. data/ProjectTox-Core/toxav/rtp.h +196 -0
  70. data/ProjectTox-Core/toxav/toxav.c +1148 -0
  71. data/ProjectTox-Core/toxav/toxav.h +389 -0
  72. data/ProjectTox-Core/toxcore/DHT.c +2521 -0
  73. data/ProjectTox-Core/toxcore/DHT.h +412 -0
  74. data/ProjectTox-Core/toxcore/LAN_discovery.c +322 -0
  75. data/ProjectTox-Core/{core → toxcore}/LAN_discovery.h +17 -12
  76. data/ProjectTox-Core/toxcore/Makefile.inc +67 -0
  77. data/ProjectTox-Core/toxcore/Messenger.c +3006 -0
  78. data/ProjectTox-Core/toxcore/Messenger.h +818 -0
  79. data/ProjectTox-Core/toxcore/TCP_client.c +858 -0
  80. data/ProjectTox-Core/toxcore/TCP_client.h +156 -0
  81. data/ProjectTox-Core/toxcore/TCP_server.c +1332 -0
  82. data/ProjectTox-Core/toxcore/TCP_server.h +181 -0
  83. data/ProjectTox-Core/toxcore/assoc.c +1033 -0
  84. data/ProjectTox-Core/toxcore/assoc.h +104 -0
  85. data/ProjectTox-Core/toxcore/crypto_core.c +278 -0
  86. data/ProjectTox-Core/toxcore/crypto_core.h +151 -0
  87. data/ProjectTox-Core/toxcore/friend_requests.c +175 -0
  88. data/ProjectTox-Core/toxcore/friend_requests.h +83 -0
  89. data/ProjectTox-Core/toxcore/group_chats.c +837 -0
  90. data/ProjectTox-Core/toxcore/group_chats.h +199 -0
  91. data/ProjectTox-Core/toxcore/list.c +256 -0
  92. data/ProjectTox-Core/toxcore/list.h +85 -0
  93. data/ProjectTox-Core/toxcore/logger.c +153 -0
  94. data/ProjectTox-Core/toxcore/logger.h +84 -0
  95. data/ProjectTox-Core/toxcore/misc_tools.h +70 -0
  96. data/ProjectTox-Core/toxcore/net_crypto.c +2753 -0
  97. data/ProjectTox-Core/toxcore/net_crypto.h +410 -0
  98. data/ProjectTox-Core/toxcore/network.c +979 -0
  99. data/ProjectTox-Core/toxcore/network.h +367 -0
  100. data/ProjectTox-Core/toxcore/onion.c +540 -0
  101. data/ProjectTox-Core/toxcore/onion.h +150 -0
  102. data/ProjectTox-Core/toxcore/onion_announce.c +433 -0
  103. data/ProjectTox-Core/toxcore/onion_announce.h +139 -0
  104. data/ProjectTox-Core/toxcore/onion_client.c +1347 -0
  105. data/ProjectTox-Core/toxcore/onion_client.h +253 -0
  106. data/ProjectTox-Core/toxcore/ping.c +346 -0
  107. data/ProjectTox-Core/toxcore/ping.h +47 -0
  108. data/ProjectTox-Core/toxcore/ping_array.c +162 -0
  109. data/ProjectTox-Core/toxcore/ping_array.h +75 -0
  110. data/ProjectTox-Core/toxcore/tox.c +940 -0
  111. data/ProjectTox-Core/toxcore/tox.h +734 -0
  112. data/ProjectTox-Core/toxcore/util.c +193 -0
  113. data/ProjectTox-Core/toxcore/util.h +63 -0
  114. data/ProjectTox-Core/toxdns/Makefile.inc +29 -0
  115. data/ProjectTox-Core/toxdns/toxdns.c +238 -0
  116. data/ProjectTox-Core/toxdns/toxdns.h +88 -0
  117. data/ProjectTox-Core/toxencryptsave/Makefile.inc +45 -0
  118. data/ProjectTox-Core/toxencryptsave/toxencryptsave.c +179 -0
  119. data/ProjectTox-Core/toxencryptsave/toxencryptsave.h +74 -0
  120. data/interfaces/libtox.i +2 -6
  121. data/lib/ffi-tox/libtox.rb +406 -28
  122. metadata +124 -46
  123. data/ProjectTox-Core/CMakeLists.txt +0 -50
  124. data/ProjectTox-Core/cmake/FindLIBCONFIG.cmake +0 -15
  125. data/ProjectTox-Core/cmake/FindNaCl.cmake +0 -17
  126. data/ProjectTox-Core/cmake/FindSODIUM.cmake +0 -15
  127. data/ProjectTox-Core/core/CMakeLists.txt +0 -19
  128. data/ProjectTox-Core/core/DHT.c +0 -1104
  129. data/ProjectTox-Core/core/DHT.h +0 -111
  130. data/ProjectTox-Core/core/LAN_discovery.c +0 -79
  131. data/ProjectTox-Core/core/Lossless_UDP.c +0 -755
  132. data/ProjectTox-Core/core/Lossless_UDP.h +0 -106
  133. data/ProjectTox-Core/core/Messenger.c +0 -596
  134. data/ProjectTox-Core/core/Messenger.h +0 -165
  135. data/ProjectTox-Core/core/friend_requests.c +0 -131
  136. data/ProjectTox-Core/core/friend_requests.h +0 -51
  137. data/ProjectTox-Core/core/net_crypto.c +0 -575
  138. data/ProjectTox-Core/core/net_crypto.h +0 -134
  139. data/ProjectTox-Core/core/network.c +0 -205
  140. data/ProjectTox-Core/core/network.h +0 -134
  141. data/ProjectTox-Core/docs/commands.md +0 -25
  142. data/ProjectTox-Core/docs/start_guide.de.md +0 -40
  143. data/ProjectTox-Core/docs/start_guide.md +0 -38
  144. data/ProjectTox-Core/other/CMakeLists.txt +0 -9
  145. data/ProjectTox-Core/testing/CMakeLists.txt +0 -18
  146. data/ProjectTox-Core/testing/DHT_cryptosendfiletest.c +0 -228
  147. data/ProjectTox-Core/testing/DHT_sendfiletest.c +0 -176
  148. data/ProjectTox-Core/testing/Lossless_UDP_testclient.c +0 -214
  149. data/ProjectTox-Core/testing/Lossless_UDP_testserver.c +0 -201
  150. data/ProjectTox-Core/testing/misc_tools.h +0 -29
  151. data/ProjectTox-Core/testing/nTox_win32.c +0 -387
  152. data/ProjectTox-Core/testing/nTox_win32.h +0 -40
  153. data/ProjectTox-Core/testing/rect.py +0 -45
@@ -0,0 +1,62 @@
1
+ TODO list.
2
+
3
+ [IN PROGRESS] Add what is left to do to the TODO list.
4
+
5
+ Networking:
6
+ [NOT STARTED] UPnP port forwarding.
7
+ [NOT STARTED] NAT-PMP port forwarding.
8
+
9
+ DHT:
10
+ [ALMOST DONE] Metadata collection prevention. (docs/Prevent_Tracking.txt)
11
+ [IN PROGRESS] Hardening against attacks.
12
+ [IN PROGRESS] Optimizing the code.
13
+
14
+ Lossless UDP:
15
+ [DONE] Increase data send/receive rates.
16
+
17
+ [IN PROGRESS] Massive IRC like group chats (text only)
18
+ [DONE] Networking base.
19
+ [NOT STARTED] Syncing chat state between clients (nicknames, list of who is in chat, etc...)
20
+ [NOT STARTED] Make clients sign their messages so that peers can't modify them.
21
+
22
+ [IN PROGRESS] Audio/Video
23
+ [DONE] encoding/streaming/decoding
24
+ [DONE] Call initiation
25
+ [DONE] Encryption
26
+ [IN PROGRESS] Auditing.
27
+ [NEEDS TESTING] Video packet splitting.
28
+ [IN PROGRESS] Prevent audio skew (seems to be easily solvable client side.)
29
+ [IN PROGRESS] Group chats.
30
+
31
+ Friend_requests.c:
32
+ [NOT STARTED] What happens when a friend request is received needs to be changed.
33
+ [NOT STARTED] Add multiple nospam functionality.
34
+
35
+ [DONE] File transfers
36
+ [NOT STARTED] Offline messaging
37
+ [NOT STARTED] Friends list syncing
38
+ [IN PROGRESS] IPV6 support
39
+ [DONE] Networking
40
+ [DONE] DHT + Messenger
41
+ [NOT STARTED] Group chats (They work with IPv6 but some things need to be tested.)
42
+
43
+
44
+ [IN PROGRESS] Make toxcore thread safe.
45
+
46
+ [NOT STARTED] Make the core save/datafile portable across client versions/different processor architectures.
47
+
48
+ [MOSTLY DONE] A way for people to connect to people on Tox if they are behind a bad NAT that
49
+ blocks UDP (or is just unpunchable) (docs/TCP_Network.txt)
50
+
51
+ [NEEDS TESTING] Make the save made with tox_save_encrypted(...) harder to brute force.
52
+ See: (https://github.com/jencka/ProjectTox-libtoxdata)
53
+
54
+ [IN PROGRESS] GUI (no official one chosen yet, a list of promising ones follows)
55
+ https://github.com/notsecure/uTox
56
+ https://github.com/naxuroqa/Venom
57
+ https://github.com/Impyy/Toxy
58
+ https://github.com/lehitoskin/blight
59
+ https://github.com/nurupo/ProjectTox-Qt-GUI
60
+ https://github.com/Astonex/Antox
61
+
62
+ [NOT STARTED] Security audit from professionals
@@ -0,0 +1,120 @@
1
+ The TCP client and TCP server part are in a state that can be considered
2
+ feature complete. Why doesn't Tox support TCP yet even if those parts are
3
+ complete?
4
+
5
+ The answer is that a way to ensure a smooth switchover between the TCP and UDP
6
+ needs to be added. If Tox first connects to the other user using TCP but then
7
+ due to pure chance manages to connect using the faster direct UDP connection
8
+ Tox must switch seamlessly from the TCP to the UDP connection without there
9
+ being any data loss or the other user going offline and then back online. The
10
+ transition must be seamless whatever both connected users are doing be it
11
+ transferring files or simply chatting together.
12
+
13
+ Possible evil/bad or simply TCP relays going offline must not impact the
14
+ connection between both clients.
15
+
16
+ Typically Tox will use more than one TCP relay to connect to other peers for
17
+ maximum connection stability which means there must be a way for Tox to take
18
+ advantage of multiple relays in a way that the user will never be aware if one
19
+ of them goes offline/tries to slow down the connection/decides to corrupt
20
+ packets/etc..
21
+
22
+ To accomplish this Tox needs something between the low level protocol (TCP) and
23
+ high level Tox messaging protocol hence the name middle level.
24
+
25
+ The plan is to move some functionality from lossless_UDP to a higher level:
26
+ more specifically the functionality for detecting which packets a peer is
27
+ missing and the ability to request and send them again. lossless UDP uses plain
28
+ text packets to request missing packets from the other peer while Tox is
29
+ currently designed to kill the connection if any packet tampering is detected.
30
+ This works very well when connecting directly with someone because if the
31
+ attacker can modify packets it means he can kill your connection anyways. With
32
+ TCP relays however that is not the case as such the packets used to request
33
+ missing packets must be encrypted. If it is detected that a packet has been
34
+ tampered, the connection must stay intact while the evil relay must be
35
+ disconnected from and replaced with a good relay, the behavior must be the same
36
+ as if the relay had just suddenly gone online. Of course something to protect
37
+ from evil "friends" framing relays must also be implemented.
38
+
39
+ Detailed implementation details:
40
+
41
+ cookie request packet:
42
+ [uint8_t 24][Senders DHT Public key (32 bytes)][Random nonce (24
43
+ bytes)][Encrypted message containing: [Senders real public key (32
44
+ bytes)][padding (32 bytes)][uint64_t number (must be sent
45
+ back untouched in cookie response)]]
46
+ Encrypted message is encrypted with sender DHT private key, receivers DHT
47
+ public key and the nonce.
48
+
49
+ cookie response packet:
50
+ [uint8_t 25][Random nonce (24 bytes)][Encrypted message containing:
51
+ [Cookie][uint64_t number (that was sent in the request)]]
52
+ Encrypted message is encrypted with sender DHT private key, receivers DHT
53
+ public key and the nonce.
54
+
55
+ The Cookie should be basically:
56
+ [nonce][encrypted data:[uint64_t time][Senders real public key (32
57
+ bytes)][Senders dht public key (32 bytes)]]
58
+
59
+ Handshake packet:
60
+ [uint8_t 26][Cookie][nonce][Encrypted message containing: [random 24 bytes base
61
+ nonce][session public key of the peer (32 bytes)][sha512 hash of the entire
62
+ Cookie sitting outside the encrypted part][Other Cookie (used by the other to
63
+ respond to the handshake packet)]]
64
+
65
+ The handshake packet is encrypted using the real private key of the sender, the
66
+ real public key of the receiver and the nonce.
67
+
68
+
69
+ Alice wants to connect to bob.
70
+
71
+ Alice sends a cookie request packet to bob and gets a cookie response back.
72
+
73
+ Alice then generates a nonce and a temporary public/private keypair.
74
+
75
+ Alice then takes that nonce and just generated private key, the obtained
76
+ cookie, creates a new cookie and puts them in a handshake packet which she
77
+ sends to bob.
78
+
79
+ Bob gets the handshake packet, accepts the connection request, then generates a
80
+ nonce and a temporary public/private keypair and sends a handshake packet back
81
+ with this just generated information and with the cookie field being the Other
82
+ Cookie contained in the received handshake.
83
+
84
+ Both then use these temporary keys to generate the session key with which every
85
+ data packet sent and received will be encrypted and decrypted. The nonce sent
86
+ in the handshake will be used to encrypt the first data packet sent, the nonce
87
+ + 1 the second, the nonce + 2 the third and so on.
88
+
89
+ Data packets:
90
+
91
+ [uint8_t 27][uint16_t (in network byte order) the last 2 bytes of the nonce
92
+ used to encrypt this][encrypted with the session key and a nonce:[plain data]]
93
+
94
+ Plain data in the data packets:
95
+
96
+ [uint32_t our recvbuffers buffer_start, (highest packet number handled +
97
+ 1)][uint32_t packet number if lossless, our sendbuffer buffer_end if
98
+ lossy][data]
99
+
100
+ data ids:
101
+ 0: padding (skipped until we hit a non zero (data id) byte)
102
+ 1: packet request packet (lossy packet)
103
+ 2: connection kill packet (lossy packet) (tells the other that the connection is over)
104
+ ...
105
+ 16+: reserved for Messenger usage (lossless packets).
106
+ 192+: reserved for Messenger usage (lossy packets).
107
+ 255: reserved for Messenger usage (lossless packet)
108
+
109
+ packet request packet: [uint8_t (1)][uint8_t num][uint8_t num][uint8_t
110
+ num]...[uint8_t num]
111
+
112
+ the list of nums are a list of packet numbers the other is requesting.
113
+ to get the real packet numbers from this list take the recvbuffers buffer_start
114
+ from the packet, subtract 1 to it and put it in packet_num then start from the
115
+ beginning of the num list: if num is zero, add 255 to packet_num then do the
116
+ next num. if num isn't zero, add its value to packet_num, note that the other
117
+ has requested we send this packet again to them then continue to the next num in
118
+ the list.
119
+
120
+
@@ -0,0 +1,194 @@
1
+ #A/V API reference
2
+
3
+ ##Take toxmsi/phone.c as a reference
4
+
5
+ ###Initialization:
6
+
7
+ ```
8
+ phone_t* initPhone(uint16_t _listen_port, uint16_t _send_port);
9
+ ```
10
+
11
+ function initializes sample phone. _listen_port and _send_port are variables only meant
12
+ for local testing. You will not have to do anything regarding to that since
13
+ everything will be started within a mesenger.
14
+
15
+
16
+ Phone requires one msi session and two rtp sessions ( one for audio and one for
17
+ video ).
18
+
19
+ ```
20
+ msi_session_t* msi_init_session( void* _core_handler, const uint8_t* _user_agent );
21
+ ```
22
+
23
+ initializes msi session.
24
+ Params:
25
+
26
+ ```
27
+ void* _core_handler - pointer to an object handling networking,
28
+ const uint8_t* _user_agent - string describing phone client version.
29
+ ```
30
+
31
+ Return value:
32
+ msi_session_t* - pointer to a newly created msi session handler.
33
+
34
+ ###msi_session_t reference:
35
+
36
+ How to handle msi session:
37
+ Controlling is done via callbacks and action handlers.
38
+ First register callbacks for every state/action received and make sure
39
+ NOT TO PLACE SOMETHING LIKE LOOPS THAT TAKES A LOT OF TIME TO EXECUTE; every callback is being called
40
+ directly from event loop. You can find examples in phone.c.
41
+
42
+ Register callbacks:
43
+ ```
44
+ void msi_register_callback_call_started ( MCALLBACK );
45
+ void msi_register_callback_call_canceled ( MCALLBACK );
46
+ void msi_register_callback_call_rejected ( MCALLBACK );
47
+ void msi_register_callback_call_ended ( MCALLBACK );
48
+
49
+ void msi_register_callback_recv_invite ( MCALLBACK );
50
+ void msi_register_callback_recv_ringing ( MCALLBACK );
51
+ void msi_register_callback_recv_starting ( MCALLBACK );
52
+ void msi_register_callback_recv_ending ( MCALLBACK );
53
+ void msi_register_callback_recv_error ( MCALLBACK );
54
+
55
+ void msi_register_callback_requ_timeout ( MCALLBACK );
56
+ ```
57
+
58
+ MCALLBACK is defined as: void (*callback) (void* _arg)
59
+ msi_session_t* handler is being thrown as \_arg so you can use that and \_agent_handler to get to your own phone handler
60
+ directly from callback.
61
+
62
+
63
+ Actions:
64
+
65
+ ```
66
+ int msi_invite ( msi_session_t* _session, call_type _call_type, uint32_t _timeoutms );
67
+ ```
68
+
69
+ Sends call invite. Before calling/sending invite msi_session_t::_friend_id is needed to be set or else
70
+ it will not work. _call_type is type of the call ( Audio/Video ) and _timeoutms is how long
71
+ will poll wait until request is terminated.
72
+
73
+ ```
74
+ int msi_hangup ( msi_session_t* _session );
75
+ ```
76
+ Hangs up active call
77
+
78
+ ```
79
+ int msi_answer ( msi_session_t* _session, call_type _call_type );
80
+ ```
81
+ Answer incomming call. _call_type set's callee call type.
82
+
83
+ ```
84
+ int msi_cancel ( msi_session_t* _session );
85
+ ```
86
+ Cancel current request.
87
+
88
+ ```
89
+ int msi_reject ( msi_session_t* _session );
90
+ ```
91
+ Reject incomming call.
92
+
93
+
94
+ ###Now for rtp:
95
+
96
+ You will need 2 sessions; one for audio one for video.
97
+ You start them with:
98
+ ```
99
+ rtp_session_t* rtp_init_session ( int _max_users, int _multi_session );
100
+ ```
101
+
102
+ Params:
103
+ ```
104
+ int _max_users - max users. -1 if undefined
105
+ int _multi_session - any positive number means uses multi session; -1 if not.
106
+ ```
107
+
108
+ Return value:
109
+ ```
110
+ rtp_session_t* - pointer to a newly created rtp session handler.
111
+ ```
112
+
113
+ ###How to handle rtp session:
114
+ Take a look at
115
+ ```
116
+ void* phone_handle_media_transport_poll ( void* _hmtc_args_p ) in phone.c
117
+ ```
118
+ on example. Basically what you do is just receive a message via:
119
+ ```
120
+ struct rtp_msg_s* rtp_recv_msg ( rtp_session_t* _session );
121
+ ```
122
+
123
+ and then you use payload within the rtp_msg_s struct. Don't forget to deallocate it with:
124
+ void rtp_free_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg );
125
+ Receiving should be thread safe so don't worry about that.
126
+
127
+ When you capture and encode a payload you want to send it ( obviously ).
128
+
129
+ first create a new message with:
130
+ ```
131
+ struct rtp_msg_s* rtp_msg_new ( rtp_session_t* _session, const uint8_t* _data, uint32_t _length );
132
+ ```
133
+
134
+ and then send it with:
135
+ ```
136
+ int rtp_send_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg, void* _core_handler );
137
+ ```
138
+
139
+ _core_handler is the same network handler as in msi_session_s struct.
140
+
141
+
142
+ ##A/V initialization:
143
+ ```
144
+ int init_receive_audio(codec_state *cs);
145
+ int init_receive_video(codec_state *cs);
146
+ Initialises the A/V decoders. On failure it will print the reason and return 0. On success it will return 1.
147
+
148
+ int init_send_audio(codec_state *cs);
149
+ int init_send_video(codec_state *cs);
150
+ Initialises the A/V encoders. On failure it will print the reason and return 0. On success it will return 1.
151
+ init_send_audio will also let the user select an input device. init_send_video will determine the webcam's output codec and initialise the appropriate decoder.
152
+
153
+ int video_encoder_refresh(codec_state *cs, int bps);
154
+ Reinitialises the video encoder with a new bitrate. ffmpeg does not expose the needed VP8 feature to change the bitrate on the fly, so this serves as a workaround.
155
+ In the future, VP8 should be used directly and ffmpeg should be dropped from the dependencies.
156
+ The variable bps is the required bitrate in bits per second.
157
+ ```
158
+
159
+
160
+ ###A/V encoding/decoding:
161
+ ```
162
+ void *encode_video_thread(void *arg);
163
+ ```
164
+ Spawns the video encoding thread. The argument should hold a pointer to a codec_state.
165
+ This function should only be called if video encoding is supported (when init_send_video returns 1).
166
+ Each video frame gets encoded into a packet, which is sent via RTP. Every 60 frames a new bidirectional interframe is encoded.
167
+ ```
168
+ void *encode_audio_thread(void *arg);
169
+ ```
170
+ Spawns the audio encoding thread. The argument should hold a pointer to a codec_state.
171
+ This function should only be called if audio encoding is supported (when init_send_audio returns 1).
172
+ Audio frames are read from the selected audio capture device during intitialisation. This audio capturing can be rerouted to a different device on the fly.
173
+ Each audio frame is encoded into a packet, and sent via RTP. All audio frames have the same amount of samples, which is defined in AV_codec.h.
174
+ ```
175
+ int video_decoder_refresh(codec_state *cs, int width, int height);
176
+ ```
177
+ Sets the SDL window dimensions and creates a pixel buffer with the requested size. It also creates a scaling context, which will be used to convert the input image format to YUV420P.
178
+
179
+ ```
180
+ void *decode_video_thread(void *arg);
181
+ ```
182
+ Spawns a video decoding thread. The argument should hold a pointer to a codec_state. The codec_state is assumed to contain a successfully initialised video decoder.
183
+ This function reads video packets and feeds them to the video decoder. If the video frame's resolution has changed, video_decoder_refresh() is called. Afterwards, the frame is displayed on the SDL window.
184
+ ```
185
+ void *decode_audio_thread(void *arg);
186
+ ```
187
+ Spawns an audio decoding thread. The argument should hold a pointer to a codec_state. The codec_state is assumed to contain a successfully initialised audio decoder.
188
+ All received audio packets are pushed into a jitter buffer and are reordered. If there is a missing packet, or a packet has arrived too late, it is treated as a lost packet and the audio decoder is informed of the packet loss. The audio decoder will then try to reconstruct the lost packet, based on information from previous packets.
189
+ Audio is played on the default OpenAL output device.
190
+
191
+
192
+ If you have any more qustions/bug reports/feature request contact the following users on the irc channel #tox-dev on irc.freenode.net:
193
+ For RTP and MSI: mannol
194
+ For audio and video: Martijnvdc
@@ -0,0 +1,11 @@
1
+ prefix=@prefix@
2
+ exec_prefix=@exec_prefix@
3
+ libdir=@libdir@
4
+ includedir=@includedir@
5
+
6
+ Name: libtoxav
7
+ Description: Tox A/V library
8
+ Requires:
9
+ Version: @PACKAGE_VERSION@
10
+ Libs: -L${libdir} -ltoxav @AV_LIBS@
11
+ Cflags: -I${includedir}
@@ -0,0 +1,11 @@
1
+ prefix=@prefix@
2
+ exec_prefix=@exec_prefix@
3
+ libdir=@libdir@
4
+ includedir=@includedir@
5
+
6
+ Name: libtoxcore
7
+ Description: Tox protocol library
8
+ Requires:
9
+ Version: @PACKAGE_VERSION@
10
+ Libs: @NACL_OBJECTS_PKGCONFIG@ -L${libdir} @NACL_LDFLAGS@ -ltoxdns -ltoxencryptsave -ltoxcore @NACL_LIBS@ @LIBS@ @MATH_LDFLAGS@
11
+ Cflags: -I${includedir}
@@ -0,0 +1,104 @@
1
+ # ===========================================================================
2
+ # http://www.gnu.org/software/autoconf-archive/ax_have_epoll.html
3
+ # ===========================================================================
4
+ #
5
+ # SYNOPSIS
6
+ #
7
+ # AX_HAVE_EPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
8
+ # AX_HAVE_EPOLL_PWAIT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
9
+ #
10
+ # DESCRIPTION
11
+ #
12
+ # This macro determines whether the system supports the epoll I/O event
13
+ # interface. A neat usage example would be:
14
+ #
15
+ # AX_HAVE_EPOLL(
16
+ # [AX_CONFIG_FEATURE_ENABLE(epoll)],
17
+ # [AX_CONFIG_FEATURE_DISABLE(epoll)])
18
+ # AX_CONFIG_FEATURE(
19
+ # [epoll], [This platform supports epoll(7)],
20
+ # [HAVE_EPOLL], [This platform supports epoll(7).])
21
+ #
22
+ # The epoll interface was added to the Linux kernel in version 2.5.45, and
23
+ # the macro verifies that a kernel newer than this is installed. This
24
+ # check is somewhat unreliable if <linux/version.h> doesn't match the
25
+ # running kernel, but it is necessary regardless, because glibc comes with
26
+ # stubs for the epoll_create(), epoll_wait(), etc. that allow programs to
27
+ # compile and link even if the kernel is too old; the problem would then
28
+ # be detected only at runtime.
29
+ #
30
+ # Linux kernel version 2.6.19 adds the epoll_pwait() call in addition to
31
+ # epoll_wait(). The availability of that function can be tested with the
32
+ # second macro. Generally speaking, it is safe to assume that
33
+ # AX_HAVE_EPOLL would succeed if AX_HAVE_EPOLL_PWAIT has, but not the
34
+ # other way round.
35
+ #
36
+ # LICENSE
37
+ #
38
+ # Copyright (c) 2008 Peter Simons <simons@cryp.to>
39
+ #
40
+ # Copying and distribution of this file, with or without modification, are
41
+ # permitted in any medium without royalty provided the copyright notice
42
+ # and this notice are preserved. This file is offered as-is, without any
43
+ # warranty.
44
+
45
+ #serial 10
46
+
47
+ AC_DEFUN([AX_HAVE_EPOLL], [dnl
48
+ ax_have_epoll_cppflags="${CPPFLAGS}"
49
+ AC_CHECK_HEADER([linux/version.h], [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
50
+ AC_MSG_CHECKING([for Linux epoll(7) interface])
51
+ AC_CACHE_VAL([ax_cv_have_epoll], [dnl
52
+ AC_LINK_IFELSE([dnl
53
+ AC_LANG_PROGRAM([dnl
54
+ #include <sys/epoll.h>
55
+ #ifdef HAVE_LINUX_VERSION_H
56
+ # include <linux/version.h>
57
+ # if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
58
+ # error linux kernel version is too old to have epoll
59
+ # endif
60
+ #endif
61
+ ], [dnl
62
+ int fd, rc;
63
+ struct epoll_event ev;
64
+ fd = epoll_create(128);
65
+ rc = epoll_wait(fd, &ev, 1, 0);])],
66
+ [ax_cv_have_epoll=yes],
67
+ [ax_cv_have_epoll=no])])
68
+ CPPFLAGS="${ax_have_epoll_cppflags}"
69
+ AS_IF([test "${ax_cv_have_epoll}" = "yes"],
70
+ [AC_MSG_RESULT([yes])
71
+ $1],[AC_MSG_RESULT([no])
72
+ $2])
73
+ ])dnl
74
+
75
+ AC_DEFUN([AX_HAVE_EPOLL_PWAIT], [dnl
76
+ ax_have_epoll_cppflags="${CPPFLAGS}"
77
+ AC_CHECK_HEADER([linux/version.h],
78
+ [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
79
+ AC_MSG_CHECKING([for Linux epoll(7) interface with signals extension])
80
+ AC_CACHE_VAL([ax_cv_have_epoll_pwait], [dnl
81
+ AC_LINK_IFELSE([dnl
82
+ AC_LANG_PROGRAM([dnl
83
+ #ifdef HAVE_LINUX_VERSION_H
84
+ # include <linux/version.h>
85
+ # if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
86
+ # error linux kernel version is too old to have epoll_pwait
87
+ # endif
88
+ #endif
89
+ #include <sys/epoll.h>
90
+ #include <signal.h>
91
+ ], [dnl
92
+ int fd, rc;
93
+ struct epoll_event ev;
94
+ fd = epoll_create(128);
95
+ rc = epoll_wait(fd, &ev, 1, 0);
96
+ rc = epoll_pwait(fd, &ev, 1, 0, (sigset_t const *)(0));])],
97
+ [ax_cv_have_epoll_pwait=yes],
98
+ [ax_cv_have_epoll_pwait=no])])
99
+ CPPFLAGS="${ax_have_epoll_cppflags}"
100
+ AS_IF([test "${ax_cv_have_epoll_pwait}" = "yes"],
101
+ [AC_MSG_RESULT([yes])
102
+ $1],[AC_MSG_RESULT([no])
103
+ $2])
104
+ ])dnl