summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-12-15 16:21:04 -0500
committerJoel Fischer <joeljfischer@gmail.com>2017-12-15 16:21:04 -0500
commite14775a6e012076f6f44b5ba0a963f08e43d49a0 (patch)
tree42d30f46f12d6f0d593cac4e87bd211788b7b8bf
parent43a7be38b49b8e9f2e6003460e817344c5e77b45 (diff)
downloadsdl_ios-e14775a6e012076f6f44b5ba0a963f08e43d49a0.tar.gz
Allow SMM synced framerate to be disabled in config with `forceFramerateSync`
* Flip `SDLTouchManager disableSyncedPanning` to `enableSyncedPanning` and automatically set it to NO if SMM synced framerate is disabled.
-rw-r--r--SmartDeviceLink/SDLStreamingMediaConfiguration.h5
-rw-r--r--SmartDeviceLink/SDLStreamingMediaConfiguration.m1
-rw-r--r--SmartDeviceLink/SDLStreamingMediaLifecycleManager.m31
-rw-r--r--SmartDeviceLink/SDLTouchManager.h4
-rw-r--r--SmartDeviceLink/SDLTouchManager.m8
5 files changed, 31 insertions, 18 deletions
diff --git a/SmartDeviceLink/SDLStreamingMediaConfiguration.h b/SmartDeviceLink/SDLStreamingMediaConfiguration.h
index e4001009e..72a36100f 100644
--- a/SmartDeviceLink/SDLStreamingMediaConfiguration.h
+++ b/SmartDeviceLink/SDLStreamingMediaConfiguration.h
@@ -70,6 +70,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic) BOOL carWindowDrawsAfterScreenUpdates;
/**
+ When YES, the StreamingMediaManager will run a CADisplayLink with the framerate set to the video encoder settings kVTCompressionPropertyKey_ExpectedFrameRate. This then forces TouchManager (and CarWindow, if used) to sync their callbacks to the framerate. If using CarWindow, this *must* be YES. If NO, `enableSyncedPanning` on SDLTouchManager will be set to NO. Defaults to YES.
+ */
+@property (assign, nonatomic) BOOL forceFramerateSync;
+
+/**
Create an insecure video streaming configuration. No security managers will be provided and the encryption flag will be set to None. If you'd like custom video encoder settings, you can set the property manually.
@return The configuration
diff --git a/SmartDeviceLink/SDLStreamingMediaConfiguration.m b/SmartDeviceLink/SDLStreamingMediaConfiguration.m
index 4bd582e2c..aaf07035b 100644
--- a/SmartDeviceLink/SDLStreamingMediaConfiguration.m
+++ b/SmartDeviceLink/SDLStreamingMediaConfiguration.m
@@ -39,6 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
_dataSource = dataSource;
_rootViewController = rootViewController;
_carWindowDrawsAfterScreenUpdates = YES;
+ _forceFramerateSync = YES;
return self;
}
diff --git a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m
index c8cdc125f..1658b2969 100644
--- a/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m
+++ b/SmartDeviceLink/SDLStreamingMediaLifecycleManager.m
@@ -90,6 +90,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
@property (assign, nonatomic) CV_NULLABLE CVPixelBufferRef backgroundingPixelBuffer;
@property (strong, nonatomic, nullable) CADisplayLink *displayLink;
+@property (assign, nonatomic) BOOL useDisplayLink;
@property (assign, nonatomic) CMTime lastPresentationTimestamp;
@@ -113,6 +114,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
_videoEncoderSettings = configuration.customVideoEncoderSettings ?: SDLH264VideoEncoder.defaultVideoEncoderSettings;
if (configuration.rootViewController != nil) {
+ NSAssert(configuration.forceFramerateSync, @"When using CarWindow (rootViewController != nil), forceFrameRateSync must be YES");
if (@available(iOS 9.0, *)) {
SDLLogD(@"Initializing focusable item locator");
_focusableItemManager = [[SDLFocusableItemLocator alloc] initWithViewController:configuration.rootViewController connectionManager:_connectionManager];
@@ -127,6 +129,7 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
_requestedEncryptionType = configuration.maximumDesiredEncryption;
_dataSource = configuration.dataSource;
+ _useDisplayLink = configuration.forceFramerateSync;
_screenSize = SDLDefaultScreenSize;
_backgroundingPixelBuffer = NULL;
_preferredFormatIndex = 0;
@@ -404,18 +407,22 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
[[NSNotificationCenter defaultCenter] postNotificationName:SDLVideoStreamDidStartNotification object:nil];
- dispatch_async(dispatch_get_main_queue(), ^{
- // And start up the displayLink
- NSInteger targetFramerate = ((NSNumber *)self.videoEncoderSettings[(__bridge NSString *)kVTCompressionPropertyKey_ExpectedFrameRate]).integerValue;
- SDLLogD(@"Initializing CADisplayLink with framerate: %ld", (long)targetFramerate);
- self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(sdl_displayLinkFired:)];
- if (SDL_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10")) {
- self.displayLink.preferredFramesPerSecond = targetFramerate;
- } else {
- self.displayLink.frameInterval = (60 / targetFramerate);
- }
- [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
- });
+ if (self.useDisplayLink) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ // And start up the displayLink
+ NSInteger targetFramerate = ((NSNumber *)self.videoEncoderSettings[(__bridge NSString *)kVTCompressionPropertyKey_ExpectedFrameRate]).integerValue;
+ SDLLogD(@"Initializing CADisplayLink with framerate: %ld", (long)targetFramerate);
+ self.displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(sdl_displayLinkFired:)];
+ if (SDL_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10")) {
+ self.displayLink.preferredFramesPerSecond = targetFramerate;
+ } else {
+ self.displayLink.frameInterval = (60 / targetFramerate);
+ }
+ [self.displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
+ });
+ } else {
+ self.touchManager.enableSyncedPanning = NO;
+ }
}
- (void)didEnterStateVideoStreamShuttingDown {
diff --git a/SmartDeviceLink/SDLTouchManager.h b/SmartDeviceLink/SDLTouchManager.h
index 89c46f084..fb206665d 100644
--- a/SmartDeviceLink/SDLTouchManager.h
+++ b/SmartDeviceLink/SDLTouchManager.h
@@ -58,9 +58,9 @@ typedef void(^SDLTouchEventHandler)(SDLTouch *touch, SDLTouchType type);
@property (nonatomic, assign) CGFloat movementTimeThreshold __deprecated_msg("This is now unused, the movement time threshold is now synced to the framerate automatically");
/**
- If set to YES, the display link syncing will be ignored and `movementTimeThreshold` will be used.
+ If set to NO, the display link syncing will be ignored and `movementTimeThreshold` will be used. Defaults to YES.
*/
-@property (assign, nonatomic) BOOL disableSyncedPanning;
+@property (assign, nonatomic) BOOL enableSyncedPanning;
/**
* @abstract
diff --git a/SmartDeviceLink/SDLTouchManager.m b/SmartDeviceLink/SDLTouchManager.m
index c92015aac..40b3b1c54 100644
--- a/SmartDeviceLink/SDLTouchManager.m
+++ b/SmartDeviceLink/SDLTouchManager.m
@@ -107,7 +107,7 @@ static NSUInteger const MaximumNumberOfTouches = 2;
_tapTimeThreshold = 0.4f;
_tapDistanceThreshold = 50.0f;
_touchEnabled = YES;
- _disableSyncedPanning = NO;
+ _enableSyncedPanning = YES;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sdl_onTouchEvent:) name:SDLDidReceiveTouchEventNotification object:nil];
@@ -230,7 +230,7 @@ static NSUInteger const MaximumNumberOfTouches = 2;
- (void)sdl_handleTouchMoved:(SDLTouch *)touch {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if (self.disableSyncedPanning &&
+ if (!self.enableSyncedPanning &&
((touch.timeStamp - self.previousTouch.timeStamp) <= (self.movementTimeThreshold * NSEC_PER_USEC))) {
return; // no-op
}
@@ -247,7 +247,7 @@ static NSUInteger const MaximumNumberOfTouches = 2;
} break;
}
- if (self.disableSyncedPanning) {
+ if (!self.enableSyncedPanning) {
[self syncFrame];
}
} break;
@@ -262,7 +262,7 @@ static NSUInteger const MaximumNumberOfTouches = 2;
}
} break;
case SDLPerformingTouchTypePanningTouch: {
- if (self.disableSyncedPanning) {
+ if (!self.enableSyncedPanning) {
[self syncFrame];
}
self.lastStoredTouchLocation = touch.location;