Skip to content

Commit

Permalink
Merge branch 'develop' into feature/external_security_support
Browse files Browse the repository at this point in the history
# Conflicts:
#	SmartDeviceLink/SDLProxy.m
#	SmartDeviceLink/SDLStreamingMediaManager.h
#	SmartDeviceLink/SDLStreamingMediaManager.m
  • Loading branch information
joeljfischer committed Jul 29, 2016
2 parents e8e5a5b + ca91918 commit 1eb39d3
Show file tree
Hide file tree
Showing 21 changed files with 2,100 additions and 20 deletions.
88 changes: 88 additions & 0 deletions SmartDeviceLink-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions SmartDeviceLink/CGPoint_Util.h
@@ -0,0 +1,39 @@
//
// CGPoint_Util.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#ifndef CGPoint_Util_h
#define CGPoint_Util_h

#include <stdio.h>
#include <CoreGraphics/CGGeometry.h>

/**
* @abstract
* Calculate the center of two points.
* @param point1
* First point.
* @param point2
* Second point.
* @return CGPoint
* Center of the points.
*/
CGPoint CGPointCenterOfPoints(CGPoint point1, CGPoint point2);

/**
* @abstract
* Calculate the distance between two points.
* @param point1
* First point.
* @param point2
* Second point.
* @return CGFloat
* Distance between the points.
*/
CGFloat CGPointDistanceBetweenPoints(CGPoint point1, CGPoint point2);

#endif /* CGPoint_Util_h */
20 changes: 20 additions & 0 deletions SmartDeviceLink/CGPoint_Util.m
@@ -0,0 +1,20 @@
//
// CGPoint_Util.c
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#include "CGPoint_Util.h"
#include "math.h"

CGPoint CGPointCenterOfPoints(CGPoint point1, CGPoint point2) {
CGFloat xCenter = (point1.x + point2.x) / 2.0f;
CGFloat yCenter = (point1.y + point2.y) / 2.0f;
return CGPointMake(xCenter, yCenter);
}

CGFloat CGPointDistanceBetweenPoints(CGPoint point1, CGPoint point2) {
return hypotf(point1.x - point2.x, point1.y - point2.y);
}
62 changes: 62 additions & 0 deletions SmartDeviceLink/SDLPinchGesture.h
@@ -0,0 +1,62 @@
//
// SDLPinchGesture.h
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "SDLTouch.h"

NS_ASSUME_NONNULL_BEGIN

@interface SDLPinchGesture : NSObject

/**
* @abstract
* Initializes a pinch gesture.
* @param firstTouch
* First touch of the gesture
* @param secondTouch
* Second touch of the gesture
* @return SDLPinchGesture
* Instance of SDLPinchGesture.
*/
- (instancetype)initWithFirstTouch:(SDLTouch*)firstTouch secondTouch:(SDLTouch*)secondTouch;

/**
* @abstract
* First touch of a pinch gesture.
*/
@property (nonatomic, strong) SDLTouch* firstTouch;

/**
* @abstract
* Second touch of a pinch gesture.
*/
@property (nonatomic, strong) SDLTouch* secondTouch;

/**
* @abstract
* Distance between first and second touches.
*/
@property (nonatomic, assign, readonly) CGFloat distance;

/**
* @abstract
* Center point between first and second touches.
*/
@property (nonatomic, assign, readonly) CGPoint center;

/**
* @abstract
* Returns whether or not the pinch gesture is valid. This is true if both touches
* are non null.
*/
@property (nonatomic, assign, readonly) BOOL isValid;

@end

NS_ASSUME_NONNULL_END
79 changes: 79 additions & 0 deletions SmartDeviceLink/SDLPinchGesture.m
@@ -0,0 +1,79 @@
//
// SDLPinchGesture.m
// SmartDeviceLink-iOS
//
// Created by Muller, Alexander (A.) on 6/14/16.
// Copyright © 2016 smartdevicelink. All rights reserved.
//

#import "SDLPinchGesture.h"

#import "SDLTouch.h"
#import "CGPoint_Util.h"

NS_ASSUME_NONNULL_BEGIN

@implementation SDLPinchGesture

@synthesize distance = _distance;
@synthesize center = _center;

- (instancetype)initWithFirstTouch:(SDLTouch*)firstTouch secondTouch:(SDLTouch*)secondTouch {
self = [super init];
if (!self) {
return nil;
}

_firstTouch = firstTouch;
_secondTouch = secondTouch;
_distance = -1;
_center = CGPointZero;

return self;
}

#pragma mark - Setters
- (void)setFirstTouch:(SDLTouch *)firstTouch {
if (firstTouch.identifier == SDLTouchIdentifierFirstFinger) {
_firstTouch = firstTouch;
[self sdl_invalidate];
}
}

- (void)setSecondTouch:(SDLTouch *)secondTouch {
if (secondTouch.identifier == SDLTouchIdentifierSecondFinger) {
_secondTouch = secondTouch;
[self sdl_invalidate];
}
}

