OpenTok Session. More...
#include "capabilities.h"
#include "config.h"
#include "publisher.h"
#include "subscriber.h"
#include "stream.h"
Data Structures | |
struct | otc_session_capabilities |
struct | otc_custom_ice_config |
struct | otc_signal_options |
struct | otc_session_callbacks |
Macros | |
#define | ENCRYPTION_SECRET_MINIMUM_LENGTH 8 |
#define | ENCRYPTION_SECRET_MAXIMUM_LENGTH 256 |
Typedefs | |
typedef struct otc_session | otc_session |
typedef struct otc_session_settings | otc_session_settings |
OpenTok Session.
This file includes the type definition for an OpenTok session along with several function declarations useful when dealing with a session.
typedef struct otc_session otc_session |
OpenTok session type definition.
typedef struct otc_session_settings otc_session_settings |
OpenTok session settings type definition.
Error code enumeration for OpenTok sessions.
This enumeration represents several error codes associated with a session.
otc_status otc_session_connect | ( | otc_session * | session, |
const char * | token | ||
) |
Connects the client to an OpenTok session.
session | The otc_session struct representing the OpenTok session to connect to. |
token | The client token for connecting to the session. See Token Creation Overview. |
otc_status otc_session_delete | ( | otc_session * | session | ) |
Releases resources associated with the session.
session | The otc_session instance. |
otc_status otc_session_disable_force_mute | ( | otc_session * | session | ) |
Disables the active mute state of the session. After you call this method, new streams published to the session will no longer have audio muted.
After you call the otc_session_force_mute_all() function (or a moderator in another client makes a call to mute all streams), any streams published after the moderation call are published with audio muted. Call the otc_session_disable_force_mute function to remove the mute state of a session (so that new published streams are not automatically muted).
Calling this function causes the otc_session_callback.on_mute_forced() callback function to be called in each client connected to the session, with the active
property of the otc_on_mute_forced_info struct passed into the function set to OTC_FALSE
.
Call the otc_session_get_capabilities function to see if the client can call this function successfully. This is reserved for clients that have connected with a token that has been assigned the moderator role (see the Token creation overview.
session | The otc_session struct representing the OpenTok session. |
otc_status otc_session_disconnect | ( | otc_session * | session | ) |
Disconnects the client from this session. All of the client's subscribers and publishers will also be will be disconnected from the session. As a best practice, before calling this function, call the otc_session_unpublish function for all publishers and wait for the otc_publisher_callbacks#on_stream_destroyed callback. This ensures the complete removal of publishers, especially if network connectivity issues prevent removal due to the reconnection feature, which may keep publisher streams alive for potential reconnection.
session | The otc_session struct representing the OpenTok session to disconnect from. |
otc_status otc_session_force_mute_all | ( | otc_session * | session, |
const char ** | excluded_streams_ids, | ||
const int | excluded_streams_len | ||
) |
Forces all publishers in the session (except for those publishing excluded streams) to mute audio.
Also, any streams that are published after the call to the otc_session_force_mute_all function are published with audio muted. You can remove the mute state of a session by calling the otc_session_disable_force_mute function. After you call the otc_session_disable_force_mute function, new streams published to the session will no longer have audio muted.
Calling this function causes the otc_session_callback.on_mute_forced() callback function to be called in each client connected to the session, with the active
property of the otc_on_mute_forced_info struct passed into the function set to OTC_TRUE
. Also, the otc_publisher_callbacks.on_publisher_mute_forced() callback function is called in each client publishing a muted stream.
Call the otc_session_get_capabilities function to see if the client can call this function successfully. This is reserved for clients that have connected with a token that has been assigned the moderator role (see the (see the Token creation overview.
session | The otc_session struct representing the OpenTok session. |
excluded_streams_ids | A pointer to an array of stream ID strings for the streams to be muted. Set this to nullptr to mute all streams in the session (including those published by the local client). |
excluded_streams_len | The length of the excluded stream array. |
otc_status otc_session_force_mute_stream | ( | const otc_session * | session, |
const char * | stream_id_to_mute | ||
) |
Forces the publisher of a specified stream to mute its audio.
Calling this function causes the otc_publisher_callbacks.on_publisher_mute_forced() callback function to be called in the client publishing the muted stream.
Call the otc_session_get_capabilities function to see if the client can call this function successfully. This is reserved for clients that have connected with a token that has been assigned the moderator role (see the (see the Token creation overview.
session | The otc_session struct representing the OpenTok session. |
stream_id_to_mute | The stream ID string for the stream to be muted. |
struct otc_session_capabilities otc_session_get_capabilities | ( | const otc_session * | session | ) |
Gets the capabilities of the client connecxted to the session. All otc_session_capabilities members are undefined until otc_session_callbacks.on_connected has been called.
session | The otc_session struct representing the OpenTok session. |
otc_connection* otc_session_get_connection | ( | const otc_session * | session | ) |
Gets the connection object associated with this session.
session | The otc_session struct representing the OpenTok session. |
char* otc_session_get_id | ( | const otc_session * | session | ) |
Gets the unique session ID for this session.
void* otc_session_get_user_data | ( | const otc_session * | session | ) |
Gets the user data associated with the session. See otc_session_callbacks.user_data.
session | The otc_session struct representing the OpenTok session. |
otc_session* otc_session_new | ( | const char * | apikey, |
const char * | session_id, | ||
const struct otc_session_callbacks * | callbacks | ||
) |
Creates a new otc_session struct instance. Pass this into the otc_session_connect function to connect to the OpenTok session.
See also otc_session_new_with_settings for initializing a otc_session struct with advanced options.
apikey | The API key for the OpenTok project. See See your Vonage Video API account page. |
Important: If you are using the Video API with a Vonage application (instead of an OpenTok project), pass in the application ID (not an OpenTok API key) for this parameter.
session_id | The session ID. |
callbacks | The otc_session_callbacks structure containing callback functions for events related to the session. |
otc_session* otc_session_new_with_settings | ( | const char * | apikey, |
const char * | session_id, | ||
const struct otc_session_callbacks * | callbacks, | ||
otc_session_settings * | settings | ||
) |
Creates a new OpenTok session with advanced settings. These include settings for suppressing connection events, custom TURN servers, the IP proxy feature, and the IP whitelist feature.
apikey | The API key for the OpenTok project. See See your Vonage Video API account page. |
session_id | The session ID. |
callbacks | The otc_session_callbacks structure containing callback functions for events related to the session. |
settings | The otc_session_settings struct With advanced settings for the session. |
otc_status otc_session_publish | ( | otc_session * | session, |
otc_publisher * | publisher | ||
) |
Starts a publisher streaming to the session.
session | The otc_session struct representing the OpenTok session to publish to. |
publisher | The otc_publisher struct representing the publisher. |
otc_status otc_session_report_issue | ( | struct otc_session * | session, |
const char * | issue_description, | ||
char ** | issue_id | ||
) |
Report that your app experienced an issue. You can use the issue ID with the Inspector tool or when discussing an issue with the Vonage Video API support team.
session | The otc_session struct representing the OpenTok session. |
issue_description | A description string. |
issue_id | A pointer to a string that will be set the unique identifier for the reported issue. |
otc_status otc_session_send_signal | ( | otc_session * | session, |
const char * | type, | ||
const char * | signal | ||
) |
Sends a signal to all clients connected to the session. See otc_session_send_signal_with_options, otc_session_send_signal_to_connection, and otc_session_send_signal_to_connection_with_options. Also see the Signaling overview.
session | The otc_session struct representing the OpenTok session. |
type | The optional type string value for the signal. |
signal | The optional data string value for the signal. |
otc_status otc_session_send_signal_to_connection | ( | otc_session * | session, |
const char * | type, | ||
const char * | signal, | ||
const otc_connection * | connection | ||
) |
Sends a signal to a specific client connected to the session. See otc_session_send_signal_to_connection_with_options, otc_session_send_signal, and otc_session_send_signal_with_options. Also see the Signaling overview.
session | The otc_session struct representing the OpenTok session. |
type | The optional type string value for the signal. |
signal | The optional data string value for the signal. |
connection | The otc_connection struct corresponding to the client to receive the signal. |
otc_status otc_session_send_signal_to_connection_with_options | ( | otc_session * | session, |
const char * | type, | ||
const char * | signal, | ||
const otc_connection * | connection, | ||
struct otc_signal_options | signal_options | ||
) |
Sends a signal to a specific client, with specified options. See otc_session_send_signal, otc_session_send_signal_to_connection, and otc_session_send_signal_with_options. Also see the Signaling overview.
session | The otc_session struct representing the OpenTok session. |
type | The optional type string value for the signal. |
signal | The optional data string value for the signal. |
connection | The otc_connection struct corresponding to the client to receive the signal. |
signal_options | The otc_signal_options struct with options for the signal. |
otc_status otc_session_send_signal_with_options | ( | otc_session * | session, |
const char * | type, | ||
const char * | signal, | ||
struct otc_signal_options | signal_options | ||
) |
Sends a signal to all clients connected to the session, with specified options. See otc_session_send_signal, otc_session_send_signal_to_connection, and otc_session_send_signal_to_connection_with_options. Also see the Signaling overview.
session | The otc_session struct representing the OpenTok session. |
type | The optional type string value for the signal. |
signal | The optional data string value for the signal. |
signal_options | The otc_signal_options struct with options for the signal. |
otc_status otc_session_set_encryption_secret | ( | otc_session * | session, |
const char * | secret | ||
) |
Sets the end-to-end encryption secret that will be used by all publishers and subscribers in the session.
See the End-to-end encryption developer guide.
session | The otc_session struct representing the OpenTok session. | |
[in] | secret | Value for the encryption secret. |
otc_status otc_session_settings_delete | ( | otc_session_settings * | settings | ) |
Deletes an otc_session_settings instance.
otc_session_settings* otc_session_settings_new | ( | void | ) |
Creates a new otc_session_settings instance, used to set up advanced session settings. Call the following functions to configure these settings before calling the otc_session_new_with_settings function to create a session with these settings:
otc_status otc_session_settings_set_connection_events_suppressed | ( | otc_session_settings * | settings, |
otc_bool | suppress | ||
) |
Prevent connection events, to support large interactive video sessions. This prevents otc_session_callbacks.on_connection_created and otc_session_callbacks.on_connection_dropped callback functions from being invoked when other clients connect to or disconnect from the session. (Also, the OpenTok server does not send these events to the client.) For more information, see Suppressing connection events in the OpenTok developer guides.
otc_status otc_session_settings_set_custom_ice_config | ( | otc_session_settings * | settings, |
const struct otc_custom_ice_config * | custom_ice_config | ||
) |
Enables custom ICE sever configuration. This is part of the configurable TURN feature.
otc_status otc_session_settings_set_ip_whitelist | ( | otc_session_settings * | settings, |
otc_bool | ip_whitelist | ||
) |
Pass in OTC_TRUE to have the client use the IP address white list. This feature is available as an add-on feature.
otc_status otc_session_settings_set_proxy_url | ( | otc_session_settings * | settings, |
const char * | proxy_url | ||
) |
Sets the IP proxy URL. See the IP Proxy developer guide.
otc_status otc_session_settings_set_single_peer_connection | ( | otc_session_settings * | settings, |
otc_bool | enable | ||
) |
Enables or disables Single Peer Connection (SPC) for a session.
Single Peer Connection (SPC) is a feature that encapsulates all subscriber connections to a single peer connection. The benefits of enabling SPC include reduced OS resource consumption, improved rate control, and, in case of mobile native devices, support for larger sessions.
SPC is disabled by default. When disabled, the session will use Multiple Peer Connection (MPC), where a separate peer connection is established between each endpoint.
settings | Pointer to the session settings object. |
enable | Boolean flag to enable (OTC_TRUE) or disable (OTC_FALSE) SPC. |
otc_status otc_session_subscribe | ( | otc_session * | session, |
otc_subscriber * | subscriber | ||
) |
Starts subscribing to (receiving a stream for) a subscriber's audio-video stream in this session.
session | The otc_session struct representing the OpenTok session containing the subscriber's stream. |
subscriber | The otc_subscriber struct representing the subscriber. |
otc_status otc_session_unpublish | ( | otc_session * | session, |
otc_publisher * | publisher | ||
) |
Causes a publisher from a session (causing its stream to stop).
session | The otc_session struct representing the OpenTok session to unpublish from. |
publisher | The otc_publisher struct representing the publisher. |
otc_status otc_session_unsubscribe | ( | otc_session * | session, |
otc_subscriber * | subscriber | ||
) |
Stops subscribing to (receiving a stream for) a specified subscriber in the session.
session | The otc_session struct representing the OpenTok session containing the subscriber's stream. |
subscriber | The otc_subscriber struct representing the subscriber. |