base.h
This file includes functions uses to initialize and destroy the library engine, as well as other functions to enable console logging.
Data structures: otc_on_mute_forced_info, otc_transport_stats
Includes: config.h
typedef otc_bool
Type definition for Boolean values.
Useful type for variables to represent Boolean values (true and false).
typedef int otc_bool;
typedef otc_status
Type definition for statuses.
This is the most common type for return value for functions in this library. This type includes values from the error code enumerations.
typedef int otc_status;
typedef otc_logger_callback
Type definition for a function pointer to the function used as the custom logging callback to get messages logged by the SDK.
typedef void(*) otc_logger_callback(const char *message)(const char *message);
enum otc_video_reason
Enum for reasons for a video to be started, stopped, resumed, etc.
| Name | Value | Description |
|---|---|---|
OTC_VIDEO_REASON_NONE |
0 |
No quality degradation or notable video event. Default or unknown reason. |
OTC_VIDEO_REASON_PUBLISH_VIDEO |
1 |
The client publishing the stream stopped streaming video. |
OTC_VIDEO_REASON_SUBSCRIBE_TO_VIDEO |
2 |
The local client stopped subscribing to video. |
OTC_VIDEO_REASON_QUALITY |
3 |
The video event was caused by a change to the video stream quality. |
OTC_VIDEO_REASON_CODEC_NOT_SUPPORTED |
4 |
The video event was caused when video in the subscriber stream was disabled because the stream uses a video codec that is not supported on the device. |
OTC_VIDEO_REASON_QUALITY_DEGRADATION_BANDWIDTH |
5 |
Quality degradation due to insufficient network bandwidth. |
OTC_VIDEO_REASON_QUALITY_DEGRADATION_CPU |
6 |
Quality degradation caused by CPU limitations on the client device. |
OTC_VIDEO_REASON_QUALITY_DEGRADATION_OTHER |
7 |
Quality degradation caused by other reason |
OTC_VIDEO_REASON_CODEC_CHANGE |
8 |
Video codec has changed |
OTC_VIDEO_REASON_RESOLUTION_CHANGE |
9 |
Change in video resolution or number of layers This can occur due to bitrate constraints, encoder adaptation, camera source changes (e.g., switching cameras or changing input resolution), or configuration changes, and does not always imply quality degradation. |
OTC_VIDEO_REASON_VIDEO_INTERRUPTION |
10 |
Video interruption event |
OTC_VIDEO_REASON_SENDER_QUALITY_RESTRICTION |
11 |
Sender restricted video quality |
enum otc_network_reason
Enum describing reasons impacting the network condition.
These values indicate the primary factor affecting the current network condition assessment, such as bandwidth constraints, or packet loss.
| Name | Value | Description |
|---|---|---|
OTC_NETWORK_REASON_NONE |
0 |
No notable reason. |
OTC_NETWORK_REASON_UNKNOWN |
1 |
Unknown reason. |
OTC_NETWORK_REASON_BANDWIDTH |
2 |
Network condition score impacted by bandwidth. |
OTC_NETWORK_REASON_PACKET_LOSS |
3 |
Network condition score impacted by packet loss. |
OTC_NETWORK_REASON_NETWORK_CONDITION_CHANGE |
4 |
Indicates that the local or remote participant network condition has changed. Triggered when a significant change is detected in the local or remote participant network. |
OTC_NETWORK_REASON_NO_SUBSCRIBERS |
5 |
Publisher bitrate is limited because there are no active subscribers. In this case, the Media Router may reduce or pause upstream transmission to optimize resource usage. |
OTC_NETWORK_REASON_DOWNSTREAM_CONSTRAINT |
6 |
Publisher bitrate is constrained by downstream receiver conditions. This typically occurs when client simulcast is disabled, causing publisher constraints to be derived from subscribers RTCP feedback propagated through the Media Router. |
enum otc_constant
This enumeration includes commonly used constants.
| Name | Value | Description |
|---|---|---|
OTC_SUCCESS |
0 |
Constant that represents success. |
OTC_FALSE |
0 |
Constant that represents false. |
OTC_TRUE |
!OTC_FALSE |
Constant that represents true. |
enum otc_error_code
This enumeration includes error codes.
| Name | Value | Description |
|---|---|---|
OTC_INVALID_PARAM |
1 |
Invalid funtion argument error code. An argment used in a function call is not valid. |
OTC_FATAL |
2 |
Fatal error code. Generic error. |
OTC_INVALID_VIDEO_FORMAT |
3 |
Invalid video format Raised when the capturer is configured with an invalid video format |
OTC_CONNECTION_DROPPED |
1022 |
Connection dropped error code. The connection to the OpenTok messaging server was dropped. Check the network connection. |
OTC_UNABLE_TO_FORCE_DISCONNECT |
1520 |
Force disconnect error code. Unable to successfully call otc_session_force_disconnect, perhaps because of missing permissions. |
OTC_UNABLE_TO_FORCE_MUTE |
1540 |
Force mute error code. Unable to successfully call otc_session_force_mute_all or otc_session_force_mute_stream, perhaps because of missing permissions. |
OTC_CONNECTION_TIMED_OUT |
1542 |
Connection time out error code. Time out while performing a connect action. |
OTC_UNKNOWN_PUBLISHER_INSTANCE |
2003 |
Unknown publisher instance error code. An unknown Publisher instance was used as a function argument. |
OTC_UNKNOWN_SUBSCRIBER_INSTANCE |
2004 |
Unknown subscriber instance error code. An unknown subscriber instance was used as a function argument. |
OTC_VIDEO_CAPTURE_FAILED |
3000 |
Video capture error code. There was an error with the video capturer. |
OTC_CAMERA_FAILED |
3010 |
Acquiring video camera error code. There was an error while acquiring video from the camera. |
OTC_VIDEO_RENDER_FAILED |
4000 |
Video rendering error code. There was an error while rendering video. |
OT_UNABLE_TO_ACCESS_MEDIA_ENGINE |
5000 |
Media engine access error code. There was an error when trying to get the list of supported video codecs. |
enum otc_log_level
Log level enumeration.
This enumeration represents the different log levels supported.
| Name | Value | Description |
|---|---|---|
OTC_LOG_LEVEL_DISABLED |
0 |
No messages enum value. |
OTC_LOG_LEVEL_ERROR |
1 |
Error level messages. |
OTC_LOG_LEVEL_WARN |
2 |
Warning level messages. |
OTC_LOG_LEVEL_INFO |
3 |
Info level messages. |
OTC_LOG_LEVEL_DEBUG |
4 |
Debug level messages. |
OTC_LOG_LEVEL_TRACE |
5 |
Trace level messages (most verbose). |
OTC_LOG_LEVEL_FATAL |
OTC_LOG_LEVEL_ERROR |
DEPRECATED. |
OTC_LOG_LEVEL_MSG |
OTC_LOG_LEVEL_DEBUG |
DEPRECATED. |
OTC_LOG_LEVEL_ALL |
OTC_LOG_LEVEL_TRACE |
DEPRECATED. |
enum otc_network_condition
This enum represents the overall health of the network connection for a given transport (local or remote). It is typically derived from metrics such as packet loss, and estimated available bandwidth. Higher values indicate better network conditions.
OTC_NETWORK_CONDITION_WARNING and OTC_NETWORK_CONDITION_CRITICAL indicate degraded network conditions that may trigger audio fallback callbacks. If audio fallback is enabled, the SDK will notify via the corresponding callbacks, and in the CRITICAL state, video is disabled to preserve call stability.
| Name | Value | Description |
|---|---|---|
OTC_NETWORK_CONDITION_UNKNOWN |
0 |
Network condition could not be determined |
OTC_NETWORK_CONDITION_CRITICAL |
1 |
Severe network issues; audio fallback is triggered if enabled |
OTC_NETWORK_CONDITION_WARNING |
2 |
Poor network conditions; video quality is heavily impacted and a video disable warning may be triggered if audio fallback is enabled |
OTC_NETWORK_CONDITION_FAIR |
3 |
Moderate network conditions; video quality may be restricted by the media server or peer |
OTC_NETWORK_CONDITION_GOOD |
4 |
Good network conditions; minor temporary issues may occur |
OTC_NETWORK_CONDITION_EXCELLENT |
5 |
Excellent network conditions; video quality is optimal and estimated bandwidth can accommodate the maximum bitrate for the current resolution |
enum otc_quality_restriction
Enum describing reasons for sender quality restriction.
These values indicate media server quality adjustments (spatial/temporal switches) detected during a session.
| Name | Value | Description |
|---|---|---|
OTC_QUALITY_RESTRICTION_UNKNOWN |
0 |
Unknown reason. |
OTC_QUALITY_RESTRICTION_NONE |
1 |
No notable event. |
OTC_QUALITY_RESTRICTION_SPATIAL |
2 |
Sender reduced subscriber spatial resolution. |
OTC_QUALITY_RESTRICTION_TEMPORAL |
3 |
Sender reduced subscriber temporal quality. |
OTC_QUALITY_RESTRICTION_SPATIAL_AND_TEMPORAL |
4 |
Sender reduced both spatial and temporal quality. |
enum otc_network_degradation_source
Indicates the source of video/network degradation in the session.
This enum identifies which side of the call is responsible for observed network issues impacting video quality. It complements per-transport network condition metrics.
| Name | Value | Description |
|---|---|---|
OTC_NETWORK_DEGRADATION_SOURCE_NONE |
0 |
No degradation detected; video quality is good. |
OTC_NETWORK_DEGRADATION_SOURCE_BOTH_OR_UNCLEAR |
Degradation detected, but the responsible side cannot be determined. | |
OTC_NETWORK_DEGRADATION_SOURCE_LOCAL |
Local network or transport is the cause of degradation. | |
OTC_NETWORK_DEGRADATION_SOURCE_REMOTE |
Remot network or transport is the cause of degradation. |
Functions
| Name | Description |
|---|---|
otc_init(reserved) → {otc_status} |
Initializes the library. |
otc_destroy() → {otc_status} |
Destroys the library engine. |
otc_log_set_logger_callback(callback) |
Sets the function pointer to a custom logging callback function to get messages logged by the SDK. |
otc_log_enable(log_level) |
Enables logging of SDK messages for a given log level. |
otc_get_log_level() → {enum otc_log_level} |
Gets the current console logging level. |
otc_init(reserved) → {otc_status}
Initializes the library. You must call this function before the execution of any other code using the library.
Parameters:
| Name | Type | Description |
|---|---|---|
reserved |
void * | A void pointer to a memory area holding reserved resources used for the internal implementation. This must be set to NULL. |
Returns:
Return value indicating either error or success.
otc_destroy() → {otc_status}
Destroys the library engine. You should call this function when you are done executing code that uses the library.
Returns:
Return value indicating either error or success.
otc_log_set_logger_callback(callback)
Sets the function pointer to a custom logging callback function to get messages logged by the SDK. If you do not set a logging callback function, the SDK will log messages to the console.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
otc_logger_callback | A pointer to the callback function. |
See: : - otc_log_enable
otc_log_enable(log_level)
Enables logging of SDK messages for a given log level.
Parameters:
| Name | Type | Description |
|---|---|---|
log_level |
enum otc_log_level | The desired log level. |
See: : - otc_log_set_logger_callback - otc_get_log_level
otc_get_log_level() → {enum otc_log_level}
Gets the current console logging level.
Returns:
The log level set.