#pragma mark - Getters
- (CGFloat)distance {
if (_distance == -1) {
_distance = CGPointDistanceBetweenPoints(self.firstTouch.location,
self.secondTouch.location);
}
return _distance;
}

- (CGPoint)center {
if (CGPointEqualToPoint(_center, CGPointZero)) {
_center = CGPointCenterOfPoints(self.firstTouch.location,
self.secondTouch.location);
}
return _center;
}

- (BOOL)isValid {
return (self.firstTouch != nil) && (self.secondTouch != nil);
}

#pragma mark - Private
- (void)sdl_invalidate {
_distance = -1;
_center = CGPointZero;
}

@end

NS_ASSUME_NONNULL_END
14 changes: 11 additions & 3 deletions SmartDeviceLink/SDLProxy.m
Expand Up @@ -29,7 +29,7 @@
#import "SDLProtocolMessage.h"
#import "SDLProtocolMessage.h"
#import "SDLPutFile.h"
#import "SDLRequestType.h"
#import "SDLRPCPayload.h"
#import "SDLRPCPayload.h"
#import "SDLRPCRequestFactory.h"
#import "SDLRPCResponse.h"
Expand Down Expand Up @@ -64,7 +64,8 @@ @interface SDLProxy () {

@property (copy, nonatomic) NSString *appId;
@property (strong, nonatomic) NSMutableSet *mutableProxyListeners;
@property (nonatomic, strong, readwrite) SDLStreamingMediaManager *streamingMediaManager;
@property (nonatomic, strong, readwrite, nullable) SDLStreamingMediaManager *streamingMediaManager;
@property (nonatomic, strong, nullable) SDLDisplayCapabilities* displayCapabilities;
@property (nonatomic, strong) NSMutableDictionary<SDLVehicleMake *, Class> *securityManagers;

@end
Expand Down Expand Up @@ -111,6 +112,8 @@ - (void)destructObjects {
_transport = nil;
_protocol = nil;
_mutableProxyListeners = nil;
_streamingMediaManager = nil;
_displayCapabilities = nil;
}
}

Expand Down Expand Up @@ -177,8 +180,12 @@ - (NSString *)proxyVersion {

- (SDLStreamingMediaManager *)streamingMediaManager {
if (_streamingMediaManager == nil) {
_streamingMediaManager = [[SDLStreamingMediaManager alloc] initWithProtocol:self.protocol];
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];
}

return _streamingMediaManager;
Expand Down Expand Up @@ -373,6 +380,7 @@ - (void)handleRegisterAppInterfaceResponse:(SDLRPCResponse *)response {
NSString *logMessage = [NSString stringWithFormat:@"Framework Version: %@", self.proxyVersion];
[SDLDebugTool logInfo:logMessage withType:SDLDebugType_RPC toOutput:SDLDebugOutput_All toGroup:self.debugConsoleGroupName];
SDLRegisterAppInterfaceResponse *registerResponse = (SDLRegisterAppInterfaceResponse *)response;
self.displayCapabilities = registerResponse.displayCapabilities;
self.protocol.securityManager = [self securityManagerForMake:registerResponse.vehicleType.make];

if ([SDLGlobals globals].protocolVersion >= 4) {
Expand Down
28 changes: 27 additions & 1 deletion SmartDeviceLink/SDLStreamingMediaManager.h
Expand Up @@ -12,6 +12,8 @@
#import "SDLProtocolListener.h"

@class SDLAbstractProtocol;
@class SDLDisplayCapabilities;
@class SDLTouchManager;


NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -52,8 +54,32 @@ typedef void (^SDLStreamingEncryptionStartBlock)(BOOL success, BOOL encryption,
@property (assign, nonatomic, readonly) BOOL videoSessionAuthenticated;
@property (assign, nonatomic, readonly) BOOL audioSessionAuthenticated;

/**
* Touch Manager responsible for providing touch event notifications.
*/
@property (nonatomic, strong, readonly) SDLTouchManager* touchManager;

/**
* 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.
*
* @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) NSDictionary* videoEncoderSettings;

/**
* Provides default video encoder settings used.
*/
@property (strong, nonatomic, readonly) NSDictionary* defaultVideoEncoderSettings;

/**
* 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;


- (instancetype)initWithProtocol:(SDLAbstractProtocol *)protocol __deprecated_msg(("Please use initWithProtocol:displayCapabilities: instead"));

- (instancetype)initWithProtocol:(SDLAbstractProtocol *)protocol;
- (instancetype)initWithProtocol:(SDLAbstractProtocol *)protocol displayCapabilities:(SDLDisplayCapabilities*)displayCapabilities;

/**
* This method will attempt to start a streaming video session. It will set up iOS's video encoder, and call out to the head unit asking if it will start a video session.
Expand Down

0 comments on commit 1eb39d3

Please sign in to comment.