summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuller, Alexander (A.) <amulle19@ford.com>2016-07-27 15:12:34 -0700
committerMuller, Alexander (A.) <amulle19@ford.com>2016-07-27 15:12:34 -0700
commit2e929ed5296eca2befc00d3836687cb95871bbea (patch)
treee331b5f54da40288ab76dc4479e43556fb6f4628
parent74ae86f50e94fb93a89a66040f4892d02f615b64 (diff)
downloadsdl_ios-2e929ed5296eca2befc00d3836687cb95871bbea.tar.gz
Added support for retrieving screen dimensions from a successful register app interface for use in the video encoder.
-rw-r--r--SmartDeviceLink/SDLProxy.m12
-rw-r--r--SmartDeviceLink/SDLStreamingMediaManager.h19
-rw-r--r--SmartDeviceLink/SDLStreamingMediaManager.m22
3 files changed, 45 insertions, 8 deletions
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m
index b9f172d7f..c8faa4a6d 100644
--- a/SmartDeviceLink/SDLProxy.m
+++ b/SmartDeviceLink/SDLProxy.m
@@ -29,7 +29,7 @@
#import "SDLProtocolMessage.h"
#import "SDLProtocolMessage.h"
#import "SDLPutFile.h"
-#import "SDLRPCPayload.h"
+#import "SDLRegisterAppInterfaceResponse.h"
#import "SDLRPCPayload.h"
#import "SDLRPCRequestFactory.h"
#import "SDLRPCResponse.h"
@@ -57,6 +57,7 @@ const int POLICIES_CORRELATION_ID = 65535;
@property (strong, nonatomic) NSMutableSet *mutableProxyListeners;
@property (nonatomic, strong, readwrite, nullable) SDLStreamingMediaManager *streamingMediaManager;
+@property (nonatomic, strong, nullable) SDLDisplayCapabilities* displayCapabilities;
@end
@@ -102,6 +103,7 @@ const int POLICIES_CORRELATION_ID = 65535;
_protocol = nil;
_mutableProxyListeners = nil;
_streamingMediaManager = nil;
+ _displayCapabilities = nil;
}
}
@@ -167,7 +169,11 @@ 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];
+ _streamingMediaManager.displayCapabilities = self.displayCapabilities;
[self.protocol.protocolDelegateTable addObject:_streamingMediaManager];
}
@@ -329,6 +335,10 @@ const int POLICIES_CORRELATION_ID = 65535;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendMobileHMIState) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sendMobileHMIState) name:UIApplicationDidEnterBackgroundNotification object:nil];
}
+
+ // Extract the display capabilties to successfully build SDLStreamingMediaManager's video encoder.
+ SDLRegisterAppInterfaceResponse* registerResponse = (SDLRegisterAppInterfaceResponse*)response;
+ self.displayCapabilities = registerResponse.displayCapabilities;
}
- (void)handleSyncPData:(SDLRPCMessage *)message {
diff --git a/SmartDeviceLink/SDLStreamingMediaManager.h b/SmartDeviceLink/SDLStreamingMediaManager.h
index 344ac52f0..1d41fb5d6 100644
--- a/SmartDeviceLink/SDLStreamingMediaManager.h
+++ b/SmartDeviceLink/SDLStreamingMediaManager.h
@@ -12,6 +12,7 @@
#import "SDLProtocolListener.h"
@class SDLAbstractProtocol;
+@class SDLDisplayCapabilities;
NS_ASSUME_NONNULL_BEGIN
@@ -82,6 +83,9 @@ typedef void (^SDLStreamingStartBlock)(BOOL success, NSError *__nullable error);
*/
- (BOOL)sendAudioData:(NSData *)pcmAudioData;
+@property (assign, nonatomic, readonly) BOOL videoSessionConnected;
+@property (assign, nonatomic, readonly) BOOL audioSessionConnected;
+
/**
* The settings used in a VTCompressionSessionRef encoder. These will be verified when the video stream is started. Acceptable properties for this are located in VTCompressionProperties. If set to nil, the defaultVideoEncoderSettings will be used.
*
@@ -89,14 +93,21 @@ typedef void (^SDLStreamingStartBlock)(BOOL success, NSError *__nullable error);
*/
@property (strong, nonatomic, null_resettable) NSDictionary* videoEncoderSettings;
-@property (assign, nonatomic, readonly) BOOL videoSessionConnected;
-@property (assign, nonatomic, readonly) BOOL audioSessionConnected;
-
/**
- * Provides default video encoder settings used.
+ * Provides default video encoder settings used.
*/
@property (strong, nonatomic, readonly) NSDictionary* defaultVideoEncoderSettings;
+/**
+ * The capabilities of the display that is currently connected to.
+ *
+ */
+@property (strong, nonatomic) SDLDisplayCapabilities* displayCapabilities;
+
+/**
+ * This is the current screen size of a connected display. This will be the size the video encoder uses to encode the raw image data.
+ */
+@property (assign, nonatomic, readonly) CGSize screenSize;
@end
diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m
index ec07f369b..3580e1d07 100644
--- a/SmartDeviceLink/SDLStreamingMediaManager.m
+++ b/SmartDeviceLink/SDLStreamingMediaManager.m
@@ -11,8 +11,10 @@
@import UIKit;
#import "SDLAbstractProtocol.h"
+#import "SDLDisplayCapabilities.h"
#import "SDLGlobals.h"
-
+#import "SDLImageResolution.h"
+#import "SDLScreenParams.h"
NSString *const SDLErrorDomainStreamingMediaVideo = @"com.sdl.streamingmediamanager.video";
NSString *const SDLErrorDomainStreamingMediaAudio = @"com.sdl.streamingmediamanager.audio";
@@ -58,6 +60,8 @@ NS_ASSUME_NONNULL_BEGIN
_videoStartBlock = nil;
_audioStartBlock = nil;
+
+ _screenSize = CGSizeMake(640, 480);
return self;
}
@@ -162,6 +166,19 @@ NS_ASSUME_NONNULL_BEGIN
return defaultVideoEncoderSettings;
}
+- (void)setDisplayCapabilities:(SDLDisplayCapabilities *)displayCapabilities {
+ _displayCapabilities = displayCapabilities;
+
+ 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);
+ }
+}
#pragma mark - SDLProtocolListener Methods
@@ -259,8 +276,7 @@ void sdl_videoEncoderOutputCallback(void *outputCallbackRefCon, void *sourceFram
OSStatus status;
// Create a compression session
- // TODO (Joel F.)[2015-08-18]: Dimensions should be from the Head Unit
- status = VTCompressionSessionCreate(NULL, 640, 480, kCMVideoCodecType_H264, NULL, NULL, NULL, &sdl_videoEncoderOutputCallback, (__bridge void *)self, &_compressionSession);
+ status = VTCompressionSessionCreate(NULL, self.screenSize.width, self.screenSize.height, kCMVideoCodecType_H264, NULL, NULL, NULL, &sdl_videoEncoderOutputCallback, (__bridge void *)self, &_compressionSession);
if (status != noErr) {
// TODO: Log the error