summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/Hardening.txt14
-rw-r--r--docs/av_api.md78
2 files changed, 71 insertions, 21 deletions
diff --git a/docs/Hardening.txt b/docs/Hardening.txt
index 838b3566..d95b2cda 100644
--- a/docs/Hardening.txt
+++ b/docs/Hardening.txt
@@ -45,4 +45,16 @@ to us then it is good.
45 45
46Problems with this: People don't always have at least one online friend. 46Problems with this: People don't always have at least one online friend.
47 47
482. ... 482. Pick random nodes (add ourselves some random (fake) friends to increase the
49pool of available nodes) and make then send requests to other nodes, the
50response is then relayed back to us and compared to how the node should have
51behaved. If the node is found to be behaving correctly, it is set as trusted.
52Only trusted nodes are sent in send node packets, that is unless the exact node
53being queried for in the getnode packet is present, it will be sent in the
54sendnode packet even if it is not trusted.
55
56The hypothesis is that if to be part of the network nodes have to behave
57correctly it should prevent disruption from nodes that behave incorrectly.
58
59(This idea is currently being implemented in the harden branch.)
60...
diff --git a/docs/av_api.md b/docs/av_api.md
index 08e05a6d..17930144 100644
--- a/docs/av_api.md
+++ b/docs/av_api.md
@@ -1,10 +1,13 @@
1A/V API reference 1#A/V API reference
2 2
3Take toxmsi/phone.c as a reference 3##Take toxmsi/phone.c as a reference
4 4
5Initialization: 5###Initialization:
6 6
7```
7phone_t* initPhone(uint16_t _listen_port, uint16_t _send_port); 8phone_t* initPhone(uint16_t _listen_port, uint16_t _send_port);
9```
10
8function initializes sample phone. _listen_port and _send_port are variables only meant 11function initializes sample phone. _listen_port and _send_port are variables only meant
9for local testing. You will not have to do anything regarding to that since 12for local testing. You will not have to do anything regarding to that since
10everything will be started within a mesenger. 13everything will be started within a mesenger.
@@ -13,17 +16,22 @@ everything will be started within a mesenger.
13Phone requires one msi session and two rtp sessions ( one for audio and one for 16Phone requires one msi session and two rtp sessions ( one for audio and one for
14video ). 17video ).
15 18
19```
16msi_session_t* msi_init_session( void* _core_handler, const uint8_t* _user_agent ); 20msi_session_t* msi_init_session( void* _core_handler, const uint8_t* _user_agent );
21```
17 22
18initializes msi session. 23initializes msi session.
19Params: 24Params:
25
26```
20void* _core_handler - pointer to an object handling networking, 27void* _core_handler - pointer to an object handling networking,
21const uint8_t* _user_agent - string describing phone client version. 28const uint8_t* _user_agent - string describing phone client version.
29```
22 30
23Return value: 31Return value:
24msi_session_t* - pointer to a newly created msi session handler. 32msi_session_t* - pointer to a newly created msi session handler.
25 33
26msi_session_t reference: 34###msi_session_t reference:
27 35
28How to handle msi session: 36How to handle msi session:
29Controling is done via callbacks and action handlers. 37Controling is done via callbacks and action handlers.
@@ -32,6 +40,7 @@ NOT TO PLACE SOMETHING LIKE LOOPS THAT TAKES A LOT OF TIME TO EXECUTE; every cal
32directly from event loop. You can find examples in phone.c. 40directly from event loop. You can find examples in phone.c.
33 41
34Register callbacks: 42Register callbacks:
43```
35void msi_register_callback_call_started ( MCALLBACK ); 44void msi_register_callback_call_started ( MCALLBACK );
36void msi_register_callback_call_canceled ( MCALLBACK ); 45void msi_register_callback_call_canceled ( MCALLBACK );
37void msi_register_callback_call_rejected ( MCALLBACK ); 46void msi_register_callback_call_rejected ( MCALLBACK );
@@ -44,52 +53,72 @@ void msi_register_callback_recv_ending ( MCALLBACK );
44void msi_register_callback_recv_error ( MCALLBACK ); 53void msi_register_callback_recv_error ( MCALLBACK );
45 54
46void msi_register_callback_requ_timeout ( MCALLBACK ); 55void msi_register_callback_requ_timeout ( MCALLBACK );
56```
47 57
48MCALLBACK is defined as: void (*callback) (void* _arg) 58MCALLBACK is defined as: void (*callback) (void* _arg)
49msi_session_t* handler is being thrown as _arg so you can use that and _agent_handler to get to your own phone handler 59msi_session_t* handler is being thrown as \_arg so you can use that and \_agent_handler to get to your own phone handler
50directly from callback. 60directly from callback.
51 61
52 62
53Actions: 63Actions:
64
65```
54int msi_invite ( msi_session_t* _session, call_type _call_type, uint32_t _timeoutms ); 66int msi_invite ( msi_session_t* _session, call_type _call_type, uint32_t _timeoutms );
67```
68
55Sends call invite. Before calling/sending invite msi_session_t::_friend_id is needed to be set or else 69Sends call invite. Before calling/sending invite msi_session_t::_friend_id is needed to be set or else
56it will not work. _call_type is type of the call ( Audio/Video ) and _timeoutms is how long 70it will not work. _call_type is type of the call ( Audio/Video ) and _timeoutms is how long
57will poll wait until request is terminated. 71will poll wait until request is terminated.
58 72
73```
59int msi_hangup ( msi_session_t* _session ); 74int msi_hangup ( msi_session_t* _session );
75```
60Hangs up active call 76Hangs up active call
61 77
78```
62int msi_answer ( msi_session_t* _session, call_type _call_type ); 79int msi_answer ( msi_session_t* _session, call_type _call_type );
80```
63Answer incomming call. _call_type set's callee call type. 81Answer incomming call. _call_type set's callee call type.
64 82
83```
65int msi_cancel ( msi_session_t* _session ); 84int msi_cancel ( msi_session_t* _session );
85```
66Cancel current request. 86Cancel current request.
67 87
88```
68int msi_reject ( msi_session_t* _session ); 89int msi_reject ( msi_session_t* _session );
90```
69Reject incomming call. 91Reject incomming call.
70 92
71 93
94###Now for rtp:
72 95
73
74Now for rtp:
75You will need 2 sessions; one for audio one for video. 96You will need 2 sessions; one for audio one for video.
76You start them with: 97You start them with:
77 98```
78rtp_session_t* rtp_init_session ( int _max_users, int _multi_session ); 99rtp_session_t* rtp_init_session ( int _max_users, int _multi_session );
100```
79 101
80Params: 102Params:
103```
81int _max_users - max users. -1 if undefined 104int _max_users - max users. -1 if undefined
82int _multi_session - any positive number means uses multi session; -1 if not. 105int _multi_session - any positive number means uses multi session; -1 if not.
106```
83 107
84Return value: 108Return value:
109```
85rtp_session_t* - pointer to a newly created rtp session handler. 110rtp_session_t* - pointer to a newly created rtp session handler.
111```
86 112
87How to handle rtp session: 113###How to handle rtp session:
88Take a look at 114Take a look at
115```
89void* phone_handle_media_transport_poll ( void* _hmtc_args_p ) in phone.c 116void* phone_handle_media_transport_poll ( void* _hmtc_args_p ) in phone.c
117```
90on example. Basically what you do is just receive a message via: 118on example. Basically what you do is just receive a message via:
91 119```
92struct rtp_msg_s* rtp_recv_msg ( rtp_session_t* _session ); 120struct rtp_msg_s* rtp_recv_msg ( rtp_session_t* _session );
121```
93 122
94and then you use payload within the rtp_msg_s struct. Don't forget to deallocate it with: 123and then you use payload within the rtp_msg_s struct. Don't forget to deallocate it with:
95void rtp_free_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg ); 124void rtp_free_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg );
@@ -98,17 +127,20 @@ Receiving should be thread safe so don't worry about that.
98When you capture and encode a payload you want to send it ( obviously ). 127When you capture and encode a payload you want to send it ( obviously ).
99 128
100first create a new message with: 129first create a new message with:
130```
101struct rtp_msg_s* rtp_msg_new ( rtp_session_t* _session, const uint8_t* _data, uint32_t _length ); 131struct rtp_msg_s* rtp_msg_new ( rtp_session_t* _session, const uint8_t* _data, uint32_t _length );
132```
102 133
103and then send it with: 134and then send it with:
135```
104int rtp_send_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg, void* _core_handler ); 136int rtp_send_msg ( rtp_session_t* _session, struct rtp_msg_s* _msg, void* _core_handler );
137```
105 138
106_core_handler is the same network handler as in msi_session_s struct. 139_core_handler is the same network handler as in msi_session_s struct.
107 140
108 141
109 142##A/V initialization:
110A/V initialization: 143```
111
112int init_receive_audio(codec_state *cs); 144int init_receive_audio(codec_state *cs);
113int init_receive_video(codec_state *cs); 145int init_receive_video(codec_state *cs);
114Initialises the A/V decoders. On failure it will print the reason and return 0. On success it will return 1. 146Initialises the A/V decoders. On failure it will print the reason and return 0. On success it will return 1.
@@ -122,30 +154,36 @@ int video_encoder_refresh(codec_state *cs, int bps);
122Reinitialises 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. 154Reinitialises 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.
123In the future, VP8 should be used directly and ffmpeg should be dropped from the dependencies. 155In the future, VP8 should be used directly and ffmpeg should be dropped from the dependencies.
124The variable bps is the required bitrate in bits per second. 156The variable bps is the required bitrate in bits per second.
157```
125 158
126 159
127 160###A/V encoding/decoding:
128A/V encoding/decoding: 161```
129
130void *encode_video_thread(void *arg); 162void *encode_video_thread(void *arg);
163```
131Spawns the video encoding thread. The argument should hold a pointer to a codec_state. 164Spawns the video encoding thread. The argument should hold a pointer to a codec_state.
132This function should only be called if video encoding is supported (when init_send_video returns 1). 165This function should only be called if video encoding is supported (when init_send_video returns 1).
133Each video frame gets encoded into a packet, which is sent via RTP. Every 60 frames a new bidirectional interframe is encoded. 166Each video frame gets encoded into a packet, which is sent via RTP. Every 60 frames a new bidirectional interframe is encoded.
134 167```
135void *encode_audio_thread(void *arg); 168void *encode_audio_thread(void *arg);
169```
136Spawns the audio encoding thread. The argument should hold a pointer to a codec_state. 170Spawns the audio encoding thread. The argument should hold a pointer to a codec_state.
137This function should only be called if audio encoding is supported (when init_send_audio returns 1). 171This function should only be called if audio encoding is supported (when init_send_audio returns 1).
138Audio frames are read from the selected audio capture device during intitialisation. This audio capturing can be rerouted to a different device on the fly. 172Audio frames are read from the selected audio capture device during intitialisation. This audio capturing can be rerouted to a different device on the fly.
139Each 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. 173Each 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.
140 174```
141int video_decoder_refresh(codec_state *cs, int width, int height); 175int video_decoder_refresh(codec_state *cs, int width, int height);
176```
142Sets 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. 177Sets 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.
143 178
179```
144void *decode_video_thread(void *arg); 180void *decode_video_thread(void *arg);
181```
145Spawns 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. 182Spawns 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.
146This 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. 183This 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.
147 184```
148void *decode_audio_thread(void *arg); 185void *decode_audio_thread(void *arg);
186```
149Spawns 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. 187Spawns 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.
150All 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. 188All 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.
151Audio is played on the default OpenAL output device. 189Audio is played on the default OpenAL output device.
@@ -153,4 +191,4 @@ Audio is played on the default OpenAL output device.
153 191
154If you have any more qustions/bug reports/feature request contact the following users on the irc channel #tox-dev on irc.freenode.net: 192If you have any more qustions/bug reports/feature request contact the following users on the irc channel #tox-dev on irc.freenode.net:
155For RTP and MSI: mannol 193For RTP and MSI: mannol
156For audio and video: Martijnvdc \ No newline at end of file 194For audio and video: Martijnvdc