summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-08-15 16:53:54 -0400
committerJoel Fischer <joeljfischer@gmail.com>2017-08-15 16:53:54 -0400
commit7aea81eaa08665dc656effa519f064ce72976270 (patch)
treef7d3b3461b7a9e350cb826826c913e01df8f07a1
parent1a80cac24e37aff57fa069ceea7a9704de522a25 (diff)
downloadsdl_ios-7aea81eaa08665dc656effa519f064ce72976270.tar.gz
Lots of little merge fixes
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartService.h10
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartService.m16
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h11
-rw-r--r--SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m16
-rw-r--r--SmartDeviceLink/SDLGlobals.m4
-rw-r--r--SmartDeviceLink/SDLHMICapabilities.h7
-rw-r--r--SmartDeviceLink/SDLHMICapabilities.m12
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m4
-rw-r--r--SmartDeviceLink/SDLProtocol.h4
-rw-r--r--SmartDeviceLink/SDLProtocol.m31
-rw-r--r--SmartDeviceLink/SDLProtocolReceivedMessageRouter.m2
-rw-r--r--SmartDeviceLink/SDLUploadFileOperation.m4
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m18
-rw-r--r--SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m16
-rw-r--r--SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m16
-rw-r--r--SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m12
-rw-r--r--SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m12
-rw-r--r--SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m32
18 files changed, 104 insertions, 123 deletions
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h
index 30ea57e8f..63274f3ef 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.h
@@ -10,8 +10,8 @@
#import "SDLControlFramePayloadType.h"
-@class SDLVideoStreamingCodec;
-@class SDLVideoStreamingProtocol;
+#import "SDLVideoStreamingCodec.h"
+#import "SDLVideoStreamingProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@@ -24,12 +24,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic, readonly) int32_t width;
/// Desired video protocol to be used. See VideoStreamingProtocol RPC
-@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingCodec *videoCodec;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingCodec videoCodec;
/// Desired video codec to be used. See VideoStreamingCodec RPC
-@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingProtocol *videoProtocol;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingProtocol videoProtocol;
-- (instancetype)initWithVideoHeight:(int32_t)height width:(int32_t)width protocol:(nullable SDLVideoStreamingProtocol *)protocol codec:(nullable SDLVideoStreamingCodec *)codec;
+- (instancetype)initWithVideoHeight:(int32_t)height width:(int32_t)width protocol:(nullable SDLVideoStreamingProtocol)protocol codec:(nullable SDLVideoStreamingCodec)codec;
@end
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m
index caa6a24a2..800c3ace8 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartService.m
@@ -10,8 +10,6 @@
#import "bson_object.h"
#import "SDLControlFramePayloadConstants.h"
-#import "SDLVideoStreamingCodec.h"
-#import "SDLVideoStreamingProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@@ -20,14 +18,14 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic, readwrite) int32_t height;
@property (assign, nonatomic, readwrite) int32_t width;
-@property (copy, nonatomic, readwrite, nullable) SDLVideoStreamingCodec *videoCodec;
-@property (copy, nonatomic, readwrite, nullable) SDLVideoStreamingProtocol *videoProtocol;
+@property (copy, nonatomic, readwrite, nullable) SDLVideoStreamingCodec videoCodec;
+@property (copy, nonatomic, readwrite, nullable) SDLVideoStreamingProtocol videoProtocol;
@end
@implementation SDLControlFramePayloadVideoStartService
-- (instancetype)initWithVideoHeight:(int32_t)height width:(int32_t)width protocol:(nullable SDLVideoStreamingProtocol *)protocol codec:(nullable SDLVideoStreamingCodec *)codec {
+- (instancetype)initWithVideoHeight:(int32_t)height width:(int32_t)width protocol:(nullable SDLVideoStreamingProtocol)protocol codec:(nullable SDLVideoStreamingCodec)codec {
self = [super init];
if (!self) return nil;
@@ -73,11 +71,11 @@ NS_ASSUME_NONNULL_BEGIN
}
if (self.videoProtocol != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.value.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.UTF8String);
}
if (self.videoCodec != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.value.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.UTF8String);
}
BytePtr bsonData = bson_object_to_bytes(&payloadObject);
@@ -96,12 +94,12 @@ NS_ASSUME_NONNULL_BEGIN
char *utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoProtocolKey);
if (utf8String != NULL) {
- self.videoProtocol = [SDLVideoStreamingProtocol valueOf:[NSString stringWithUTF8String:utf8String]];
+ self.videoProtocol = [NSString stringWithUTF8String:utf8String];
}
utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoCodecKey);
if (utf8String != NULL) {
- self.videoCodec = [SDLVideoStreamingCodec valueOf:[NSString stringWithUTF8String:utf8String]];
+ self.videoCodec = [NSString stringWithUTF8String:utf8String];
}
bson_object_deinitialize(&payloadObject);
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h
index ed6c17474..36ad5cfd6 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.h
@@ -10,8 +10,9 @@
#import "SDLControlFramePayloadType.h"
-@class SDLVideoStreamingCodec;
-@class SDLVideoStreamingProtocol;
+#import "SDLVideoStreamingCodec.h"
+#import "SDLVideoStreamingProtocol.h"
+
NS_ASSUME_NONNULL_BEGIN
@@ -27,12 +28,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (assign, nonatomic, readonly) int32_t width;
/// Accepted video protocol to be used. See VideoStreamingProtocol RPC
-@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingProtocol *videoProtocol;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingProtocol videoProtocol;
/// Accepted video codec to be used. See VideoStreamingCodec RPC
-@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingCodec *videoCodec;
+@property (copy, nonatomic, readonly, nullable) SDLVideoStreamingCodec videoCodec;
-- (instancetype)initWithMTU:(int64_t)mtu height:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec;
+- (instancetype)initWithMTU:(int64_t)mtu height:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol)protocol codec:(SDLVideoStreamingCodec)codec;
@end
diff --git a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m
index e30fe1af7..d74d1c68c 100644
--- a/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m
+++ b/SmartDeviceLink/SDLControlFramePayloadVideoStartServiceAck.m
@@ -10,8 +10,6 @@
#import "bson_object.h"
#import "SDLControlFramePayloadConstants.h"
-#import "SDLVideoStreamingCodec.h"
-#import "SDLVideoStreamingProtocol.h"
@interface SDLControlFramePayloadVideoStartServiceAck ()
@@ -19,14 +17,14 @@
@property (assign, nonatomic, readwrite) int64_t mtu;
@property (assign, nonatomic, readwrite) int32_t height;
@property (assign, nonatomic, readwrite) int32_t width;
-@property (copy, nonatomic, readwrite) SDLVideoStreamingProtocol *videoProtocol;
-@property (copy, nonatomic, readwrite) SDLVideoStreamingCodec *videoCodec;
+@property (copy, nonatomic, readwrite) SDLVideoStreamingProtocol videoProtocol;
+@property (copy, nonatomic, readwrite) SDLVideoStreamingCodec videoCodec;
@end
@implementation SDLControlFramePayloadVideoStartServiceAck
-- (instancetype)initWithMTU:(int64_t)mtu height:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol *)protocol codec:(SDLVideoStreamingCodec *)codec {
+- (instancetype)initWithMTU:(int64_t)mtu height:(int32_t)height width:(int32_t)width protocol:(SDLVideoStreamingProtocol)protocol codec:(SDLVideoStreamingCodec)codec {
self = [super init];
if (!self) return nil;
@@ -79,11 +77,11 @@
}
if (self.videoProtocol != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.value.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoProtocolKey, (char *)self.videoProtocol.UTF8String);
}
if (self.videoCodec != nil) {
- bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.value.UTF8String);
+ bson_object_put_string(&payloadObject, SDLControlFrameVideoCodecKey, (char *)self.videoCodec.UTF8String);
}
BytePtr bsonData = bson_object_to_bytes(&payloadObject);
@@ -103,12 +101,12 @@
char *utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoProtocolKey);
if (utf8String != NULL) {
- self.videoProtocol = [SDLVideoStreamingProtocol valueOf:[NSString stringWithUTF8String:utf8String]];
+ self.videoProtocol = [NSString stringWithUTF8String:utf8String];
}
utf8String = bson_object_get_string(&payloadObject, SDLControlFrameVideoCodecKey);
if (utf8String != NULL) {
- self.videoCodec = [SDLVideoStreamingCodec valueOf:[NSString stringWithUTF8String:utf8String]];
+ self.videoCodec = [NSString stringWithUTF8String:utf8String];
}
bson_object_deinitialize(&payloadObject);
diff --git a/SmartDeviceLink/SDLGlobals.m b/SmartDeviceLink/SDLGlobals.m
index 066545df6..68f9c0378 100644
--- a/SmartDeviceLink/SDLGlobals.m
+++ b/SmartDeviceLink/SDLGlobals.m
@@ -75,8 +75,8 @@ typedef NSNumber* MTUBox;
- (NSUInteger)mtuSizeForServiceType:(SDLServiceType)serviceType {
if (self.dynamicMTUDict[@(serviceType)] != nil) {
return self.dynamicMTUDict[@(serviceType)].unsignedIntegerValue;
- } else if (self.dynamicMTUDict[@(SDLServiceType_RPC)]) {
- return self.dynamicMTUDict[@(SDLServiceType_RPC)].unsignedIntegerValue;
+ } else if (self.dynamicMTUDict[@(SDLServiceTypeRPC)]) {
+ return self.dynamicMTUDict[@(SDLServiceTypeRPC)].unsignedIntegerValue;
} else {
return [self sdl_defaultMaxMTUSize];
}
diff --git a/SmartDeviceLink/SDLHMICapabilities.h b/SmartDeviceLink/SDLHMICapabilities.h
index f31be93b7..6ab29741e 100644
--- a/SmartDeviceLink/SDLHMICapabilities.h
+++ b/SmartDeviceLink/SDLHMICapabilities.h
@@ -29,13 +29,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nullable, copy, nonatomic) NSNumber<SDLBool> *videoStreaming;
-/**
- Availability of build in video streaming. True: Available, False: Not Available
-
- Boolean value. Optional.
- */
-@property (copy, nonatomic) NSNumber *videoStreaming;
-
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLHMICapabilities.m b/SmartDeviceLink/SDLHMICapabilities.m
index 9a72b0fc4..01fd01949 100644
--- a/SmartDeviceLink/SDLHMICapabilities.m
+++ b/SmartDeviceLink/SDLHMICapabilities.m
@@ -35,18 +35,6 @@ NS_ASSUME_NONNULL_BEGIN
return [store sdl_objectForName:SDLNameVideoStreaming];
}
-- (void)setVideoStreaming:(NSNumber *)videoStreaming {
- if (videoStreaming != nil) {
- store[NAMES_videoStreaming] = videoStreaming;
- } else {
- [store removeObjectForKey:NAMES_videoStreaming];
- }
-}
-
-- (NSNumber *)videoStreaming {
- return store[NAMES_videoStreaming];
-}
-
@end
NS_ASSUME_NONNULL_END
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index f1d716d3c..bc5b06fc0 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -470,11 +470,11 @@ int const streamOpenTimeoutSeconds = 2;
return ^(NSInputStream *istream) {
__strong typeof(weakSelf) strongSelf = weakSelf;
- uint8_t buf[[[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceType_RPC]];
+ uint8_t buf[[[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC]];
while (istream.streamStatus == NSStreamStatusOpen && istream.hasBytesAvailable) {
// It is necessary to check the stream status and whether there are bytes available because the dataStreamHasBytesHandler is executed on the IO thread and the accessory disconnect notification arrives on the main thread, causing data to be passed to the delegate while the main thread is tearing down the transport.
- NSInteger bytesRead = [istream read:buf maxLength:[[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceType_RPC]];
+ NSInteger bytesRead = [istream read:buf maxLength:[[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC]];
NSData *dataIn = [NSData dataWithBytes:buf length:bytesRead];
SDLLogBytes(dataIn, SDLLogBytesDirectionReceive);
diff --git a/SmartDeviceLink/SDLProtocol.h b/SmartDeviceLink/SDLProtocol.h
index b039e83d8..ea6df9667 100644
--- a/SmartDeviceLink/SDLProtocol.h
+++ b/SmartDeviceLink/SDLProtocol.h
@@ -19,10 +19,10 @@ extern NSString *const SDLProtocolSecurityErrorDomain;
// Sending
- (void)sendStartSessionWithType:(SDLServiceType)serviceType __deprecated_msg(("Use startServiceWithType: instead"));
- (void)startServiceWithType:(SDLServiceType)serviceType __deprecated_msg(("Use startServiceWithType:payload: instead"));
-- (void)startServiceWithType:(SDLServiceType)serviceType payload:(NSData *)payload;
+- (void)startServiceWithType:(SDLServiceType)serviceType payload:(nullable NSData *)payload;
- (void)startSecureServiceWithType:(SDLServiceType)serviceType completionHandler:(void (^)(BOOL success, NSError *error))completionHandler __deprecated_msg(("Use startSecureServiceWithType:payload:completionHandler instead"));
-- (void)startSecureServiceWithType:(SDLServiceType)serviceType payload:(NSData *)payload completionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
+- (void)startSecureServiceWithType:(SDLServiceType)serviceType payload:(nullable NSData *)payload completionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
- (void)sendEndSessionWithType:(SDLServiceType)serviceType __deprecated_msg(("Use endServiceWithType: instead"));
- (void)endServiceWithType:(SDLServiceType)serviceType;
diff --git a/SmartDeviceLink/SDLProtocol.m b/SmartDeviceLink/SDLProtocol.m
index e70cb036e..9d22fa602 100644
--- a/SmartDeviceLink/SDLProtocol.m
+++ b/SmartDeviceLink/SDLProtocol.m
@@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN
[self startServiceWithType:serviceType payload:nil];
}
-- (void)startServiceWithType:(SDLServiceType)serviceType payload:(NSData *)payload {
+- (void)startServiceWithType:(SDLServiceType)serviceType payload:(nullable NSData *)payload {
// No encryption, just build and send the message synchronously
SDLProtocolMessage *message = [self sdl_createStartServiceMessageWithType:serviceType encrypted:NO payload:payload];
[self sdl_sendDataToTransport:message.data onService:serviceType];
@@ -99,7 +99,7 @@ NS_ASSUME_NONNULL_BEGIN
[self startSecureServiceWithType:serviceType payload:nil completionHandler:completionHandler];
}
-- (void)startSecureServiceWithType:(SDLServiceType)serviceType payload:(NSData *)payload completionHandler:(void (^)(BOOL success, NSError *error))completionHandler {
+- (void)startSecureServiceWithType:(SDLServiceType)serviceType payload:(nullable NSData *)payload completionHandler:(void (^)(BOOL success, NSError *error))completionHandler {
[self sdl_initializeTLSEncryptionWithCompletionHandler:^(BOOL success, NSError *error) {
if (!success) {
// We can't start the service because we don't have encryption, return the error
@@ -113,7 +113,7 @@ NS_ASSUME_NONNULL_BEGIN
}];
}
-- (SDLProtocolMessage *)sdl_createStartServiceMessageWithType:(SDLServiceType)serviceType encrypted:(BOOL)encryption payload:(NSData *)payload {
+- (SDLProtocolMessage *)sdl_createStartServiceMessageWithType:(SDLServiceType)serviceType encrypted:(BOOL)encryption payload:(nullable NSData *)payload {
SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals sharedGlobals].majorProtocolVersion];
NSData *servicePayload = payload;
@@ -199,7 +199,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)sendRPC:(SDLRPCMessage *)message encrypted:(BOOL)encryption error:(NSError *__autoreleasing *)error {
NSParameterAssert(message != nil);
- NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[message serializeAsDictionary:[SDLGlobals sharedGlobals].protocolVersion] options:kNilOptions error:error];
+ NSData *jsonData = [NSJSONSerialization dataWithJSONObject:[message serializeAsDictionary:[SDLGlobals sharedGlobals].majorProtocolVersion] options:kNilOptions error:error];
if (error != nil) {
SDLLogW(@"Error encoding JSON data: %@", *error);
@@ -270,7 +270,7 @@ NS_ASSUME_NONNULL_BEGIN
SDLProtocolMessage *protocolMessage = [SDLProtocolMessage messageWithHeader:header andPayload:messagePayload];
// See if the message is small enough to send in one transmission. If not, break it up into smaller messages and send.
- if (protocolMessage.size < [[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC] {
+ if (protocolMessage.size < [[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC]) {
SDLLogV(@"Sending protocol message: %@", protocolMessage);
[self sdl_sendDataToTransport:protocolMessage.data onService:SDLServiceTypeRPC];
} else {
@@ -335,7 +335,7 @@ NS_ASSUME_NONNULL_BEGIN
SDLLogV(@"Sending protocol message: %@", message);
[self sdl_sendDataToTransport:message.data onService:header.serviceType];
} else {
- NSArray<SDLProtocolMessage *> *messages = [SDLProtocolMessageDisassembler disassemble:message withLimit:[SDLGlobals sharedGlobals].maxMTUSize];
+ NSArray<SDLProtocolMessage *> *messages = [SDLProtocolMessageDisassembler disassemble:message withLimit:[[SDLGlobals sharedGlobals] mtuSizeForServiceType:service]];
for (SDLProtocolMessage *smallerMessage in messages) {
SDLLogV(@"Sending protocol message: %@", smallerMessage);
[self sdl_sendDataToTransport:smallerMessage.data onService:header.serviceType];
@@ -350,7 +350,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)handleBytesFromTransport:(NSData *)receivedData {
// Initialize the receive buffer which will contain bytes while messages are constructed.
if (self.receiveBuffer == nil) {
- self.receiveBuffer = [NSMutableData dataWithCapacity:(4 * [[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC]];
+ self.receiveBuffer = [NSMutableData dataWithCapacity:(4 * [[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC])];
}
// Save the data
@@ -360,7 +360,7 @@ NS_ASSUME_NONNULL_BEGIN
}
- (void)processMessages {
- UInt8 incomingVersion = [SDLProtocolMessage determineVersion:self.receiveBuffer];
+ UInt8 incomingVersion = [SDLProtocolHeader determineVersion:self.receiveBuffer];
// If we have enough bytes, create the header.
SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:incomingVersion];
@@ -418,14 +418,14 @@ NS_ASSUME_NONNULL_BEGIN
// V5 Packet
if (startServiceACK.header.version >= 5) {
switch (startServiceACK.header.serviceType) {
- case SDLServiceType_RPC: {
+ case SDLServiceTypeRPC: {
SDLControlFramePayloadRPCStartServiceAck *startServiceACKPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithData:startServiceACK.payload];
// NSLog(@"ServiceAckPayload: %@", startServiceACKPayload);
if (startServiceACKPayload.mtu != SDLControlFrameInt64NotFound) {
- [[SDLGlobals globals] setDynamicMTUSize:startServiceACKPayload.mtu forServiceType:startServiceACK.header.serviceType];
+ [[SDLGlobals sharedGlobals] setDynamicMTUSize:startServiceACKPayload.mtu forServiceType:startServiceACK.header.serviceType];
}
- [SDLGlobals globals].maxHeadUnitVersion = (startServiceACKPayload.protocolVersion != nil) ? startServiceACKPayload.protocolVersion : [NSString stringWithFormat:@"%u.0.0", startServiceACK.header.version];
+ [SDLGlobals sharedGlobals].maxHeadUnitVersion = (startServiceACKPayload.protocolVersion != nil) ? startServiceACKPayload.protocolVersion : [NSString stringWithFormat:@"%u.0.0", startServiceACK.header.version];
// TODO: Hash id?
} break;
default:
@@ -434,8 +434,8 @@ NS_ASSUME_NONNULL_BEGIN
} else {
// V4 and below packet
switch (startServiceACK.header.serviceType) {
- case SDLServiceType_RPC: {
- [SDLGlobals globals].maxHeadUnitVersion = [NSString stringWithFormat:@"%u.0.0", startServiceACK.header.version];
+ case SDLServiceTypeRPC: {
+ [SDLGlobals sharedGlobals].maxHeadUnitVersion = [NSString stringWithFormat:@"%u.0.0", startServiceACK.header.version];
} break;
default:
break;
@@ -520,7 +520,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)handleHeartbeatForSession:(Byte)session {
// Respond with a heartbeat ACK
- SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals sharedGlobals].protocolVersion];
+ SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals sharedGlobals].majorProtocolVersion];
header.frameType = SDLFrameTypeControl;
header.serviceType = SDLServiceTypeControl;
header.frameData = SDLFrameInfoHeartbeatACK;
@@ -586,8 +586,7 @@ NS_ASSUME_NONNULL_BEGIN
SDLControlFramePayloadNak *endServiceNakPayload = [[SDLControlFramePayloadNak alloc] initWithData:nakMessage.payload];
NSArray<NSString *> *rejectedParams = endServiceNakPayload.rejectedParams;
if (rejectedParams.count > 0) {
- NSString *log = [NSString stringWithFormat:@"Start Service NAK'd, service type: %@, rejectedParams: %@", @(nakMessage.header.serviceType), rejectedParams];
- [SDLDebugTool logInfo:log];
+ SDLLogE(@"Start Service NAK'd, service type: %@, rejectedParams: %@", @(nakMessage.header.serviceType), rejectedParams);
}
}
}
diff --git a/SmartDeviceLink/SDLProtocolReceivedMessageRouter.m b/SmartDeviceLink/SDLProtocolReceivedMessageRouter.m
index 831cafecb..cb12229cf 100644
--- a/SmartDeviceLink/SDLProtocolReceivedMessageRouter.m
+++ b/SmartDeviceLink/SDLProtocolReceivedMessageRouter.m
@@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)sdl_dispatchControlMessage:(SDLProtocolMessage *)message {
switch (message.header.frameData) {
- case SDLFrameData_StartSessionACK: {
+ case SDLFrameInfoStartServiceACK: {
if ([self.delegate respondsToSelector:@selector(handleProtocolStartServiceACKMessage:)]) {
[self.delegate handleProtocolStartServiceACKMessage:message];
}
diff --git a/SmartDeviceLink/SDLUploadFileOperation.m b/SmartDeviceLink/SDLUploadFileOperation.m
index 0a3ca201b..44af473ce 100644
--- a/SmartDeviceLink/SDLUploadFileOperation.m
+++ b/SmartDeviceLink/SDLUploadFileOperation.m
@@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)start {
[super start];
- [self sdl_sendPutFiles:[self.class sdl_splitFile:self.fileWrapper.file mtuSize:[[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC]] withCompletion:self.fileWrapper.completionHandler];
+ [self sdl_sendFile:self.fileWrapper.file mtuSize:[[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeRPC] withCompletion:self.fileWrapper.completionHandler];
}
/**
@@ -62,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
@param mtuSize The maximum packet size allowed
@param completion Closure returning whether or not the upload was a success
*/
-- (void)sdl_sendPutFiles:(SDLFile *)file mtuSize:(NSUInteger)mtuSize withCompletion:(SDLFileManagerUploadCompletionHandler)completion {
+- (void)sdl_sendFile:(SDLFile *)file mtuSize:(NSUInteger)mtuSize withCompletion:(SDLFileManagerUploadCompletionHandler)completion {
__block NSError *streamError = nil;
__block NSUInteger bytesAvailable = 0;
__block NSInteger highestCorrelationIDReceived = -1;
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
index 970a75ebe..6d9474568 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLUploadFileOperationSpec.m
@@ -28,7 +28,7 @@ describe(@"Streaming upload of data", ^{
__block NSError *errorResult = nil;
beforeEach(^{
- [SDLGlobals sharedGlobals].maxHeadUnitVersion = 2;
+ [SDLGlobals sharedGlobals].maxHeadUnitVersion = @"2.0.0";
testFileName = nil;
testFileData = nil;
@@ -87,7 +87,7 @@ describe(@"Streaming upload of data", ^{
errorResult = error;
}];
- numberOfPutFiles = ((([testFile fileSize] - 1) / [SDLGlobals sharedGlobals].maxMTUSize) + 1);
+ numberOfPutFiles = ((([testFile fileSize] - 1) / [[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeBulkData]) + 1);
testConnectionManager = [[TestConnectionManager alloc] init];
testOperation = [[SDLUploadFileOperation alloc] initWithFile:testFileWrapper connectionManager:testConnectionManager];
@@ -105,10 +105,12 @@ describe(@"Streaming upload of data", ^{
for (NSUInteger index = 0; index < numberOfPutFiles; index++) {
SDLPutFile *putFile = putFiles[index];
- expect(putFile.offset).to(equal(@(index * [SDLGlobals sharedGlobals].maxMTUSize)));
+ NSUInteger mtuSize = [[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeBulkData];
+
+ expect(putFile.offset).to(equal(@(index * mtuSize)));
expect(putFile.persistentFile).to(equal(@NO));
expect(putFile.syncFileName).to(equal(testFileName));
- expect(putFile.bulkData).to(equal([testFileData subdataWithRange:NSMakeRange((index * [SDLGlobals sharedGlobals].maxMTUSize), MIN(putFile.length.unsignedIntegerValue, [SDLGlobals sharedGlobals].maxMTUSize))]));
+ expect(putFile.bulkData).to(equal([testFileData subdataWithRange:NSMakeRange((index * mtuSize), MIN(putFile.length.unsignedIntegerValue, mtuSize))]));
// Length is used to inform the SDL Core of the total incoming packet size
if (index == 0) {
@@ -116,10 +118,10 @@ describe(@"Streaming upload of data", ^{
expect(putFile.length).to(equal(@([testFile fileSize])));
} else if (index == numberOfPutFiles - 1) {
// The last pufile contains the remaining data size
- expect(putFile.length).to(equal(@([testFile fileSize] - (index * [SDLGlobals sharedGlobals].maxMTUSize))));
+ expect(putFile.length).to(equal(@([testFile fileSize] - (index * mtuSize))));
} else {
// All other putfiles contain the max data size for a putfile packet
- expect(putFile.length).to(equal(@([SDLGlobals sharedGlobals].maxMTUSize)));
+ expect(putFile.length).to(equal(@(mtuSize)));
}
}
});
@@ -158,7 +160,9 @@ describe(@"Streaming upload of data", ^{
errorResult = error;
}];
- numberOfPutFiles = ((([testFile fileSize] - 1) / [SDLGlobals sharedGlobals].maxMTUSize) + 1);
+ NSUInteger mtuSize = [[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeBulkData];
+
+ numberOfPutFiles = ((([testFile fileSize] - 1) / mtuSize) + 1);
testConnectionManager = [[TestConnectionManager alloc] init];
testOperation = [[SDLUploadFileOperation alloc] initWithFile:testFileWrapper connectionManager:testConnectionManager];
diff --git a/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m
index 1a5e9cc9d..1af113777 100644
--- a/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m
+++ b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFramePayloadVideoStartServiceSpec.m
@@ -15,15 +15,15 @@ describe(@"Test encoding data", ^{
__block SDLControlFramePayloadVideoStartService *testPayload = nil;
__block int32_t testHeight = SDLControlFrameInt32NotFound;
__block int32_t testWidth = SDLControlFrameInt32NotFound;
- __block SDLVideoStreamingCodec *testCodec = nil;
- __block SDLVideoStreamingProtocol *testProtocol = nil;
+ __block SDLVideoStreamingCodec testCodec = nil;
+ __block SDLVideoStreamingProtocol testProtocol = nil;
context(@"with paramaters", ^{
beforeEach(^{
testHeight = 59794;
testWidth = 363;
- testCodec = [SDLVideoStreamingCodec H265];
- testProtocol = [SDLVideoStreamingProtocol RTMP];
+ testCodec = SDLVideoStreamingCodecH265;
+ testProtocol = SDLVideoStreamingProtocolRTMP;
testPayload = [[SDLControlFramePayloadVideoStartService alloc] initWithVideoHeight:testHeight width:testWidth protocol:testProtocol codec:testCodec];
});
@@ -54,14 +54,14 @@ describe(@"Test decoding data", ^{
__block NSData *testData = nil;
__block int32_t testHeight = SDLControlFrameInt32NotFound;
__block int32_t testWidth = SDLControlFrameInt32NotFound;
- __block SDLVideoStreamingCodec *testCodec = nil;
- __block SDLVideoStreamingProtocol *testProtocol = nil;
+ __block SDLVideoStreamingCodec testCodec = nil;
+ __block SDLVideoStreamingProtocol testProtocol = nil;
beforeEach(^{
testHeight = 787;
testWidth = 36365;
- testCodec = [SDLVideoStreamingCodec THEORA];
- testProtocol = [SDLVideoStreamingProtocol RTSP];
+ testCodec = SDLVideoStreamingCodecTheora;
+ testProtocol = SDLVideoStreamingProtocolRTSP;
SDLControlFramePayloadVideoStartService *firstPayload = [[SDLControlFramePayloadVideoStartService alloc] initWithVideoHeight:testHeight width:testWidth protocol:testProtocol codec:testCodec];
testData = firstPayload.data;
diff --git a/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m
index b52740312..cc7db881c 100644
--- a/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m
+++ b/SmartDeviceLinkTests/ProtocolSpecs/ControlFramePayloadSpecs/SDLControlFrameVideoStartServiceAckSpec.m
@@ -16,16 +16,16 @@ describe(@"Test encoding data", ^{
__block int64_t testMTU = SDLControlFrameInt64NotFound;
__block int32_t testHeight = SDLControlFrameInt32NotFound;
__block int32_t testWidth = SDLControlFrameInt32NotFound;
- __block SDLVideoStreamingCodec *testCodec = nil;
- __block SDLVideoStreamingProtocol *testProtocol = nil;
+ __block SDLVideoStreamingCodec testCodec = nil;
+ __block SDLVideoStreamingProtocol testProtocol = nil;
context(@"with paramaters", ^{
beforeEach(^{
testMTU = 1247988;
testHeight = 5974;
testWidth = 36;
- testCodec = [SDLVideoStreamingCodec H264];
- testProtocol = [SDLVideoStreamingProtocol RAW];
+ testCodec = SDLVideoStreamingCodecH264;
+ testProtocol = SDLVideoStreamingProtocolRAW;
testPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:testHeight width:testWidth protocol:testProtocol codec:testCodec];
});
@@ -58,15 +58,15 @@ describe(@"Test decoding data", ^{
__block int64_t testMTU = SDLControlFrameInt64NotFound;
__block int32_t testHeight = SDLControlFrameInt32NotFound;
__block int32_t testWidth = SDLControlFrameInt32NotFound;
- __block SDLVideoStreamingCodec *testCodec = nil;
- __block SDLVideoStreamingProtocol *testProtocol = nil;
+ __block SDLVideoStreamingCodec testCodec = nil;
+ __block SDLVideoStreamingProtocol testProtocol = nil;
beforeEach(^{
testMTU = 4584651;
testHeight = 787;
testWidth = 36365;
- testCodec = [SDLVideoStreamingCodec VP8];
- testProtocol = [SDLVideoStreamingProtocol RTSP];
+ testCodec = SDLVideoStreamingCodecVP8;
+ testProtocol = SDLVideoStreamingProtocolRTSP;
SDLControlFramePayloadVideoStartServiceAck *firstPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithMTU:testMTU height:testHeight width:testWidth protocol:testProtocol codec:testCodec];
testData = firstPayload.data;
diff --git a/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m
index 12c5e248d..c83cd1242 100644
--- a/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m
+++ b/SmartDeviceLinkTests/ProtocolSpecs/HeaderSpecs/SDLProtocolHeaderSpec.m
@@ -26,4 +26,16 @@ describe(@"HeaderForVersion Tests", ^ {
});
});
+describe(@"DetermineVersion Tests", ^ {
+ it(@"Should return the correct version", ^ {
+ const char bytesV1[8] = {0x10 | SDLFrameTypeFirst, SDLServiceTypeBulkData, SDLFrameInfoStartServiceACK, 0x5E, 0x00, 0x00, 0x00, 0x00};
+ NSData* messageV1 = [NSData dataWithBytes:bytesV1 length:8];
+ expect(@([SDLProtocolHeader determineVersion:messageV1])).to(equal(@1));
+
+ const char bytesV2[12] = {0x20 | SDLFrameTypeFirst, SDLServiceTypeBulkData, SDLFrameInfoStartServiceACK, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44};
+ NSData* messageV2 = [NSData dataWithBytes:bytesV2 length:12];
+ expect(@([SDLProtocolHeader determineVersion:messageV2])).to(equal(@2));
+ });
+});
+
QuickSpecEnd
diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m
index 4ab0eabb8..8c6f03f9c 100644
--- a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m
+++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolMessageSpec.m
@@ -38,18 +38,6 @@ describe(@"MessageWithHeader Tests", ^ {
});
});
-describe(@"DetermineVersion Tests", ^ {
- it(@"Should return the correct version", ^ {
- const char bytesV1[8] = {0x10 | SDLFrameTypeFirst, SDLServiceTypeBulkData, SDLFrameInfoStartServiceACK, 0x5E, 0x00, 0x00, 0x00, 0x00};
- NSData* messageV1 = [NSData dataWithBytes:bytesV1 length:8];
- expect(@([SDLProtocolMessage determineVersion:messageV1])).to(equal(@1));
-
- const char bytesV2[12] = {0x20 | SDLFrameTypeFirst, SDLServiceTypeBulkData, SDLFrameInfoStartServiceACK, 0x5E, 0x00, 0x00, 0x00, 0x00, 0x44, 0x44, 0x44, 0x44};
- NSData* messageV2 = [NSData dataWithBytes:bytesV2 length:12];
- expect(@([SDLProtocolMessage determineVersion:messageV2])).to(equal(@2));
- });
-});
-
describe(@"Data tests", ^ {
it(@"Should return the correct data", ^ {
SDLProtocolMessage* testMessage = [[SDLProtocolMessage alloc] init];
diff --git a/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m b/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m
index 191f7b705..7d203b75d 100644
--- a/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m
+++ b/SmartDeviceLinkTests/UtilitiesSpecs/SDLGlobalsSpec.m
@@ -26,7 +26,7 @@ describe(@"The SDLGlobals class", ^{
});
it(@"should give the v1 MTU size", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(SDLV1MTUSize));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV1MTUSize));
});
});
@@ -52,24 +52,24 @@ describe(@"The SDLGlobals class", ^{
context(@"when protocol version is 1 - 2", ^{
it(@"should return the correct value when protocol version is 1", ^{
testGlobals.maxHeadUnitVersion = @"1.0.0";
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(SDLV1MTUSize));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV1MTUSize));
});
it(@"should return the correct value when protocol version is 2", ^{
testGlobals.maxHeadUnitVersion = @"2.0.0";
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(SDLV1MTUSize));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV1MTUSize));
});
});
context(@"when protocol version is 3 - 4", ^{
it(@"should return the correct value when protocol version is 3", ^{
testGlobals.maxHeadUnitVersion = @"3.0.0";
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(SDLV3MTUSize));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV3MTUSize));
});
it(@"should return the correct value when protocol version is 4", ^{
testGlobals.maxHeadUnitVersion = @"4.0.0";
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(SDLV3MTUSize));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV3MTUSize));
});
describe(@"when the max proxy version is lower than max head unit version", ^{
@@ -79,7 +79,7 @@ describe(@"The SDLGlobals class", ^{
});
it(@"should return the v1 - 2 value", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(SDLV1MTUSize));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV1MTUSize));
});
});
});
@@ -96,44 +96,44 @@ describe(@"The SDLGlobals class", ^{
context(@"Setting the RPC service MTU", ^{
beforeEach(^{
- [testGlobals setDynamicMTUSize:dynamicMTUSize1 forServiceType:SDLServiceType_RPC];
+ [testGlobals setDynamicMTUSize:dynamicMTUSize1 forServiceType:SDLServiceTypeRPC];
});
it(@"should set the RPC service MTU", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(dynamicMTUSize1));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(dynamicMTUSize1));
});
it(@"should have the video service fall back to the RPC service MTU", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_Video]).to(equal(dynamicMTUSize1));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeVideo]).to(equal(dynamicMTUSize1));
});
});
context(@"setting the video service MTU", ^{
beforeEach(^{
- [testGlobals setDynamicMTUSize:dynamicMTUSize1 forServiceType:SDLServiceType_Video];
+ [testGlobals setDynamicMTUSize:dynamicMTUSize1 forServiceType:SDLServiceTypeVideo];
});
it(@"should not set the RPC service MTU", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(SDLV3MTUSize));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(SDLV3MTUSize));
});
it(@"should have the video service fall back to the RPC service MTU", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_Video]).to(equal(dynamicMTUSize1));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeVideo]).to(equal(dynamicMTUSize1));
});
});
context(@"setting both the video service and RPC service MTU", ^{
beforeEach(^{
- [testGlobals setDynamicMTUSize:dynamicMTUSize1 forServiceType:SDLServiceType_RPC];
- [testGlobals setDynamicMTUSize:dynamicMTUSize2 forServiceType:SDLServiceType_Video];
+ [testGlobals setDynamicMTUSize:dynamicMTUSize1 forServiceType:SDLServiceTypeRPC];
+ [testGlobals setDynamicMTUSize:dynamicMTUSize2 forServiceType:SDLServiceTypeVideo];
});
it(@"should set the RPC service MTU", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_RPC]).to(equal(dynamicMTUSize1));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeRPC]).to(equal(dynamicMTUSize1));
});
it(@"should have the video service fall back to the RPC service MTU", ^{
- expect([testGlobals mtuSizeForServiceType:SDLServiceType_Video]).to(equal(dynamicMTUSize2));
+ expect([testGlobals mtuSizeForServiceType:SDLServiceTypeVideo]).to(equal(dynamicMTUSize2));
});
});
});