#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_has_captions_changed )(otc_session *session, void *user_data, const otc_stream *stream, otc_bool has_captions)
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(* on_mute_forced )(otc_session *session, void *user_data, otc_on_mute_forced_info *mute_info)
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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | archive_id | The archive ID. | | name | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | archive_id | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | connection | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | connection | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | error_string | The error string. | | error | The error code (of type otc_session_error_code). |

on_mute_forced

void(* on_mute_forced) (otc_session *session, void *user_data, otc_on_mute_forced_info *mute_info)

Called when a moderator mutes streams in the session or disables the mute state in the session.

Parameters : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | mute_info | Check the active property of this struct. It is set to OTC_TRUE when a moderator has muted audio in the session. It is set to OTC_FALSE when a moderator disables the mute audio state in the session. |

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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | type | The type string for the signal (if one was provided when the signal was sent). | | signal | The data string for the signal (if one was provided when the signal was sent). | | connection | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | stream | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | stream | The otc_stream struct representing the new stream. | | has_audio | Whether the stream now has audio (OTC_TRUE) or not (OTC_FALSE). |

on_stream_has_captions_changed

void(* on_stream_has_captions_changed) (otc_session *session, void *user_data, const otc_stream *stream, otc_bool has_captions)

Called when a stream toggles captions on or off.

Parameters : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | stream | A pointer to the otc_stream struct representing the stream. | | has_captions | Whether the stream now has captions (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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | stream | Whether 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | stream | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | width | The new width of the stream, in pixels. | | height | The 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 : | | | | --- | --- | | session | A pointer to the otc_session struct. | | user_data | A pointer to the user_data you set for the session. | | type | The 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.