Media management - Storm Android Library

StormLibrary for Android 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:

                        
StormMediaItem stormMediaItem = new StormMediaItem("mydomain.com",443,true,,"live","test_stream_320p","320p");
                    

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

                        
StormMediaItem stormMediaItem = new StormMediaItem("mydomain.com",443,true,"live","test_stream_320p","320p","somertmpserver.com","live");
                    

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).
isSSLbooleanYesWhenever the WebSocket connection should be established with SSL (true) or not (false).
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, rtmpHosts 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.
Table 1. StormMediaItem constructor parameters

StormGateway example

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

                        
StormLibrary stormLibrary = new StormLibrary();
stormLibrary.initExoPlayer(this, findViewById(R.id.exoPlayerView));

StormGateway stormGateway = stormLibrary.initStormGateway("test");

StormGatewayServer primary = new StormGatewayServer("sub1.yourdomain.com","live", 443, true);
stormGateway.addStormGatewayServer(primary);

StormGatewayServer secondary = new StormGatewayServer("sub2.yourdomain.com","live", 443, true);
stormGateway.addStormGatewayServer(secondary);

try {
    stormLibrary.prepare(true);
} catch(Exception e){
    e.printStackTrace();
}
                    

StormGateway.initStormGateway constructor parameters.

NameTypeRequiredDescription
groupNameStringYesName of a stream group.
Table 2. StormGateway.initStormGateway constructor 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).
isSSLbooleanYesWhenever the WebSocket connection should be established with SSL (true) or not (false).
Table 3. StormGatewayServer constructor parameters