Defines a broad set of APIs that allow the client application to query build and runtime properties of the enclosing system.
Runtime capabilities are boolean properties of a platform that can't be determined at compile-time. They may vary from device to device, but they will not change over the course of a single execution. They often specify particular behavior of other APIs within the bounds of their operating range.
Whether this system has reversed Enter and Back keys.
Whether this system has the ability to report on GPU memory usage. If (and only if) a system has this capability will SbSystemGetTotalGPUMemory() and SbSystemGetUsedGPUMemory() be valid to call.
Whether this system sets the
timestampfield of SbInputData . If the system does not set this field, then it will automatically be set; however, the relative time between input events likely will not be preserved, so time-related calculations (e.g. velocity for move events) will be incorrect.
Enumeration of network connection types.
The system is on a wired connection.
The system is on a wireless connection.
The system connection type is unknown.
Enumeration of device types.
Blue-ray Disc Player (BDP).
A relatively high-powered TV device used primarily for playing games.
Over the top (OTT) devices stream content via the Internet over another type of network, e.g. cable or satellite.
Set top boxes (STBs) stream content primarily over cable or satellite. Some STBs can also stream OTT content via the Internet.
A Smart TV is a TV that can directly run applications that stream OTT content via the Internet.
An Android TV Device.
Enumeration of special paths that the platform can define.
Path to where the local content files that ship with the binary are available.
Path to the directory that can be used as a local file cache, if available.
Path to the directory where debug output (e.g. logs, trace output, screenshots) can be written into.
Path to a directory where system font files can be found. Should only be specified on platforms that provide fonts usable by Starboard applications.
Path to a directory where system font configuration metadata can be found. May be the same directory as
kSbSystemPathFontDirectory, but not necessarily. Should only be specified on platforms that provide fonts usable by Starboard applications.
Path to a directory where temporary files can be written.
Path to a directory where test results can be written.
Full path to the executable file.
Path to a directory for permanent file storage. Both read and write access is required. This is where an app may store its persistent settings. The location should be user agnostic if possible.
Possible responses for
Enumeration of possible values for the
type parameter passed to the
Cobalt received a network connection error, or a network disconnection event. If the
kSbSystemPlatformErrorResponsePositivethen the request should be retried, otherwise the app should be stopped.
System properties that can be queried for. Many of these are used in User-Agent string generation.
The certification scope that identifies a group of devices.
The HMAC-SHA256 base64 encoded symmetric key used to sign a subset of the query parameters from the application startup URL.
The full model number of the main platform chipset, including any vendor- specific prefixes.
The production firmware version number which the device is currently running.
A friendly name for this actual device. It may include user-personalization like "Upstairs Bedroom." It may be displayed to users as part of some kind of device selection (e.g. in-app DIAL).
A deprecated alias for
The name of the brand under which the device is being sold.
The final production model number of the device.
The year the device was launched, e.g. "2016".
The corporate entity responsible for submitting the device to YouTube certification and for the device maintenance/updates.
The name of the operating system and platform, suitable for inclusion in a User-Agent, say.
The Google Speech API key. The platform manufacturer is responsible for registering a Google Speech API key for their products. In the API Console ( http://developers.google.com/console ), you can enable the Speech APIs and generate a Speech API key.
A field that, if available, is appended to the user agent
Pointer to a function to compare two items. The return value uses standard
ais less than
0if the two items are equal
ais greater than
a: The first value to compare.
b: The second value to compare.
typedef int(* SbSystemComparator) (const void *a, const void *b)
A type that can represent a system error code across all Starboard platforms.
typedef int SbSystemError
Type of callback function that may be called in response to an error
response is a code to indicate
the user's response, e.g. if the platform raised a dialog to notify the user of
user_data is the opaque pointer that was passed to the call to
typedef void(* SbSystemPlatformErrorCallback) (SbSystemPlatformErrorResponse response, void *user_data)
Binary searches a sorted table
element_count objects, each element
element_width bytes in size for an element that
comparator compares equal to
This function is meant to be a drop-in replacement for
key: The key to search for in the table.
base: The sorted table of elements
to be searched.
element_count: The number of elements in the table.
element_width: The size, in bytes, of each element in the table.
A value that indicates how the element in the table should compare to the
void* SbSystemBinarySearch(const void *key, const void *base, size_t element_count, size_t element_width, SbSystemComparator comparator)
Breaks the current program into the debugger, if a debugger is attached. If a debugger is not attached, this function aborts the program.
SB_NORETURN void SbSystemBreakIntoDebugger()
Clears the last error set by a Starboard call in the current thread.
Returns the device's current network connection type.
Returns the type of the device.
Generates a human-readable string for an error. The return value specifies the total desired length of the string.
error: The error for which a human-readable string is generated.
The generated string. This value may be null, and it is always terminated with a
string_length: The maximum length of the error string.
int SbSystemGetErrorString(SbSystemError error, char *out_string, int string_length)
Gets the last platform-specific error code produced by any Starboard call in the current thread for diagnostic purposes. Semantic reactions to Starboard function call results should be modeled explicitly.
Gets the system's current POSIX-style Locale ID. The locale represents the location, language, and cultural conventions that the system wants to use, which affects which text is displayed to the user as well as how displayed numbers, dates, currency, and similar values are formatted.
At its simplest, the locale ID can just be a BCP 47 language code, like
Currently, POSIX also wants to include the encoding as in
also allows a couple very bare-bones locales, like "C" or "POSIX", but they are
not supported here. POSIX also supports different locale settings for a few
different purposes, but Starboard only exposes one locale at a time.
RFC 5646 describes BCP 47 language codes: https://tools.ietf.org/html/bcp47
For more information than you probably want about POSIX locales, see: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap07.html
const char* SbSystemGetLocaleId()
Returns the number of processor cores available to this application. If the process is sandboxed to a subset of the physical cores, the function returns that sandboxed limit.
Retrieves the platform-defined system property specified by
places its value as a zero-terminated string into the user-allocated
unless it is longer than
value_length - 1. This implementation must be thread-
This function returns
true if the property is retrieved successfully. It
false under any of the following conditions and, in any such case,
out_value is not changed:
property_idis invalid for this platform
value_lengthis too short for the given result
property_id: The system path to be retrieved.
out_value: The platform-
defined system property specified by
value_length: The length
of the system property.
bool SbSystemGetProperty(SbSystemPropertyId property_id, char *out_value, int value_length)
A cryptographically secure random number generator that produces an arbitrary,
non-negative number of
buffer_size random, non-negative bytes. The generated
number is placed in
out_buffer. This function does not require manual seeding.
out_buffer: A pointer for the generated random number. This value must not be
buffer_size: The size of the random number, in bytes.
void SbSystemGetRandomData(void *out_buffer, int buffer_size)
A cryptographically secure random number generator that gets 64 random bits and
returns them as an
uint64_t. This function does not require manual seeding.
Places up to
stack_size instruction pointer addresses of the current execution
out_stack. The return value specifies the number of entries added.
The returned stack frames are in "downward" order from the calling frame toward the entry point of the thread. So, if all the stack frames do not fit, the ones truncated will be the less interesting ones toward the thread entry point.
This function is used in crash signal handlers and, therefore, it must be async- signal-safe on platforms that support signals. The following document discusses what it means to be async-signal-safe on POSIX: http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_04.html#tag_02_04_03
out_stack: A non-NULL array of
void * of at least
stack_size: The maximum number of instruction pointer addresses to be placed
out_stack from the current execution stack.
int SbSystemGetStack(void **out_stack, int stack_size)
Returns the total CPU memory (in bytes) potentially available to this application. If the process is sandboxed to a maximum allowable limit, the function returns the lesser of the physical and sandbox limits.
Returns the total GPU memory (in bytes) available for use by this application.
This function may only be called the return value for calls to
Returns the total physical CPU memory (in bytes) used by this application. This value should always be less than (or, in particularly exciting situations, equal to) SbSystemGetTotalCPUMemory().
Returns the current amount of GPU memory (in bytes) that is currently being used
by this application. This function may only be called if the return value for
calls to SbSystemHasCapability(kSbSystemCapabilityCanQueryGPUMemoryStats) is
Returns whether the platform has the runtime capability specified by
capability_id. Returns false for any unknown capabilities. This implementation
must be thread-safe.
capability_id: The runtime capability to check.
bool SbSystemHasCapability(SbSystemCapabilityId capability_id)
Hides the system splash screen on systems that support a splash screen that is displayed while the application is loading. This function may be called from any thread and must be idempotent.
Attempts to determine whether the current program is running inside or attached
to a debugger. The function returns
false if neither of those cases is true.
Cobalt calls this function to notify the platform that an error has occurred in the application that the platform may need to handle. The platform is expected to then notify the user of the error and to provide a means for any required interaction, such as by showing a dialog.
The return value is a boolean. If the platform cannot respond to the error, then
this function should return
false, otherwise it should return
This function may be called from any thread, and it is the platform's
responsibility to decide how to handle an error received while a previous error
is still pending. If that platform can only handle one error at a time, then it
may queue the second error or ignore it by returning
type: An error type, from the SbSystemPlatformErrorType enum, that defines the
callback: A function that may be called by the platform to let the
caller know that the user has reacted to the error.
user_data: An opaque
pointer that the platform should pass as an argument to the callback function,
if it is called.
bool SbSystemRaisePlatformError(SbSystemPlatformErrorType type, SbSystemPlatformErrorCallback callback, void *user_data)
Requests that the application move into the Paused state at the next convenient point. This should roughly correspond to "unfocused application" in a traditional window manager, where the application may be partially visible.
This function eventually causes a
kSbEventTypePause event to be dispatched to
the application. Before the
kSbEventTypePause event is dispatched, some work
may continue to be done, and unrelated system events may be dispatched.
Requests that the application be terminated gracefully at the next convenient
point. In the meantime, some work may continue to be done, and unrelated system
events may be dispatched. This function eventually causes a
event to be dispatched to the application. When the process finally terminates,
error_level, if that has any meaning on the current platform.
error_level: An integer that serves as the return value for the process that
is eventually terminated as a result of a call to this function.
void SbSystemRequestStop(int error_level)
Requests that the application move into the Suspended state at the next convenient point. This should roughly correspond to "minimization" in a traditional window manager, where the application is no longer visible.
This function eventually causes a
kSbEventTypeSuspend event to be dispatched
to the application. Before the
kSbEventTypeSuspend event is dispatched, some
work may continue to be done, and unrelated system events may be dispatched.
In the Suspended state, the application will be resident, but probably not running. The expectation is that an external system event will bring the application out of the Suspended state.
Requests that the application move into the Started state at the next convenient point. This should roughly correspond to a "focused application" in a traditional window manager, where the application is fully visible and the primary receiver of input events.
This function eventually causes a
kSbEventTypeUnpause event to be dispatched
to the application. Before
kSbEventTypeUnpause is dispatched, some work may
continue to be done, and unrelated system events may be dispatched.
Computes a HMAC-SHA256 digest of
digest using the application's
This function may be implemented as an alternative to implementing SbSystemGetProperty(kSbSystemPropertyBase64EncodedCertificationSecret), however both should not be implemented.
The output will be written into
digest_size_in_bytes must be 32 (or
greater), since 32-bytes will be written into it. Returns false in the case of
an error, or if it is not implemented. In this case the contents of
will be undefined.
bool SbSystemSignWithCertificationSecretKey(const uint8_t *message, size_t message_size_in_bytes, uint8_t *digest, size_t digest_size_in_bytes)
Sorts an array of elements
element_count elements of
element_width bytes each, using
comparator as the comparison function.
This function is meant to be a drop-in replacement for
base: The array of elements to be sorted.
element_count: The number of
elements in the array.
element_width: The size, in bytes, of each element in
comparator: A value that indicates how the array should be sorted.
void SbSystemSort(void *base, size_t element_count, size_t element_width, SbSystemComparator comparator)
Returns false if the platform doesn't need resume after suspend support. In such case Cobalt will free up the resource it retains for resume after suspend. Note that if this function returns false, the Starboard implementation cannot send kSbEventTypeResume to the event handler. The return value of this function cannot change over the life time of the application.
address as an instruction pointer and places up to (
1) characters of the symbol associated with it in
out_buffer, which must not
out_buffer will be NULL-terminated.
The return value indicates whether the function found a reasonable match for
address. If the return value is
out_buffer is not modified.
This function is used in crash signal handlers and, therefore, it must be async- signal-safe on platforms that support signals.
bool SbSystemSymbolize(const void *address, char *out_buffer, int buffer_size)