GCKDeviceProvider Class

GCKDeviceProvider Class Reference

Overview

An abstract base class for performing device discovery and session construction.

Support for additional device types can be added by extending this class. See the GCKDeviceProvider(Protected) category for a list of helper methods intended for use by subclasses. New device providers are registered with the framework using registerDeviceProvider: (GCKCastContext).

Since
3.0

Inherits NSObject.

Instance Method Summary

(instancetype) - initWithDeviceCategory:
 Designated initializer. More...
 
(void) - startDiscovery
 Starts a new discovery scan. More...
 
(void) - stopDiscovery
 Stops the discovery scan. More...
 
(GCKSession *) - createSessionForDevice:sessionID:
 Constructs a new session for the given device and optionally an existing session ID. More...
 
(void) - notifyDidStartDiscovery
 Notifies the discovery manager that discovery has started. More...
 
(void) - notifyDidPublishDevice:
 Notifies the discovery manager that a new device has been published. More...
 
(void) - notifyDidUnpublishDevice:
 Notifies the discovery manager that a previously-published device has been unpublished, because it is no longer available. More...
 
(void) - notifyDidUpdateDevice:
 Notifies the discovery manager that one or more of a previously-published device's display attributes (such as friendly name or icons) have changed. More...
 
(GCKDevice *) - createDeviceWithID:ipAddress:servicePort:
 Factory method for constructing new GCKDevice instances. More...
 

Property Summary

NSString * deviceCategory
 A string that uniquely identifies the type of device that will be discovered by this provider. More...
 
BOOL passiveScan
 Whether the scan should be a passive scan. More...
 
NSArray< GCKDevice * > * devices
 The array of discovered devices. More...
 

Method Detail

- (instancetype) initWithDeviceCategory: (NSString *)  deviceCategory

Designated initializer.

Constructs a new GCKDeviceProvider for devices of the specified type.

Parameters
deviceCategoryA string that uniquely identifies the type of device that is managed by by this provider.
- (void) startDiscovery

Starts a new discovery scan.

This is (commonly) an asynchronous operation. If any of the devices discovered by the previous scan are no longer valid, the provider should unpublish them at this time. Must be overridden by subclasses.

The provider must notify the discovery manager once the scan has been started (and any stale devices have been unpublished) by calling notifyDidStartDiscovery (GCKDeviceProvider(Protected)). If a particular implementation of this method has no asynchronous work to do when starting a scan, it can call the notification method directly before returning.

- (void) stopDiscovery

Stops the discovery scan.

Must be overridden by subclasses.

- (GCKSession *) createSessionForDevice: (GCKDevice *)  device
sessionID: (NSString *__nullable)  sessionID 

Constructs a new session for the given device and optionally an existing session ID.

Must be overridden by subclasses.

Parameters
deviceThe device to connect to.
sessionIDThe ID of the session to resume; or nil to start a new session.
- (void) notifyDidStartDiscovery

Notifies the discovery manager that discovery has started.

Provided by category GCKDeviceProvider(Protected).

- (void) notifyDidPublishDevice: (GCKDevice *)  device

Notifies the discovery manager that a new device has been published.

Provided by category GCKDeviceProvider(Protected).

- (void) notifyDidUnpublishDevice: (GCKDevice *)  device

Notifies the discovery manager that a previously-published device has been unpublished, because it is no longer available.

Provided by category GCKDeviceProvider(Protected).

- (void) notifyDidUpdateDevice: (GCKDevice *)  device

Notifies the discovery manager that one or more of a previously-published device's display attributes (such as friendly name or icons) have changed.

Provided by category GCKDeviceProvider(Protected).

- (GCKDevice *) createDeviceWithID: (NSString *)  deviceID
ipAddress: (NSString *)  ipAddress
servicePort: (uint16_t)  servicePort 

Factory method for constructing new GCKDevice instances.

The parameters correspond to immutable properties of a GCKDevice.

Parameters
deviceIDThe unique ID identifying this device. This value must be unique among all GCKDevice objects that are created by this provider.
ipAddressThe IP address of the device, in numeric form (for example, @"10.0.0.10"). May not be nil.
servicePortThe service port on which connections should be made to this device. May be 0 if a service port is not applicable.

Provided by category GCKDeviceProvider(Protected).

Property Detail

- (NSString*) deviceCategory
readnonatomiccopy

A string that uniquely identifies the type of device that will be discovered by this provider.

- (BOOL) passiveScan
readwritenonatomicassign

Whether the scan should be a passive scan.

A passive scan sends discovery queries less frequently, so it is more efficient, but the results will not be as fresh. It's appropriate to do a passive scan when the user is not actively selecting a Cast target. Not all implementations will honor this property.

- (NSArray<GCKDevice *>*) devices
readnonatomiccopy

The array of discovered devices.