-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc44966
commit bfe3b69
Showing
29 changed files
with
2,372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
BlockRunner | ||
=========== | ||
|
||
Abstracts and encapsulates asynchrony, that is how and where blocks are | ||
run. Using this protocol, you can easily change which dispatch queue or | ||
``NSOperationQueue`` delegate blocks are run on, instead of hard-coding | ||
``dispatch_async(dispatch_get_main_queue(), ^{ });``. For example: | ||
|
||
.. code-block:: objc | ||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0); | ||
AppStateChangeNotifier *notifier = [AppStateChangeNotifier new]; | ||
notifier.blockRunner = [[DispatchQueueBlockRunner alloc] initWithDispatchQueue:queue]; | ||
Another great use case is turning asynchronous tests into synchronous, | ||
making them faster and easier: | ||
|
||
.. code-block:: objc | ||
- (void)testStartListeningShouldSubscribeToDidBackgroundEvent { | ||
AppStateChangeNotifier *notifier = [AppStateChangeNotifier new]; | ||
notifier.blockRunner = [SynchronousBlockRunner new]; | ||
[notifier startListening]; | ||
__block BOOL verified = NO; | ||
notifier.didBackgroundBlock = ^{ | ||
verified = YES; | ||
}; | ||
[self postNotificationName:UIApplicationDidEnterBackgroundNotification]; | ||
XCTAssertTrue(verified, @"didBackgroundBlock should be called"); | ||
} | ||
Here we use the synchronous block runner (instead of the default | ||
asynchronous, main queue one) to avoid writing asynchronous tests with | ||
``XCTestExpectation``. | ||
|
||
Methods | ||
------- | ||
|
||
\- (void) **runBlock**:(nonnull `VoidBlock <#VoidBlock>`__)\ *block* | ||
Runs the given ``block`` somewhere, depending on the concrete | ||
implementation. | ||
|
||
**Parameters:** | ||
|
||
* block – block to run; must not be ``nil``. | ||
|
||
\- (void) **runBlock**:(nonnull `VoidBlock <#VoidBlock>`__)\ *block* | ||
Runs the given ``block`` somewhere, depending on the concrete | ||
implementation. | ||
|
||
**Parameters:** | ||
|
||
* block – block to run; must not be ``nil``. | ||
|
||
Typedefs | ||
-------- | ||
|
||
VoidBlock | ||
~~~~~~~~~ | ||
|
||
void(^)(void) | ||
|
||
A type for blocks without arguments and no return value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
CapabilityFilter | ||
================ | ||
|
||
CapabilityFilter is an object that wraps an NSArray of required | ||
capabilities. This CapabilityFilter is used for determining which | ||
devices will appear in DiscoveryManager's compatibleDevices array. The | ||
contents of a CapabilityFilter's array must be any of the string | ||
constants defined in the Capability header files. | ||
|
||
CapabilityFilter values | ||
----------------------- | ||
|
||
Here are some examples of values for the Capability constants. | ||
|
||
* kMediaPlayerPlayVideo = "MediaPlayer.Display.Video" | ||
* kMediaPlayerDisplayImage = "MediaPlayer.Display.Image" | ||
* kVolumeControlSubscribe = "VolumeControl.Subscribe" | ||
* kMediaControlAny = "Media.Control.Any" | ||
|
||
All Capability header files also define a constant array of all | ||
capabilities defined in that header (ex. kVolumeControlCapabilities). | ||
|
||
AND/OR Filtering | ||
---------------- | ||
|
||
CapabilityFilter is an AND filter. A ConnectableDevice would need to | ||
satisfy all conditions of a CapabilityFilter to pass. | ||
|
||
[DiscoveryManager capabilityFilters] is an OR filter. a | ||
ConnectableDevice only needs to satisfy one condition (CapabilityFilter) | ||
to pass. | ||
|
||
Examples | ||
-------- | ||
|
||
Filter for all devices that support video playback AND any media | ||
controls AND volume up/down. | ||
|
||
.. code-block:: objc | ||
NSArray *capabilities = @[ | ||
kMediaPlayerPlayVideo, | ||
kMediaControlAny, | ||
kVolumeControlVolumeUpDown | ||
]; | ||
CapabilityFilter *filter = | ||
[CapabilityFilter filterWithCapabilities:capabilities]; | ||
[[DiscoveryManager sharedManager] setCapabilityFilters:@[filter]]; | ||
Filter for all devices that support (video playback AND any media | ||
controls AND volume up/down) OR (image display). | ||
|
||
.. code-block:: objc | ||
NSArray *videoCapabilities = @[ | ||
kMediaPlayerPlayVideo, | ||
kMediaControlAny, | ||
kVolumeControlVolumeUpDown | ||
]; | ||
NSArray *imageCapabilities = @[ | ||
kMediaPlayerDisplayImage | ||
]; | ||
CapabilityFilter *videoFilter = | ||
[CapabilityFilter filterWithCapabilities:videoCapabilities]; | ||
CapabilityFilter *imageFilter = | ||
[CapabilityFilter filterWithCapabilities:imageCapabilities]; | ||
[[DiscoveryManager sharedManager] setCapabilityFilters:@[videoFilter, imageFilter]]; | ||
Properties | ||
---------- | ||
|
||
NSArray \* capabilities | ||
Array of capabilities required by this filter. This property is | ||
readonly use the addCapability or addCapabilities to build this | ||
object. | ||
|
||
Methods | ||
------- | ||
|
||
\+ (`CapabilityFilter </apis/1-6-0/ios/CapabilityFilter>`__ \*) **filterWithCapabilities**:(NSArray \*)\ *capabilities* | ||
Create a CapabilityFilter with the given array required capabilities. | ||
|
||
**Parameters** | ||
|
||
* capabilities – Capabilities to be added to the new filter | ||
|
||
\- (void) **addCapability**:(NSString \*)\ *capability* | ||
Add a required capability to the filter. | ||
|
||
**Parameters** | ||
|
||
* capability – Capability name to add (see capability header files for NSString constants) | ||
|
||
\- (void) **addCapabilities**:(NSArray \*)\ *capabilities* | ||
Add array of required capabilities to the filter. | ||
|
||
**Parameters** | ||
|
||
* capabilities – List of capability names (see capability header files for NSString constants) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
CapabilityPriorityLevel | ||
======================= | ||
|
||
CapabilityPriorityLevel values are used by ConnectableDevice to find the | ||
most suitable DeviceService capability to be presented to the user. | ||
Values of VeryLow and VeryHigh are not in use internally the SDK. | ||
Connect SDK uses Low, Normal, and High internally. | ||
|
||
Default behavior: If you are unsatisfied with the default priority | ||
levels & behavior of Connect SDK, it is possible to subclass a | ||
particular DeviceService and provide your own value for each capability. | ||
That DeviceService subclass would need to be registered with | ||
DiscoveryManager. | ||
|
||
Properties | ||
---------- | ||
|
||
**CapabilityPriorityLevelVeryLow** | ||
|
||
**CapabilityPriorityLevelLow** | ||
|
||
**CapabilityPriorityLevelNormal** | ||
|
||
**CapabilityPriorityLevelHigh** | ||
|
||
**CapabilityPriorityLevelVeryHigh** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
CastService | ||
=========== | ||
|
||
*extends* :doc:`DeviceService <ios-deviceservice>` | ||
|
||
CastService provides capabilities for Google Chromecast devices. | ||
CastService acts as a layer on top of Google's own Cast SDK, and | ||
requires the Cast SDK library to function. CastService provides the | ||
following functionality: | ||
|
||
* Media playback | ||
* Media control | ||
* Web app launching & two-way communication | ||
* Volume control | ||
|
||
Using Connect SDK for discovery/control of Chromecast devices will | ||
result in your app complying with the Google Cast SDK `terms of | ||
service <https://developers.google.com/cast/docs/terms>`__. | ||
|
||
To learn more about Cast SDK, visit the `Google Cast SDK Developer | ||
site <https://developers.google.com/cast/>`__. | ||
|
||
Properties | ||
---------- | ||
|
||
GCKDeviceManager \* castDeviceManager | ||
The GCKDeviceManager that CastService is using internally to manage | ||
devices. | ||
|
||
GCKDevice \* castDevice | ||
The GCKDevice object that CastService is using internally for device | ||
information. | ||
|
||
CastServiceChannel \* castServiceChannel | ||
The CastServiceChannel is used for app-to-app communication that is | ||
handling by the Connect SDK JavaScript Bridge. | ||
|
||
GCKMediaControlChannel \* castMediaControlChannel | ||
The GCKMediaControlChannel that the CastService is using to send | ||
media events to the connected web app. | ||
|
||
NSString \* castWebAppId | ||
The CastService will launch the specified web app id. | ||
|
||
Inherited Methods | ||
----------------- | ||
|
||
\+ (NSDictionary \*) **discoveryParameters** | ||
A dictionary of keys/values that will be used by the | ||
DiscoveryProvider used to discover this DeviceService. Some keys that | ||
are used are: service name, SSDP filter, etc. | ||
|
||
\+ (:doc:`DeviceService <ios-deviceservice>` \*) **deviceServiceWithClass**:(Class)\ *\_class* **serviceConfig**:(ServiceConfig \*)\ *serviceConfig* | ||
**Parameters:** | ||
|
||
* \_class | ||
* **serviceConfig**: serviceConfig | ||
|
||
\+ (BOOL) **shouldDisconnectOnBackground** | ||
Static property that determines whether a DeviceService subclass | ||
should shut down communication channels when the app enters a | ||
background state. This may be helpful for apps that need to | ||
communicate with web apps from the background. This property may not | ||
be applicable to all DeviceService subclasses. | ||
|
||
Sets the shouldDisconnectOnBackground static property. This property | ||
should be set before starting DiscoveryManager for the first time. | ||
|
||
\+ (void) **setShouldDisconnectOnBackround**:(BOOL)\ *shouldDisconnectOnBackground* | ||
**Parameters:** | ||
|
||
* shouldDisconnectOnBackground | ||
|
||
\- (instancetype) **initWithServiceConfig**:(ServiceConfig \*)\ *serviceConfig* | ||
**Parameters:** | ||
|
||
* serviceConfig | ||
|
||
\- (BOOL) **hasCapability**:(NSString \*)\ *capability* | ||
**Parameters:** | ||
|
||
* capability | ||
|
||
\- (BOOL) **hasCapabilities**:(NSArray \*)\ *capabilities* | ||
**Parameters:** | ||
|
||
* capabilities | ||
|
||
\- (BOOL) **hasAnyCapability**:(NSArray \*)\ *capabilities* | ||
**Parameters:** | ||
|
||
* capabilities | ||
|
||
\- (void) **connect** | ||
Will attempt to connect to the DeviceService. The failure/success | ||
will be reported back to the DeviceServiceDelegate. If the connection | ||
attempt reveals that pairing is required, the DeviceServiceDelegate | ||
will also be notified in that event. | ||
|
||
\- (void) **disconnect** | ||
Will attempt to disconnect from the DeviceService. The | ||
failure/success will be reported back to the DeviceServiceDelegate. | ||
|
||
\- (void) **pairWithData**:(id)\ *pairingData* | ||
Will attempt to pair with the DeviceService with the provided | ||
pairingData. The failure/success will be reported back to the | ||
DeviceServiceDelegate. | ||
|
||
**Parameters:** | ||
|
||
* pairingData – | ||
|
||
Data to be used for pairing. The type of this parameter will vary | ||
depending on what type of pairing is required, but is likely to be | ||
a string (pin code, pairing key, etc). | ||
|
||
\- (void) **closeLaunchSession**:(:doc:`LaunchSession <ios-launchsession>` \*)\ *launchSession* **success**:(SuccessBlock)\ *success* **failure**:(FailureBlock)\ *failure* | ||
Every LaunchSession object has an associated DeviceService. | ||
Internally, LaunchSession's close method proxies to it's | ||
DeviceService's closeLaunchSession method. If, for some reason, your | ||
LaunchSession loses it's DeviceService reference, you can call this | ||
closeLaunchSession method directly. | ||
|
||
**Parameters:** | ||
|
||
* launchSession – LaunchSession to be closed | ||
* **success**: success – (optional) SuccessBlock to be called on success | ||
* **failure**: failure – (optional) FailureBlock to be called on failure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ChannelInfo | ||
=========== | ||
|
||
Normalized reference object for information about a TVs channels. This | ||
object is required to set the channel on a TV. | ||
|
||
Properties | ||
---------- | ||
|
||
NSString \* id | ||
TV's unique ID for the channel | ||
|
||
NSString \* name | ||
User-friendly name of the channel | ||
|
||
NSString \* number | ||
TV channel's number (likely to be a combination of the major & minor | ||
numbers) | ||
|
||
int majorNumber | ||
TV channel's major number | ||
|
||
int minorNumber | ||
TV channel's minor number | ||
|
||
id rawData | ||
Raw data from the first screen device about the channel. In most | ||
cases, this is an NSDictionary. | ||
|
||
Methods | ||
------- | ||
|
||
\- (BOOL) **isEqual**:(:doc:`ChannelInfo <ios-channelinfo>` \*)\ *channelInfo* | ||
Compares two ChannelInfo objects. | ||
|
||
**Parameters:** | ||
|
||
* channelInfo – ChannelInfo object to compare. | ||
|
||
**Returns:** YES if both ChannelInfo number & name values are equal |
Oops, something went wrong.