summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2017-07-27 15:50:19 -0400
committerJoel Fischer <joeljfischer@gmail.com>2017-07-27 15:50:19 -0400
commit22a8682154503400b3043f0f3ee70833f8c5c1ee (patch)
tree63a57be100049bd0b99acdab88beb9c1217aec55
parentbc8e676ef7d363daf8d4d7193e5f9e38c445dcb1 (diff)
downloadsdl_ios-22a8682154503400b3043f0f3ee70833f8c5c1ee.tar.gz
Implemented dynamic MTU per service
-rw-r--r--SmartDeviceLink/SDLAbstractProtocol.h14
-rw-r--r--SmartDeviceLink/SDLAbstractProtocol.m10
-rw-r--r--SmartDeviceLink/SDLGlobals.h6
-rw-r--r--SmartDeviceLink/SDLGlobals.m66
-rw-r--r--SmartDeviceLink/SDLIAPTransport.m4
-rw-r--r--SmartDeviceLink/SDLProtocol.h8
-rw-r--r--SmartDeviceLink/SDLProtocol.m41
-rw-r--r--SmartDeviceLink/SDLProxy.m2
-rw-r--r--SmartDeviceLink/SDLStreamingMediaManager.m90
-rw-r--r--SmartDeviceLink/SDLUploadFileOperation.m2
10 files changed, 157 insertions, 86 deletions
diff --git a/SmartDeviceLink/SDLAbstractProtocol.h b/SmartDeviceLink/SDLAbstractProtocol.h
index a8277dac3..664ace5f6 100644
--- a/SmartDeviceLink/SDLAbstractProtocol.h
+++ b/SmartDeviceLink/SDLAbstractProtocol.h
@@ -19,14 +19,20 @@
@property (nonatomic, copy) NSString *appId;
// Sending
-- (void)sendStartSessionWithType:(SDLServiceType)serviceType __deprecated_msg(("Use startServiceWithType: instead"));
-- (void)startServiceWithType:(SDLServiceType)serviceType;
-- (void)startSecureServiceWithType:(SDLServiceType)serviceType completionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
+- (void)sendStartSessionWithType:(SDLServiceType)serviceType __deprecated_msg(("Use startServiceWithType:payload: instead"));
+- (void)startServiceWithType:(SDLServiceType)serviceType __deprecated_msg(("Use startServiceWithType:payload: instead"));
+- (void)startServiceWithType:(SDLServiceType)serviceType payload:(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)sendEndSessionWithType:(SDLServiceType)serviceType __deprecated_msg(("Use endServiceWithType: instead"));
- (void)endServiceWithType:(SDLServiceType)serviceType;
+
+- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest __deprecated_msg(("Use sendRPC: instead"));
- (void)sendRPC:(SDLRPCMessage *)message;
- (BOOL)sendRPC:(SDLRPCMessage *)message encrypted:(BOOL)encryption error:(NSError **)error;
-- (void)sendRPCRequest:(SDLRPCRequest *)rpcRequest __deprecated_msg(("Use sendRPC: instead"));
+
- (void)sendRawData:(NSData *)data withServiceType:(SDLServiceType)serviceType;
- (void)sendEncryptedRawData:(NSData *)data onService:(SDLServiceType)serviceType;
diff --git a/SmartDeviceLink/SDLAbstractProtocol.m b/SmartDeviceLink/SDLAbstractProtocol.m
index 37d18bfef..69301de44 100644
--- a/SmartDeviceLink/SDLAbstractProtocol.m
+++ b/SmartDeviceLink/SDLAbstractProtocol.m
@@ -24,7 +24,15 @@
[self doesNotRecognizeSelector:_cmd];
}
-- (void)startSecureServiceWithType:(SDLServiceType)serviceType completionHandler:(void (^)(BOOL success, NSError *error))completionHandler {
+- (void)startServiceWithType:(SDLServiceType)serviceType payload:(NSData *)payload {
+ [self doesNotRecognizeSelector:_cmd];
+}
+
+- (void)startSecureServiceWithType:(SDLServiceType)serviceType completionHandler:(void (^)(BOOL, NSError *))completionHandler {
+ [self doesNotRecognizeSelector:_cmd];
+}
+
+- (void)startSecureServiceWithType:(SDLServiceType)serviceType payload:(NSData *)payload completionHandler:(void (^)(BOOL, NSError *))completionHandler {
[self doesNotRecognizeSelector:_cmd];
}
diff --git a/SmartDeviceLink/SDLGlobals.h b/SmartDeviceLink/SDLGlobals.h
index 990157069..4dc025dc4 100644
--- a/SmartDeviceLink/SDLGlobals.h
+++ b/SmartDeviceLink/SDLGlobals.h
@@ -8,6 +8,8 @@
#import <Foundation/Foundation.h>
+#import "SDLProtocolHeader.h"
+
#define SDL_SYSTEM_VERSION_LESS_THAN(version) ([[[UIDevice currentDevice] systemVersion] compare:version options:NSNumericSearch] == NSOrderedAscending)
#define BLOCK_RETURN return
@@ -21,9 +23,11 @@ extern NSUInteger const SDLV3MTUSize;
@property (strong, nonatomic, readonly) NSString *protocolVersion;
@property (assign, nonatomic, readonly) NSInteger majorProtocolVersion;
-@property (assign, nonatomic) NSUInteger maxMTUSize;
@property (strong, nonatomic) NSString *maxHeadUnitVersion;
+ (instancetype)globals;
+- (void)setDynamicMTUSize:(NSUInteger)maxMTUSize forServiceType:(SDLServiceType)serviceType;
+- (NSUInteger)mtuSizeForServiceType:(SDLServiceType)serviceType;
+
@end
diff --git a/SmartDeviceLink/SDLGlobals.m b/SmartDeviceLink/SDLGlobals.m
index 8be8afc64..ae0912857 100644
--- a/SmartDeviceLink/SDLGlobals.m
+++ b/SmartDeviceLink/SDLGlobals.m
@@ -16,9 +16,13 @@ NSUInteger const SDLV1MTUSize = 1024;
NSUInteger const SDLV3MTUSize = 131024;
+typedef NSNumber* ServiceTypeBox;
+typedef NSNumber* MTUBox;
+
+
@interface SDLGlobals ()
-@property (assign, nonatomic) NSUInteger backingMaxMTUSize;
+@property (strong, nonatomic) NSMutableDictionary<ServiceTypeBox, MTUBox> *dynamicMTUDict;
@property (strong, nonatomic, readwrite) NSString *protocolVersion;
@end
@@ -44,7 +48,6 @@ NSUInteger const SDLV3MTUSize = 131024;
_protocolVersion = @"1.0.0";
_maxHeadUnitVersion = @"0.0.0";
- _backingMaxMTUSize = SDLDefaultMTUSize;
return self;
}
@@ -58,7 +61,38 @@ NSUInteger const SDLV3MTUSize = 131024;
_maxHeadUnitVersion = maxHeadUnitVersion;
}
-- (NSUInteger)maxMTUSize {
+- (NSInteger)majorProtocolVersion {
+ return [self.protocolVersion substringWithRange:NSMakeRange(0, 1)].integerValue;
+}
+
+- (void)setProtocolVersion:(NSString *)protocolVersion {
+ _protocolVersion = protocolVersion;
+
+
+}
+
+- (void)setDynamicMTUSize:(NSUInteger)maxMTUSize forServiceType:(SDLServiceType)serviceType {
+ self.dynamicMTUDict[@(serviceType)] = @(maxMTUSize);
+}
+
+- (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 {
+ return [self sdl_defaultMaxMTUSize];
+ }
+}
+
+
+#pragma mark - Helpers
+
+- (BOOL)sdl_isVersion:(NSString *)version1 greaterThanVersion:(NSString *)version2 {
+ return ([version1 compare:version2 options:NSNumericSearch] == NSOrderedDescending);
+}
+
+- (NSUInteger)sdl_defaultMaxMTUSize {
// VERSION DEPENDENT CODE
switch (self.majorProtocolVersion) {
case 1: // fallthrough
@@ -67,7 +101,8 @@ NSUInteger const SDLV3MTUSize = 131024;
return SDLV1MTUSize;
} break;
case 3: // fallthrough
- case 4: {
+ case 4: // fallthrough
+ case 5: {
// If the head unit isn't running v3/4, but that's the connection scheme we're using, then we have to know that they could be running an MTU that's not 128k, so we default back to the v1/2 MTU for safety.
if ([self sdl_isVersion:self.maxHeadUnitVersion greaterThanVersion:SDLMaxProxyProtocolVersion]) {
return SDLV1MTUSize;
@@ -75,14 +110,6 @@ NSUInteger const SDLV3MTUSize = 131024;
return SDLV3MTUSize;
}
} break;
- case 5: {
- // V5 has a negotiated MTU size from the head unit
- if (self.backingMaxMTUSize == SDLDefaultMTUSize) {
- return SDLV3MTUSize;
- } else {
- return self.backingMaxMTUSize;
- }
- }
default: {
NSAssert(NO, @"Unknown version number for MTU Size: %@", @(self.majorProtocolVersion));
return 0;
@@ -90,19 +117,4 @@ NSUInteger const SDLV3MTUSize = 131024;
}
}
-- (void)setMaxMTUSize:(NSUInteger)maxMTUSize {
- _backingMaxMTUSize = maxMTUSize;
-}
-
-- (NSInteger)majorProtocolVersion {
- return [self.protocolVersion substringWithRange:NSMakeRange(0, 1)].integerValue;
-}
-
-
-#pragma mark - Helpers
-
-- (BOOL)sdl_isVersion:(NSString *)version1 greaterThanVersion:(NSString *)version2 {
- return ([version1 compare:version2 options:NSNumericSearch] == NSOrderedDescending);
-}
-
@end
diff --git a/SmartDeviceLink/SDLIAPTransport.m b/SmartDeviceLink/SDLIAPTransport.m
index cee814556..6dd55e3a2 100644
--- a/SmartDeviceLink/SDLIAPTransport.m
+++ b/SmartDeviceLink/SDLIAPTransport.m
@@ -442,11 +442,11 @@ int const streamOpenTimeoutSeconds = 2;
return ^(NSInputStream *istream) {
__strong typeof(weakSelf) strongSelf = weakSelf;
- uint8_t buf[[SDLGlobals globals].maxMTUSize];
+ uint8_t buf[[[SDLGlobals globals] mtuSizeForServiceType:SDLServiceType_RPC]];
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 globals].maxMTUSize];
+ NSInteger bytesRead = [istream read:buf maxLength:[[SDLGlobals globals] mtuSizeForServiceType:SDLServiceType_RPC]];
NSData *dataIn = [NSData dataWithBytes:buf length:bytesRead];
if (bytesRead > 0) {
diff --git a/SmartDeviceLink/SDLProtocol.h b/SmartDeviceLink/SDLProtocol.h
index 78b1c798e..0d7023ce9 100644
--- a/SmartDeviceLink/SDLProtocol.h
+++ b/SmartDeviceLink/SDLProtocol.h
@@ -15,8 +15,12 @@ extern NSString *const SDLProtocolSecurityErrorDomain;
// Sending
- (void)sendStartSessionWithType:(SDLServiceType)serviceType __deprecated_msg(("Use startServiceWithType: instead"));
-- (void)startServiceWithType:(SDLServiceType)serviceType;
-- (void)startSecureServiceWithType:(SDLServiceType)serviceType completionHandler:(void (^)(BOOL success, NSError *error))completionHandler;
+- (void)startServiceWithType:(SDLServiceType)serviceType __deprecated_msg(("Use startServiceWithType:payload: instead"));
+- (void)startServiceWithType:(SDLServiceType)serviceType payload:(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)sendEndSessionWithType:(SDLServiceType)serviceType __deprecated_msg(("Use endServiceWithType: instead"));
- (void)endServiceWithType:(SDLServiceType)serviceType;
- (void)sendRPC:(SDLRPCMessage *)message;
diff --git a/SmartDeviceLink/SDLProtocol.m b/SmartDeviceLink/SDLProtocol.m
index c8a305197..67bb6047f 100644
--- a/SmartDeviceLink/SDLProtocol.m
+++ b/SmartDeviceLink/SDLProtocol.m
@@ -80,19 +80,27 @@ typedef NSNumber SDLServiceTypeBox;
}
- (void)sendStartSessionWithType:(SDLServiceType)serviceType {
- [self startServiceWithType:serviceType];
+ [self startServiceWithType:serviceType payload:nil];
}
#pragma mark - Start Service
-- (void)startServiceWithType:(SDLServiceType)serviceType {
+- (void)startServiceWithtype:(SDLServiceType)serviceType {
+ [self startServiceWithType:serviceType payload:nil];
+}
+
+- (void)startServiceWithType:(SDLServiceType)serviceType payload:(NSData *)payload {
// No encryption, just build and send the message synchronously
- SDLProtocolMessage *message = [self sdl_createStartServiceMessageWithType:serviceType encrypted:NO];
+ SDLProtocolMessage *message = [self sdl_createStartServiceMessageWithType:serviceType encrypted:NO payload:payload];
[self sdl_sendDataToTransport:message.data onService:serviceType];
}
- (void)startSecureServiceWithType:(SDLServiceType)serviceType completionHandler:(void (^)(BOOL success, NSError *error))completionHandler {
+ [self startSecureServiceWithType:serviceType payload:nil completionHandler:completionHandler];
+}
+
+- (void)startSecureServiceWithType:(SDLServiceType)serviceType payload:(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
@@ -101,14 +109,14 @@ typedef NSNumber SDLServiceTypeBox;
}
// TLS initialization succeeded. Build and send the message.
- SDLProtocolMessage *message = [self sdl_createStartServiceMessageWithType:serviceType encrypted:YES];
+ SDLProtocolMessage *message = [self sdl_createStartServiceMessageWithType:serviceType encrypted:YES payload:nil];
[self sdl_sendDataToTransport:message.data onService:serviceType];
}];
}
-- (SDLProtocolMessage *)sdl_createStartServiceMessageWithType:(SDLServiceType)serviceType encrypted:(BOOL)encryption {
+- (SDLProtocolMessage *)sdl_createStartServiceMessageWithType:(SDLServiceType)serviceType encrypted:(BOOL)encryption payload:(NSData *)payload {
SDLProtocolHeader *header = [SDLProtocolHeader headerForVersion:[SDLGlobals globals].majorProtocolVersion];
- NSData *payload = nil;
+ NSData *servicePayload = payload;
switch (serviceType) {
case SDLServiceType_RPC: {
@@ -121,7 +129,7 @@ typedef NSNumber SDLServiceTypeBox;
}
SDLControlFramePayloadRPCStartService *startServicePayload = [[SDLControlFramePayloadRPCStartService alloc] initWithVersion:SDLMaxProxyProtocolVersion];
- payload = startServicePayload.data;
+ servicePayload = startServicePayload.data;
} break;
default: {
header.sessionID = [self sdl_retrieveSessionIDforServiceType:SDLServiceType_RPC];
@@ -130,12 +138,12 @@ typedef NSNumber SDLServiceTypeBox;
header.frameType = SDLFrameType_Control;
header.serviceType = serviceType;
header.frameData = SDLFrameData_StartSession;
- header.bytesInPayload = payload.length;
+ header.bytesInPayload = (UInt32)payload.length;
// Sending a StartSession with the encrypted bit set causes module to initiate SSL Handshake with a ClientHello message, which should be handled by the 'processControlService' method.
header.encrypted = encryption;
- return [SDLProtocolMessage messageWithHeader:header andPayload:payload];
+ return [SDLProtocolMessage messageWithHeader:header andPayload:servicePayload];
}
- (void)sdl_initializeTLSEncryptionWithCompletionHandler:(void (^)(BOOL success, NSError *error))completionHandler {
@@ -262,11 +270,11 @@ typedef NSNumber SDLServiceTypeBox;
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 globals].maxMTUSize) {
+ if (protocolMessage.size < [[SDLGlobals globals] mtuSizeForServiceType:SDLServiceType_RPC]) {
[self sdl_logRPCSend:protocolMessage];
[self sdl_sendDataToTransport:protocolMessage.data onService:SDLServiceType_RPC];
} else {
- NSArray *messages = [SDLProtocolMessageDisassembler disassemble:protocolMessage withLimit:[SDLGlobals globals].maxMTUSize];
+ NSArray *messages = [SDLProtocolMessageDisassembler disassemble:protocolMessage withLimit:[[SDLGlobals globals] mtuSizeForServiceType:SDLServiceType_RPC]];
for (SDLProtocolMessage *smallerMessage in messages) {
[self sdl_logRPCSend:smallerMessage];
[self sdl_sendDataToTransport:smallerMessage.data onService:SDLServiceType_RPC];
@@ -329,11 +337,11 @@ typedef NSNumber SDLServiceTypeBox;
SDLProtocolMessage *message = [SDLProtocolMessage messageWithHeader:header andPayload:data];
- if (message.size < [SDLGlobals globals].maxMTUSize) {
+ if (message.size < [[SDLGlobals globals] mtuSizeForServiceType:service]) {
[self sdl_logRPCSend:message];
[self sdl_sendDataToTransport:message.data onService:header.serviceType];
} else {
- NSArray *messages = [SDLProtocolMessageDisassembler disassemble:message withLimit:[SDLGlobals globals].maxMTUSize];
+ NSArray *messages = [SDLProtocolMessageDisassembler disassemble:message withLimit:[[SDLGlobals globals] mtuSizeForServiceType:service]];
for (SDLProtocolMessage *smallerMessage in messages) {
[self sdl_logRPCSend:smallerMessage];
[self sdl_sendDataToTransport:smallerMessage.data onService:header.serviceType];
@@ -348,7 +356,7 @@ typedef NSNumber SDLServiceTypeBox;
- (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 globals].maxMTUSize)];
+ self.receiveBuffer = [NSMutableData dataWithCapacity:(4 * [[SDLGlobals globals] mtuSizeForServiceType:SDLServiceType_RPC])];
}
// Save the data
@@ -422,8 +430,11 @@ typedef NSNumber SDLServiceTypeBox;
switch (startServiceACK.header.serviceType) {
case SDLServiceType_RPC: {
SDLControlFramePayloadRPCStartServiceAck *startServiceACKPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithData:startServiceACK.payload];
+// NSLog(@"ServiceAckPayload: %@", startServiceACKPayload);
- [SDLGlobals globals].maxMTUSize = (startServiceACKPayload.mtu != SDLControlFrameInt64NotFound) ? startServiceACKPayload.mtu : SDLDefaultMTUSize;
+ if (startServiceACKPayload.mtu != SDLControlFrameInt64NotFound) {
+ [[SDLGlobals globals] setDynamicMTUSize:startServiceACKPayload.mtu forServiceType:startServiceACK.header.serviceType];
+ }
[SDLGlobals globals].maxHeadUnitVersion = (startServiceACKPayload.protocolVersion != nil) ? startServiceACKPayload.protocolVersion : [NSString stringWithFormat:@"%u.0.0", startServiceACK.header.version];
// TODO: Hash id?
} break;
diff --git a/SmartDeviceLink/SDLProxy.m b/SmartDeviceLink/SDLProxy.m
index 0b6764d58..c3b8efb24 100644
--- a/SmartDeviceLink/SDLProxy.m
+++ b/SmartDeviceLink/SDLProxy.m
@@ -771,7 +771,7 @@ const int POLICIES_CORRELATION_ID = 65535;
// Grab some bytes from the stream and send them in a SDLPutFile RPC Request
NSUInteger currentStreamOffset = [[stream propertyForKey:NSStreamFileCurrentOffsetKey] unsignedIntegerValue];
- NSMutableData *buffer = [NSMutableData dataWithLength:[SDLGlobals globals].maxMTUSize];
+ NSMutableData *buffer = [NSMutableData dataWithLength:[[SDLGlobals globals] mtuSizeForServiceType:SDLServiceType_RPC]];
NSUInteger nBytesRead = [(NSInputStream *)stream read:(uint8_t *)buffer.mutableBytes maxLength:buffer.length];
if (nBytesRead > 0) {
NSData *data = [buffer subdataWithRange:NSMakeRange(0, nBytesRead)];
diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m
index 11fa8048e..57df1dcbf 100644
--- a/SmartDeviceLink/SDLStreamingMediaManager.m
+++ b/SmartDeviceLink/SDLStreamingMediaManager.m
@@ -11,10 +11,14 @@
#import <UIKit/UIKit.h>
#import "SDLAbstractProtocol.h"
+#import "SDLControlFramePayloadConstants.h"
+#import "SDLControlFramePayloadAudioStartServiceAck.h"
+#import "SDLControlFramePayloadVideoStartServiceAck.h"
#import "SDLDebugTool.h"
#import "SDLDisplayCapabilities.h"
#import "SDLGlobals.h"
#import "SDLImageResolution.h"
+#import "SDLProtocolMessage.h"
#import "SDLScreenParams.h"
#import "SDLTouchManager.h"
@@ -280,49 +284,71 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - SDLProtocolListener Methods
-- (void)handleProtocolStartSessionACK:(SDLProtocolHeader *)header {
- switch (header.serviceType) {
- case SDLServiceType_Audio: {
- self.audioSessionConnected = YES;
- self.audioSessionEncrypted = header.encrypted;
-
- if (self.audioStartBlock == nil) {
- return;
- }
+#pragma mark Protocol Ack
- self.audioStartBlock(YES, header.encrypted, nil);
- self.audioStartBlock = nil;
+- (void)handleProtocolStartServiceACKMessage:(SDLProtocolMessage *)startServiceACK {
+ switch (startServiceACK.header.serviceType) {
+ case SDLServiceType_Audio: {
+ [self sdl_handleAudioStartServiceAck:startServiceACK];
} break;
case SDLServiceType_Video: {
- NSError *error = nil;
- BOOL success = [self sdl_configureVideoEncoderWithError:&error];
+ [self sdl_handleVideoStartServiceAck:startServiceACK];
+ } break;
+ default: break;
+ }
+}
- if (!success) {
- [self sdl_teardownCompressionSession];
- [self.protocol endServiceWithType:SDLServiceType_Video];
+- (void)sdl_handleAudioStartServiceAck:(SDLProtocolMessage *)audioStartAck {
+ SDLControlFramePayloadAudioStartServiceAck *audioAckPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithData:audioStartAck.payload];
- if (self.videoStartBlock == nil) {
- return;
- }
+ if (audioAckPayload.mtu != SDLControlFrameInt64NotFound) {
+ [[SDLGlobals globals] setDynamicMTUSize:audioAckPayload.mtu forServiceType:SDLServiceType_Audio];
+ }
- self.videoStartBlock(NO, header.encrypted, error);
- self.videoStartBlock = nil;
+ self.audioSessionConnected = YES;
+ self.audioSessionEncrypted = audioStartAck.header.encrypted;
- return;
- }
+ if (self.audioStartBlock == nil) {
+ return;
+ }
- self.videoSessionConnected = YES;
- self.videoSessionEncrypted = header.encrypted;
+ self.audioStartBlock(YES, audioStartAck.header.encrypted, nil);
+ self.audioStartBlock = nil;
+}
- if (self.videoStartBlock == nil) {
- return;
- }
+- (void)sdl_handleVideoStartServiceAck:(SDLProtocolMessage *)videoStartAck {
+ SDLControlFramePayloadVideoStartServiceAck *videoAckPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithData:videoStartAck.payload];
- self.videoStartBlock(YES, header.encrypted, nil);
- self.videoStartBlock = nil;
- } break;
- default: break;
+ if (videoAckPayload.mtu != SDLControlFrameInt64NotFound) {
+ [[SDLGlobals globals] setDynamicMTUSize:videoAckPayload.mtu forServiceType:SDLServiceType_Video];
+ }
+
+ NSError *error = nil;
+ BOOL success = [self sdl_configureVideoEncoderWithError:&error];
+
+ if (!success) {
+ [self sdl_teardownCompressionSession];
+ [self.protocol endServiceWithType:SDLServiceType_Video];
+
+ if (self.videoStartBlock == nil) {
+ return;
+ }
+
+ self.videoStartBlock(NO, videoStartAck.header.encrypted, error);
+ self.videoStartBlock = nil;
+
+ return;
}
+
+ self.videoSessionConnected = YES;
+ self.videoSessionEncrypted = videoStartAck.header.encrypted;
+
+ if (self.videoStartBlock == nil) {
+ return;
+ }
+
+ self.videoStartBlock(YES, videoStartAck.header.encrypted, nil);
+ self.videoStartBlock = nil;
}
- (void)handleProtocolStartSessionNACK:(SDLServiceType)serviceType {
diff --git a/SmartDeviceLink/SDLUploadFileOperation.m b/SmartDeviceLink/SDLUploadFileOperation.m
index f373dc566..a10ecd069 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 globals].maxMTUSize] withCompletion:self.fileWrapper.completionHandler];
+ [self sdl_sendPutFiles:[self.class sdl_splitFile:self.fileWrapper.file mtuSize:[[SDLGlobals globals] mtuSizeForServiceType:SDLServiceType_RPC]] withCompletion:self.fileWrapper.completionHandler];
}
- (void)sdl_sendPutFiles:(NSArray<SDLPutFile *> *)putFiles withCompletion:(SDLFileManagerUploadCompletionHandler)completion {