diff options
author | Muller, Alexander (A.) <amulle19@ford.com> | 2016-08-02 09:38:35 -0700 |
---|---|---|
committer | Muller, Alexander (A.) <amulle19@ford.com> | 2016-08-02 09:38:35 -0700 |
commit | 6df9e741de1f9e10d620b40d2738d5a5d3172d73 (patch) | |
tree | 50533ca112cc2882f8fd94c379d51c9bf61034dc | |
parent | 1798a1c2734876cf98174e27d49d338ebb796fd2 (diff) | |
download | sdl_ios-6df9e741de1f9e10d620b40d2738d5a5d3172d73.tar.gz |
Extracted display capabilities out and allowed it to be a settable property of SDLStreamingMediaManager.
-rw-r--r-- | SmartDeviceLink/SDLProxy.m | 6 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.h | 9 | ||||
-rw-r--r-- | SmartDeviceLink/SDLStreamingMediaManager.m | 36 |
3 files changed, 37 insertions, 14 deletions
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m index c4189452d..6be5a3c33 100644 --- a/SmartDeviceLink/SDLProxy.m +++ b/SmartDeviceLink/SDLProxy.m @@ -180,9 +180,6 @@ const int POLICIES_CORRELATION_ID = 65535; - (SDLStreamingMediaManager *)streamingMediaManager { if (_streamingMediaManager == nil) { - if (self.displayCapabilities == nil) { - @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"SDLStreamingMediaManager must be accessed only after a successful RegisterAppInterfaceResponse" userInfo:nil]; - } _streamingMediaManager = [[SDLStreamingMediaManager alloc] initWithProtocol:self.protocol displayCapabilities:self.displayCapabilities]; [self.protocol.protocolDelegateTable addObject:_streamingMediaManager]; [self.mutableProxyListeners addObject:_streamingMediaManager.touchManager]; @@ -381,6 +378,9 @@ const int POLICIES_CORRELATION_ID = 65535; [SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName]; SDLRegisterAppInterfaceResponse *registerResponse = (SDLRegisterAppInterfaceResponse *)response; self.displayCapabilities = registerResponse.displayCapabilities; + if (_streamingMediaManager) { + _streamingMediaManager.displayCapabilties = registerResponse.displayCapabilities; + } self.protocol.securityManager = [self securityManagerForMake:registerResponse.vehicleType.make]; if ([SDLGlobals globals].protocolVersion >= 4) { diff --git a/SmartDeviceLink/SDLStreamingMediaManager.h b/SmartDeviceLink/SDLStreamingMediaManager.h index 59e1917db..82e7e3733 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.h +++ b/SmartDeviceLink/SDLStreamingMediaManager.h @@ -40,6 +40,8 @@ typedef NS_ENUM(NSInteger, SDLStreamingAudioError) { extern NSString *const SDLErrorDomainStreamingMediaVideo; extern NSString *const SDLErrorDomainStreamingMediaAudio; +extern CGSize const SDLDefaultScreenSize; + typedef void (^SDLStreamingStartBlock)(BOOL success, NSError *__nullable error); typedef void (^SDLStreamingEncryptionStartBlock)(BOOL success, BOOL encryption, NSError *__nullable error); @@ -67,6 +69,13 @@ typedef void (^SDLStreamingEncryptionStartBlock)(BOOL success, BOOL encryption, @property (strong, nonatomic, null_resettable) NSDictionary* videoEncoderSettings; /** + * Display capabilties that will set the screenSize property. If set to nil, the SDLDefaultScreenSize will be used. + * + * @warning Video streaming must not be connected to update the encoder properties. If it is running, issue a stopVideoSession before updating. + */ +@property (strong, nonatomic, null_resettable) SDLDisplayCapabilities* displayCapabilties; + +/** * Provides default video encoder settings used. */ @property (strong, nonatomic, readonly) NSDictionary* defaultVideoEncoderSettings; diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m index ac5197246..65aea4122 100644 --- a/SmartDeviceLink/SDLStreamingMediaManager.m +++ b/SmartDeviceLink/SDLStreamingMediaManager.m @@ -21,6 +21,7 @@ NSString *const SDLErrorDomainStreamingMediaVideo = @"com.sdl.streamingmediamanager.video"; NSString *const SDLErrorDomainStreamingMediaAudio = @"com.sdl.streamingmediamanager.audio"; +CGSize const SDLDefaultScreenSize = {800,480}; NS_ASSUME_NONNULL_BEGIN @@ -59,16 +60,9 @@ NS_ASSUME_NONNULL_BEGIN } _protocol = protocol; - - SDLImageResolution* resolution = displayCapabilities.screenParams.resolution; - if (resolution != nil) { - _screenSize = CGSizeMake(resolution.resolutionWidth.floatValue, - resolution.resolutionHeight.floatValue); - } else { - NSLog(@"Could not retrieve screen size. Defaulting to 640 x 480."); - _screenSize = CGSizeMake(640, - 480); - } + + _displayCapabilties = displayCapabilities; + [self sdl_updateScreenSizeFromDisplayCapabilities:displayCapabilities]; return self; @@ -105,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN _videoStartBlock = nil; _audioStartBlock = nil; - _screenSize = CGSizeMake(640, 480); + _screenSize = SDLDefaultScreenSize; _videoEncoderSettings = self.defaultVideoEncoderSettings; _touchManager = [[SDLTouchManager alloc] init]; @@ -250,6 +244,16 @@ NS_ASSUME_NONNULL_BEGIN } } +- (void)setDisplayCapabilties:(SDLDisplayCapabilities * _Nullable)displayCapabilties { + if (self.videoSessionConnected) { + @throw [NSException exceptionWithName:SDLErrorDomainStreamingMediaVideo reason:@"Cannot update video encoder settings while video session is connected." userInfo:nil]; + return; + } + + _displayCapabilties = displayCapabilties; + [self sdl_updateScreenSizeFromDisplayCapabilities:displayCapabilties]; +} + - (NSDictionary*)defaultVideoEncoderSettings { static NSDictionary* defaultVideoEncoderSettings = nil; if (defaultVideoEncoderSettings == nil) { @@ -520,6 +524,16 @@ void sdl_videoEncoderOutputCallback(void *outputCallbackRefCon, void *sourceFram [self.touchManager cancelPendingTouches]; } +- (void)sdl_updateScreenSizeFromDisplayCapabilities:(SDLDisplayCapabilities*)displayCapabilities { + SDLImageResolution* resolution = displayCapabilities.screenParams.resolution; + if (resolution != nil) { + _screenSize = CGSizeMake(resolution.resolutionWidth.floatValue, + resolution.resolutionHeight.floatValue); + } else { + _screenSize = SDLDefaultScreenSize; + } +} + @end NS_ASSUME_NONNULL_END |