Current section
Files
Jump to
Current section
Files
c_src/ex_libnice/_generated/nif/native.h
#pragma once
#include "../../native.h"
#include <erl_nif.h>
#include <stdint.h>
#include <stdio.h>
#include <unifex/payload.h>
#include <unifex/unifex.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Functions that manage lib and state lifecycle
* Functions with 'unifex_' prefix are generated automatically,
* the user have to implement rest of them.
*/
typedef State UnifexState;
/**
* Allocates the state struct. Have to be paired with 'unifex_release_state'
* call
*/
UnifexState *unifex_alloc_state(UnifexEnv *env);
/**
* Removes a reference to the state object.
* The state is destructed when the last reference is removed.
* Each call to 'unifex_release_state' must correspond to a previous
* call to 'unifex_alloc_state' or 'unifex_keep_state'.
*/
void unifex_release_state(UnifexEnv *env, UnifexState *state);
/**
* Increases reference count of state object.
* Each call has to be balanced by 'unifex_release_state' call
*/
void unifex_keep_state(UnifexEnv *env, UnifexState *state);
/**
* Callback called when the state struct is destroyed. It should
* be responsible for releasing any resources kept inside state.
*/
void handle_destroy_state(UnifexEnv *env, UnifexState *state);
/*
* Declaration of native functions for module Elixir.ExLibnice.Native.
* The implementation have to be provided by the user.
*/
UNIFEX_TERM init(UnifexEnv *env, char **stun_servers,
unsigned int stun_servers_length, int controlling_mode,
unsigned int min_port, unsigned int max_port);
UNIFEX_TERM add_stream(UnifexEnv *env, UnifexState *state,
unsigned int n_components, char *name);
UNIFEX_TERM remove_stream(UnifexEnv *env, UnifexState *state,
unsigned int stream_id);
UNIFEX_TERM set_relay_info(UnifexEnv *env, UnifexState *state,
unsigned int stream_id, unsigned int component_id,
char *server_ip, unsigned int server_port,
char *username, char *password, char *relay_type);
UNIFEX_TERM forget_relays(UnifexEnv *env, UnifexState *state,
unsigned int stream_id, unsigned int component_id);
UNIFEX_TERM generate_local_sdp(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM parse_remote_sdp(UnifexEnv *env, UnifexState *state,
char *remote_sdp);
UNIFEX_TERM get_local_credentials(UnifexEnv *env, UnifexState *state,
unsigned int stream_id);
UNIFEX_TERM set_remote_credentials(UnifexEnv *env, UnifexState *state,
char *credentials, unsigned int stream_id);
UNIFEX_TERM gather_candidates(UnifexEnv *env, UnifexState *state,
unsigned int stream_id);
UNIFEX_TERM peer_candidate_gathering_done(UnifexEnv *env, UnifexState *state,
unsigned int stream_id);
UNIFEX_TERM set_remote_candidate(UnifexEnv *env, UnifexState *state,
char *candidate, unsigned int stream_id,
unsigned int component_id);
UNIFEX_TERM restart(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM restart_stream(UnifexEnv *env, UnifexState *state,
unsigned int stream_id);
UNIFEX_TERM send_payload(UnifexEnv *env, UnifexState *state,
unsigned int stream_id, unsigned int component_id,
UnifexPayload *data);
/*
* Callbacks for nif lifecycle hooks.
* Have to be implemented by user.
*/
/*
* Functions that create the defined output from Nif.
* They are automatically generated and don't need to be implemented.
*/
UNIFEX_TERM init_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM add_stream_result_ok(UnifexEnv *env, unsigned int stream_id,
UnifexState *state);
UNIFEX_TERM add_stream_result_error_failed_to_add_stream(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM
add_stream_result_error_invalid_stream_or_duplicate_name(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM add_stream_result_error_failed_to_attach_recv(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM remove_stream_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM set_relay_info_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM set_relay_info_result_error_bad_relay_type(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM set_relay_info_result_error_failed_to_set_turn(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM forget_relays_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM forget_relays_result_error_component_not_found(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM generate_local_sdp_result_ok(UnifexEnv *env, char const *local_sdp,
UnifexState *state);
UNIFEX_TERM parse_remote_sdp_result_ok(UnifexEnv *env,
unsigned int added_cand_num,
UnifexState *state);
UNIFEX_TERM
parse_remote_sdp_result_error_failed_to_parse_sdp(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM get_local_credentials_result_ok(UnifexEnv *env,
char const *credentials,
UnifexState *state);
UNIFEX_TERM get_local_credentials_result_error_failed_to_get_credentials(
UnifexEnv *env, UnifexState *state);
UNIFEX_TERM set_remote_credentials_result_ok(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM set_remote_credentials_result_error_failed_to_set_credentials(
UnifexEnv *env, UnifexState *state);
UNIFEX_TERM gather_candidates_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM
gather_candidates_result_error_invalid_stream_or_allocation(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM peer_candidate_gathering_done_result_ok(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM
peer_candidate_gathering_done_result_error_stream_not_found(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM set_remote_candidate_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM set_remote_candidate_result_error_failed_to_parse_sdp_string(
UnifexEnv *env, UnifexState *state);
UNIFEX_TERM set_remote_candidate_result_error_failed_to_set(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM restart_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM restart_result_error_failed_to_restart(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM restart_stream_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM restart_stream_result_error_failed_to_restart(UnifexEnv *env,
UnifexState *state);
UNIFEX_TERM send_payload_result_ok(UnifexEnv *env, UnifexState *state);
UNIFEX_TERM send_payload_result_error_failed_to_send(UnifexEnv *env,
UnifexState *state);
/*
* Functions that send the defined messages from Nif.
* They are automatically generated and don't need to be implemented.
*/
int send_new_candidate_full(UnifexEnv *env, UnifexPid pid, int flags,
char const *candidate);
int send_new_remote_candidate_full(UnifexEnv *env, UnifexPid pid, int flags,
char const *candidate);
int send_candidate_gathering_done(UnifexEnv *env, UnifexPid pid, int flags,
unsigned int stream_id);
int send_new_selected_pair(UnifexEnv *env, UnifexPid pid, int flags,
unsigned int stream_id, unsigned int component_id,
char const *lfoundation, char const *rfoundation);
int send_component_state_failed(UnifexEnv *env, UnifexPid pid, int flags,
unsigned int stream_id,
unsigned int component_id);
int send_component_state_ready(UnifexEnv *env, UnifexPid pid, int flags,
unsigned int stream_id,
unsigned int component_id);
int send_ice_payload(UnifexEnv *env, UnifexPid pid, int flags,
unsigned int stream_id, unsigned int component_id,
UnifexPayload *payload);
#ifdef __cplusplus
}
#endif