Skip to content

Commit

Permalink
Fix StreamingMediaManager always trying to start with encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
joeljfischer committed Feb 18, 2016
1 parent 8a5b736 commit f782e8d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions SmartDeviceLink-iOS/SmartDeviceLink/SDLProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ - (void)addSecurityManager:(Class)securityManagerClass forMake:(NSString *)vehic
}

- (id<SDLSecurityType>)securityManagerForMake:(NSString *)make {
if ((make != nil) && (_securityManagers[make] != nil)) {
Class securityManagerClass = _securityManagers[make];
if ((make != nil) && (self.securityManagers[make] != nil)) {
Class securityManagerClass = self.securityManagers[make];
return [[securityManagerClass alloc] init];
}

Expand Down
44 changes: 26 additions & 18 deletions SmartDeviceLink-iOS/SmartDeviceLink/SDLStreamingMediaManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,19 @@ - (void)startVideoSessionWithEncryption:(BOOL)encryption startBlock:(SDLStreamin

self.videoStartBlock = [startBlock copy];

__weak typeof(self) weakSelf = self;
[self.protocol startEncryptedServiceWithType:SDLServiceType_Video completionHandler:^(BOOL success, NSError *error) {
typeof(weakSelf) strongSelf = weakSelf;
// If this passes, we will get an ACK or NACK, so those methods will handle calling the video block
if (!success) {
strongSelf.videoStartBlock(NO, NO, error);
strongSelf.videoStartBlock = nil;
}
}];
if (encryption) {
__weak typeof(self) weakSelf = self;
[self.protocol startEncryptedServiceWithType:SDLServiceType_Video completionHandler:^(BOOL success, NSError *error) {
typeof(weakSelf) strongSelf = weakSelf;
// If success, we will get an ACK or NACK, so those methods will handle calling the video block
if (!success) {
strongSelf.videoStartBlock(NO, NO, error);
strongSelf.videoStartBlock = nil;
}
}];
} else {
[self.protocol startServiceWithType:SDLServiceType_Video];
}
}

- (void)stopVideoSession {
Expand All @@ -110,15 +114,19 @@ - (void)startAudioStreamingWithStartBlock:(SDLStreamingStartBlock)startBlock {
- (void)startAudioStreamingWithEncryption:(BOOL)encryption startBlock:(SDLStreamingStartBlock)startBlock {
self.audioStartBlock = [startBlock copy];

__weak typeof(self) weakSelf = self;
[self.protocol startEncryptedServiceWithType:SDLServiceType_Audio completionHandler:^(BOOL success, NSError *error) {
typeof(weakSelf) strongSelf = weakSelf;
// If this passes, we will get an ACK or NACK, so those methods will handle calling the video block
if (!success) {
strongSelf.audioStartBlock(NO, NO, error);
strongSelf.audioStartBlock = nil;
}
}];
if (encryption) {
__weak typeof(self) weakSelf = self;
[self.protocol startEncryptedServiceWithType:SDLServiceType_Audio completionHandler:^(BOOL success, NSError *error) {
typeof(weakSelf) strongSelf = weakSelf;
// If this passes, we will get an ACK or NACK, so those methods will handle calling the video block
if (!success) {
strongSelf.audioStartBlock(NO, NO, error);
strongSelf.audioStartBlock = nil;
}
}];
} else {
[self.protocol startServiceWithType:SDLServiceType_Audio];
}
}

- (void)stopAudioSession {
Expand Down

0 comments on commit f782e8d

Please sign in to comment.