Media Management - Storm iOS Library

Storm Library for iOS can be feed with video data in two distinctive way. The first one requires you to embed all stream data directly inside your code with help of StormMediaItem objects. By creating and removing these objects the library can be populated with multiple quality version of the same stream. The main drawback for this approach is that you have to manage both sources and servers on your own.

Alternatively a Storm Streaming Gateway can be used, which generates an pre-emptive request for video data already pushed to the server. Thanks to this approach all multi-source streams can be defined within the Storm Streaming Server and shared among all edge servers within a cluster. This method also enables you to use Storm's load-balancing functionality.

StormMediaItem Example

StormMediaItem can be added to a Storm Library. For streams ingested into the Storm Server creating new source object will look as follow:

                        
let mediaItem = StormMediaItem(host: "stormdev.web-anatomy.com", port: 80, isSSL: false, applicationName: "live", streamName: "test_hd", label: "720p", isSelected: true)
stormLibrary.addStormMediaItem(stormMediaItem: mediaItem)
                    

... and the version for external RTMP source (additional parameters):

                        
let mediaItem = StormMediaItem(host: "stormdev.web-anatomy.com", port: 80, isSSL: false, applicationName: "live", streamName: "test_hd", label: "720p", rtmpHost: "rtmp.domain.com", rtmpApplicationName: "live", isSelected: true)
stormLibrary.addStormMediaItem(stormMediaItem: mediaItem)
                    
Please keep in mind that at least one StormMediaItem must be marked via isSelected:true for the library to work properly!

StormMediaItem constructor parameters

Name Type Required Description
host String Yes Domain address to a StormStreaming Server.
port Int Yes Port to a StormStreaming Server. The value should match WebSocket configuration for the server (443 port is set by default).
isSSL Bool Yes Whenever the WebSocket connection should be established with SSL (true) or not (false).
applicationName String Yes Name of an application within the server.
streamName String Yes A name of a stream.
label String Yes If more sources must be added to the library, the labels is used to identify separate streams. Labels are also used on quality list.
rtmpHost String No If the source is located on an external RTMP server, rtmpHost tells the server where to look it.
rtmpApplicationName String No If the source is located on an external RTMP server, rtmpApplication tells the server what application it should connect to.
isSelected Bool No Whenever this particular item should be marked as the default one.
Table 1. StormMediaItem constructor parameters.

StormGateway Example

In order to use the Gateway approach in the Storm iOS Library, a new StormGateway object containing our streamGroup name must be created first. In the we attach StormGatewayServer instances to it.

                        
let gatewayServers = [
    StormGatewayServer(host: "sub1.domain.com", applicationName: "live", port: 443, isSSL: true),
    StormGatewayServer(host: "sub2.domain.com", applicationName: "live", port: 443, isSSL: true)
]

stormLibrary.connectToGateway(groupName: "test", stormGatewayServers: gatewayServers, autoplay: true)
                    

StormGateway.connectToGateway parameters.

Name Type Required Description
groupName String Yes Name of a stream group.
stormGatewayServers [StormGatewayServer] Yes A table with StormGatewayServer objects.
autoplay Bool Yes Decides whenever the library should start playing automatically.
Table 2. StormGateway.connectToGateway parameters.

StormGatewayServer constructor parameters.

Name Type Required Description
host String Yes Domain address to a StormStreaming Server (with Gateway server enabled).
application String Yes Name of the application where a stream is published.
port Int Yes Port to a StormStreaming Server. The value should match WebSocket configuration for the server (443 port is set by default).
isSSL Bool Yes Whenever the WebSocket connection should be established with SSL (true) or not (false).
Table 3. StormGatewayServer constructor parameters.
Next Step

In the next step you'll learn more about events and listeners in Events Basics guide.

Support Needed?

Create a free ticket and our support team will provide you necessary assistance.