Commit 5e46e54e authored by Tobias's avatar Tobias

first very hacked tvOS UPnP playback POC

parent 3b4d6b13
---
BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'
......@@ -9,3 +9,4 @@ External
ImportedSources
DerivedData
Pods
vendor/bundle
source 'https://rubygems.org'
gem 'cocoapods', :git => 'https://github.com/CocoaPods/CocoaPods.git', :branch => 'tvos'
gem 'cocoapods-core', :git => 'https://github.com/CocoaPods/Core.git', :branch => 'tvos-support'
gem 'xcodeproj', :git => 'https://github.com/CocoaPods/Xcodeproj.git', :branch => 'tvos-support'
GIT
remote: https://github.com/CocoaPods/CocoaPods.git
revision: 25bcc14b04260939144496cc08f091061f5500de
branch: tvos
specs:
cocoapods (0.39.0.beta.4)
activesupport (>= 3.2.15)
claide (~> 0.9.1)
cocoapods-core (= 0.39.0.beta.4)
cocoapods-downloader (~> 0.9.3)
cocoapods-plugins (~> 0.4.2)
cocoapods-search (~> 0.1.0)
cocoapods-stats (~> 0.6.1)
cocoapods-trunk (~> 0.6.4)
cocoapods-try (~> 0.5.1)
colored (~> 1.2)
escape (~> 0.0.4)
molinillo (~> 0.3.1)
nap (~> 1.0)
xcodeproj (~> 0.27.2)
GIT
remote: https://github.com/CocoaPods/Core.git
revision: f60d8b4f28223ea2e02316efa52a612153d7fe2e
branch: tvos-support
specs:
cocoapods-core (0.39.0.beta.4)
activesupport (>= 3.2.15)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: b208640ffd04ffb1ec1becc085e8b3f3759ff8f1
branch: tvos-support
specs:
xcodeproj (0.27.2)
activesupport (>= 3)
claide (~> 0.9.1)
colored (~> 1.2)
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.4)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
claide (0.9.1)
cocoapods-downloader (0.9.3)
cocoapods-plugins (0.4.2)
nap
cocoapods-search (0.1.0)
cocoapods-stats (0.6.1)
cocoapods-trunk (0.6.4)
nap (>= 0.8, < 2.0)
netrc (= 0.7.8)
cocoapods-try (0.5.1)
colored (1.2)
escape (0.0.4)
fuzzy_match (2.0.4)
i18n (0.7.0)
json (1.8.3)
minitest (5.8.0)
molinillo (0.3.1)
nap (1.0.0)
netrc (0.7.8)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
cocoapods!
cocoapods-core!
xcodeproj!
BUNDLED WITH
1.10.6
......@@ -9,13 +9,20 @@ target 'vlc-ios' do
pod 'OBSlider', '1.1.0'
pod 'GHSidebarNav', '1.0.0'
pod 'InAppSettingsKit', '2.2.2'
pod 'upnpx', '~>1.3.4'
pod 'upnpx', :podspec => 'vendor/upnpx.podspec'
pod 'HockeySDK', '~>3.6.4'
pod 'SSKeychain', '~>1.2.2'
pod 'box-ios-sdk-v2', :git => 'git://github.com/carolanitz/box-ios-sdk-v2.git', :commit => 'd2df30aa5f76d30910e06f3ef5aff49025de3cf1' #has a logout function added
pod 'RESideMenu', '~>4.0.7'
end
target 'VLC for Apple TV' do
platform :tvos, '9.0'
pod 'upnpx', :podspec => 'vendor/upnpx.podspec'
end
post_install do |installer_representation|
installer_representation.pods_project.build_configurations.each do |config|
config.build_settings['SKIP_INSTALL'] = 'YES'
......
......@@ -19,12 +19,14 @@ DEPENDENCIES:
- OBSlider (= 1.1.0)
- RESideMenu (~> 4.0.7)
- SSKeychain (~> 1.2.2)
- upnpx (~> 1.3.4)
- upnpx (from `vendor/upnpx.podspec`)
EXTERNAL SOURCES:
box-ios-sdk-v2:
:commit: d2df30aa5f76d30910e06f3ef5aff49025de3cf1
:git: git://github.com/carolanitz/box-ios-sdk-v2.git
upnpx:
:podspec: vendor/upnpx.podspec
CHECKOUT OPTIONS:
box-ios-sdk-v2:
......@@ -39,6 +41,6 @@ SPEC CHECKSUMS:
OBSlider: 490f108007bfdd5414a38650b211fe403a95b8a0
RESideMenu: f24c508404b49c667344c54aba7e590883533958
SSKeychain: 88767e903ee8d274ed380e364d96b7a101235286
upnpx: 790dcf9598818385d881ca39a5b77b184b7d291a
upnpx: a480f282159960290fc2a620c7937a785b3e4b82
COCOAPODS: 0.38.2
COCOAPODS: 0.39.0.beta.4
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder.AppleTV.Storyboard" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
<document type="com.apple.InterfaceBuilder.AppleTV.Storyboard" version="3.0" toolsVersion="9046" systemVersion="14F27" targetRuntime="AppleTV" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="49e-Tb-3d3">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9035"/>
</dependencies>
<scenes>
<!--First-->
<scene sceneID="hNz-n2-bh7">
<objects>
<viewController id="9pv-A4-QxB" customClass="FirstViewController" customModuleProvider="" sceneMemberID="viewController">
<viewController id="9pv-A4-QxB" customClass="FirstViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Ia1-K6-d13"/>
<viewControllerLayoutGuide type="bottom" id="4ug-Mw-9AY"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="tsR-hK-woN">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<rect key="frame" x="0.0" y="0.0" width="1285" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="First View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="KQZ-1w-vlD">
<rect key="frame" x="884" y="519" width="153" height="43"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" text="First View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="KQZ-1w-vlD">
<rect key="frame" x="566" y="519" width="153" height="43"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by FirstViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L">
<rect key="frame" x="863" y="570" width="194" height="17"/>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="Loaded by FirstViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L">
<rect key="frame" x="545" y="570" width="194" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
......@@ -44,45 +44,111 @@
</objects>
<point key="canvasLocation" x="2246" y="-640"/>
</scene>
<!--Second-->
<scene sceneID="wg7-f3-ORb">
<!--UPnP Servers-->
<scene sceneID="hqD-9z-56O">
<objects>
<viewController id="8rJ-Kc-sve" customClass="SecondViewController" customModuleProvider="" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="L7p-HK-0SC"/>
<viewControllerLayoutGuide type="bottom" id="Djb-ko-YwX"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="QS5-Rx-YEW">
<tableViewController title="UPnP Servers" id="l98-N5-BW4" customClass="VLCUPnPTableViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="66" sectionHeaderHeight="40" sectionFooterHeight="40" id="kY9-yU-BbX">
<rect key="frame" x="0.0" y="0.0" width="1920" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Second View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="zEq-FU-wV5">
<rect key="frame" x="857" y="519" width="207" height="43"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<fontDescription key="fontDescription" type="system" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by SecondViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NDk-cv-Gan">
<rect key="frame" x="853" y="570" width="215" height="17"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="NDk-cv-Gan" firstAttribute="top" secondItem="zEq-FU-wV5" secondAttribute="bottom" constant="8" symbolic="YES" id="Day-4N-Vmt"/>
<constraint firstItem="NDk-cv-Gan" firstAttribute="centerX" secondItem="zEq-FU-wV5" secondAttribute="centerX" id="JgO-Fn-dHn"/>
<constraint firstAttribute="centerX" secondItem="zEq-FU-wV5" secondAttribute="centerX" id="qqM-NS-xev"/>
<constraint firstAttribute="centerY" secondItem="zEq-FU-wV5" secondAttribute="centerY" id="qzY-Ky-pLD"/>
</constraints>
</view>
<tabBarItem key="tabBarItem" title="Second" image="second" id="cPa-gy-q4n"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4Nw-L8-lE0" sceneMemberID="firstResponder"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" misplaced="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="networkCell" textLabel="fCo-1K-Ebm" style="IBUITableViewCellStyleDefault" id="trs-hJ-cZc">
<rect key="frame" x="0.0" y="199" width="1890" height="66"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="trs-hJ-cZc" id="ar8-vf-oi9">
<rect key="frame" x="0.0" y="0.0" width="1904" height="66"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="fCo-1K-Ebm">
<rect key="frame" x="20" y="0.0" width="1864" height="66"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="38"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="0ks-xH-ETi" kind="showDetail" identifier="showUPnP" id="YcH-QE-2ZU"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="l98-N5-BW4" id="wBL-pa-Te3"/>
<outlet property="delegate" destination="l98-N5-BW4" id="N44-o0-TkQ"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Root View Controller" id="GMH-kj-ibJ"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="B3d-jh-T2A" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="4473" y="971"/>
</scene>
<!--PnP Server List View Controller-->
<scene sceneID="OBK-SU-dHU">
<objects>
<tableViewController id="0ks-xH-ETi" customClass="VLCUPnPServerListViewController" sceneMemberID="viewController">
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="114" sectionHeaderHeight="40" sectionFooterHeight="40" id="cXC-lh-KTv">
<rect key="frame" x="0.0" y="0.0" width="1285" height="1080"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<prototypes>
<tableViewCell contentMode="scaleToFill" misplaced="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" textLabel="oOt-aH-Ecu" detailTextLabel="7H1-T6-1kJ" rowHeight="114" style="IBUITableViewCellStyleSubtitle" id="v8b-3V-RZq">
<rect key="frame" x="0.0" y="54" width="1255" height="114"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="v8b-3V-RZq" id="d4Q-nN-fAJ">
<rect key="frame" x="0.0" y="0.0" width="1269" height="114"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="oOt-aH-Ecu">
<rect key="frame" x="20" y="11" width="72" height="46"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="38"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="7H1-T6-1kJ">
<rect key="frame" x="20" y="57" width="96" height="46"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="38"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="0.40000000000000002" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
<connections>
<segue destination="0ks-xH-ETi" kind="showDetail" identifier="showUPnP" id="v9H-aw-ONv"/>
</connections>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="0ks-xH-ETi" id="rbp-BK-nfH"/>
<outlet property="delegate" destination="0ks-xH-ETi" id="UFr-m6-z3D"/>
</connections>
</tableView>
<connections>
<segue destination="9pv-A4-QxB" kind="showDetail" identifier="showFromURL" id="qBl-Cg-wao"/>
</connections>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="uuI-oS-t6D" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="6749.5" y="823"/>
</scene>
<!--UPnP-->
<scene sceneID="nbe-Rs-i7W">
<objects>
<navigationController id="dbV-0x-zND" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="UPnP" id="lqh-dx-hws"/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="Efb-0S-Scn">
<rect key="frame" x="0.0" y="0.0" width="1920" height="145"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
<segue destination="l98-N5-BW4" kind="relationship" relationship="rootViewController" id="P5a-8W-lWp"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="hss-2b-7v2" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2246" y="624"/>
<point key="canvasLocation" x="2293" y="957"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="yl2-sM-qoP">
......@@ -96,16 +162,19 @@
</tabBar>
<connections>
<segue destination="9pv-A4-QxB" kind="relationship" relationship="viewControllers" id="u7Y-xg-7CH"/>
<segue destination="8rJ-Kc-sve" kind="relationship" relationship="viewControllers" id="lzU-1b-eKA"/>
<segue destination="dbV-0x-zND" kind="relationship" relationship="viewControllers" id="C5j-XM-hh1"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="0.0" y="0.0"/>
<point key="canvasLocation" x="82" y="326"/>
</scene>
</scenes>
<resources>
<image name="first" width="30" height="30"/>
<image name="second" width="30" height="30"/>
</resources>
<inferredMetricsTieBreakers>
<segue reference="YcH-QE-2ZU"/>
<segue reference="qBl-Cg-wao"/>
</inferredMetricsTieBreakers>
</document>
......@@ -12,7 +12,7 @@
#import <UIKit/UIKit.h>
@interface FirstViewController : UIViewController
@property (nonatomic, strong) NSURL *url;
@end
......@@ -19,7 +19,10 @@
@end
@implementation FirstViewController
- (void)awakeFromNib {
[super awakeFromNib];
self.url = [NSURL URLWithString:@"http://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4"];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
......@@ -34,7 +37,7 @@
_mediaplayer.drawable = self.view;
/* create a media object and give it to the player */
_mediaplayer.media = [VLCMedia mediaWithURL:[NSURL URLWithString:@"http://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4"]];
_mediaplayer.media = [VLCMedia mediaWithURL:self.url];
[_mediaplayer play];
}
......
......@@ -28,5 +28,10 @@
<array>
<string>arm64</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
/*****************************************************************************
* VLCUPnPServerListViewController.h
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Author: Felix Paul Kühne <fkuehne # videolan.org>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "SecondViewController.h"
#import "VLCNetworkListViewController.h"
@interface SecondViewController ()
@class MediaServer1Device;
@end
@implementation SecondViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
@interface VLCUPnPServerListViewController : UITableViewController
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)configureWithUPNPDevice:(MediaServer1Device *)device header:(NSString *)header andRootID:(NSString *)rootID;
@end
/*****************************************************************************
* VLCUPnPServerListViewController.m
* VLC for iOS
*****************************************************************************
* Copyright (c) 2013-2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Marc Etcheverry <marc@taplightsoftware.com>
* Pierre SAGASPE <pierre.sagaspe # me.com>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCUPnPServerListViewController.h"
#import "NSString+SupportedMedia.h"
#import "MediaServerBasicObjectParser.h"
#import "MediaServer1ItemObject.h"
#import "MediaServer1ContainerObject.h"
#import "MediaServer1Device.h"
#import "BasicUPnPDevice+VLC.h"
#import <upnpx/UPnPManager.h>
#import "FirstViewController.h"
@interface VLCUPnPServerListViewController () <UITableViewDataSource, UITableViewDelegate>
{
MediaServer1Device *_UPNPdevice;
NSString *_UPNProotID;
NSMutableArray *_mutableObjectList;
NSMutableArray *_searchData;
MediaServer1ItemObject *_lastSelectedMediaItem;
UIView *_resourceSelectionActionSheetAnchorView;
}
@end
@implementation VLCUPnPServerListViewController
- (void)configureWithUPNPDevice:(MediaServer1Device*)device header:(NSString*)header andRootID:(NSString*)rootID
{
_UPNPdevice = device;
self.title = header;
_UPNProotID = rootID;
}
- (void)viewDidLoad
{
[super viewDidLoad];
_mutableObjectList = [[NSMutableArray alloc] init];
NSString *sortCriteria = @"";
NSMutableString *outSortCaps = [[NSMutableString alloc] init];
[[_UPNPdevice contentDirectory] GetSortCapabilitiesWithOutSortCaps:outSortCaps];
if ([outSortCaps rangeOfString:@"dc:title"].location != NSNotFound)
{
sortCriteria = @"+dc:title";
}
NSMutableString *outResult = [[NSMutableString alloc] init];
NSMutableString *outNumberReturned = [[NSMutableString alloc] init];
NSMutableString *outTotalMatches = [[NSMutableString alloc] init];
NSMutableString *outUpdateID = [[NSMutableString alloc] init];
[[_UPNPdevice contentDirectory] BrowseWithObjectID:_UPNProotID BrowseFlag:@"BrowseDirectChildren" Filter:@"*" StartingIndex:@"0" RequestedCount:@"0" SortCriteria:sortCriteria OutResult:outResult OutNumberReturned:outNumberReturned OutTotalMatches:outTotalMatches OutUpdateID:outUpdateID];
[_mutableObjectList removeAllObjects];
NSData *didl = [outResult dataUsingEncoding:NSUTF8StringEncoding];
MediaServerBasicObjectParser *parser;
@synchronized(self) {
parser = [[MediaServerBasicObjectParser alloc] initWithMediaObjectArray:_mutableObjectList itemsOnly:NO];
}
[parser parseFromData:didl];
}
#pragma mark - table view data source, for more see super
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _mutableObjectList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
MediaServer1BasicObject *item;
item = _mutableObjectList[indexPath.row];
if (![item isContainer]) {
MediaServer1ItemObject *mediaItem;
long long mediaSize = 0;
unsigned int durationInSeconds = 0;
unsigned int bitrate = 0;
MediaServer1ItemRes *resource = nil;
NSEnumerator *e = [[mediaItem resources] objectEnumerator];
while((resource = (MediaServer1ItemRes*)[e nextObject])){
if (resource.bitrate > 0 && resource.durationInSeconds > 0) {
mediaSize = resource.size;
durationInSeconds = resource.durationInSeconds;
bitrate = resource.bitrate;
}
}
if (mediaSize < 1)
mediaSize = [mediaItem.size longLongValue];
if (mediaSize < 1)
mediaSize = (bitrate * durationInSeconds);
// object.item.videoItem.videoBroadcast items (like the HDHomeRun) may not have this information. Center the title (this makes channel names look better for the HDHomeRun)
if (mediaSize > 0 && durationInSeconds > 0) {
[cell.detailTextLabel setText: [NSString stringWithFormat:@"%@ (%@)", [NSByteCountFormatter stringFromByteCount:mediaSize countStyle:NSByteCountFormatterCountStyleFile], [VLCTime timeWithInt:durationInSeconds * 1000].stringValue]];
}
// Custom TV icon for video broadcasts
if ([[mediaItem objectClass] isEqualToString:@"object.item.videoItem.videoBroadcast"]) {
UIImage *broadcastImage;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
broadcastImage = [UIImage imageNamed:@"TVBroadcastIcon"];
} else {
broadcastImage = [UIImage imageNamed:@"TVBroadcastIcon~ipad"];
}
cell.imageView.image = broadcastImage;
} else {
cell.imageView.image = [UIImage imageNamed:@"blank"];
}
} else {
cell.imageView.image = [UIImage imageNamed:@"folder"];
}
cell.textLabel.text = [item title];
return cell;
}
#pragma mark - table view delegate, for more see super
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MediaServer1BasicObject *item;
item = _mutableObjectList[indexPath.row];
if ([item isContainer]) {
MediaServer1ContainerObject *container;
container = _mutableObjectList[indexPath.row];
[self performSegueWithIdentifier:@"showUPnP" sender:container];
} else {
MediaServer1ItemObject *mediaItem;
mediaItem = _mutableObjectList[indexPath.row];
NSURL *itemURL;
NSArray *uriCollectionKeys = [[mediaItem uriCollection] allKeys];
NSUInteger count = uriCollectionKeys.count;
NSRange position;
NSUInteger correctIndex = 0;
NSUInteger numberOfDownloadableResources = 0;
for (NSUInteger i = 0; i < count; i++) {
position = [uriCollectionKeys[i] rangeOfString:@"http-get:*:video/"];
if (position.location != NSNotFound) {
correctIndex = i;
numberOfDownloadableResources++;
}
}
NSArray *uriCollectionObjects = [[mediaItem uriCollection] allValues];
// Present an action sheet for the user to choose which URI to download. Do not deselect the cell to provide visual feedback to the user
if (numberOfDownloadableResources > 1) {
_resourceSelectionActionSheetAnchorView = [tableView cellForRowAtIndexPath:indexPath];
// [self presentResourceSelectionActionSheetForUPnPMediaItem:mediaItem forDownloading:NO];
} else {
if (uriCollectionObjects.count > 0) {
itemURL = [NSURL URLWithString:uriCollectionObjects[correctIndex]];
}
if (itemURL) {
[self performSegueWithIdentifier:@"showFromURL" sender:itemURL];
}
}
}
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showUPnP"]) {
MediaServer1ContainerObject *container = sender;
[(VLCUPnPServerListViewController *)segue.destinationViewController configureWithUPNPDevice:_UPNPdevice header:[container title] andRootID:[container objectID]];
} else if ([segue.identifier isEqualToString:@"showFromURL"]) {
[(FirstViewController *)segue.destinationViewController setUrl:sender];
}
}
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender {
if ([sender isKindOfClass:[UITableViewCell class]]) {
return false;
}
return true;
}
@end
......@@ -4,15 +4,13 @@
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne # videolan.org>
* Authors: Tobias Conradi <videolan@tobias-conradi.de>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
@interface VLCUPnPTableViewController : UITableViewController
@end
/*****************************************************************************
* VLC for iOS
*****************************************************************************
* Copyright (c) 2015 VideoLAN. All rights reserved.
* $Id$
*
* Authors: Tobias Conradi <videolan@tobias-conradi.de>
*
* Refer to the COPYING file of the official project for license.
*****************************************************************************/
#import "VLCUPnPTableViewController.h"
#import <upnpx/UPnPManager.h>
#import "VLCUPnPServerListViewController.h"
@interface VLCUPnPTableViewController () <UPnPDBObserver>
{
NSArray *_filteredUPNPDevices;
NSArray *_UPNPdevices;
BOOL _udnpDiscoveryRunning;
NSTimer *_searchTimer;
BOOL _setup;
}
@end
@implementation VLCUPnPTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}