FMLiveSwitchUtility Class Reference

Utility methods. More...

Instance Methods

(instancetype) - init
 

Class Methods

(NSMutableArray *) + cloneIntArray:
 Clones an array of int values. More...
 
(NSMutableArray *) + cloneLongArray:
 Clones an array of long values. More...
 
(NSMutableArray *) + cloneStringArray:
 Clones an array of string values. More...
 
(NSMutableArray< id > *) + cloneWithList:
 Clones the specified list. More...
 
(id+ firstOrDefaultWithArray:
 Gets the first element in the array or the default value if the array is null or empty. More...
 
(id+ firstOrDefaultWithList:
 Gets the first element in the list or the default value if the list is null or empty. More...
 
(NSString *) + formatDoubleAsPercent:decimalPlaces:
 Formats a double as a percentage string. More...
 
(NSString *) + generateId
 Generates a globally unique identifier with no hyphens. More...
 
(long long) + generateSynchronizationSource
 Generates a synchronization source. More...
 
(NSString *) + generateTieBreaker
 Generates a tie-breaker. More...
 
(int) + getRtpSequenceNumberDeltaWithRtpSequenceNumber:lastRtpSequenceNumber:
 Retrieves the difference between two RTP sequence numbers while accounting for overflow rollover. More...
 
(long long) + getRtpTimestampDeltaWithRtpTimestamp:lastRtpTimestamp:
 Retrieves the difference between two RTP timestamps while accounting for overflow rollover. More...
 
(id+ lastOrDefaultWithArray:
 Gets the last element in the array or the default value if the array is null or empty. More...
 
(id+ lastOrDefaultWithList:
 Gets the last element in the list or the default value if the list is null or empty. More...
 
(bool) + nullableLongEqualsWithLong1:long2:
 Compares two nullable longs for equality. More...
 
(id+ singleOrDefaultWithArray:
 Gets the only element in the array or the default value if the array is null or does not have exactly one value. More...
 
(id+ singleOrDefaultWithList:
 Gets the only element in the list or the default value if the list is null or does not have exactly one value. More...
 
(NSMutableArray *) + spliceWithArray:index:addItems:createArray:
 Splices an array. More...
 
(NSMutableArray *) + spliceWithArray:index:addItems:createArrayBlock:
 Splices an array. More...
 
(NSMutableArray *) + spliceWithArray:index:removeCount:addItems:createArray:
 Splices an array. More...
 
(NSMutableArray *) + spliceWithArray:index:removeCount:addItems:createArrayBlock:
 Splices an array. More...
 
(NSMutableArray *) + spliceWithArray:index:removeCount:createArray:
 Splices an array. More...
 
(NSMutableArray *) + spliceWithArray:index:removeCount:createArrayBlock:
 Splices an array. More...
 
(int) + spliceWithArrayAndIndexAndAddItemsAndCreateArrayBlock
 Splices an array. More...
 
(int) + spliceWithArrayAndIndexAndRemoveCountAndAddItemsAndCreateArrayBlock
 Splices an array. More...
 
(int) + spliceWithArrayAndIndexAndRemoveCountAndCreateArrayBlock
 Splices an array. More...
 
(NSMutableArray *) + toIntArrayWithIntList:
 Converts a list of int values to an array of int values. More...
 
(NSMutableArray< id > *) + toListWithArray:
 Converts an array to a list. More...
 
(NSMutableArray *) + toLongArrayWithLongList:
 Converts a list of long values to an array of long values. More...
 
(NSMutableArray *) + toStringArrayWithStringList:
 Converts a list of string values to an array of string values. More...
 
(void) + treeFindLeavesWithRoot:childrenCallback:nodeCallback:
 Enumerates over all nodes in the tree, invoking the callback for each one. More...
 
(void) + treeFindLeavesWithRoot:childrenCallbackBlock:nodeCallbackBlock:
 Enumerates over all nodes in the tree, invoking the callback for each one. More...
 
(id+ treeFindLeavesWithRootAndChildrenCallbackBlockAndNodeCallbackBlock
 Enumerates over all nodes in the tree, invoking the callback for each one. More...
 
(void) + treeSearchWithRoot:childrenCallback:nodeCallback:
 Enumerates over all nodes in the tree, invoking the callback for each one. More...
 
(void) + treeSearchWithRoot:childrenCallbackBlock:nodeCallbackBlock:
 Enumerates over all nodes in the tree, invoking the callback for each one. More...
 
(id+ treeSearchWithRootAndChildrenCallbackBlockAndNodeCallbackBlock
 Enumerates over all nodes in the tree, invoking the callback for each one. More...
 
(FMLiveSwitchUtility *) + utility
 

Detailed Description

Utility methods.

Method Documentation

◆ cloneIntArray:

+ (NSMutableArray*) cloneIntArray: (NSMutableArray *)  intArray

Clones an array of int values.

Parameters
intArrayAn array of int values.

◆ cloneLongArray:

+ (NSMutableArray*) cloneLongArray: (NSMutableArray *)  longArray

Clones an array of long values.

Parameters
longArrayAn array of long values.

◆ cloneStringArray:

+ (NSMutableArray*) cloneStringArray: (NSMutableArray *)  stringArray

Clones an array of string values.

Parameters
stringArrayAn array of string values.

◆ cloneWithList:

+ (NSMutableArray<id>*) cloneWithList: (NSMutableArray< id > *)  list

Clones the specified list.

Parameters
listThe list.

◆ firstOrDefaultWithArray:

+ (id) firstOrDefaultWithArray: (NSMutableArray *)  array

Gets the first element in the array or the default value if the array is null or empty.

Parameters
arrayThe array.

◆ firstOrDefaultWithList:

+ (id) firstOrDefaultWithList: (NSMutableArray< id > *)  list

Gets the first element in the list or the default value if the list is null or empty.

Parameters
listThe list.

◆ formatDoubleAsPercent:decimalPlaces:

+ (NSString*) formatDoubleAsPercent: (double)  value
decimalPlaces: (int)  decimalPlaces 

Formats a double as a percentage string.

Parameters
valueThe value.
decimalPlacesThe number of decimal places to include.

◆ generateId

+ (NSString*) generateId

Generates a globally unique identifier with no hyphens.

Returns
A globally unique identifier with no hyphens.

◆ generateSynchronizationSource

+ (long long) generateSynchronizationSource

Generates a synchronization source.

◆ generateTieBreaker

+ (NSString*) generateTieBreaker

Generates a tie-breaker.

Returns
A tie-breaker.
Deprecated:
Use GenerateId instead.

◆ getRtpSequenceNumberDeltaWithRtpSequenceNumber:lastRtpSequenceNumber:

+ (int) getRtpSequenceNumberDeltaWithRtpSequenceNumber: (int)  rtpSequenceNumber
lastRtpSequenceNumber: (int)  lastRtpSequenceNumber 

Retrieves the difference between two RTP sequence numbers while accounting for overflow rollover.

Parameters
rtpSequenceNumberThe current RTP sequence number.
lastRtpSequenceNumberThe last (previous) RTP sequence number.
Returns
The difference between the two RTP sequence numbers.

◆ getRtpTimestampDeltaWithRtpTimestamp:lastRtpTimestamp:

+ (long long) getRtpTimestampDeltaWithRtpTimestamp: (long long)  rtpTimestamp
lastRtpTimestamp: (long long)  lastRtpTimestamp 

Retrieves the difference between two RTP timestamps while accounting for overflow rollover.

Parameters
rtpTimestampThe current RTP timestamp.
lastRtpTimestampThe last (previous) RTP timestamp.
Returns
The difference between the two RTP timestamps.

◆ init

- (instancetype) init

◆ lastOrDefaultWithArray:

+ (id) lastOrDefaultWithArray: (NSMutableArray *)  array

Gets the last element in the array or the default value if the array is null or empty.

Parameters
arrayThe array.

◆ lastOrDefaultWithList:

+ (id) lastOrDefaultWithList: (NSMutableArray< id > *)  list

Gets the last element in the list or the default value if the list is null or empty.

Parameters
listThe list.

◆ nullableLongEqualsWithLong1:long2:

+ (bool) nullableLongEqualsWithLong1: (FMLiveSwitchNullableLong *)  long1
long2: (FMLiveSwitchNullableLong *)  long2 

Compares two nullable longs for equality.

Parameters
long1The first long value.
long2The second long value.

◆ singleOrDefaultWithArray:

+ (id) singleOrDefaultWithArray: (NSMutableArray *)  array

Gets the only element in the array or the default value if the array is null or does not have exactly one value.

Parameters
arrayThe array.

◆ singleOrDefaultWithList:

+ (id) singleOrDefaultWithList: (NSMutableArray< id > *)  list

Gets the only element in the list or the default value if the list is null or does not have exactly one value.

Parameters
listThe list.

◆ spliceWithArray:index:addItems:createArray:

+ (NSMutableArray*) spliceWithArray: (NSMutableArray *)  array
index: (int)  index
addItems: (NSMutableArray *)  addItems
createArray: (FMLiveSwitchFunction1< id, NSMutableArray * > *)  createArray 

Splices an array.

Parameters
arrayThe array.
indexThe splice index.
addItemsThe items to add.
createArrayA function that creates an array of the given size.

◆ spliceWithArray:index:addItems:createArrayBlock:

+ (NSMutableArray*) spliceWithArray: (NSMutableArray *)  array
index: (int)  index
addItems: (NSMutableArray *)  addItems
createArrayBlock: (NSMutableArray *(^)(int))  createArrayBlock 

Splices an array.

Parameters
arrayThe array.
indexThe splice index.
addItemsThe items to add.
createArrayBlockA function that creates an array of the given size.

◆ spliceWithArray:index:removeCount:addItems:createArray:

+ (NSMutableArray*) spliceWithArray: (NSMutableArray *)  array
index: (int)  index
removeCount: (int)  removeCount
addItems: (NSMutableArray *)  addItems
createArray: (FMLiveSwitchFunction1< id, NSMutableArray * > *)  createArray 

Splices an array.

Parameters
arrayThe array.
indexThe splice index.
removeCountThe number of items to remove.
addItemsThe items to add.
createArrayA function that creates an array of the given size.

◆ spliceWithArray:index:removeCount:addItems:createArrayBlock:

+ (NSMutableArray*) spliceWithArray: (NSMutableArray *)  array
index: (int)  index
removeCount: (int)  removeCount
addItems: (NSMutableArray *)  addItems
createArrayBlock: (NSMutableArray *(^)(int))  createArrayBlock 

Splices an array.

Parameters
arrayThe array.
indexThe splice index.
removeCountThe number of items to remove.
addItemsThe items to add.
createArrayBlockA function that creates an array of the given size.

◆ spliceWithArray:index:removeCount:createArray:

+ (NSMutableArray*) spliceWithArray: (NSMutableArray *)  array
index: (int)  index
removeCount: (int)  removeCount
createArray: (FMLiveSwitchFunction1< id, NSMutableArray * > *)  createArray 

Splices an array.

Parameters
arrayThe array.
indexThe splice index.
removeCountThe number of items to remove.
createArrayA function that creates an array of the given size.

◆ spliceWithArray:index:removeCount:createArrayBlock:

+ (NSMutableArray*) spliceWithArray: (NSMutableArray *)  array
index: (int)  index
removeCount: (int)  removeCount
createArrayBlock: (NSMutableArray *(^)(int))  createArrayBlock 

Splices an array.

Parameters
arrayThe array.
indexThe splice index.
removeCountThe number of items to remove.
createArrayBlockA function that creates an array of the given size.

◆ spliceWithArrayAndIndexAndAddItemsAndCreateArrayBlock

+ (int) spliceWithArrayAndIndexAndAddItemsAndCreateArrayBlock

Splices an array.

@inlineparam array The array. @inlineparam index The splice index. @inlineparam addItems The items to add. @inlineparam createArrayBlock A function that creates an array of the given size.

◆ spliceWithArrayAndIndexAndRemoveCountAndAddItemsAndCreateArrayBlock

+ (int) spliceWithArrayAndIndexAndRemoveCountAndAddItemsAndCreateArrayBlock

Splices an array.

@inlineparam array The array. @inlineparam index The splice index. @inlineparam removeCount The number of items to remove. @inlineparam addItems The items to add. @inlineparam createArrayBlock A function that creates an array of the given size.

◆ spliceWithArrayAndIndexAndRemoveCountAndCreateArrayBlock

+ (int) spliceWithArrayAndIndexAndRemoveCountAndCreateArrayBlock

Splices an array.

@inlineparam array The array. @inlineparam index The splice index. @inlineparam removeCount The number of items to remove. @inlineparam createArrayBlock A function that creates an array of the given size.

◆ toIntArrayWithIntList:

+ (NSMutableArray*) toIntArrayWithIntList: (NSMutableArray< id > *)  intList

Converts a list of int values to an array of int values.

Parameters
intListA list of int values.

◆ toListWithArray:

+ (NSMutableArray<id>*) toListWithArray: (NSMutableArray *)  array

Converts an array to a list.

Parameters
arrayThe array.

◆ toLongArrayWithLongList:

+ (NSMutableArray*) toLongArrayWithLongList: (NSMutableArray< id > *)  longList

Converts a list of long values to an array of long values.

Parameters
longListA list of long values.

◆ toStringArrayWithStringList:

+ (NSMutableArray*) toStringArrayWithStringList: (NSMutableArray< NSString * > *)  stringList

Converts a list of string values to an array of string values.

Parameters
stringListA list of string values.

◆ treeFindLeavesWithRoot:childrenCallback:nodeCallback:

+ (void) treeFindLeavesWithRoot: (id root
childrenCallback: (FMLiveSwitchFunction1< id, NSMutableArray * > *)  childrenCallback
nodeCallback: (FMLiveSwitchAction1< id > *)  nodeCallback 

Enumerates over all nodes in the tree, invoking the callback for each one.

Parameters
rootThe root.
childrenCallbackThe children callback.
nodeCallbackThe node callback.

◆ treeFindLeavesWithRoot:childrenCallbackBlock:nodeCallbackBlock:

+ (void) treeFindLeavesWithRoot: (id root
childrenCallbackBlock: (NSMutableArray *(^)(id))  childrenCallbackBlock
nodeCallbackBlock: (void(^)(id))  nodeCallbackBlock 

Enumerates over all nodes in the tree, invoking the callback for each one.

Parameters
rootThe root.
childrenCallbackBlockThe children callback.
nodeCallbackBlockThe node callback.

◆ treeFindLeavesWithRootAndChildrenCallbackBlockAndNodeCallbackBlock

+ (id) treeFindLeavesWithRootAndChildrenCallbackBlockAndNodeCallbackBlock

Enumerates over all nodes in the tree, invoking the callback for each one.

@inlineparam root The root. @inlineparam childrenCallbackBlock The children callback. @inlineparam nodeCallbackBlock The node callback.

◆ treeSearchWithRoot:childrenCallback:nodeCallback:

+ (void) treeSearchWithRoot: (id root
childrenCallback: (FMLiveSwitchFunction1< id, NSMutableArray * > *)  childrenCallback
nodeCallback: (FMLiveSwitchAction1< id > *)  nodeCallback 

Enumerates over all nodes in the tree, invoking the callback for each one.

Parameters
rootThe root.
childrenCallbackThe children callback.
nodeCallbackThe node callback.

◆ treeSearchWithRoot:childrenCallbackBlock:nodeCallbackBlock:

+ (void) treeSearchWithRoot: (id root
childrenCallbackBlock: (NSMutableArray *(^)(id))  childrenCallbackBlock
nodeCallbackBlock: (void(^)(id))  nodeCallbackBlock 

Enumerates over all nodes in the tree, invoking the callback for each one.

Parameters
rootThe root.
childrenCallbackBlockThe children callback.
nodeCallbackBlockThe node callback.

◆ treeSearchWithRootAndChildrenCallbackBlockAndNodeCallbackBlock

+ (id) treeSearchWithRootAndChildrenCallbackBlockAndNodeCallbackBlock

Enumerates over all nodes in the tree, invoking the callback for each one.

@inlineparam root The root. @inlineparam childrenCallbackBlock The children callback. @inlineparam nodeCallbackBlock The node callback.

◆ utility

+ (FMLiveSwitchUtility*) utility