Apple iOS SDK Overview
The Cisco StadiumVision Mobile iOS SDK contains the following components:
- A set of static libraries, header files, and an a sample iOS app (with a complete Xcode project)
- Customizable iOS SDK video player
Client Application Integration Overview
Figure 2-5 illustrates the high-level view of the Cisco StadiumVision iOS API libraries and common framework components. The left side of the graphic represents how to modify the sample application, and the right represents how the SDK is packaged.
Figure 2-5 Cisco StadiumVision Mobile iOS SDK Components
Cisco StadiumVision Mobile iOS API Class Overview
The singleton "StadiumVisionMobile" class provides the top-level API to start, configure, and stop the framework. Video View Controller classes are provided to play the video channels and allow for customer customization. Figure 2-6 illustrates the Cisco StadiumVision Mobile API classes.
Figure 2-6 Cisco StadiumVision Mobile iOS API Classes
Video View Controller Inheritance
The iOS "UIViewController" and "UIView" classes are used as base classes. The customer application can extend the Cisco StadiumVision Mobile classes. Figure 2-7 illustrates the UIViewController and UIView classes.
Figure 2-7 Cisco StadiumVision Mobile Video Classes
Cisco StadiumVision Mobile Application Classes
The Cisco StadiumVision Mobile application classes:
- Extends and customizes the SVMVideoViewController class
- Adds a UI overlay for controlling video playback (play, stop, close)
- Adds a UI overlay for displaying Cisco StadiumVision Mobile stats
- Handles gestures to display UI overlays with the MyVideoViewController class
Figure 2-8 Cisco StadiumVision Mobile Sample Application Classes
Cisco StadiumVision Mobile iOS API Summary
Table 2-1 summarizes the iOS API library. Following the summary are detailed tables for each API call.
Table 2-1 Cisco StadiumVision Mobile iOS API Summary
|
|
|
StadiumVisionMobile* |
sharedInstance |
Gets a reference to the API singleton class used for all API calls |
NSDictionary* |
getConfig |
Gets the SDK configuration at run-time |
NSArray* |
getStreamerArray |
Gets an array of detected SVM Streamer servers as 'SVMStreamer' objects |
SVMStatus* |
start |
Starts the StadiumVision Mobile SDK |
SVMStatus* |
shutdown |
Stops the StadiumVision Mobile SDK |
SVMStatus* |
addVideoChannelListDelegate |
Registers a callback delegate to receive all video channel list updates |
SVMStatus* |
removeVideoChannelListDelegate |
Unregisters the callback delegate from receiving the video channel list updates |
SVMStatus |
addDataChannelListDelegate |
Registers a callback delegate to receive all data channel list updates |
SVMStatus* |
removeDataChannelListDelegate |
Unregisters the callback delegate from receiving the data channel list updates |
SVMStatus* |
addDataChannelObserver |
Registers an observer class to receive data for a particular data channel |
SVMStatus* |
removeDataChannelObserver |
Unregisters an observer class from receiving data for a particular data channel |
SVMStatus* |
addDataChannelObserver:forChannel: |
Registers an observer class to receive all data updates for a particular data channel |
SVMStatus* |
addDataChannelObserver:forChannelName: |
Registers an observer class to receive all data updates for a particular data channel name |
SVMStatus* |
removeDataChannelObserver:forChannel: |
Unregisters an observer class from receiving any data updates for a particular data channel |
SVMStatus* |
removeDataChannelObserver:forChannelName: |
Unregisters an observer class from receiving any data updates for a particular data channel |
SVMStatus* |
getVideoChannelListArray |
Returns a snapshot array of the currently available video channels. |
SVMStatus* |
getDataChannelListArray |
Returns a snapshot array of the currently avaialable data channels. |
NSDictionary |
stats |
Gets an NSDictionary of current StadiumVision Mobile SDK stats. |
SVMStatus* |
version |
Gets the StadiumVision Mobile version string. |
SVMStatus* |
setConfig |
Sets the SDK configuration at run time. |
SVMStatus* |
setConfigWithString |
Sets the SDK configuration at run time with the config JSON string. |
Cisco StadiumVision Mobile iOS API
The following sections and tables describe each API call in more detail, including example usage:
Return Status Object
Each API call returns a SVMStatus object whenever applicable. Table 2-2 lists the SVMStatus object fields. This section contains the following API calls and tables:
Table 2-2 SVMStatus class
|
BOOL |
NSString |
|
isOk |
errorString |
|
Boolean indicating whether the API call was successful or not. |
If the API call was not successful (isOk == NO), this string describes the error. |
|
// make an api call
StadiumVisionMobile *svm = [StadiumVisionMobile sharedInstance];
SVMStatus status = svm.start();
// if an error occurred
if (status.isOk == NO) {
// display the error description
NSLog(@"Error occurred: %@" + status.errorString);
|
Table 2-3 sharedInstance
|
(StadiumVisionMobile*) sharedInstance
|
|
N/A |
|
Class method that returns a reference to the StadiumVision Mobile API singleton class. The returned "StadiumVisionMobile" object reference is used for all subsequent StadiumVision Mobile API calls. |
|
N/A |
Table 2-4 Start
|
|
|
N/A |
|
This method starts the StadiumVision Mobile SDK. This will kick-off and start any required StadiumVision Mobile background threads and component managers. |
|
N/A |
Table 2-5 addVideoChannelListDelegate
|
(SVMStatus*) addVideoChannelListDelegate: (id)delegate
|
|
N/A |
|
This method registers the given delegate class to receive all video channel list updates from the StadiumVision Mobile SDK. |
|
N/A |
Table 2-6 setLogLevel
|
StadiumVisionMobile *svm = [StadiumVisionMobile sharedInstance];
[svm setLogLevel:SVM_API_LOG_DEBUG]
|
|
N/A |
|
Sets the logging output level of the SDK, with the "DEBUG" level being more verbose than the "INFO" level. |
|
SVMStatus* |
Table 2-7 removeVideoChannelListDelegate
|
(SVMStatus*) addVideoChannelListDelegate: (id)delegate |
|
N/A |
|
This method unregisters the given delegate class from receiving any video channel list updates from the StadiumVision Mobile SDK. |
|
N/A |
Table 2-8 addDataChannelListDelegate
|
(SVMStatus*) addDataChannelListDelegate: (id)delegate |
|
N/A |
|
This method registers the given delegate class to receive all data channel list updates from the StadiumVision Mobile SDK. |
|
N/A |
Table 2-9 removeDataChannelListDelegate
|
(SVMStatus*) removeDataChannelListDelegate: (id)delegate
|
|
N/A |
|
This method unregisters the given delegate class from receiving any data channel list updates from the StadiumVision Mobile SDK. |
|
N/A |
Table 2-10 addDataChannelListDelegate
|
(SVMStatus*) addDataChannelListDelegate: (id)delegate
|
|
N/A |
|
This method registers the given delegate class to receive all data channel list updates from the StadiumVision Mobile SDK. |
|
N/A |
Table 2-11 removeDataChannelListDelegate
|
(SVMStatus*) removeDataChannelListDelegate: (id)delegate
|
|
N/A |
|
This method unregisters the given delegate class from receiving any data channel list updates from the StadiumVision Mobile SDK. |
|
N/A |
Table 2-12 addDataChannelObserver
|
(SVMStatus*) addDataChannelObserver: (id<SVMDataObserver>)delegate
forChannel: (SVMChannel*)channel
(SVMStatus*) addDataChannelObserver:(id<SVMDataObserver>)delegate forChannelName: (NSString*)channelName The following example enables reception of the data announcements:
SVMChannel *selectedChannel1 = [dataChannelList objectAtIndex:0];
[svm addDataChannelObserver:self forChannelName:selectedChannel1.name];
|
|
N/A |
|
This method registers the given delegate class to receive all data for the given data channel object. |
|
N/A |
Table 2-13 removeDataChannelObserver
|
(SVMStatus*) removeDataChannelObserver: (id<SVMDataObserver>)delegate
forChannel: (SVMChannel*)channel
|
|
N/A |
|
This method unregisters the given delegate class from receiving any data for the given data channel name. |
|
N/A |
Table 2-14 setConfig
|
(SVMStatus*)setConfig:(NSDictionary*)runtimeConfigDict;
|
|
N/A |
|
This method sets the SDK configuration at run-time. |
|
N/A |
Table 2-15 setConfigWithString
|
(SVMStatus*)setConfigWithString:(NSString*)jsonConfig;
|
|
N/A |
|
This method sets the SDK configuration at run-time. |
|
N/A |
Table 2-16 allowPlaybackWhenViewDisappears
|
(SVMStatus *)allowPlaybackWhenViewDisappears:(BOOL)isAllowed;
|
|
N/A |
|
Provides a mode that allows the video player to continue rendering the audio and video channels when the video player view has lost focus. |
|
N/A |
Table 2-17 getConfig
|
(NSDictionary*)getConfig;
|
|
N/A |
|
This method fetches the SDK configuration. |
|
N/A |
Table 2-18 onData
|
(void) onData:(NSData*)data withChannelName:(NSString*)channelName
|
|
N/A |
|
This method is implemented by the customer app to support the "SVMDataObserver" protocol. This delegate method is used as a callback from the StadiumVision Mobile SDK. Each callback from the SDK to the customer app provides a received data message on the given data channel. The data channel message is delivered as an array of bytes (NSData). |
|
N/A |
Table 2-19 Stats
|
(NSDictionary*) stats |
|
N/A |
|
This method returns the StadiumVision Mobile SDK stats as a dictionary of name / value pairs. Stats are currently only available for the video channel (not data channels). |
|
N/A |
Table 2-20 Stats API Hash Keys and Descriptions
|
|
announcement_session_id |
The video session announcement ID |
announcement_session_title |
The session announcement name |
announcementsMalformed |
Number of malformed channel announcement packets received |
announcementsNotAllowed |
Number of announcements where the Streamer is not allowed |
announcementsReceived |
Number of total channel announcements received |
channelsAdded |
Number of times a channel was added to the channel list |
channelsPruned |
Number of times a channel was pruned from the channel list |
invalidJsonAnnouncements |
Number of announcements with an invalid JSON body |
licenseMismatchAnnouncements |
Number of license key mismatches |
listenerIgmpRestarts |
Number of announcement listener IGMP restarts |
num_dropped_video_frames |
The total number of video frames dropped |
num_ts_discontinuities |
The total number of MPEG2-TS packet discontinuities |
protection_windows |
The total number of protection windows sent |
session_link_indicator |
The health of the WiFi network connection. Ranges from 0 (poor) to 10 (excellent). |
session_uptime |
The length of time the session has been active (in seconds) |
statsUploadAttempts |
Number of Reporter stats upload attempts |
statsUploadFailures |
Number of Reporter stats upload failures |
statsUploadSuccesses |
Number of Reporter stats upload successes |
total_num_bytes_written |
The total number of video bytes played |
versionMismatchAnnouncements |
Number of announcement version mismatches |
window_error |
The total number of protection windows with more packets per window than can be supported by Cisco StadiumVision Mobile. |
window_no_loss |
The total number of protection windows with no dropped video packets |
window_recovery_failures |
The total number of protection windows that could not recover dropped packets. Recovery failure occurs when the number of received repair packets is less than the number of dropped video packets |
window_recovery_successes |
The total number of protection windows with recovered video packets |
window_warning |
The total number of protection windows with more packets per window than the recommended value |
Table 2-21 getVideoChannelListArray
|
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
NSArray *currentChannels = [svm getVideoChannelListArray]; |
|
N/A |
|
This method returns an array (NSArray*) of the currently available video channels (array of “SVMChannel” objects). |
|
NSArray* of SVMChannel objects |
Table 2-22 getDataChannelListArray
|
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
NSArray *currentChannels = [svm getDataChannelListArray];
|
|
N/A |
|
This method returns an array (NSArray*) of the currently available data channels (array of “SVMChannel” objects) |
|
NSArray* of SVMChannel objects |
Table 2-23 wifiInfo
|
|
|
N/A |
|
This method returns the current WiFi network connection information. This information gets collected in the statistics information that gets uploaded to the Reporter server. |
|
N/A |
Table 2-24 and Table 2-25 contain properties are available within the SVMWifiInfo object.
Table 2-24 wifiInfo Object Properties
|
|
session_link_indicator |
The health of the WiFi network connection. Ranges from 0 (poor) to 10 (excellent). |
session_uptime |
The length of time the session has been active (in seconds) |
announcement_session_id |
The video session announcement ID |
Table 2-25 version
|
|
|
N/A |
|
This method returns the Cisco StadiumVision Mobile SDK version string. |
|
N/A |
The 'SVMVideoVideoController' class can be extended and customized. The SVMVideoVideoController API methods are listed in Table 2-26 . This section contains the following API calls and tables:
Table 2-26 Video View Controller API Summary
|
|
|
void |
setRenderVideoView |
Sets the iOS UI video view where video frames will get rendered |
SVMStatus |
playVideoChannel |
Starts playback of a particular video channel, changing channels on subsequent calls |
SVMStatus |
seekRelative |
Moves the video playback buffer pointer relative to the current video playback buffer offset position |
SVMStatus |
seekAbsolute |
Moves the video playback buffer pointer relative to the starting "live" video playback buffer offset position |
SVMStatus |
rewindForDuration |
Rewinds the video playback buffer pointer relative to the current playback buffer offset position |
SVMStatus |
playLive |
Moves the video playback buffer pointer to the head ("live") offset position in the video playback buffer |
Table 2-27 setRenderVideoView
|
(void)setRenderVideoView: (UIView*)aVideoView; |
|
N/A |
|
This method sets the target iOS video view (SVMVideoView) that will be used by the StadiumVision Mobile SDK to render video frames. |
|
N/A |
Table 2-28 playVideo Channel
|
(void)playVideoChannel:(SVMChannel*)channel; |
|
N/A |
|
This method plays the given video channel object. When subsequently called with a different video channel object, the video view controller will automatically stop the currently playing channel and start playback of the new channel |
|
N/A |
Table 2-29 getConfig
|
(NSDictionary*)getConfig |
|
N/A |
|
This method returns the current SDK configuration as an NSDictionary object. |
|
NSDictionary* |
Table 2-30 getStreamerArray
|
(NSArray*)getStreamerArray |
|
N/A |
|
This method returns an array of Streamer servers detected by the SVM SDK; with each Streamer entry represented as an 'SVMStreamer' object in the array. |
|
NSArray* |
Table 2-31 seekRelative
|
(void) seekRelative: (NSInteger)durationMs; |
|
N/A |
|
- This method moves the video playback buffer pointer within the video history buffer for the given amount of time (in milliseconds) relative to its current position.
- The StadiumVision Mobile SDK currently buffers 30 seconds of previously played video data that can be used for playing previously recorded video data.
- A negative duration value rewinds the video play-head within the video history buffer.
- A positive duration value forwards the video play-head towards the latest "live" video data in the video history buffer.
- Should a duration be given (positive or negative) that is larger than the available size of the video history buffer, then the StadiumVision Mobile SDK move the video play-head as far as possible within the video history buffer.
|
|
N/A |
Table 2-32 seekAbsolute
|
(void) seekAbsolute: (NSUInteger)durationMs; |
|
N/A |
|
- This method moves the video playback buffer pointer within the video history buffer for the given amount of time (in milliseconds) relative to the latest "live" video data.
- The StadiumVision Mobile SDK currently buffers 30 seconds of previously played video data that can be used for playing previously recorded video data
- A positive duration value moves the video play-head away from the latest "live" video data in the video history buffer.
- Should a duration be given that is larger than the available size of the video history buffer, then the StadiumVision Mobile SDK move the video play-head to the end of the video history buffer.
|
|
N/A |
Table 2-33 playLive
|
|
|
N/A |
|
- This method forwards the video play-head to the starting "live" position at the beginning of the video data buffer.
- This convenience method acts as a wrapper for the "seekAbsolute" API method; making "playLive()" equivalent to "seekAbsolute(0)".
|
|
N/A |
NS Notification Events
The StadiumVision Mobile SDK broadcasts the following iOS NSNotification events for use by the client application (listed in Table 2-34 ).
Table 2-34 NSNotification Event Properties
|
|
kSVMVideoEventNotification |
Constant defining the video event generated by the StadiumVision Mobile SDK |
kSVMEventTypeVideoBufferingActive |
Constant defining the "Video Buffering" type of video event |
kSVMEventTypeVideoBufferingInactive |
Constant defining the "Video Not Buffering" type of video event |
kSVMVideoOpenState |
Occurs when the video player initially opens the video channel session |
kSVMVideoPlayState |
Occurs when the video player starts playing the video channel |
kSVMVideoRewindState |
Occurs when the video player rewinds (seeks backwards) within the video history buffer |
kSVMVideoLiveState |
Occurs when the video player moves the play-head to the beginning "live" position |
kSVMVideoStopState |
Occurs when the video player stop video playback |
kSVMVideoCloseState |
Occurs when the video player closes the video channel session |
The following source code registers to receive the Cisco video notifications:
#include "StadiumVisionMobile.h"
// register to handle the video buffering events
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onVideoEvent:)
name:kSVMVideoEventNotification
The following source code handles the Cisco video notifications:
#include "StadiumVisionMobile.h"
// video event notification handler
(void)onVideoEvent:(NSNotification*)notification {
// get the passed "SVMEvent" object
SVMEvent *event = [notification object];
// determine the video event type
case kSVMEventTypeVideoBufferingActive:
// activate the UI "buffering" indicator
case kSVMEventTypeVideoBufferingInactive:
// deactivate the UI "buffering" indicator
The following example shows how to subscribe to receive the video player broadcast notifications:
// subscribe to receive video channel state change notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onVideoChannelStateChanged:)
name:kSVMVideoPlayerChannelStateChange
The following example shows how to parse the video player broadcast notifications for (1) the video channel name and (2) the video channel state:
// get the video channel state dictionary from the notification
NSDictionary *stateDict = [notify userInfo];
// get the video channel name
NSString *videoChannelName = [stateDict objectForKey:kSVMVideoPlayerChannelNameKey];
// get the video channel state
NSString *videoChannelState = [stateDict objectForKey:kSVMVideoPlayerChannelStateKey];
// determine the video channel state
if ([videoChannelState isEqualToString:kSVMVideoPlayState] == YES) {
// video player is now playing
NSLog(@"### VIDEO PLAYER: PLAYING");
} else if ([videoChannelState isEqualToString:kSVMVideoStopState] == YES) {
// video player is now stopped
NSLog(@"### VIDEO PLAYER: STOPPED");
Video Player State Flags
The SVM video player class ("SVMVideoViewController") provides a set of state flags that the inherited video player class (ie: "MyVideoViewController") can use to monitor the current video player state:
- BOOL isPlaying;
- BOOL isOpen;
- BOOL isAppActive;
- BOOL isVisible;
- BOOL isBackgroundPlaybackAllowed;
Table 2-35 provides a description of each state flag provided by the StadiumVision Mobile video player ("SVMVideoViewController"):
Table 2-35 Video Player State Flags
|
|
isOpen |
Boolean flag indicating that the video player has opened a session for video channel playback |
isPlaying |
Boolean flag indicating when the video player is currently playing a video channel |
isBackgroundPlaybackAllowed |
Boolean flag indicating if the video player is allowed to continue rendering the audio and video channels when the video player view has lost focus ("allowPlaybackWhenViewDisappears") |
isVisible |
Boolean flag indicating when the video player view is visible. This is useful when the video player is allowed to continue playing the audio / video channels when the video player has lost focus ("allowPlaybackWhenViewDisappears") |
isAppActive |
Boolean flag indicating when the container iOS app is in the foreground |
Video Player Background Audio
Starting Cisco StadiumVision Mobile SDK Release 1.3, the SVM video player ("SVMVideoViewController") provides a mode that allows the video player to continue rendering the audio and video channels when the video player view has lost focus. This mode allows the audio to still be played even when the user navigates away from the video player screen (view controller) to a different app screen; causing the video player to be hidden.
The background audio mode is disabled in the "SVMVideoViewController" by default.
The following example shows how to set the "SVMVideoViewController" mode that allows the video player to continue rendering audio and video when the "SVMVideoViewController" loses focus (is not visible):
// create the video view controller
self.videoViewController = [[MyVideoViewController alloc] init];
// allow the video player to continue playing when the video view disappears
[self.videoViewController allowPlaybackWhenViewDisappears:YES];
Video Player Channel Inactive Callback
To detect that a currently playing video channel has become invalid (due to Streamer server admin changes), the SVM video player ("SVMVideoViewController") provides a callback to tell the video player sub-class (ie: "MyVideoViewController") that the currently playing channel is no longer valid.
When a channel becomes invalid, playback of the video channel is automatically stopped.
To receive these callbacks, the "onCurrentChannelInvalid" method must be overridden by the 'SVMVideoViewController' sub-class (ie: "MyViewViewController"). The following example shows the method signature and implementation of this overridden callback method:
// OVERRIDDEN by the 'SVMVideoViewController' sub-class; indicates that the current channel is invalid
- (void)onCurrentChannelInvalid
NSLog(@"Current channel is no longer valid: dismissing video view controller");
// dismiss this modal video view controller
[self dismissModalViewControllerAnimated:YES];
Receiving Service Up and Down Notifications
The Release 2.0 of the Cisco StadiumVision Mobile SDK includes a mechanism to determine if the Cisco StadiumVision Mobile service is available or not. The SDK provides an indicator to the application indicating if the StadiumVision Mobile service is up or down. This indication should be used by the application to indicate to the user whether the StadiumVision Mobile service is available or not. Service is declared 'down' by the SDK when any of the following are true:
- The SVM SDK detects that the video quality is poor
- The SVM SDK detects that no valid, licensed channel are available
- The mobile device's WiFi interface is disabled
Poor video quality can occur when the user is receiving a weak WiFi signal; causing data loss. There are two different ways that the iOS app can get the "Service State" from the SVM SDK:
- Register to receive the "Service Up / Down" notifications
- Fetch the current service state from the SDK on-demand
When the app receives the "Service Down" notification, the SDK will supply a bitmap containing the reasons why the service wasdeclared as 'down' by the SDK. The 'reasons' bitmap is given in Table 3 :
Table 3 Service Down Reason Notification
|
|
Poor video quality networking conditions detected |
kSVMServiceDownReasonPoorQuality |
WiFi connection is down |
kSVMServiceDownReasonWiFiDown |
No valid SVM channels have been detected |
kSVMServiceDownReasonNoChannels |
The following example shows how to register to receive the "Service Up / Down" notifications from the StadiumVision Mobile SDK:
#import "StadiumVisionMobile.h"
// subscribe to receive service state up / down change notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onServiceStateChanged:)
name:kSVMServiceStateChangedNotification
// handle the received service state notifications
- (void)onServiceStateChanged:(NSNotification*)notify
// get the service state dictionary from the notification
NSDictionary *serviceStateDict = [notify userInfo];
// get the service state integer value
NSNumber *serviceStateNumber = [serviceStateDict objectForKey:kSVMServiceStateObjectKey];
NSUInteger serviceState = [serviceStateNumber unsignedIntegerValue];
// if the service state is down
if (serviceState == kSVMServiceStateDown) {
NSLog(@"*** SERVICE STATE: DOWN");
// get the service state down reasons bitmap
NSNumber *reasonsNumber = [serviceStateDict objectForKey:kSVMServiceStateChangeReasonsObjectKey];
NSUInteger reasonsBitmap = [reasonsNumber unsignedIntegerValue];
// determine the reason(s) why the service state went down
if (reasonsBitmap & kSVMServiceDownReasonSDKNotRunning) {
NSLog(@"SERVICE DOWN: SVM SDK was stopped");
} else if (reasonsBitmap & kSVMServiceDownReasonWiFiDown) {
NSLog(@"SERVICE DOWN: WiFi connection is down");
} else if (reasonsBitmap & kSVMServiceDownReasonNoChannels) {
NSLog(@"SERVICE DOWN: No valid licensed SVM channels available");
} else if (reasonsBitmap & kSVMServiceDownReasonPoorQuality) {
NSLog(@"SERVICE DOWN: Poor quality conditions detected");
// show the service down message
[self showServiceDownMessage];
} else if (serviceState == kSVMServiceStateUp) {
NSLog(@"*** SERVICE STATE: UP");
Getting the Current Service Up or Down State On Demand
The "getServiceState" API method can be used to fetch the current service state from the SDK. The method signature of the "getServiceState" API call is given below:
// api call to fetch the current svm 'service state' on-demand
- (SVMServiceState)getServiceState;
The following example show how to fetch the current service state from the SVM SDK using the "getServiceState" API call:
#import "StadiumVisionMobile.h"
// get the svm api context
StadiumVisionMobile *svm = [StadiumVisionMobile sharedInstance];
// get the current svm service state
SVMServiceState state = [svm getServiceState];
// determine the current service state
if (serviceState == kSVMServiceStateUp) {
NSLog(@"*** SERVICE STATE: UP");
} else if (serviceState == kSVMServiceStateDown) {
NSLog(@"*** SERVICE STATE: DOWN");
In-Venue Detection
Cisco StadiumVision Mobile SDK Release 1.3 provides a mechanism to detect whether the mobile device is connected within the SVM-enabled venue or not. There are two different ways that the iOS app can get this "In-Venue Detection" state from the SVM SDK:
1. Register to receive the "In-Venue Detection" notifications
2. Fetch the current "In-Venue" state from the SDK on-demand
Receiving In-Venue Detection Notifications
The following example shows how to register to receive the "Service Up / Down" notifications from the SVM SDK:
// subscribe to receive in-venue connection change notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(onVenueConnectionChanged:)
name:kSVMVenueConnectionUpdateNotification
// handle the venue connection changed event
- (void)onVenueConnectionChanged:(NSNotification*)notify
// get the in-venue detection dictionary from the notification
NSDictionary *inVenueDetectionDict = [notify userInfo];
// get the in-venue detection value
NSNumber *inVenueDetectionNumber = [inVenueDetectionDict objectForKey:kSVMVenueConnectionStateObjectKey];
BOOL isConnectedToVenue = [inVenueDetectionNumber boolValue];
// log whether we are inside the venue
NSLog(@"###### Venue Connection Updated: %@", (isConnectedToVenue ? @"INSIDE" : @"OUTSIDE"));
Get the Current In-Venue State On-Demand
The "isConnectedToVenue" API method can be used to fetch the current in-venue state from the SDK. The method signature of the "isConnectedToVenue" API call is given below:
// returns whether the device is connected to the licensed SVM venue or not
- (BOOL)isConnectedToVenue;
The following example shows how to fetch the current service state from the SVM SDK using the "getServiceState" API call:
// get a reference to the svm api
StadiumVisionMobile *svm = [StadiumVisionMobile sharedInstance];
// get whether the device is currently connected to the SVM licensed venue
BOOL isConnectedToVenue = [svm isConnectedToVenue];
// log whether the device is currently connected to the SVM licensed venue
NSLog(@"###### Venue Connection State: %@", (isConnectedToVenue ? @"INSIDE" : @"OUTSIDE"));
Set the SDK Configuration at Run-Time
Previously, the Cisco StadiumVision Mobile SDK could only be configured by using a JSON-formatted config file ("cisco_svm.cfg") bundled within the iOS app. Starting with Release 2.0, the application can now set the SDK configuration at run-time through an API method. This allows the application to dynamically configure the SDK. For example, the application can fetch the SDK configuration information from a network connection, and then pass that configuration to the SDK.
Two different methods are provided for setting the SDK configuration at run-time:
The following example shows how to set the SDK configuration using the "setConfig" API method:
#import "StadiumVisionMobile.h"
// get the stadiumvision mobile api instance
StadiumVisionMobile *svmInstance = [StadiumVisionMobile sharedInstance];
// create the config dictionary with the set of licensing keys
NSMutableDictionary *configDict = [[[NSMutableDictionary alloc] init] autorelease];
NSMutableDictionary *licenseDict = [[[NSMutableDictionary alloc] init] autorelease];
[licenseDict setObject:@"MyVenueNameKey" forKey:@"venueName"];
[licenseDict setObject:@"MyContentOwnerKey" forKey:@"contentOwner"];
[licenseDict setObject:@"MyAppDeveloperKey" forKey:@"appDeveloper"];
[configDict setObject:licenseDict forKey:@"license"];
// update the stadiumvision mobile configuration
[svmInstance setConfig:configDict];
Scalable File Distribution
The Cisco StadiumVision Mobile SDK libraries will support file channels that are easily accessible to the mobile client application.
Table 4 lists the Cisco StadiumVision Mobile scalable file distribution API.
Table 4 Scalable File Distribution and Service API Summary
|
File Service API Method Name
|
|
SVMStatus * |
addFileChannelListDelegate |
Registers a callback delegate to receive all file channel list updates |
SVMStatus* |
removeFileChannelListDelegate |
Unregisters the callback delegate from receiving the file channel list updates |
NSArray * |
getFileChannelListArray |
Returns a snapshot array of the currently avaialable file channels |
SVMStatus* |
addFileChannelObserver |
Registers an observer class to receive data for a particular file channel |
SVMStatus * |
removeFileChannelObserver |
Unregisters an observer class from receiving file for a particular file channel |
SVMStatus* |
addFileChannelObserver:forChannel |
Registers an observer class to receive all file updates for a particular file channel |
SVMStatus* |
addFileChannelObserver:forChannelName |
Registers an observer class to receive all file updates for a particular file channel name |
SVMStatus * |
removeFileChannelObserver:forChannel |
Unregisters an observer class from receiving any file updates for a particular file channel |
SVMStatus * |
removeFileChannelObserver:forChannelName |
Unregisters an observer class from receiving any file updates for a particular file channel name |
NSMutableDictionary * |
getFileDistributionTable |
Gets File distribution table details |
NSString * |
getFileDistributionLocalFilename |
Get local filesystem filename for any object given its URI and the file channel |
NSString * |
getFileDistributionLocalFilename:forChannel |
Get local filesystem filename for any object given its URI and the file channel |
NSString * |
getFileDistributionLocalFilename:forChannelName |
Get local filesystem filename for any object given its URI and the file channel name |
SDK Workflow
This section describes the Cisco StadiumVision Mobile SDK workflow, and contains the following sections:
Starting the SDK
The StadiumVision Mobile SDK needs to be started at the application initialization by calling the "start" API method as in the following example:
#import "StadiumVisionMobile.h"
// get a reference to the StadiumVision Mobile API
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
// start the StadiumVision Mobile SDK
Setting the Log Level
Sets the logging output level of the SDK, with the “DEBUG” level being more verbose than the “INFO” level. An example follows:
// start method sets logs to INFO by default
StadiumVisionMobile *svm = [StadiumVisionMobile sharedInstance];
// set the desired log level
[svm setLogLevel:SVM_API_LOG_DEBUG];
Getting the Video Channel List
The client application registers to receive callback whenever the video channel list is updated, as in the following example:
// register to receive video channel list updates
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
[svm addVideoChannelListDelegate:self];
The StadiumVision Mobile SDK will callback the client application with any video channel list updates.
#import "StadiumVisionMobile.h"
// implement the "SVMChannelListObserver" protocol
@interface MyViewController : UIViewController <SVMChannelListObserver>
// video channel handler (array of 'SVMChannel' objects)
-(void)onVideoChannelListUpdated:(NSArray*)channelList;
Presenting the Video Channel List
Table 2-36 lists the "SVMChannel" video channel objects containing all of the information needed to display the channel list to the user.
Table 2-36 SVMChannel object properties
|
|
"name” |
The name of the video channel |
"bandwidthKbps” |
The nominal video stream bandwidth (in kbps) |
"sessionNum” |
The session number of the channel |
"channelText” |
The complete text description of the video channel |
“venueName” |
The name of the venue |
“contentOwner” |
The name of the content owner |
“appDeveloper” |
The name of the application developer |
Playing A Video Channel
The example below demonstrates these actions:
- Selects a channel from the locally saved channel list
- Presents the video view controller modally
- Commands the video view controller to play the selected channel
#import "StadiumVisionMobile"
// get the user-selected video channel object
SVMChannel *selectedChannel = [videochannelList objectAtIndex:0];
NSLog(@"Selected Video Channel = %@", selectedChannel.name);
// create the video view controller
MyVideoViewController *myVC = [[MyVideoViewController alloc] init];
// present the modal video view controller
myVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:myVC animated:YES];
// play the selected video channel
[myVC playVideoChannel:selectedChannel];
Seeking Within the Video Buffer
The last 30 seconds of played video is stored in the device RAM. The following example jumps backwards 20 seconds in the video buffer (instant replay).
// get a reference to the api object
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
[svm rewindForDuration:-20000];
The example below jumps back to the top of the video buffer ("live" video playback):
// get a reference to the api object
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
// play at the "live" video offset
Getting The Data Channel List
In the following example, the client application registers to receive callback whenever the data channel list is updated.
// register to receive data channel list updates
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
[svm addDataChannelListDelegate:self];
In this example, the StadiumVision Mobile SDK will callback the client application with any data channel list updates:
#import "StadiumVisionMobile.h"
// implement the "SVMChannelListObserver" protocol
@interface MyViewController : UIViewController <SVMChannelListObserver>
// data channel handler (array of 'SVMChannel' objects)
(void)onDataChannelListUpdated:(NSArray*)channelList;
Observing a Data Channel
In the following example, the registered class needs to implement the "SVMDataObserver" protocol:
#import "SVMDataObserver.h"
@interface DataChannelViewController : UIViewController <SVMDataObserver>
In this example, the "onData:withChannelName" method is called to push the received data to the registered class:
-(void)onData:(NSData*)data withChannelName:(NSString *)channelName {
// convert the data bytes into a string
NSString *dataStr = [[NSString alloc] initWithBytes:[data bytes]
encoding:NSUTF8StringEncoding];
// display the data bytes and associated channel name
NSLog(@"ChannelListViewController: onData callback: "
"channelName = %@, data = %@", channelName, dataStr);
Getting the SDK Version String
The example below gets the StadiumVision Mobile SDK version string:
#import "StadiumVisionMobile"
// get a reference to the api object
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
// get the sdk version string
NSString *sdkVersion = [svm version];
Shutting Down the SDK (Optional)
The StadiumVision Mobile SDK automatically shuts-down and restarts based upon the iOS life-cycle notifications (NSNotifications). The client iOS application does not need to explicitly stop and restart the StadiumVision Mobile SDK. This 'shutdown' API is provided in case a customer use-case requires an explicit SDK shutdown.
#import "StadiumVisionMobile"
// get a reference to the api object
StadiumVisionMobile *svm = [StadiumVisonMobile sharedInstance];
// shutdown the StadiumVision Mobile SDK
Video Player View Controller Customization
This section describes how to customize the video player, and contains the following sections:
Default Cisco Video Player View Controller
The default Cisco video player has the following features:
- Implemented as a separate iOS "UIViewController"
- Support for fullscreen and partial-screen video views
- Video frames rendered using an iOS "UIView" and OpenGL layer (CAEAGLLayer)
- Customizable by extending the "SVMVideoViewController" class
- The Cisco demo app uses a customized video player
Customized Video Player
To customize the video player, extend the "SVMVideoViewController" base class as in the following example:
#import "SVMVideoViewController.h";
@interface MyVideoViewController : SVMVideoViewController {
Figure 2-9 Video Player Customization
Cisco Demo Customized Video Player
The demo customized video player has the following properties:
- Implemented as "MyVideoViewController"
- Extends the "SVMVideoViewController" class
- Handles all video overlays and gestures
- Single-tap gesture and "Back", "Rewind" / "Live" overlay buttons
- Two-finger double-tap gesture and stats overlay
- Uses the "MyVideoViewController~iphone.xib" to layout the screen
- Located in the "Customer App / App UI Resources / UI XML Files" Xcode project folder
The video view shown in Interface Builder is connected to the "videoView" property and is of class type "MyVideoView".
Configuration
This section describes the required configuration files. and contains the following sections:
Configuration Files
There are three configuration files that must be bundled with any iOS app using the StadiumVision Mobile SDK, as listed in the following table:
Table 2-37 Configuration Files
|
|
"cisco_svm.cfg” |
The Cisco StadiumVision Mobile SDK configuration file that contains the "Field-of-Use" para meters and some optional WiFi network debugging information |
"vompPlay.cfg” |
Video decoder configuration file that contains the tuned decoding parameters. These settings should never be changed. Any changes could result in poor video or audio playback. |
“voVidDec.dat” |
Video decoder license file. |
Field of Use Configuration
There are three "field-of-use" (also known as the triplet key) properties in the "cisco_svm.cfg" configuration file that need to be configured for each StadiumVision Mobile application: These three fields must match the channel settings in the Cisco StadiumVision Mobile Streamer for the channels to be accessible by the application:
- Venue Name
- Content Owner
- App Developer
An example set of fields in the "cisco_svm.cfg" file is shown below:
"venueName": "Stadium-A",
"contentOwner": "Multi-Tenant Team-B",
"appDeveloper": "Vendor-C"
Wi-Fi Access Point Configuration
The "cisco_svm.cfg" configuration file can optionally include an array of WiFi AP information that will be used by the StadiumVision Mobile SDK for statistics reporting if available. Below is an example WiFi AP info entry in the "cisco_svm.cfg" configuration file:
"name": "Press Box Booth 5",
"bssid": "04:C5:A4:09:55:70"
Integration Checklist
The following list outlines integration steps for using the Cisco StadiumVision Mobile SDK.
1. Supported iOS version
– Set the app's iOS version target set to iOS v4.0 or above
2. Copy configuration files
– Copy the "cisco_svm.cfg" and vompPlay.cfg" config files, and the "voVidDec.dat" license file into the Xcode project.
3. Copy libraries
– Copy the "libStadiumVisionMobile.a" and "libvoCTS.a" static libraries into the Xcode project.
4. Set the Xcode Project "Build Settings"
– Add the "-ObjC" flag to the "Other Linker Flags" build setting. This ensures all Objective-C categories are loaded from the StadiumVision Mobile static library.
– Add the "-lstdc++" flag to the "Other Linker Flags" build setting. This ensures that the C++ video decoder library is properly linked to the final app build.
5. Include Required iOS Libraries by adding frameworks in the target build phases pane of the Xcode project, under "Link Binary With Libraries" section, as shown in Figure 2-10.
Figure 2-10 Adding frameworks in Xcode
Required iOS Libraries
- UIKit.framework
- Foundation.framework
- CoreGraphics.framework
- AudioToolbox.framework
- OpenGLES.framework
- QuartzCore.framework
- CFNetwork.framework
- SystemConfiguration.framework
- MobileCoreServices.framework
- libz.dylib
What the SDK Handles
The StadiumVision Mobile SDK automatically handles the following events:
- Dynamic video channel discovery and notification
- Dynamic data channel discovery and notification
- Automatic SDK shutdown / restart in response to WiFi up / down events
- Automatic SDK shutdown / restart in response to iOS life-cycle events
- Management of multicast network data threads
- On-demand management of video / audio decoding threads
- Automatic statistics reporting to the StadiumVision Mobile Reporter server
Customer Application Roles
Figure 2-11 illustrates the roles of the customer application. The application must specify:
- Getting the list of video channels
- Displaying the list of video channels
- Handling user gestures for selecting video channels
- Adding video overlays and layouts
- Handling user gestures to control video overlays
Figure 2-11 Customer Application Responsibilities