Skip to content

Commit

Permalink
Merge branch 'poc/sdl0296_upd_video_stream_cap' into poc/sdl0296_upd_…
Browse files Browse the repository at this point in the history
…video_stream_cap_

POC: SDL 0296 - Possibility to update video streaming capabilities during ignition cycle [issue smartdevicelink#983]
  • Loading branch information
yLeonid committed Jun 1, 2020
2 parents 5e38806 + 5006418 commit 54ca893
Show file tree
Hide file tree
Showing 49 changed files with 2,156 additions and 287 deletions.
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15400" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="l5Q-ZP-1BO">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="l5Q-ZP-1BO">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15404"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -15,23 +15,43 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<view key="tableHeaderView" contentMode="scaleToFill" id="K0C-tf-9HD">
<rect key="frame" x="0.0" y="0.0" width="375" height="64"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" text="SDL 0296 - Possibility to update video streaming capabilities during ignition cycle #983" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="56Z-nY-c4O">
<rect key="frame" x="10" y="0.0" width="355" height="64"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
</textView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="56Z-nY-c4O" firstAttribute="top" secondItem="K0C-tf-9HD" secondAttribute="top" id="3ro-an-naY"/>
<constraint firstAttribute="trailing" secondItem="56Z-nY-c4O" secondAttribute="trailing" constant="10" id="6CV-0Q-rz0"/>
<constraint firstItem="56Z-nY-c4O" firstAttribute="leading" secondItem="K0C-tf-9HD" secondAttribute="leading" constant="10" id="9q0-VD-QET"/>
<constraint firstAttribute="bottom" secondItem="56Z-nY-c4O" secondAttribute="bottom" id="gwe-YJ-Lis"/>
</constraints>
</view>
<sections>
<tableViewSection headerTitle="TCP Server" id="bF6-yi-Ial">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="pbJ-oz-jNt">
<rect key="frame" x="0.0" y="55.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="119.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="pbJ-oz-jNt" id="B7X-yY-lwJ">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="IP Address" clearsOnBeginEditing="YES" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="xqM-s4-9RV">
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="IP Address" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="xqM-s4-9RV">
<rect key="frame" x="16" y="0.0" width="343" height="44"/>
<constraints>
<constraint firstAttribute="height" constant="44" id="5Pw-mh-x83"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="URL"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no" keyboardType="URL" smartDashesType="no" smartInsertDeleteType="no" textContentType="url"/>
</textField>
</subviews>
<constraints>
Expand All @@ -42,7 +62,7 @@
</tableViewCellContentView>
</tableViewCell>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="C5b-fS-v3d">
<rect key="frame" x="0.0" y="99.5" width="375" height="44"/>
<rect key="frame" x="0.0" y="163.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="C5b-fS-v3d" id="ZD4-xA-og5">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
Expand All @@ -66,10 +86,38 @@
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="" id="rgl-Lm-uDH">
<tableViewSection headerTitle="App Kind" id="BPB-8S-l9t">
<cells>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" id="2JT-t9-quM" userLabel="play start/stop cell">
<rect key="frame" x="0.0" y="255.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="2JT-t9-quM" id="hlo-ge-ada">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<segmentedControl hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="UDP-rT-hdx">
<rect key="frame" x="10" y="0.0" width="355" height="45"/>
<segments>
<segment title="UI app"/>
<segment title="No UI app"/>
<segment title="(3D app)"/>
</segments>
</segmentedControl>
</subviews>
<constraints>
<constraint firstItem="UDP-rT-hdx" firstAttribute="leading" secondItem="hlo-ge-ada" secondAttribute="leading" constant="10" id="HCu-x2-J5S"/>
<constraint firstItem="UDP-rT-hdx" firstAttribute="top" secondItem="hlo-ge-ada" secondAttribute="top" id="HOn-tt-p8n"/>
<constraint firstAttribute="trailing" secondItem="UDP-rT-hdx" secondAttribute="trailing" constant="10" id="J9p-0A-FLN"/>
<constraint firstAttribute="bottom" secondItem="UDP-rT-hdx" secondAttribute="bottom" id="sG7-4A-xYp"/>
</constraints>
</tableViewCellContentView>
</tableViewCell>
</cells>
</tableViewSection>
<tableViewSection headerTitle="Connection Control" id="rgl-Lm-uDH" userLabel="Connect Section">
<cells>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="ybX-Eh-Hbx">
<rect key="frame" x="0.0" y="175.5" width="375" height="44"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="ybX-Eh-Hbx" userLabel="Connect Cell">
<rect key="frame" x="0.0" y="347.5" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="ybX-Eh-Hbx" id="uI9-fK-205">
<rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
Expand Down Expand Up @@ -98,7 +146,6 @@
</tableViewSection>
</sections>
<connections>
<outlet property="dataSource" destination="l5Q-ZP-1BO" id="kIY-aI-9y3"/>
<outlet property="delegate" destination="l5Q-ZP-1BO" id="nhW-OL-xIC"/>
</connections>
</tableView>
Expand All @@ -114,6 +161,7 @@
</segmentedControl>
</navigationItem>
<connections>
<outlet property="appSelector" destination="UDP-rT-hdx" id="fgT-Pk-aAM"/>
<outlet property="connectButton" destination="t37-4W-6F4" id="f6v-Q4-ggs"/>
<outlet property="connectTableViewCell" destination="ybX-Eh-Hbx" id="hyh-CW-oXx"/>
<outlet property="ipAddressTextField" destination="xqM-s4-9RV" id="daz-uN-Rxa"/>
Expand Down
80 changes: 74 additions & 6 deletions Example Apps/Example ObjC/ConnectionTCPTableViewController.m
Expand Up @@ -4,12 +4,24 @@

#import <AVFoundation/AVFoundation.h>
#import <MobileCoreServices/MobileCoreServices.h>

#import <AVFoundation/AVFoundation.h>
#import <AVKit/AVKit.h>
#import "ConnectionTCPTableViewController.h"

#import "Preferences.h"
#import "ProxyManager.h"
#import "SDLStreamingMediaManager.h"
#import "SDLManager.h"
#import "TestUIAppViewController.h"
#import "SimpleAppViewController.h"
#import "GameViewController.h"


typedef NS_ENUM(NSInteger, AppKind) {
AppKindUIApp,
AppKindSimple,
AppKind3DApp,
AppKindVideoApp,
};

@interface ConnectionTCPTableViewController ()

Expand All @@ -18,9 +30,12 @@ @interface ConnectionTCPTableViewController ()

@property (weak, nonatomic) IBOutlet UITableViewCell *connectTableViewCell;
@property (weak, nonatomic) IBOutlet UIButton *connectButton;
@property (weak, nonatomic) IBOutlet UISegmentedControl *appSelector;

@end
@property (strong, nonatomic, nullable) UIViewController *testAppViewController;
@property (assign, nonatomic) AppKind appKind;

@end


@implementation ConnectionTCPTableViewController
Expand Down Expand Up @@ -52,11 +67,22 @@ - (void)dealloc {
- (IBAction)connectButtonWasPressed:(UIButton *)sender {
[Preferences sharedPreferences].ipAddress = self.ipAddressTextField.text;
[Preferences sharedPreferences].port = self.portTextField.text.integerValue;


[self.view endEditing:YES]; // hide keyboard

ProxyState state = [ProxyManager sharedManager].state;
switch (state) {
case ProxyStateStopped: {
[[ProxyManager sharedManager] startWithProxyTransportType:ProxyTransportTypeTCP];
SDLTCPConfig *tcpConfig = [SDLTCPConfig configWithHost:self.ipAddressTextField.text port:self.portTextField.text.integerValue];

if (!self.testAppViewController) {
// self.appKind = (!self.appSelector || self.appSelector.hidden) ? AppKindSimple : self.appSelector.selectedSegmentIndex;
self.appKind = AppKindSimple;
self.testAppViewController = [self createTestViewControllerOfType:self.appKind];
}
[ProxyManager sharedManager].videoVC = self.testAppViewController;

[[ProxyManager sharedManager] startProxyTCP:tcpConfig];
} break;
case ProxyStateSearchingForConnection: {
[[ProxyManager sharedManager] stopConnection];
Expand All @@ -68,6 +94,23 @@ - (IBAction)connectButtonWasPressed:(UIButton *)sender {
}
}

- (UIViewController*)createTestViewControllerOfType:(AppKind)appKind {
switch (appKind) {
case AppKindVideoApp:
return nil;

case AppKindSimple: // Video Player
return [SimpleAppViewController createViewController];
return nil;

case AppKind3DApp: // 3D app
return [GameViewController createViewController];

default:
case AppKindUIApp: // UI app
return [TestUIAppViewController createViewController];
}
}

#pragma mark - Table view delegate

Expand All @@ -93,7 +136,9 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:NSStringFromSelector(@selector(state))]) {
ProxyState newState = [change[NSKeyValueChangeNewKey] unsignedIntegerValue];
[self proxyManagerDidChangeState:newState];
dispatch_async(dispatch_get_main_queue(), ^{
[self proxyManagerDidChangeState:newState];
});
}
}

Expand All @@ -105,6 +150,7 @@ - (void)proxyManagerDidChangeState:(ProxyState)newState {
case ProxyStateStopped: {
newColor = [UIColor redColor];
newTitle = @"Connect";
[self finishApp];
} break;
case ProxyStateSearchingForConnection: {
newColor = [UIColor blueColor];
Expand All @@ -113,6 +159,7 @@ - (void)proxyManagerDidChangeState:(ProxyState)newState {
case ProxyStateConnected: {
newColor = [UIColor greenColor];
newTitle = @"Disconnect";
[self startAppOfKind:self.appKind];
} break;
default: break;
}
Expand All @@ -125,4 +172,25 @@ - (void)proxyManagerDidChangeState:(ProxyState)newState {
}
}

// start / stop client app

- (void)startAppOfKind:(AppKind)kind {
NSLog(@"start AppKind:%d", (int)kind);
if (self.testAppViewController) {
if ([self.testAppViewController isKindOfClass:[SimpleAppViewController class]]) {
NSLog(@"%@ : is not supposed to be in the view stack", NSStringFromClass(self.testAppViewController.class));
} else {
[self.navigationController pushViewController:self.testAppViewController animated:YES];
}
} else {
NSLog(@"wrong app kind: %d", (int)kind);
}
}

- (void)finishApp {
if (self.testAppViewController) {
[self.navigationController popToViewController:self.parentViewController animated:YES];
}
}

@end
6 changes: 4 additions & 2 deletions Example Apps/Example ObjC/ConnectionTransitionContext.m
Expand Up @@ -101,10 +101,12 @@ - (CGAffineTransform)targetTransform {


#pragma mark Interactive Transition

// method stubs to supress compiler warnings
- (void)updateInteractiveTransition:(CGFloat)percentComplete {}
- (void)finishInteractiveTransition {}
- (void)cancelInteractiveTransition {}

- (void)pauseInteractiveTransition {}
@synthesize animated;
@synthesize interactive;

@end
@@ -0,0 +1,19 @@
//
// SimpleAppViewController.h
// SmartDeviceLink-iOS
//
// Created by Leonid Lokhmatov on 5/25/20.
// Copyright © 2018 Luxoft. All rights reserved
//

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface SimpleAppViewController : UIViewController

+ (SimpleAppViewController*)createViewController;

@end

NS_ASSUME_NONNULL_END

0 comments on commit 54ca893

Please sign in to comment.