Fork me on GitHub
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
utils.h File Reference

TURN REST API client. More...

#include <stdint.h>
#include <glib.h>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

gint64 janus_get_monotonic_time (void)
 Helper to retrieve the system monotonic time, as Glib's g_get_monotonic_time may not be available (only since 2.28)
char * janus_string_replace (char *message, const char *old_string, const char *new_string) G_GNUC_WARN_UNUSED_RESULT
 Helper to replace strings.
gboolean janus_is_true (const char *value)
 Helper to parse yes/no|true/false configuration values.
gboolean janus_strcmp_const_time (const void *str1, const void *str2)
 Helper to compare strings in constant time.
int janus_mkdir (const char *dir, mode_t mode)
 Helper to create a new directory, and recursively create parent directories if needed.
int janus_get_opus_pt (const char *sdp)
 Ugly and dirty helper to quickly get the Opus payload type in an SDP.
int janus_get_vp8_pt (const char *sdp)
 Ugly and dirty helper to quickly get the VP8 payload type in an SDP.
gboolean janus_is_ip_valid (const char *ip, int *family)
 Check if the given IP address is valid: family is set to the address family if the IP is valid.

Flags helper methods

typedef uint32_t janus_flags
 Janus flags container.
void janus_flags_reset (janus_flags *flags)
 Janus flags reset method.
void janus_flags_set (janus_flags *flags, uint32_t flag)
 Janus flags set method.
void janus_flags_clear (janus_flags *flags, uint32_t flag)
 Janus flags clear method.
gboolean janus_flags_is_set (janus_flags *flags, uint32_t flag)
 Janus flags check method.

Detailed Description

TURN REST API client.

Utilities and helpers (headers)

TURN REST API client (headers)

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementation of the draft-uberti-rtcweb-turn-rest-00 draft, that is a REST API that can be used to access TURN services, more specifically credentials to use. Currently implemented in both rfc5766-turn-server and coturn, and so should be generic enough to be usable here.

Note
This implementation depends on libcurl and is optional.

Core

Author
Lorenzo Miniero loren.nosp@m.zo@m.nosp@m.eetec.nosp@m.ho.c.nosp@m.om

Implementations of a few methods that may be of use here and there in the code.

Core

Typedef Documentation

typedef uint32_t janus_flags

Janus flags container.

Function Documentation

void janus_flags_clear ( janus_flags flags,
uint32_t  flag 
)

Janus flags clear method.

Parameters
[in]flagsThe janus_flags instance to update
[in]flagThe flag to clear
gboolean janus_flags_is_set ( janus_flags flags,
uint32_t  flag 
)

Janus flags check method.

Parameters
[in]flagsThe janus_flags instance to check
[in]flagThe flag to check
Returns
true if the flag is set, false otherwise
void janus_flags_reset ( janus_flags flags)

Janus flags reset method.

Parameters
[in]flagsThe janus_flags instance to reset
void janus_flags_set ( janus_flags flags,
uint32_t  flag 
)

Janus flags set method.

Parameters
[in]flagsThe janus_flags instance to update
[in]flagThe flag to set
gint64 janus_get_monotonic_time ( void  )

Helper to retrieve the system monotonic time, as Glib's g_get_monotonic_time may not be available (only since 2.28)

Returns
The system monotonic time
int janus_get_opus_pt ( const char *  sdp)

Ugly and dirty helper to quickly get the Opus payload type in an SDP.

Parameters
sdpThe SDP to parse
Returns
The Opus payload type, if found, -1 otherwise
int janus_get_vp8_pt ( const char *  sdp)

Ugly and dirty helper to quickly get the VP8 payload type in an SDP.

Parameters
sdpThe SDP to parse
Returns
The VP8 payload type, if found, -1 otherwise
gboolean janus_is_ip_valid ( const char *  ip,
int *  family 
)

Check if the given IP address is valid: family is set to the address family if the IP is valid.

Parameters
ipThe IP address to check
[in,out]familyThe address family of the address, set by the method if valid
Returns
true if the address is valid, false otherwise
gboolean janus_is_true ( const char *  value)

Helper to parse yes/no|true/false configuration values.

Parameters
valueThe configuration value to parse
Returns
true if the value contains a "yes", "YES", "true", TRUE", "1", false otherwise
int janus_mkdir ( const char *  dir,
mode_t  mode 
)

Helper to create a new directory, and recursively create parent directories if needed.

Parameters
dirPath to the new folder to create
modeFile permissions for the new directory file
Returns
An integer like the regular mkdir does
Note
A failure may indicate that creating any of the subdirectories failed: some may still have been created
gboolean janus_strcmp_const_time ( const void *  str1,
const void *  str2 
)

Helper to compare strings in constant time.

Parameters
str1The first string to compare
str2The second string to compare
Returns
true if the strings are the same, false otherwise
char* janus_string_replace ( char *  message,
const char *  old_string,
const char *  new_string 
)

Helper to replace strings.

Parameters
messageThe string that contains the text to replace, which may be freed if it is too short
old_stringThe old text to replace
new_stringThe new text
Returns
A pointer to the updated text string (re-allocated or just updated)