Usage examples
// set access token provider delegate so mobile SDK will be able to retrieve access token when needed
CMAccessTokenProvider.delegate = yourAccessTokenProviderDelegateInstance
// init and start sniffing
let sniffer = CMCameraSniffer(delegate: yourSnifferDelegateInstance)
sniffer.startSniffing()
// search for device manually if sniffer cannot detect it automatically
sniffer.searchDeviceManually(at: ipAddressOfCamera)
// init wizard and add some device
let wizard = CMCameraWizard(delegate: yourWizardDelegateInstance)
wizard.addDevice(someDeviceReturnedBySniffer, named: nameForNewCamera, atZone: someZoneIdFetchedByYou)
// prepare streamer
let streamer = CMCameraStreamer(layer: someLayerToRenderPictureIn)
streamer.delegate = yourCameraStreamerDelegate
streamer.renderMode = CMCameraStreamerRenderModeAspectFit
streamer.currentItem = CMStreamerItem.init(cameraId: cameraIdFetchedByYou, recordingId: recordingIdFetchedByYou)
// wait until status will change to readyToPlay, after that you can manipulate with playback
if streamer.status == CMCameraStreamerStatusReadyToPlay {
streamer.rate = 0.0 // pause stream.
streamer.rate = 1.0 // play stream at rate x1.
}
// you can seek if seeking capability is supported
let seekingSupported = UInt8(streamer.currentItem.capabilitiesMask.rawValue) & UInt8(CMStreamerItemCapabilitiesMaskCanSeek.rawValue) > 0
if seekingSupported {
streamer.seek(to: streamer.currentItem.duration * 0.5) // seek to middle of footage.
}
// you can step if stepping capability is supported
let steppingSupported = UInt8(streamer.currentItem.capabilitiesMask.rawValue) & UInt8(CMStreamerItemCapabilitiesMaskCanStep.rawValue) > 0
if steppingSupported {
streamer.step(by: 10) // move 10 frames further.
streamer.step(by: -2) // move 2 frames backwards.
}
// you can speedPlay if speedPlay capability is supported
let speedPlaySupported = UInt8(streamer.currentItem.capabilitiesMask.rawValue) & UInt8(CMStreamerItemCapabilitiesMaskCanSpeedPlay.rawValue) > 0
if speedPlaySupported {
streamer.rate = 3.0 // play stream at rate x3.
}
// start and stop sending audio to camera. Note that live stream should be active otherwise you will receive error
let audioStreamingSupported = UInt8(streamer.currentItem.capabilitiesMask.rawValue) & UInt8(CMStreamerItemCapabilitiesMaskCanStreamAudio.rawValue) > 0
if audioStreamingSupported {
streamer.startAudioStreaming()
streamer.stopAudioStreaming()
}
// init Nubocam wizard and add some Nubocam. Check NuboCamWizard page for more information
let nuboCamWizard = CMNuboCamWizard(delegate: yourNuboCamWizardDelegateInstance)
nuboCamWizard.prepareForConnection(with: ["zoneId" : 1234])
nuboCamWizard.connectToCamera() // Note: you should connect to Nubocam's wifi hotspot via iOS Settings app before calling this method
nuboCamWizard.refreshWifiList()
nuboCamWizard.connectCamera(to: wifiReturnedByPreviousMethod, withName: "My first Nubocam")
// init Doorbell wizard and add some Doorbell camera. Check DoorbellWizard page for more information
let doorbellWizard = CMDoorbellWizard(delegate: yourDoorbellWizardDelegateInstance)
doorbellWizard.prepareForConnection(with: ["zoneId" : 1234])
doorbellWizard.connectToCamera() // Note: you should connect to Doorbell's wifi hotspot via iOS Settings app before calling this method
doorbellWizard.refreshWifiList()
doorbellWizard.connectCamera(to: wifiReturnedByPreviousMethod, withName: "My first Doorbell")
// set access token provider delegate so mobile SDK will be able to retrieve access token when needed
CMAccessTokenProvider.delegate = yourAccessTokenProviderDelegateInstance
// init and start sniffing
CMCameraSniffer* sniffer = [[CMCameraSniffer alloc] initWithDelegate:yourSnifferDelegateInstance];
[sniffer startSniffing];
// search for device manually if sniffer cannot detect it automatically
[sniffer searchDeviceManuallyAt: ipAddressOfCamera];
// search for device manually if sniffer cannot detect it automatically
[sniffer searchDeviceManuallyAt: ipAddressOfCamera];
// init wizard and add some device
CMCameraWizard* wizard = [[CMCameraWizard alloc] initWithDelegate:yourWizardDelegateInstance];
[wizard addDevice:someDeviceReturnedBySniffer named:nameForNewCamera atZone:someZoneIdFetchedByYou];
// prepare streamer
let streamer = [[CMCameraStreamer alloc] initWithLayer:someLayerToRenderPictureIn];
streamer.delegate = yourCameraStreamerDelegate;
streamer.renderMode = CMCameraStreamerRenderModeAspectFit;
streamer.currentItem = [CMStreamerItem itemWithCameraId:cameraIdFetchedByYou recordingId:recordingIdFetchedByYou];
// wait until status will change to readyToPlay, after that you can manipulate with playback
if (streamer.status == CMCameraStreamerStatusReadyToPlay) {
streamer.rate = 0.0; // pause stream.
streamer.rate = 1.0; // play stream at rate x1.
}
// you can seek if seeking capability is supported
BOOL seekingSupported = (streamer.currentItem.capabilitiesMask & CMStreamerItemCapabilitiesMaskCanSeek) > 0;
if (seekingSupported) {
[streamer seekTo: streamer.currentItem.duration * 0.5]; // seek to middle of footage.
}
// you can step if stepping capability is supported
BOOL steppingSupported = (streamer.currentItem.capabilitiesMask & CMStreamerItemCapabilitiesMaskCanStep) > 0;
if (steppingSupported) {
[streamer stepBy: 10]; // move 10 frames further.
[streamer stepBy: -2]; // move 2 frames backwards.
}
// you can speedPlay if speedPlay capability is supported
BOOL speedPlaySupported = (streamer.currentItem.capabilitiesMask & CMStreamerItemCapabilitiesMaskCanSpeedPlay) > 0;
if (speedPlaySupported) {
streamer.rate = 3.0; // play stream at rate x3.
}
// start and stop sending audio to camera. Note that live stream should be active otherwise you will receive error
BOOL audioStreamingSupported = (streamer.currentItem.capabilitiesMask & CMStreamerItemCapabilitiesMaskCanStreamAudio) > 0;
if (audioStreamingSupported) {
[streamer startAudioStreaming];
[streamer stopAudioStreaming];
}
// init Nubocam wizard and add some Nubocam. Check NuboCamWizard page for more information
CMNuboCamWizard *nuboCamWizard = [[CMNuboCamWizard alloc] initWithDelegate:yourNuboCamWizardDelegateInstance];
[nuboCamWizard prepareForConnectionWith:@{@"zoneId" : @(1234)}];
[nuboCamWizard connectToCamera]; // Note: you should connect to Nubocam's wifi hotspot via iOS Settings app before calling this method
[nuboCamWizard refreshWifiList];
[nuboCamWizard connectCameraTo:wifiReturnedByPreviousMethod withName:@"My first Nubocam"];
// init Doorbell wizard and add some Doorbell camera. Check DoorbellWizard page for more information
CMDoorbellWizard *doorbellWizard = [[CMDoorbellWizard alloc] initWithDelegate:yourDoorbellWizardDelegateInstance];
[doorbellWizard prepareForConnectionWith:@{@"zoneId" : @(1234)}];
[doorbellWizard connectToCamera]; // Note: you should connect to Doorbell's wifi hotspot via iOS Settings app before calling this method
[doorbellWizard refreshWifiList];
[doorbellWizard connectCameraTo:wifiReturnedByPreviousMethod withName:@"My first Doorbell"];
Updated about 2 years ago