diff options
author | NicoleYarroch <nicole@livio.io> | 2017-10-04 14:58:34 -0400 |
---|---|---|
committer | NicoleYarroch <nicole@livio.io> | 2017-10-04 14:58:34 -0400 |
commit | 6b227f787f9b2de692869e8df42954f74d6332e8 (patch) | |
tree | 1035f0b875059625ab64469c83fb2b5bb48eb925 | |
parent | e1028fe45ecc934decb83f1e632d16168992a96d (diff) | |
download | sdl_ios-6b227f787f9b2de692869e8df42954f74d6332e8.tar.gz |
Working with iOS11 and iOS10
Signed-off-by: NicoleYarroch <nicole@livio.io>
-rw-r--r-- | SmartDeviceLink/SDLLifecycleManager.m | 24 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaLifecycleManager.m | 84 |
2 files changed, 63 insertions, 45 deletions
diff --git a/SmartDeviceLink/SDLLifecycleManager.m b/SmartDeviceLink/SDLLifecycleManager.m index 759a576d5..3c5e250d1 100644 --- a/SmartDeviceLink/SDLLifecycleManager.m +++ b/SmartDeviceLink/SDLLifecycleManager.m @@ -71,6 +71,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; // Private properties @property (copy, nonatomic) SDLManagerReadyBlock readyHandler; +@property (assign, nonatomic) BOOL firstHMINonNoneOccurred; @end @@ -104,6 +105,7 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; _notificationDispatcher = [[SDLNotificationDispatcher alloc] init]; _responseDispatcher = [[SDLResponseDispatcher alloc] initWithNotificationDispatcher:_notificationDispatcher]; _registerResponse = nil; + _firstHMINonNoneOccurred = NO; // Managers _fileManager = [[SDLFileManager alloc] initWithConnectionManager:self]; @@ -183,9 +185,6 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; } #pragma clang diagnostic pop - if (self.streamManager != nil) { - [self.streamManager startWithProtocol:self.proxy.protocol]; - } } - (void)didEnterStateStopped { @@ -443,6 +442,16 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; return YES; } +- (void)sdl_onFirstHMINonNone { + // If we are a nav / projection app and desire to stream, we need to be in HMI background, limited, or full and perform additional setup when that occurs + if (self.streamManager == nil) { + return; + } + + [self.streamManager startWithProtocol:self.proxy.protocol]; +} + + #pragma mark SDL notification observers - (void)transportDidConnect { @@ -452,6 +461,8 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; - (void)transportDidDisconnect { SDLLogD(@"Transport Disconnected"); + self.firstHMINonNoneOccurred = NO; + if (self.lifecycleState == SDLLifecycleStateUnregistering || self.lifecycleState == SDLLifecycleStateStopped) { [self.lifecycleStateMachine transitionToState:SDLLifecycleStateStopped]; } else { @@ -475,7 +486,12 @@ SDLLifecycleState *const SDLLifecycleStateReady = @"Ready"; self.systemContext = hmiStatusNotification.systemContext; SDLLogD(@"HMI level changed from %@ to %@", oldHMILevel, self.hmiLevel); - + + if (!self.firstHMINonNoneOccurred && ![self.hmiLevel isEqualToEnum:SDLHMILevelNone]) { + self.firstHMINonNoneOccurred = YES; + [self sdl_onFirstHMINonNone]; + } + if ([self.lifecycleStateMachine isCurrentState:SDLLifecycleStateSettingUpHMI]) { [self.lifecycleStateMachine transitionToState:SDLLifecycleStateReady]; } diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index c623bc7a8..f801c8b41 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -154,6 +154,43 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N } else { SDLLogV(@"Not adding protocol to table"); } + + __weak typeof(self) weakSelf = self; + [self sdl_requestVideoCapabilities:^(SDLVideoStreamingCapability * _Nullable capability) { + SDLLogD(@"Received video capability response"); + SDLLogV(@"%@", capability); + if (capability != nil) { + // If we got a response, get our preferred formats and resolutions + weakSelf.preferredFormats = capability.supportedFormats; + weakSelf.preferredResolutions = @[capability.preferredResolution]; + + if (weakSelf.dataSource != nil) { + SDLLogV(@"Calling data source for modified preferred formats and resolutions"); + weakSelf.preferredFormats = [weakSelf.dataSource preferredVideoFormatOrderFromHeadUnitPreferredOrder:weakSelf.preferredFormats]; + weakSelf.preferredResolutions = [weakSelf.dataSource resolutionFromHeadUnitPreferredResolution:weakSelf.preferredResolutions.firstObject]; + } + + if (weakSelf.hapticInterface != nil) { + weakSelf.hapticInterface.enableHapticDataRequests = capability.hapticSpatialDataSupported.boolValue; + } + + SDLLogD(@"Got specialized video capabilites, preferred formats: %@, resolutions: %@ haptics enabled %@", weakSelf.preferredFormats, weakSelf.preferredResolutions, (capability.hapticSpatialDataSupported.boolValue ? @"YES" : @"NO")); + } else { + // If we can't get capabilities, we're assuming it's H264 RAW at whatever the display capabilities said in the RAIR. We also aren't going to call the data source because they have no options. + SDLVideoStreamingFormat *format = [[SDLVideoStreamingFormat alloc] initWithCodec:SDLVideoStreamingCodecH264 protocol:SDLVideoStreamingProtocolRAW]; + SDLImageResolution *resolution = [[SDLImageResolution alloc] initWithWidth:weakSelf.screenSize.width height:weakSelf.screenSize.height]; + weakSelf.preferredFormats = @[format]; + weakSelf.preferredResolutions = @[resolution]; + + if (weakSelf.hapticInterface != nil) { + weakSelf.hapticInterface.enableHapticDataRequests = NO; + } + + SDLLogD(@"Using generic video capabilites, preferred formats: %@, resolutions: %@, haptics disabled", weakSelf.preferredFormats, weakSelf.preferredResolutions); + } + + [weakSelf sdl_startVideoSession]; + }]; } - (void)stop { @@ -311,42 +348,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N SDLLogD(@"Video stream starting"); self.restartVideoStream = NO; - __weak typeof(self) weakSelf = self; - [self sdl_requestVideoCapabilities:^(SDLVideoStreamingCapability * _Nullable capability) { - SDLLogD(@"Received video capability response"); - SDLLogV(@"%@", capability); - if (capability != nil) { - // If we got a response, get our preferred formats and resolutions - weakSelf.preferredFormats = capability.supportedFormats; - weakSelf.preferredResolutions = @[capability.preferredResolution]; - - if (weakSelf.dataSource != nil) { - SDLLogV(@"Calling data source for modified preferred formats and resolutions"); - weakSelf.preferredFormats = [weakSelf.dataSource preferredVideoFormatOrderFromHeadUnitPreferredOrder:weakSelf.preferredFormats]; - weakSelf.preferredResolutions = [weakSelf.dataSource resolutionFromHeadUnitPreferredResolution:weakSelf.preferredResolutions.firstObject]; - } - - if (weakSelf.hapticInterface != nil) { - weakSelf.hapticInterface.enableHapticDataRequests = capability.hapticSpatialDataSupported.boolValue; - } - - SDLLogD(@"Got specialized video capabilites, preferred formats: %@, resolutions: %@ haptics enabled %@", weakSelf.preferredFormats, weakSelf.preferredResolutions, (capability.hapticSpatialDataSupported.boolValue ? @"YES" : @"NO")); - } else { - // If we can't get capabilities, we're assuming it's H264 RAW at whatever the display capabilities said in the RAIR. We also aren't going to call the data source because they have no options. - SDLVideoStreamingFormat *format = [[SDLVideoStreamingFormat alloc] initWithCodec:SDLVideoStreamingCodecH264 protocol:SDLVideoStreamingProtocolRAW]; - SDLImageResolution *resolution = [[SDLImageResolution alloc] initWithWidth:weakSelf.screenSize.width height:weakSelf.screenSize.height]; - weakSelf.preferredFormats = @[format]; - weakSelf.preferredResolutions = @[resolution]; - - if (weakSelf.hapticInterface != nil) { - weakSelf.hapticInterface.enableHapticDataRequests = NO; - } - - SDLLogD(@"Using generic video capabilites, preferred formats: %@, resolutions: %@, haptics disabled", weakSelf.preferredFormats, weakSelf.preferredResolutions); - } - - [weakSelf sdl_startVideoSession]; - }]; + [self sdl_sendVideoStartService]; } - (void)didEnterStateVideoStreamReady { @@ -592,11 +594,11 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N SDLLogD(@"HMI level changed from level %@ to level %@", self.hmiLevel, hmiStatus.hmiLevel); self.hmiLevel = hmiStatus.hmiLevel; -// if (self.isHmiStateVideoStreamCapable) { -// [self sdl_startVideoSession]; -// } else { -// [self sdl_stopVideoSession]; -// } + if (self.isHmiStateVideoStreamCapable) { + [self sdl_startVideoSession]; + } else { + [self sdl_stopVideoSession]; + } if (self.isHmiStateAudioStreamCapable) { [self sdl_startAudioSession]; |