1 module c.hitgvoip; 2 import std.stdint; 3 4 extern (C) { 5 alias DiscardCallback = int function(long, call_discard_reason_t call, int32_t); 6 alias AcceptCallback = void function(long); 7 8 struct CallProtocols { 9 bool udp_p2p_; 10 bool udp_reflector_; 11 int32_t min_layer_; 12 int32_t max_layer_; 13 }; 14 15 enum AUDIO_STATE { 16 AUDIO_STATE_NONE = -1, 17 AUDIO_STATE_CREATED = 0, 18 AUDIO_STATE_CONFIGURED = 1, 19 AUDIO_STATE_RUNNING = 2 20 }; 21 22 enum CALL_STATE { 23 CALL_STATE_NONE = -1, 24 CALL_STATE_REQUESTED = 0, 25 CALL_STATE_INCOMING = 1, 26 CALL_STATE_ACCEPTED = 2, 27 CALL_STATE_CONFIRMED = 3, 28 CALL_STATE_READY = 4, 29 CALL_STATE_ENDED = 5 30 }; 31 32 enum PROXY_PROTOCOL { 33 PROXY_NONE = 0, 34 PROXY_SOCKS5 = 1 35 }; 36 37 enum NET_TYPE { 38 NET_TYPE_UNKNOWN=0, 39 NET_TYPE_GPRS, 40 NET_TYPE_EDGE, 41 NET_TYPE_3G, 42 NET_TYPE_HSPA, 43 NET_TYPE_LTE, 44 NET_TYPE_WIFI, 45 NET_TYPE_ETHERNET, 46 NET_TYPE_OTHER_HIGH_SPEED, 47 NET_TYPE_OTHER_LOW_SPEED, 48 NET_TYPE_DIALUP, 49 NET_TYPE_OTHER_MOBILE 50 }; 51 52 enum DATA_SAVING { 53 DATA_SAVING_NEVER = 0, 54 DATA_SAVING_MOBILE, 55 DATA_SAVING_ALWAYS 56 }; 57 58 enum call_discard_reason_t { 59 CallDiscardReasonDeclined, 60 CallDiscardReasonDisconnected, 61 CallDiscardReasonEmpty, 62 CallDiscardReasonHungUp, 63 CallDiscardReasonMissed 64 }; 65 66 struct call_stats_t { 67 uint64_t bytes_sent_wifi; 68 uint64_t bytes_sent_mobile; 69 uint64_t bytes_recvd_wifi; 70 uint64_t bytes_recvd_mobile; 71 }; 72 73 struct config_t { 74 double recv_timeout; 75 double init_timeout; 76 DATA_SAVING data_saving; 77 bool enableAEC; 78 bool enableNS; 79 bool enableAGC; 80 bool enableCallUpgrade; 81 const char *log_file_path; 82 const char *status_dump_path; 83 } 84 85 struct endpoints_t { 86 int64_t id; 87 char* ipv4; 88 char* ipv6; 89 int32_t port; 90 char* peer_tag; 91 }; 92 93 struct proxy_t { 94 PROXY_PROTOCOL protocol; 95 char* address; 96 uint16_t port; 97 char* username; 98 char* password; 99 }; 100 101 struct client_t { 102 uintptr_t client_id; 103 DiscardCallback discard_callback; 104 AcceptCallback accept_callback; 105 }; 106 107 struct call_params_t { 108 bool creator; 109 long other_ID; 110 long call_id; 111 CALL_STATE call_state; 112 CallProtocols call_protocols; 113 DiscardCallback discard_callback; 114 AcceptCallback accept_callback; 115 }; 116 117 client_t create_client(call_params_t call_params); 118 void destroy_client(client_t client); 119 int discard_call(client_t client, call_discard_reason_t call_discard_reason, int32_t reason); 120 int accept_call(client_t client); 121 void close_call(client_t client); 122 int start(client_t client); 123 int64_t when_created(client_t client); 124 int is_creator(client_t client); 125 long get_other_ID(client_t client); 126 CallProtocols get_protocol(client_t client); 127 long get_call_id(client_t client); 128 CALL_STATE get_call_state(client_t client); 129 int set_output_file(client_t client, char* output_file_path); 130 int play(client_t client, char* input_file_path); 131 int play_on_hold(client_t client, char[]* input_files_path, size_t length); 132 void set_mic_mute(client_t client, int mute); 133 void debug_ctl(client_t client, int request, int param); 134 void set_bitrate(client_t client, int bitrate); 135 size_t get_debug_log(client_t client, char* debug_data, size_t size); 136 const(char)* get_version(); 137 int get_signal_bars_count(client_t client); 138 int64_t get_preferred_relay_ID(client_t client); 139 int get_last_error(client_t client); 140 size_t get_debug_string(client_t client, char* debug_string, size_t size); 141 call_stats_t get_stats(client_t client); 142 uint32_t get_peer_capabilities(client_t client); 143 void request_call_upgrade(client_t client); 144 void send_group_call_key(client_t client, char* key); 145 int get_state(client_t client); 146 int is_playing(client_t client); 147 int is_destroyed(client_t client); 148 void set_server_config(char[]* values, int count); 149 void set_config(client_t client, config_t config); 150 void set_encryption_key(client_t client, char* key); 151 void set_endpoints(client_t client, endpoints_t endpoints); 152 void set_network_type(client_t client, NET_TYPE type); 153 void set_proxy(client_t client, proxy_t proxy); 154 }