Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

otc_session_callbacks Struct Reference

#include <session.h>

Data Fields

void(* on_connected )(otc_session *session, void *user_data)
void(* on_disconnected )(otc_session *session, void *user_data)
void(* on_connection_created )(otc_session *session, void *user_data, const otc_connection *connection)
void(* on_connection_dropped )(otc_session *session, void *user_data, const otc_connection *connection)
void(* on_stream_received )(otc_session *session, void *user_data, const otc_stream *stream)
void(* on_stream_dropped )(otc_session *session, void *user_data, const otc_stream *stream)
void(* on_stream_has_audio_changed )(otc_session *session, void *user_data, const otc_stream *stream, otc_bool has_audio)
void(* on_stream_has_video_changed )(otc_session *session, void *user_data, const otc_stream *stream, otc_bool has_video)
void(* on_stream_video_dimensions_changed )(otc_session *session, void *user_data, const otc_stream *stream, int width, int height)
void(* on_stream_video_type_changed )(otc_session *session, void *user_data, const otc_stream *stream, enum otc_stream_video_type type)
void(* on_signal_received )(otc_session *session, void *user_data, const char *type, const char *signal, const otc_connection *connection)
void(* on_reconnection_started )(otc_session *session, void *user_data)
void(* on_reconnected )(otc_session *session, void *user_data)
void(* on_archive_started )(otc_session *session, void *user_data, const char *archive_id, const char *name)
void(* on_archive_stopped )(otc_session *session, void *user_data, const char *archive_id)
void(* on_error )(otc_session *session, void *user_data, const char *error_string, enum otc_session_error_code error)
void * user_data
void * reserved

Detailed Description

Session callback functions.

This struct is a set of function pointers to callback functions for events related to an OpenTok session.

All callbacks will not be made on the application or main thread but on an internal thread. The application should return the callback as quickly as possible to avoid blocking the internal thread.

Data passed into a callback function (other than session and user_data) will be released after the callback is called. Make a copy of the data if you need to retain it.

Field Documentation

◆ on_archive_started

void(* on_archive_started) (otc_session *session, void *user_data, const char *archive_id, const char *name)

Called when an archive of the session starts recording. See the Archiving developer guide.

Parameters
sessionA pointer to the otc_session struct.
archive_idThe archive ID.
nameThe name of the archive (if one was provided when the archive was created).

◆ on_archive_stopped

void(* on_archive_stopped) (otc_session *session, void *user_data, const char *archive_id)

Called when an archive of the session stops being recorded.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
archive_idThe archive ID.

◆ on_connected

void(* on_connected) (otc_session *session, void *user_data)

Called when the otc_session_connect function successfully connects the client to an OpenTok session.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.

◆ on_connection_created

void(* on_connection_created) (otc_session *session, void *user_data, const otc_connection *connection)

Called when a new connection (from another client) is created.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
connectionThe otc_connection struct corresponding to the client connecting to the session.

◆ on_connection_dropped

void(* on_connection_dropped) (otc_session *session, void *user_data, const otc_connection *connection)

Called when another client's connection to the session is dropped.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
connectionThe otc_connection struct corresponding to the client disconnecting from the session.

◆ on_disconnected

void(* on_disconnected) (otc_session *session, void *user_data)

Called when the client is no longer connected to the OpenTok session.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.

◆ on_error

void(* on_error) (otc_session *session, void *user_data, const char *error_string, enum otc_session_error_code error)

Called when the session fails.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
error_stringThe error string.
errorThe error code (of type otc_session_error_code).

◆ on_reconnected

void(* on_reconnected) (otc_session *session, void *user_data)

Called when the local client has reconnected to the OpenTok session after its network connection was lost temporarily.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.

◆ on_reconnection_started

void(* on_reconnection_started) (otc_session *session, void *user_data)

Called when the local client has lost its connection to the OpenTok session and is trying to reconnect.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.

◆ on_signal_received

void(* on_signal_received) (otc_session *session, void *user_data, const char *type, const char *signal, const otc_connection *connection)

Called when a signal is received in the session. See the Signaling overview documentation.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
typeThe type string for the signal (if one was provided when the signal was sent).
signalThe data string for the signal (if one was provided when the signal was sent).
connectThe otc_connection representing the client that sent the signal.

◆ on_stream_dropped

void(* on_stream_dropped) (otc_session *session, void *user_data, const otc_stream *stream)

Called when another client's stream is dropped from this OpenTok session.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
streamThe otc_stream struct representing the stream.

◆ on_stream_has_audio_changed

void(* on_stream_has_audio_changed) (otc_session *session, void *user_data, const otc_stream *stream, otc_bool has_audio)

Called when a stream toggles audio on or off.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
streamThe otc_stream struct representing the new stream.
has_audioWhether the stream now has audio (OTC_TRUE) or not (OTC_FALSE).

◆ on_stream_has_video_changed

void(* on_stream_has_video_changed) (otc_session *session, void *user_data, const otc_stream *stream, otc_bool has_video)

Called when a stream toggles video on or off.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
streamWhether the stream now has video (OTC_TRUE) or not (OTC_FALSE).

◆ on_stream_received

void(* on_stream_received) (otc_session *session, void *user_data, const otc_stream *stream)

Called when a there is a new stream in this OpenTok session. Call the otc_session_subscribe function to subscribe to the stream.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
streamThe otc_stream struct representing the new stream.

◆ on_stream_video_dimensions_changed

void(* on_stream_video_dimensions_changed) (otc_session *session, void *user_data, const otc_stream *stream, int width, int height)

Called when the video dimensions of a stream in the session change.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
widthThe new width of the stream, in pixels.
heightThe new beigbt of the stream, in pixels.

◆ on_stream_video_type_changed

void(* on_stream_video_type_changed) (otc_session *session, void *user_data, const otc_stream *stream, enum otc_stream_video_type type)

Called when the video type of a stream in the session changes.

Parameters
sessionA pointer to the otc_session struct.
user_dataA pointer to the user_data you set for the session.
typeThe new stream type.

◆ reserved

void* reserved

A void pointer to a memory area holding reserved resources used for the internal implementation.

◆ user_data

void* user_data

A pointer to data you set related to the session.