summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Fischer <joeljfischer@gmail.com>2020-09-18 11:22:46 -0400
committerGitHub <noreply@github.com>2020-09-18 11:22:46 -0400
commitba15545ed19d124cfa317c0fb1ca39a3ab2b4498 (patch)
tree9f56847ea167fa0321bbbc1d97b4f5e52b8581d8
parent1b030c1ac8e8290e9ff7e60dc35a0c98481883e9 (diff)
parent0ed7920ff25b7dc4393a898fc509fbc990f2e560 (diff)
downloadsdl_ios-ba15545ed19d124cfa317c0fb1ca39a3ab2b4498.tar.gz
Merge pull request #1770 from smartdevicelink/bugfix/issue-1615-consolidate-logic-for-saving-the-dynamic-mtu-size
Consolidate logic for saving the dynamic mtu size
-rw-r--r--SmartDeviceLink/private/SDLProtocol.m14
-rw-r--r--SmartDeviceLink/private/SDLStreamingAudioLifecycleManager.m4
-rw-r--r--SmartDeviceLink/private/SDLStreamingVideoLifecycleManager.m4
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m1
-rw-r--r--SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m1
-rw-r--r--SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m124
6 files changed, 131 insertions, 17 deletions
diff --git a/SmartDeviceLink/private/SDLProtocol.m b/SmartDeviceLink/private/SDLProtocol.m
index ad660eb79..a76e6a24d 100644
--- a/SmartDeviceLink/private/SDLProtocol.m
+++ b/SmartDeviceLink/private/SDLProtocol.m
@@ -527,6 +527,20 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: Hash id?
} break;
+ case SDLServiceTypeAudio: {
+ SDLControlFramePayloadRPCStartServiceAck *startServiceACKPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithData:startServiceACK.payload];
+
+ if (startServiceACKPayload.mtu != SDLControlFrameInt64NotFound) {
+ [[SDLGlobals sharedGlobals] setDynamicMTUSize:(NSUInteger)startServiceACKPayload.mtu forServiceType:SDLServiceTypeAudio];
+ }
+ } break;
+ case SDLServiceTypeVideo: {
+ SDLControlFramePayloadRPCStartServiceAck *startServiceACKPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithData:startServiceACK.payload];
+
+ if (startServiceACKPayload.mtu != SDLControlFrameInt64NotFound) {
+ [[SDLGlobals sharedGlobals] setDynamicMTUSize:(NSUInteger)startServiceACKPayload.mtu forServiceType:SDLServiceTypeVideo];
+ }
+ } break;
default:
break;
}
diff --git a/SmartDeviceLink/private/SDLStreamingAudioLifecycleManager.m b/SmartDeviceLink/private/SDLStreamingAudioLifecycleManager.m
index 31ed5aa0f..5e77bb305 100644
--- a/SmartDeviceLink/private/SDLStreamingAudioLifecycleManager.m
+++ b/SmartDeviceLink/private/SDLStreamingAudioLifecycleManager.m
@@ -195,10 +195,6 @@ NS_ASSUME_NONNULL_BEGIN
SDLControlFramePayloadAudioStartServiceAck *audioAckPayload = [[SDLControlFramePayloadAudioStartServiceAck alloc] initWithData:startServiceACK.payload];
SDLLogD(@"Request to start audio service ACKed on transport %@, with payload: %@", protocol.transport, audioAckPayload);
- if (audioAckPayload.mtu != SDLControlFrameInt64NotFound) {
- [[SDLGlobals sharedGlobals] setDynamicMTUSize:(NSUInteger)audioAckPayload.mtu forServiceType:SDLServiceTypeAudio];
- }
-
[self.audioStreamStateMachine transitionToState:SDLAudioStreamManagerStateReady];
}
diff --git a/SmartDeviceLink/private/SDLStreamingVideoLifecycleManager.m b/SmartDeviceLink/private/SDLStreamingVideoLifecycleManager.m
index a0598534f..5d1236a98 100644
--- a/SmartDeviceLink/private/SDLStreamingVideoLifecycleManager.m
+++ b/SmartDeviceLink/private/SDLStreamingVideoLifecycleManager.m
@@ -508,10 +508,6 @@ typedef void(^SDLVideoCapabilityResponseHandler)(SDLVideoStreamingCapability *_N
SDLControlFramePayloadVideoStartServiceAck *videoAckPayload = [[SDLControlFramePayloadVideoStartServiceAck alloc] initWithData:startServiceACK.payload];
SDLLogD(@"Request to start video service ACKed on transport %@, with payload: %@", protocol.transport, videoAckPayload);
- if (videoAckPayload.mtu != SDLControlFrameInt64NotFound) {
- [[SDLGlobals sharedGlobals] setDynamicMTUSize:(NSUInteger)videoAckPayload.mtu forServiceType:SDLServiceTypeVideo];
- }
-
// This is the definitive screen size that will be used
if ((videoAckPayload.height != SDLControlFrameInt32NotFound || videoAckPayload.height != 0) && (videoAckPayload.width != SDLControlFrameInt32NotFound && videoAckPayload.width != 0)) {
self.videoScaleManager.displayViewportResolution = CGSizeMake(videoAckPayload.width, videoAckPayload.height);
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m
index 93d5e5829..4a39a0676 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingAudioLifecycleManagerSpec.m
@@ -315,7 +315,6 @@ describe(@"the streaming audio manager", ^{
});
it(@"should have set all the right properties", ^{
- expect([[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeAudio]).to(equal(testMTU));
expect(streamingLifecycleManager.audioEncrypted).to(equal(YES));
expect(streamingLifecycleManager.currentAudioStreamState).to(equal(SDLAudioStreamManagerStateReady));
});
diff --git a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m
index d2c2889db..c42e10961 100644
--- a/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m
+++ b/SmartDeviceLinkTests/DevAPISpecs/SDLStreamingVideoLifecycleManagerSpec.m
@@ -556,7 +556,6 @@ describe(@"the streaming video manager", ^{
});
it(@"should have set all the right properties", ^{
- expect([[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeVideo]).to(equal(testMTU));
expect(@(CGSizeEqualToSize(streamingLifecycleManager.videoScaleManager.displayViewportResolution, CGSizeMake(testVideoWidth, testVideoHeight)))).to(beTrue());
expect(streamingLifecycleManager.videoEncrypted).to(equal(YES));
expect(streamingLifecycleManager.videoFormat).to(equal([[SDLVideoStreamingFormat alloc] initWithCodec:testVideoCodec protocol:testVideoProtocol]));
diff --git a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
index b4e542012..483033569 100644
--- a/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
+++ b/SmartDeviceLinkTests/ProtocolSpecs/MessageSpecs/SDLProtocolSpec.m
@@ -399,6 +399,8 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
__block id transportMock = nil;
__block SDLProtocol *testProtocol = nil;
__block id delegateMock = nil;
+ __block int64_t testMTU = 989786483;
+ __block int32_t hashId = 1545784;
beforeEach(^{
transportMock = OCMProtocolMock(@protocol(SDLTransportType));
@@ -419,7 +421,7 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
context(@"If the service type is RPC", ^{
it(@"Should store the auth token and the protocol version and pass the start service along to the delegate", ^{
- SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:1545784 mtu:989786483 authToken:testAuthToken protocolVersion:@"5.2.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:testAuthToken protocolVersion:@"5.2.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
NSData *testData = testPayload.data;
SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:5];
@@ -443,7 +445,7 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
});
it(@"Should store the protocol version, but not get the auth token, and pass the start service along to the delegate if the protocol version is greater than 5.0.0 but less than 5.2.0", ^{
- SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:1545784 mtu:989786483 authToken:testAuthToken protocolVersion:@"5.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:testAuthToken protocolVersion:@"5.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
NSData *testData = testPayload.data;
SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:5];
@@ -467,7 +469,7 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
});
it(@"Should set the max head unit version using the header version if the protocol version is missing from the payload", ^{
- SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:1545784 mtu:989786483 authToken:nil protocolVersion:nil secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:nil protocolVersion:nil secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
NSData *testData = testPayload.data;
SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:5];
@@ -491,9 +493,9 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
});
});
- context(@"If the service type is not RPC", ^{
+ context(@"If the service type is control", ^{
it(@"Should just pass the start service along to the delegate", ^{
- SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:1545784 mtu:989786483 authToken:testAuthToken protocolVersion:@"5.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:testAuthToken protocolVersion:@"5.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
NSData *testData = testPayload.data;
SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:5];
@@ -517,12 +519,68 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
expect([SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion.stringVersion).to(equal(@"0.0.0"));
});
});
+
+ context(@"If the service type is Audio", ^{
+ it(@"Should just pass the start service along to the delegate", ^{
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:testAuthToken protocolVersion:@"5.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ NSData *testData = testPayload.data;
+
+ SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:5];
+ testHeader.frameType = SDLFrameTypeControl;
+ testHeader.serviceType = SDLServiceTypeAudio;
+ testHeader.frameData = SDLFrameInfoStartServiceACK;
+ testHeader.sessionID = 0x93;
+ testHeader.bytesInPayload = (UInt32)testData.length;
+
+ SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData];
+ OCMExpect([delegateMock protocol:testProtocol didReceiveStartServiceACK:ackMessage]);
+
+ [testProtocol.protocolDelegateTable addObject:delegateMock];
+ [testProtocol protocol:testProtocol didReceiveStartServiceACK:ackMessage];
+
+ OCMVerifyAllWithDelay(delegateMock, 0.1);
+
+ // Should keep their default values
+ expect(testProtocol.authToken).to(beNil());
+ expect([SDLGlobals sharedGlobals].protocolVersion.stringVersion).to(equal(@"1.0.0"));
+ expect([[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeAudio]).to(equal(testMTU));
+ expect([SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion.stringVersion).to(equal(@"0.0.0"));
+ });
+ });
+
+ context(@"If the service type is Video", ^{
+ it(@"Should just pass the start service along to the delegate", ^{
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:testAuthToken protocolVersion:@"5.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ NSData *testData = testPayload.data;
+
+ SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:5];
+ testHeader.frameType = SDLFrameTypeControl;
+ testHeader.serviceType = SDLServiceTypeVideo;
+ testHeader.frameData = SDLFrameInfoStartServiceACK;
+ testHeader.sessionID = 0x93;
+ testHeader.bytesInPayload = (UInt32)testData.length;
+
+ SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData];
+ OCMExpect([delegateMock protocol:testProtocol didReceiveStartServiceACK:ackMessage]);
+
+ [testProtocol.protocolDelegateTable addObject:delegateMock];
+ [testProtocol protocol:testProtocol didReceiveStartServiceACK:ackMessage];
+
+ OCMVerifyAllWithDelay(delegateMock, 0.1);
+
+ // Should keep their default values
+ expect(testProtocol.authToken).to(beNil());
+ expect([SDLGlobals sharedGlobals].protocolVersion.stringVersion).to(equal(@"1.0.0"));
+ expect([[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeVideo]).to(equal(testMTU));
+ expect([SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion.stringVersion).to(equal(@"0.0.0"));
+ });
+ });
});
context(@"For protocol versions below 5.0.0", ^{
context(@"If the service type is RPC", ^{
it(@"Should store the protocol version and pass the start service along to the delegate", ^{
- SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:1545784 mtu:989786483 authToken:nil protocolVersion:@"3.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:nil protocolVersion:@"3.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
NSData *testData = testPayload.data;
SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:5];
@@ -547,7 +605,7 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
context(@"If the service type is not RPC", ^{
it(@"Should just pass the start service along to the delegate", ^{
- SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:1545784 mtu:989786483 authToken:nil protocolVersion:@"4.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:nil protocolVersion:@"4.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
NSData *testData = testPayload.data;
SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:4];
@@ -569,6 +627,58 @@ describe(@"HandleProtocolSessionStarted tests", ^ {
OCMVerifyAllWithDelay(delegateMock, 0.1);
});
});
+
+ context(@"If the service type is Audio", ^{
+ it(@"Should just pass the start service along to the delegate", ^{
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:nil protocolVersion:@"4.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ NSData *testData = testPayload.data;
+
+ SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:4];
+ testHeader.frameType = SDLFrameTypeControl;
+ testHeader.serviceType = SDLServiceTypeAudio;
+ testHeader.frameData = SDLFrameInfoStartServiceACK;
+ testHeader.sessionID = 0x93;
+ testHeader.bytesInPayload = (UInt32)testData.length;
+
+ SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData];
+ OCMExpect([delegateMock protocol:testProtocol didReceiveStartServiceACK:ackMessage]);
+
+ [testProtocol.protocolDelegateTable addObject:delegateMock];
+ [testProtocol protocol:testProtocol didReceiveStartServiceACK:ackMessage];
+
+ // Should keep their default values
+ expect([SDLGlobals sharedGlobals].protocolVersion.stringVersion).to(equal(@"1.0.0"));
+ expect([[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeAudio]).to(equal(1024));
+ expect([SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion.stringVersion).to(equal(@"0.0.0"));
+ OCMVerifyAllWithDelay(delegateMock, 0.1);
+ });
+ });
+
+ context(@"If the service type is Video", ^{
+ it(@"Should just pass the start service along to the delegate", ^{
+ SDLControlFramePayloadRPCStartServiceAck *testPayload = [[SDLControlFramePayloadRPCStartServiceAck alloc] initWithHashId:hashId mtu:testMTU authToken:nil protocolVersion:@"4.1.0" secondaryTransports:nil audioServiceTransports:nil videoServiceTransports:nil];
+ NSData *testData = testPayload.data;
+
+ SDLV2ProtocolHeader* testHeader = [[SDLV2ProtocolHeader alloc] initWithVersion:4];
+ testHeader.frameType = SDLFrameTypeControl;
+ testHeader.serviceType = SDLServiceTypeVideo;
+ testHeader.frameData = SDLFrameInfoStartServiceACK;
+ testHeader.sessionID = 0x93;
+ testHeader.bytesInPayload = (UInt32)testData.length;
+
+ SDLProtocolMessage *ackMessage = [SDLProtocolMessage messageWithHeader:testHeader andPayload:testData];
+ OCMExpect([delegateMock protocol:testProtocol didReceiveStartServiceACK:ackMessage]);
+
+ [testProtocol.protocolDelegateTable addObject:delegateMock];
+ [testProtocol protocol:testProtocol didReceiveStartServiceACK:ackMessage];
+
+ // Should keep their default values
+ expect([SDLGlobals sharedGlobals].protocolVersion.stringVersion).to(equal(@"1.0.0"));
+ expect([[SDLGlobals sharedGlobals] mtuSizeForServiceType:SDLServiceTypeVideo]).to(equal(1024));
+ expect([SDLGlobals sharedGlobals].maxHeadUnitProtocolVersion.stringVersion).to(equal(@"0.0.0"));
+ OCMVerifyAllWithDelay(delegateMock, 0.1);
+ });
+ });
});
});