Skip to content

Instantly share code, notes, and snippets.

@ErnyTech
Created March 26, 2019 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErnyTech/25c8f03658f2d67ea8ed795049b8a030 to your computer and use it in GitHub Desktop.
Save ErnyTech/25c8f03658f2d67ea8ed795049b8a030 to your computer and use it in GitHub Desktop.
#include <hitgvoip.h>
void update_handler(Object update) {
if(some_function_to_check_if_update_is_a_call_update) {
if(some_function_to_check_if_call_is_ready_state) {
call_params_t params = {true, user_id_to_send_call, your_call_id, CALL_STATE_REQUESTED, {true, true, 65, 65}, {}, {}};
client_t client = create_client(params);
const char *server_config[40] = {"audio_max_bitrate", "20000", audio_max_bitrate_gprs", "8000", "audio_max_bitrate_edge", "16000","audio_max_bitrate_saving", "8000","audio_init_bitrate", "16000","audio_init_bitrate_gprs", "8000","audio_init_bitrate_edge", "8000","audio_init_bitrate_saving", "8000","audio_bitrate_step_incr", "1000","audio_bitrate_step_decr", "1000","audio_min_bitrate", "8000","relay_switch_threshold", "0.8","p2p_to_relay_switch_threshold", "0.6","relay_to_p2p_switch_threshold", "0.8","reconnecting_state_timeout", "2.0","rate_flags", "0xFFFFFFFF","rate_min_rtt", "0.6","rate_min_send_loss", "0.2","packet_loss_for_extra_ec", "0.02","max_unsent_stream_packets", "2"};
// you can get server_config also with a telegram api, it's grant better performance
set_server_config(server_config, 40);
set_config(client, {20.0, 30.0, DATA_SAVING_NEVER, false, false, false, false, "", ""});
set_encryption_key(client, encry_key); //you need to calculate the encryption key or use an api that provides it (like https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1call_state_ready.html)
set_endpoints(client, {id, ipv4, ipv6, port, peer}); //you need use an telegram api for get endpoint (like https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1call_state_ready.html)
set_network_type(client, NET_TYPE_ETHERNET);
play_on_hold(client, files, N_files);
start(client);
}
}
}
int main() {
some_your_function_to_set_update_callback(update_handler);
some_your_function_to_create_call(user_id_to_send_call, other_args); //for example you could use createCall from tdlib
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment