eSDK Initialization
Commercial Hardware tools and the eSDK are available only for approved partners
To initialize the library, use the function SpInit(). The function takes a struct of type SpConfig as a parameter. Within SpConfig there are a number of required fields that need to be set to start with:
- SpConfig::memory_block. A pointer to an application-provided memory buffer that the library uses for all its memory allocations. The library does not allocate any memory beyond the size of the buffer (other than stack variables).
- SpConfig::unique_id. A unique id for the device on which it is running, typically the MAC address. This is used by the library to distinguish the device from other Spotify Connect-enabled devices that the user has. It is important that this ID is sufficiently unique and that it does not change between sessions. (See SpConfig::unique_id for more information.)
- SpConfig::display_name. The name of the device that will appear when selecting the device in the Connect menu of the Spotify mobile app, for example. Typically, this is the model name of the device or the name that the device uses to announce itself via UPnP or similar protocols.
- The fields SpConfig::brand_name and SpConfig::model_name should be set to match the brand and model name that you provided in the certification application for the hardware product.
- SpConfig::brand_display_name and SpConfig::model_display_name. Use these fields if the brand/model strings (see previous bullet) contain characters not allowed. If used, they will override SpConfig::brand_name and SpConfig::model_name for display purposes.
- SpConfig::device_type. The field should be set to the device type that matches the hardware product most closely.
- SpConfig::client_id. Provide a Client ID in the field.
- SpConfig::product_id. For each product enter a designated Product ID, a non-zero unsigned integer which enumerates this model. The simplest way to assign Product IDs for your products is to just use 1, 2, 3, and so on. The Product ID must match the value given in the New Product Application form for this particular model.
- SpConfig::error_callback. A callback function that the library will use to report errors that happen asynchronously.
Apart from these fields, there are a number of fields you may use. For a complete list, see the SpConfig page.
_24struct SpConfig conf;_24int buffer_size = SP_RECOMMENDED_MEMORY_BLOCK_SIZE;_24enum SpDeviceType device_type = kSpDeviceTypeSpeaker;_24const char *client_id = "my-client-id";_24_24memset(&conf, 0, sizeof(conf));_24_24conf.api_version = SP_API_VERSION;_24conf.memory_block = malloc(buffer_size);_24conf.memory_block_size = buffer_size;_24conf.error_callback = CallbackError;_24conf.error_callback_context = NULL;_24conf.display_name = "Example";_24conf.unique_id = "my-sample-unique-id";_24conf.brand_name = "Example_Brand";_24conf.model_name = "example_embedded";_24conf.brand_display_name = "Example Brand";_24conf.model_display_name = "example_embedded \u266C";_24conf.device_type = device_type;_24conf.zeroconf_serve = 1;_24conf.zeroconf_port = 0;_24conf.host_name = conf.unique_id;_24conf.client_id = client_id;_24conf.scope = SP_SCOPE_STREAMING;