From 9ff12026e1316741bc263de6a16913810888f2ba Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Thu, 29 Mar 2018 13:57:41 -0400 Subject: [PATCH 1/8] Relocated delegate check for resolution in the lifecycle manager --- SmartDeviceLink/SDLStreamingMediaLifecycleManager.m | 12 ++++++++---- .../DevAPISpecs/SDLSoftButtonManagerSpec.m | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index 1fbf64374..2d133a37e 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -347,14 +347,13 @@ - (void)didEnterStateVideoStreamStarting { SDLLogV(@"Capability: %@", capability); if (capability != nil) { - // If we got a response, get our preferred formats and resolutions + // If we got a response, get the head unit's 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"); + SDLLogV(@"Calling data source for modified preferred formats"); weakSelf.preferredFormats = [weakSelf.dataSource preferredVideoFormatOrderFromHeadUnitPreferredOrder:weakSelf.preferredFormats]; - weakSelf.preferredResolutions = [weakSelf.dataSource resolutionFromHeadUnitPreferredResolution:weakSelf.preferredResolutions.firstObject]; } if (weakSelf.focusableItemManager != nil) { @@ -363,7 +362,7 @@ - (void)didEnterStateVideoStreamStarting { 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. + // If no response, assume that the format is H264 RAW and get the screen resolution from the RAI response's display capabilities. SDLVideoStreamingFormat *format = [[SDLVideoStreamingFormat alloc] initWithCodec:SDLVideoStreamingCodecH264 protocol:SDLVideoStreamingProtocolRAW]; SDLImageResolution *resolution = [[SDLImageResolution alloc] initWithWidth:(uint16_t)weakSelf.screenSize.width height:(uint16_t)weakSelf.screenSize.height]; weakSelf.preferredFormats = @[format]; @@ -376,6 +375,11 @@ - (void)didEnterStateVideoStreamStarting { SDLLogD(@"Using generic video capabilites, preferred formats: %@, resolutions: %@, haptics disabled", weakSelf.preferredFormats, weakSelf.preferredResolutions); } + if (weakSelf.dataSource != nil) { + SDLLogV(@"Calling data source for modified preferred resolutions"); + weakSelf.preferredResolutions = [weakSelf.dataSource resolutionFromHeadUnitPreferredResolution:weakSelf.preferredResolutions.firstObject]; + } + [self sdl_sendVideoStartService]; }]; } diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m index c6e2cd6b1..0115d318e 100644 --- a/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m +++ b/SmartDeviceLinkTests/DevAPISpecs/SDLSoftButtonManagerSpec.m @@ -42,7 +42,7 @@ @interface SDLSoftButtonManager() QuickSpecBegin(SDLSoftButtonManagerSpec) -fdescribe(@"a soft button manager", ^{ +describe(@"a soft button manager", ^{ __block SDLSoftButtonManager *testManager = nil; __block SDLFileManager *testFileManager = nil; From 951b4fd22af6194ad6fe4fe22118df86119d98f5 Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Wed, 4 Apr 2018 10:45:44 -0400 Subject: [PATCH 2/8] Added support for preferred video resolution - Preferred resolution is now set, even if video capabilities is not supported by Core - Preferred resolution is now set when the `videoAckPayload` does not return a width or height - Exposed the `SDLStreamingMediaManagerDataSource` files --- SmartDeviceLink-iOS.podspec | 1 + SmartDeviceLink-iOS.xcodeproj/project.pbxproj | 4 ++-- SmartDeviceLink.podspec | 1 + .../SDLStreamingMediaLifecycleManager.m | 19 ++++++++++++++++--- SmartDeviceLink/SmartDeviceLink.h | 1 + 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/SmartDeviceLink-iOS.podspec b/SmartDeviceLink-iOS.podspec index 423e3c24b..3ac9fc85d 100644 --- a/SmartDeviceLink-iOS.podspec +++ b/SmartDeviceLink-iOS.podspec @@ -280,6 +280,7 @@ ss.public_header_files = [ 'SmartDeviceLink/SDLStreamingMediaConfiguration.h', 'SmartDeviceLink/SDLStreamingMediaManager.h', 'SmartDeviceLink/SDLStreamingMediaManagerConstants.h', +'SmartDeviceLink/SDLStreamingMediaManagerDataSource.h', 'SmartDeviceLink/SDLSubscribeButton.h', 'SmartDeviceLink/SDLSubscribeButtonResponse.h', 'SmartDeviceLink/SDLSubscribeVehicleData.h', diff --git a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj index 0b7c7038c..bff33322b 100644 --- a/SmartDeviceLink-iOS.xcodeproj/project.pbxproj +++ b/SmartDeviceLink-iOS.xcodeproj/project.pbxproj @@ -908,7 +908,7 @@ 5D8204311BD001C700D0A41B /* SDLArtwork.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D82042F1BD001C700D0A41B /* SDLArtwork.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D8204321BD001C700D0A41B /* SDLArtwork.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D8204301BD001C700D0A41B /* SDLArtwork.m */; }; 5D850AB01D4907C500E6E7EE /* TestLockScreenAppIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 5D850AAF1D4907C500E6E7EE /* TestLockScreenAppIcon.png */; }; - 5D8A09811F54B4E5002502A2 /* SDLStreamingMediaManagerDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8A09801F54B4E5002502A2 /* SDLStreamingMediaManagerDataSource.h */; }; + 5D8A09811F54B4E5002502A2 /* SDLStreamingMediaManagerDataSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8A09801F54B4E5002502A2 /* SDLStreamingMediaManagerDataSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D8B174F1AC9D266006A6E1C /* SDLDialNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8B174D1AC9D266006A6E1C /* SDLDialNumber.h */; settings = {ATTRIBUTES = (Public, ); }; }; 5D8B17501AC9D266006A6E1C /* SDLDialNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D8B174E1AC9D266006A6E1C /* SDLDialNumber.m */; }; 5D8B17531AC9E11B006A6E1C /* SDLDialNumberResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D8B17511AC9E11B006A6E1C /* SDLDialNumberResponse.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -2287,7 +2287,7 @@ 5DBF0D5F1F3B3DB4008AF2C9 /* SDLControlFrameVideoStartServiceAckSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFrameVideoStartServiceAckSpec.m; path = ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m; sourceTree = ""; }; 5DC09ED91F2F7FEC00F4AB1D /* SDLControlFramePayloadNakSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLControlFramePayloadNakSpec.m; path = ControlFramePayloadSpecs/SDLControlFramePayloadNakSpec.m; sourceTree = ""; }; 5DC978251B7A38640012C2F1 /* SDLGlobalsSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SDLGlobalsSpec.m; path = UtilitiesSpecs/SDLGlobalsSpec.m; sourceTree = ""; }; - 5DCA93821EE0844D0015768E /* SmartDeviceLink.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SmartDeviceLink.podspec; sourceTree = SOURCE_ROOT; }; + 5DCA93821EE0844D0015768E /* SmartDeviceLink.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = SmartDeviceLink.podspec; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 5DCD7ADC1FCCA8D100A0FC7F /* SDLCarWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLCarWindow.h; sourceTree = ""; }; 5DCD7ADD1FCCA8D200A0FC7F /* SDLCarWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDLCarWindow.m; sourceTree = ""; }; 5DCD7AE61FCCA8E400A0FC7F /* SDLScreenshotViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDLScreenshotViewController.h; sourceTree = ""; }; diff --git a/SmartDeviceLink.podspec b/SmartDeviceLink.podspec index 4b6f5866d..a94f95b85 100644 --- a/SmartDeviceLink.podspec +++ b/SmartDeviceLink.podspec @@ -280,6 +280,7 @@ ss.public_header_files = [ 'SmartDeviceLink/SDLStreamingMediaConfiguration.h', 'SmartDeviceLink/SDLStreamingMediaManager.h', 'SmartDeviceLink/SDLStreamingMediaManagerConstants.h', +'SmartDeviceLink/SDLStreamingMediaManagerDataSource.h', 'SmartDeviceLink/SDLSubscribeButton.h', 'SmartDeviceLink/SDLSubscribeButtonResponse.h', 'SmartDeviceLink/SDLSubscribeVehicleData.h', diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index 2d133a37e..d37e09c3a 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -360,7 +360,7 @@ - (void)didEnterStateVideoStreamStarting { weakSelf.focusableItemManager.enableHapticDataRequests = capability.hapticSpatialDataSupported.boolValue; } - SDLLogD(@"Got specialized video capabilites, preferred formats: %@, resolutions: %@ haptics enabled %@", weakSelf.preferredFormats, weakSelf.preferredResolutions, (capability.hapticSpatialDataSupported.boolValue ? @"YES" : @"NO")); + SDLLogD(@"Got specialized video capabilites, preferred formats: %@, haptics enabled %@", weakSelf.preferredFormats, (capability.hapticSpatialDataSupported.boolValue ? @"YES" : @"NO")); } else { // If no response, assume that the format is H264 RAW and get the screen resolution from the RAI response's display capabilities. SDLVideoStreamingFormat *format = [[SDLVideoStreamingFormat alloc] initWithCodec:SDLVideoStreamingCodecH264 protocol:SDLVideoStreamingProtocolRAW]; @@ -378,6 +378,7 @@ - (void)didEnterStateVideoStreamStarting { if (weakSelf.dataSource != nil) { SDLLogV(@"Calling data source for modified preferred resolutions"); weakSelf.preferredResolutions = [weakSelf.dataSource resolutionFromHeadUnitPreferredResolution:weakSelf.preferredResolutions.firstObject]; + SDLLogD(@"Got specialized video resolutions: %@", weakSelf.preferredResolutions); } [self sdl_sendVideoStartService]; @@ -519,10 +520,22 @@ - (void)sdl_handleVideoStartServiceAck:(SDLProtocolMessage *)videoStartServiceAc [[SDLGlobals sharedGlobals] setDynamicMTUSize:(NSUInteger)videoAckPayload.mtu forServiceType:SDLServiceTypeVideo]; } - // This is the definitive screen size that will be used + // This is the definitive Oscreen size that will be used if (videoAckPayload.height != SDLControlFrameInt32NotFound && videoAckPayload.width != SDLControlFrameInt32NotFound) { _screenSize = CGSizeMake(videoAckPayload.width, videoAckPayload.height); - } // else we are using the screen size we got from the RAIR earlier + } else { + // If a preferred resolution was set, use the first option to set the screen size + if (self.preferredResolutions.count > 0) { + SDLImageResolution *preferredResolution = self.preferredResolutions[0]; + CGSize newScreenSize = CGSizeMake(preferredResolution.resolutionWidth.floatValue, preferredResolution.resolutionHeight.floatValue); + if (!CGSizeEqualToSize(self.screenSize, newScreenSize)) { + SDLLogW(@"The preferred resolution does not match the screen dimensions returned by the Register App Interface Response. Video may look distorted or video may not show up on the head unit"); + _screenSize = CGSizeMake(preferredResolution.resolutionWidth.floatValue, preferredResolution.resolutionHeight.floatValue); + } + } else { + // else we are using the screen size we got from the RAIR earlier + } + } // Figure out the definitive format that will be used. If the protocol / codec weren't passed in the payload, it's probably a system that doesn't support those properties, which also means it's a system that requires H.264 RAW encoding self.videoFormat = [[SDLVideoStreamingFormat alloc] init]; diff --git a/SmartDeviceLink/SmartDeviceLink.h b/SmartDeviceLink/SmartDeviceLink.h index 553d8f4d3..339f23910 100644 --- a/SmartDeviceLink/SmartDeviceLink.h +++ b/SmartDeviceLink/SmartDeviceLink.h @@ -328,6 +328,7 @@ FOUNDATION_EXPORT const unsigned char SmartDeviceLinkVersionString[]; #import "SDLTouchManager.h" #import "SDLTouchManagerDelegate.h" #import "SDLSecurityType.h" +#import "SDLStreamingMediaManagerDataSource.h" // Files #import "SDLArtwork.h" From 279700cedd662bfdf3f275a3943d89dc19725057 Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Wed, 4 Apr 2018 15:18:24 -0400 Subject: [PATCH 3/8] Added test cases for setting preferred screen size via the data source --- .../SDLStreamingMediaLifecycleManagerSpec.m | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m index 0ea63be4d..83f23282f 100644 --- a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m @@ -502,6 +502,50 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve expect(streamingLifecycleManager.currentVideoStreamState).to(equal(SDLVideoStreamStateReady)); }); }); + + context(@"with missing screen height and screen width values", ^{ + __block SDLImageResolution *preferredResolutionSquare = nil; + __block SDLImageResolution *preferredResolutionRectangle = nil; + + + beforeEach(^{ + preferredResolutionSquare = [[SDLImageResolution alloc] initWithWidth:56 height:56]; + preferredResolutionRectangle = [[SDLImageResolution alloc] initWithWidth:100 height:61]; + streamingLifecycleManager.preferredResolutions = @[preferredResolutionSquare, preferredResolutionRectangle]; + }); + + context(@"If the data source is nil", ^{ + beforeEach(^{ + expect(CGSizeEqualToSize(streamingLifecycleManager.screenSize, CGSizeZero)); + streamingLifecycleManager.dataSource = nil; + + testVideoStartServicePayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:-1 width:-1 protocol:nil codec:nil]; + testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartServicePayload.data]; + [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; + }); + + it(@"should not replace the existing screen resolution", ^{ + expect(CGSizeEqualToSize(streamingLifecycleManager.screenSize, CGSizeZero)); + expect(streamingLifecycleManager.dataSource).to(beNil()); + }); + }); + + context(@"If the preferred resolution was set in the data source", ^{ + beforeEach(^{ + streamingLifecycleManager.dataSource = testDataSource; + + testVideoStartServicePayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:-1 width:-1 protocol:nil codec:nil]; + testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartServicePayload.data]; + [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; + }); + + it(@"should set the screen size using the preferred resolution", ^{ + CGSize preferredFormat = CGSizeMake(preferredResolutionSquare.resolutionWidth.floatValue, preferredResolutionSquare.resolutionHeight.floatValue); + expect(CGSizeEqualToSize(streamingLifecycleManager.screenSize, preferredFormat)); + expect(streamingLifecycleManager.dataSource).toNot(beNil()); + }); + }); + }); }); describe(@"after receiving a Video Start NAK", ^{ From 293a01b621dd29b981b972da490497b23573f678 Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Thu, 5 Apr 2018 08:48:07 -0400 Subject: [PATCH 4/8] Removed extra letter from documentation --- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ SmartDeviceLink/SDLStreamingMediaLifecycleManager.m | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 SmartDeviceLink-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/SmartDeviceLink-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SmartDeviceLink-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/SmartDeviceLink-iOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index d37e09c3a..af5cffbf5 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -520,7 +520,7 @@ - (void)sdl_handleVideoStartServiceAck:(SDLProtocolMessage *)videoStartServiceAc [[SDLGlobals sharedGlobals] setDynamicMTUSize:(NSUInteger)videoAckPayload.mtu forServiceType:SDLServiceTypeVideo]; } - // This is the definitive Oscreen size that will be used + // This is the definitive screen size that will be used if (videoAckPayload.height != SDLControlFrameInt32NotFound && videoAckPayload.width != SDLControlFrameInt32NotFound) { _screenSize = CGSizeMake(videoAckPayload.width, videoAckPayload.height); } else { From 191478f5d9f028e363f8bbcd72768e2bf416babf Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Thu, 5 Apr 2018 08:51:11 -0400 Subject: [PATCH 5/8] Removed redundant else statement --- SmartDeviceLink/SDLStreamingMediaLifecycleManager.m | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index af5cffbf5..dcc4f10a4 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -532,9 +532,7 @@ - (void)sdl_handleVideoStartServiceAck:(SDLProtocolMessage *)videoStartServiceAc SDLLogW(@"The preferred resolution does not match the screen dimensions returned by the Register App Interface Response. Video may look distorted or video may not show up on the head unit"); _screenSize = CGSizeMake(preferredResolution.resolutionWidth.floatValue, preferredResolution.resolutionHeight.floatValue); } - } else { - // else we are using the screen size we got from the RAIR earlier - } + } // else we are using the screen size we got from the RAIR earlier } // Figure out the definitive format that will be used. If the protocol / codec weren't passed in the payload, it's probably a system that doesn't support those properties, which also means it's a system that requires H.264 RAW encoding From 36c1808c4f28b2f7b0ef8be66d03d81d1dbe8dcf Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Thu, 5 Apr 2018 08:54:55 -0400 Subject: [PATCH 6/8] Renamed test vars in SDLStreamingMediaLifecycleManagerSpec --- .../SDLStreamingMediaLifecycleManagerSpec.m | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m index 83f23282f..2db80119a 100644 --- a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m @@ -504,14 +504,14 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); context(@"with missing screen height and screen width values", ^{ - __block SDLImageResolution *preferredResolutionSquare = nil; - __block SDLImageResolution *preferredResolutionRectangle = nil; + __block SDLImageResolution *preferredResolutionLow = nil; + __block SDLImageResolution *preferredResolutionHigh = nil; beforeEach(^{ - preferredResolutionSquare = [[SDLImageResolution alloc] initWithWidth:56 height:56]; - preferredResolutionRectangle = [[SDLImageResolution alloc] initWithWidth:100 height:61]; - streamingLifecycleManager.preferredResolutions = @[preferredResolutionSquare, preferredResolutionRectangle]; + preferredResolutionLow = [[SDLImageResolution alloc] initWithWidth:10 height:10]; + preferredResolutionHigh = [[SDLImageResolution alloc] initWithWidth:100 height:100]; + streamingLifecycleManager.preferredResolutions = @[preferredResolutionLow, preferredResolutionHigh]; }); context(@"If the data source is nil", ^{ @@ -540,7 +540,7 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve }); it(@"should set the screen size using the preferred resolution", ^{ - CGSize preferredFormat = CGSizeMake(preferredResolutionSquare.resolutionWidth.floatValue, preferredResolutionSquare.resolutionHeight.floatValue); + CGSize preferredFormat = CGSizeMake(preferredResolutionLow.resolutionWidth.floatValue, preferredResolutionLow.resolutionHeight.floatValue); expect(CGSizeEqualToSize(streamingLifecycleManager.screenSize, preferredFormat)); expect(streamingLifecycleManager.dataSource).toNot(beNil()); }); From befd479e1bcbd431d2e9f41286be3aa6eb5c404f Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Thu, 5 Apr 2018 09:04:00 -0400 Subject: [PATCH 7/8] Refactored preferred video resolution test cases --- .../SDLStreamingMediaLifecycleManagerSpec.m | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m index 2db80119a..c33499ecc 100644 --- a/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m +++ b/SmartDeviceLinkTests/SDLStreamingMediaLifecycleManagerSpec.m @@ -512,15 +512,16 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve preferredResolutionLow = [[SDLImageResolution alloc] initWithWidth:10 height:10]; preferredResolutionHigh = [[SDLImageResolution alloc] initWithWidth:100 height:100]; streamingLifecycleManager.preferredResolutions = @[preferredResolutionLow, preferredResolutionHigh]; + + testVideoStartServicePayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:SDLControlFrameInt32NotFound width:SDLControlFrameInt32NotFound protocol:nil codec:nil]; + testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartServicePayload.data]; + + expect(CGSizeEqualToSize(streamingLifecycleManager.screenSize, CGSizeZero)); }); context(@"If the data source is nil", ^{ beforeEach(^{ - expect(CGSizeEqualToSize(streamingLifecycleManager.screenSize, CGSizeZero)); streamingLifecycleManager.dataSource = nil; - - testVideoStartServicePayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:-1 width:-1 protocol:nil codec:nil]; - testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartServicePayload.data]; [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; }); @@ -533,13 +534,10 @@ __block void (^sendNotificationForHMILevel)(SDLHMILevel hmiLevel) = ^(SDLHMILeve context(@"If the preferred resolution was set in the data source", ^{ beforeEach(^{ streamingLifecycleManager.dataSource = testDataSource; - - testVideoStartServicePayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:-1 width:-1 protocol:nil codec:nil]; - testVideoMessage = [[SDLV2ProtocolMessage alloc] initWithHeader:testVideoHeader andPayload:testVideoStartServicePayload.data]; [streamingLifecycleManager handleProtocolStartServiceACKMessage:testVideoMessage]; }); - it(@"should set the screen size using the preferred resolution", ^{ + it(@"should set the screen size using the first provided preferred resolution", ^{ CGSize preferredFormat = CGSizeMake(preferredResolutionLow.resolutionWidth.floatValue, preferredResolutionLow.resolutionHeight.floatValue); expect(CGSizeEqualToSize(streamingLifecycleManager.screenSize, preferredFormat)); expect(streamingLifecycleManager.dataSource).toNot(beNil()); From 468c50ea24ed0002bff8ad5e49ca72cbde1b9c1b Mon Sep 17 00:00:00 2001 From: NicoleYarroch Date: Fri, 6 Apr 2018 16:07:36 -0400 Subject: [PATCH 8/8] Consolidated if:else statements for setting final screen size --- .../SDLStreamingMediaLifecycleManager.m | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m index dcc4f10a4..a77f87820 100644 --- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m +++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m @@ -523,17 +523,15 @@ - (void)sdl_handleVideoStartServiceAck:(SDLProtocolMessage *)videoStartServiceAc // This is the definitive screen size that will be used if (videoAckPayload.height != SDLControlFrameInt32NotFound && videoAckPayload.width != SDLControlFrameInt32NotFound) { _screenSize = CGSizeMake(videoAckPayload.width, videoAckPayload.height); - } else { + } else if (self.preferredResolutions.count > 0) { // If a preferred resolution was set, use the first option to set the screen size - if (self.preferredResolutions.count > 0) { - SDLImageResolution *preferredResolution = self.preferredResolutions[0]; - CGSize newScreenSize = CGSizeMake(preferredResolution.resolutionWidth.floatValue, preferredResolution.resolutionHeight.floatValue); - if (!CGSizeEqualToSize(self.screenSize, newScreenSize)) { - SDLLogW(@"The preferred resolution does not match the screen dimensions returned by the Register App Interface Response. Video may look distorted or video may not show up on the head unit"); - _screenSize = CGSizeMake(preferredResolution.resolutionWidth.floatValue, preferredResolution.resolutionHeight.floatValue); - } - } // else we are using the screen size we got from the RAIR earlier - } + SDLImageResolution *preferredResolution = self.preferredResolutions.firstObject; + CGSize newScreenSize = CGSizeMake(preferredResolution.resolutionWidth.floatValue, preferredResolution.resolutionHeight.floatValue); + if (!CGSizeEqualToSize(self.screenSize, newScreenSize)) { + SDLLogW(@"The preferred resolution does not match the screen dimensions returned by the Register App Interface Response. Video may look distorted or video may not show up on the head unit"); + _screenSize = CGSizeMake(preferredResolution.resolutionWidth.floatValue, preferredResolution.resolutionHeight.floatValue); + } + } // else we are using the screen size we got from the RAIR earlier // Figure out the definitive format that will be used. If the protocol / codec weren't passed in the payload, it's probably a system that doesn't support those properties, which also means it's a system that requires H.264 RAW encoding self.videoFormat = [[SDLVideoStreamingFormat alloc] init];