CjConnectivity
cj_connectivity.h
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Seajei, LLC. All rights reserved.
3 //
4 
11 #ifndef _CJ_CONNECTIVITY_H_
12 #define _CJ_CONNECTIVITY_H_
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /* Library Header files */
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include <stddef.h>
22 
26 typedef enum {
46 
50 typedef enum {
57 
61 typedef enum {
66 } CjCoDataType;
67 
71 typedef enum {
84 } CjCoError;
85 
97 typedef void (*cj_co_connection_event_handler)(CjCoConnectionEvent connectionEvent, const char *otherDeviceId, CjCoConnectionType connectionType, CjCoDataType dataType, const uint8_t *buf, size_t bufLen, void *data);
98 
111 CjCoError cj_co_init(const char *token,
112  const char *myDeviceId,
113  size_t videoReceivingBufferSize,
114  size_t videoResendBufferSize,
115  size_t nbrReceivingAudioFramesToBuffer,
116  size_t audioResendBufferSize,
117  cj_co_connection_event_handler connectionEventHandler,
118  void *data);
119 
123 void cj_co_deinit(void);
124 
129 void cj_co_process_main_loop(void);
130 
135 void cj_co_network_changed_hint(void);
136 
145 CjCoError cj_co_send_msg(const char *msg, size_t msgLen, const char *otherDeviceId);
146 
155 CjCoError cj_co_send_push_notification(const char *msg, const char *action);
156 
163 CjCoError cj_co_connect(const char *otherDeviceId);
164 
169 bool cj_co_is_connected(void);
170 
177 
181 void cj_co_disconnect(void);
182 
190 CjCoError cj_co_send_video_h264_frame(const uint8_t *h264Frame, size_t h264FrameSize);
191 
199 CjCoError cj_co_send_video_h264_data_chunk(const uint8_t *h264Data, size_t h264DataSize);
200 
208 CjCoError cj_co_send_audio_frames(const uint8_t *audioFrames, size_t audioFramesSize);
209 
217 CjCoError cj_co_send_other_data(const uint8_t *buf, size_t bufSize);
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 
223 #endif /* _CJ_CONNECTIVITY_H_ */
CjCoConnectionEvent
CjCoConnectionEvent gives information about events occurring with a specific connection,...
Definition: cj_connectivity.h:26
CjCoError cj_co_send_audio_frames(const uint8_t *audioFrames, size_t audioFramesSize)
Send audio frames.
Peer-to-peer connection over the public internet.
Definition: cj_connectivity.h:53
Connection was successful on one of the other two of three connection types (CjCoConnectionType)....
Definition: cj_connectivity.h:36
The network connection is offline.
Definition: cj_connectivity.h:80
Network conditions are not good enough for current bitrate. Reduce the video resolution/bitrate when ...
Definition: cj_connectivity.h:30
void(* cj_co_connection_event_handler)(CjCoConnectionEvent connectionEvent, const char *otherDeviceId, CjCoConnectionType connectionType, CjCoDataType dataType, const uint8_t *buf, size_t bufLen, void *data)
Callback gets called when any type of event is received, including receiving messages or data.
Definition: cj_connectivity.h:97
CjCoConnectionType
CjOpConnectionType indicates what kind of connection we are dealing with (direct local connection,...
Definition: cj_connectivity.h:50
Other device's version is too old and not compatible with this device.
Definition: cj_connectivity.h:43
Data is neither audio nor video.
Definition: cj_connectivity.h:65
CjCoError cj_co_send_push_notification(const char *msg, const char *action)
Send push notification to other device.
Success return value. No error occurred.
Definition: cj_connectivity.h:72
CjCoError
Most methods will return a CjOpError code. The code indicates success or what type of failure happene...
Definition: cj_connectivity.h:71
Data was received (could be any type of data such as audio, video, or other).
Definition: cj_connectivity.h:27
CjCoError cj_co_send_other_data(const uint8_t *buf, size_t bufSize)
Send data that is neither H.264 video nor audio.
Received a connection request and started initiating connection.
Definition: cj_connectivity.h:35
Already attempted the maximum number of connections allowed.
Definition: cj_connectivity.h:41
Already attempted the maximum number of connections allowed.
Definition: cj_connectivity.h:82
CjCoError cj_co_init(const char *token, const char *myDeviceId, size_t videoReceivingBufferSize, size_t videoResendBufferSize, size_t nbrReceivingAudioFramesToBuffer, size_t audioResendBufferSize, cj_co_connection_event_handler connectionEventHandler, void *data)
Initializes library, sets local device unique ID, and defines how big buffers for resending lost vide...
It took too long to attempt the connection. One of the 2 devices is not connected to the network or h...
Definition: cj_connectivity.h:40
This device's version is too old and not compatible with other device.
Definition: cj_connectivity.h:42
Encompasses all connection types (such as for example when receiving and overall timeout event).
Definition: cj_connectivity.h:55
Peer sent disconnection request.
Definition: cj_connectivity.h:34
CjCoError cj_co_connect(const char *otherDeviceId)
Establish a data connection to another device.
There was an error with the token.
Definition: cj_connectivity.h:78
CjCoError cj_co_send_video_h264_frame(const uint8_t *h264Frame, size_t h264FrameSize)
Send H.264 video frame (NALU).
CjCoError cj_co_send_video_h264_data_chunk(const uint8_t *h264Data, size_t h264DataSize)
Send H.264 video data chunks.
The token used has a session maximum time limit and that limit has been reached. Contact support@seaj...
Definition: cj_connectivity.h:44
Data is video.
Definition: cj_connectivity.h:63
An internal error has occurred.
Definition: cj_connectivity.h:75
bool cj_co_is_connected(void)
Check if we have a data connection with other device.
CjCoError cj_co_send_msg(const char *msg, size_t msgLen, const char *otherDeviceId)
Send message to other device via signaling.
No associated data type.
Definition: cj_connectivity.h:62
Got disconnected because of a network change (such as network lost for example).
Definition: cj_connectivity.h:32
Something is wrong with the token provided.
Definition: cj_connectivity.h:38
An input parameter is bad.
Definition: cj_connectivity.h:74
Trying to initialize but we are already initialized.
Definition: cj_connectivity.h:77
Message received via signaling.
Definition: cj_connectivity.h:28
Attempted to reconnect more quickly than minimum interval tied to this token. Contact support@seajei....
Definition: cj_connectivity.h:83
Data is audio.
Definition: cj_connectivity.h:64
CjCoDataType
CjCoDataType indicates whether the type of data being sent or received is video, audio,...
Definition: cj_connectivity.h:61
void cj_co_disconnect(void)
Disconnects from other device.
Connection via relay server.
Definition: cj_connectivity.h:54
No associated connection type.
Definition: cj_connectivity.h:51
The data connection is disconnected.
Definition: cj_connectivity.h:81
Trying to call functions that need initialization first.
Definition: cj_connectivity.h:76
Token status is expired.
Definition: cj_connectivity.h:79
A generic error. Not enough information for a specific error code.
Definition: cj_connectivity.h:73
The token provided is expired.
Definition: cj_connectivity.h:39
bool cj_co_is_connected_via_connection_type(CjCoConnectionType connectionType)
Check if we have a data connection with other device via a specific data connection type.
void cj_co_process_main_loop(void)
This function needs to be called regularly for the library to function.
Network conditions are good enough for a higher bitrate than the one currently used....
Definition: cj_connectivity.h:29
Peer stopped responding, indicating that peer either crashed or lost its network connection.
Definition: cj_connectivity.h:33
Connection was successful. Gets received when first of 3 possible connection types gets established.
Definition: cj_connectivity.h:37
Device is ready to receive messages to its ID.
Definition: cj_connectivity.h:31
Connection over same local network.
Definition: cj_connectivity.h:52
void cj_co_network_changed_hint(void)
Deals with network changes.
void cj_co_deinit(void)
Disconnects from other device if needed and deinitializes library.