Media management - Storm iOS Library

StormLibrary 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. For better understanding of this method please make yourself familiar with Gateway server section.

StormMediaItem example

StormMediaItem can be added to a StormLibrary. 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

NameTypeRequiredDescription
hostStringYesDomain address to a StormStreaming Server.
portIntYesPort to a StormStreaming Server. The value should match WebSocket configuration for the server (443 port is set by default).
isSSLBoolYesWhenever the WebSocket connection should be established with SSL (true) or not (false).
applicationNameStringYesName of an application within the server.
streamNameStringYesA name of a stream.
labelStringYesIf more sources must be added to the library, the labels is used to identify separate streams. Labels are also used on quality list.
rtmpHostStringNoIf the source is located on an external RTMP server, rtmpHost tells the server where to look it.
rtmpApplicationNameStringNoIf the source is located on an external RTMP server, rtmpApplication tells the server what application it should connect to.
isSelectedBoolNoWhenever 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.

NameTypeRequiredDescription
groupNameStringYesName of a stream group.
stormGatewayServers[StormGatewayServer]YesA table with StormGatewayServer objects.
autoplayBoolYesDecides whenever the library should start playing automatically.
Table 2. StormGateway.connectToGateway parameters

StormGatewayServer constructor parameters.

NameTypeRequiredDescription
hostStringYesDomain address to a StormStreaming Server (with Gateway server enabled).
applicationStringYesName of the application where a stream is published.
portIntYesPort to a StormStreaming Server. The value should match WebSocket configuration for the server (443 port is set by default).
isSSLBoolYesWhenever the WebSocket connection should be established with SSL (true) or not (false).
Table 3. StormGatewayServer constructor parameters